Can not upload to Raspberry Pi Pico

My board is a Raspberry Pi Pico.
It opens a disk with "INDEX.HTM" and "INFO_UF2.TXT", so I suppose the board is working.

I followed what was written here: https://github.com/earlephilhower/arduino-pico#uploading-sketches

But I get:

rp2040load 1.0.1 - compiled with go1.15.8
.....................
Upload error: Error: 2 UNKNOWN: uploading error: uploading error: exit status 1

I can't find a way to get beyond that point.
What else can I try ?

Arduino IDE 2.0.0-beta.8
Board: Arduino Mbed OS RP2040 Boards / Raspberry Pi Pico
OS: linux

Then I tried to put the UF2 file on it as described here: https://www.raspberrypi.org/documentation/rp2040/getting-started/#getting-started-with-c.
That starts to blink the led, but it should also open a Serial port. However, there is no Serial port.

[Update] It seems to be a driver problem in linux.
In Windows the Raspberry Pi Pico does create a serial port. I can successfully upload a sketch, but that is all, the sketch does no run.
When I go to linux after that, then the serial port is still there (/dev/ttyACM0), but I can not upload a sketch and when I try that, the serial port disappears.

[Update 2] I installed the file "~/.arduino15/packages/arduino/hardware/mbed_rp2040/2.2.0/post_install.sh", and now I have a serial port in linux and no errors when uploading. However, just as in Windows, the sketch does not run.

What is the sketch?

Hi,
Did you turn it OFF then ON? again?
giphy (1)

Tom... :smiley: :+1: :coffee: :australia:
PS. I'm awaiting my Pi Pico in the mail somewhere.

Any sketch, even the Blink example did not work.

Finally, I got it working :sweat_smile: Here's how I did it.

Start with Windows 10:

  • Download the 2.0 Beta exe-file and install it.
  • Turn on Verbose mode for Upload in the Preferences.
  • Add the Raspberry Pi Pico board.
  • Use the sketch below.
  • Connect the Pico board.
  • If there is no COM port yet, then the upload process will choose the file system. Everything should go automatically.
  • If that does not work, drop the UF2 file from here onto the Pico "disk", then at lease the led should blink.
  • If the Pico "disk" is not shown, keep the BOOTSEL button pressed and connect the Pico board to the computer. When the Pico "disk" is connected, release the button.

In linux I did this:

  • Make it work in Windows 10 first.
  • If a modemmanager is installed, remove it.
  • Type groups in a terminal, the dialout must be part of it.
  • Download the 64-bit linux version of the 2.0 Beta and unpack it somewhere in a local folder.
  • Add the Pico board.
  • Turn on Verbose mode for Upload in the Preferences. Close the Arduino IDE.
  • Run the script as sudo: "~/.arduino15/packages/arduino/hardware/mbed_rp2040/2.2.0/post_install.sh". If you see a error message "post_install.sh: 12: [: Illegal number:", ignore it.
  • Start the Arduino IDE 2.0 Beta and connect the Pico board.
  • The serial port of the Pico board programmed in Windows does not work in linux. Use the BOOTSEL. Keep it pressed when connecting to the computer. Upload the sketch and it will use the filesystem. Only after that, it will upload via the new serial port /dev/ttyACM0
  • There will be many errors about serial ports, ignore them.
  • If there are still problems, then try again next day. The next day if might suddenly work better or worse.

This is the sketch that works in Windows and linux with or without the Arduino IDE.

// Raspberry Pi Pico with Arduino IDE 2.0.0-beta.8
// Test sketch

unsigned long previousMillisBlink;
unsigned long intervalBlink = 150;
unsigned long previousMillisTime;
const unsigned long intervalTime = 1000;

bool useSerial = true;

void setup() 
{
  pinMode(LED_BUILTIN, OUTPUT);

  // Wait for the Serial Monitor to be open.
  // But don't wait forever to let it run with just power.
  unsigned long t1 = millis();
  while(!Serial)    // Serial or SerialUSB, they are the same thing
  {
    if( millis() - t1 >= 2000)   // 2 seconds should be enough
    {
      useSerial = false;
      intervalBlink = 50;
      break;
    }
  }

  Serial.begin( 115200);

  // this delay was required during testing before the first Serial.println()
  // In Windows a delay of 200ms is required, in linux 500ms.
  delay( 500);      

  if( useSerial)
  {
    Serial.println( "The sketch has started");
    Serial.println( "Sketch compile time: " __DATE__ ", " __TIME__);
  }
}

void loop() 
{
  unsigned long currentMillis = millis();

  if( currentMillis - previousMillisBlink >= intervalBlink)
  {
    previousMillisBlink = currentMillis;

    // A digitalRead() on a output pin works.
    int ledState = digitalRead( LED_BUILTIN);
    ledState = ledState == HIGH ? LOW : HIGH;
    digitalWrite(LED_BUILTIN, ledState);
  }

  if( currentMillis - previousMillisTime >= intervalTime)
  {
    previousMillisTime += intervalTime;
 
    unsigned long seconds = millis() / 1000UL;   // works for the first 50 days

    if( useSerial)
    {
      if( seconds % 16 == 0)
        Serial.println();

      Serial.print( seconds);
      Serial.print( ", ");
    }
  }
}

[EDIT] Added a Serial.begin

Hi,
Did you try IDE 1.8.15 rater than the 2.0 beta whatever it is?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Yes, I tried that before, that was when everything went wrong.
You can get the 2.0 Beta here: https://www.arduino.cc/en/software#experimental-software.
Both the 1.8.15 and the 2.0 Beta can be used without bad changes to configuration files. That layer is almost identical.

Hi,
I have the beta running here too.
My Pi Pico should arrive today, could only order one.
Local supplier has a purchase limit on them due to the silli shortage.

Tom... :smiley: :+1: :coffee: :australia:

Is this the only sketch that works, or are you now able to run any sketch you like (e.g., the standard Blink)?

@pert The Blink example works. I can even do a digitalRead() on a output pin.

Building the binary is faster in linux.

My sketch was missing a "Serial.begin()", fixed it.

I have not tested peripherals, but so far everything seems to run.

I thought that the included Scheduler would work, but no luck yet.

There is a glitch in the Arduino IDE 2.0.0-beta.8. The serial monitor is cleared after uploading, but the Pico board is already sending text. That is why a delay is needed.

The Scheduler works, I had a library conflict.

Updating via the serial port has almost stopped working in linux. I have to disconnect and connect with the button pressed for every upload.
There are many error messages in the Arduino IDE, and if I try to upload using the serial port, then linux is showing error messages about the mounted media (Pico disk). Because of that the Serial Monitor in the Arduino IDE does not connect to the Pico.

Conclusion: Working in Windows, not so much in linux.