8 Commits

Author SHA1 Message Date
7facf4286c rp2: Increase micropython stack allocation
We were running out of stack for micropython, and the core1 code doesn't
need 4k. So shift the allocation so that micropython has 6k and core1
has 2k. Adjust the linker script since it didn't support splitting
SCRATCH_X between the two stacks.

Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
2025-08-20 19:56:13 +02:00
ccdecf255d rp2: Allow using btree module with rp2 port
Integrate btree extmod in rp2 CMakeLists so it can be enabeled with
MICROPY_PY_BTREE=On.

Default values for DEFPSIZE and MINCACHE copied from esp8266 board.

Note: To be able to use the btree module, you must set the
MICROPY_C_HEAP_SIZE CMake option to at least 8192.
2025-08-19 19:57:04 +02:00
Angus Gratton
a792c8f3bf lib/littlefs: Fix string initializer in lfs1.c.
Avoids the new Wunterminated-string-literal when compiled with gcc 15.1.

It would be preferable to just disable this warning, but Clang
-Wunknown-warning-option kicks in even when disabling warnings so this
becomes fiddly to apply.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-20 20:04:43 +02:00
Angus Gratton
f4ff9dac89 py/emitinlinethumb: Refactor string literal as array initializer.
Avoids the new Wunterminated-string-literal when compiled with gcc 15.1.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-20 20:04:31 +02:00
Angus Gratton
fb05f048e9 extmod/moductypes: Refactor string literal as array initializer.
Avoids the new Wunterminated-string-literal when compiled with gcc 15.1.

Also split out the duplicate string to a top-level array (probably the
duplicate string literal was interned, so unlikely to have any impact.)

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-20 20:04:17 +02:00
Angus Gratton
f6a4651af9 rp2: Add temporary workaround for GCC 15.1 build failure.
This is a workaround for this upstream issue:
https://github.com/raspberrypi/pico-sdk/issues/2448

Can be removed after the next pico-sdk update.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-20 20:03:58 +02:00
33dc78967d rp2: Fix stacks for multicore operation
Unfortunately, no way to override this from board config.
2025-05-20 19:57:07 +02:00
074dd7ac06 rp2: Modify linker script to run MP3 decoder from RAM 2025-05-20 19:56:50 +02:00
6 changed files with 136 additions and 62 deletions

View File

@@ -277,15 +277,18 @@ static mp_obj_t uctypes_struct_sizeof(size_t n_args, const mp_obj_t *args) {
}
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(uctypes_struct_sizeof_obj, 1, 2, uctypes_struct_sizeof);
static const char type2char[16] = {
'B', 'b', 'H', 'h', 'I', 'i', 'Q', 'q',
'-', '-', '-', '-', '-', '-', 'f', 'd'
};
static inline mp_obj_t get_unaligned(uint val_type, byte *p, int big_endian) {
char struct_type = big_endian ? '>' : '<';
static const char type2char[16] = "BbHhIiQq------fd";
return mp_binary_get_val(struct_type, type2char[val_type], p, &p);
}
static inline void set_unaligned(uint val_type, byte *p, int big_endian, mp_obj_t val) {
char struct_type = big_endian ? '>' : '<';
static const char type2char[16] = "BbHhIiQq------fd";
mp_binary_set_val(struct_type, type2char[val_type], val, p, &p);
}

View File

