diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index c5f88a827b..a90f78d8e4 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -2,7 +2,7 @@ "env": { // TODO: This is a duplication of the configuration set in /docker/build.sh! "TOOLS_DIR": "/opt", - "GCC_ARM_PATH": "gcc-arm-none-eabi-10.3-2021.10" + "GCC_ARM_PATH": "arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi" }, "configurations": [ { diff --git a/.vscode/launch.json b/.vscode/launch.json index 7d3f17a11c..afd37c9ead 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -53,7 +53,7 @@ "continue" ], // Only use armToolchainPath if your arm-none-eabi-gdb is not in your path (some GCC packages does not contain arm-none-eabi-gdb) - "armToolchainPath": "${workspaceRoot}/../gcc-arm-none-eabi-10.3-2021.10/bin", + "armToolchainPath": "${workspaceRoot}/../arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi/bin", "svdFile": "${workspaceRoot}/nrf52.svd", "configFiles": [ "interface/stlink.cfg", @@ -68,7 +68,7 @@ "request": "launch", "servertype": "external", // FIXME: This is hardcoded. I have no idea how to use the values set in build.sh here - "gdbPath": "/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb", + "gdbPath": "/opt/arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb", // Connect to an already running OpenOCD instance "gdbTarget": "host.docker.internal:3333", "svdFile": "${workspaceRoot}/nrf52.svd", diff --git a/doc/buildAndProgram.md b/doc/buildAndProgram.md index 5d3af46ef0..8fb765a009 100644 --- a/doc/buildAndProgram.md +++ b/doc/buildAndProgram.md @@ -4,7 +4,7 @@ To build this project, you'll need: -- A cross-compiler : [ARM-GCC (10.3-2021.10)](https://developer.arm.com/downloads/-/gnu-rm) +- A cross-compiler : [ARM-GCC 15.2-Rel1 from December 17, 2025 (AArch32 bare-metal targetĀ (arm-none-eabi))](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) - The NRF52 SDK 15.3.0 : [nRF-SDK v15.3.0](https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/nrf5sdk153059ac345.zip) - The Python 3 modules `cbor`, `intelhex`, `click` and `cryptography` modules for the `mcuboot` tool (see [requirements.txt](../tools/mcuboot/requirements.txt)) - To keep the system clean, you can install python modules into a python virtual environment (`venv`) @@ -38,7 +38,7 @@ CMake configures the project according to variables you specify the command line Variable | Description | Example| ----------|-------------|--------| -**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`-DARM_NONE_EABI_TOOLCHAIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-10.3-2021.10/`| +**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`-DARM_NONE_EABI_TOOLCHAIN_PATH=/home/jf/nrf52/arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi/`| **NRF5_SDK_PATH**|path to the NRF52 SDK|`-DNRF5_SDK_PATH=/home/jf/nrf52/Pinetime/sdk`| **CMAKE_BUILD_TYPE (\*)**| Build type (Release or Debug). Release is applied by default if this variable is not specified.|`-DCMAKE_BUILD_TYPE=Debug` **BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-DBUILD_DFU=1` diff --git a/doc/buildWithVScode.md b/doc/buildWithVScode.md index 5f8724828a..9d9575356b 100644 --- a/doc/buildWithVScode.md +++ b/doc/buildWithVScode.md @@ -8,7 +8,7 @@ To support as many setups as possible the VS Code configuration files expect the Variable | Description | Example ----------|-------------|-------- -**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`export ARM_NONE_EABI_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi-10.3-2021.10` +**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`export ARM_NONE_EABI_TOOLCHAIN_PATH=/opt/arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi` **NRF5_SDK_PATH**|path to the NRF52 SDK|`export NRF5_SDK_PATH=/opt/nRF5_SDK_15.3.0_59ac345` ## VS Code Extensions diff --git a/docker/build.sh b/docker/build.sh index b7637f4990..31db89f142 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -16,7 +16,7 @@ export NPM_DIR="$BUILD_DIR/npm" export npm_config_cache="${NPM_DIR}" export BUILD_TYPE=${BUILD_TYPE:=Release} -export GCC_ARM_VER=${GCC_ARM_VER:="10.3-2021.10"} +export GCC_ARM_VER=${GCC_ARM_VER:="15.2.rel1"} export NRF_SDK_VER=${NRF_SDK_VER:="nRF5_SDK_15.3.0_59ac345"} # convert to lower case and remove _ and . character # the download URL uses the SLUG, but the extracted folder is named like the original value @@ -26,7 +26,7 @@ export NRF_SDK_VER_SLUG=${NRF_SDK_VER_SLUG//[_.]/} MACHINE="$(uname -m)" [ "$MACHINE" = "arm64" ] && MACHINE="aarch64" -export GCC_ARM_PATH="gcc-arm-none-eabi-$GCC_ARM_VER" +export GCC_ARM_PATH="arm-gnu-toolchain-$GCC_ARM_VER-$MACHINE-arm-none-eabi" main() { local target="$1" @@ -50,7 +50,7 @@ main() { } GetGcc() { - wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/$GCC_ARM_VER/$GCC_ARM_PATH-$MACHINE-linux.tar.bz2 -O - | tar -xj -C $TOOLS_DIR/ + wget -q https://developer.arm.com/-/media/Files/downloads/gnu/$GCC_ARM_VER/binrel/$GCC_ARM_PATH.tar.xz -O - | tar -xJ -C $TOOLS_DIR/ if [ ! -d "$TOOLS_DIR/$GCC_ARM_PATH" ]; then echo "missing GCC path: $TOOLS_DIR/$GCC_ARM_PATH" return 1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e4a354df64..faef4160da 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -930,7 +930,7 @@ target_compile_options(${EXECUTABLE_NAME} PUBLIC set_target_properties(${EXECUTABLE_NAME} PROPERTIES SUFFIX ".out" - LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_FILE_NAME}.map" + LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_FILE_NAME}.map" ) add_custom_command(TARGET ${EXECUTABLE_NAME} @@ -965,7 +965,7 @@ target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES SUFFIX ".out" - LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_MCUBOOT_FILE_NAME}.map" + LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_MCUBOOT_FILE_NAME}.map" ) add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME} @@ -1008,7 +1008,7 @@ target_compile_options(${EXECUTABLE_RECOVERY_NAME} PUBLIC set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES SUFFIX ".out" - LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_RECOVERY_FILE_NAME}.map" + LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_RECOVERY_FILE_NAME}.map" ) add_custom_command(TARGET ${EXECUTABLE_RECOVERY_NAME} @@ -1040,7 +1040,7 @@ target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES SUFFIX ".out" - LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_GRAPHICS_FILE_NAME}.map" + LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_GRAPHICS_FILE_NAME}.map" ) add_custom_command(TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME} @@ -1083,7 +1083,7 @@ add_dependencies(${EXECUTABLE_RECOVERYLOADER_NAME} ${EXECUTABLE_RECOVERY_MCUBOOT set_target_properties(${EXECUTABLE_RECOVERYLOADER_NAME} PROPERTIES SUFFIX ".out" - LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_RECOVERYLOADER_FILE_NAME}.map" + LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_RECOVERYLOADER_FILE_NAME}.map" ) add_custom_command(TARGET ${EXECUTABLE_RECOVERYLOADER_NAME} @@ -1118,7 +1118,7 @@ add_dependencies(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} ${EXECUTABLE_RECOVERY set_target_properties(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PROPERTIES SUFFIX ".out" - LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.map" + LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.map" ) add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} diff --git a/src/stdlib.c b/src/stdlib.c index 21b506a843..18884c4893 100644 --- a/src/stdlib.c +++ b/src/stdlib.c @@ -1,6 +1,8 @@ #include #include #include +#include +#include // Override malloc() and free() to use the memory manager from FreeRTOS. // According to the documentation of libc, we also need to override @@ -29,7 +31,7 @@ void __wrap_free(void* ptr) { } void* calloc(size_t num, size_t size) { - void *ptr = malloc(num * size); + void* ptr = malloc(num * size); if (ptr) { memset(ptr, 0, num * size); } @@ -49,3 +51,58 @@ void* realloc(void* ptr, size_t newSize) { void* __wrap_realloc(void* ptr, size_t newSize) { return realloc(ptr, newSize); } + +// Implement functions required by libc as stubs +// These functions aren't linked into the final binary + +__attribute__((error("stub"))) void _close(int fp) { + __builtin_trap(); + (void) fp; +} + +__attribute__((error("stub"))) void _fstat(int fildes, struct stat* buf) { + __builtin_trap(); + (void) fildes; + (void) buf; +} + +__attribute__((error("stub"))) pid_t _getpid() { + __builtin_trap(); +} + +__attribute__((error("stub"))) int _isatty(int fd) { + __builtin_trap(); + (void) fd; +} + +__attribute__((error("stub"))) int _kill(pid_t pid, int sig) { + __builtin_trap(); + (void) pid; + (void) sig; +} + +__attribute__((error("stub"))) off_t _lseek(int fd, off_t offset, int whence) { + __builtin_trap(); + (void) fd; + (void) offset; + (void) whence; +} + +__attribute__((error("stub"))) ssize_t _read(int fd, void* buf, size_t count) { + __builtin_trap(); + (void) fd; + (void) buf; + (void) count; +} + +__attribute__((error("stub"))) ssize_t _write(int fd, void* buf, size_t count) { + __builtin_trap(); + (void) fd; + (void) buf; + (void) count; +} + +__attribute__((error("stub"))) void _exit(int status) { + __builtin_trap(); + (void) status; +}