0

rp2040 itsy bitsy with Arduino IDE keeps showing up as drive
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

rp2040 itsy bitsy with Arduino IDE keeps showing up as drive

by mhuster on Tue Aug 03, 2021 11:07 am

I followed the directions https://learn.adafruit.com/rp2040-ardui ... e?view=all, but uploads are failing with the message below.
I am running Windows 10. The first time I plugged the I-B RP2040 in, I held the BOOT button down as directed. The code successfully uploaded. The web page says, "You only need manually to enter the bootloader the first time you load an Arduino sketch onto your Pico. It is not necessary to manually enter the bootloader to load subsequent sketches once you are already running an Arduino sketch."
However following uploads failed. I did see the file explorer pop a window for RPI-RP2 (D:). Then a file NEW.UF2 showed up, then the File Explorer window closed on its own. There was no output to the Arduino Serial Monitor.
When I unplug the RP, the COM6 device goes away; when I plug it back in the same COM6 device shows back up. When I hold BOOT and plug it in, no COM device shows up, but RPI-RP2 (D:) drive does.

Very frustrated!

Code: Select all | TOGGLE FULL SIZE
Arduino: 1.8.13 (Windows 10), TD: 1.53, Board: "Adafruit ItsyBitsy RP2040, 8MB (no FS), 125 MHz, Disabled, None, Pico SDK"
Sketch uses 58824 bytes (0%) of program storage space. Maximum is 8384512 bytes.
Global variables use 11660 bytes (4%) of dynamic memory, leaving 250484 bytes for local variables. Maximum is 262144 bytes.
Resetting COM6
Converting to uf2, output size: 132096, start address: 0x2000
Flashing D: (RPI-RP2)
Wrote 132096 bytes to D:/NEW.UF2
processing.app.SerialException: Error opening serial port 'COM6'.
   at processing.app.Serial.<init>(Serial.java:154)
   at processing.app.Serial.<init>(Serial.java:82)
   at processing.app.SerialMonitor$2.<init>(SerialMonitor.java:132)
   at processing.app.SerialMonitor.open(SerialMonitor.java:132)
   at processing.app.AbstractMonitor.resume(AbstractMonitor.java:132)
   at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2148)
   at processing.app.Editor.access$1300(Editor.java:117)
   at processing.app.Editor$UploadHandler.run(Editor.java:2105)
   at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - COM6; Method name - openPort(); Exception type - Port not found.
   at jssc.SerialPort.openPort(SerialPort.java:167)
   at processing.app.Serial.<init>(Serial.java:143)
   ... 8 more
Error opening serial port 'COM6'.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

mhuster
 
Posts: 4
Joined: Thu Apr 06, 2017 7:25 am

Re: rp2040 itsy bitsy with Arduino IDE keeps showing up as d

by adafruit_support_carter on Tue Aug 03, 2021 4:28 pm

What was the code you upload the first time that worked?

If you try the manual bootloader approach again, does that work each time? In general - can you repeat your initial success just as sanity check?

adafruit_support_carter
 
Posts: 21122
Joined: Tue Nov 29, 2016 2:45 pm

Re: rp2040 itsy bitsy with Arduino IDE keeps showing up as d

by mhuster on Wed Aug 04, 2021 10:04 am

I tried the initial approach of holding down BOOT when plugging it in, then releasing it. I got the same results. it pops up a file explorer for RPI-RP2 (D:). I got the same result with and without holding the BOOT button down.

The code is for running the Adafruit Ultrasonic Distance Sensor - 3V or 5V - HC-SR04 compatible - RCWL-1601.
Code: Select all | TOGGLE FULL SIZE
/*
 * Full tutorial and explanation at pimylifeup.com
 */
 
int trigger_pin = 7;
int echo_pin = 9;
long pulse_duration;
float distance;
 
void setup() {

  //Start serial output
  Serial.begin(115200);
  while (!Serial) ; // Wait for serial port to be available

  static char fName[] = __FILE__;
  int iF = 0;
  for(iF = sizeof(fName)-2; fName[iF] != '\\' && iF; iF--)
    ;
  Serial.println(__FILE__+(iF+1));

 
  //Set pinMode
  pinMode(trigger_pin, OUTPUT);
  pinMode(echo_pin, INPUT);

  //Set the trigger pin to low
  digitalWrite(trigger_pin, LOW);
}
 
void loop() {
  static int iLoop = 0;
  //Set pin to high for 10 microseconds
  digitalWrite(trigger_pin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigger_pin, LOW);
 
  //Check the echo pin for when it goes high and save the time it took in microseconds)
  pulse_duration = pulseIn(echo_pin, HIGH);
 
  // Convert the time into a distance (cm)
  // Math: distance = ( (duration) * (speed of sound in cm per microsecond 0.0343 / 2)
  distance = pulse_duration * 0.0171;

  //convert the time into a distance (inches)
  // Math: distance = ( (duration) * (speed of sound in inches per microsecond 0.01350 / 2)
  //distance = round(pulse_duration/0.00675);

  Serial.print("Loop ");
  Serial.print(iLoop++);
  Serial.print(", Distance = ");
  Serial.print(distance);
  Serial.print(" cm     \n");

  delay(200);
}

mhuster
 
Posts: 4
Joined: Thu Apr 06, 2017 7:25 am

Re: rp2040 itsy bitsy with Arduino IDE keeps showing up as d

by mhuster on Wed Aug 04, 2021 10:31 am

Today it is working, but weird as I describe below. Without holding BOOT, when I upload code it still pops up the File Explorer for a few seconds, then resets.
I still get the error/info message
Code: Select all | TOGGLE FULL SIZE
Resetting COM6
Converting to uf2, output size: 133120, start address: 0x2000
Flashing D: (RPI-RP2)
Wrote 133120 bytes to D:/NEW.UF2

Then a lot of error/traceback code ending with
Code: Select all | TOGGLE FULL SIZE
Error opening serial port 'COM6'.


Another odd thing is that the I leave the Serial Monitor open the whole time and no new output in the Serial Monitor. However when I close the Serial Monitor and reopen it, the new code runs. The RST (reset) button on the RP does not do anything I can see.
I think the previous uploads were working, but because I didn't close and reopen the Serial Monitor, I could not tell; the output just froze.
When I use putty, the new sketch is there. When I press RST, Putty pops "Error reading from serial device." When I click OK, the session is frozen. When I restart the session, the RP resets then and starts anew.

Should pressing the RST on the RP cause a reset and output to the Serial Monitor?
Why doesn't the RP reset until I restart a com session with either Arduino IDE, or putty?

mhuster
 
Posts: 4
Joined: Thu Apr 06, 2017 7:25 am

Re: rp2040 itsy bitsy with Arduino IDE keeps showing up as d

by adafruit_support_carter on Wed Aug 04, 2021 10:40 am

I think what you are seeing is the expected behavior. For the RP2040 board, the way the upload works is something like:
  • Compile Arduino sketch to .bin file (same as done with any Arduino board)
  • Convert .bin file to .uf2 file
  • Reset the RP2040 board so it goes into bootloader mode (RPI-RP2 folder shows up)
  • Copy .uf2 file to RPI-RP2 folder
  • Once copy is complete, board resets again to run uploaded code

So this output looks OK:
Code: Select all | TOGGLE FULL SIZE
Resetting COM6
Converting to uf2, output size: 133120, start address: 0x2000
Flashing D: (RPI-RP2)
Wrote 133120 bytes to D:/NEW.UF2


Since there are several resets involved, your computer is reacting each time. Also, you can't keep a serial monitor connected during upload since the resets will kill the connection. Additionally, it may show up on a different COM port when it shows up again (windows mainly does this).

Should pressing the RST on the RP cause a reset and output to the Serial Monitor?

Yes. Although if it also changes to a new COM port after reset, the currently open Serial Monitor may stop working. In general, close any open Serial Monitors before uploading.

Why doesn't the RP reset until I restart a com session with either Arduino IDE, or putty?

The sketch may have a loop that waits until a Serial Monitor is opened? A line that looks something like:
Code: Select all | TOGGLE FULL SIZE
while (!Serial);


So it seems like this is all working. Just maybe keep playing with it to get used to all the stuff that happens during an upload and the potential quirks that can also happen in the process.

adafruit_support_carter
 
Posts: 21122
Joined: Tue Nov 29, 2016 2:45 pm

Re: rp2040 itsy bitsy with Arduino IDE keeps showing up as d

by mhuster on Thu Aug 05, 2021 8:43 am

Thank you for your very thorough answer!
I am comparing the RP2040 to other microcontrollers, so it has been a bit confusing.

mhuster
 
Posts: 4
Joined: Thu Apr 06, 2017 7:25 am

Please be positive and constructive with your questions and comments.