@@ -2141,7 +2141,7 @@ int lfs1_format(lfs1_t *lfs1, const struct lfs1_config *cfg) {
.d.elen = sizeof(superblock.d) - sizeof(superblock.d.magic) - 4,
.d.nlen = sizeof(superblock.d.magic),
.d.version = LFS1_DISK_VERSION,
.d.magic = {"littlefs"},
.d.magic = {'l', 'i', 't', 't', 'l', 'e', 'f', 's'},
.d.block_size = lfs1->cfg->block_size,
.d.block_count = lfs1->cfg->block_count,
.d.root = {lfs1->root[0], lfs1->root[1]},

View File

@@ -79,6 +79,9 @@ endif()
list(APPEND GIT_SUBMODULES lib/mbedtls)
list(APPEND GIT_SUBMODULES lib/tinyusb)
# Workaround for pico-sdk host toolchain issue, see directory for details
list(APPEND CMAKE_MODULE_PATH "${MICROPY_PORT_DIR}/tools_patch")
# Include component cmake fragments
include(${MICROPY_DIR}/py/py.cmake)
include(${MICROPY_DIR}/extmod/extmod.cmake)
@@ -471,6 +474,15 @@ if (MICROPY_PY_NETWORK_WIZNET5K)
)
endif()
if (MICROPY_PY_BTREE)
target_link_libraries(${MICROPY_TARGET} micropy_extmod_btree)
target_compile_definitions(${MICROPY_TARGET} PRIVATE
MICROPY_STREAMS_POSIX_API=1
MICROPY_BERKELEY_DB_DEFPSIZE=1024
MICROPY_BERKELEY_DB_MINCACHE=3
)
endif()
# Add qstr sources for extmod and usermod, in case they are modified by components above.
list(APPEND MICROPY_SOURCE_QSTR
${MICROPY_SOURCE_EXTMOD}
@@ -551,13 +563,14 @@ set_source_files_properties(
)
target_compile_definitions(${MICROPY_TARGET} PRIVATE
${MICROPY_DEF_CORE}
${MICROPY_DEF_BOARD}
FFCONF_H=\"${MICROPY_OOFATFS_DIR}/ffconf.h\"
LFS1_NO_MALLOC LFS1_NO_DEBUG LFS1_NO_WARN LFS1_NO_ERROR LFS1_NO_ASSERT
LFS2_NO_MALLOC LFS2_NO_DEBUG LFS2_NO_WARN LFS2_NO_ERROR LFS2_NO_ASSERT
PICO_FLOAT_PROPAGATE_NANS=1
PICO_STACK_SIZE=0x2000
PICO_CORE1_STACK_SIZE=0
PICO_STACK_SIZE=0x1800
PICO_CORE1_STACK_SIZE=0x800
PICO_MAX_SHARED_IRQ_HANDLERS=8 # we need more than the default
PICO_PROGRAM_NAME="MicroPython"
PICO_NO_PROGRAM_VERSION_STRING=1 # do it ourselves in main.c

View File

@@ -69,7 +69,7 @@ SECTIONS
* FLASH ... we will include any thing excluded here in .data below by default */
*(.init)
/* Change for MicroPython... exclude gc.c, parse.c, vm.c from flash */
*(EXCLUDE_FILE(*libgcc.a: *libc.a: *lib_a-mem*.o *libm.a: *gc.c.obj *vm.c.obj *parse.c.obj) .text*)
*(EXCLUDE_FILE(*libgcc.a: *libc.a: *lib_a-mem*.o *libm.a: *gc.c.obj *vm.c.obj *parse.c.obj *libhelix_mp3.a:) .text*)
*(.fini)
/* Pull all c'tors into .text */
*crtbegin.o(.ctors)
@@ -89,7 +89,7 @@ SECTIONS
} > FLASH
.rodata : {
*(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .rodata*)
*(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a: *libhelix_mp3.a:) .rodata*)
. = ALIGN(4);
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*)))
. = ALIGN(4);
@@ -250,7 +250,7 @@ SECTIONS
__GcHeapEnd = ORIGIN(RAM) + LENGTH(RAM);
/* Define memory for the C stack */
__StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X);
__StackOneTop = ORIGIN(SCRATCH_X) + SIZEOF(.stack1_dummy);
__StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y);
__StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy);
__StackBottom = __StackTop - SIZEOF(.stack_dummy);

View File

