diff --git a/docs/images/pio_debugging.png b/docs/images/pio_debugging.png new file mode 100644 index 000000000..d0ae66df1 Binary files /dev/null and b/docs/images/pio_debugging.png differ diff --git a/docs/images/pio_fs_upload.png b/docs/images/pio_fs_upload.png new file mode 100644 index 000000000..f70bef0d5 Binary files /dev/null and b/docs/images/pio_fs_upload.png differ diff --git a/docs/platformio.rst b/docs/platformio.rst index ea622549c..8ed294edf 100644 --- a/docs/platformio.rst +++ b/docs/platformio.rst @@ -19,14 +19,14 @@ The PlatformIO experience: Refer to the general documentation at https://docs.platformio.org/. -Especially useful is the `Getting started with VSCode + PlatformIO `__ page. +Especially useful is the `Getting started with VSCode + PlatformIO `_, `CLI reference `_ and the `platformio.ini options `_ page. Hereafter it is assumed that you have a basic understanding of PlatformIO in regards to project creation, project file structure and building and uploading PlatformIO projects, through reading the above pages. Current state of development ---------------------------- -At the time of writing, PlatformIO integration for this core is a work-in-progress and not yet merged into mainline PlatformIO. This is subject to change soon. +At the time of writing, PlatformIO integration for this core is a work-in-progress and not yet merged into mainline PlatformIO. This is subject to change once `this pull request `_ is merged. If you want to use the PlatformIO integration right now, make sure you first create a standard Raspberry Pi Pico + Arduino project within PlatformIO. This will give you a project with the ``platformio.ini`` @@ -38,8 +38,7 @@ This will give you a project with the ``platformio.ini`` board = pico framework = arduino -Here, you need to change the `platform` to take advantage of the features described hereunder. -You *also* need to inject two PlatformIO packages, one for the compiler toolchain and one for the Arduino core package. +Here, you need to change the `platform` to take advantage of the features described hereunder and switch to the new core. .. code:: ini @@ -47,12 +46,34 @@ You *also* need to inject two PlatformIO packages, one for the compiler toolchai platform = https://github.com/maxgerhardt/platform-raspberrypi.git board = pico framework = arduino + board_build.core = earlephilhower + +When the support for this core has been merged into mainline PlatformIO, this notice will be removed and a standard `platformio.ini` as shown above will work as a base. + +Deprecation warnings +--------------------- + +Previous versions of this documentation told users to inject the framework and toolchain package into the project by using + +.. code:: ini + ; note that download link for toolchain is specific for 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.3.1-a/x86_64-w64-mingw32.arm-none-eabi-7855b0c.210706.zip - -When the support for this core has been merged into mainline PlatformIO, this notice will be removed and a standard `platformio.ini` as shown above will work as a base. + +This is now **deprecated** and should not be done anymore. Users should delete these ``platform_packages`` lines and update the platform integration by issuing the command + +.. code:: bash + + pio pkg update -g -p https://github.com/maxgerhardt/platform-raspberrypi.git + +in the `PlatformIO CLI `_. The same can be achieved by using the VSCode PIO Home -> Platforms -> Updates GUI. + +The toolchain, which was also renamed to ``toolchain-rp2040-earlephilhower`` is downloaded automatically from the registry. The same goes for the ``framework-arduinopico`` toolchain package, which points directly to the Arduino-Pico Github repository. +However, users can still select a custom fork or branch of the core if desired so, as detailed in a chapter below. + +As the pull req Selecting the new core ---------------------- @@ -61,8 +82,8 @@ Prerequisite for using this core is to tell PlatformIO to switch to it. There will be board definition files where the Earle-Philhower core will be the default since it's a board that only exists in this core (and not the other https://github.com/arduino/ArduinoCore-mbed). To switch boards -for which this is not the default core (e.g. the standard -``board = pico``), the directive +for which this is not the default core (which are only +``board = pico`` and ``board = nanorp2040connect``), the directive .. code:: ini @@ -72,6 +93,8 @@ must be added to the ``platformio.ini``. This controls the `core switching logic `__. +When using Arduino-Pico-only boards like ``board = rpipico`` or ``board = adafruit_feather``, this is not needed. + Flash size ---------- @@ -154,6 +177,37 @@ either a sing line or a newline-separated expression. -DDEBUG_RP2040_CORE -DDEBUG_RP2040_PORT=Serial2 +C++ Exceptions +-------------- + +Exceptions are disabled by default. To enable them, use + +.. code:: ini + + ; Enable Exceptions + build_flags = -DPIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS + +Stack Protector +--------------- + +To enable GCC's stack protection feature, use + +.. code:: ini + + ; Enable Stack Protector + build_flags = -fstack-protector + + +RTTI +---- + +RTTI (run-time type information) is disabled by default. To enable it, use + +.. code:: ini + + ; Enable RTTI + build_flags = -DPIO_FRAMEWORK_ARDUINO_ENABLE_RTTI + USB Stack --------- @@ -188,8 +242,8 @@ directive to do so. Simply specify that the framework package Whereas the ``#master`` can also be replaced by a ``#branchname`` or a ``#commithash``. If left out, it will pull the default branch, which is ``master``. -The ``file://`` pseudo-protocol can also be used instead of ``https://`` to point to a -local copy of the core (with e.g. some modifications) on disk. +The ``file://`` and ``symlink://`` pseudo-protocols can also be used instead of ``https://`` to point to a +local copy of the core (with e.g. some modifications) on disk (`see documentation _`). Note that this can only be done for versions that have the PlatformIO builder script it in, so versions before 1.9.2 are not supported. @@ -206,14 +260,50 @@ and 0.5MByte filesystem. platform = https://github.com/maxgerhardt/platform-raspberrypi.git board = pico framework = arduino + ; board can use both Arduino cores -- we select Arduino-Pico here board_build.core = earlephilhower board_build.filesystem_size = 0.5m - ; note that download link for toolchain is specific for 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.3.1-a/x86_64-w64-mingw32.arm-none-eabi-7855b0c.210706.zip The initial project structure should be generated just creating a new project for the Pico and the Arduino framework, after which the auto-generated ``platformio.ini`` can be adapted per above. + +Debugging +--------- + +With recent updates to the toolchain and OpenOCD, debugging firmwares is also possible. + +To specify the debugging adapter, use ``debug_tool`` (`documentation `_). Supported values are: + +* ``picoprobe`` +* ``cmsis-dap`` +* ``jlink`` +* ``raspberrypi-swd`` + +These values can also be used in ``upload_protocol`` if you want PlatformIO to upload the regular firmware through this method, which you likely want. + +Especially the PicoProbe method is convenient when you have two Raspberry Pi Pico boards. One of them can be flashed with the PicoProbe firmware (`documentation `_) and is then connected to the target Raspberry Pi Pico board (see `documentation `_ chapter "Picoprobe Wiring"). Remember that on Windows, you have to use `Zadig `_ to also load "WinUSB" drivers for the "Picoprobe (Interface 2)" device so that OpenOCD can speak to it. + +With that set up, debugging can be started via the left debugging sidebar and works nicely: Setup breakpoints, inspect the value of variables in the code, step through the code line by line. When a breakpoint is hit or execution is halted, you can even see the execution state both Cortex-M0+ cores of the RP2040. + +.. image:: images/pio_debugging.png + +For further information on customizing debug options, like the initial breakpoint or debugging / SWD speed, consult `the documentation `_. + +Filesystem Uploading +-------------------- + +For the Arduino IDE, `a plugin `_ is available that enables a data folder to be packed as a LittleFS filesystem binary and uploaded to the Pico. + +This functionality is also built-in in the PlatformIO integration. Open the `project tasks `_ and expand the "Platform" tasks: + +.. image:: images/pio_fs_upload.png + +The files you want to upload should be placed in a folder called ``data`` inside the project. This can be customized `if needed `_. + +The task "Build Filesystem Image" will take all files in the data directory and create a ``littlefs.bin`` file from it using the ``mklittlefs`` tool. + +The task "Upload Filesystem Image" will upload the filesystem image to the Pico via the specified ``upload_protocol``. + +**Note:** Currently only the default ``picotool`` (regular direct USB upload) and the OpenOCD-based debug methods (meaning all but ``jlink``) can transport the filesystem to the Pico. \ No newline at end of file diff --git a/tools/json/adafruit_feather.json b/tools/json/adafruit_feather.json index dec96a673..46c114d37 100644 --- a/tools/json/adafruit_feather.json +++ b/tools/json/adafruit_feather.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "adafruit_feather", "arduino": { "earlephilhower": { - "variant": "adafruit_feather", "boot2_source": "boot2_w25x10cl_4_padded_checksum.S", "usb_vid": "0x239a", - "usb_pid": "0x80f1", - "usb_manufacturer": "Adafruit", - "usb_product": "Feather RP2040" + "usb_pid": "0x80f1" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Adafruit" -} \ No newline at end of file +} diff --git a/tools/json/adafruit_itsybitsy.json b/tools/json/adafruit_itsybitsy.json index 14622dd3d..3119dac8b 100644 --- a/tools/json/adafruit_itsybitsy.json +++ b/tools/json/adafruit_itsybitsy.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "adafruit_itsybitsy", "arduino": { "earlephilhower": { - "variant": "adafruit_itsybitsy", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x239a", - "usb_pid": "0x80fd", - "usb_manufacturer": "Adafruit", - "usb_product": "ItsyBitsy RP2040" + "usb_pid": "0x80fd" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Adafruit" -} \ No newline at end of file +} diff --git a/tools/json/adafruit_kb2040.json b/tools/json/adafruit_kb2040.json index 4be755fcd..d77f37a48 100644 --- a/tools/json/adafruit_kb2040.json +++ b/tools/json/adafruit_kb2040.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "adafruit_kb2040", "arduino": { "earlephilhower": { - "variant": "adafruit_kb2040", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x239a", - "usb_pid": "0x8105", - "usb_manufacturer": "Adafruit", - "usb_product": "KB2040" + "usb_pid": "0x8105" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Adafruit" -} \ No newline at end of file +} diff --git a/tools/json/adafruit_macropad2040.json b/tools/json/adafruit_macropad2040.json index c0662547b..34c7a1220 100644 --- a/tools/json/adafruit_macropad2040.json +++ b/tools/json/adafruit_macropad2040.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "adafruit_macropad2040", "arduino": { "earlephilhower": { - "variant": "adafruit_macropad2040", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x239a", - "usb_pid": "0x8107", - "usb_manufacturer": "Adafruit", - "usb_product": "MacroPad RP2040" + "usb_pid": "0x8107" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Adafruit" -} \ No newline at end of file +} diff --git a/tools/json/adafruit_qtpy.json b/tools/json/adafruit_qtpy.json index 21f09fa6e..f37230829 100644 --- a/tools/json/adafruit_qtpy.json +++ b/tools/json/adafruit_qtpy.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "adafruit_qtpy", "arduino": { "earlephilhower": { - "variant": "adafruit_qtpy", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x239a", - "usb_pid": "0x80f7", - "usb_manufacturer": "Adafruit", - "usb_product": "QT Py RP2040" + "usb_pid": "0x80f7" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Adafruit" -} \ No newline at end of file +} diff --git a/tools/json/adafruit_stemmafriend.json b/tools/json/adafruit_stemmafriend.json index 89a8f0c62..d9c166715 100644 --- a/tools/json/adafruit_stemmafriend.json +++ b/tools/json/adafruit_stemmafriend.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "adafruit_stemmafriend", "arduino": { "earlephilhower": { - "variant": "adafruit_stemmafriend", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x239a", - "usb_pid": "0x80e3", - "usb_manufacturer": "Adafruit", - "usb_product": "STEMMA Friend RP2040" + "usb_pid": "0x80e3" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Adafruit" -} \ No newline at end of file +} diff --git a/tools/json/adafruit_trinkeyrp2040qt.json b/tools/json/adafruit_trinkeyrp2040qt.json index 6c873c93f..3472ccc1f 100644 --- a/tools/json/adafruit_trinkeyrp2040qt.json +++ b/tools/json/adafruit_trinkeyrp2040qt.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "adafruit_trinkeyrp2040qt", "arduino": { "earlephilhower": { - "variant": "adafruit_trinkeyrp2040qt", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x239a", - "usb_pid": "0x8109", - "usb_manufacturer": "Adafruit", - "usb_product": "Trinkey RP2040 QT" + "usb_pid": "0x8109" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Adafruit" -} \ No newline at end of file +} diff --git a/tools/json/arduino_nano_connect.json b/tools/json/arduino_nano_connect.json index a294f93d8..a8235e0a3 100644 --- a/tools/json/arduino_nano_connect.json +++ b/tools/json/arduino_nano_connect.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "arduino_nano_connect", "arduino": { "earlephilhower": { - "variant": "arduino_nano_connect", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2341", - "usb_pid": "0x0058", - "usb_manufacturer": "Arduino", - "usb_product": "Nano RP2040 Connect" + "usb_pid": "0x0058" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Arduino" -} \ No newline at end of file +} diff --git a/tools/json/challenger_2040_lora.json b/tools/json/challenger_2040_lora.json index e47abf45b..7e75c3970 100644 --- a/tools/json/challenger_2040_lora.json +++ b/tools/json/challenger_2040_lora.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "challenger_2040_lora", "arduino": { "earlephilhower": { - "variant": "challenger_2040_lora", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x1023", - "usb_manufacturer": "iLabs", - "usb_product": "Challenger 2040 LoRa" + "usb_pid": "0x1023" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "iLabs" -} \ No newline at end of file +} diff --git a/tools/json/challenger_2040_lte.json b/tools/json/challenger_2040_lte.json index 7b5991bd4..5e59e2d59 100644 --- a/tools/json/challenger_2040_lte.json +++ b/tools/json/challenger_2040_lte.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "challenger_2040_lte", "arduino": { "earlephilhower": { - "variant": "challenger_2040_lte", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x100b", - "usb_manufacturer": "iLabs", - "usb_product": "Challenger 2040 LTE" + "usb_pid": "0x100b" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "iLabs" -} \ No newline at end of file +} diff --git a/tools/json/challenger_2040_wifi.json b/tools/json/challenger_2040_wifi.json index 51111116e..e286c814c 100644 --- a/tools/json/challenger_2040_wifi.json +++ b/tools/json/challenger_2040_wifi.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "challenger_2040_wifi", "arduino": { "earlephilhower": { - "variant": "challenger_2040_wifi", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x1006", - "usb_manufacturer": "iLabs", - "usb_product": "Challenger 2040 WiFi" + "usb_pid": "0x1006" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "iLabs" -} \ No newline at end of file +} diff --git a/tools/json/challenger_2040_wifi_ble.json b/tools/json/challenger_2040_wifi_ble.json index b7f1783b4..78cfefa2a 100644 --- a/tools/json/challenger_2040_wifi_ble.json +++ b/tools/json/challenger_2040_wifi_ble.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "challenger_2040_wifi_ble", "arduino": { "earlephilhower": { - "variant": "challenger_2040_wifi_ble", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x102C", - "usb_manufacturer": "iLabs", - "usb_product": "Challenger 2040 WiFi/BLE" + "usb_pid": "0x102C" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "iLabs" -} \ No newline at end of file +} diff --git a/tools/json/challenger_nb_2040_wifi.json b/tools/json/challenger_nb_2040_wifi.json index b1ee1144b..8adff8600 100644 --- a/tools/json/challenger_nb_2040_wifi.json +++ b/tools/json/challenger_nb_2040_wifi.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "challenger_nb_2040_wifi", "arduino": { "earlephilhower": { - "variant": "challenger_nb_2040_wifi", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x100b", - "usb_manufacturer": "iLabs", - "usb_product": "Challenger NB 2040 WiFi" + "usb_pid": "0x100b" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "iLabs" -} \ No newline at end of file +} diff --git a/tools/json/cytron_maker_nano_rp2040.json b/tools/json/cytron_maker_nano_rp2040.json index cb7314cbb..2b7899562 100644 --- a/tools/json/cytron_maker_nano_rp2040.json +++ b/tools/json/cytron_maker_nano_rp2040.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "cytron_maker_nano_rp2040", "arduino": { "earlephilhower": { - "variant": "cytron_maker_nano_rp2040", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x100f", - "usb_manufacturer": "Cytron", - "usb_product": "Maker Nano RP2040" + "usb_pid": "0x100f" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Cytron" -} \ No newline at end of file +} diff --git a/tools/json/cytron_maker_pi_rp2040.json b/tools/json/cytron_maker_pi_rp2040.json index d5ed15c51..a3985acfe 100644 --- a/tools/json/cytron_maker_pi_rp2040.json +++ b/tools/json/cytron_maker_pi_rp2040.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "cytron_maker_pi_rp2040", "arduino": { "earlephilhower": { - "variant": "cytron_maker_pi_rp2040", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x1000", - "usb_manufacturer": "Cytron", - "usb_product": "Maker Pi RP2040" + "usb_pid": "0x1000" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Cytron" -} \ No newline at end of file +} diff --git a/tools/json/dfrobot_beetle_rp2040.json b/tools/json/dfrobot_beetle_rp2040.json index 95df8f84f..f0c1f5504 100644 --- a/tools/json/dfrobot_beetle_rp2040.json +++ b/tools/json/dfrobot_beetle_rp2040.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "dfrobot_beetle_rp2040", "arduino": { "earlephilhower": { - "variant": "dfrobot_beetle_rp2040", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x3343", - "usb_pid": "0x4253", - "usb_manufacturer": "DFRobot", - "usb_product": "Beetle RP2040" + "usb_pid": "0x4253" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "DFRobot" -} \ No newline at end of file +} diff --git a/tools/json/flyboard2040_core.json b/tools/json/flyboard2040_core.json index b60e0baa7..b7f0b8331 100644 --- a/tools/json/flyboard2040_core.json +++ b/tools/json/flyboard2040_core.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "flyboard2040_core", "arduino": { "earlephilhower": { - "variant": "flyboard2040_core", "boot2_source": "boot2_generic_03h_4_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x008a", - "usb_manufacturer": "DeRuiLab", - "usb_product": "FlyBoard2040Core" + "usb_pid": "0x008a" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "DeRuiLab" -} \ No newline at end of file +} diff --git a/tools/json/generic.json b/tools/json/generic.json index fa89b117a..4785e678b 100644 --- a/tools/json/generic.json +++ b/tools/json/generic.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "generic", "arduino": { "earlephilhower": { - "variant": "generic", "boot2_source": "boot2_generic_03h_4_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0xf00a", - "usb_manufacturer": "Generic", - "usb_product": "RP2040" + "usb_pid": "0xf00a" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Generic" -} \ No newline at end of file +} diff --git a/tools/json/ilabs_rpico32.json b/tools/json/ilabs_rpico32.json index 058e45816..ee1dedfd5 100644 --- a/tools/json/ilabs_rpico32.json +++ b/tools/json/ilabs_rpico32.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "ilabs_rpico32", "arduino": { "earlephilhower": { - "variant": "ilabs_rpico32", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x1010", - "usb_manufacturer": "iLabs", - "usb_product": "RPICO32" + "usb_pid": "0x1010" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "iLabs" -} \ No newline at end of file +} diff --git a/tools/json/melopero_shake_rp2040.json b/tools/json/melopero_shake_rp2040.json index 98134575f..761f215c2 100644 --- a/tools/json/melopero_shake_rp2040.json +++ b/tools/json/melopero_shake_rp2040.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "melopero_shake_rp2040", "arduino": { "earlephilhower": { - "variant": "melopero_shake_rp2040", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x1005", - "usb_manufacturer": "Melopero", - "usb_product": "Shake RP2040" + "usb_pid": "0x1005" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Melopero" -} \ No newline at end of file +} diff --git a/tools/json/rpipico.json b/tools/json/rpipico.json index 4d688ab7a..b5020bc10 100644 --- a/tools/json/rpipico.json +++ b/tools/json/rpipico.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "rpipico", "arduino": { "earlephilhower": { - "variant": "rpipico", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x000a", - "usb_manufacturer": "Raspberry Pi", - "usb_product": "Pico" + "usb_pid": "0x000a" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Raspberry Pi" -} \ No newline at end of file +} diff --git a/tools/json/seeed_xiao_rp2040.json b/tools/json/seeed_xiao_rp2040.json index d70f69619..8609f62ed 100644 --- a/tools/json/seeed_xiao_rp2040.json +++ b/tools/json/seeed_xiao_rp2040.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "seeed_xiao_rp2040", "arduino": { "earlephilhower": { - "variant": "seeed_xiao_rp2040", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x000a", - "usb_manufacturer": "Seeed", - "usb_product": "XAIO RP2040" + "usb_pid": "0x000a" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Seeed" -} \ No newline at end of file +} diff --git a/tools/json/solderparty_rp2040_stamp.json b/tools/json/solderparty_rp2040_stamp.json index 6f3ac69aa..57280be31 100644 --- a/tools/json/solderparty_rp2040_stamp.json +++ b/tools/json/solderparty_rp2040_stamp.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "solderparty_rp2040_stamp", "arduino": { "earlephilhower": { - "variant": "solderparty_rp2040_stamp", "boot2_source": "boot2_generic_03h_4_padded_checksum.S", "usb_vid": "0x1209", - "usb_pid": "0xa182", - "usb_manufacturer": "Solder Party", - "usb_product": "RP2040 Stamp" + "usb_pid": "0xa182" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "Solder Party" -} \ No newline at end of file +} diff --git a/tools/json/sparkfun_promicrorp2040.json b/tools/json/sparkfun_promicrorp2040.json index 630630ef8..efd2fee49 100644 --- a/tools/json/sparkfun_promicrorp2040.json +++ b/tools/json/sparkfun_promicrorp2040.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "sparkfun_promicrorp2040", "arduino": { "earlephilhower": { - "variant": "sparkfun_promicrorp2040", "boot2_source": "boot2_generic_03h_4_padded_checksum.S", "usb_vid": "0x1b4f", - "usb_pid": "0x0026", - "usb_manufacturer": "SparkFun", - "usb_product": "ProMicro RP2040" + "usb_pid": "0x0026" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "SparkFun" -} \ No newline at end of file +} diff --git a/tools/json/sparkfun_thingplusrp2040.json b/tools/json/sparkfun_thingplusrp2040.json index 982b55a12..9c4a14cc7 100644 --- a/tools/json/sparkfun_thingplusrp2040.json +++ b/tools/json/sparkfun_thingplusrp2040.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "sparkfun_thingplusrp2040", "arduino": { "earlephilhower": { - "variant": "sparkfun_thingplusrp2040", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x1b4f", - "usb_pid": "0x0026", - "usb_manufacturer": "SparkFun", - "usb_product": "Thing Plus RP2040" + "usb_pid": "0x0026" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "SparkFun" -} \ No newline at end of file +} diff --git a/tools/json/upesy_rp2040_devkit.json b/tools/json/upesy_rp2040_devkit.json index 3452f7ea4..dcf85d475 100644 --- a/tools/json/upesy_rp2040_devkit.json +++ b/tools/json/upesy_rp2040_devkit.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "upesy_rp2040_devkit", "arduino": { "earlephilhower": { - "variant": "upesy_rp2040_devkit", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x1007", - "usb_manufacturer": "uPesy", - "usb_product": "RP2040 DevKit" + "usb_pid": "0x1007" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "uPesy" -} \ No newline at end of file +} diff --git a/tools/json/wiznet_5100s_evb_pico.json b/tools/json/wiznet_5100s_evb_pico.json index 2e66dbaff..1f8235860 100644 --- a/tools/json/wiznet_5100s_evb_pico.json +++ b/tools/json/wiznet_5100s_evb_pico.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "wiznet_5100s_evb_pico", "arduino": { "earlephilhower": { - "variant": "wiznet_5100s_evb_pico", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x1027", - "usb_manufacturer": "WIZnet", - "usb_product": "W5100S-EVB-Pico" + "usb_pid": "0x1027" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "WIZnet" -} \ No newline at end of file +} diff --git a/tools/json/wiznet_5500_evb_pico.json b/tools/json/wiznet_5500_evb_pico.json index 27bfe0de8..a39122f9b 100644 --- a/tools/json/wiznet_5500_evb_pico.json +++ b/tools/json/wiznet_5500_evb_pico.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "wiznet_5500_evb_pico", "arduino": { "earlephilhower": { - "variant": "wiznet_5500_evb_pico", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x1029", - "usb_manufacturer": "WIZnet", - "usb_product": "W5500-EVB-Pico" + "usb_pid": "0x1029" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "WIZnet" -} \ No newline at end of file +} diff --git a/tools/json/wiznet_wizfi360_evb_pico.json b/tools/json/wiznet_wizfi360_evb_pico.json index e696ca2c6..43f00bc0d 100644 --- a/tools/json/wiznet_wizfi360_evb_pico.json +++ b/tools/json/wiznet_wizfi360_evb_pico.json @@ -11,14 +11,12 @@ ] ], "mcu": "rp2040", + "variant": "wiznet_wizfi360_evb_pico", "arduino": { "earlephilhower": { - "variant": "wiznet_wizfi360_evb_pico", "boot2_source": "boot2_w25q080_2_padded_checksum.S", "usb_vid": "0x2e8a", - "usb_pid": "0x1028", - "usb_manufacturer": "WIZnet", - "usb_product": "WizFi360-EVB-Pico" + "usb_pid": "0x1028" } } }, @@ -49,4 +47,4 @@ }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "WIZnet" -} \ No newline at end of file +} diff --git a/tools/makeboards.py b/tools/makeboards.py index c8c06dcb5..efa2339e7 100755 --- a/tools/makeboards.py +++ b/tools/makeboards.py @@ -188,14 +188,12 @@ def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, f ] ], "mcu": "rp2040", + "variant": "VARIANTNAME", "arduino": { "earlephilhower": { - "variant": "VARIANTNAME", "boot2_source": "BOOT2.S", "usb_vid": "VID", - "usb_pid": "PID", - "usb_manufacturer": "VENDORNAME", - "usb_product": "PRODUCTNAME" + "usb_pid": "PID" } } }, @@ -226,7 +224,7 @@ def MakeBoardJSON(name, vendor_name, product_name, vid, pid, pwr, boarddefine, f }, "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", "vendor": "VENDORNAME" -}""".replace('VARIANTNAME', name).replace('BOARDDEFINE', boarddefine).replace('BOOT2', boot2).replace('VID', vid).replace('PID', pid).replace('VENDORNAME', vendor_name).replace('PRODUCTNAME', product_name).replace('FLASHSIZE', str(1024*1024*flashsizemb)).replace('USBPWR', str(pwr)) +}\n""".replace('VARIANTNAME', name).replace('BOARDDEFINE', boarddefine).replace('BOOT2', boot2).replace('VID', vid).replace('PID', pid).replace('VENDORNAME', vendor_name).replace('PRODUCTNAME', product_name).replace('FLASHSIZE', str(1024*1024*flashsizemb)).replace('USBPWR', str(pwr)) jsondir = os.path.abspath(os.path.dirname(__file__)) + "/json" f = open(jsondir + "/" + name + ".json", "w") f.write(json) diff --git a/tools/platformio-build.py b/tools/platformio-build.py index 6488ddcd4..95f4f79af 100755 --- a/tools/platformio-build.py +++ b/tools/platformio-build.py @@ -27,7 +27,8 @@ FRAMEWORK_DIR = platform.get_package_dir("framework-arduinopico") assert os.path.isdir(FRAMEWORK_DIR) -# read includes from this file to add them into CPPPATH later +# read includes from this file to add them into CPPPATH later for good IDE intellisense +# will use original -iprefix @ for compilation though. includes_file = os.path.join(FRAMEWORK_DIR, "lib", "platform_inc.txt") file_lines = [] includes = [] @@ -38,10 +39,41 @@ # emulate -iprefix . path = os.path.join(FRAMEWORK_DIR, path) # prevent non-existent paths from being added - # looking at you here, pico-extras/src/common/pico_audio and co. if os.path.isdir(path): includes.append(path) +def is_pio_build(): + from SCons.Script import COMMAND_LINE_TARGETS + return "idedata" not in COMMAND_LINE_TARGETS and "_idedata" not in COMMAND_LINE_TARGETS + +# get all activated macros +flatten_cppdefines = env.Flatten(env['CPPDEFINES']) + +# +# Exceptions +# +stdcpp_lib = None +if "PIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS" in flatten_cppdefines: + env.Append( + CXXFLAGS=["-fexceptions"] + ) + stdcpp_lib = "stdc++-exc" +else: + env.Append( + CXXFLAGS=["-fno-exceptions"] + ) + stdcpp_lib = "stdc++" + +# +# RTTI +# +# standard is -fno-rtti flag. If special macro is present, don't +# add that flag. +if not "PIO_FRAMEWORK_ARDUINO_ENABLE_RTTI" in flatten_cppdefines: + env.Append( + CXXFLAGS=["-fno-rtti"] + ) + # update progsize expression to also check for bootloader. env.Replace( SIZEPROGREGEXP=r"^(?:\.boot2|\.text|\.data|\.rodata|\.text.align|\.ARM.exidx)\s+(\d+).*" @@ -57,11 +89,8 @@ "-mcpu=cortex-m0plus", "-mthumb", "-ffunction-sections", - "-fdata-sections", - # use explicit include (-I) paths, otherwise it's - # not visible in the IDE's intellisense. - #"-iprefix" + os.path.join(FRAMEWORK_DIR), - #"@%s" % os.path.join(FRAMEWORK_DIR, "lib", "platform_inc.txt") + "-fdata-sections" + # -iprefix etc. added lader if in build mode ], CFLAGS=[ @@ -70,8 +99,6 @@ CXXFLAGS=[ "-std=gnu++17", - "-fno-exceptions", - "-fno-rtti", ], CPPDEFINES=[ @@ -114,10 +141,18 @@ # link lib/libpico.a by full path, ignore libstdc++ LIBS=[ File(os.path.join(FRAMEWORK_DIR, "lib", "libpico.a")), - "m", "c", "stdc++", "c"] + "m", "c", stdcpp_lib, "c"] ) -# expand with read includes -env.Append(CPPPATH=includes) + +# expand with read includes for IDE, but use -iprefix command for actual building +if not is_pio_build(): + env.Append(CPPPATH=includes) +else: + env.Append(CCFLAGS=[ + "-iprefix" + os.path.join(FRAMEWORK_DIR), + "@%s" % os.path.join(FRAMEWORK_DIR, "lib", "platform_inc.txt") + ]) + def configure_usb_flags(cpp_defines): global ram_size @@ -223,8 +258,8 @@ def configure_usb_flags(cpp_defines): # if no custom linker script is provided, we use the command that we prepared to generate one. if not board.get("build.ldscript", ""): - # execute fetch filesystem info stored in env to alawys have that info ready - env["fetch_fs_size"](env) + # execute fetch filesystem info stored in env to always have that info ready + env["__fetch_fs_size"](env) env.Depends("$BUILD_DIR/${PROGNAME}.elf", linkerscript_cmd) env.Replace(LDSCRIPT_PATH=os.path.join("$BUILD_DIR", "memmap_default.ld"))