Skip to content

Commit c7b8241

Browse files
committed
ports/rp2: Per-board linker flash config.
Add per-board flash config to avoid silently overwriting user code on vfs init. Make linker FLASH section reflect board size. Add linker APP section for user code. Add linker FILESYSTEM section for vfs. Add per-board config for FLASH + APP sizes: * MICROPY_HW_FLASH_SIZE_BYTES * MICROPY_HW_APP_SIZE_BYTES CMake "configure_file" memmap_mp.ld.in. Signed-off-by: Phil Howard <phil@pimoroni.com>
1 parent 579f330 commit c7b8241

File tree

27 files changed

+83
-31
lines changed

27 files changed

+83
-31
lines changed

ports/rp2/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,26 +390,36 @@ target_compile_definitions(${MICROPY_TARGET} PRIVATE
390390
MICROPY_BUILD_TYPE="${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} ${CMAKE_BUILD_TYPE}"
391391
PICO_NO_BI_STDIO_UART=1 # we call it UART REPL
392392
PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1
393+
MICROPY_HW_FLASH_SIZE_BYTES=${MICROPY_HW_FLASH_SIZE_BYTES}
394+
MICROPY_HW_APP_SIZE_BYTES=${MICROPY_HW_APP_SIZE_BYTES}
393395
)
394396

395397
target_link_libraries(${MICROPY_TARGET}
396398
${PICO_SDK_COMPONENTS}
397399
)
398400

401+
target_link_options(${MICROPY_TARGET} PRIVATE
402+
-Wl,--print-memory-usage
403+
)
404+
399405
if (MICROPY_HW_ENABLE_DOUBLE_TAP)
400406
# Enable double tap reset into bootrom.
401407
target_link_libraries(${MICROPY_TARGET}
402408
pico_bootsel_via_double_reset
403409
)
404410
endif()
405411

412+
# parse the linker file, replacing ${MICROPY_HW_FLASH_SIZE_BYTES}, etc with their values
413+
configure_file(${CMAKE_CURRENT_LIST_DIR}/memmap_mp.ld.in ${CMAKE_CURRENT_BINARY_DIR}/memmap_mp.ld)
414+
406415
# todo this is a bit brittle, but we want to move a few source files into RAM (which requires
407416
# a linker script modification) until we explicitly add macro calls around the function
408417
# defs to move them into RAM.
409418
if (PICO_ON_DEVICE AND NOT PICO_NO_FLASH AND NOT PICO_COPY_TO_RAM)
410-
pico_set_linker_script(${MICROPY_TARGET} ${CMAKE_CURRENT_LIST_DIR}/memmap_mp.ld)
419+
pico_set_linker_script(${MICROPY_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/memmap_mp.ld)
411420
endif()
412421

422+
413423
pico_add_extra_outputs(${MICROPY_TARGET})
414424

415425
add_custom_command(TARGET ${MICROPY_TARGET}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
# cmake file for Adafruit Feather RP2040
2+
set(MICROPY_HW_FLASH_SIZE_BYTES "8 * 1024 * 1024")
3+
set(MICROPY_HW_APP_SIZE_BYTES "1 * 1024 * 1024")

ports/rp2/boards/ADAFRUIT_FEATHER_RP2040/mpconfigboard.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// https://learn.adafruit.com/adafruit-feather-rp2040-pico/pinouts
33

44
#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040"
5-
#define MICROPY_HW_FLASH_STORAGE_BYTES (7 * 1024 * 1024)
65

76
#define MICROPY_HW_USB_VID (0x239A)
87
#define MICROPY_HW_USB_PID (0x80F2)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
# cmake file for Adafruit ItsyBitsy RP2040
2+
set(MICROPY_HW_FLASH_SIZE_BYTES "8 * 1024 * 1024")
3+
set(MICROPY_HW_APP_SIZE_BYTES "1 * 1024 * 1024")
4+

ports/rp2/boards/ADAFRUIT_ITSYBITSY_RP2040/mpconfigboard.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// https://learn.adafruit.com/adafruit-itsybitsy-rp2040/pinouts
33

44
#define MICROPY_HW_BOARD_NAME "Adafruit ItsyBitsy RP2040"
5-
#define MICROPY_HW_FLASH_STORAGE_BYTES (7 * 1024 * 1024)
65

76
#define MICROPY_HW_USB_VID (0x239A)
87
#define MICROPY_HW_USB_PID (0x80FE)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
# cmake file for Adafruit QT Py RP2040
2+
set(MICROPY_HW_FLASH_SIZE_BYTES "8 * 1024 * 1024")
3+
set(MICROPY_HW_APP_SIZE_BYTES "1 * 1024 * 1024")
4+

ports/rp2/boards/ADAFRUIT_QTPY_RP2040/mpconfigboard.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// https://learn.adafruit.com/adafruit-qt-py-2040/pinouts
33

44
#define MICROPY_HW_BOARD_NAME "Adafruit QT Py RP2040"
5-
#define MICROPY_HW_FLASH_STORAGE_BYTES (7 * 1024 * 1024)
65

76
#define MICROPY_HW_USB_VID (0x239A)
87
#define MICROPY_HW_USB_PID (0x80F8)

ports/rp2/boards/ARDUINO_NANO_RP2040_CONNECT/mpconfigboard.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# cmake file for Arduino Nano RP2040 Connect.
2+
3+
# This is a 16MB board? Was an 8MB firmware size intentional?
4+
# https://github.com/raspberrypi/pico-sdk/blob/master/src/boards/include/boards/arduino_nano_rp2040_connect.h#L76
5+
set(MICROPY_HW_FLASH_SIZE_BYTES "16 * 1024 * 1024")
6+
set(MICROPY_HW_APP_SIZE_BYTES "8 * 1024 * 1024")
7+
28
set(MICROPY_PY_BLUETOOTH 1)
39
set(MICROPY_BLUETOOTH_NIMBLE 1)
410
set(MICROPY_PY_NETWORK_NINAW10 1)

ports/rp2/boards/ARDUINO_NANO_RP2040_CONNECT/mpconfigboard.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
// Board and hardware specific configuration
44
#define MICROPY_HW_BOARD_NAME "Arduino Nano RP2040 Connect"
5-
#define MICROPY_HW_FLASH_STORAGE_BYTES (8 * 1024 * 1024)
65

76
// Enable networking.
87
#define MICROPY_PY_NETWORK (1)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# cmake file
22

3+
set(MICROPY_HW_FLASH_SIZE_BYTES "1 * 1024 * 1024")
4+
set(MICROPY_HW_APP_SIZE_BYTES "384 * 1024")
35
set(PICO_BOARD garatronic_pybstick26_rp2040)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy