earlephilhower / arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 and RP2350 boards
GNU Lesser General Public License v2.1
2.03k stars 422 forks source link

Great job! Do you have a plan to adjust it for Platformio? #66

Closed vladkozlov69 closed 1 year ago

vladkozlov69 commented 3 years ago

Hello Earle,

your codebase looks really great. Do you have a plan to adjust it for Platformio? i.e. adding board definition and platformio-specific packages/platforms?

WaGi-Coding commented 2 years ago

I finally managed to upload, but unfortunately it cannot detect any networks, while it works fine with micropython.

Thats my main.cpp

#include <Arduino.h>
#include <WiFi.h>

void setup() { Serial.begin(115200); }

void loop() {
  Serial.println(WiFi.scanNetworks());
  delay(5000);
}

Thats my platformio.ini

[env:rpipicow]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = rpipicow
framework = arduino
board_build.core = earlephilhower

platform_packages =
    maxgerhardt/framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
    maxgerhardt/toolchain-pico@https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.4.0-c/x86_64-w64-mingw32.arm-none-eabi-0196c06.220714.zip

Thats the output:

0
0
0
...

With micropython i find a bunch of networks. VSC does not show any errors or warnings, i am lost ^^

earlephilhower commented 2 years ago

--edit-- Oops, funny typo... :laughing:

I just tested and the ScanNetworks example works fine, so I think you have a build problem. I'd dump the full compile commands and make sure you have the proper defines set.

Beginning scan at 188393
Found 9 networks

                            SSID   ENC     BSSID         CH RSSI
                                  WPA2 08:36:C9:87:C8:FF  9  -86
                                  WPA2 10:0C:6B:50:2D:EB  6  -92
                        JK-Guest  WPA2 12:36:C9:87:C8:FF  9  -86
                           Scout  WPA2 30:FD:38:FD:69:E2  6  -90
                        NOBABIES  WPA2 38:2C:4A:90:FA:80 10  -32
                       Grace4all  WPA2 4C:B1:CD:0D:2C:F8  6  -89
                        NOBABIES  WPA2 50:D4:F7:FE:A3:4D  1  -73
             ngHub_31946CN402774  WPA2 9C:3D:CF:F3:89:AF 11  -88
                        NOBABIES  AUTO AC:84:C6:6C:EF:F3  1  -60

--- Sleeping ---

A normal IDE compile line looks like:

/home/earle/.arduino15/packages/rp2040/tools/pqt-gcc/1.4.0-c-0196c06/bin/arm-none-eabi-g++ -c -Werror=return-type -DCFG_TUSB_MCU=OPT_MCU_RP2040 -DUSB_VID=0x2e8a -DUSB_PID=0xf00a "-DUSB_MANUFACTURER=\"Raspberry Pi\"" "-DUSB_PRODUCT=\"Pico W\"" -DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_LWIP=0 -DLWIP_IPV6=0 -DLWIP_IPV4=1 -DLWIP_IGMP=1 -DLWIP_CHECKSUM_CTRL_PER_NETIF=1 -march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -fno-exceptions -iprefix/home/earle/Arduino/hardware/pico/rp2040/ @/home/earle/Arduino/hardware/pico/rp2040/lib/platform_inc.txt -I/home/earle/Arduino/hardware/pico/rp2040/include -fno-rtti -std=gnu++17 -g -w -x c++ -E -CC -DSERIALUSB_PID=0xf00a -DUSBD_MAX_POWER_MA=250 -DF_CPU=133000000L -DARDUINO=10816 -DARDUINO_RASPBERRY_PI_PICO_W "-DBOARD_NAME=\"RASPBERRY_PI_PICO_W\"" -DARDUINO_ARCH_RP2040 -Os -I/home/earle/Arduino/hardware/pico/rp2040/cores/rp2040 -I/home/earle/Arduino/hardware/pico/rp2040/variants/rpipicow -I/home/earle/Arduino/hardware/pico/rp2040/libraries/WiFi/src /home/earle/Arduino/hardware/pico/rp2040/libraries/WiFi/src/BearSSLHelpers.cpp -o /dev/null
WaGi-Coding commented 2 years ago