@@ -0,0 +1,58 @@
# Finds (or builds) the pioasm executable
#
# This will define the following imported targets
#
# pioasm
#
# This is a temporary patched copy of pico-sdk file Findpioasm.cmake to work around
# a host toolchain issue with GCC 15.1:
# https://github.com/raspberrypi/pico-sdk/issues/2448
if (NOT TARGET pioasm)
# todo we would like to use pckgconfig to look for it first
# see https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
include(ExternalProject)
set(PIOASM_SOURCE_DIR ${PICO_SDK_PATH}/tools/pioasm)
set(PIOASM_BINARY_DIR ${CMAKE_BINARY_DIR}/pioasm)
set(PIOASM_INSTALL_DIR ${CMAKE_BINARY_DIR}/pioasm-install CACHE PATH "Directory where pioasm has been installed" FORCE)
set(pioasmBuild_TARGET pioasmBuild)
set(pioasm_TARGET pioasm)
if (NOT TARGET ${pioasmBuild_TARGET})
pico_message_debug("PIOASM will need to be built")
# message("Adding external project ${pioasmBuild_Target} in ${CMAKE_CURRENT_LIST_DIR}}")
ExternalProject_Add(${pioasmBuild_TARGET}
PREFIX pioasm
SOURCE_DIR ${PIOASM_SOURCE_DIR}
BINARY_DIR ${PIOASM_BINARY_DIR}
INSTALL_DIR ${PIOASM_INSTALL_DIR}
CMAKE_ARGS
"--no-warn-unused-cli"
"-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}"
"-DPIOASM_FLAT_INSTALL=1"
"-DCMAKE_INSTALL_PREFIX=${PIOASM_INSTALL_DIR}"
"-DCMAKE_RULE_MESSAGES=OFF" # quieten the build
"-DCMAKE_INSTALL_MESSAGE=NEVER" # quieten the install
# Toolchain workaround follows
"-DCMAKE_CXX_FLAGS=-include cstdint"
CMAKE_CACHE_ARGS "-DPIOASM_EXTRA_SOURCE_FILES:STRING=${PIOASM_EXTRA_SOURCE_FILES}"
BUILD_ALWAYS 1 # force dependency checking
EXCLUDE_FROM_ALL TRUE
)
endif()
if (CMAKE_HOST_WIN32)
set(pioasm_EXECUTABLE ${PIOASM_INSTALL_DIR}/pioasm/pioasm.exe)
else()
set(pioasm_EXECUTABLE ${PIOASM_INSTALL_DIR}/pioasm/pioasm)
endif()
add_executable(${pioasm_TARGET} IMPORTED GLOBAL)
set_property(TARGET ${pioasm_TARGET} PROPERTY IMPORTED_LOCATION
${pioasm_EXECUTABLE})
add_dependencies(${pioasm_TARGET} ${pioasmBuild_TARGET})
endif()

View File

