[Arduino RP4020 Connect] Upload Error

Hi

I am trying to upload program to my “Arduino RP4020 Connect” on Windows.
The problem is that upload keeps failing.

Below codes are for platform.ini and upload error messages.

Please help me out.

[env:nanorp2040connect]
platform = raspberrypi
board = nanorp2040connect
framework = arduino

upload_port = D:\
Processing nanorp2040connect (platform: raspberrypi; board: nanorp2040connect; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/raspberrypi/nanorp2040connect.html
PLATFORM: Raspberry Pi RP2040 (1.5.0) > Arduino Nano RP2040 Connect
HARDWARE: RP2040 133MHz, 264KB RAM, 2MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, jlink, raspberrypi-swd)
PACKAGES:
 - framework-arduino-mbed 2.6.1
 - tool-openocd-raspberrypi 2.1100.0 (11.0)
 - tool-rp2040tools 1.0.2
 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 31 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\nanorp2040connect\src\main.cpp.o
Generating LD script .pio\build\nanorp2040connect\cpp.linker_script.ld
Compiling .pio\build\nanorp2040connect\FrameworkArduinoVariant\double_tap_usb_boot.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduinoVariant\nina_pins.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduinoVariant\variant.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\Interrupts.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\Serial.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\Tone.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\USB\PluggableUSBDevice.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\USB\USBCDC.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\USB\USBSerial.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\abi.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\api\Common.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\api\IPAddress.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\api\PluggableUSB.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\api\Print.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\api\Stream.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\api\String.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\arm_hal_random.c.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\as_mbed_library\variant.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\itoa.c.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\main.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\mbed\platform\cxxsupport\mstd_mutex.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\pinToIndex.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\wiring.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\wiring_analog.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\wiring_digital.cpp.o
In file included from C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2040/hardware_regs/include/hardware/platform_defs.h:12,
                 from C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/pico_platform/include/pico/platform.h:12,
                 from C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/common/pico_base/include/pico.h:19,
                 from C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\variants\NANO_RP2040_CONNECT\double_tap_usb_boot.cpp:2:
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/hardware_timer/include/hardware/timer.h: In function 'uint32_t time_us_32()':
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2040/hardware_regs/include/hardware/regs/addressmap.h:56:20: warning: type qualifiers ignored on cast result type [-Wignored-qualifiers]
   56 | #define TIMER_BASE 0x40054000
      |                    ^~~~~~~~~~
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2040/hardware_structs/include/hardware/structs/timer.h:33:38: note: in expansion of macro 'TIMER_BASE'
   33 | #define timer_hw ((timer_hw_t *const)TIMER_BASE)
      |                                      ^~~~~~~~~~
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/hardware_timer/include/hardware/timer.h:66:12: note: in 
expansion of macro 'timer_hw'
   66 |     return timer_hw->timerawl;
      |            ^~~~~~~~
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/hardware_timer/include/hardware/timer.h: In function 'bool time_reached(absolute_time_t)':
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2040/hardware_regs/include/hardware/regs/addressmap.h:56:20: warning: type qualifiers ignored on cast result type [-Wignored-qualifiers]
   56 | #define TIMER_BASE 0x40054000
      |                    ^~~~~~~~~~
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2040/hardware_structs/include/hardware/structs/timer.h:33:38: note: in expansion of macro 'TIMER_BASE'
   33 | #define timer_hw ((timer_hw_t *const)TIMER_BASE)
      |                                      ^~~~~~~~~~
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/hardware_timer/include/hardware/timer.h:110:19: note: in expansion of macro 'timer_hw'
  110 |     uint32_t hi = timer_hw->timerawh;
      |                   ^~~~~~~~
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2040/hardware_regs/include/hardware/regs/addressmap.h:56:20: warning: type qualifiers ignored on cast result type [-Wignored-qualifiers]
   56 | #define TIMER_BASE 0x40054000
      |                    ^~~~~~~~~~
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2040/hardware_structs/include/hardware/structs/timer.h:33:38: note: in expansion of macro 'TIMER_BASE'
   33 | #define timer_hw ((timer_hw_t *const)TIMER_BASE)
      |                                      ^~~~~~~~~~