Hmm, I have no idea how i'd check that to be honest. I just got into platformio and i think it's just too much for me it seems & i should prob. stick to micropython or wait for official support :S I was happy already when i managed uploading to the board ^^

Sorry for my confusing

maxgerhardt commented 2 years ago

I will double check the compile commands on PlatformIO -- since I don't have my Pico W yet, I couldn't test on real hardware, only got it to compile. Though the adaptions of the builder script made before me looked perfectly fine.

WaGi-Coding commented 2 years ago

I will double check the compile commands on PlatformIO -- since I don't have my Pico W yet, I couldn't test on real hardware, only got it to compile. Though the adaptions of the builder script made before me looked perfectly fine.

If there is any way i can remotely help you with it easily, feel free to tell me/us what to do ^^ Also, if you really need one(they seem to be hard to get atm), i can send you one of mine from Austria to Germany. Free of charge as thanks for your work

maxgerhardt commented 2 years ago

In the meantime @WaGi-Coding, can you install the Arduino-Pico core in the Arduino IDE and see if you also get 0 networks?

WaGi-Coding commented 2 years ago

In the meantime @WaGi-Coding, can you install the Arduino-Pico core in the Arduino IDE and see if you also get 0 networks?

Seems to work fine, beside the weird fact it somehow finds less and less networks with each scan, then finds them "all" again. But i guess thats some normal behaviour, also see that on my ESP32 boards

image

maxgerhardt commented 2 years ago

Okay, thanks for confirming, if the Arduino IDE and PlatformIO results differ with the exact same code, then the fault is likely in the PIO builder script -- I'll have a look.

Also, if you really need one(they seem to be hard to get atm), i can send you one of mine

I preordered two Pico W from Elektor the day the sent the email that preorders are available. And wow, looking at their website now it used to say available on July 20th, now it says August 1st.. not a good sign :/. I hope they're really shipped to me by then.

But for a first check I'll compare compile commands, no hardware needed yet.

maxgerhardt commented 2 years ago

@WaGi-Coding I have a bad dejavu with variant-specific initVariant() not being linked correctly due to using a .a archive instead of an object file. In the code for PlatformIO, can you use the code

#include <Arduino.h>
#include <WiFi.h>
#include <pico/cyw43_arch.h>

void setup() { cyw43_arch_init(); Serial.begin(115200); }

void loop() {
  Serial.println(WiFi.scanNetworks());
  delay(5000);
}

and retry?

WaGi-Coding commented 2 years ago

@maxgerhardt oh yeah that seems to work, many many thanks <3 image

maxgerhardt commented 2 years ago

Alright then I know exactly what's wrong, many thanks. I'll PR this in shortly.

Same as I did in https://github.com/espressif/arduino-esp32/pull/6809.

maxgerhardt commented 2 years ago

This will be fixed by https://github.com/earlephilhower/arduino-pico/pull/696.

maxgerhardt commented 2 years ago