@@ -150,27 +150,27 @@ typedef struct _reg_name_t { byte reg;
byte name[3];
} reg_name_t;
static const reg_name_t reg_name_table[] = {
{0, "r0\0"},
{1, "r1\0"},
{2, "r2\0"},
{3, "r3\0"},
{4, "r4\0"},
{5, "r5\0"},
{6, "r6\0"},
{7, "r7\0"},
{8, "r8\0"},
{9, "r9\0"},
{10, "r10"},
{11, "r11"},
{12, "r12"},
{13, "r13"},
{14, "r14"},
{15, "r15"},
{10, "sl\0"},
{11, "fp\0"},
{13, "sp\0"},
{14, "lr\0"},
{15, "pc\0"},
{0, {'r', '0' }},
{1, {'r', '1' }},
{2, {'r', '2' }},
{3, {'r', '3' }},
{4, {'r', '4' }},
{5, {'r', '5' }},
{6, {'r', '6' }},
{7, {'r', '7' }},
{8, {'r', '8' }},
{9, {'r', '9' }},
{10, {'r', '1', '0' }},
{11, {'r', '1', '1' }},
{12, {'r', '1', '2' }},
{13, {'r', '1', '3' }},
{14, {'r', '1', '4' }},
{15, {'r', '1', '5' }},
{10, {'s', 'l' }},
{11, {'f', 'p' }},
{13, {'s', 'p' }},
{14, {'l', 'r' }},
{15, {'p', 'c' }},
};
#define MAX_SPECIAL_REGISTER_NAME_LENGTH 7
@@ -368,20 +368,20 @@ typedef struct _cc_name_t { byte cc;
byte name[2];
} cc_name_t;
static const cc_name_t cc_name_table[] = {
{ ASM_THUMB_CC_EQ, "eq" },
{ ASM_THUMB_CC_NE, "ne" },
{ ASM_THUMB_CC_CS, "cs" },
{ ASM_THUMB_CC_CC, "cc" },
{ ASM_THUMB_CC_MI, "mi" },
{ ASM_THUMB_CC_PL, "pl" },
{ ASM_THUMB_CC_VS, "vs" },
{ ASM_THUMB_CC_VC, "vc" },
{ ASM_THUMB_CC_HI, "hi" },
{ ASM_THUMB_CC_LS, "ls" },
{ ASM_THUMB_CC_GE, "ge" },
{ ASM_THUMB_CC_LT, "lt" },
{ ASM_THUMB_CC_GT, "gt" },
{ ASM_THUMB_CC_LE, "le" },
{ ASM_THUMB_CC_EQ, { 'e', 'q' }},
{ ASM_THUMB_CC_NE, { 'n', 'e' }},
{ ASM_THUMB_CC_CS, { 'c', 's' }},
{ ASM_THUMB_CC_CC, { 'c', 'c' }},
{ ASM_THUMB_CC_MI, { 'm', 'i' }},
{ ASM_THUMB_CC_PL, { 'p', 'l' }},
{ ASM_THUMB_CC_VS, { 'v', 's' }},
{ ASM_THUMB_CC_VC, { 'v', 'c' }},
{ ASM_THUMB_CC_HI, { 'h', 'i' }},
{ ASM_THUMB_CC_LS, { 'l', 's' }},
{ ASM_THUMB_CC_GE, { 'g', 'e' }},
{ ASM_THUMB_CC_LT, { 'l', 't' }},
{ ASM_THUMB_CC_GT, { 'g', 't' }},
{ ASM_THUMB_CC_LE, { 'l', 'e' }},
};
typedef struct _format_4_op_t { byte op;
@@ -389,21 +389,21 @@ typedef struct _format_4_op_t { byte op;
} format_4_op_t;
#define X(x) (((x) >> 4) & 0xff) // only need 1 byte to distinguish these ops
static const format_4_op_t format_4_op_table[] = {
{ X(ASM_THUMB_FORMAT_4_EOR), "eor" },
{ X(ASM_THUMB_FORMAT_4_LSL), "lsl" },
{ X(ASM_THUMB_FORMAT_4_LSR), "lsr" },
{ X(ASM_THUMB_FORMAT_4_ASR), "asr" },
{ X(ASM_THUMB_FORMAT_4_ADC), "adc" },
{ X(ASM_THUMB_FORMAT_4_SBC), "sbc" },
{ X(ASM_THUMB_FORMAT_4_ROR), "ror" },
{ X(ASM_THUMB_FORMAT_4_TST), "tst" },
{ X(ASM_THUMB_FORMAT_4_NEG), "neg" },
{ X(ASM_THUMB_FORMAT_4_CMP), "cmp" },
{ X(ASM_THUMB_FORMAT_4_CMN), "cmn" },
{ X(ASM_THUMB_FORMAT_4_ORR), "orr" },
{ X(ASM_THUMB_FORMAT_4_MUL), "mul" },
{ X(ASM_THUMB_FORMAT_4_BIC), "bic" },
{ X(ASM_THUMB_FORMAT_4_MVN), "mvn" },
{ X(ASM_THUMB_FORMAT_4_EOR), {'e', 'o', 'r' }},
{ X(ASM_THUMB_FORMAT_4_LSL), {'l', 's', 'l' }},
{ X(ASM_THUMB_FORMAT_4_LSR), {'l', 's', 'r' }},
{ X(ASM_THUMB_FORMAT_4_ASR), {'a', 's', 'r' }},
{ X(ASM_THUMB_FORMAT_4_ADC), {'a', 'd', 'c' }},
{ X(ASM_THUMB_FORMAT_4_SBC), {'s', 'b', 'c' }},
{ X(ASM_THUMB_FORMAT_4_ROR), {'r', 'o', 'r' }},
{ X(ASM_THUMB_FORMAT_4_TST), {'t', 's', 't' }},
{ X(ASM_THUMB_FORMAT_4_NEG), {'n', 'e', 'g' }},
{ X(ASM_THUMB_FORMAT_4_CMP), {'c', 'm', 'p' }},
{ X(ASM_THUMB_FORMAT_4_CMN), {'c', 'm', 'n' }},
{ X(ASM_THUMB_FORMAT_4_ORR), {'o', 'r', 'r' }},
{ X(ASM_THUMB_FORMAT_4_MUL), {'m', 'u', 'l' }},
{ X(ASM_THUMB_FORMAT_4_BIC), {'b', 'i', 'c' }},
{ X(ASM_THUMB_FORMAT_4_MVN), {'m', 'v', 'n' }},
};
#undef X
@@ -428,10 +428,10 @@ typedef struct _format_vfp_op_t {
char name[3];
} format_vfp_op_t;
static const format_vfp_op_t format_vfp_op_table[] = {
{ 0x30, "add" },
{ 0x34, "sub" },
{ 0x20, "mul" },
{ 0x80, "div" },
{ 0x30, {'a', 'd', 'd' }},
{ 0x34, {'s', 'u', 'b' }},
{ 0x20, {'m', 'u', 'l' }},
{ 0x80, {'d', 'i', 'v' }},
};
// shorthand alias for whether we allow ARMv7-M instructions