C:\Users\totoy\.platformio\packages\framework-arduino-mbed@2.6.1\cores\arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/rp2_common/hardware_timer/include/hardware/timer.h:111:33: note: in expansion of macro 'timer_hw'
  111 |     return (hi >= hi_target && (timer_hw->timerawl >= (uint32_t) target || hi != hi_target));
      |                                 ^~~~~~~~
Compiling .pio\build\nanorp2040connect\FrameworkArduino\wiring_pulse.cpp.o
Compiling .pio\build\nanorp2040connect\FrameworkArduino\wiring_shift.cpp.o
Archiving .pio\build\nanorp2040connect\libFrameworkArduinoVariant.a
Archiving .pio\build\nanorp2040connect\libFrameworkArduino.a
Linking .pio\build\nanorp2040connect\firmware.elf
Generating UF2 image
elf2uf2 ".pio\build\nanorp2040connect\firmware.elf" ".pio\build\nanorp2040connect\firmware.uf2"
Checking size .pio\build\nanorp2040connect\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  15.3% (used 41360 bytes from 270336 bytes)
Flash: [          ]   0.2% (used 4038 bytes from 2097152 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, jlink, picotool, raspberrypi-swd
CURRENT: upload_protocol = picotool
Looking for upload port...
Use manually specified: D:\
Forcing reset using 1200bps open/close on port D:\
Uploading .pio\build\nanorp2040connect\firmware.elf
rp2040load 1.0.1 - compiled with go1.15.8
.....................
*** [upload] Error 1
====================================================================================== [FAILED] Took 52.18 seconds ======================================================================================

Copy this file on the Pico’s USB drive to flash the firmware once, then remove the upload_port = .. line. Does uploading work afterwards?

1 Like

Thank you so much.

You solution works perfectly.
I searched online to find out solution but I couldn’t find any related one.
How do you know it? It’s very interesting. :grinning: :grinning: :grinning:

I have a Raspberry Pi Pico myself and ran into this a few times, plus the conversation on Upload port required · Issue #2 · platformio/platform-raspberrypi · GitHub.

1 Like

Thanks a lot for your post!
Since I am just a Arduino beginner I do not really know where to put your little patch.
I am working with VS code. For a while everything was working just fine. But now, when verifying the code, the error message occurs… .(*** [.pio/build/nanorp2040connect/src/main.cpp.o] Error 1)
and I don’t know where to put your patch…
Thanks for your help in advance…

That’s a build error not an upload error.

We’d need to see your full code and error message to help.

Thanks for the quick reply!
Interestingly, the code is working without any problem on the Arduino IDE, however, when copying the code into Visual studio code, the code is not working; all the libraries are installed…
I used this code to test VS code…

#include <Arduino.h>
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>             // Arduino SPI library

// ST7789 TFT module connections
#define TFT_CS    10  // define chip select pin
#define TFT_DC     7  // define data/command pin
#define TFT_RST    8  // define reset pin, or set to -1 and connect to Arduino RESET pin

// Initialize Adafruit ST7789 TFT library
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

float p = 3.1415926;

// constants to set pin numbers:
const int buttonPin = 2;  // the number of the pushbutton pin
const int ledPin = 14;    // the number of the LED pin

// variables will change:
int buttonState = 0;  // variable for reading the pushbutton status

void setup(void) {

  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT_PULLUP);

  Serial.begin(9600);
  Serial.print(F("Moin! ST77xx TFT Test"));

  // the display has CS pin therfor with SPI_MODE0
  tft.init(135, 240, SPI_MODE0);    // Init ST7789 display 135x240 pixel

  // rotate screen in horizontal position, 
  tft.setRotation(1);
  tft.fillScreen(ST77XX_GREEN); // test screen
  delay (50);

  Serial.println(F("Initialized"));
// feststellen der Zeit, start systemzeit
  uint16_t time = millis();
  tft.fillScreen(ST77XX_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(1000);


  // optimized lines
  testfastlines(ST77XX_RED, ST77XX_BLUE);
  delay(500);

  testdrawrects(ST77XX_GREEN);
  delay(500);

  testfillrects(ST77XX_YELLOW, ST77XX_MAGENTA);
  delay(500);

  tft.fillScreen(ST77XX_BLACK);
  testfillcircles(10, ST77XX_BLUE);
  testdrawcircles(10, ST77XX_WHITE);
  delay(500);

  testroundrects();
  delay(1100);

  mediabuttons();
  delay(500);

  Serial.println("done");
  delay(1000);
}

void loop() {
  tft.invertDisplay(true);
  delay(1000);
  //tft.invertDisplay(false);
  //delay(500);

  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  if (buttonState==LOW){
    tft.fillTriangle(29, 12, 29, 42, 74, 27, ST77XX_BLUE);
    tft.fillRoundRect(32, 74, 14, 25, 5, ST77XX_GREEN);
    tft.fillRoundRect(50, 74, 14, 25, 5, ST77XX_GREEN);
    //turn Playbutton red:
  } else {
    tft.fillTriangle(29, 12, 29, 42, 74, 27, ST77XX_GREEN);
    tft.fillRoundRect(32, 74, 14, 25, 5, ST77XX_RED);
    tft.fillRoundRect(50, 74, 14, 25, 5, ST77XX_RED);
  }
  tft.setTextColor(ST77XX_MAGENTA);
  tft.setTextSize(2);
  tft.setCursor(150, 48);
  tft.print(millis() / 1000);
  tft.setCursor (150,48);
}

void testdrawtext(char *text, uint16_t color) {
  tft.setCursor(0, 0);
  tft.setTextColor(color);
  tft.setTextWrap(true);
  tft.print(text);
}

void testfastlines(uint16_t color1, uint16_t color2) {
  tft.fillScreen(ST77XX_BLACK);
  for (int16_t y=0; y < tft.height(); y+=5) {
    tft.drawFastHLine(0, y, tft.width(), color1);
  }
  for (int16_t x=0; x < tft.width(); x+=5) {
    tft.drawFastVLine(x, 0, tft.height(), color2);
  }
}

void testdrawrects(uint16_t color) {
  tft.fillScreen(ST77XX_BLACK);
  for (int16_t x=0; x < tft.width(); x+=6) {
    tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color);
  }
}