@WaGi-Coding since the PR was merged and I updated the commit reference (https://github.com/maxgerhardt/platform-raspberrypi/commit/bd2f3e756ba7340150f2bebc2d46110988243018), please do a pio pkg update -g -p https://github.com/maxgerhardt/platform-raspberrypi.git in the CLI and try it without calling into cyw43_arch_init(); explicitly -- Arduino IDE and PlatformIO behavior should be exactly equal now.

WaGi-Coding commented 2 years ago

@maxgerhardt it works like a charm now. Again, many thanks

pquinton commented 2 years ago

NOTE: I'm using PlatformIO via Visual Studio Code with custom upload/debug config

@maxgerhardt I had the same issue as @WaGi-Coding yesterday, where everything appeared to compile fine but didn't get any networks/no wi-fi connections. I can confirm that it works today.

I've been playing with various platformio.ini configurations over the last couple of days and I'm not 100% convinced that platformio correctly handles all the updates/pkg changes quite right. After moving out my .platformio directory and letting the extension re-install along with the toolchains etc., I found that the dependency graph picked up the lwIP_CYW43 which I swear wasn't in there before and I've also noticed that some of the defines changed, such as LWIP_IPV6 is now disabled where as it was enabled before (when it didn't work).

Scanning dependencies...
Dependency Graph
|-- WiFi @ 1.0.0
|   |-- lwIP-Ethernet @ 1
|   |   |-- lwIP_CYW43 @ 1
|   |   |   |-- SPI @ 1.0
|   |   |-- SPI @ 1.0
|-- NTPClient @ 3.2.1

Appreciate all the hard work on this. Thanks.

Ing-Dom commented 2 years ago

We from OpenKNX are impatiently waiting for this getting into offical PIO because we want it to be our default Toolchain. What is the status of the pio integration, since some week it looked to me that it may be only a matter of days ? Thanks.

maxgerhardt commented 2 years ago

The holdup with the merge into official PIO is at https://github.com/platformio/platform-raspberrypi/pull/36, not in this issue; I can't say what is holding it up directly, but I'm trying to resolve it soon. Had a lot to do the past weeks, and this looks like it's going to be a bit more involved..

Barilium8 commented 2 years ago

Looking for some help (been trying for a couple days). The code builds and uploads to the RPi Pico via the Arduino IDE 1.8.19. I followed the boards manager method on arduino-pico.readthedocs.io/en/latest/install.html etc...

But I can't seem to get it to compile and upload PIO VSC.

Here's my platformio.ini

[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
board_build.core = earlephilhower

platform_packages =
    maxgerhardt/framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
    maxgerhardt/toolchain-pico@https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.4.0-c/x86_64-w64-mingw32.arm-none-eabi-0196c06.220714.zip

lib_deps = 
    fortyseveneffects/MIDI Library@^5.0.2
    adafruit/Adafruit TinyUSB Library@^1.14.1

The error I get is this... Error: Missing PlatformIO build script C:\Users\Steve\.platformio\packages\framework-arduinopico\tools\platformio-build.py! Any help would be greatly appreciated! :-)

Barilium8 commented 2 years ago

Some progress... 1) Deleted all sub dirs at "C:\Users\Steve.platformio\packages" 2) commented out the "platform_packages =..." in platformio.ini

that got me to here...

.....
Compiling .pio\build\pico\FrameworkArduino\wiring_analog.cpp.o
Compiling .pio\build\pico\FrameworkArduino\wiring_digital.cpp.o
Compiling .pio\build\pico\FrameworkArduino\wiring_private.cpp.o
src\main.cpp:4:10: fatal error: Adafruit_TinyUSB.h: No such file or directory

**************************************************************************
* Looking for Adafruit_TinyUSB.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Adafruit_TinyUSB.h"
* Web  > https://registry.platformio.org/search?q=header:Adafruit_TinyUSB.h
*
**************************************************************************

    4 | #include <Adafruit_TinyUSB.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.

some searching suggested adding below to platformio.ini

build_flags =
    -IC:/Users/Steve/.platformio/packages/framework-arduinopico/libraries/Adafruit_TinyUSB_Arduino/src

This got me to here....

......
Compiling .pio\build\pico\FrameworkArduino\wiring_analog.cpp.o
Compiling .pio\build\pico\FrameworkArduino\wiring_digital.cpp.o
Compiling .pio\build\pico\FrameworkArduino\wiring_private.cpp.o
In file included from src\main.cpp:4:
C:\Users\Steve\.platformio\packages\framework-arduinopico\libraries\Adafruit_TinyUSB_Arduino\src/Adafruit_TinyUSB.h:31:2: error: #error TinyUSB is not selected, please select it in "Tools->Menu->USB Stack"
   31 | #error TinyUSB is not selected, please select it in "Tools->Menu->USB Stack"