void testfillrects(uint16_t color1, uint16_t color2) {
  tft.fillScreen(ST77XX_BLACK);
  for (int16_t x=tft.width()-1; x > 6; x-=6) {
    tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color1);
    tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color2);
  }
}

void testfillcircles(uint8_t radius, uint16_t color) {
  for (int16_t x=radius; x < tft.width(); x+=radius*2) {
    for (int16_t y=radius; y < tft.height(); y+=radius*2) {
      tft.fillCircle(x, y, radius, color);
    }
  }
}

void testdrawcircles(uint8_t radius, uint16_t color) {
  for (int16_t x=0; x < tft.width()+radius; x+=radius*2) {
    for (int16_t y=0; y < tft.height()+radius; y+=radius*2) {
      tft.drawCircle(x, y, radius, color);
    }
  }
}



void testroundrects() {
  tft.fillScreen(ST77XX_BLACK);
  int color = 100;
  int i;
  int t;
  for(t = 0 ; t <= 4; t+=1) {
    int x = 0;
    int y = 0;
    int w = tft.width()-2;
    int h = tft.height()-2;
    for(i = 0 ; i <= 16; i+=1) {
      tft.drawRoundRect(x, y, w, h, 5, color);
      x+=2;
      y+=3;
      w-=4;
      h-=6;
      color+=1100;
    }
    color+=100;
  }
}

void tftPrintTest() {
  tft.setTextWrap(false);
  tft.fillScreen(ST77XX_BLACK);
  tft.setCursor(0, 30);
  tft.setTextColor(ST77XX_RED);
  tft.setTextSize(2);
  tft.println("IQ");
  tft.setTextColor(ST77XX_YELLOW);
  tft.setTextSize(2);
  tft.println("Smart");
  tft.setTextColor(ST77XX_GREEN);
  tft.setTextSize(3);
  tft.println("spot");
  tft.setTextColor(ST77XX_BLUE);
  tft.setTextSize(2);
  tft.print("Test");
  delay(5500);
  tft.setCursor(0, 0);
  tft.fillScreen(ST77XX_BLACK);
  tft.setTextColor(ST77XX_WHITE);
  tft.setTextSize(0);
  tft.println("Moin Moin!");
  tft.setTextSize(1);
  tft.setTextColor(ST77XX_GREEN);
  tft.print(p, 6);
  tft.println(" Es wird klappen!");
  tft.println(" ");
  tft.print(8675309, HEX); // print 8,675,309 out in HEX!
  tft.println(" Print HEX!");
  tft.println(" ");
  tft.setTextColor(ST77XX_WHITE);
  tft.println("Das Ding läuft");
  tft.println("seit: ");
  tft.setTextColor(ST77XX_MAGENTA);
  // run-time:
  tft.print(millis() / 1000);
  tft.setTextColor(ST77XX_WHITE);
  tft.print(" Sekunden.");
}

void mediabuttons() {
  // play
  tft.fillScreen(ST77XX_BLACK);
  tft.fillRoundRect(20, 10, 54, 35, 5, ST77XX_WHITE);
  // 1: Pusitioning x Achse; 2: Position Y Achse; 3: Ausdechnung X-Achse; 4: Ausdehnung Y-Achse; 5: Eckenabrundung
  tft.fillTriangle(29, 12, 29, 42, 74, 27, ST77XX_RED);
  delay(1000);
  // pause
  tft.fillRoundRect(20, 70, 54, 35, 5, ST77XX_WHITE);
  tft.fillRoundRect(32, 74, 14, 25, 5, ST77XX_GREEN);
  tft.fillRoundRect(50, 74, 14, 25, 5, ST77XX_GREEN);
  delay(200);
  // play color
 // tft.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_BLUE);
  delay(50);
  // pause color
  tft.fillRoundRect(32, 74, 14, 25, 5, ST77XX_RED);
  tft.fillRoundRect(50, 74, 14, 25, 5, ST77XX_RED);
  // play color
  tft.fillTriangle(29, 12, 29, 42, 74, 27, ST77XX_GREEN);
  // 1: position x1 ; 2: position Y1 3: position x2; 4 position y2; 5: x3; 6: y3 ; 
  delay (200);
}  


// this is to be continued -- no function so far:
void Leerstellen ( long Wert, int i, boolean Null){ 
  long k = 10;
  for (int j = 1; j<i;j++)
  {
    if (Wert<k)
    { if ( Null == 0 )
      { tft.print(" "); }
      else
      { tft.print("0"); }
    }
    k*=10; 
  }
  tft.print(Wert);
}

Assuming you’ve pasted this example as src/main.cpp into PlatformIO, it’s understandable that it doesn’t work, because the original examples is a .ino file and you didn’t any conversion to the source file as described per docs

https://docs.platformio.org/en/latest/faq/ino-to-cpp.html

So if you don’t wanna touch the code, just rename src/main.cppsrc/main.ino.

Oh, I totally forgot about the “language”
After renaming the file of src/main.ino. - the program is still not working.
I guess the problem is behind the computer - I still struggle to understand how PlattformIO and VsC works…
I think, I will stick with the Arduino IDE for a little longer. Plattform IO might be to complicated for me…
I was looking for a way to make coding and trouble shooting easier but I underestimated the complexity of VS studio code and PlatformIO. It quickly becomes very frustrating…
Do you know some good tutorials that cover the topics libraries these kind of problems?
Thanks a lot once again for your support!

Again, to help any further, I’d need to see both platformio.ini and the full error message.

Libraries are covered per

https://docs.platformio.org/en/latest/projectconf/sections/env/options/library/lib_deps.html#lib-deps