some more searching suggested adding below to platformio.ini

build_flags =
    -IC:/Users/Steve/.platformio/packages/framework-arduinopico/libraries/Adafruit_TinyUSB_Arduino/src
    -DUSE_TINYUSB

This got me to here....

Processing pico (platform: https://github.com/maxgerhardt/platform-raspberrypi.git; board: pico; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/raspberrypi/pico.html
PLATFORM: Raspberry Pi RP2040 (1.7.0+sha.5677d9b) > Raspberry Pi Pico
HARDWARE: RP2040 133MHz, 264KB RAM, 2MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, jlink, picoprobe, raspberrypi-swd)
PACKAGES:
 - framework-arduinopico @ 1.20303.0 (2.3.3)
 - tool-mklittlefs-rp2040-earlephilhower @ 5.100300.220714 (10.3.0)
 - tool-openocd-rp2040-earlephilhower @ 5.100300.220714 (10.3.0)
 - tool-rp2040tools @ 1.0.2 
 - toolchain-rp2040-earlephilhower @ 5.100300.220714 (10.3.0)
Flash size: 2.00MB
Sketch size: 2.00MB
Filesystem size: 0.00MB
Maximium Sketch size: 2093056 EEPROM start: 0x101ff000 Filesystem start: 0x101ff000 Filesystem end: 0x101ff000
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 25 compatible libraries
Scanning dependencies...
Dependency Graph
|-- MIDI Library @ 5.0.2
|-- Adafruit TinyUSB Library @ 1.14.1
Building in release mode
Retrieving maximum program size .pio\build\pico\firmware.elf
Flash size: 2.00MB
Sketch size: 2.00MB
Filesystem size: 0.00MB
Maximium Sketch size: 2093056 EEPROM start: 0x101ff000 Filesystem start: 0x101ff000 Filesystem end: 0x101ff000
Checking size .pio\build\pico\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.4% (used 11612 bytes from 262144 bytes)
Flash: [          ]   3.2% (used 66840 bytes from 2093056 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, jlink, picoprobe, picotool, raspberrypi-swd
CURRENT: upload_protocol = picotool
Looking for upload port...
Error: Please specify `upload_port` for environment or use global `--upload-port` option.
For some development platforms it can be a USB flash drive (i.e. /media/<user>/<device name>)
*** [upload] Explicit exit, status 1
================================================== [FAILED] Took 6.18 seconds ==================================================

But I can't get it to upload! YIKES It seems like I shouldn't need the build flags??? Thoughts? Thanks again!

maxgerhardt commented 2 years ago

The first one was the result of a corrupted package, you did correctly by remocing those folders to force a redownload. However, as you still have platform_packages for the toolchain in your platformio.ini, that is outdated. We updated the documentation for that some time ago. Also, TinyUSB is already included in this core, you don't need to add it to lib_deps. Also no need for the -I flag for TinyUSB, the builder script takes care of that once you give it -DUSE_TINYUSB, as documented. You should be just using

[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
board_build.core = earlephilhower
lib_deps = 
    fortyseveneffects/MIDI Library@^5.0.2

for the latest stable 2.3.3 core. For your your upload problem: For the very first upload, you have to manually put the .uf2 file (.pio\build\pico\firmware.elf) on the boot drive (plug in Pico with BOOTSEL button pressed into the PC), the firmware will then open the USB serial port which is used by the upload_protocol = picotool method. Don't forget to also use Zadig to load WinUSB drivers for the Boot Interface 1 device as said here for picotool to be able to speak to the Pico once it was reset into bootloader mode.

For an alternative first upload, set upload_protocol = mbed in the platformio.ini, plug the Pico in in bootloader mode, and press upload. It will just copy the .uf2 file on the Pico's usb drive. (No automatic reset though, so after that picotool is advised.)

Barilium8 commented 2 years ago

THANKS MAX!!! Got it all running! Here's the final platformio.ini with some notes:

[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
board_build.core = earlephilhower
; NOTE: must use: Zadig (https://zadig.akeo.ie/) to install WinUSB driver for Pico,
; so Pico acts as mass-storage-dev that PIO can copy firmware.uf2 to.

lib_deps = 
    fortyseveneffects/MIDI Library@^5.0.2
    ; not needed, it's built-in... adafruit/Adafruit TinyUSB Library@^1.14.1

build_flags =   
    -DUSE_TINYUSB
        ; not needed, DUSE_TINYUSB sets this path... -IC:/Users/Steve/.platformio/packages/framework-arduinopico/libraries/Adafruit_TinyUSB_Arduino/src

; HELPFUL LINKS:
; UPDATER: paste into the CLI... "pio pkg update -g -p https://github.com/maxgerhardt/platform-raspberrypi.git"
; Pico Core (NOT Arduino official) by Earle Philhower - https://arduino-pico.readthedocs.io/en/latest/platformio.html#current-state-of-development
; thread on the manual install process - https://github.com/earlephilhower/arduino-pico/issues/66
; platformio.ini info - https://docs.platformio.org/en/latest/projectconf/section_platformio.html#data-dir
; Pico mass-storage-device Bootloader & USB driver info - https://forums.raspberrypi.com/viewtopic.php?t=33656
jhmaloney commented 2 years ago

Hi, Max and Earle.

I just upgraded Platformio and and I am now getting this compile error on Linux:

$ pio run -e pico-linux Processing pico-linux (platform: https://github.com/maxgerhardt/platform-raspberrypi.git; board: pico; framework: arduino)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/raspberrypi/pico.html PLATFORM: Raspberry Pi RP2040 (1.7.0+sha.ff7a675) > Raspberry Pi Pico HARDWARE: RP2040 133MHz, 264KB RAM, 2MB Flash DEBUG: Current (cmsis-dap) External (cmsis-dap, jlink, picoprobe, raspberrypi-swd) PACKAGES:

Oddly, I'm not getting the error when building on MacOS.

Here are my platformio.ini file entries:

[env:pico-linux] ; Linux toolchain. Used during deploy. platform = https://github.com/maxgerhardt/platform-raspberrypi.git board = pico board_build.filesystem_size = 1.5m lib_ldf_mode = chain+ build_flags = -Os board_build.core = earlephilhower ; Core package not yet registered with PlatformIO, so pull from git ; Note: Toolchain download link is specific to OS! See https://github.com/earlephilhower/pico-quick-toolchain/releases. platform_packages = maxgerhardt/framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git maxgerhardt/toolchain-pico@https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.4.0-c/x86_64-linux-gnu.arm-none-eabi-0196c06.220714.tar.gz

[env:pico-mac] ; MacOS toolchain. Used during development. platform = https://github.com/maxgerhardt/platform-raspberrypi.git board = pico board_build.filesystem_size = 1.5m lib_ldf_mode = chain+ build_flags = -Os board_build.core = earlephilhower ; Core package not yet registered with PlatformIO, so pull from git ; Note: Toolchain download link is specific to OS! See https://github.com/earlephilhower/pico-quick-toolchain/releases. platform_packages = maxgerhardt/framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git maxgerhardt/toolchain-pico@https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.4.0-c/x86_64-apple-darwin14.arm-none-eabi-0196c06.220714.tar.gz

Do I need to explicitly include the WiFi library in lib_deps?

Thanks!

maxgerhardt commented 2 years ago

Not sure why vm/filePrims.cpp would include LWIP, but hm, (okay it's coming from IPAddress.h of the core) can you link to the src/main.cpp code you're currently using?

(Note: You can also edit your post to format the logs and platformio.ini in a code block by surrounding it with tripple backtick + newline)

Edit: Hm, actually these LWIP headers are supposed to be always found, because the

https://github.com/earlephilhower/arduino-pico/blob/master/lib/platform_inc.txt#L55-L56

adds them. Does the folder /home/git/.platformio/packages/framework-arduinopico/pico-sdk/lib/lwip/src/include exist and have that file it says is missing?

jhmaloney commented 2 years ago

Hi, Max.

The folder /home/git/.platformio/packages/framework-arduinopico/pico-sdk/lib/lwip/src/include does exist, but it is empty.

My repository is here:

https://bitbucket.org/john_maloney/smallvm/src/master/

All the code is in the vm subfolder.

To reproduce the problem, clone the repository, cd into "smallvm" folder, check out the "dev" branch, and run:

pio run -e pico-linux

maxgerhardt commented 2 years ago

The folder /home/git/.platformio/packages/framework-arduinopico/pico-sdk/lib/lwip/src/include does exist, but it is empty.

Then the Arduino core was downloaded incorrectly. rm -rf /home/git/.platformio/packages/framework-arduinopico and build again.

jhmaloney commented 2 years ago

Brilliant! That did the trick.

I've been using this platformio setup since before the PicoW was released and had not upgraded for a while. I'm guessing that the platformio package updating process did not properly add the new lpiw submodule.

In any case, thank you for the super quick answer!

Ing-Dom commented 2 years ago

hey guys,

what do i have to define in the plattformio.ini to use a "Generic RP2040" with 16MB Flash and boot stage 2 W25Q080 QSPI/4 ?

cant find anything about that in the documentation chapter 4...

maxgerhardt commented 2 years ago

The boards/ directory has all available files. The "Generic" board maps to generic.json. The Boot2 source may not be adjustable via the platformio.ini, you might need to copy-paste the generic.json definition in the project's boards/ directory as mygeneric.json, adjust the boot2_source field manually, then reference board = mygeneric. But I guess it's worth a try:

[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = generic
framework = arduino
board_build.filesystem_size = 0.5m ; adjust if needed
board_upload.maximum_size = 16777216
board_build.arduino.earlephilhower.boot2_source = boot2_w25q080_4_padded_checksum.S

The boot2 sources come from https://github.com/earlephilhower/arduino-pico/tree/master/boot2.

tobozo commented 1 year ago

@maxgerhardt thanks for your work on this project :+1:

I tried the suggested sample with the basic values:

platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = generic
framework = arduino
rp2040_pico    SUCCESS   00:05:06.816

Note: it took 5mn from my home fiber connection but some CI workflow runs took up to 10mn

The initial run seem to have pulled a lot of submodules from arduino-pico package, so I thought I'd try to specify the zipball url instead. However it's still pulling the submodules I've probably missed something, unless this is by design?

[env:rp2040_pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
platform_packages = framework-arduino-core-mbed @ https://github.com/earlephilhower/arduino-pico/releases/download/2.6.1/rp2040-2.6.1.zip
board = generic
framework = arduino
board_build.filesystem_size = 0.5m ; adjust if needed
board_upload.maximum_size = 16777216
board_build.arduino.earlephilhower.boot2_source = boot2_w25q080_4_padded_checksum.S
maxgerhardt commented 1 year ago
  1. the line platform_packages = framework-arduino-core-mbed @ https://github.com/earlephilhower/arduino-pico/releases/download/2.6.1/rp2040-2.6.1.zip is wrong because the package for the Arduino-Pico framework (earlephilhowever) is called framework-arduinopico, not framework-arduino-core-mbed. So this should do a download but discard the result.
  2. Even if the name was correct, the .zip version does not have the submodules downloaded, which is the e.g. TinyUSB components. So, compilation explode immediately when you instruct PlatformIO to use the TinyUSB stack instead of the default Pico SDK stack.
tobozo commented 1 year ago

@maxgerhardt your suggestion helped a lot, thanks!

the release version I've selected appears to have the submodules

rp2040_pico    SUCCESS   00:00:43.548

this is the ini I've used:

[env:rp2040_pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
platform_packages = framework-arduinopico @ https://github.com/earlephilhower/arduino-pico/releases/download/2.6.1/rp2040-2.6.1.zip
board = generic
framework = arduino
board_build.filesystem_size = 0.5m ; adjust if needed
board_upload.maximum_size = 16777216
board_build.arduino.earlephilhower.boot2_source = boot2_w25q080_4_padded_checksum.S
maxgerhardt commented 1 year ago

Hm okay so the submodule clone is only 1 layer deep. So pico-sdk gets downloaded but none if its submodules -- e.g., the folder pico-sdk\lib\tinyusb\tools\uf2\ is empty in the .zip file, although it points to a repo with content (https://github.com/hathach/tinyusb/tree/4bfab30c02279a0530e1a56f4a7c539f2d35a293/tools). Same for lib/CMSIS_5 for example, which I think contains the bulk of the submodule clone (thanks to all the STM32 HALs).

So some content is indeed missing compared to a full recursive submodule clone. Further, with the .zip file URLs can't point to a specific commit (as is important in this phase for updating to versions with critical patches). So I think I'll keep the platform.json pointing to the .git link with commits to just be on the safe side.

tobozo commented 1 year ago

understood this is by design, I'll set a workflow cache stragegy with the .platformio folder for the timebeing, thanks to taking the time to explain!

maxgerhardt commented 1 year ago

Actually, the Github Actions yaml file yml file in the documentation should have the critical cache functions already enabled, so if you use that, the CI should cache the downloaded files after the first download.

mclane commented 1 year ago

Hello, I have a raspberry pico W which I would like to program using VSCode and PlatformIO. I started with a simple program:

#include <Arduino.h>

void setup() { 
   Serial.begin(115200);
    }

void loop() {
  Serial.println("Hello");
  delay(5000);
}

My platformio.ini file looks like this:

[env:rpipicow]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino

This configuration is working correctly. if I change to
board = rpipipicow
or
board = rpipico
the program still compiles, but nothing shows up in the serial monitor. In every case, I deleted the build directory before a new compile run. What could be the issue? Thanks for any hint.

maxgerhardt commented 1 year ago

@mclane I've just personally tested this to be working on my Pico W.

grafik

Make sure you have all-latest versions installed (CLI -> pio pkg update -g -p raspberrypi). If multiple COM ports exist on your computer, make sure that PlatformIO picks the right one by setting monitor_port in the platformio.ini. You can also double check that the firmware produces output by using a different terminal program like hterm -- make sure the "DTR" button is pressed though, the firmware won't output anything without it being asserted.

mclane commented 1 year ago

Thanks for the hints. I have the latest versions installed (as shown when executing pio pkg update...). I am running all this on a linux machine (manjaro). DTR is active. I added monitor_port = /dev/ttyACM0, which changed nothing. Sporadically, I get a single output when restarting the monitor. I have the same behavior when using a different terminal program (cutecom). As mentioned, with
board = pico
everything is working fine.
Do you ave any further ideas?

maxgerhardt commented 1 year ago

I've erased the Pico, downloaded Manjaro, installed it in a VM, fully updated it to Linux kernel 6.0.2-2, installed Microsoft VSCode on it via this, installed PlatformIO in it, installed the PIO udev rules on it, installed my platform-raspberrypi in it, forwarded my Pico W as USB device to the VM, created the same project as above, built it, uploaded it, and monitored it, and...

grafik

If you haven't done so yet, also execute pio upgrade --dev in the CLI and retry. Otherwise, try a different Linux distribution.

mclane commented 1 year ago

Thank you very much for your extensive investigations. Obviously, there is something wrong elsewhere in my setup. I will try now on a different machine. Thanks again!

Ing-Dom commented 1 year ago

Hi @maxgerhardt

I'm not sure if this is a Plattform I/O issue or a issue of the core or the Plattform I/O integration.

I came accros this issue: I use a file "foo.h" with some #defines in it. I only include this foo.h in the [env] part of the plattformio.ini with -include "src/foo.h" => this works when I change sth in the foo.h, these changed are correctly highlited in the code

BUT: when I do a build, these changes are not taken into account. If I only change foo.h, NOTHING is built.

When I use -D flags in the ini, changes to the -D flag ARE taken into account when changed. But not when they are in the -included .h file...

Can you help ?

maxgerhardt commented 1 year ago

@Ing-Dom let's continue the discussion in https://community.platformio.org/t/searching-for-a-solution-pattern-to-configure-libs-with-preprocessor-defines/30259.

rgrr commented 1 year ago

No other extensions. For now I have given up and switched to the Arduino IDE 2.0.

Although this is something very old... @laserjones: do you have cygwin in your path? I made similar experiences with gitlab-runners when the wrong git was chosen, aka cygwin-git.

DomGib commented 1 year ago

Hello everyone,

I also have a problem with Platformio. I'm just trying to make the on-board LED blink and print an output in the serial monitor for testing. Flashing on the Pico W works and the output appears on the serial monitor. However, the LED does not blink. The same code flashed with the Arduino IDE makes the LED blink. I've already tried manually dragging the created uf2 file onto the pico, which also didn't achieve any more success. Anyone have an idea what the problem is here?

JonnyHaystack commented 1 year ago

@DomGib the Pico W doesn't have the LED attached directly to an RP2040 GPIO pin. It's attached to the GPIO of the wireless module. Same goes for the VBUS sense pin. arduino-pico does handle this for you though. You can just use pin number 32 with the Arduino functions. Bear in mind it's much slower to read and write through the wireless module than with the native GPIO of the RP2040.

Here is the code that handles this: https://github.com/earlephilhower/arduino-pico/blob/master/variants/rpipicow/picow_digital.cpp#L39

maxgerhardt commented 1 year ago

The same code flashed with the Arduino IDE makes the LED blink.

Then PlatformIO should behave the same given the same core versions. LED_BUILTIN for the Pico W is also defined to be 32 (source) and that should thus trigger the special case for the digitalWrite overload. There might again be something wrong in the linking the way PlatformIO does it, we had that once before. I will cross-check on my Pico W.

earlephilhower commented 1 year ago

Make sure you're using the rpipicow board, not the rpipico one in your .ini file.

DomiGib commented 1 year ago

Make sure you're using the rpipicow board, not the rpipico one in your .ini file.

Thank you, that solved my problem!

maxgerhardt commented 1 year ago

Okay good, I also cross verified it just now to be working with rpipicow correctly.

Ing-Dom commented 1 year ago

I came across the question if it is possible and if it is usefull to specify the platform more specifc ;)

I really hate if something changes and maybe breaks something, so thats why a specified a exact core version in platform_packages (2.5.4). can I do this for platform also ? pic some version / branch / commit ?

[RP2040]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
platform_packages = framework-arduinopico @ https://github.com/earlephilhower/arduino-pico/releases/download/2.5.4/rp2040-2.5.4.zip
board = pico
; Arduino-Pico core
board_build.core = earlephilhower
maxgerhardt commented 1 year ago

Yes, per documentation, you can fixate the platform version in place too by the commit or branch name, using the #<commit / branch> syntax.

platform = https://github.com/maxgerhardt/platform-raspberrypi.git#9f8c10e50b5acd18e7bfd32638199c655be73a5b

Note that sometimes this does not protect from breakage. When e.g. new toolchains are uploaded which invalidate the old version, and you have a platform version that doesn't reference the new version, compilation will simply break with a "no such package found" error. It does however fix everything else in place (board definitions, platform.py, main.py build logic..)