diff --git a/.github/workflows/build_aarch64.yml b/.github/workflows/build_aarch64.yml
index e5dbf9494..237692498 100644
--- a/.github/workflows/build_aarch64.yml
+++ b/.github/workflows/build_aarch64.yml
@@ -47,7 +47,7 @@ jobs:
run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
- name: Cache Toolchain
- uses: actions/cache@v3
+ uses: actions/cache@v4
id: cache-toolchain
with:
path: ~/cache/
diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml
index 9f3270c91..12e6615ea 100644
--- a/.github/workflows/build_arm.yml
+++ b/.github/workflows/build_arm.yml
@@ -41,7 +41,6 @@ jobs:
- 'lpc51'
- 'mm32 msp432e4'
- 'samd11 same5x saml2x'
- - 'stm32f2 stm32f3'
- 'stm32l0 stm32wb'
- 'tm4c123 xmc4000'
steps:
diff --git a/.github/workflows/cmake_arm.yml b/.github/workflows/build_cmake.yml
similarity index 51%
rename from .github/workflows/cmake_arm.yml
rename to .github/workflows/build_cmake.yml
index 1e5f61e0e..65de47e8d 100644
--- a/.github/workflows/cmake_arm.yml
+++ b/.github/workflows/build_cmake.yml
@@ -1,4 +1,4 @@
-name: CMake ARM
+name: Build CMake
on:
workflow_dispatch:
@@ -10,7 +10,7 @@ on:
- 'hw/**'
- 'test/hil/**'
- 'tools/get_deps.py'
- - '.github/workflows/cmake_arm.yml'
+ - '.github/workflows/build_cmake.yml'
pull_request:
branches: [ master ]
paths:
@@ -20,7 +20,7 @@ on:
- 'hw/**'
- 'test/hil/**'
- 'tools/get_deps.py'
- - '.github/workflows/cmake_arm.yml'
+ - '.github/workflows/build_cmake.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -28,9 +28,9 @@ concurrency:
jobs:
# ---------------------------------------
- # Build ARM family
+ # Build ARM with GCC
# ---------------------------------------
- build-arm:
+ arm-gcc:
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -49,6 +49,8 @@ jobs:
- 'samd51'
- 'stm32f0'
- 'stm32f1'
+ - 'stm32f2'
+ - 'stm32f3'
- 'stm32f4'
- 'stm32f7'
- 'stm32g0'
@@ -66,10 +68,7 @@ jobs:
- name: Install ARM GCC
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
- release: '11.2-2022.02'
-
- - name: Install Ninja
- run: sudo apt install -y ninja-build
+ release: '12.3.Rel1'
- name: Checkout TinyUSB
uses: actions/checkout@v4
@@ -83,12 +82,13 @@ jobs:
path: pico-sdk
- name: Get Dependencies
- run: python3 tools/get_deps.py ${{ matrix.family }}
+ run: |
+ sudo apt install -y ninja-build
+ python3 tools/get_deps.py ${{ matrix.family }}
- name: Build
run: python tools/build_cmake.py ${{ matrix.family }} -DCMAKE_BUILD_TYPE=MinSizeRel
env:
- # for rp2040, there is no harm if defined for other families
PICO_SDK_PATH: ${{ github.workspace }}/pico-sdk
- name: Upload Artifacts for Hardware Testing (rp2040)
@@ -115,6 +115,129 @@ jobs:
path: |
cmake-build/cmake-build-itsybitsy_m4/*/*/*.bin
+ # ---------------------------------------
+ # Build ARM with Clang
+ # ---------------------------------------
+ arm-clang:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ family:
+ # Alphabetical order
+ - 'imxrt'
+ - 'kinetis_k kinetis_kl'
+ - 'lpc17 lpc18 lpc40 lpc43'
+ - 'lpc54 lpc55'
+ #- 'mcx' not working with gcc anymore, need to fix this first
+ - 'nrf'
+ #- 'ra' port later
+ #- 'rp2040' port later
+ - 'samd21'
+ - 'samd51'
+ - 'stm32f0'
+ - 'stm32f1'
+ - 'stm32f2'
+ - 'stm32f3'
+ - 'stm32f4'
+ - 'stm32f7'
+ - 'stm32g0'
+ - 'stm32g4'
+ - 'stm32h5'
+ - 'stm32h7'
+ - 'stm32l4'
+ - 'stm32u5'
+ steps:
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.x'
+
+ - name: Checkout TinyUSB
+ uses: actions/checkout@v4
+
+ - name: Checkout pico-sdk for rp2040
+ if: matrix.family == 'rp2040'
+ uses: actions/checkout@v4
+ with:
+ repository: raspberrypi/pico-sdk
+ ref: develop
+ path: pico-sdk
+
+ - name: Set Toolchain URL
+ run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-17.0.1/LLVMEmbeddedToolchainForArm-17.0.1-Linux-x86_64.tar.xz
+
+ - name: Cache Toolchain
+ uses: actions/cache@v4
+ id: cache-toolchain
+ with:
+ path: ~/cache/
+ key: ${{ runner.os }}-24-04-17-${{ env.TOOLCHAIN_URL }}
+
+ - name: Install Toolchain
+ if: steps.cache-toolchain.outputs.cache-hit != 'true'
+ run: |
+ mkdir -p ~/cache/toolchain
+ wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.xz
+ tar -C ~/cache/toolchain -xaf toolchain.tar.xz
+
+ - name: Prepare to build
+ run: |
+ echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
+ sudo apt install -y ninja-build
+ python3 tools/get_deps.py ${{ matrix.family }}
+
+ - name: Build
+ run: python tools/build_cmake.py ${{ matrix.family }} -DTOOLCHAIN=clang -DCMAKE_BUILD_TYPE=MinSizeRel
+ env:
+ PICO_SDK_PATH: ${{ github.workspace }}/pico-sdk
+
+ # ---------------------------------------
+ # Build MSP430 with GCC
+ # ---------------------------------------
+ msp430-gcc:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ family:
+ # Alphabetical order
+ - 'msp430'
+ steps:
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.x'
+
+ - name: Checkout TinyUSB
+ uses: actions/checkout@v4
+
+ - name: Set Toolchain URL
+ run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2
+
+ - name: Cache Toolchain
+ uses: actions/cache@v4
+ id: cache-toolchain
+ with:
+ path: ~/cache/
+ key: ${{ runner.os }}-24-04-17-${{ env.TOOLCHAIN_URL }}
+
+ - name: Install Toolchain
+ if: steps.cache-toolchain.outputs.cache-hit != 'true'
+ run: |
+ mkdir -p ~/cache/toolchain
+ wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.bz2
+ tar -C ~/cache/toolchain -xaf toolchain.tar.bz2
+
+ - name: Prepare to build
+ run: |
+ echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
+ sudo apt install -y ninja-build
+ python3 tools/get_deps.py ${{ matrix.family }}
+
+ - name: Build
+ run: python tools/build_cmake.py ${{ matrix.family }} -DCMAKE_BUILD_TYPE=MinSizeRel
+
# ---------------------------------------
# Hardware in the loop (HIL)
# Current self-hosted instance is running on an RPI4. For attached hardware checkout hil_pi4.json
@@ -122,7 +245,7 @@ jobs:
hil-test:
# run only with hathach's commit due to limited resource on RPI4
if: github.repository_owner == 'hathach'
- needs: build-arm
+ needs: arm-gcc
runs-on: [self-hosted, rp2040, nrf52840, hardware-in-the-loop]
strategy:
fail-fast: false
diff --git a/.github/workflows/build_esp.yml b/.github/workflows/build_esp.yml
index d283c6535..4108a58a5 100644
--- a/.github/workflows/build_esp.yml
+++ b/.github/workflows/build_esp.yml
@@ -34,7 +34,7 @@ jobs:
# ESP32-S2
- 'espressif_kaluga_1'
# ESP32-S3
- - 'espressif_s3_devkitc'
+ - 'espressif_s3_devkitm'
steps:
- name: Setup Python
uses: actions/setup-python@v5
@@ -51,7 +51,7 @@ jobs:
run: docker run --rm -v $PWD:/project -w /project espressif/idf:v5.1.1 python3 tools/build_esp32.py ${{ matrix.board }}
- name: Upload Artifacts for Hardware Testing
- if: matrix.board == 'espressif_s3_devkitc' && github.repository_owner == 'hathach'
+ if: matrix.board == 'espressif_s3_devkitm' && github.repository_owner == 'hathach'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.board }}
@@ -75,7 +75,7 @@ jobs:
fail-fast: false
matrix:
board:
- - 'espressif_s3_devkitc'
+ - 'espressif_s3_devkitm'
steps:
- name: Clean workspace
run: |
diff --git a/.github/workflows/build_msp430.yml b/.github/workflows/build_msp430.yml
deleted file mode 100644
index 95d212708..000000000
--- a/.github/workflows/build_msp430.yml
+++ /dev/null
@@ -1,71 +0,0 @@
-name: Build MSP430
-
-on:
- workflow_dispatch:
- push:
- paths:
- - 'src/**'
- - 'examples/**'
- - 'lib/**'
- - 'hw/**'
- - 'tools/get_deps.py'
- - '.github/workflows/build_msp430.yml'
- pull_request:
- branches: [ master ]
- paths:
- - 'src/**'
- - 'examples/**'
- - 'lib/**'
- - 'hw/**'
- - 'tools/get_deps.py'
- - '.github/workflows/build_msp430.yml'
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
- cancel-in-progress: true
-
-jobs:
- build-msp430:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- family:
- # Alphabetical order
- - 'msp430'
-
- steps:
- - name: Setup Python
- uses: actions/setup-python@v5
- with:
- python-version: '3.x'
-
- - name: Checkout TinyUSB
- uses: actions/checkout@v4
-
- - name: Set Toolchain URL
- run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2
-
- - name: Cache Toolchain
- uses: actions/cache@v3
- id: cache-toolchain
- with:
- path: ~/cache/
- key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }}
-
- - name: Install Toolchain
- if: steps.cache-toolchain.outputs.cache-hit != 'true'
- run: |
- mkdir -p ~/cache/toolchain
- wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.bz2
- tar -C ~/cache/toolchain -xaf toolchain.tar.bz2
-
- - name: Set Toolchain Path
- run: |
- echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin`
- sudo apt install -y ninja-build
-
- - name: Build
- run: |
- python3 tools/get_deps.py ${{ matrix.family }}
- python tools/build_cmake.py ${{ matrix.family }} -DCMAKE_BUILD_TYPE=MinSizeRel
diff --git a/.github/workflows/build_renesas.yml b/.github/workflows/build_renesas.yml
index ec06c9426..fbc12d285 100644
--- a/.github/workflows/build_renesas.yml
+++ b/.github/workflows/build_renesas.yml
@@ -46,7 +46,7 @@ jobs:
run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx/gcc-8.3.0.202004-GNURX-ELF.run
- name: Cache Toolchain
- uses: actions/cache@v3
+ uses: actions/cache@v4
id: cache-toolchain
with:
path: ~/cache/
diff --git a/.github/workflows/build_riscv.yml b/.github/workflows/build_riscv.yml
index e891a3a51..7f5031ff1 100644
--- a/.github/workflows/build_riscv.yml
+++ b/.github/workflows/build_riscv.yml
@@ -48,7 +48,7 @@ jobs:
run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz
- name: Cache Toolchain
- uses: actions/cache@v3
+ uses: actions/cache@v4
id: cache-toolchain
with:
path: ~/cache/
diff --git a/.idea/cmake.xml b/.idea/cmake.xml
index c361e237d..22199b103 100644
--- a/.idea/cmake.xml
+++ b/.idea/cmake.xml
@@ -3,8 +3,8 @@
-
-
+
+
@@ -42,10 +42,10 @@
-
-
+
+
-
+
@@ -53,11 +53,13 @@
+
-
-
+
+
+
@@ -65,17 +67,19 @@
+
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -84,7 +88,6 @@
-
diff --git a/.idea/runConfigurations/kl25.xml b/.idea/runConfigurations/kl25.xml
index 5aace3a60..96c208dde 100644
--- a/.idea/runConfigurations/kl25.xml
+++ b/.idea/runConfigurations/kl25.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/lpc1857.xml b/.idea/runConfigurations/lpc1857.xml
index a60b481eb..a4764b9d6 100644
--- a/.idea/runConfigurations/lpc1857.xml
+++ b/.idea/runConfigurations/lpc1857.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/lpc4088.xml b/.idea/runConfigurations/lpc4088.xml
index 767d98602..9da975ef3 100644
--- a/.idea/runConfigurations/lpc4088.xml
+++ b/.idea/runConfigurations/lpc4088.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/lpc54628.xml b/.idea/runConfigurations/lpc54628.xml
index e425e2387..0c3877e94 100644
--- a/.idea/runConfigurations/lpc54628.xml
+++ b/.idea/runConfigurations/lpc54628.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/lpc55s69.xml b/.idea/runConfigurations/lpc55s69.xml
index 27743d980..2fa127d33 100644
--- a/.idea/runConfigurations/lpc55s69.xml
+++ b/.idea/runConfigurations/lpc55s69.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/mcx947.xml b/.idea/runConfigurations/mcx947.xml
index 2ff405739..12180a996 100644
--- a/.idea/runConfigurations/mcx947.xml
+++ b/.idea/runConfigurations/mcx947.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/nrf52840.xml b/.idea/runConfigurations/nrf52840.xml
index 8053d9b38..8e48a2b97 100644
--- a/.idea/runConfigurations/nrf52840.xml
+++ b/.idea/runConfigurations/nrf52840.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/nrf5340.xml b/.idea/runConfigurations/nrf5340.xml
index 4a5a91734..646f2d38c 100644
--- a/.idea/runConfigurations/nrf5340.xml
+++ b/.idea/runConfigurations/nrf5340.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/.idea/runConfigurations/ra4m1.xml b/.idea/runConfigurations/ra4m1.xml
index a5c361a2a..72bc63d9b 100644
--- a/.idea/runConfigurations/ra4m1.xml
+++ b/.idea/runConfigurations/ra4m1.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/.idea/runConfigurations/ra6m1.xml b/.idea/runConfigurations/ra6m1.xml
index 7db8e9815..ca8c7245a 100644
--- a/.idea/runConfigurations/ra6m1.xml
+++ b/.idea/runConfigurations/ra6m1.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/.idea/runConfigurations/ra6m5.xml b/.idea/runConfigurations/ra6m5.xml
index 24e942fda..ecbdb21b7 100644
--- a/.idea/runConfigurations/ra6m5.xml
+++ b/.idea/runConfigurations/ra6m5.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/.idea/runConfigurations/rp2040.xml b/.idea/runConfigurations/rp2040.xml
index 51ae689be..51ab7b5cc 100644
--- a/.idea/runConfigurations/rp2040.xml
+++ b/.idea/runConfigurations/rp2040.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/.idea/runConfigurations/rt1010.xml b/.idea/runConfigurations/rt1010.xml
index 7929d56d8..f415c0676 100644
--- a/.idea/runConfigurations/rt1010.xml
+++ b/.idea/runConfigurations/rt1010.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/.idea/runConfigurations/rt1060.xml b/.idea/runConfigurations/rt1060.xml
index f26dc7373..cc75aa62c 100644
--- a/.idea/runConfigurations/rt1060.xml
+++ b/.idea/runConfigurations/rt1060.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/samd21g18.xml b/.idea/runConfigurations/samd21g18.xml
index a922da648..f8aa6009d 100644
--- a/.idea/runConfigurations/samd21g18.xml
+++ b/.idea/runConfigurations/samd21g18.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/samd51j19.xml b/.idea/runConfigurations/samd51j19.xml
index a11baa3fd..694ea7dfd 100644
--- a/.idea/runConfigurations/samd51j19.xml
+++ b/.idea/runConfigurations/samd51j19.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/stlink.xml b/.idea/runConfigurations/stlink.xml
index c82f37d59..628f7910d 100644
--- a/.idea/runConfigurations/stlink.xml
+++ b/.idea/runConfigurations/stlink.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/.idea/runConfigurations/stm32g474.xml b/.idea/runConfigurations/stm32g474.xml
index ad6209bc0..6d65e83c7 100644
--- a/.idea/runConfigurations/stm32g474.xml
+++ b/.idea/runConfigurations/stm32g474.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/stm32h743.xml b/.idea/runConfigurations/stm32h743.xml
index 1d0c0155d..aeaf9fb53 100644
--- a/.idea/runConfigurations/stm32h743.xml
+++ b/.idea/runConfigurations/stm32h743.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/.idea/runConfigurations/uno_r4.xml b/.idea/runConfigurations/uno_r4.xml
index f3d1ccac6..98bf91812 100644
--- a/.idea/runConfigurations/uno_r4.xml
+++ b/.idea/runConfigurations/uno_r4.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/examples/build_system/cmake/cpu/cortex-m0.cmake b/examples/build_system/cmake/cpu/cortex-m0.cmake
index bc2257048..62019d90d 100644
--- a/examples/build_system/cmake/cpu/cortex-m0.cmake
+++ b/examples/build_system/cmake/cpu/cortex-m0.cmake
@@ -4,14 +4,19 @@ if (TOOLCHAIN STREQUAL "gcc")
-mcpu=cortex-m0plus
-mfloat-abi=soft
)
+ set(FREERTOS_PORT GCC_ARM_CM0 CACHE INTERNAL "")
+elseif (TOOLCHAIN STREQUAL "clang")
+ set(TOOLCHAIN_COMMON_FLAGS
+ --target=arm-none-eabi
+ -mcpu=cortex-m0
+ )
set(FREERTOS_PORT GCC_ARM_CM0 CACHE INTERNAL "")
elseif (TOOLCHAIN STREQUAL "iar")
set(TOOLCHAIN_COMMON_FLAGS
--cpu cortex-m0
)
-
set(FREERTOS_PORT IAR_ARM_CM0 CACHE INTERNAL "")
endif ()
diff --git a/examples/build_system/cmake/cpu/cortex-m0plus.cmake b/examples/build_system/cmake/cpu/cortex-m0plus.cmake
index bc2257048..ddf0f16af 100644
--- a/examples/build_system/cmake/cpu/cortex-m0plus.cmake
+++ b/examples/build_system/cmake/cpu/cortex-m0plus.cmake
@@ -4,14 +4,19 @@ if (TOOLCHAIN STREQUAL "gcc")
-mcpu=cortex-m0plus
-mfloat-abi=soft
)
+ set(FREERTOS_PORT GCC_ARM_CM0 CACHE INTERNAL "")
+elseif (TOOLCHAIN STREQUAL "clang")
+ set(TOOLCHAIN_COMMON_FLAGS
+ --target=arm-none-eabi
+ -mcpu=cortex-m0plus
+ )
set(FREERTOS_PORT GCC_ARM_CM0 CACHE INTERNAL "")
elseif (TOOLCHAIN STREQUAL "iar")
set(TOOLCHAIN_COMMON_FLAGS
--cpu cortex-m0
)
-
set(FREERTOS_PORT IAR_ARM_CM0 CACHE INTERNAL "")
endif ()
diff --git a/examples/build_system/cmake/cpu/cortex-m23.cmake b/examples/build_system/cmake/cpu/cortex-m23.cmake
index c7ce1d242..00382ed9b 100644
--- a/examples/build_system/cmake/cpu/cortex-m23.cmake
+++ b/examples/build_system/cmake/cpu/cortex-m23.cmake
@@ -4,14 +4,19 @@ if (TOOLCHAIN STREQUAL "gcc")
-mcpu=cortex-m23
-mfloat-abi=soft
)
+ set(FREERTOS_PORT GCC_ARM_CM23_NTZ_NONSECURE CACHE INTERNAL "")
+elseif (TOOLCHAIN STREQUAL "clang")
+ set(TOOLCHAIN_COMMON_FLAGS
+ --target=arm-none-eabi
+ -mcpu=cortex-m23
+ )
set(FREERTOS_PORT GCC_ARM_CM23_NTZ_NONSECURE CACHE INTERNAL "")
elseif (TOOLCHAIN STREQUAL "iar")
set(TOOLCHAIN_COMMON_FLAGS
--cpu cortex-m23
)
-
set(FREERTOS_PORT IAR_ARM_CM23_NTZ_NONSECURE CACHE INTERNAL "")
endif ()
diff --git a/examples/build_system/cmake/cpu/cortex-m3.cmake b/examples/build_system/cmake/cpu/cortex-m3.cmake
index f6f5a62f8..27888604e 100644
--- a/examples/build_system/cmake/cpu/cortex-m3.cmake
+++ b/examples/build_system/cmake/cpu/cortex-m3.cmake
@@ -3,14 +3,19 @@ if (TOOLCHAIN STREQUAL "gcc")
-mthumb
-mcpu=cortex-m3
)
+ set(FREERTOS_PORT GCC_ARM_CM3 CACHE INTERNAL "")
+elseif (TOOLCHAIN STREQUAL "clang")
+ set(TOOLCHAIN_COMMON_FLAGS
+ --target=arm-none-eabi
+ -mcpu=cortex-m3
+ )
set(FREERTOS_PORT GCC_ARM_CM3 CACHE INTERNAL "")
elseif (TOOLCHAIN STREQUAL "iar")
set(TOOLCHAIN_COMMON_FLAGS
--cpu cortex-m3
)
-
set(FREERTOS_PORT IAR_ARM_CM3 CACHE INTERNAL "")
endif ()
diff --git a/examples/build_system/cmake/cpu/cortex-m33-nodsp-nofp.cmake b/examples/build_system/cmake/cpu/cortex-m33-nodsp-nofp.cmake
index 01e6b979a..51fd70b0e 100644
--- a/examples/build_system/cmake/cpu/cortex-m33-nodsp-nofp.cmake
+++ b/examples/build_system/cmake/cpu/cortex-m33-nodsp-nofp.cmake
@@ -4,14 +4,15 @@ if (TOOLCHAIN STREQUAL "gcc")
-mcpu=cortex-m33+nodsp
-mfloat-abi=soft
)
-
set(FREERTOS_PORT GCC_ARM_CM33_NTZ_NONSECURE CACHE INTERNAL "")
+elseif (TOOLCHAIN STREQUAL "clang")
+ message(FATAL_ERROR "Clang is not supported for this target")
+
elseif (TOOLCHAIN STREQUAL "iar")
set(TOOLCHAIN_COMMON_FLAGS
--cpu cortex-m33+nodsp
)
-
set(FREERTOS_PORT IAR_ARM_CM33_NTZ_NONSECURE CACHE INTERNAL "")
endif ()
diff --git a/examples/build_system/cmake/cpu/cortex-m33.cmake b/examples/build_system/cmake/cpu/cortex-m33.cmake
index 94c29099d..d56d07ebc 100644
--- a/examples/build_system/cmake/cpu/cortex-m33.cmake
+++ b/examples/build_system/cmake/cpu/cortex-m33.cmake
@@ -5,7 +5,14 @@ if (TOOLCHAIN STREQUAL "gcc")
-mfloat-abi=hard
-mfpu=fpv5-sp-d16
)
+ set(FREERTOS_PORT GCC_ARM_CM33_NTZ_NONSECURE CACHE INTERNAL "")
+elseif (TOOLCHAIN STREQUAL "clang")
+ set(TOOLCHAIN_COMMON_FLAGS
+ --target=arm-none-eabi
+ -mcpu=cortex-m33
+ -mfpu=fpv5-sp-d16
+ )
set(FREERTOS_PORT GCC_ARM_CM33_NTZ_NONSECURE CACHE INTERNAL "")
elseif (TOOLCHAIN STREQUAL "iar")
@@ -13,7 +20,6 @@ elseif (TOOLCHAIN STREQUAL "iar")
--cpu cortex-m33
--fpu VFPv5-SP
)
-
set(FREERTOS_PORT IAR_ARM_CM33_NTZ_NONSECURE CACHE INTERNAL "")
endif ()
diff --git a/examples/build_system/cmake/cpu/cortex-m4.cmake b/examples/build_system/cmake/cpu/cortex-m4.cmake
index db308aa83..9cdadc6f8 100644
--- a/examples/build_system/cmake/cpu/cortex-m4.cmake
+++ b/examples/build_system/cmake/cpu/cortex-m4.cmake
@@ -5,7 +5,16 @@ if (TOOLCHAIN STREQUAL "gcc")
-mfloat-abi=hard
-mfpu=fpv4-sp-d16
)
+ if (NOT DEFINED FREERTOS_PORT)
+ set(FREERTOS_PORT GCC_ARM_CM4F CACHE INTERNAL "")
+ endif ()
+elseif (TOOLCHAIN STREQUAL "clang")
+ set(TOOLCHAIN_COMMON_FLAGS
+ --target=arm-none-eabi
+ -mcpu=cortex-m4
+ -mfpu=fpv4-sp-d16
+ )
if (NOT DEFINED FREERTOS_PORT)
set(FREERTOS_PORT GCC_ARM_CM4F CACHE INTERNAL "")
endif ()
diff --git a/examples/build_system/cmake/cpu/cortex-m7.cmake b/examples/build_system/cmake/cpu/cortex-m7.cmake
index 3e5f7f44b..b41dfded5 100644
--- a/examples/build_system/cmake/cpu/cortex-m7.cmake
+++ b/examples/build_system/cmake/cpu/cortex-m7.cmake
@@ -5,7 +5,14 @@ if (TOOLCHAIN STREQUAL "gcc")
-mfloat-abi=hard
-mfpu=fpv5-d16
)
+ set(FREERTOS_PORT GCC_ARM_CM7 CACHE INTERNAL "")
+elseif (TOOLCHAIN STREQUAL "clang")
+ set(TOOLCHAIN_COMMON_FLAGS
+ --target=arm-none-eabi
+ -mcpu=cortex-m7
+ -mfpu=fpv5-d16
+ )
set(FREERTOS_PORT GCC_ARM_CM7 CACHE INTERNAL "")
elseif (TOOLCHAIN STREQUAL "iar")
@@ -13,7 +20,6 @@ elseif (TOOLCHAIN STREQUAL "iar")
--cpu cortex-m7
--fpu VFPv5_D16
)
-
set(FREERTOS_PORT IAR_ARM_CM7 CACHE INTERNAL "")
endif ()
diff --git a/examples/build_system/cmake/cpu/msp430.cmake b/examples/build_system/cmake/cpu/msp430.cmake
index b4b47a2e8..584ec5741 100644
--- a/examples/build_system/cmake/cpu/msp430.cmake
+++ b/examples/build_system/cmake/cpu/msp430.cmake
@@ -1,6 +1,9 @@
if (TOOLCHAIN STREQUAL "gcc")
set(FREERTOS_PORT GCC_MSP430F449 CACHE INTERNAL "")
+elseif (TOOLCHAIN STREQUAL "clang")
+ message(FATAL_ERROR "Clang is not supported for this target")
+
elseif (TOOLCHAIN STREQUAL "iar")
set(FREERTOS_PORT IAR_MSP430 CACHE INTERNAL "")
diff --git a/examples/build_system/cmake/toolchain/arm_clang.cmake b/examples/build_system/cmake/toolchain/arm_clang.cmake
new file mode 100644
index 000000000..754d672fd
--- /dev/null
+++ b/examples/build_system/cmake/toolchain/arm_clang.cmake
@@ -0,0 +1,21 @@
+if (NOT DEFINED CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER "clang")
+endif ()
+
+if (NOT DEFINED CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER "clang++")
+endif ()
+
+set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
+set(CMAKE_SIZE "llvm-size" CACHE FILEPATH "")
+set(CMAKE_OBJCOPY "llvm-objcopy" CACHE FILEPATH "")
+set(CMAKE_OBJDUMP "llvm-objdump" CACHE FILEPATH "")
+
+include(${CMAKE_CURRENT_LIST_DIR}/common.cmake)
+
+get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
+if (IS_IN_TRY_COMPILE)
+ set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib")
+ set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib")
+ cmake_print_variables(CMAKE_C_LINK_FLAGS)
+endif ()
diff --git a/examples/build_system/cmake/toolchain/arm_gcc.cmake b/examples/build_system/cmake/toolchain/arm_gcc.cmake
index d3fd5b557..d3d73c629 100644
--- a/examples/build_system/cmake/toolchain/arm_gcc.cmake
+++ b/examples/build_system/cmake/toolchain/arm_gcc.cmake
@@ -1,5 +1,3 @@
-set(CMAKE_SYSTEM_NAME Generic)
-
if (NOT DEFINED CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
endif ()
@@ -9,44 +7,15 @@ if (NOT DEFINED CMAKE_CXX_COMPILER)
endif ()
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
-
set(CMAKE_SIZE "arm-none-eabi-size" CACHE FILEPATH "")
set(CMAKE_OBJCOPY "arm-none-eabi-objcopy" CACHE FILEPATH "")
set(CMAKE_OBJDUMP "arm-none-eabi-objdump" CACHE FILEPATH "")
-set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
+include(${CMAKE_CURRENT_LIST_DIR}/common.cmake)
-# Look for includes and libraries only in the target system prefix.
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-
-# pass TOOLCHAIN_CPU to
-set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR)
-
-include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
-
-# enable all possible warnings for building examples
-list(APPEND TOOLCHAIN_COMMON_FLAGS
- -fdata-sections
- -ffunction-sections
- -fsingle-precision-constant
- -fno-strict-aliasing
- )
-
-list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
- -Wl,--print-memory-usage
- -Wl,--gc-sections
- -Wl,--cref
- )
-
-include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
-
-# try_compile is cmake test compiling its own example,
-# pass -nostdlib to skip stdlib linking
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
if (IS_IN_TRY_COMPILE)
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib")
+ cmake_print_variables(CMAKE_C_LINK_FLAGS)
endif ()
diff --git a/examples/build_system/cmake/toolchain/arm_iar.cmake b/examples/build_system/cmake/toolchain/arm_iar.cmake
index 1482624e5..6d2219ca8 100644
--- a/examples/build_system/cmake/toolchain/arm_iar.cmake
+++ b/examples/build_system/cmake/toolchain/arm_iar.cmake
@@ -1,32 +1,17 @@
-set(CMAKE_SYSTEM_NAME Generic)
+if (NOT DEFINED CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER "iccarm")
+endif()
-set(CMAKE_C_COMPILER "iccarm")
-set(CMAKE_CXX_COMPILER "iccarm")
-set(CMAKE_ASM_COMPILER "iasmarm")
+if (NOT DEFINED CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER "iccarm")
+endif()
+
+if (NOT DEFINED CMAKE_ASM_COMPILER)
+ set(CMAKE_ASM_COMPILER "iasmarm")
+endif()
set(CMAKE_SIZE "size" CACHE FILEPATH "")
set(CMAKE_OBJCOPY "ielftool" CACHE FILEPATH "")
set(CMAKE_OBJDUMP "iefdumparm" CACHE FILEPATH "")
-set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
-
-# Look for includes and libraries only in the target system prefix.
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-
-# pass TOOLCHAIN_CPU to
-set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR)
-
-include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
-
-# enable all possible warnings for building examples
-list(APPEND TOOLCHAIN_COMMON_FLAGS
- )
-
-list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
- --diag_suppress=Li065
- )
-
-include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/common.cmake)
diff --git a/examples/build_system/cmake/toolchain/common.cmake b/examples/build_system/cmake/toolchain/common.cmake
new file mode 100644
index 000000000..688715914
--- /dev/null
+++ b/examples/build_system/cmake/toolchain/common.cmake
@@ -0,0 +1,64 @@
+include(CMakePrintHelpers)
+
+# ----------------------------------------------------------------------------
+# Common
+# ----------------------------------------------------------------------------
+set(CMAKE_SYSTEM_NAME Generic)
+set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
+
+# Look for includes and libraries only in the target system prefix.
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+
+# pass TOOLCHAIN_CPU to
+set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR)
+include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
+
+# ----------------------------------------------------------------------------
+# Compile flags
+# ----------------------------------------------------------------------------
+if (TOOLCHAIN STREQUAL "gcc")
+ list(APPEND TOOLCHAIN_COMMON_FLAGS
+ -fdata-sections
+ -ffunction-sections
+ -fsingle-precision-constant
+ -fno-strict-aliasing
+ )
+ list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
+ -Wl,--print-memory-usage
+ -Wl,--gc-sections
+ -Wl,--cref
+ )
+
+elseif (TOOLCHAIN STREQUAL "iar")
+ #list(APPEND TOOLCHAIN_COMMON_FLAGS)
+ list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
+ --diag_suppress=Li065
+ )
+
+elseif (TOOLCHAIN STREQUAL "clang")
+ list(APPEND TOOLCHAIN_COMMON_FLAGS
+ -fdata-sections
+ -ffunction-sections
+ -fno-strict-aliasing
+ )
+ list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
+ -Wl,--print-memory-usage
+ -Wl,--gc-sections
+ -Wl,--cref
+ )
+endif ()
+
+# join the toolchain flags into a single string
+list(JOIN TOOLCHAIN_COMMON_FLAGS " " TOOLCHAIN_COMMON_FLAGS)
+foreach (LANG IN ITEMS C CXX ASM)
+ set(CMAKE_${LANG}_FLAGS_INIT ${TOOLCHAIN_COMMON_FLAGS})
+ # optimization flags for LOG, LOGGER ?
+ #set(CMAKE_${LANG}_FLAGS_RELEASE_INIT "-Os")
+ #set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0")
+endforeach ()
+
+# Linker
+list(JOIN TOOLCHAIN_EXE_LINKER_FLAGS " " CMAKE_EXE_LINKER_FLAGS_INIT)
diff --git a/examples/build_system/cmake/toolchain/msp430_gcc.cmake b/examples/build_system/cmake/toolchain/msp430_gcc.cmake
index 6291ce5a4..73368adba 100644
--- a/examples/build_system/cmake/toolchain/msp430_gcc.cmake
+++ b/examples/build_system/cmake/toolchain/msp430_gcc.cmake
@@ -1,5 +1,3 @@
-set(CMAKE_SYSTEM_NAME Generic)
-
if (NOT DEFINED CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER "msp430-elf-gcc")
endif ()
@@ -14,39 +12,4 @@ set(CMAKE_SIZE "msp430-elf-size" CACHE FILEPATH "")
set(CMAKE_OBJCOPY "msp430-elf-objcopy" CACHE FILEPATH "")
set(CMAKE_OBJDUMP "msp430-elf-objdump" CACHE FILEPATH "")
-set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
-
-# Look for includes and libraries only in the target system prefix.
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-
-# pass TOOLCHAIN_CPU to
-set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR)
-
-include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
-
-# enable all possible warnings for building examples
-list(APPEND TOOLCHAIN_COMMON_FLAGS
- -fdata-sections
- -ffunction-sections
- -fsingle-precision-constant
- -fno-strict-aliasing
- )
-
-list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS
- -Wl,--print-memory-usage
- -Wl,--gc-sections
- -Wl,--cref
- )
-
-include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
-
-# try_compile is cmake test compiling its own example,
-# pass -nostdlib to skip stdlib linking
-get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
-if (IS_IN_TRY_COMPILE)
- set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib")
- set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib")
-endif ()
+include(${CMAKE_CURRENT_LIST_DIR}/common.cmake)
diff --git a/examples/build_system/cmake/toolchain/set_flags.cmake b/examples/build_system/cmake/toolchain/set_flags.cmake
deleted file mode 100644
index 44930ef4d..000000000
--- a/examples/build_system/cmake/toolchain/set_flags.cmake
+++ /dev/null
@@ -1,17 +0,0 @@
-include(CMakePrintHelpers)
-
-# join the toolchain flags into a single string
-list(JOIN TOOLCHAIN_COMMON_FLAGS " " TOOLCHAIN_COMMON_FLAGS)
-
-foreach (LANG IN ITEMS C CXX ASM)
- set(CMAKE_${LANG}_FLAGS_INIT ${TOOLCHAIN_COMMON_FLAGS})
-
- #cmake_print_variables(CMAKE_${LANG}_FLAGS_INIT)
-
- # optimization flags for LOG, LOGGER ?
- #set(CMAKE_${LANG}_FLAGS_RELEASE_INIT "-Os")
- #set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0")
-endforeach ()
-
-# Linker
-list(JOIN TOOLCHAIN_EXE_LINKER_FLAGS " " CMAKE_EXE_LINKER_FLAGS_INIT)
diff --git a/examples/build_system/make/cpu/cortex-m0.mk b/examples/build_system/make/cpu/cortex-m0.mk
index feb0f395b..c2c33a2ee 100644
--- a/examples/build_system/make/cpu/cortex-m0.mk
+++ b/examples/build_system/make/cpu/cortex-m0.mk
@@ -4,10 +4,18 @@ ifeq ($(TOOLCHAIN),gcc)
-mcpu=cortex-m0 \
-mfloat-abi=soft \
+else ifeq ($(TOOLCHAIN),clang)
+ CFLAGS += \
+ --target=arm-none-eabi \
+ -mcpu=cortex-m0 \
+
else ifeq ($(TOOLCHAIN),iar)
# IAR Flags
CFLAGS += --cpu cortex-m0
ASFLAGS += --cpu cortex-m0
+
+else
+ $(error "TOOLCHAIN is not supported")
endif
# For freeRTOS port source
diff --git a/examples/build_system/make/cpu/cortex-m0plus.mk b/examples/build_system/make/cpu/cortex-m0plus.mk
index b416b7a4a..fe8feb227 100644
--- a/examples/build_system/make/cpu/cortex-m0plus.mk
+++ b/examples/build_system/make/cpu/cortex-m0plus.mk
@@ -4,10 +4,18 @@ ifeq ($(TOOLCHAIN),gcc)
-mcpu=cortex-m0plus \
-mfloat-abi=soft \
+else ifeq ($(TOOLCHAIN),clang)
+ CFLAGS += \
+ --target=arm-none-eabi \
+ -mcpu=cortex-m0plus \
+
else ifeq ($(TOOLCHAIN),iar)
# IAR Flags
CFLAGS += --cpu cortex-m0+
ASFLAGS += --cpu cortex-m0+
+
+else
+ $(error "TOOLCHAIN is not supported")
endif
# For freeRTOS port source
diff --git a/examples/build_system/make/cpu/cortex-m23.mk b/examples/build_system/make/cpu/cortex-m23.mk
index 29542d8e8..7ab758352 100644
--- a/examples/build_system/make/cpu/cortex-m23.mk
+++ b/examples/build_system/make/cpu/cortex-m23.mk
@@ -4,10 +4,18 @@ ifeq ($(TOOLCHAIN),gcc)
-mcpu=cortex-m23 \
-mfloat-abi=soft \
+else ifeq ($(TOOLCHAIN),clang)
+ CFLAGS += \
+ --target=arm-none-eabi \
+ -mcpu=cortex-m23 \
+
else ifeq ($(TOOLCHAIN),iar)
# IAR Flags
CFLAGS += --cpu cortex-m23
ASFLAGS += --cpu cortex-m23
+
+else
+ $(error "TOOLCHAIN is not supported")
endif
# For freeRTOS port source
diff --git a/examples/build_system/make/cpu/cortex-m3.mk b/examples/build_system/make/cpu/cortex-m3.mk
index 7a34b9e04..b6325313f 100644
--- a/examples/build_system/make/cpu/cortex-m3.mk
+++ b/examples/build_system/make/cpu/cortex-m3.mk
@@ -4,13 +4,18 @@ ifeq ($(TOOLCHAIN),gcc)
-mcpu=cortex-m3 \
-mfloat-abi=soft \
+else ifeq ($(TOOLCHAIN),clang)
+ CFLAGS += \
+ --target=arm-none-eabi \
+ -mcpu=cortex-m3 \
+
else ifeq ($(TOOLCHAIN),iar)
# IAR Flags
- CFLAGS += \
- --cpu cortex-m3 \
+ CFLAGS += --cpu cortex-m3
+ ASFLAGS += --cpu cortex-m3
- ASFLAGS += \
- --cpu cortex-m3
+else
+ $(error "TOOLCHAIN is not supported")
endif
# For freeRTOS port source
diff --git a/examples/build_system/make/cpu/cortex-m33-nodsp-nofp.mk b/examples/build_system/make/cpu/cortex-m33-nodsp-nofp.mk
index c65f24376..405053dd0 100644
--- a/examples/build_system/make/cpu/cortex-m33-nodsp-nofp.mk
+++ b/examples/build_system/make/cpu/cortex-m33-nodsp-nofp.mk
@@ -1,16 +1,24 @@
ifeq ($(TOOLCHAIN),gcc)
- CFLAGS += \
+ CFLAGS += \
-mthumb \
-mcpu=cortex-m33+nodsp \
-mfloat-abi=soft \
+else ifeq ($(TOOLCHAIN),clang)
+ CFLAGS += \
+ --target=arm-none-eabi \
+ -mcpu=cortex-m33 \
+ -mfpu=softvp \
+
else ifeq ($(TOOLCHAIN),iar)
- CFLAGS += \
+ CFLAGS += \
--cpu cortex-m33+nodsp \
- ASFLAGS += \
+ ASFLAGS += \
--cpu cortex-m33+nodsp \
+else
+ $(error "TOOLCHAIN is not supported")
endif
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM33_NTZ/non_secure
diff --git a/examples/build_system/make/cpu/cortex-m33.mk b/examples/build_system/make/cpu/cortex-m33.mk
index fe5b7b380..47b0eaecd 100644
--- a/examples/build_system/make/cpu/cortex-m33.mk
+++ b/examples/build_system/make/cpu/cortex-m33.mk
@@ -5,15 +5,23 @@ ifeq ($(TOOLCHAIN),gcc)
-mfloat-abi=hard \
-mfpu=fpv5-sp-d16 \
+else ifeq ($(TOOLCHAIN),clang)
+ CFLAGS += \
+ --target=arm-none-eabi \
+ -mcpu=cortex-m33 \
+ -mfpu=fpv5-sp-d16 \
+
else ifeq ($(TOOLCHAIN),iar)
- CFLAGS += \
+ CFLAGS += \
--cpu cortex-m33 \
--fpu VFPv5-SP \
- ASFLAGS += \
+ ASFLAGS += \
--cpu cortex-m33 \
--fpu VFPv5-SP \
+else
+ $(error "TOOLCHAIN is not supported")
endif
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM33_NTZ/non_secure
diff --git a/examples/build_system/make/cpu/cortex-m4.mk b/examples/build_system/make/cpu/cortex-m4.mk
index d8776b5d8..4e16819d1 100644
--- a/examples/build_system/make/cpu/cortex-m4.mk
+++ b/examples/build_system/make/cpu/cortex-m4.mk
@@ -5,9 +5,18 @@ ifeq ($(TOOLCHAIN),gcc)
-mfloat-abi=hard \
-mfpu=fpv4-sp-d16 \
+else ifeq ($(TOOLCHAIN),clang)
+ CFLAGS += \
+ --target=arm-none-eabi \
+ -mcpu=cortex-m4 \
+ -mfpu=fpv4-sp-d16 \
+
else ifeq ($(TOOLCHAIN),iar)
CFLAGS += --cpu cortex-m4 --fpu VFPv4
ASFLAGS += --cpu cortex-m4 --fpu VFPv4
+
+else
+ $(error "TOOLCHAIN is not supported")
endif
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM4F
diff --git a/examples/build_system/make/cpu/cortex-m7.mk b/examples/build_system/make/cpu/cortex-m7.mk
index 0e3461787..3e6116179 100644
--- a/examples/build_system/make/cpu/cortex-m7.mk
+++ b/examples/build_system/make/cpu/cortex-m7.mk
@@ -5,6 +5,12 @@ ifeq ($(TOOLCHAIN),gcc)
-mfloat-abi=hard \
-mfpu=fpv5-d16 \
+else ifeq ($(TOOLCHAIN),clang)
+ CFLAGS += \
+ --target=arm-none-eabi \
+ -mcpu=cortex-m7 \
+ -mfpu=fpv5-d16 \
+
else ifeq ($(TOOLCHAIN),iar)
CFLAGS += \
--cpu cortex-m7 \
@@ -14,6 +20,8 @@ else ifeq ($(TOOLCHAIN),iar)
--cpu cortex-m7 \
--fpu VFPv5_D16 \
+else
+ $(error "TOOLCHAIN is not supported")
endif
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/ARM_CM7/r0p1
diff --git a/examples/build_system/make/cpu/msp430.mk b/examples/build_system/make/cpu/msp430.mk
index 06340d23b..6daa2c38d 100644
--- a/examples/build_system/make/cpu/msp430.mk
+++ b/examples/build_system/make/cpu/msp430.mk
@@ -1,7 +1,11 @@
ifeq ($(TOOLCHAIN),gcc)
# nothing to add
+else ifeq ($(TOOLCHAIN),clang)
+ # nothing to add
else ifeq ($(TOOLCHAIN),iar)
# nothing to add
+else
+ $(error "TOOLCHAIN is not supported")
endif
# For freeRTOS port source
diff --git a/examples/build_system/make/make.mk b/examples/build_system/make/make.mk
index 772befca4..a78f4130d 100644
--- a/examples/build_system/make/make.mk
+++ b/examples/build_system/make/make.mk
@@ -2,6 +2,24 @@
# Common make definition for all examples
# ---------------------------------------
+#-------------------------------------------------------------
+# Toolchain
+# Can be changed via TOOLCHAIN=gcc|iar or CC=arm-none-eabi-gcc|iccarm|clang
+#-------------------------------------------------------------
+
+ifneq (,$(findstring clang,$(CC)))
+ TOOLCHAIN = clang
+else ifneq (,$(findstring iccarm,$(CC)))
+ TOOLCHAIN = iar
+else ifneq (,$(findstring gcc,$(CC)))
+ TOOLCHAIN = gcc
+endif
+
+# Default to GCC
+ifndef TOOLCHAIN
+ TOOLCHAIN = gcc
+endif
+
#-------------- TOP and CURRENT_PATH ------------
# Set TOP to be the path to get from the current directory (where make was invoked) to the top of the tree.
@@ -15,6 +33,8 @@ TOP = $(abspath $(subst make.mk,../../..,$(THIS_MAKEFILE)))
# Set CURRENT_PATH to the relative path from TOP to the current directory, ie examples/device/cdc_msc_freertos
CURRENT_PATH = $(subst $(TOP)/,,$(abspath .))
+#-------------- Linux/Windows ------------
+
# Detect whether shell style is windows or not
# https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069
ifeq '$(findstring ;,$(PATH))' ';'
@@ -26,13 +46,18 @@ CMDEXE := 1
SHELL := cmd.exe
endif
-# Handy check parameter function
-check_defined = \
- $(strip $(foreach 1,$1, \
- $(call __check_defined,$1,$(strip $(value 2)))))
-__check_defined = \
- $(if $(value $1),, \
- $(error Undefined make flag: $1$(if $2, ($2))))
+ifeq ($(CMDEXE),1)
+ CP = copy
+ RM = del
+ MKDIR = mkdir
+ PYTHON = python
+else
+ CP = cp
+ RM = rm
+ MKDIR = mkdir
+ PYTHON = python3
+endif
+
# Build directory
BUILD := _build/$(BOARD)
@@ -44,8 +69,8 @@ BIN := $(TOP)/_bin/$(BOARD)/$(notdir $(CURDIR))
# Board without family
ifneq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/board.mk),)
-BOARD_PATH := hw/bsp/$(BOARD)
-FAMILY :=
+ BOARD_PATH := hw/bsp/$(BOARD)
+ FAMILY :=
endif
# Board within family
@@ -68,31 +93,6 @@ else
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c))
endif
-#-------------- Toolchain ------------
-
-# Supported toolchain: gcc, iar
-TOOLCHAIN ?= gcc
-
-# Can be set by board, default to ARM GCC
-CROSS_COMPILE ?= arm-none-eabi-
-
-ifeq ($(TOOLCHAIN),iar)
-CC := iccarm
-USE_IAR = 1
-endif
-
-ifeq ($(CMDEXE),1)
- CP = copy
- RM = del
- MKDIR = mkdir
- PYTHON = python
-else
- CP = cp
- RM = rm
- MKDIR = mkdir
- PYTHON = python3
-endif
-
#-------------- Source files and compiler flags --------------
# tinyusb makefile
include $(TOP)/src/tinyusb.mk
@@ -124,7 +124,7 @@ endif
# Logger: default is uart, can be set to rtt or swo
ifneq ($(LOGGER),)
- CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
+ CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
endif
ifeq ($(LOGGER),rtt)
@@ -143,3 +143,11 @@ endif
# toolchain specific
include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN).mk
+
+# Handy check parameter function
+check_defined = \
+ $(strip $(foreach 1,$1, \
+ $(call __check_defined,$1,$(strip $(value 2)))))
+__check_defined = \
+ $(if $(value $1),, \
+ $(error Undefined make flag: $1$(if $2, ($2))))
diff --git a/examples/build_system/make/rules.mk b/examples/build_system/make/rules.mk
index 78fce49d2..7b6b339ed 100644
--- a/examples/build_system/make/rules.mk
+++ b/examples/build_system/make/rules.mk
@@ -24,7 +24,7 @@ vpath %.c . $(TOP)
vpath %.s . $(TOP)
vpath %.S . $(TOP)
-include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN)_rules.mk
+include ${TOP}/examples/build_system/make/toolchain/$(TOOLCHAIN)_rules.mk
# ---------------------------------------
# Compiler Flags
diff --git a/examples/build_system/make/toolchain/arm_clang.mk b/examples/build_system/make/toolchain/arm_clang.mk
new file mode 100644
index 000000000..97face39c
--- /dev/null
+++ b/examples/build_system/make/toolchain/arm_clang.mk
@@ -0,0 +1,10 @@
+CC = clang
+CXX = clang++
+AS = $(CC) -x assembler-with-cpp
+LD = $(CC)
+
+GDB = $(CROSS_COMPILE)gdb
+OBJCOPY = llvm-objcopy
+SIZE = llvm-size
+
+include ${TOP}/examples/build_system/make/toolchain/gcc_common.mk
diff --git a/examples/build_system/make/toolchain/arm_gcc.mk b/examples/build_system/make/toolchain/arm_gcc.mk
index ed5ddc970..a8576f8ee 100644
--- a/examples/build_system/make/toolchain/arm_gcc.mk
+++ b/examples/build_system/make/toolchain/arm_gcc.mk
@@ -1,5 +1,8 @@
# makefile for arm gcc toolchain
+# Can be set by family, default to ARM GCC
+CROSS_COMPILE ?= arm-none-eabi-
+
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
AS = $(CC) -x assembler-with-cpp
@@ -9,73 +12,9 @@ GDB = $(CROSS_COMPILE)gdb
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size
-CC_VERSION := $(shell $(CC) -dumpversion)
-CC_VERSION_MAJOR = $(firstword $(subst ., ,$(CC_VERSION)))
-
-# ---------------------------------------
-# Compiler Flags
-# ---------------------------------------
CFLAGS += \
- -MD \
- -ggdb \
- -fdata-sections \
- -ffunction-sections \
-fsingle-precision-constant \
- -fno-strict-aliasing \
- -Wall \
- -Wextra \
- -Werror \
- -Wfatal-errors \
- -Wdouble-promotion \
- -Wstrict-prototypes \
- -Wstrict-overflow \
- -Werror-implicit-function-declaration \
- -Wfloat-equal \
- -Wundef \
- -Wshadow \
- -Wwrite-strings \
- -Wsign-compare \
- -Wmissing-format-attribute \
- -Wunreachable-code \
- -Wcast-align \
- -Wcast-function-type \
- -Wcast-qual \
- -Wnull-dereference \
- -Wuninitialized \
- -Wunused \
- -Wreturn-type \
- -Wredundant-decls \
-# conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion
-# -Wconversion
+LIBS += -lgcc -lm -lnosys
-# Size Optimization as default
-CFLAGS_OPTIMIZED ?= -Os
-
-# Debugging/Optimization
-ifeq ($(DEBUG), 1)
- CFLAGS += -O0
- NO_LTO = 1
-else
- CFLAGS += $(CFLAGS_OPTIMIZED)
-endif
-
-# ---------------------------------------
-# Linker Flags
-# ---------------------------------------
-LDFLAGS += \
- -Wl,-Map=$@.map \
- -Wl,-cref \
- -Wl,-gc-sections \
-
-# renesas rx does not support --print-memory-usage flags
-ifneq ($(FAMILY),rx)
-LDFLAGS += -Wl,--print-memory-usage
-endif
-
-# from version 12
-ifeq ($(strip $(if $(CMDEXE),\
- $(shell if $(CC_VERSION_MAJOR) geq 12 (echo 1) else (echo 0)),\
- $(shell expr $(CC_VERSION_MAJOR) \>= 12))), 1)
-LDFLAGS += -Wl,--no-warn-rwx-segment
-endif
+include ${TOP}/examples/build_system/make/toolchain/gcc_common.mk
diff --git a/examples/build_system/make/toolchain/arm_iar.mk b/examples/build_system/make/toolchain/arm_iar.mk
index 04c9f22b3..17967b41a 100644
--- a/examples/build_system/make/toolchain/arm_iar.mk
+++ b/examples/build_system/make/toolchain/arm_iar.mk
@@ -1,4 +1,6 @@
# makefile for arm iar toolchain
+
+CC = iccarm
AS = iasmarm
LD = ilinkarm
OBJCOPY = ielftool --silent
diff --git a/examples/build_system/make/toolchain/clang_rules.mk b/examples/build_system/make/toolchain/clang_rules.mk
new file mode 100644
index 000000000..341f705b1
--- /dev/null
+++ b/examples/build_system/make/toolchain/clang_rules.mk
@@ -0,0 +1 @@
+include ${TOP}/examples/build_system/make/toolchain/gcc_rules.mk
diff --git a/examples/build_system/make/toolchain/gcc_common.mk b/examples/build_system/make/toolchain/gcc_common.mk
new file mode 100644
index 000000000..6986d8bba
--- /dev/null
+++ b/examples/build_system/make/toolchain/gcc_common.mk
@@ -0,0 +1,71 @@
+# ---------------------------------------
+# Compiler Flags
+# ---------------------------------------
+CFLAGS += \
+ -MD \
+ -ggdb \
+ -fdata-sections \
+ -ffunction-sections \
+ -fno-strict-aliasing \
+ -Wall \
+ -Wextra \
+ -Werror \
+ -Wfatal-errors \
+ -Wdouble-promotion \
+ -Wstrict-prototypes \
+ -Wstrict-overflow \
+ -Werror-implicit-function-declaration \
+ -Wfloat-equal \
+ -Wundef \
+ -Wshadow \
+ -Wwrite-strings \
+ -Wsign-compare \
+ -Wmissing-format-attribute \
+ -Wunreachable-code \
+ -Wcast-align \
+ -Wcast-function-type \
+ -Wcast-qual \
+ -Wnull-dereference \
+ -Wuninitialized \
+ -Wunused \
+ -Wreturn-type \
+ -Wredundant-decls \
+
+# conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion
+# -Wconversion
+
+# Size Optimization as default
+CFLAGS_OPTIMIZED ?= -Os
+
+# Debugging/Optimization
+ifeq ($(DEBUG), 1)
+ CFLAGS += -O0
+ NO_LTO = 1
+else
+ CFLAGS += $(CFLAGS_OPTIMIZED)
+endif
+
+# ---------------------------------------
+# Linker Flags
+# ---------------------------------------
+LDFLAGS += \
+ -Wl,-Map=$@.map \
+ -Wl,--cref \
+ -Wl,-gc-sections \
+
+# renesas rx does not support --print-memory-usage flags
+ifneq ($(FAMILY),rx)
+LDFLAGS += -Wl,--print-memory-usage
+endif
+
+ifeq ($(TOOLCHAIN),gcc)
+CC_VERSION := $(shell $(CC) -dumpversion)
+CC_VERSION_MAJOR = $(firstword $(subst ., ,$(CC_VERSION)))
+
+# from version 12
+ifeq ($(strip $(if $(CMDEXE),\
+ $(shell if $(CC_VERSION_MAJOR) geq 12 (echo 1) else (echo 0)),\
+ $(shell expr $(CC_VERSION_MAJOR) \>= 12))), 1)
+LDFLAGS += -Wl,--no-warn-rwx-segment
+endif
+endif
diff --git a/examples/build_system/make/toolchain/arm_gcc_rules.mk b/examples/build_system/make/toolchain/gcc_rules.mk
similarity index 91%
rename from examples/build_system/make/toolchain/arm_gcc_rules.mk
rename to examples/build_system/make/toolchain/gcc_rules.mk
index d295879d9..fc5225503 100644
--- a/examples/build_system/make/toolchain/arm_gcc_rules.mk
+++ b/examples/build_system/make/toolchain/gcc_rules.mk
@@ -21,8 +21,14 @@ ifneq ($(CFLAGS_SKIP),)
CFLAGS := $(filter-out $(CFLAGS_SKIP),$(CFLAGS))
endif
+ifeq ($(TOOLCHAIN),clang)
+CFLAGS += $(CFLAGS_CLANG)
+LDFLAGS += $(CFLAGS) $(LDFLAGS_CLANG)
+else
LDFLAGS += $(CFLAGS) $(LDFLAGS_GCC)
+endif
+# TODO should be removed after all examples are updated
ifdef LD_FILE
LDFLAGS += -Wl,-T,$(TOP)/$(LD_FILE)
endif
@@ -33,11 +39,7 @@ endif
ASFLAGS += $(CFLAGS)
-LIBS_GCC ?= -lgcc -lm -lnosys
-
# libc
-LIBS += $(LIBS_GCC)
-
ifneq ($(BOARD), spresense)
LIBS += -lc
endif
diff --git a/examples/build_system/make/toolchain/arm_iar_rules.mk b/examples/build_system/make/toolchain/iar_rules.mk
similarity index 100%
rename from examples/build_system/make/toolchain/arm_iar_rules.mk
rename to examples/build_system/make/toolchain/iar_rules.mk
diff --git a/examples/device/audio_test_multi_rate/src/main.c b/examples/device/audio_test_multi_rate/src/main.c
index 3e7f40dac..2ff7f10bd 100644
--- a/examples/device/audio_test_multi_rate/src/main.c
+++ b/examples/device/audio_test_multi_rate/src/main.c
@@ -272,7 +272,7 @@ bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
sampFreq = (uint32_t)((audio_control_cur_4_t *)pBuff)->bCur;
- TU_LOG2("Clock set current freq: %lu\r\n", sampFreq);
+ TU_LOG2("Clock set current freq: %" PRIu32 "\r\n", sampFreq);
return true;
break;
diff --git a/examples/device/cdc_msc/src/main.c b/examples/device/cdc_msc/src/main.c
index 0d3f97c8f..4581a3bab 100644
--- a/examples/device/cdc_msc/src/main.c
+++ b/examples/device/cdc_msc/src/main.c
@@ -23,10 +23,6 @@
*
*/
-#include
-#include
-#include
-
#include "bsp/board_api.h"
#include "tusb.h"
diff --git a/examples/device/cdc_msc_freertos/Makefile b/examples/device/cdc_msc_freertos/Makefile
index 13f336f99..fe3fb6482 100644
--- a/examples/device/cdc_msc_freertos/Makefile
+++ b/examples/device/cdc_msc_freertos/Makefile
@@ -1,7 +1,7 @@
include ../../build_system/make/make.mk
FREERTOS_SRC = lib/FreeRTOS-Kernel
-FREERTOS_PORTABLE_PATH= $(FREERTOS_SRC)/portable/$(if $(USE_IAR),IAR,GCC)
+FREERTOS_PORTABLE_PATH = $(FREERTOS_SRC)/portable/$(if $(findstring iar,$(TOOLCHAIN)),IAR,GCC)
INC += \
src \
diff --git a/examples/device/cdc_uac2/src/uac2_app.c b/examples/device/cdc_uac2/src/uac2_app.c
index 98659ea68..c57d98a1a 100644
--- a/examples/device/cdc_uac2/src/uac2_app.c
+++ b/examples/device/cdc_uac2/src/uac2_app.c
@@ -69,7 +69,7 @@ static bool tud_audio_clock_get_request(uint8_t rhport, audio_control_request_t
{
if (request->bRequest == AUDIO_CS_REQ_CUR)
{
- TU_LOG1("Clock get current freq %lu\r\n", current_sample_rate);
+ TU_LOG1("Clock get current freq %" PRIu32 "\r\n", current_sample_rate);
audio_control_cur_4_t curf = { (int32_t) tu_htole32(current_sample_rate) };
return tud_audio_buffer_and_schedule_control_xfer(rhport, (tusb_control_request_t const *)request, &curf, sizeof(curf));
@@ -118,7 +118,7 @@ static bool tud_audio_clock_set_request(uint8_t rhport, audio_control_request_t
current_sample_rate = (uint32_t) ((audio_control_cur_4_t const *)buf)->bCur;
- TU_LOG1("Clock set current freq: %ld\r\n", current_sample_rate);
+ TU_LOG1("Clock set current freq: %" PRIu32 "\r\n", current_sample_rate);
return true;
}
diff --git a/examples/device/hid_composite_freertos/Makefile b/examples/device/hid_composite_freertos/Makefile
index add9e9814..88d602393 100644
--- a/examples/device/hid_composite_freertos/Makefile
+++ b/examples/device/hid_composite_freertos/Makefile
@@ -3,7 +3,7 @@ DEPS_SUBMODULES += lib/FreeRTOS-Kernel
include ../../build_system/make/make.mk
FREERTOS_SRC = lib/FreeRTOS-Kernel
-FREERTOS_PORTABLE_PATH= $(FREERTOS_SRC)/portable/$(if $(USE_IAR),IAR,GCC)
+FREERTOS_PORTABLE_PATH= $(FREERTOS_SRC)/portable/$(if $(findstring iar,$(TOOLCHAIN)),IAR,GCC)
INC += \
src \
diff --git a/examples/device/msc_dual_lun/src/main.c b/examples/device/msc_dual_lun/src/main.c
index de402d3da..aabd0bf8a 100644
--- a/examples/device/msc_dual_lun/src/main.c
+++ b/examples/device/msc_dual_lun/src/main.c
@@ -39,7 +39,7 @@
* - 1000 ms : device mounted
* - 2500 ms : device is suspended
*/
-enum {
+enum {
BLINK_NOT_MOUNTED = 250,
BLINK_MOUNTED = 1000,
BLINK_SUSPENDED = 2500,
@@ -50,8 +50,7 @@ static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED;
void led_blinking_task(void);
/*------------- MAIN -------------*/
-int main(void)
-{
+int main(void) {
board_init();
// init device stack on configured roothub port
@@ -61,8 +60,7 @@ int main(void)
board_init_after_tusb();
}
- while (1)
- {
+ while (1) {
tud_task(); // tinyusb device task
led_blinking_task();
}
@@ -73,42 +71,37 @@ int main(void)
//--------------------------------------------------------------------+
// Invoked when device is mounted
-void tud_mount_cb(void)
-{
+void tud_mount_cb(void) {
blink_interval_ms = BLINK_MOUNTED;
}
// Invoked when device is unmounted
-void tud_umount_cb(void)
-{
+void tud_umount_cb(void) {
blink_interval_ms = BLINK_NOT_MOUNTED;
}
// Invoked when usb bus is suspended
// remote_wakeup_en : if host allow us to perform remote wakeup
// Within 7ms, device must draw an average of current less than 2.5 mA from bus
-void tud_suspend_cb(bool remote_wakeup_en)
-{
+void tud_suspend_cb(bool remote_wakeup_en) {
(void) remote_wakeup_en;
blink_interval_ms = BLINK_SUSPENDED;
}
// Invoked when usb bus is resumed
-void tud_resume_cb(void)
-{
+void tud_resume_cb(void) {
blink_interval_ms = tud_mounted() ? BLINK_MOUNTED : BLINK_NOT_MOUNTED;
}
//--------------------------------------------------------------------+
// BLINKING TASK
//--------------------------------------------------------------------+
-void led_blinking_task(void)
-{
+void led_blinking_task(void) {
static uint32_t start_ms = 0;
static bool led_state = false;
// Blink every interval ms
- if ( board_millis() - start_ms < blink_interval_ms) return; // not enough time
+ if (board_millis() - start_ms < blink_interval_ms) return; // not enough time
start_ms += blink_interval_ms;
board_led_write(led_state);
diff --git a/examples/device/uac2_headset/src/main.c b/examples/device/uac2_headset/src/main.c
index fbd7ffe22..0ea6e7025 100644
--- a/examples/device/uac2_headset/src/main.c
+++ b/examples/device/uac2_headset/src/main.c
@@ -157,7 +157,7 @@ static bool tud_audio_clock_get_request(uint8_t rhport, audio_control_request_t
{
if (request->bRequest == AUDIO_CS_REQ_CUR)
{
- TU_LOG1("Clock get current freq %lu\r\n", current_sample_rate);
+ TU_LOG1("Clock get current freq %" PRIu32 "\r\n", current_sample_rate);
audio_control_cur_4_t curf = { (int32_t) tu_htole32(current_sample_rate) };
return tud_audio_buffer_and_schedule_control_xfer(rhport, (tusb_control_request_t const *)request, &curf, sizeof(curf));
@@ -206,7 +206,7 @@ static bool tud_audio_clock_set_request(uint8_t rhport, audio_control_request_t
current_sample_rate = (uint32_t) ((audio_control_cur_4_t const *)buf)->bCur;
- TU_LOG1("Clock set current freq: %ld\r\n", current_sample_rate);
+ TU_LOG1("Clock set current freq: %" PRIu32 "\r\n", current_sample_rate);
return true;
}
diff --git a/examples/host/bare_api/src/main.c b/examples/host/bare_api/src/main.c
index 14725996d..940840a30 100644
--- a/examples/host/bare_api/src/main.c
+++ b/examples/host/bare_api/src/main.c
@@ -420,5 +420,5 @@ static void print_utf16(uint16_t *temp_buf, size_t buf_len) {
_convert_utf16le_to_utf8(temp_buf + 1, utf16_len, (uint8_t *) temp_buf, sizeof(uint16_t) * buf_len);
((uint8_t*) temp_buf)[utf8_len] = '\0';
- printf((char*)temp_buf);
+ printf("%s", (char*)temp_buf);
}
diff --git a/examples/host/cdc_msc_hid/src/cdc_app.c b/examples/host/cdc_msc_hid/src/cdc_app.c
index e275e7943..4a13f8b27 100644
--- a/examples/host/cdc_msc_hid/src/cdc_app.c
+++ b/examples/host/cdc_msc_hid/src/cdc_app.c
@@ -72,7 +72,7 @@ void tuh_cdc_rx_cb(uint8_t idx) {
uint32_t count = tuh_cdc_read(idx, buf, bufsize);
buf[count] = 0;
- printf((char*) buf);
+ printf("%s", (char*) buf);
}
// Invoked when a device with CDC interface is mounted
@@ -89,7 +89,7 @@ void tuh_cdc_mount_cb(uint8_t idx) {
// while eneumerating new cdc device
cdc_line_coding_t line_coding = {0};
if (tuh_cdc_get_local_line_coding(idx, &line_coding)) {
- printf(" Baudrate: %lu, Stop Bits : %u\r\n", line_coding.bit_rate, line_coding.stop_bits);
+ printf(" Baudrate: %" PRIu32 ", Stop Bits : %u\r\n", line_coding.bit_rate, line_coding.stop_bits);
printf(" Parity : %u, Data Width: %u\r\n", line_coding.parity, line_coding.data_bits);
}
#else
diff --git a/examples/host/cdc_msc_hid/src/msc_app.c b/examples/host/cdc_msc_hid/src/msc_app.c
index e9c9676b8..1d7e18e6e 100644
--- a/examples/host/cdc_msc_hid/src/msc_app.c
+++ b/examples/host/cdc_msc_hid/src/msc_app.c
@@ -48,8 +48,8 @@ bool inquiry_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const * cb_da
uint32_t const block_count = tuh_msc_get_block_count(dev_addr, cbw->lun);
uint32_t const block_size = tuh_msc_get_block_size(dev_addr, cbw->lun);
- printf("Disk Size: %lu MB\r\n", block_count / ((1024*1024)/block_size));
- printf("Block Count = %lu, Block Size: %lu\r\n", block_count, block_size);
+ printf("Disk Size: %" PRIu32 " MB\r\n", block_count / ((1024*1024)/block_size));
+ printf("Block Count = %" PRIu32 ", Block Size: %" PRIu32 "\r\n", block_count, block_size);
return true;
}
diff --git a/examples/host/cdc_msc_hid_freertos/Makefile b/examples/host/cdc_msc_hid_freertos/Makefile
index 5351a6248..bf4725f47 100644
--- a/examples/host/cdc_msc_hid_freertos/Makefile
+++ b/examples/host/cdc_msc_hid_freertos/Makefile
@@ -1,7 +1,7 @@
include ../../build_system/make/make.mk
FREERTOS_SRC = lib/FreeRTOS-Kernel
-FREERTOS_PORTABLE_PATH= $(FREERTOS_SRC)/portable/$(if $(USE_IAR),IAR,GCC)
+FREERTOS_PORTABLE_PATH= $(FREERTOS_SRC)/portable/$(if $(findstring iar,$(TOOLCHAIN)),IAR,GCC)
INC += \
src \
diff --git a/examples/host/cdc_msc_hid_freertos/src/cdc_app.c b/examples/host/cdc_msc_hid_freertos/src/cdc_app.c
index 6ff513be1..7d246af67 100644
--- a/examples/host/cdc_msc_hid_freertos/src/cdc_app.c
+++ b/examples/host/cdc_msc_hid_freertos/src/cdc_app.c
@@ -117,7 +117,7 @@ void tuh_cdc_rx_cb(uint8_t idx) {
uint32_t count = tuh_cdc_read(idx, buf, bufsize);
buf[count] = 0;
- printf((char *) buf);
+ printf("%s", (char *) buf);
}
void tuh_cdc_mount_cb(uint8_t idx) {
@@ -131,7 +131,7 @@ void tuh_cdc_mount_cb(uint8_t idx) {
// otherwise you need to call tuh_cdc_set_line_coding() first
cdc_line_coding_t line_coding = { 0 };
if (tuh_cdc_get_local_line_coding(idx, &line_coding)) {
- printf(" Baudrate: %lu, Stop Bits : %u\r\n", line_coding.bit_rate, line_coding.stop_bits);
+ printf(" Baudrate: %" PRIu32 ", Stop Bits : %u\r\n", line_coding.bit_rate, line_coding.stop_bits);
printf(" Parity : %u, Data Width: %u\r\n", line_coding.parity, line_coding.data_bits);
}
#endif
diff --git a/examples/host/cdc_msc_hid_freertos/src/msc_app.c b/examples/host/cdc_msc_hid_freertos/src/msc_app.c
index ee02ba917..9ffd5d965 100644
--- a/examples/host/cdc_msc_hid_freertos/src/msc_app.c
+++ b/examples/host/cdc_msc_hid_freertos/src/msc_app.c
@@ -47,8 +47,8 @@ bool inquiry_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const *cb_dat
uint32_t const block_count = tuh_msc_get_block_count(dev_addr, cbw->lun);
uint32_t const block_size = tuh_msc_get_block_size(dev_addr, cbw->lun);
- printf("Disk Size: %lu MB\r\n", block_count / ((1024 * 1024) / block_size));
- printf("Block Count = %lu, Block Size: %lu\r\n", block_count, block_size);
+ printf("Disk Size: %" PRIu32 " MB\r\n", block_count / ((1024 * 1024) / block_size));
+ printf("Block Count = %" PRIu32 ", Block Size: %" PRIu32 "\r\n", block_count, block_size);
return true;
}
diff --git a/examples/host/msc_file_explorer/src/main.c b/examples/host/msc_file_explorer/src/main.c
index 73f3e9eb5..f6b6810f5 100644
--- a/examples/host/msc_file_explorer/src/main.c
+++ b/examples/host/msc_file_explorer/src/main.c
@@ -72,8 +72,7 @@ extern bool msc_app_init(void);
extern void msc_app_task(void);
/*------------- MAIN -------------*/
-int main(void)
-{
+int main(void) {
board_init();
printf("TinyUSB Host MassStorage Explorer Example\r\n");
@@ -87,8 +86,7 @@ int main(void)
msc_app_init();
- while (1)
- {
+ while (1) {
// tinyusb host task
tuh_task();
@@ -103,28 +101,25 @@ int main(void)
// TinyUSB Callbacks
//--------------------------------------------------------------------+
-void tuh_mount_cb(uint8_t dev_addr)
-{
+void tuh_mount_cb(uint8_t dev_addr) {
(void) dev_addr;
}
-void tuh_umount_cb(uint8_t dev_addr)
-{
+void tuh_umount_cb(uint8_t dev_addr) {
(void) dev_addr;
}
//--------------------------------------------------------------------+
// Blinking Task
//--------------------------------------------------------------------+
-void led_blinking_task(void)
-{
+void led_blinking_task(void) {
const uint32_t interval_ms = 1000;
static uint32_t start_ms = 0;
static bool led_state = false;
// Blink every interval ms
- if ( board_millis() - start_ms < interval_ms) return; // not enough time
+ if (board_millis() - start_ms < interval_ms) return; // not enough time
start_ms += interval_ms;
board_led_write(led_state);
diff --git a/examples/host/msc_file_explorer/src/msc_app.c b/examples/host/msc_file_explorer/src/msc_app.c
index ecea614a2..ddd39c674 100644
--- a/examples/host/msc_file_explorer/src/msc_app.c
+++ b/examples/host/msc_file_explorer/src/msc_app.c
@@ -95,7 +95,6 @@ void msc_app_task(void)
//
//--------------------------------------------------------------------+
-
bool inquiry_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const * cb_data)
{
msc_cbw_t const* cbw = cb_data->cbw;
@@ -114,7 +113,7 @@ bool inquiry_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const * cb_da
uint32_t const block_count = tuh_msc_get_block_count(dev_addr, cbw->lun);
uint32_t const block_size = tuh_msc_get_block_size(dev_addr, cbw->lun);
- printf("Disk Size: %lu MB\r\n", block_count / ((1024*1024)/block_size));
+ printf("Disk Size: %" PRIu32 " MB\r\n", block_count / ((1024*1024)/block_size));
// printf("Block Count = %lu, Block Size: %lu\r\n", block_count, block_size);
// For simplicity: we only mount 1 LUN per device
@@ -541,10 +540,10 @@ void cli_cmd_ls(EmbeddedCli *cli, char *args, void *context)
printf("%-40s", fno.fname);
if (fno.fsize < 1024)
{
- printf("%lu B\r\n", fno.fsize);
+ printf("%" PRIu32 " B\r\n", fno.fsize);
}else
{
- printf("%lu KB\r\n", fno.fsize / 1024);
+ printf("%" PRIu32 " KB\r\n", fno.fsize / 1024);
}
}
}
diff --git a/hw/bsp/board.c b/hw/bsp/board.c
index 23b4b6628..bb339f613 100644
--- a/hw/bsp/board.c
+++ b/hw/bsp/board.c
@@ -108,6 +108,28 @@ TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
// st->st_mode = S_IFCHR;
//}
+// Clang use picolibc
+#if defined(__clang__)
+static int cl_putc(char c, FILE *f) {
+ (void) f;
+ return sys_write(0, &c, 1);
+}
+
+static int cl_getc(FILE* f) {
+ (void) f;
+ char c;
+ return sys_read(0, &c, 1) > 0 ? c : -1;
+}
+
+static FILE __stdio = FDEV_SETUP_STREAM(cl_putc, cl_getc, NULL, _FDEV_SETUP_RW);
+FILE *const stdin = &__stdio;
+__strong_reference(stdin, stdout);
+__strong_reference(stdin, stderr);
+#endif
+
+//--------------------------------------------------------------------+
+// Board API
+//--------------------------------------------------------------------+
int board_getchar(void) {
char c;
return (sys_read(0, &c, 1) > 0) ? (int) c : (-1);
diff --git a/hw/bsp/board_api.h b/hw/bsp/board_api.h
index 3b9f211a2..f21a32371 100644
--- a/hw/bsp/board_api.h
+++ b/hw/bsp/board_api.h
@@ -32,7 +32,10 @@ extern "C" {
#endif
#include
+#include
#include
+#include
+
#include "tusb.h"
#if CFG_TUSB_OS == OPT_OS_FREERTOS
@@ -139,6 +142,7 @@ static inline size_t board_usb_get_serial(uint16_t desc_str1[], size_t max_chars
uint8_t uid[16] TU_ATTR_ALIGNED(4);
size_t uid_len;
+ // TODO work with make, but not working with esp32s3 cmake
if ( board_get_unique_id ) {
uid_len = board_get_unique_id(uid, sizeof(uid));
}else {
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake
index d4f355e0c..5f0653646 100644
--- a/hw/bsp/family_support.cmake
+++ b/hw/bsp/family_support.cmake
@@ -6,12 +6,33 @@ include(CMakePrintHelpers)
set(TOP "${CMAKE_CURRENT_LIST_DIR}/../..")
get_filename_component(TOP ${TOP} ABSOLUTE)
-# Default to gcc
+#-------------------------------------------------------------
+# Toolchain
+# Can be changed via -DTOOLCHAIN=gcc|iar or -DCMAKE_C_COMPILER=
+#-------------------------------------------------------------
+# Detect toolchain based on CMAKE_C_COMPILER
+if (DEFINED CMAKE_C_COMPILER)
+ string(FIND ${CMAKE_C_COMPILER} "iccarm" IS_IAR)
+ string(FIND ${CMAKE_C_COMPILER} "clang" IS_CLANG)
+ string(FIND ${CMAKE_C_COMPILER} "gcc" IS_GCC)
+
+ if (NOT IS_IAR EQUAL -1)
+ set(TOOLCHAIN iar)
+ elseif (NOT IS_CLANG EQUAL -1)
+ set(TOOLCHAIN clang)
+ elseif (NOT IS_GCC EQUAL -1)
+ set(TOOLCHAIN gcc)
+ endif ()
+endif ()
+
+# default to gcc
if (NOT DEFINED TOOLCHAIN)
set(TOOLCHAIN gcc)
endif ()
-# FAMILY not defined, try to detect it from BOARD
+#-------------------------------------------------------------
+# FAMILY and BOARD
+#-------------------------------------------------------------
if (NOT DEFINED FAMILY)
if (NOT DEFINED BOARD)
message(FATAL_ERROR "You must set a FAMILY variable for the build (e.g. rp2040, espressif).
@@ -74,6 +95,9 @@ set(WARNING_FLAGS_GNU
set(WARNING_FLAGS_IAR "")
+#-------------------------------------------------------------
+# Functions
+#-------------------------------------------------------------
# Filter example based on only.txt and skip.txt
function(family_filter RESULT DIR)
@@ -195,8 +219,9 @@ function(family_configure_common TARGET RTOS)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
endif ()
- endif()
- if (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${TARGET} PUBLIC "LINKER:-Map=$.map")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${TARGET} PUBLIC "LINKER:--map=$.map")
endif()
@@ -214,7 +239,7 @@ function(family_configure_common TARGET RTOS)
if (NOT TARGET segger_rtt)
add_library(segger_rtt STATIC ${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c)
target_include_directories(segger_rtt PUBLIC ${TOP}/lib/SEGGER_RTT/RTT)
- #target_compile_definitions(segger_rtt PUBLIC SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL)
+# target_compile_definitions(segger_rtt PUBLIC SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL)
endif()
target_link_libraries(${TARGET} PUBLIC segger_rtt)
endif ()
diff --git a/hw/bsp/fomu/fomu.ld b/hw/bsp/fomu/fomu.ld
index 13278d2ad..0b0cf2612 100644
--- a/hw/bsp/fomu/fomu.ld
+++ b/hw/bsp/fomu/fomu.ld
@@ -11,7 +11,7 @@ MEMORY {
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
/* Section Definitions */
SECTIONS
diff --git a/hw/bsp/imxrt/family.c b/hw/bsp/imxrt/family.c
index 8ed72aa19..c9c4918ef 100644
--- a/hw/bsp/imxrt/family.c
+++ b/hw/bsp/imxrt/family.c
@@ -224,3 +224,22 @@ uint32_t board_millis(void) {
return system_ticks;
}
#endif
+
+
+#ifndef __ICCARM__
+// Implement _start() since we use linker flag '-nostartfiles'.
+// Requires defined __STARTUP_CLEAR_BSS,
+extern int main(void);
+TU_ATTR_UNUSED void _start(void) {
+ // called by startup code
+ main();
+ while (1) {}
+}
+
+#ifdef __clang__
+void _exit (int __status) {
+ while (1) {}
+}
+#endif
+
+#endif
diff --git a/hw/bsp/imxrt/family.cmake b/hw/bsp/imxrt/family.cmake
index 090014754..f4d7378a5 100644
--- a/hw/bsp/imxrt/family.cmake
+++ b/hw/bsp/imxrt/family.cmake
@@ -1,9 +1,5 @@
include_guard()
-if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
-endif ()
-
set(SDK_DIR ${TOP}/hw/mcu/nxp/mcux-sdk)
set(CMSIS_DIR ${TOP}/lib/CMSIS_5)
@@ -26,7 +22,21 @@ function(add_board_target BOARD_TARGET)
return()
endif ()
+ # LD_FILE and STARTUP_FILE can be defined in board.cmake
+ if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
+ set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx${MCU_CORE}_flexspi_nor.ld)
+ #set(LD_FILE_IAR ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld)
+ endif ()
+ set(LD_FILE_Clang ${LD_FILE_GNU})
+
+ if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
+ set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT_WITH_CORE}.S)
+ #set(STARTUP_FILE_IAR ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT_WITH_CORE}.S)
+ endif ()
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
add_library(${BOARD_TARGET} STATIC
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/board/clock_config.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}/board/pin_mux.c
${SDK_DIR}/drivers/common/fsl_common.c
@@ -52,6 +62,7 @@ function(add_board_target BOARD_TARGET)
__ARMFPV5__=0
XIP_EXTERNAL_FLASH=1
XIP_BOOT_HEADER_ENABLE=1
+ __STARTUP_CLEAR_BSS
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
@@ -68,31 +79,21 @@ function(add_board_target BOARD_TARGET)
update_board(${BOARD_TARGET})
- # LD_FILE and STARTUP_FILE can be defined in board.cmake
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx${MCU_CORE}_flexspi_nor.ld)
- #set(LD_FILE_IAR ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_VARIANT}xxxxx_flexspi_nor.ld)
- endif ()
-
- if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT_WITH_CORE}.S)
- #set(STARTUP_FILE_IAR ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT_WITH_CORE}.S)
- endif ()
-
- target_sources(${BOARD_TARGET} PUBLIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
- )
-
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
- # nanolib
- --specs=nosys.specs
- --specs=nano.specs
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
# force linker to look for these symbols
-Wl,-uimage_vector_table
-Wl,-ug_boot_data
)
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -Wl,-uimage_vector_table
+ -Wl,-ug_boot_data
+ )
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--config=${LD_FILE_IAR}"
diff --git a/hw/bsp/imxrt/family.mk b/hw/bsp/imxrt/family.mk
index c6adcba5a..bde4c4ba6 100644
--- a/hw/bsp/imxrt/family.mk
+++ b/hw/bsp/imxrt/family.mk
@@ -11,6 +11,7 @@ MCU_DIR = $(SDK_DIR)/devices/$(MCU_VARIANT)
CFLAGS += \
-D__ARMVFP__=0 \
-D__ARMFPV5__=0 \
+ -D__STARTUP_CLEAR_BSS \
-DXIP_EXTERNAL_FLASH=1 \
-DXIP_BOOT_HEADER_ENABLE=1 \
-DCFG_TUSB_MCU=OPT_MCU_MIMXRT1XXX
@@ -26,7 +27,9 @@ endif
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=implicit-fallthrough -Wno-error=redundant-decls
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += \
+ -nostartfiles \
+ --specs=nosys.specs --specs=nano.specs
# All source paths should be relative to the top level.
LD_FILE ?= $(MCU_DIR)/gcc/$(MCU_VARIANT)xxxxx${MCU_CORE}_flexspi_nor.ld
diff --git a/hw/bsp/kinetis_k/family.c b/hw/bsp/kinetis_k/family.c
index 6df29c1fc..30dfe6d76 100644
--- a/hw/bsp/kinetis_k/family.c
+++ b/hw/bsp/kinetis_k/family.c
@@ -140,5 +140,23 @@ void SysTick_Handler(void) {
uint32_t board_millis(void) {
return system_ticks;
}
+#endif
+
+
+#ifndef __ICCARM__
+// Implement _start() since we use linker flag '-nostartfiles'.
+// Requires defined __STARTUP_CLEAR_BSS,
+extern int main(void);
+TU_ATTR_UNUSED void _start(void) {
+ // called by startup code
+ main();
+ while (1) {}
+}
+
+#ifdef __clang__
+void _exit (int __status) {
+ while (1) {}
+}
+#endif
#endif
diff --git a/hw/bsp/kinetis_k/family.cmake b/hw/bsp/kinetis_k/family.cmake
index 452ef4b26..771754ebd 100644
--- a/hw/bsp/kinetis_k/family.cmake
+++ b/hw/bsp/kinetis_k/family.cmake
@@ -22,48 +22,53 @@ set(FAMILY_MCUS KINETIS_K CACHE INTERNAL "")
#------------------------------------
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
- if (NOT TARGET ${BOARD_TARGET})
- add_library(${BOARD_TARGET} STATIC
- # driver
- ${SDK_DIR}/drivers/gpio/fsl_gpio.c
- ${SDK_DIR}/drivers/uart/fsl_uart.c
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
- ${SDK_DIR}/devices/${MCU_VARIANT}/system_${MCU_VARIANT}.c
- )
- target_compile_definitions(${BOARD_TARGET} PUBLIC
- )
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${CMSIS_DIR}/CMSIS/Core/Include
- ${SDK_DIR}/devices/${MCU_VARIANT}
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers
- ${SDK_DIR}/drivers/common
- ${SDK_DIR}/drivers/gpio
- ${SDK_DIR}/drivers/port
- ${SDK_DIR}/drivers/smc
- ${SDK_DIR}/drivers/sysmpu
- ${SDK_DIR}/drivers/uart
- )
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif ()
- update_board(${BOARD_TARGET})
+ # LD_FILE and STARTUP_FILE can be defined in board.cmake
+ set(LD_FILE_Clang ${LD_FILE_GNU})
+ set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S)
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
- # LD_FILE and STARTUP_FILE can be defined in board.cmake
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S)
+ add_library(${BOARD_TARGET} STATIC
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ ${SDK_DIR}/drivers/gpio/fsl_gpio.c
+ ${SDK_DIR}/drivers/uart/fsl_uart.c
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
+ ${SDK_DIR}/devices/${MCU_VARIANT}/system_${MCU_VARIANT}.c
+ )
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ __STARTUP_CLEAR_BSS
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMSIS_DIR}/CMSIS/Core/Include
+ ${SDK_DIR}/devices/${MCU_VARIANT}
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers
+ ${SDK_DIR}/drivers/common
+ ${SDK_DIR}/drivers/gpio
+ ${SDK_DIR}/drivers/port
+ ${SDK_DIR}/drivers/smc
+ ${SDK_DIR}/drivers/sysmpu
+ ${SDK_DIR}/drivers/uart
+ )
- target_sources(${BOARD_TARGET} PUBLIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
)
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- # nanolib
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endif ()
endfunction()
diff --git a/hw/bsp/kinetis_k/family.mk b/hw/bsp/kinetis_k/family.mk
index 995873eec..844ce332e 100644
--- a/hw/bsp/kinetis_k/family.mk
+++ b/hw/bsp/kinetis_k/family.mk
@@ -6,9 +6,12 @@ include $(TOP)/$(BOARD_PATH)/board.mk
CPU_CORE ?= cortex-m4
CFLAGS += \
+ -D__STARTUP_CLEAR_BSS \
-DCFG_TUSB_MCU=OPT_MCU_KINETIS_K \
LDFLAGS += \
+ -nostartfiles \
+ --specs=nosys.specs --specs=nano.specs \
-Wl,--defsym,__stack_size__=0x400 \
-Wl,--defsym,__heap_size__=0
diff --git a/hw/bsp/kinetis_kl/family.c b/hw/bsp/kinetis_kl/family.c
index c436be3e6..254a95176 100644
--- a/hw/bsp/kinetis_kl/family.c
+++ b/hw/bsp/kinetis_kl/family.c
@@ -141,3 +141,22 @@ uint32_t board_millis(void)
return system_ticks;
}
#endif
+
+
+#ifndef __ICCARM__
+// Implement _start() since we use linker flag '-nostartfiles'.
+// Requires defined __STARTUP_CLEAR_BSS,
+extern int main(void);
+TU_ATTR_UNUSED void _start(void) {
+ // called by startup code
+ main();
+ while (1) {}
+}
+
+#ifdef __clang__
+void _exit (int __status) {
+ while (1) {}
+}
+#endif
+
+#endif
diff --git a/hw/bsp/kinetis_kl/family.cmake b/hw/bsp/kinetis_kl/family.cmake
index 6d9b65df0..85a913d54 100644
--- a/hw/bsp/kinetis_kl/family.cmake
+++ b/hw/bsp/kinetis_kl/family.cmake
@@ -26,7 +26,12 @@ function(add_board_target BOARD_TARGET)
return()
endif ()
+ # LD_FILE and STARTUP_FILE can be defined in board.cmake
+ set(LD_FILE_Clang ${LD_FILE_GNU})
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
add_library(${BOARD_TARGET} STATIC
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
${SDK_DIR}/drivers/gpio/fsl_gpio.c
${SDK_DIR}/drivers/lpsci/fsl_lpsci.c
${SDK_DIR}/drivers/uart/fsl_uart.c
@@ -34,6 +39,7 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/devices/${MCU_VARIANT}/system_${MCU_VARIANT}.c
)
target_compile_definitions(${BOARD_TARGET} PUBLIC
+ __STARTUP_CLEAR_BSS
)
target_include_directories(${BOARD_TARGET} PUBLIC
${CMSIS_DIR}/CMSIS/Core/Include
@@ -48,16 +54,15 @@ function(add_board_target BOARD_TARGET)
)
update_board(${BOARD_TARGET})
- # LD_FILE and STARTUP_FILE can be defined in board.cmake
- target_sources(${BOARD_TARGET} PUBLIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
- )
-
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
- # nanolib
--specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
@@ -103,5 +108,4 @@ function(family_configure_example TARGET RTOS)
# Flashing
family_flash_jlink(${TARGET})
- #family_flash_nxplink(${TARGET})
endfunction()
diff --git a/hw/bsp/kinetis_kl/family.mk b/hw/bsp/kinetis_kl/family.mk
index e331d82b7..1fdce981a 100644
--- a/hw/bsp/kinetis_kl/family.mk
+++ b/hw/bsp/kinetis_kl/family.mk
@@ -6,9 +6,11 @@ include $(TOP)/$(BOARD_PATH)/board.mk
CPU_CORE ?= cortex-m0plus
CFLAGS += \
+ -D__STARTUP_CLEAR_BSS \
-DCFG_TUSB_MCU=OPT_MCU_KINETIS_KL \
LDFLAGS += \
+ -nostartfiles \
-specs=nosys.specs -specs=nano.specs \
-Wl,--defsym,__stack_size__=0x400 \
-Wl,--defsym,__heap_size__=0
diff --git a/hw/bsp/lpc17/boards/lpcxpresso1769/lpc1769.ld b/hw/bsp/lpc17/boards/lpcxpresso1769/lpc1769.ld
index 095bd3d92..a6c35c157 100644
--- a/hw/bsp/lpc17/boards/lpcxpresso1769/lpc1769.ld
+++ b/hw/bsp/lpc17/boards/lpcxpresso1769/lpc1769.ld
@@ -140,7 +140,7 @@ SECTIONS
*(COMMON)
. = ALIGN(4) ;
_ebss = .;
- PROVIDE(end = .);
+/* PROVIDE(end = .);*/
} > RamLoc32
/* NOINIT section for RamAHB32 */
@@ -159,18 +159,36 @@ SECTIONS
. = ALIGN(4) ;
_end_noinit = .;
} > RamLoc32
- PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+
+ /* hathach add heap section for clang */
+ .heap (NOLOAD): {
+ __heap_start = .;
+ __HeapBase = .;
+ __heap_base = .;
+ __end = .;
+ PROVIDE(end = .);
+ PROVIDE(_end = .);
+ PROVIDE(__end__ = .);
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ __heap_limit = .;
+ __heap_end = .;
+ } > RamLoc32
+
+/* PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);*/
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
/* ## Create checksum value (used in startup) ## */
+ /* This cause issue with clang linker, so it is disabled */
+ /* MemManage_Handler, BusFault_Handler, UsageFault_Handler may not be defined */
PROVIDE(__valid_user_code_checksum = 0 -
(_vStackTop
+ (ResetISR + 1)
+ (NMI_Handler + 1)
+ (HardFault_Handler + 1)
- + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
- + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
- + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1)
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1)
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1)
) );
/* Provide basic symbols giving location and size of main text
diff --git a/hw/bsp/lpc17/boards/mbed1768/lpc1768.ld b/hw/bsp/lpc17/boards/mbed1768/lpc1768.ld
index 095bd3d92..a6c35c157 100644
--- a/hw/bsp/lpc17/boards/mbed1768/lpc1768.ld
+++ b/hw/bsp/lpc17/boards/mbed1768/lpc1768.ld
@@ -140,7 +140,7 @@ SECTIONS
*(COMMON)
. = ALIGN(4) ;
_ebss = .;
- PROVIDE(end = .);
+/* PROVIDE(end = .);*/
} > RamLoc32
/* NOINIT section for RamAHB32 */
@@ -159,18 +159,36 @@ SECTIONS
. = ALIGN(4) ;
_end_noinit = .;
} > RamLoc32
- PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+
+ /* hathach add heap section for clang */
+ .heap (NOLOAD): {
+ __heap_start = .;
+ __HeapBase = .;
+ __heap_base = .;
+ __end = .;
+ PROVIDE(end = .);
+ PROVIDE(_end = .);
+ PROVIDE(__end__ = .);
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ __heap_limit = .;
+ __heap_end = .;
+ } > RamLoc32
+
+/* PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);*/
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
/* ## Create checksum value (used in startup) ## */
+ /* This cause issue with clang linker, so it is disabled */
+ /* MemManage_Handler, BusFault_Handler, UsageFault_Handler may not be defined */
PROVIDE(__valid_user_code_checksum = 0 -
(_vStackTop
+ (ResetISR + 1)
+ (NMI_Handler + 1)
+ (HardFault_Handler + 1)
- + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
- + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
- + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
+ + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1)
+ + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1)
+ + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1)
) );
/* Provide basic symbols giving location and size of main text
diff --git a/hw/bsp/lpc17/family.cmake b/hw/bsp/lpc17/family.cmake
index 63ac3149c..cccfdac9f 100644
--- a/hw/bsp/lpc17/family.cmake
+++ b/hw/bsp/lpc17/family.cmake
@@ -1,10 +1,7 @@
include_guard()
-if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
-endif ()
-
set(SDK_DIR ${TOP}/hw/mcu/nxp/lpcopen/lpc175x_6x/lpc_chip_175x_6x)
+set(CMSIS_DIR ${TOP}/lib/CMSIS_5)
# include board specific
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
@@ -21,42 +18,46 @@ set(FAMILY_MCUS LPC175X_6X CACHE INTERNAL "")
#------------------------------------
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
- if (NOT TARGET ${BOARD_TARGET})
- add_library(${BOARD_TARGET} STATIC
- ${SDK_DIR}/../gcc/cr_startup_lpc175x_6x.c
- ${SDK_DIR}/src/chip_17xx_40xx.c
- ${SDK_DIR}/src/clock_17xx_40xx.c
- ${SDK_DIR}/src/gpio_17xx_40xx.c
- ${SDK_DIR}/src/iocon_17xx_40xx.c
- ${SDK_DIR}/src/sysctl_17xx_40xx.c
- ${SDK_DIR}/src/sysinit_17xx_40xx.c
- ${SDK_DIR}/src/uart_17xx_40xx.c
- )
- target_compile_options(${BOARD_TARGET} PUBLIC
- -nostdlib
- )
- target_compile_definitions(${BOARD_TARGET} PUBLIC
- __USE_LPCOPEN
- CORE_M3
- RTC_EV_SUPPORT=0
- )
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${SDK_DIR}/inc
- )
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif ()
- update_board(${BOARD_TARGET})
+ add_library(${BOARD_TARGET} STATIC
+ ${SDK_DIR}/../gcc/cr_startup_lpc175x_6x.c
+ ${SDK_DIR}/src/chip_17xx_40xx.c
+ ${SDK_DIR}/src/clock_17xx_40xx.c
+ ${SDK_DIR}/src/gpio_17xx_40xx.c
+ ${SDK_DIR}/src/iocon_17xx_40xx.c
+ ${SDK_DIR}/src/sysctl_17xx_40xx.c
+ ${SDK_DIR}/src/sysinit_17xx_40xx.c
+ ${SDK_DIR}/src/uart_17xx_40xx.c
+ )
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ __USE_LPCOPEN
+ CORE_M3
+ RTC_EV_SUPPORT=0
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}/inc
+ ${CMSIS_DIR}/CMSIS/Core/Include
+ )
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- # nanolib
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_compile_options(${BOARD_TARGET} PUBLIC -nostdlib)
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
endif ()
endfunction()
diff --git a/hw/bsp/lpc17/family.mk b/hw/bsp/lpc17/family.mk
index 694b6cccf..84ed95648 100644
--- a/hw/bsp/lpc17/family.mk
+++ b/hw/bsp/lpc17/family.mk
@@ -18,7 +18,7 @@ CFLAGS += -Wno-error=strict-prototypes -Wno-error=cast-qual
# caused by freeRTOS port !!
CFLAGS += -Wno-error=maybe-uninitialized
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += --specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/nxp/lpc17_40/dcd_lpc17_40.c \
@@ -36,3 +36,4 @@ SRC_C += \
INC += \
$(TOP)/$(BOARD_PATH) \
$(TOP)/$(MCU_DIR)/inc \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
diff --git a/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld b/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld
index f1a3add8f..0dd971433 100644
--- a/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld
+++ b/hw/bsp/lpc18/boards/lpcxpresso18s37/lpc1837.ld
@@ -308,9 +308,24 @@ SECTIONS
_ebss = .;
PROVIDE(__end_bss_RAM = .) ;
PROVIDE(__end_bss_RamLoc32 = .) ;
- PROVIDE(end = .);
+/* PROVIDE(end = .);*/
} > RamLoc40 AT> RamLoc40 /* > RamLoc32 AT> RamLoc32 */
+ /* hathach add heap section for clang */
+ .heap (NOLOAD): {
+ __heap_start = .;
+ __HeapBase = .;
+ __heap_base = .;
+ __end = .;
+ PROVIDE(end = .);
+ PROVIDE(_end = .);
+ PROVIDE(__end__ = .);
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ __heap_limit = .;
+ __heap_end = .;
+ } > RamLoc40
+
/* NOINIT section for RamLoc40 */
.noinit_RAM2 (NOLOAD) : ALIGN(4)
{
@@ -379,19 +394,21 @@ SECTIONS
PROVIDE(__end_noinit_RAM = .) ;
PROVIDE(__end_noinit_RamLoc32 = .) ;
} > RamLoc32 AT> RamLoc32
- PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+/* PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);*/
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
/* ## Create checksum value (used in startup) ## */
- PROVIDE(__valid_user_code_checksum = 0 -
- (_vStackTop
- + (ResetISR + 1)
- + (NMI_Handler + 1)
- + (HardFault_Handler + 1)
- + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
- + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
- + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
- ) );
+ /* This cause issue with clang linker, so it is disabled */
+ /* MemManage_Handler, BusFault_Handler, UsageFault_Handler may not be defined */
+/* PROVIDE(__valid_user_code_checksum = 0 -*/
+/* (_vStackTop*/
+/* + (ResetISR + 1)*/
+/* + (NMI_Handler + 1)*/
+/* + (HardFault_Handler + 1)*/
+/* + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1)*/
+/* + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1)*/
+/* + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1)*/
+/* ) );*/
/* Provide basic symbols giving location and size of main text
* block, including initial values of RW data sections. Note that
diff --git a/hw/bsp/lpc18/boards/mcb1800/lpc1857.ld b/hw/bsp/lpc18/boards/mcb1800/lpc1857.ld
index 837dec364..143aa11ec 100644
--- a/hw/bsp/lpc18/boards/mcb1800/lpc1857.ld
+++ b/hw/bsp/lpc18/boards/mcb1800/lpc1857.ld
@@ -255,7 +255,7 @@ SECTIONS
*(COMMON)
. = ALIGN(4) ;
_ebss = .;
- PROVIDE(end = .);
+ /* PROVIDE(end = .); */
} > RamLoc40 /* RamLoc32 */
/* NOINIT section for RamLoc40 */
@@ -266,6 +266,21 @@ SECTIONS
. = ALIGN(4) ;
} > RamLoc40
+ /* hathach add heap section for clang */
+ .heap (NOLOAD): {
+ __heap_start = .;
+ __HeapBase = .;
+ __heap_base = .;
+ __end = .;
+ PROVIDE(end = .);
+ PROVIDE(_end = .);
+ PROVIDE(__end__ = .);
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ __heap_limit = .;
+ __heap_end = .;
+ } > RamLoc40
+
/* NOINIT section for RamAHB32 */
.noinit_RAM3 (NOLOAD) : ALIGN(4)
{
@@ -298,19 +313,21 @@ SECTIONS
. = ALIGN(4) ;
_end_noinit = .;
} > RamLoc32
- PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+/* PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);*/
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
/* ## Create checksum value (used in startup) ## */
- PROVIDE(__valid_user_code_checksum = 0 -
- (_vStackTop
- + (ResetISR + 1)
- + (NMI_Handler + 1)
- + (HardFault_Handler + 1)
- + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
- + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
- + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
- ) );
+ /* This cause issue with clang linker, so it is disabled */
+ /* MemManage_Handler, BusFault_Handler, UsageFault_Handler may not be defined */
+/* PROVIDE(__valid_user_code_checksum = 0 -*/
+/* (_vStackTop*/
+/* + (ResetISR + 1)*/
+/* + (NMI_Handler + 1)*/
+/* + (HardFault_Handler + 1)*/
+/* + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1)*/
+/* + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1)*/
+/* + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1)*/
+/* ) );*/
/* Provide basic symbols giving location and size of main text
* block, including initial values of RW data sections. Note that
diff --git a/hw/bsp/lpc18/family.cmake b/hw/bsp/lpc18/family.cmake
index 78f4c510b..309186667 100644
--- a/hw/bsp/lpc18/family.cmake
+++ b/hw/bsp/lpc18/family.cmake
@@ -1,10 +1,7 @@
include_guard()
-if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
-endif ()
-
set(SDK_DIR ${TOP}/hw/mcu/nxp/lpcopen/lpc18xx/lpc_chip_18xx)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
# include board specific
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
@@ -21,41 +18,44 @@ set(FAMILY_MCUS LPC18XX CACHE INTERNAL "")
#------------------------------------
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
- if (NOT TARGET ${BOARD_TARGET})
- add_library(${BOARD_TARGET} STATIC
- ${SDK_DIR}/../gcc/cr_startup_lpc18xx.c
- ${SDK_DIR}/src/chip_18xx_43xx.c
- ${SDK_DIR}/src/clock_18xx_43xx.c
- ${SDK_DIR}/src/gpio_18xx_43xx.c
- ${SDK_DIR}/src/sysinit_18xx_43xx.c
- ${SDK_DIR}/src/uart_18xx_43xx.c
- )
- target_compile_options(${BOARD_TARGET} PUBLIC
- -nostdlib
- )
- target_compile_definitions(${BOARD_TARGET} PUBLIC
- __USE_LPCOPEN
- CORE_M3
- )
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${SDK_DIR}/inc
- ${SDK_DIR}/inc/config_18xx
- )
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif ()
- update_board(${BOARD_TARGET})
+ add_library(${BOARD_TARGET} STATIC
+ ${SDK_DIR}/../gcc/cr_startup_lpc18xx.c
+ ${SDK_DIR}/src/chip_18xx_43xx.c
+ ${SDK_DIR}/src/clock_18xx_43xx.c
+ ${SDK_DIR}/src/gpio_18xx_43xx.c
+ ${SDK_DIR}/src/sysinit_18xx_43xx.c
+ ${SDK_DIR}/src/uart_18xx_43xx.c
+ )
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ __USE_LPCOPEN
+ CORE_M3
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}/inc
+ ${SDK_DIR}/inc/config_18xx
+ ${CMSIS_5}/CMSIS/Core/Include
+ )
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- # nanolib
- --specs=nosys.specs
- --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_compile_options(${BOARD_TARGET} PUBLIC -nostdlib)
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
+ )
endif ()
endfunction()
@@ -97,5 +97,4 @@ function(family_configure_example TARGET RTOS)
# Flashing
family_flash_jlink(${TARGET})
- #family_flash_nxplink(${TARGET})
endfunction()
diff --git a/hw/bsp/lpc18/family.mk b/hw/bsp/lpc18/family.mk
index c36c903ae..f625e926a 100644
--- a/hw/bsp/lpc18/family.mk
+++ b/hw/bsp/lpc18/family.mk
@@ -14,7 +14,7 @@ CFLAGS += \
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=strict-prototypes -Wno-error=cast-qual
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += --specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/chipidea/ci_hs/dcd_ci_hs.c \
@@ -30,4 +30,5 @@ SRC_C += \
INC += \
$(TOP)/$(BOARD_PATH) \
$(TOP)/$(MCU_DIR)/inc \
- $(TOP)/$(MCU_DIR)/inc/config_18xx
+ $(TOP)/$(MCU_DIR)/inc/config_18xx \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
diff --git a/hw/bsp/lpc40/boards/ea4088_quickstart/lpc4088.ld b/hw/bsp/lpc40/boards/ea4088_quickstart/lpc4088.ld
index 5897707f6..55b60e1e7 100644
--- a/hw/bsp/lpc40/boards/ea4088_quickstart/lpc4088.ld
+++ b/hw/bsp/lpc40/boards/ea4088_quickstart/lpc4088.ld
@@ -140,7 +140,7 @@ SECTIONS
*(COMMON)
. = ALIGN(4) ;
_ebss = .;
- PROVIDE(end = .);
+/* PROVIDE(end = .);*/
} > RamLoc64
/* NOINIT section for RamPeriph32 */
@@ -159,7 +159,23 @@ SECTIONS
. = ALIGN(4) ;
_end_noinit = .;
} > RamLoc64
- PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+
+ /* hathach add heap section for clang */
+ .heap (NOLOAD): {
+ __heap_start = .;
+ __HeapBase = .;
+ __heap_base = .;
+ __end = .;
+ PROVIDE(end = .);
+ PROVIDE(_end = .);
+ PROVIDE(__end__ = .);
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ __heap_limit = .;
+ __heap_end = .;
+ } > RamLoc64
+
+/* PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);*/
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc64 - 0);
/* ## Create checksum value (used in startup) ## */
diff --git a/hw/bsp/lpc40/family.cmake b/hw/bsp/lpc40/family.cmake
index fce9772b6..4c14da8a7 100644
--- a/hw/bsp/lpc40/family.cmake
+++ b/hw/bsp/lpc40/family.cmake
@@ -1,6 +1,7 @@
include_guard()
set(SDK_DIR ${TOP}/hw/mcu/nxp/lpcopen/lpc40xx/lpc_chip_40xx)
+set(CMSIS_DIR ${TOP}/lib/CMSIS_5)
# include board specific
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
@@ -9,7 +10,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor")
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
-set(FAMILY_MCUS LPC18XX CACHE INTERNAL "")
+set(FAMILY_MCUS LPC40XX CACHE INTERNAL "")
#------------------------------------
@@ -32,9 +33,6 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/src/sysinit_17xx_40xx.c
${SDK_DIR}/src/uart_17xx_40xx.c
)
- target_compile_options(${BOARD_TARGET} PUBLIC
- -nostdlib
- )
target_compile_definitions(${BOARD_TARGET} PUBLIC
__USE_LPCOPEN
CORE_M4
@@ -42,16 +40,20 @@ function(add_board_target BOARD_TARGET)
)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_DIR}/inc
+ ${CMSIS_DIR}/CMSIS/Core/Include
)
update_board(${BOARD_TARGET})
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_compile_options(${BOARD_TARGET} PUBLIC -nostdlib)
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
- # nanolib
- --specs=nosys.specs
- --specs=nano.specs
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
diff --git a/hw/bsp/lpc40/family.mk b/hw/bsp/lpc40/family.mk
index fa76789e3..79d868f35 100644
--- a/hw/bsp/lpc40/family.mk
+++ b/hw/bsp/lpc40/family.mk
@@ -15,7 +15,7 @@ CFLAGS += \
# mcu driver cause following warnings
CFLAGS += -Wno-error=strict-prototypes -Wno-error=unused-parameter -Wno-error=cast-qual
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += --specs=nosys.specs --specs=nano.specs
# All source paths should be relative to the top level.
SRC_C += \
@@ -32,4 +32,5 @@ SRC_C += \
INC += \
$(TOP)/$(MCU_DIR)/inc \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
$(TOP)/$(BOARD_PATH)
diff --git a/hw/bsp/lpc43/boards/ea4357/lpc4357.ld b/hw/bsp/lpc43/boards/ea4357/lpc4357.ld
index 53343f6a9..002dcaaed 100644
--- a/hw/bsp/lpc43/boards/ea4357/lpc4357.ld
+++ b/hw/bsp/lpc43/boards/ea4357/lpc4357.ld
@@ -256,7 +256,7 @@ SECTIONS
*(COMMON)
. = ALIGN(4) ;
_ebss = .;
- PROVIDE(end = .);
+ /* PROVIDE(end = .); */
} > RamLoc40 /* RamLoc32 */
/* NOINIT section for RamLoc40 */
@@ -267,6 +267,21 @@ SECTIONS
. = ALIGN(4) ;
} > RamLoc40
+ /* hathach add heap section for clang */
+ .heap (NOLOAD): {
+ __heap_start = .;
+ __HeapBase = .;
+ __heap_base = .;
+ __end = .;
+ PROVIDE(end = .);
+ PROVIDE(_end = .);
+ PROVIDE(__end__ = .);
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ __heap_limit = .;
+ __heap_end = .;
+ } > RamLoc40
+
/* NOINIT section for RamAHB32 */
.noinit_RAM3 (NOLOAD) : ALIGN(4)
{
@@ -299,19 +314,21 @@ SECTIONS
. = ALIGN(4) ;
_end_noinit = .;
} > RamLoc32
- PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+/* PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);*/
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
/* ## Create checksum value (used in startup) ## */
- PROVIDE(__valid_user_code_checksum = 0 -
- (_vStackTop
- + (ResetISR + 1)
- + (NMI_Handler + 1)
- + (HardFault_Handler + 1)
- + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
- + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
- + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
- ) );
+ /* This cause issue with clang linker, so it is disabled */
+ /* MemManage_Handler, BusFault_Handler, UsageFault_Hander may not be defined */
+/* PROVIDE(__valid_user_code_checksum = 0 -*/
+/* (_vStackTop*/
+/* + (ResetISR + 1)*/
+/* + (NMI_Handler + 1)*/
+/* + (HardFault_Handler + 1)*/
+/* + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1)*/
+/* + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1)*/
+/* + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1)*/
+/* ) );*/
/* Provide basic symbols giving location and size of main text
* block, including initial values of RW data sections. Note that
diff --git a/hw/bsp/lpc43/boards/lpcxpresso43s67/lpc4367.ld b/hw/bsp/lpc43/boards/lpcxpresso43s67/lpc4367.ld
index 99276fb47..f19350e00 100644
--- a/hw/bsp/lpc43/boards/lpcxpresso43s67/lpc4367.ld
+++ b/hw/bsp/lpc43/boards/lpcxpresso43s67/lpc4367.ld
@@ -304,9 +304,24 @@ SECTIONS
_ebss = .;
PROVIDE(__end_bss_RAM = .) ;
PROVIDE(__end_bss_RamLoc32 = .) ;
- PROVIDE(end = .);
+/* PROVIDE(end = .);*/
} > RamLoc40 AT> RamLoc40 /* > RamLoc32 AT> RamLoc32 */
+ /* hathach add heap section for clang */
+ .heap (NOLOAD): {
+ __heap_start = .;
+ __HeapBase = .;
+ __heap_base = .;
+ __end = .;
+ PROVIDE(end = .);
+ PROVIDE(_end = .);
+ PROVIDE(__end__ = .);
+ KEEP(*(.heap*))
+ __HeapLimit = .;
+ __heap_limit = .;
+ __heap_end = .;
+ } > RamLoc40
+
/* NOINIT section for RamLoc40 */
.noinit_RAM2 (NOLOAD) : ALIGN(4)
{
@@ -376,20 +391,22 @@ SECTIONS
PROVIDE(__end_noinit_RamLoc32 = .) ;
} > RamLoc32 AT> RamLoc32
- PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);
+/* PROVIDE(_pvHeapStart = DEFINED(__user_heap_base) ? __user_heap_base : .);*/
PROVIDE(_vStackTop = DEFINED(__user_stack_top) ? __user_stack_top : __top_RamLoc32 - 0);
/* ## Create checksum value (used in startup) ## */
- PROVIDE(__valid_user_code_checksum = 0 -
- (_vStackTop
- + (ResetISR + 1)
- + (NMI_Handler + 1)
- + (HardFault_Handler + 1)
- + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1) /* MemManage_Handler may not be defined */
- + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1) /* BusFault_Handler may not be defined */
- + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1) /* UsageFault_Handler may not be defined */
- ) );
+ /* This cause issue with clang linker, so it is disabled */
+ /* MemManage_Handler, BusFault_Handler, UsageFault_Hander may not be defined */
+/* PROVIDE(__valid_user_code_checksum = 0 -*/
+/* (_vStackTop*/
+/* + (ResetISR + 1)*/
+/* + (NMI_Handler + 1)*/
+/* + (HardFault_Handler + 1)*/
+/* + (( DEFINED(MemManage_Handler) ? MemManage_Handler : 0 ) + 1)*/
+/* + (( DEFINED(BusFault_Handler) ? BusFault_Handler : 0 ) + 1)*/
+/* + (( DEFINED(UsageFault_Handler) ? UsageFault_Handler : 0 ) + 1)*/
+/* ) );*/
/* Provide basic symbols giving location and size of main text
* block, including initial values of RW data sections. Note that
diff --git a/hw/bsp/lpc43/family.cmake b/hw/bsp/lpc43/family.cmake
index f66da98aa..2bacd9ea4 100644
--- a/hw/bsp/lpc43/family.cmake
+++ b/hw/bsp/lpc43/family.cmake
@@ -1,6 +1,7 @@
include_guard()
set(SDK_DIR ${TOP}/hw/mcu/nxp/lpcopen/lpc43xx/lpc_chip_43xx)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
# include board specific
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
@@ -23,6 +24,7 @@ function(add_board_target BOARD_TARGET)
# Startup & Linker script
set(STARTUP_FILE_GNU ${SDK_DIR}/../gcc/cr_startup_lpc43xx.c)
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
set(STARTUP_FILE_IAR ${SDK_DIR}/../iar/iar_startup_lpc18xx43xx.s)
set(LD_FILE_IAR ${SDK_DIR}/../iar/linker/lpc18xx_43xx_ldscript_iflash.icf)
@@ -43,6 +45,7 @@ function(add_board_target BOARD_TARGET)
target_include_directories(${BOARD_TARGET} PUBLIC
${SDK_DIR}/inc
${SDK_DIR}/inc/config_43xx
+ ${CMSIS_5}/CMSIS/Core/Include
)
update_board(${BOARD_TARGET})
@@ -51,9 +54,11 @@ function(add_board_target BOARD_TARGET)
target_compile_options(${BOARD_TARGET} PUBLIC -nostdlib)
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
- # nanolib
- --specs=nosys.specs
- --specs=nano.specs
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
diff --git a/hw/bsp/lpc43/family.mk b/hw/bsp/lpc43/family.mk
index f24385139..84e7c30b3 100644
--- a/hw/bsp/lpc43/family.mk
+++ b/hw/bsp/lpc43/family.mk
@@ -18,7 +18,7 @@ CFLAGS += \
-Wno-error=cast-qual \
-Wno-error=incompatible-pointer-types \
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += --specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/chipidea/ci_hs/dcd_ci_hs.c \
@@ -36,4 +36,5 @@ SRC_C += \
INC += \
$(TOP)/$(BOARD_PATH) \
${TOP}/${SDK_DIR}/inc \
- ${TOP}/${SDK_DIR}/inc/config_43xx
+ ${TOP}/${SDK_DIR}/inc/config_43xx \
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
diff --git a/hw/bsp/lpc54/family.c b/hw/bsp/lpc54/family.c
index 7411c72d4..5e5732d74 100644
--- a/hw/bsp/lpc54/family.c
+++ b/hw/bsp/lpc54/family.c
@@ -88,8 +88,7 @@ settings:
sources:
- {id: SYSCON.fro_hf.outFreq, value: 96 MHz}
******************************************************************/
-void BootClockFROHF96M(void)
-{
+void BootClockFROHF96M(void) {
/*!< Set up the clock sources */
/*!< Set up FRO */
POWER_DisablePD(kPDRUNCFG_PD_FRO_EN); /*!< Ensure FRO is on */
@@ -110,8 +109,7 @@ void BootClockFROHF96M(void)
SystemCoreClock = 96000000U;
}
-void board_init(void)
-{
+void board_init(void) {
// Enable IOCON clock
CLOCK_EnableClock(kCLOCK_Iocon);
@@ -198,38 +196,53 @@ void board_init(void)
// Board porting API
//--------------------------------------------------------------------+
-void board_led_write(bool state)
-{
- GPIO_PinWrite(GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+void board_led_write(bool state) {
+ GPIO_PinWrite(GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
}
-uint32_t board_button_read(void)
-{
+uint32_t board_button_read(void) {
// active low
return BUTTON_STATE_ACTIVE == GPIO_PinRead(GPIO, BUTTON_PORT, BUTTON_PIN);
}
-int board_uart_read(uint8_t* buf, int len)
-{
- (void) buf; (void) len;
+int board_uart_read(uint8_t* buf, int len) {
+ (void) buf;
+ (void) len;
return 0;
}
-int board_uart_write(void const * buf, int len)
-{
- USART_WriteBlocking(UART_DEV, (uint8_t const *) buf, len);
+int board_uart_write(void const* buf, int len) {
+ USART_WriteBlocking(UART_DEV, (uint8_t const*) buf, len);
return 0;
}
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
-void SysTick_Handler(void)
-{
+
+void SysTick_Handler(void) {
system_ticks++;
}
-uint32_t board_millis(void)
-{
+uint32_t board_millis(void) {
return system_ticks;
}
#endif
+
+
+#ifndef __ICCARM__
+// Implement _start() since we use linker flag '-nostartfiles'.
+// Requires defined __STARTUP_CLEAR_BSS,
+extern int main(void);
+TU_ATTR_UNUSED void _start(void) {
+ // called by startup code
+ main();
+ while (1) {}
+}
+
+#ifdef __clang__
+void _exit (int __status) {
+ while (1) {}
+}
+#endif
+
+#endif
diff --git a/hw/bsp/lpc54/family.cmake b/hw/bsp/lpc54/family.cmake
index 287b437fb..5c61a07f0 100644
--- a/hw/bsp/lpc54/family.cmake
+++ b/hw/bsp/lpc54/family.cmake
@@ -1,9 +1,5 @@
include_guard()
-if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
-endif ()
-
set(SDK_DIR ${TOP}/hw/mcu/nxp/mcux-sdk)
set(CMSIS_DIR ${TOP}/lib/CMSIS_5)
@@ -32,7 +28,18 @@ function(add_board_target BOARD_TARGET)
return()
endif()
+ if (NOT DEFINED LD_FILE_GNU)
+ set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
+ endif ()
+ set(LD_FILE_Clang ${LD_FILE_GNU})
+
+ if (NOT DEFINED STARTUP_FILE_GNU)
+ set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
+ endif ()
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
add_library(${BOARD_TARGET} STATIC
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
# driver
${SDK_DIR}/drivers/lpc_gpio/fsl_gpio.c
${SDK_DIR}/drivers/common/fsl_common_arm.c
@@ -44,12 +51,27 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_power.c
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_reset.c
)
-
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${TOP}/lib/sct_neopixel
+ # driver
+ ${SDK_DIR}/drivers/common
+ ${SDK_DIR}/drivers/flexcomm
+ ${SDK_DIR}/drivers/lpc_iocon
+ ${SDK_DIR}/drivers/lpc_gpio
+ ${SDK_DIR}/drivers/lpuart
+ ${SDK_DIR}/drivers/sctimer
+ # mcu
+ ${SDK_DIR}/devices/${MCU_VARIANT}
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers
+ ${CMSIS_DIR}/CMSIS/Core/Include
+ )
target_compile_definitions(${BOARD_TARGET} PUBLIC
CFG_TUSB_MEM_ALIGN=TU_ATTR_ALIGNED\(64\)
BOARD_TUD_RHPORT=${PORT}
BOARD_TUH_RHPORT=${HOST_PORT}
+ __STARTUP_CLEAR_BSS
)
+
# Port 0 is Fullspeed, Port 1 is Highspeed. Port1 controller can only access USB_SRAM
if (PORT EQUAL 1)
target_compile_definitions(${BOARD_TARGET} PUBLIC
@@ -66,42 +88,17 @@ function(add_board_target BOARD_TARGET)
)
endif ()
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${TOP}/lib/sct_neopixel
- # driver
- ${SDK_DIR}/drivers/common
- ${SDK_DIR}/drivers/flexcomm
- ${SDK_DIR}/drivers/lpc_iocon
- ${SDK_DIR}/drivers/lpc_gpio
- ${SDK_DIR}/drivers/lpuart
- ${SDK_DIR}/drivers/sctimer
- # mcu
- ${CMSIS_DIR}/CMSIS/Core/Include
- ${SDK_DIR}/devices/${MCU_VARIANT}
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers
- )
-
update_board(${BOARD_TARGET})
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
- endif ()
-
- if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
- endif ()
-
- target_sources(${BOARD_TARGET} PUBLIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
- )
-
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_link_options(${BOARD_TARGET} PUBLIC
- # linker file
"LINKER:--script=${LD_FILE_GNU}"
- # nanolib
- --specs=nosys.specs
- --specs=nano.specs
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
diff --git a/hw/bsp/lpc54/family.mk b/hw/bsp/lpc54/family.mk
index 9b5eac18d..ea4c9c39c 100644
--- a/hw/bsp/lpc54/family.mk
+++ b/hw/bsp/lpc54/family.mk
@@ -7,6 +7,7 @@ MCU_DIR = $(SDK_DIR)/devices/$(MCU_VARIANT)
CFLAGS += \
-flto \
+ -D__STARTUP_CLEAR_BSS \
-DCFG_TUSB_MCU=OPT_MCU_LPC54XXX \
-DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))' \
@@ -23,7 +24,9 @@ endif
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += \
+ -nostartfiles \
+ --specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
diff --git a/hw/bsp/lpc55/family.c b/hw/bsp/lpc55/family.c
index 0fd85988a..cfd5b7032 100644
--- a/hw/bsp/lpc55/family.c
+++ b/hw/bsp/lpc55/family.c
@@ -72,13 +72,11 @@
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
-void USB0_IRQHandler(void)
-{
+void USB0_IRQHandler(void) {
tud_int_handler(0);
}
-void USB1_IRQHandler(void)
-{
+void USB1_IRQHandler(void) {
tud_int_handler(1);
}
@@ -92,8 +90,7 @@ settings:
sources:
- {id: SYSCON.fro_hf.outFreq, value: 96 MHz}
******************************************************************/
-void BootClockFROHF96M(void)
-{
+void BootClockFROHF96M(void) {
/*!< Set up the clock sources */
/*!< Set up FRO */
POWER_DisablePD(kPDRUNCFG_PD_FRO192M); /*!< Ensure FRO is on */
@@ -116,8 +113,7 @@ void BootClockFROHF96M(void)
SystemCoreClock = 96000000U;
}
-void board_init(void)
-{
+void board_init(void) {
// Enable IOCON clock
CLOCK_EnableClock(kCLOCK_Iocon);
@@ -138,7 +134,7 @@ void board_init(void)
// LED
IOCON_PinMuxSet(IOCON, LED_PORT, LED_PIN, IOCON_PIO_DIG_FUNC0_EN);
- gpio_pin_config_t const led_config = { kGPIO_DigitalOutput, 1};
+ gpio_pin_config_t const led_config = {kGPIO_DigitalOutput, 1};
GPIO_PinInit(GPIO, LED_PORT, LED_PIN, &led_config);
board_led_write(0);
@@ -157,7 +153,7 @@ void board_init(void)
// Button
IOCON_PinMuxSet(IOCON, BUTTON_PORT, BUTTON_PIN, IOCON_PIO_DIG_FUNC0_EN);
- gpio_pin_config_t const button_config = { kGPIO_DigitalInput, 0};
+ gpio_pin_config_t const button_config = {kGPIO_DigitalInput, 0};
GPIO_PinInit(GPIO, BUTTON_PORT, BUTTON_PIN, &button_config);
#ifdef UART_DEV
@@ -170,8 +166,8 @@ void board_init(void)
usart_config_t uart_config;
USART_GetDefaultConfig(&uart_config);
uart_config.baudRate_Bps = CFG_BOARD_UART_BAUDRATE;
- uart_config.enableTx = true;
- uart_config.enableRx = true;
+ uart_config.enableTx = true;
+ uart_config.enableRx = true;
USART_Init(UART_DEV, &uart_config, 12000000);
#endif
@@ -250,9 +246,8 @@ void board_init(void)
// Board porting API
//--------------------------------------------------------------------+
-void board_led_write(bool state)
-{
- GPIO_PinWrite(GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+void board_led_write(bool state) {
+ GPIO_PinWrite(GPIO, LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
#ifdef NEOPIXEL_PIN
if (state) {
@@ -266,33 +261,50 @@ void board_led_write(bool state)
#endif
}
-uint32_t board_button_read(void)
-{
+uint32_t board_button_read(void) {
// active low
return BUTTON_STATE_ACTIVE == GPIO_PinRead(GPIO, BUTTON_PORT, BUTTON_PIN);
}
-int board_uart_read(uint8_t* buf, int len)
-{
- (void) buf; (void) len;
+int board_uart_read(uint8_t* buf, int len) {
+ (void) buf;
+ (void) len;
return 0;
}
-int board_uart_write(void const * buf, int len)
-{
- USART_WriteBlocking(UART_DEV, (uint8_t const *) buf, len);
+int board_uart_write(void const* buf, int len) {
+ USART_WriteBlocking(UART_DEV, (uint8_t const*) buf, len);
return len;
}
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
-void SysTick_Handler(void)
-{
+
+void SysTick_Handler(void) {
system_ticks++;
}
-uint32_t board_millis(void)
-{
+uint32_t board_millis(void) {
return system_ticks;
}
#endif
+
+
+#ifndef __ICCARM__
+// Implement _start() since we use linker flag '-nostartfiles'.
+// Requires defined __STARTUP_CLEAR_BSS,
+extern int main(void);
+
+TU_ATTR_UNUSED void _start(void) {
+ // called by startup code
+ main();
+ while (1) {}
+}
+
+#ifdef __clang__
+void _exit (int __status) {
+ while (1) {}
+}
+#endif
+
+#endif
diff --git a/hw/bsp/lpc55/family.cmake b/hw/bsp/lpc55/family.cmake
index 75dabfe5a..21c57fc1f 100644
--- a/hw/bsp/lpc55/family.cmake
+++ b/hw/bsp/lpc55/family.cmake
@@ -1,9 +1,5 @@
include_guard()
-if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
-endif ()
-
set(SDK_DIR ${TOP}/hw/mcu/nxp/mcux-sdk)
set(CMSIS_DIR ${TOP}/lib/CMSIS_5)
@@ -30,9 +26,20 @@ set(HOST_PORT $)
function(add_board_target BOARD_TARGET)
if (TARGET ${BOARD_TARGET})
return()
+ endif()
+
+ if (NOT DEFINED LD_FILE_GNU)
+ set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
endif ()
+ set(LD_FILE_Clang ${LD_FILE_GNU})
+
+ if (NOT DEFINED STARTUP_FILE_GNU)
+ set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
+ endif ()
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
add_library(${BOARD_TARGET} STATIC
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
# driver
${SDK_DIR}/drivers/lpc_gpio/fsl_gpio.c
${SDK_DIR}/drivers/common/fsl_common_arm.c
@@ -44,12 +51,27 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_power.c
${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_reset.c
)
-
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${TOP}/lib/sct_neopixel
+ # driver
+ ${SDK_DIR}/drivers/common
+ ${SDK_DIR}/drivers/flexcomm
+ ${SDK_DIR}/drivers/lpc_iocon
+ ${SDK_DIR}/drivers/lpc_gpio
+ ${SDK_DIR}/drivers/lpuart
+ ${SDK_DIR}/drivers/sctimer
+ # mcu
+ ${SDK_DIR}/devices/${MCU_VARIANT}
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers
+ ${CMSIS_DIR}/CMSIS/Core/Include
+ )
target_compile_definitions(${BOARD_TARGET} PUBLIC
CFG_TUSB_MEM_ALIGN=TU_ATTR_ALIGNED\(64\)
BOARD_TUD_RHPORT=${PORT}
BOARD_TUH_RHPORT=${HOST_PORT}
+ __STARTUP_CLEAR_BSS
)
+
# Port 0 is Fullspeed, Port 1 is Highspeed. Port1 controller can only access USB_SRAM
if (PORT EQUAL 1)
target_compile_definitions(${BOARD_TARGET} PUBLIC
@@ -65,42 +87,17 @@ function(add_board_target BOARD_TARGET)
)
endif ()
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${TOP}/lib/sct_neopixel
- # driver
- ${SDK_DIR}/drivers/common
- ${SDK_DIR}/drivers/flexcomm
- ${SDK_DIR}/drivers/lpc_iocon
- ${SDK_DIR}/drivers/lpc_gpio
- ${SDK_DIR}/drivers/lpuart
- ${SDK_DIR}/drivers/sctimer
- # mcu
- ${CMSIS_DIR}/CMSIS/Core/Include
- ${SDK_DIR}/devices/${MCU_VARIANT}
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers
- )
-
update_board(${BOARD_TARGET})
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
- endif ()
-
- if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
- set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
- endif ()
-
- target_sources(${BOARD_TARGET} PUBLIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
- )
-
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_link_options(${BOARD_TARGET} PUBLIC
- # linker file
"LINKER:--script=${LD_FILE_GNU}"
- # nanolib
- --specs=nosys.specs
- --specs=nano.specs
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
diff --git a/hw/bsp/lpc55/family.mk b/hw/bsp/lpc55/family.mk
index 1b97c43e4..d82e85904 100644
--- a/hw/bsp/lpc55/family.mk
+++ b/hw/bsp/lpc55/family.mk
@@ -11,9 +11,10 @@ PORT ?= 1
CFLAGS += \
-flto \
+ -D__STARTUP_CLEAR_BSS \
-DCFG_TUSB_MCU=OPT_MCU_LPC55XX \
-DCFG_TUSB_MEM_ALIGN='__attribute__((aligned(64)))' \
- -DBOARD_TUD_RHPORT=$(PORT)
+ -DBOARD_TUD_RHPORT=$(PORT) \
ifeq ($(PORT), 1)
$(info "PORT1 High Speed")
@@ -28,7 +29,9 @@ endif
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=float-equal
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += \
+ -nostartfiles \
+ --specs=nosys.specs --specs=nano.specs \
# All source paths should be relative to the top level.
LD_FILE ?= $(MCU_DIR)/gcc/$(MCU_CORE)_flash.ld
diff --git a/hw/bsp/mcx/family.cmake b/hw/bsp/mcx/family.cmake
index c8591b569..223afb9ec 100644
--- a/hw/bsp/mcx/family.cmake
+++ b/hw/bsp/mcx/family.cmake
@@ -1,9 +1,5 @@
include_guard()
-if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
-endif ()
-
set(SDK_DIR ${TOP}/hw/mcu/nxp/mcux-sdk)
set(CMSIS_DIR ${TOP}/lib/CMSIS_5)
@@ -28,60 +24,63 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
#------------------------------------
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
- if (NOT TARGET ${BOARD_TARGET})
- add_library(${BOARD_TARGET} STATIC
- # external driver
- #lib/sct_neopixel/sct_neopixel.c
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif()
- # driver
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_gpio.c
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_common_arm.c
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_lpuart.c
+ if (NOT DEFINED LD_FILE_GNU)
+ set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld)
+ endif ()
+ set(LD_FILE_Clang ${LD_FILE_GNU})
- # mcu
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_reset.c
- ${SDK_DIR}/devices/${MCU_VARIANT}/system_${MCU_CORE}.c
+ if (NOT DEFINED STARTUP_FILE_GNU)
+ set(STARTUP_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S)
+ endif()
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+ add_library(${BOARD_TARGET} STATIC
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ # driver
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_gpio.c
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_common_arm.c
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_lpuart.c
+ # mcu
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_clock.c
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_reset.c
+ ${SDK_DIR}/devices/${MCU_VARIANT}/system_${MCU_CORE}.c
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMSIS_DIR}/CMSIS/Core/Include
+ ${SDK_DIR}/devices/${MCU_VARIANT}
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers
+ )
+
+ if (${FAMILY_MCUS} STREQUAL "MCXN9")
+ target_sources(${BOARD_TARGET} PRIVATE
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_lpflexcomm.c
+ )
+ elseif(${FAMILY_MCUS} STREQUAL "MCXA15")
+ target_sources(${BOARD_TARGET} PRIVATE
+ ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_spc.c
+ )
+ endif()
+
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ --specs=nosys.specs --specs=nano.specs
+ #-nostartfiles
)
-
- if (${FAMILY_MCUS} STREQUAL "MCXN9")
- target_sources(${BOARD_TARGET} PRIVATE
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_lpflexcomm.c
- )
- elseif(${FAMILY_MCUS} STREQUAL "MCXA15")
- target_sources(${BOARD_TARGET} PRIVATE
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers/fsl_spc.c
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
)
- endif()
-
- # target_compile_definitions(${BOARD_TARGET} PUBLIC
- # )
- target_include_directories(${BOARD_TARGET} PUBLIC
- # driver
- # mcu
- ${CMSIS_DIR}/CMSIS/Core/Include
- ${SDK_DIR}/devices/${MCU_VARIANT}
- ${SDK_DIR}/devices/${MCU_VARIANT}/drivers
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
)
-
- update_board(${BOARD_TARGET})
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_sources(${BOARD_TARGET} PUBLIC
- ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_CORE}.S
- )
- target_link_options(${BOARD_TARGET} PUBLIC
- # linker file
- "LINKER:--script=${SDK_DIR}/devices/${MCU_VARIANT}/gcc/${MCU_CORE}_flash.ld"
- # nanolib
- --specs=nosys.specs
- --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endif ()
endfunction()
diff --git a/hw/bsp/nrf/boards/arduino_nano33_ble/arduino_nano33_ble.ld b/hw/bsp/nrf/boards/arduino_nano33_ble/arduino_nano33_ble.ld
index b7cac1019..9288a0c5e 100755
--- a/hw/bsp/nrf/boards/arduino_nano33_ble/arduino_nano33_ble.ld
+++ b/hw/bsp/nrf/boards/arduino_nano33_ble/arduino_nano33_ble.ld
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
-GROUP(-lgcc -lc -lnosys)
+/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/
MEMORY
{
diff --git a/hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake b/hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake
index 726438d05..6ff1a7b59 100644
--- a/hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake
+++ b/hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake
@@ -1,6 +1,5 @@
set(MCU_VARIANT nrf52840)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/../../linker/nrf52840_s140_v6.ld)
-#set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
# enable max3421 host driver for this board
set(MAX3421_HOST 1)
diff --git a/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld
index 78eddc9c3..a6bc6dcfe 100644
--- a/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld
+++ b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
-GROUP(-lgcc -lc -lnosys)
+/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/
MEMORY
{
diff --git a/hw/bsp/nrf/boards/pca10056/board.cmake b/hw/bsp/nrf/boards/pca10056/board.cmake
index 693d7beed..cc370aac8 100644
--- a/hw/bsp/nrf/boards/pca10056/board.cmake
+++ b/hw/bsp/nrf/boards/pca10056/board.cmake
@@ -1,5 +1,4 @@
set(MCU_VARIANT nrf52840)
-set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
function(update_board TARGET)
endfunction()
diff --git a/hw/bsp/nrf/boards/pca10059/pca10059.ld b/hw/bsp/nrf/boards/pca10059/pca10059.ld
index 510bfdd8c..adc80f3c4 100644
--- a/hw/bsp/nrf/boards/pca10059/pca10059.ld
+++ b/hw/bsp/nrf/boards/pca10059/pca10059.ld
@@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
-GROUP(-lgcc -lc -lnosys)
+/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/
MEMORY
{
@@ -11,3 +11,9 @@ MEMORY
INCLUDE "nrf_common.ld"
+
+/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
+__tbss_start__ = __tbss_start;
+__tbss_end__ = __tbss_end;
+__sbss_start__ = __sbss_start;
+__sbss_end__ = __sbss_end;
diff --git a/hw/bsp/nrf/boards/pca10095/board.cmake b/hw/bsp/nrf/boards/pca10095/board.cmake
index ca5399a3a..95dd30969 100644
--- a/hw/bsp/nrf/boards/pca10095/board.cmake
+++ b/hw/bsp/nrf/boards/pca10095/board.cmake
@@ -1,5 +1,4 @@
set(MCU_VARIANT nrf5340_application)
-set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf5340_xxaa_application.ld)
function(update_board TARGET)
target_sources(${TARGET} PRIVATE
diff --git a/hw/bsp/nrf/boards/pca10100/board.cmake b/hw/bsp/nrf/boards/pca10100/board.cmake
index c30026815..a925dae80 100644
--- a/hw/bsp/nrf/boards/pca10100/board.cmake
+++ b/hw/bsp/nrf/boards/pca10100/board.cmake
@@ -1,5 +1,4 @@
set(MCU_VARIANT nrf52833)
-set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52833_xxaa.ld)
function(update_board TARGET)
endfunction()
diff --git a/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.cmake b/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.cmake
index 693d7beed..cc370aac8 100644
--- a/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.cmake
+++ b/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.cmake
@@ -1,5 +1,4 @@
set(MCU_VARIANT nrf52840)
-set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
function(update_board TARGET)
endfunction()
diff --git a/hw/bsp/nrf/family.c b/hw/bsp/nrf/family.c
index 71c651f5f..885910f9a 100644
--- a/hw/bsp/nrf/family.c
+++ b/hw/bsp/nrf/family.c
@@ -33,6 +33,7 @@
#pragma GCC diagnostic ignored "-Wcast-qual"
#pragma GCC diagnostic ignored "-Wcast-align"
#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wundef"
#pragma GCC diagnostic ignored "-Wredundant-decls"
#endif
@@ -54,6 +55,14 @@
#endif
+// There is API changes between nrfx v2 and v3
+#if 85301 >= (10000*MDK_MAJOR_VERSION + 100*MDK_MINOR_VERSION + MDK_MICRO_VERSION)
+ // note MDK 8.53.1 is also used by nrfx v3.0.0, just skip this version and use later 3.x
+ #define NRFX_VER 2
+#else
+ #define NRFX_VER 3
+#endif
+
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
@@ -98,8 +107,12 @@ TU_ATTR_UNUSED static void power_event_handler(nrfx_power_usb_evt_t event) {
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
static void max3421_init(void);
static nrfx_spim_t _spi = NRFX_SPIM_INSTANCE(1);
+
+#if NRFX_VER > 2
+static nrfx_gpiote_t _gpiote = NRFX_GPIOTE_INSTANCE(0);
#endif
+#endif
//--------------------------------------------------------------------+
//
@@ -124,6 +137,7 @@ void board_init(void) {
SysTick_Config(SystemCoreClock / 1000);
// UART
+ #if NRFX_VER <= 2
nrfx_uarte_config_t uart_cfg = {
.pseltxd = UART_TX_PIN,
.pselrxd = UART_RX_PIN,
@@ -137,6 +151,21 @@ void board_init(void) {
.parity = NRF_UARTE_PARITY_EXCLUDED,
}
};
+ #else
+ nrfx_uarte_config_t uart_cfg = {
+ .txd_pin = UART_TX_PIN,
+ .rxd_pin = UART_RX_PIN,
+ .rts_pin = NRF_UARTE_PSEL_DISCONNECTED,
+ .cts_pin = NRF_UARTE_PSEL_DISCONNECTED,
+ .p_context = NULL,
+ .baudrate = NRF_UARTE_BAUDRATE_115200, // CFG_BOARD_UART_BAUDRATE
+ .interrupt_priority = 7,
+ .config = {
+ .hwfc = NRF_UARTE_HWFC_DISABLED,
+ .parity = NRF_UARTE_PARITY_EXCLUDED,
+ }
+ };
+ #endif
nrfx_uarte_init(&_uart_id, &uart_cfg, NULL); //uart_handler);
@@ -224,11 +253,17 @@ int board_uart_read(uint8_t* buf, int len) {
(void) buf;
(void) len;
return 0;
-// return NRFX_SUCCESS == nrfx_uart_rx(&_uart_id, buf, (size_t) len) ? len : 0;
+// nrfx_err_t err = nrfx_uarte_rx(&_uart_id, buf, (size_t) len);
+// return NRFX_SUCCESS == err ? len : 0;
}
int board_uart_write(void const* buf, int len) {
- return (NRFX_SUCCESS == nrfx_uarte_tx(&_uart_id, (uint8_t const*) buf, (size_t) len)) ? len : 0;
+ nrfx_err_t err = nrfx_uarte_tx(&_uart_id, (uint8_t const*) buf, (size_t) len
+ #if NRFX_VER > 2
+ ,0
+ #endif
+ );
+ return (NRFX_SUCCESS == err) ? len : 0;
}
#if CFG_TUSB_OS == OPT_OS_NONE
@@ -241,9 +276,22 @@ void SysTick_Handler(void) {
uint32_t board_millis(void) {
return system_ticks;
}
-
#endif
+#ifndef __ICCARM__
+// Implement _start() since we use linker flag '-nostartfiles'.
+// Requires defined __STARTUP_CLEAR_BSS,
+extern int main(void);
+TU_ATTR_UNUSED void _start(void) {
+ // called by startup code
+ main();
+ while (1) {}
+}
+#endif
+
+//--------------------------------------------------------------------+
+// Softdevice running
+//--------------------------------------------------------------------+
#ifdef SOFTDEVICE_PRESENT
// process SOC event from SD
uint32_t proc_soc(void) {
@@ -286,8 +334,16 @@ void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info) {
//--------------------------------------------------------------------+
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
-void max3421_int_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
- if (!(pin == MAX3421_INTR_PIN && action == NRF_GPIOTE_POLARITY_HITOLO)) return;
+#if NRFX_VER <= 2
+void max3421_int_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action ) {
+ if (action != NRF_GPIOTE_POLARITY_HITOLO) return;
+#else
+void max3421_int_handler(nrfx_gpiote_pin_t pin, nrfx_gpiote_trigger_t action, void* p_context) {
+ (void) p_context;
+ if (action != NRFX_GPIOTE_TRIGGER_HITOLO) return;
+#endif
+
+ if (pin != MAX3421_INTR_PIN) return;
tuh_int_handler(1, true);
}
@@ -303,28 +359,55 @@ static void max3421_init(void) {
.sck_pin = MAX3421_SCK_PIN,
.mosi_pin = MAX3421_MOSI_PIN,
.miso_pin = MAX3421_MISO_PIN,
+ #if NRFX_VER <= 2
.ss_pin = NRFX_SPIM_PIN_NOT_USED,
+ .frequency = NRF_SPIM_FREQ_4M,
+ #else
+ .ss_pin = NRF_SPIM_PIN_NOT_CONNECTED,
+ .frequency = 4000000u,
+ #endif
.ss_active_high = false,
.irq_priority = 3,
.orc = 0xFF,
// default setting 4 Mhz, Mode 0, MSB first
- .frequency = NRF_SPIM_FREQ_4M,
.mode = NRF_SPIM_MODE_0,
.bit_order = NRF_SPIM_BIT_ORDER_MSB_FIRST,
+ .miso_pull = NRF_GPIO_PIN_NOPULL,
};
// no handler --> blocking
- nrfx_spim_init(&_spi, &cfg, NULL, NULL);
+ TU_ASSERT(NRFX_SUCCESS == nrfx_spim_init(&_spi, &cfg, NULL, NULL), );
// max3421e interrupt pin
+ #if NRFX_VER <= 2
nrfx_gpiote_init(1);
nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
in_config.pull = NRF_GPIO_PIN_PULLUP;
-
NVIC_SetPriority(GPIOTE_IRQn, 2);
-
nrfx_gpiote_in_init(MAX3421_INTR_PIN, &in_config, max3421_int_handler);
nrfx_gpiote_trigger_enable(MAX3421_INTR_PIN, true);
+ #else
+ nrf_gpio_pin_pull_t intr_pull = NRF_GPIO_PIN_PULLUP;
+ nrfx_gpiote_trigger_config_t intr_trigger = {
+ .trigger = NRFX_GPIOTE_TRIGGER_HITOLO,
+ .p_in_channel = NULL, // sensing mechanism
+ };
+ nrfx_gpiote_handler_config_t intr_handler = {
+ .handler = max3421_int_handler,
+ .p_context = NULL,
+ };
+ nrfx_gpiote_input_pin_config_t intr_config = {
+ .p_pull_config = &intr_pull,
+ .p_trigger_config = &intr_trigger,
+ .p_handler_config = &intr_handler,
+ };
+
+ nrfx_gpiote_init(&_gpiote, 1);
+ NVIC_SetPriority(GPIOTE_IRQn, 2);
+
+ nrfx_gpiote_input_configure(&_gpiote, MAX3421_INTR_PIN, &intr_config);
+ nrfx_gpiote_trigger_enable(&_gpiote, MAX3421_INTR_PIN, true);
+ #endif
}
// API to enable/disable MAX3421 INTR pin interrupt
diff --git a/hw/bsp/nrf/family.cmake b/hw/bsp/nrf/family.cmake
index 2c4620b97..5de69a8a3 100644
--- a/hw/bsp/nrf/family.cmake
+++ b/hw/bsp/nrf/family.cmake
@@ -1,9 +1,5 @@
include_guard()
-if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
-endif ()
-
set(NRFX_DIR ${TOP}/hw/mcu/nordic/nrfx)
set(CMSIS_DIR ${TOP}/lib/CMSIS_5)
@@ -29,68 +25,75 @@ set(FAMILY_MCUS NRF5X CACHE INTERNAL "")
#------------------------------------
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
- if (NOT TARGET ${BOARD_TARGET})
- add_library(${BOARD_TARGET} STATIC
- # driver
- ${NRFX_DIR}/helpers/nrfx_flag32_allocator.c
- ${NRFX_DIR}/drivers/src/nrfx_gpiote.c
- ${NRFX_DIR}/drivers/src/nrfx_power.c
- ${NRFX_DIR}/drivers/src/nrfx_spim.c
- ${NRFX_DIR}/drivers/src/nrfx_uarte.c
- # mcu
- ${NRFX_DIR}/mdk/system_${MCU_VARIANT}.c
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif ()
+
+ if (MCU_VARIANT STREQUAL "nrf5340_application")
+ set(MCU_VARIANT_XXAA "nrf5340_xxaa_application")
+ else ()
+ set(MCU_VARIANT_XXAA "${MCU_VARIANT}_xxaa")
+ endif ()
+
+ if (NOT DEFINED LD_FILE_GNU)
+ set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT_XXAA}.ld)
+ endif ()
+
+ if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
+ set(STARTUP_FILE_GNU ${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S)
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+ endif ()
+
+ add_library(${BOARD_TARGET} STATIC
+ ${NRFX_DIR}/helpers/nrfx_flag32_allocator.c
+ ${NRFX_DIR}/drivers/src/nrfx_gpiote.c
+ ${NRFX_DIR}/drivers/src/nrfx_power.c
+ ${NRFX_DIR}/drivers/src/nrfx_spim.c
+ ${NRFX_DIR}/drivers/src/nrfx_uarte.c
+ ${NRFX_DIR}/mdk/system_${MCU_VARIANT}.c
+ ${NRFX_DIR}/soc/nrfx_atomic.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ string(TOUPPER "${MCU_VARIANT_XXAA}" MCU_VARIANT_XXAA_UPPER)
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ __STARTUP_CLEAR_BSS
+ CONFIG_GPIO_AS_PINRESET
+ ${MCU_VARIANT_XXAA_UPPER}
+ )
+
+ if (TRACE_ETM STREQUAL "1")
+ # ENABLE_TRACE will cause system_nrf5x.c to set up ETM trace
+ target_compile_definitions(${BOARD_TARGET} PUBLIC ENABLE_TRACE)
+ endif ()
+
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${NRFX_DIR}
+ ${NRFX_DIR}/mdk
+ ${NRFX_DIR}/hal
+ ${NRFX_DIR}/drivers/include
+ ${NRFX_DIR}/drivers/src
+ ${CMSIS_DIR}/CMSIS/Core/Include
+ )
+
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -L${NRFX_DIR}/mdk
+ --specs=nosys.specs --specs=nano.specs
+ -nostartfiles
)
- target_compile_definitions(${BOARD_TARGET} PUBLIC CONFIG_GPIO_AS_PINRESET)
-
- if (MCU_VARIANT STREQUAL "nrf52840")
- target_compile_definitions(${BOARD_TARGET} PUBLIC NRF52840_XXAA)
- elseif (MCU_VARIANT STREQUAL "nrf52833")
- target_compile_definitions(${BOARD_TARGET} PUBLIC NRF52833_XXAA)
- elseif (MCU_VARIANT STREQUAL "nrf5340_application")
- target_compile_definitions(${BOARD_TARGET} PUBLIC NRF5340_XXAA NRF5340_XXAA_APPLICATION)
- endif ()
-
- if (TRACE_ETM STREQUAL "1")
- # ENABLE_TRACE will cause system_nrf5x.c to set up ETM trace
- target_compile_definitions(${BOARD_TARGET} PUBLIC ENABLE_TRACE)
- endif ()
-
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
- ${NRFX_DIR}
- ${NRFX_DIR}/mdk
- ${NRFX_DIR}/hal
- ${NRFX_DIR}/drivers/include
- ${NRFX_DIR}/drivers/src
- ${CMSIS_DIR}/CMSIS/Core/Include
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -L${NRFX_DIR}/mdk
)
-
- update_board(${BOARD_TARGET})
-
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- set(LD_FILE_GNU ${NRFX_DIR}/mdk/${MCU_VARIANT}_xxaa.ld)
- endif ()
-
- if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
- set(STARTUP_FILE_GNU ${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S)
- endif ()
-
- target_sources(${BOARD_TARGET} PUBLIC
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
)
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- # linker file
- "LINKER:--script=${LD_FILE_GNU}"
- -L${NRFX_DIR}/mdk
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endif ()
endfunction()
diff --git a/hw/bsp/nrf/family.mk b/hw/bsp/nrf/family.mk
index 29802dc37..b3c05e6db 100644
--- a/hw/bsp/nrf/family.mk
+++ b/hw/bsp/nrf/family.mk
@@ -8,25 +8,31 @@ include $(TOP)/$(BOARD_PATH)/board.mk
CPU_CORE ?= cortex-m4
CFLAGS += \
- -flto \
-DCFG_TUSB_MCU=OPT_MCU_NRF5X \
- -DCONFIG_GPIO_AS_PINRESET
+ -DCONFIG_GPIO_AS_PINRESET \
+ -D__STARTUP_CLEAR_BSS
#CFLAGS += -nostdlib
#CFLAGS += -D__START=main
# suppress warning caused by vendor mcu driver
-CFLAGS += \
+CFLAGS_GCC += \
+ -flto \
-Wno-error=undef \
-Wno-error=unused-parameter \
+ -Wno-error=unused-variable \
-Wno-error=cast-align \
-Wno-error=cast-qual \
- -Wno-error=redundant-decls
+ -Wno-error=redundant-decls \
-LDFLAGS += \
- -specs=nosys.specs -specs=nano.specs \
+LDFLAGS_GCC += \
+ -nostartfiles \
+ --specs=nosys.specs --specs=nano.specs \
-L$(TOP)/${NRFX_DIR}/mdk
+LDFLAGS_CLANG += \
+ -L$(TOP)/${NRFX_DIR}/mdk \
+
SRC_C += \
src/portable/nordic/nrf5x/dcd_nrf5x.c \
${NRFX_DIR}/helpers/nrfx_flag32_allocator.c \
@@ -34,7 +40,8 @@ SRC_C += \
${NRFX_DIR}/drivers/src/nrfx_power.c \
${NRFX_DIR}/drivers/src/nrfx_spim.c \
${NRFX_DIR}/drivers/src/nrfx_uarte.c \
- ${NRFX_DIR}/mdk/system_$(MCU_VARIANT).c
+ ${NRFX_DIR}/mdk/system_$(MCU_VARIANT).c \
+ ${NRFX_DIR}/soc/nrfx_atomic.c
INC += \
$(TOP)/$(BOARD_PATH) \
diff --git a/hw/bsp/nrf/linker/nrf52833_xxaa.ld b/hw/bsp/nrf/linker/nrf52833_xxaa.ld
new file mode 100644
index 000000000..ae4d0e5b3
--- /dev/null
+++ b/hw/bsp/nrf/linker/nrf52833_xxaa.ld
@@ -0,0 +1,20 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x80000
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000
+ CODE_RAM (rwx) : ORIGIN = 0x800000, LENGTH = 0x20000
+}
+
+
+INCLUDE "nrf_common.ld"
+
+/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
+__tbss_start__ = __tbss_start;
+__tbss_end__ = __tbss_end;
+__sbss_start__ = __sbss_start;
+__sbss_end__ = __sbss_end;
diff --git a/hw/bsp/nrf/linker/nrf52840_s140_v6.ld b/hw/bsp/nrf/linker/nrf52840_s140_v6.ld
index e27fa1c91..037a14196 100644
--- a/hw/bsp/nrf/linker/nrf52840_s140_v6.ld
+++ b/hw/bsp/nrf/linker/nrf52840_s140_v6.ld
@@ -1,11 +1,11 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
-GROUP(-lgcc -lc -lnosys)
+/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/
MEMORY
{
- FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xED000 - 0x26000
+ FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xED000 - 0x26000
/* SRAM required by S132 depend on
* - Attribute Table Size
@@ -14,7 +14,7 @@ MEMORY
* - Concurrent connection peripheral + central + secure links
* - Event Len, HVN queue, Write CMD queue
*/
- RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20040000 - 0x20003400
+ RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20040000 - 0x20003400
}
SECTIONS
@@ -36,3 +36,9 @@ SECTIONS
} INSERT AFTER .data;
INCLUDE "nrf_common.ld"
+
+/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
+__tbss_start__ = __tbss_start;
+__tbss_end__ = __tbss_end;
+__sbss_start__ = __sbss_start;
+__sbss_end__ = __sbss_end;
diff --git a/hw/bsp/nrf/linker/nrf52840_xxaa.ld b/hw/bsp/nrf/linker/nrf52840_xxaa.ld
new file mode 100644
index 000000000..2d20ba7ac
--- /dev/null
+++ b/hw/bsp/nrf/linker/nrf52840_xxaa.ld
@@ -0,0 +1,20 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x100000
+ EXTFLASH (rx) : ORIGIN = 0x12000000, LENGTH = 0x8000000
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000
+ CODE_RAM (rwx) : ORIGIN = 0x800000, LENGTH = 0x40000
+}
+
+INCLUDE "nrf_common.ld"
+
+/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
+__tbss_start__ = __tbss_start;
+__tbss_end__ = __tbss_end;
+__sbss_start__ = __sbss_start;
+__sbss_end__ = __sbss_end;
diff --git a/hw/bsp/nrf/linker/nrf5340_xxaa_application.ld b/hw/bsp/nrf/linker/nrf5340_xxaa_application.ld
new file mode 100644
index 000000000..31762d0b2
--- /dev/null
+++ b/hw/bsp/nrf/linker/nrf5340_xxaa_application.ld
@@ -0,0 +1,21 @@
+/* Linker script to configure memory regions. */
+
+SEARCH_DIR(.)
+/*GROUP(-lgcc -lc) not compatible with clang*/
+
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x100000
+ EXTFLASH (rx) : ORIGIN = 0x10000000, LENGTH = 0x8000000
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000
+ RAM1 (rwx) : ORIGIN = 0x20040000, LENGTH = 0x3F000
+}
+
+
+INCLUDE "nrf_common.ld"
+
+/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
+__tbss_start__ = __tbss_start;
+__tbss_end__ = __tbss_end;
+__sbss_start__ = __sbss_start;
+__sbss_end__ = __sbss_end;
diff --git a/hw/bsp/nrf/nrfx_config.h b/hw/bsp/nrf/nrfx_config.h
index 95ef33ce4..fbec4192b 100644
--- a/hw/bsp/nrf/nrfx_config.h
+++ b/hw/bsp/nrf/nrfx_config.h
@@ -6,6 +6,7 @@
#define NRFX_CLOCK_ENABLED 0
#define NRFX_GPIOTE_ENABLED 1
+#define NRFX_GPIOTE0_ENABLED 1
#define NRFX_UARTE_ENABLED 1
#define NRFX_UARTE0_ENABLED 1
diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake
index 861d20bdd..a298e684b 100644
--- a/hw/bsp/rp2040/family.cmake
+++ b/hw/bsp/rp2040/family.cmake
@@ -6,6 +6,12 @@ if (NOT BOARD)
set(BOARD pico_sdk)
endif()
+if (TOOLCHAIN STREQUAL "clang")
+ set(PICO_COMPILER "pico_arm_clang")
+else()
+ set(PICO_COMPILER "pico_arm_gcc")
+endif()
+
# add the SDK in case we are standalone tinyusb example (noop if already present)
include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_import.cmake)
@@ -30,13 +36,13 @@ endif()
add_library(tinyusb_common_base INTERFACE)
target_sources(tinyusb_common_base INTERFACE
- ${TOP}/src/tusb.c
- ${TOP}/src/common/tusb_fifo.c
- )
+ ${TOP}/src/tusb.c
+ ${TOP}/src/common/tusb_fifo.c
+ )
target_include_directories(tinyusb_common_base INTERFACE
- ${TOP}/src
- )
+ ${TOP}/src
+ )
if(DEFINED LOG)
set(TINYUSB_DEBUG_LEVEL ${LOG})
@@ -48,9 +54,9 @@ else ()
endif()
target_compile_definitions(tinyusb_common_base INTERFACE
- CFG_TUSB_MCU=OPT_MCU_RP2040
- CFG_TUSB_OS=${TINYUSB_OPT_OS}
- CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
+ CFG_TUSB_MCU=OPT_MCU_RP2040
+ CFG_TUSB_OS=${TINYUSB_OPT_OS}
+ CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
)
target_link_libraries(tinyusb_common_base INTERFACE
diff --git a/hw/bsp/samd11/boards/cynthion_d11/samd11d14am_flash.ld b/hw/bsp/samd11/boards/cynthion_d11/samd11d14am_flash.ld
index f175e6504..57e7f8904 100644
--- a/hw/bsp/samd11/boards/cynthion_d11/samd11d14am_flash.ld
+++ b/hw/bsp/samd11/boards/cynthion_d11/samd11d14am_flash.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x400;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x400;
/* Section Definitions */
SECTIONS
diff --git a/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld b/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld
index 9e12acec8..75d880f62 100644
--- a/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld
+++ b/hw/bsp/samd11/boards/samd11_xplained/samd11d14am_flash.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x400;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x400;
/* Section Definitions */
SECTIONS
diff --git a/hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld b/hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld
index e2f93416d..d9b086f9c 100644
--- a/hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld
+++ b/hw/bsp/samd21/boards/atsamd21_xpro/samd21j18a_flash.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
/* Section Definitions */
SECTIONS
diff --git a/hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld b/hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld
index f0c93340c..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld
+++ b/hw/bsp/samd21/boards/circuitplayground_express/circuitplayground_express.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld b/hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld
index 153f0cbb9..e03a4ce60 100644
--- a/hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld
+++ b/hw/bsp/samd21/boards/curiosity_nano/samd21g17a_flash.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x1000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x1000;
/* Section Definitions */
SECTIONS
diff --git a/hw/bsp/samd21/boards/cynthion_d21/samd21g18a_flash.ld b/hw/bsp/samd21/boards/cynthion_d21/samd21g18a_flash.ld
index ecb6b8523..95d71b9e3 100644
--- a/hw/bsp/samd21/boards/cynthion_d21/samd21g18a_flash.ld
+++ b/hw/bsp/samd21/boards/cynthion_d21/samd21g18a_flash.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
/* Section Definitions */
SECTIONS
diff --git a/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld b/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld
index f0c93340c..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld
+++ b/hw/bsp/samd21/boards/feather_m0_express/feather_m0_express.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld b/hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld
index f0c93340c..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld
+++ b/hw/bsp/samd21/boards/itsybitsy_m0/itsybitsy_m0.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld b/hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld
index f0c93340c..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld
+++ b/hw/bsp/samd21/boards/metro_m0_express/metro_m0_express.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd21/boards/qtpy/qtpy.ld b/hw/bsp/samd21/boards/qtpy/qtpy.ld
index f0c93340c..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/qtpy/qtpy.ld
+++ b/hw/bsp/samd21/boards/qtpy/qtpy.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld b/hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld
index cf11c4c35..0d0c4e6c4 100644
--- a/hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld
+++ b/hw/bsp/samd21/boards/seeeduino_xiao/seeeduino_xiao.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/sparkfun_samd21_mini_usb.ld b/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/sparkfun_samd21_mini_usb.ld
index f5d2ad151..0754a8e9c 100644
--- a/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/sparkfun_samd21_mini_usb.ld
+++ b/hw/bsp/samd21/boards/sparkfun_samd21_mini_usb/sparkfun_samd21_mini_usb.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld b/hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld
index f0c93340c..ce7aff80b 100644
--- a/hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld
+++ b/hw/bsp/samd21/boards/trinket_m0/trinket_m0.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd21/family.cmake b/hw/bsp/samd21/family.cmake
index a79a25b54..540a0ee33 100644
--- a/hw/bsp/samd21/family.cmake
+++ b/hw/bsp/samd21/family.cmake
@@ -17,52 +17,57 @@ set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -c \"transport select swd\" -f ta
#------------------------------------
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
- if (NOT TARGET ${BOARD_TARGET})
- add_library(${BOARD_TARGET} STATIC
- ${SDK_DIR}/gcc/system_samd21.c
- ${SDK_DIR}/hpl/gclk/hpl_gclk.c
- ${SDK_DIR}/hpl/pm/hpl_pm.c
- ${SDK_DIR}/hpl/sysctrl/hpl_sysctrl.c
- ${SDK_DIR}/hal/src/hal_atomic.c
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif ()
+
+ set(LD_FILE_Clang ${LD_FILE_GNU})
+ if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
+ message(FATAL_ERROR "LD_FILE_${CMAKE_C_COMPILER_ID} not defined")
+ endif ()
+
+ if (NOT DEFINED STARTUP_FILE_GNU)
+ set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_samd21.c)
+ endif ()
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+ add_library(${BOARD_TARGET} STATIC
+ ${SDK_DIR}/gcc/system_samd21.c
+ ${SDK_DIR}/hpl/gclk/hpl_gclk.c
+ ${SDK_DIR}/hpl/pm/hpl_pm.c
+ ${SDK_DIR}/hpl/sysctrl/hpl_sysctrl.c
+ ${SDK_DIR}/hal/src/hal_atomic.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}
+ ${SDK_DIR}/config
+ ${SDK_DIR}/include
+ ${SDK_DIR}/hal/include
+ ${SDK_DIR}/hal/utils/include
+ ${SDK_DIR}/hpl/pm
+ ${SDK_DIR}/hpl/port
+ ${SDK_DIR}/hri
+ ${SDK_DIR}/CMSIS/Include
+ )
+ target_compile_definitions(${BOARD_TARGET} PUBLIC CONF_DFLL_OVERWRITE_CALIBRATION=0)
+
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
)
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${SDK_DIR}
- ${SDK_DIR}/config
- ${SDK_DIR}/include
- ${SDK_DIR}/hal/include
- ${SDK_DIR}/hal/utils/include
- ${SDK_DIR}/hpl/pm
- ${SDK_DIR}/hpl/port
- ${SDK_DIR}/hri
- ${SDK_DIR}/CMSIS/Include
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
)
- target_compile_definitions(${BOARD_TARGET} PUBLIC CONF_DFLL_OVERWRITE_CALIBRATION=0)
-
- update_board(${BOARD_TARGET})
-
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- message(FATAL_ERROR "LD_FILE_${CMAKE_C_COMPILER_ID} not defined")
- endif ()
-
- if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
- set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_samd21.c)
- endif ()
-
- target_sources(${BOARD_TARGET} PRIVATE
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
)
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endif ()
endfunction()
@@ -101,6 +106,7 @@ function(family_configure_example TARGET RTOS)
target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb)
# Flashing
+ family_add_bin_hex(${TARGET})
family_flash_jlink(${TARGET})
#family_flash_openocd(${TARGET} ${OPENOCD_OPTION})
endfunction()
diff --git a/hw/bsp/samd21/family.mk b/hw/bsp/samd21/family.mk
index 3302aade5..aabcff4a2 100644
--- a/hw/bsp/samd21/family.mk
+++ b/hw/bsp/samd21/family.mk
@@ -6,7 +6,6 @@ CPU_CORE ?= cortex-m0plus
CFLAGS += \
-flto \
- -nostdlib -nostartfiles \
-DCONF_DFLL_OVERWRITE_CALIBRATION=0 \
-DCFG_TUSB_MCU=OPT_MCU_SAMD21
@@ -16,7 +15,11 @@ CFLAGS += -Wno-error=redundant-decls
# SAM driver is flooded with -Wcast-qual which slow down complication significantly
CFLAGS_SKIP += -Wcast-qual
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += \
+ -nostdlib -nostartfiles \
+ --specs=nosys.specs --specs=nano.specs \
+
+LDFLAGS_CLANG +=
SRC_C += \
src/portable/microchip/samd/dcd_samd.c \
diff --git a/hw/bsp/samd51/boards/feather_m4_express/feather_m4_express.ld b/hw/bsp/samd51/boards/feather_m4_express/feather_m4_express.ld
index f1a021d75..1408c3018 100644
--- a/hw/bsp/samd51/boards/feather_m4_express/feather_m4_express.ld
+++ b/hw/bsp/samd51/boards/feather_m4_express/feather_m4_express.ld
@@ -42,7 +42,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd51/boards/itsybitsy_m4/itsybitsy_m4.ld b/hw/bsp/samd51/boards/itsybitsy_m4/itsybitsy_m4.ld
index f1a021d75..1408c3018 100644
--- a/hw/bsp/samd51/boards/itsybitsy_m4/itsybitsy_m4.ld
+++ b/hw/bsp/samd51/boards/itsybitsy_m4/itsybitsy_m4.ld
@@ -42,7 +42,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd51/boards/metro_m4_express/metro_m4_express.ld b/hw/bsp/samd51/boards/metro_m4_express/metro_m4_express.ld
index f1a021d75..1408c3018 100644
--- a/hw/bsp/samd51/boards/metro_m4_express/metro_m4_express.ld
+++ b/hw/bsp/samd51/boards/metro_m4_express/metro_m4_express.ld
@@ -42,7 +42,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd51/boards/pybadge/pybadge.ld b/hw/bsp/samd51/boards/pybadge/pybadge.ld
index f1a021d75..1408c3018 100644
--- a/hw/bsp/samd51/boards/pybadge/pybadge.ld
+++ b/hw/bsp/samd51/boards/pybadge/pybadge.ld
@@ -42,7 +42,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd51/boards/pyportal/pyportal.ld b/hw/bsp/samd51/boards/pyportal/pyportal.ld
index f1a021d75..1408c3018 100644
--- a/hw/bsp/samd51/boards/pyportal/pyportal.ld
+++ b/hw/bsp/samd51/boards/pyportal/pyportal.ld
@@ -42,7 +42,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0xC000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/samd51/family.c b/hw/bsp/samd51/family.c
index 170c88191..d56d9f695 100644
--- a/hw/bsp/samd51/family.c
+++ b/hw/bsp/samd51/family.c
@@ -388,3 +388,8 @@ bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const* tx_buf, uint8_t* rx
}
#endif
+
+void HardFault_Handler(void) {
+ __BKPT(0);
+ while (1);
+}
diff --git a/hw/bsp/samd51/family.cmake b/hw/bsp/samd51/family.cmake
index 4d91bf1a6..3ddd2e290 100644
--- a/hw/bsp/samd51/family.cmake
+++ b/hw/bsp/samd51/family.cmake
@@ -1,6 +1,7 @@
include_guard()
set(SDK_DIR ${TOP}/hw/mcu/microchip/samd51)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
# include board specific
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
@@ -17,51 +18,56 @@ set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -c \"transport select swd\" -c \"
#------------------------------------
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
- if (NOT TARGET ${BOARD_TARGET})
- add_library(${BOARD_TARGET} STATIC
- ${SDK_DIR}/gcc/system_samd51.c
- ${SDK_DIR}/hpl/gclk/hpl_gclk.c
- ${SDK_DIR}/hpl/mclk/hpl_mclk.c
- ${SDK_DIR}/hpl/osc32kctrl/hpl_osc32kctrl.c
- ${SDK_DIR}/hpl/oscctrl/hpl_oscctrl.c
- ${SDK_DIR}/hal/src/hal_atomic.c
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif ()
+
+ set(LD_FILE_Clang ${LD_FILE_GNU})
+ if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
+ message(FATAL_ERROR "LD_FILE_${CMAKE_C_COMPILER_ID} not defined")
+ endif ()
+
+ if (NOT DEFINED STARTUP_FILE_GNU)
+ set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_samd51.c)
+ endif ()
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+ add_library(${BOARD_TARGET} STATIC
+ ${SDK_DIR}/gcc/system_samd51.c
+ ${SDK_DIR}/hpl/gclk/hpl_gclk.c
+ ${SDK_DIR}/hpl/mclk/hpl_mclk.c
+ ${SDK_DIR}/hpl/osc32kctrl/hpl_osc32kctrl.c
+ ${SDK_DIR}/hpl/oscctrl/hpl_oscctrl.c
+ ${SDK_DIR}/hal/src/hal_atomic.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}/
+ ${SDK_DIR}/config
+ ${SDK_DIR}/include
+ ${SDK_DIR}/hal/include
+ ${SDK_DIR}/hal/utils/include
+ ${SDK_DIR}/hpl/port
+ ${SDK_DIR}/hri
+ ${CMSIS_5}/CMSIS/Core/Include
+ )
+
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
)
- target_include_directories(${BOARD_TARGET} PUBLIC
- ${SDK_DIR}/
- ${SDK_DIR}/config
- ${SDK_DIR}/include
- ${SDK_DIR}/hal/include
- ${SDK_DIR}/hal/utils/include
- ${SDK_DIR}/hpl/port
- ${SDK_DIR}/hri
- ${SDK_DIR}/CMSIS/Include
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
)
-
- update_board(${BOARD_TARGET})
-
- if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
- message(FATAL_ERROR "LD_FILE_${CMAKE_C_COMPILER_ID} not defined")
- endif ()
-
- if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
- set(STARTUP_FILE_GNU ${SDK_DIR}/gcc/gcc/startup_samd51.c)
- endif ()
-
- target_sources(${BOARD_TARGET} PRIVATE
- ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--config=${LD_FILE_IAR}"
)
-
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--script=${LD_FILE_GNU}"
- -nostartfiles
- --specs=nosys.specs --specs=nano.specs
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
- target_link_options(${BOARD_TARGET} PUBLIC
- "LINKER:--config=${LD_FILE_IAR}"
- )
- endif ()
endif ()
endfunction()
diff --git a/hw/bsp/samd51/family.mk b/hw/bsp/samd51/family.mk
index 94ca68705..7b90efad0 100644
--- a/hw/bsp/samd51/family.mk
+++ b/hw/bsp/samd51/family.mk
@@ -6,13 +6,14 @@ CPU_CORE ?= cortex-m4
CFLAGS += \
-flto \
- -nostdlib -nostartfiles \
-DCFG_TUSB_MCU=OPT_MCU_SAMD51
# SAM driver is flooded with -Wcast-qual which slow down complication significantly
CFLAGS_SKIP += -Wcast-qual
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += \
+ -nostdlib -nostartfiles \
+ --specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/microchip/samd/dcd_samd.c \
@@ -33,7 +34,7 @@ INC += \
$(TOP)/hw/mcu/microchip/samd51/hal/utils/include \
$(TOP)/hw/mcu/microchip/samd51/hpl/port \
$(TOP)/hw/mcu/microchip/samd51/hri \
- $(TOP)/hw/mcu/microchip/samd51/CMSIS/Include
+ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
# flash using bossac at least version 1.8
# can be found in arduino15/packages/arduino/tools/bossac/
diff --git a/hw/bsp/same5x/boards/d5035_01/same51j19a_flash.ld b/hw/bsp/same5x/boards/d5035_01/same51j19a_flash.ld
index a8dd44336..486043f22 100644
--- a/hw/bsp/same5x/boards/d5035_01/same51j19a_flash.ld
+++ b/hw/bsp/same5x/boards/d5035_01/same51j19a_flash.ld
@@ -42,7 +42,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x1000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x1000;
/* Section Definitions */
SECTIONS
diff --git a/hw/bsp/same5x/boards/same54_xplained/same54p20a_flash.ld b/hw/bsp/same5x/boards/same54_xplained/same54p20a_flash.ld
index 1f427a066..7a7f1be46 100644
--- a/hw/bsp/same5x/boards/same54_xplained/same54p20a_flash.ld
+++ b/hw/bsp/same5x/boards/same54_xplained/same54p20a_flash.ld
@@ -42,7 +42,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x10000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x10000;
/* Section Definitions */
SECTIONS
diff --git a/hw/bsp/same5x/boards/same54_xplained/same54p20a_sram.ld b/hw/bsp/same5x/boards/same54_xplained/same54p20a_sram.ld
index e6e33ec48..c768f9c9a 100644
--- a/hw/bsp/same5x/boards/same54_xplained/same54p20a_sram.ld
+++ b/hw/bsp/same5x/boards/same54_xplained/same54p20a_sram.ld
@@ -41,7 +41,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x10000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x10000;
/* Section Definitions */
SECTIONS
diff --git a/hw/bsp/samg55xplained/samg55j19_flash.ld b/hw/bsp/samg55xplained/samg55j19_flash.ld
index 21c0b5bcd..a222b919b 100644
--- a/hw/bsp/samg55xplained/samg55j19_flash.ld
+++ b/hw/bsp/samg55xplained/samg55j19_flash.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
/* The heapsize used by the application. NOTE: you need to adjust according to your application. */
HEAP_SIZE = DEFINED(HEAP_SIZE) ? HEAP_SIZE : DEFINED(__heap_size__) ? __heap_size__ : 0x0200;
diff --git a/hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld b/hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld
index 7f6b7fa99..48cacd526 100644
--- a/hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld
+++ b/hw/bsp/saml2x/boards/atsaml21_xpro/saml21j18b_flash.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
/* Section Definitions */
SECTIONS
diff --git a/hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld b/hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld
index 156c3e7e4..372107ff8 100644
--- a/hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld
+++ b/hw/bsp/saml2x/boards/saml22_feather/saml22_feather.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld b/hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld
index 156c3e7e4..372107ff8 100644
--- a/hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld
+++ b/hw/bsp/saml2x/boards/sensorwatch_m0/sensorwatch_m0.ld
@@ -40,7 +40,7 @@ MEMORY
}
/* The stack size used by the application. NOTE: you need to adjust according to your application. */
-STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
ENTRY(Reset_Handler)
diff --git a/hw/bsp/stm32f0/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/stm32f0/FreeRTOSConfig/FreeRTOSConfig.h
index b9a54b9b3..37e7e0943 100644
--- a/hw/bsp/stm32f0/FreeRTOSConfig/FreeRTOSConfig.h
+++ b/hw/bsp/stm32f0/FreeRTOSConfig/FreeRTOSConfig.h
@@ -49,7 +49,7 @@
/* Cortex M23/M33 port configuration. */
#define configENABLE_MPU 0
-#define configENABLE_FPU 1
+#define configENABLE_FPU 0
#define configENABLE_TRUSTZONE 0
#define configMINIMAL_SECURE_STACK_SIZE (1024)
diff --git a/hw/bsp/stm32f0/boards/stm32f072eval/STM32F072VBTx_FLASH.ld b/hw/bsp/stm32f0/boards/stm32f072eval/STM32F072VBTx_FLASH.ld
index 581613a5f..0eaf15186 100644
--- a/hw/bsp/stm32f0/boards/stm32f072eval/STM32F072VBTx_FLASH.ld
+++ b/hw/bsp/stm32f0/boards/stm32f072eval/STM32F072VBTx_FLASH.ld
@@ -27,12 +27,6 @@
/* Entry Point */
ENTRY(Reset_Handler)
-/* Highest address of the user mode stack */
-_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
-
-_Min_Heap_Size = 0x200 ; /* required amount of heap */
-_Min_Stack_Size = 0x400 ; /* required amount of stack */
-
/* Memories definition */
MEMORY
{
@@ -40,6 +34,12 @@ MEMORY
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
}
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
/* Sections */
SECTIONS
{
diff --git a/hw/bsp/stm32f0/family.cmake b/hw/bsp/stm32f0/family.cmake
index 89c93c47a..427c56671 100644
--- a/hw/bsp/stm32f0/family.cmake
+++ b/hw/bsp/stm32f0/family.cmake
@@ -1,9 +1,5 @@
include_guard()
-if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
-endif ()
-
set(ST_FAMILY f0)
set(ST_PREFIX stm32${ST_FAMILY}xx)
@@ -29,7 +25,10 @@ function(add_board_target BOARD_TARGET)
if (NOT TARGET ${BOARD_TARGET})
# Startup & Linker script
set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+
+ set(LD_FILE_Clang ${LD_FILE_GNU})
set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
add_library(${BOARD_TARGET} STATIC
@@ -49,8 +48,7 @@ function(add_board_target BOARD_TARGET)
${ST_CMSIS}/Include
${ST_HAL_DRIVER}/Inc
)
- target_compile_options(${BOARD_TARGET} PUBLIC
- )
+ #target_compile_options(${BOARD_TARGET} PUBLIC)
target_compile_definitions(${BOARD_TARGET} PUBLIC
CFG_EXAMPLE_MSC_READONLY
)
@@ -61,9 +59,11 @@ function(add_board_target BOARD_TARGET)
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
-nostartfiles
- # nanolib
- --specs=nosys.specs
- --specs=nano.specs
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
@@ -109,5 +109,5 @@ function(family_configure_example TARGET RTOS)
# Flashing
family_flash_stlink(${TARGET})
- #family_flash_jlink(${TARGET})
+ family_flash_jlink(${TARGET})
endfunction()
diff --git a/hw/bsp/stm32f0/family.mk b/hw/bsp/stm32f0/family.mk
index 537df4d7b..431709de0 100644
--- a/hw/bsp/stm32f0/family.mk
+++ b/hw/bsp/stm32f0/family.mk
@@ -18,12 +18,13 @@ CFLAGS += \
# GCC Flags
CFLAGS_GCC += \
-flto \
- -nostdlib -nostartfiles \
# suppress warning caused by vendor mcu driver
CFLAGS_GCC += -Wno-error=unused-parameter -Wno-error=cast-align
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += \
+ -nostdlib -nostartfiles \
+ --specs=nosys.specs --specs=nano.specs
# ------------------------
# All source paths should be relative to the top level.
diff --git a/hw/bsp/stm32f1/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/stm32f1/FreeRTOSConfig/FreeRTOSConfig.h
index d001411d9..c08a590a7 100644
--- a/hw/bsp/stm32f1/FreeRTOSConfig/FreeRTOSConfig.h
+++ b/hw/bsp/stm32f1/FreeRTOSConfig/FreeRTOSConfig.h
@@ -49,7 +49,7 @@
/* Cortex M23/M33 port configuration. */
#define configENABLE_MPU 0
-#define configENABLE_FPU 1
+#define configENABLE_FPU 0
#define configENABLE_TRUSTZONE 0
#define configMINIMAL_SECURE_STACK_SIZE (1024)
diff --git a/hw/bsp/stm32f1/family.cmake b/hw/bsp/stm32f1/family.cmake
index 6657c85ce..cf7e8e9b1 100644
--- a/hw/bsp/stm32f1/family.cmake
+++ b/hw/bsp/stm32f1/family.cmake
@@ -1,9 +1,5 @@
include_guard()
-if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
-endif ()
-
set(ST_FAMILY f1)
set(ST_PREFIX stm32${ST_FAMILY}xx)
@@ -29,8 +25,14 @@ function(add_board_target BOARD_TARGET)
if (NOT TARGET ${BOARD_TARGET})
# Startup & Linker script
set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+ set(LD_FILE_Clang ${LD_FILE_GNU})
+ if (NOT DEFINED LD_FILE_IAR)
+ set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
+ endif ()
+
add_library(${BOARD_TARGET} STATIC
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
@@ -47,10 +49,8 @@ function(add_board_target BOARD_TARGET)
${ST_CMSIS}/Include
${ST_HAL_DRIVER}/Inc
)
- target_compile_options(${BOARD_TARGET} PUBLIC
- )
- target_compile_definitions(${BOARD_TARGET} PUBLIC
- )
+ #target_compile_options(${BOARD_TARGET} PUBLIC)
+ #target_compile_definitions(${BOARD_TARGET} PUBLIC)
update_board(${BOARD_TARGET})
@@ -58,9 +58,11 @@ function(add_board_target BOARD_TARGET)
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--script=${LD_FILE_GNU}"
-nostartfiles
- # nanolib
- --specs=nosys.specs
- --specs=nano.specs
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
)
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
@@ -106,5 +108,5 @@ function(family_configure_example TARGET RTOS)
# Flashing
family_flash_stlink(${TARGET})
- #family_flash_jlink(${TARGET})
+ family_flash_jlink(${TARGET})
endfunction()
diff --git a/hw/bsp/stm32f1/family.mk b/hw/bsp/stm32f1/family.mk
index 8a5625551..03fbf4010 100644
--- a/hw/bsp/stm32f1/family.mk
+++ b/hw/bsp/stm32f1/family.mk
@@ -16,12 +16,13 @@ CFLAGS += \
# GCC Flags
CFLAGS_GCC += \
-flto \
- -nostdlib -nostartfiles \
# mcu driver cause following warnings
CFLAGS_GCC += -Wno-error=cast-align
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += \
+ -nostdlib -nostartfiles \
+ -specs=nosys.specs -specs=nano.specs
# ------------------------
# All source paths should be relative to the top level.
diff --git a/hw/bsp/stm32f2/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/stm32f2/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..edbdba4b5
--- /dev/null
+++ b/hw/bsp/stm32f2/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,149 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "stm32f2xx.h"
+#endif
+
+/* Cortex M23/M33 port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 0
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+#define configPRIO_BITS 4
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32h5/linker/STM32H523xx_FLASH.ld b/hw/bsp/stm32h5/linker/STM32H523xx_FLASH.ld
new file mode 100644
index 000000000..b799892c6
--- /dev/null
+++ b/hw/bsp/stm32h5/linker/STM32H523xx_FLASH.ld
@@ -0,0 +1,187 @@
+/*
+ ******************************************************************************
+ **
+ ** @file : LinkerScript.ld
+ **
+ ** @author : Auto-generated by STM32CubeIDE
+ **
+ ** @brief : Linker script for STM32H523xx Device from STM32H5 series
+ ** 512Kbytes FLASH
+ ** 272Kbytes RAM
+ **
+ ** Set heap size, stack size and stack location according
+ ** to application requirements.
+ **
+ ** Set memory bank area and size if external memory is used
+ **
+ ** Target : STMicroelectronics STM32
+ **
+ ** Distribution: The file is distributed as is, without any warranty
+ ** of any kind.
+ **
+ ******************************************************************************
+ ** @attention
+ **
+ ** Copyright (c) 2023 STMicroelectronics.
+ ** All rights reserved.
+ **
+ ** This software is licensed under terms that can be found in the LICENSE file
+ ** in the root directory of this software component.
+ ** If no LICENSE file comes with this software, it is provided AS-IS.
+ **
+ ******************************************************************************
+ */
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 272K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32h5/linker/STM32H533xx_FLASH.ld b/hw/bsp/stm32h5/linker/STM32H533xx_FLASH.ld
new file mode 100644
index 000000000..dece7a003
--- /dev/null
+++ b/hw/bsp/stm32h5/linker/STM32H533xx_FLASH.ld
@@ -0,0 +1,187 @@
+/*
+ ******************************************************************************
+ **
+ ** @file : LinkerScript.ld
+ **
+ ** @author : Auto-generated by STM32CubeIDE
+ **
+ ** @brief : Linker script for STM32H533xx Device from STM32H5 series
+ ** 512Kbytes FLASH
+ ** 272Kbytes RAM
+ **
+ ** Set heap size, stack size and stack location according
+ ** to application requirements.
+ **
+ ** Set memory bank area and size if external memory is used
+ **
+ ** Target : STMicroelectronics STM32
+ **
+ ** Distribution: The file is distributed as is, without any warranty
+ ** of any kind.
+ **
+ ******************************************************************************
+ ** @attention
+ **
+ ** Copyright (c) 2023 STMicroelectronics.
+ ** All rights reserved.
+ **
+ ** This software is licensed under terms that can be found in the LICENSE file
+ ** in the root directory of this software component.
+ ** If no LICENSE file comes with this software, it is provided AS-IS.
+ **
+ ******************************************************************************
+ */
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 272K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32h5/linker/STM32H562xx_FLASH.ld b/hw/bsp/stm32h5/linker/STM32H562xx_FLASH.ld
new file mode 100644
index 000000000..aee2774a4
--- /dev/null
+++ b/hw/bsp/stm32h5/linker/STM32H562xx_FLASH.ld
@@ -0,0 +1,187 @@
+/*
+ ******************************************************************************
+ **
+ ** @file : LinkerScript.ld
+ **
+ ** @author : Auto-generated by STM32CubeIDE
+ **
+ ** @brief : Linker script for STM32H562xx Device from STM32H5 series
+ ** 2048Kbytes FLASH
+ ** 640Kbytes RAM
+ **
+ ** Set heap size, stack size and stack location according
+ ** to application requirements.
+ **
+ ** Set memory bank area and size if external memory is used
+ **
+ ** Target : STMicroelectronics STM32
+ **
+ ** Distribution: The file is distributed as is, without any warranty
+ ** of any kind.
+ **
+ ******************************************************************************
+ ** @attention
+ **
+ ** Copyright (c) 2023 STMicroelectronics.
+ ** All rights reserved.
+ **
+ ** This software is licensed under terms that can be found in the LICENSE file
+ ** in the root directory of this software component.
+ ** If no LICENSE file comes with this software, it is provided AS-IS.
+ **
+ ******************************************************************************
+ */
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32h5/linker/STM32H563xx_FLASH.ld b/hw/bsp/stm32h5/linker/STM32H563xx_FLASH.ld
new file mode 100644
index 000000000..129ed5170
--- /dev/null
+++ b/hw/bsp/stm32h5/linker/STM32H563xx_FLASH.ld
@@ -0,0 +1,187 @@
+/*
+ ******************************************************************************
+ **
+ ** @file : LinkerScript.ld
+ **
+ ** @author : Auto-generated by STM32CubeIDE
+ **
+ ** @brief : Linker script for STM32H563xx Device from STM32H5 series
+ ** 2048Kbytes FLASH
+ ** 640Kbytes RAM
+ **
+ ** Set heap size, stack size and stack location according
+ ** to application requirements.
+ **
+ ** Set memory bank area and size if external memory is used
+ **
+ ** Target : STMicroelectronics STM32
+ **
+ ** Distribution: The file is distributed as is, without any warranty
+ ** of any kind.
+ **
+ ******************************************************************************
+ ** @attention
+ **
+ ** Copyright (c) 2023 STMicroelectronics.
+ ** All rights reserved.
+ **
+ ** This software is licensed under terms that can be found in the LICENSE file
+ ** in the root directory of this software component.
+ ** If no LICENSE file comes with this software, it is provided AS-IS.
+ **
+ ******************************************************************************
+ */
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32h5/linker/STM32H573xx_FLASH.ld b/hw/bsp/stm32h5/linker/STM32H573xx_FLASH.ld
new file mode 100644
index 000000000..eb98f3163
--- /dev/null
+++ b/hw/bsp/stm32h5/linker/STM32H573xx_FLASH.ld
@@ -0,0 +1,187 @@
+/*
+ ******************************************************************************
+ **
+ ** @file : LinkerScript.ld
+ **
+ ** @author : Auto-generated by STM32CubeIDE
+ **
+ ** @brief : Linker script for STM32H573xx Device from STM32H5 series
+ ** 2048Kbytes FLASH
+ ** 640Kbytes RAM
+ **
+ ** Set heap size, stack size and stack location according
+ ** to application requirements.
+ **
+ ** Set memory bank area and size if external memory is used
+ **
+ ** Target : STMicroelectronics STM32
+ **
+ ** Distribution: The file is distributed as is, without any warranty
+ ** of any kind.
+ **
+ ******************************************************************************
+ ** @attention
+ **
+ ** Copyright (c) 2023 STMicroelectronics.
+ ** All rights reserved.
+ **
+ ** This software is licensed under terms that can be found in the LICENSE file
+ ** in the root directory of this software component.
+ ** If no LICENSE file comes with this software, it is provided AS-IS.
+ **
+ ******************************************************************************
+ */
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K
+ FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(4);
+ } >FLASH
+
+ .preinit_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .init_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ .fini_array : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
+ {
+ . = ALIGN(4);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(4);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32h7/boards/daisyseed/stm32h750ibkx_flash.ld b/hw/bsp/stm32h7/boards/daisyseed/stm32h750ibkx_flash.ld
index 3588ada5b..e2bde9338 100644
--- a/hw/bsp/stm32h7/boards/daisyseed/stm32h750ibkx_flash.ld
+++ b/hw/bsp/stm32h7/boards/daisyseed/stm32h750ibkx_flash.ld
@@ -34,12 +34,6 @@
/* Entry Point */
ENTRY(Reset_Handler)
-/* Highest address of the user mode stack */
-_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of RAM */
-/* Generate a link error if heap and stack don't fit into RAM */
-_Min_Heap_Size = 0x2000 ; /* required amount of heap */
-_Min_Stack_Size = 0x4000 ; /* required amount of stack */
-
/* Specify the memory areas */
MEMORY
{
@@ -51,6 +45,12 @@ MEMORY
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
}
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x2000 ; /* required amount of heap */
+_Min_Stack_Size = 0x4000 ; /* required amount of stack */
+
/* Define output sections */
SECTIONS
{
diff --git a/hw/bsp/stm32h7/boards/daisyseed/stm32h750ibkx_ram.ld b/hw/bsp/stm32h7/boards/daisyseed/stm32h750ibkx_ram.ld
index 16f48b10a..03d9aaba3 100644
--- a/hw/bsp/stm32h7/boards/daisyseed/stm32h750ibkx_ram.ld
+++ b/hw/bsp/stm32h7/boards/daisyseed/stm32h750ibkx_ram.ld
@@ -34,12 +34,6 @@
/* Entry Point */
ENTRY(Reset_Handler)
-/* Highest address of the user mode stack */
-_estack = ORIGIN(DTCMRAM) + LENGTH(DTCMRAM); /* end of RAM */
-/* Generate a link error if heap and stack don't fit into RAM */
-_Min_Heap_Size = 0x2000 ; /* required amount of heap */
-_Min_Stack_Size = 0x4000 ; /* required amount of stack */
-
/* Specify the memory areas */
MEMORY
{
@@ -50,6 +44,12 @@ MEMORY
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
}
+/* Highest address of the user mode stack */
+_estack = ORIGIN(DTCMRAM) + LENGTH(DTCMRAM); /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x2000 ; /* required amount of heap */
+_Min_Stack_Size = 0x4000 ; /* required amount of stack */
+
/* Define output sections */
SECTIONS
{
diff --git a/hw/bsp/stm32h7/family.cmake b/hw/bsp/stm32h7/family.cmake
index 6174dfda3..e5ae6c69d 100644
--- a/hw/bsp/stm32h7/family.cmake
+++ b/hw/bsp/stm32h7/family.cmake
@@ -1,9 +1,5 @@
include_guard()
-if (NOT BOARD)
- message(FATAL_ERROR "BOARD not specified")
-endif ()
-
set(ST_FAMILY h7)
set(ST_PREFIX stm32${ST_FAMILY}xx)
@@ -29,8 +25,10 @@ function(add_board_target BOARD_TARGET)
if (NOT TARGET ${BOARD_TARGET})
# Startup & Linker script
set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
+ set(LD_FILE_Clang ${LD_FILE_GNU})
if(NOT DEFINED LD_FILE_IAR)
set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
endif()
@@ -55,10 +53,8 @@ function(add_board_target BOARD_TARGET)
${ST_CMSIS}/Include
${ST_HAL_DRIVER}/Inc
)
- target_compile_options(${BOARD_TARGET} PUBLIC
- )
- target_compile_definitions(${BOARD_TARGET} PUBLIC
- )
+ #target_compile_options(${BOARD_TARGET} PUBLIC)
+ #target_compile_definitions(${BOARD_TARGET} PUBLIC)
update_board(${BOARD_TARGET})
@@ -68,6 +64,10 @@ function(add_board_target BOARD_TARGET)
-nostartfiles
--specs=nosys.specs --specs=nano.specs
)
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
target_link_options(${BOARD_TARGET} PUBLIC
"LINKER:--config=${LD_FILE_IAR}"
diff --git a/hw/bsp/stm32h7/family.mk b/hw/bsp/stm32h7/family.mk
index 0777bb9c2..40df190db 100644
--- a/hw/bsp/stm32h7/family.mk
+++ b/hw/bsp/stm32h7/family.mk
@@ -30,12 +30,15 @@ endif
# GCC Flags
CFLAGS_GCC += \
-flto \
- -nostdlib -nostartfiles
# suppress warning caused by vendor mcu driver
-CFLAGS_GCC += -Wno-error=maybe-uninitialized -Wno-error=cast-align -Wno-error=unused-parameter
+CFLAGS_GCC += \
+ -Wno-error=cast-align \
+ -Wno-error=unused-parameter \
-LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
+LDFLAGS_GCC += \
+ -nostdlib -nostartfiles \
+ --specs=nosys.specs --specs=nano.specs
# -----------------
# Sources & Include
diff --git a/hw/bsp/stm32h7/linker/stm32h723xx_flash.ld b/hw/bsp/stm32h7/linker/stm32h723xx_flash.ld
index 05e0d4e26..b779c0d35 100644
--- a/hw/bsp/stm32h7/linker/stm32h723xx_flash.ld
+++ b/hw/bsp/stm32h7/linker/stm32h723xx_flash.ld
@@ -34,12 +34,6 @@
/* Entry Point */
ENTRY(Reset_Handler)
-/* Highest address of the user mode stack */
-_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of RAM */
-/* Generate a link error if heap and stack don't fit into RAM */
-_Min_Heap_Size = 0x200 ; /* required amount of heap */
-_Min_Stack_Size = 0x400 ; /* required amount of stack */
-
/* Specify the memory areas */
MEMORY
{
@@ -51,6 +45,12 @@ MEMORY
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K
}
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
/* Define output sections */
SECTIONS
{
diff --git a/hw/bsp/stm32l0/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/stm32l0/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..37e7e0943
--- /dev/null
+++ b/hw/bsp/stm32l0/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,149 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "stm32f0xx.h"
+#endif
+
+/* Cortex M23/M33 port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 0
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+#define configPRIO_BITS 2
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ } >FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } >FLASH
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32u5/linker/STM32U545xx_FLASH.ld b/hw/bsp/stm32u5/linker/STM32U545xx_FLASH.ld
new file mode 100644
index 000000000..ce370c643
--- /dev/null
+++ b/hw/bsp/stm32u5/linker/STM32U545xx_FLASH.ld
@@ -0,0 +1,167 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : STM32CubeIDE
+**
+** Abstract : Linker script for STM32U545xE Device from STM32U5 series
+** 512Kbytes FLASH
+** 272Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** Copyright (c) 2022 STMicroelectronics.
+** All rights reserved.
+**
+** This software is licensed under terms that can be found in the LICENSE file
+** in the root directory of this software component.
+** If no LICENSE file comes with this software, it is provided AS-IS.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
+ SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ KEEP(*(.isr_vector)) /* Startup code */
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ } >FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } >FLASH
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32u5/linker/STM32U575xx_FLASH.ld b/hw/bsp/stm32u5/linker/STM32U575xx_FLASH.ld
new file mode 100644
index 000000000..b24c533de
--- /dev/null
+++ b/hw/bsp/stm32u5/linker/STM32U575xx_FLASH.ld
@@ -0,0 +1,185 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : Auto-generated by STM32CubeIDE
+**
+** Abstract : Linker script for STM32U575xx Device from STM32U5 series
+** 2048Kbytes ROM
+** 784Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** © Copyright (c) 2021 STMicroelectronics.
+** All rights reserved.
+**
+** This software component is licensed by ST under BSD 3-Clause license,
+** the "License"; You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at:
+** opensource.org/licenses/BSD-3-Clause
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 768K
+ ROM (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
+ SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "ROM" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(8);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(8);
+ } >ROM
+
+ /* The program code and other data into "ROM" Rom type memory */
+ .text :
+ {
+ . = ALIGN(8);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(8);
+ _etext = .; /* define a global symbols at end of code */
+ } >ROM
+
+ /* Constant data into "ROM" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(8);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(8);
+ } >ROM
+
+ .ARM.extab : {
+ . = ALIGN(8);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(8);
+ } >ROM
+
+ .ARM : {
+ . = ALIGN(8);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(8);
+ } >ROM
+
+ .preinit_array :
+ {
+ . = ALIGN(8);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(8);
+ } >ROM
+
+ .init_array :
+ {
+ . = ALIGN(8);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(8);
+ } >ROM
+
+ .fini_array :
+ {
+ . = ALIGN(8);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(8);
+ } >ROM
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(8);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(8);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> ROM
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(8);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(8);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32u5/linker/STM32U585xx_FLASH.ld b/hw/bsp/stm32u5/linker/STM32U585xx_FLASH.ld
new file mode 100644
index 000000000..15b8054bc
--- /dev/null
+++ b/hw/bsp/stm32u5/linker/STM32U585xx_FLASH.ld
@@ -0,0 +1,185 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : Auto-generated by STM32CubeIDE
+**
+** Abstract : Linker script for STM32U585xx Device from STM32U5 series
+** 2048Kbytes ROM
+** 784Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** © Copyright (c) 2021 STMicroelectronics.
+** All rights reserved.
+**
+** This software component is licensed by ST under BSD 3-Clause license,
+** the "License"; You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at:
+** opensource.org/licenses/BSD-3-Clause
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 768K
+ ROM (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
+ SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "ROM" Rom type memory */
+ .isr_vector :
+ {
+ . = ALIGN(8);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(8);
+ } >ROM
+
+ /* The program code and other data into "ROM" Rom type memory */
+ .text :
+ {
+ . = ALIGN(8);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(8);
+ _etext = .; /* define a global symbols at end of code */
+ } >ROM
+
+ /* Constant data into "ROM" Rom type memory */
+ .rodata :
+ {
+ . = ALIGN(8);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(8);
+ } >ROM
+
+ .ARM.extab : {
+ . = ALIGN(8);
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ . = ALIGN(8);
+ } >ROM
+
+ .ARM : {
+ . = ALIGN(8);
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ . = ALIGN(8);
+ } >ROM
+
+ .preinit_array :
+ {
+ . = ALIGN(8);
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ . = ALIGN(8);
+ } >ROM
+
+ .init_array :
+ {
+ . = ALIGN(8);
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ . = ALIGN(8);
+ } >ROM
+
+ .fini_array :
+ {
+ . = ALIGN(8);
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ . = ALIGN(8);
+ } >ROM
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ . = ALIGN(8);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(8);
+ _edata = .; /* define a global symbol at data end */
+
+ } >RAM AT> ROM
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ . = ALIGN(8);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(8);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32u5/linker/STM32U595xx_FLASH.ld b/hw/bsp/stm32u5/linker/STM32U595xx_FLASH.ld
new file mode 100644
index 000000000..100ee14a5
--- /dev/null
+++ b/hw/bsp/stm32u5/linker/STM32U595xx_FLASH.ld
@@ -0,0 +1,168 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : STM32CubeIDE
+**
+** Abstract : Linker script for STM32U595xJ Device from STM32U5 series
+** 4096Kbytes FLASH
+** 2528Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** © Copyright (c) 2021 STMicroelectronics.
+** All rights reserved.
+**
+** This software component is licensed by ST under BSD 3-Clause license,
+** the "License"; You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at:
+** opensource.org/licenses/BSD-3-Clause
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 2496K
+ SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 4096K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ KEEP(*(.isr_vector)) /* Startup code */
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ } >FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } >FLASH
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32u5/linker/STM32U599xx_FLASH.ld b/hw/bsp/stm32u5/linker/STM32U599xx_FLASH.ld
new file mode 100644
index 000000000..55997bf40
--- /dev/null
+++ b/hw/bsp/stm32u5/linker/STM32U599xx_FLASH.ld
@@ -0,0 +1,168 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : STM32CubeIDE
+**
+** Abstract : Linker script for STM32U599xJ Device from STM32U5 series
+** 4096Kbytes FLASH
+** 2528Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** © Copyright (c) 2021 STMicroelectronics.
+** All rights reserved.
+**
+** This software component is licensed by ST under BSD 3-Clause license,
+** the "License"; You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at:
+** opensource.org/licenses/BSD-3-Clause
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 2496K
+ SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 4096K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ KEEP(*(.isr_vector)) /* Startup code */
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ } >FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } >FLASH
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32u5/linker/STM32U5A9xx_FLASH.ld b/hw/bsp/stm32u5/linker/STM32U5A9xx_FLASH.ld
new file mode 100644
index 000000000..a5f7d3405
--- /dev/null
+++ b/hw/bsp/stm32u5/linker/STM32U5A9xx_FLASH.ld
@@ -0,0 +1,168 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : STM32CubeIDE
+**
+** Abstract : Linker script for STM32U5A9xJ Device from STM32U5 series
+** 4096Kbytes FLASH
+** 2528Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** © Copyright (c) 2021 STMicroelectronics.
+** All rights reserved.
+**
+** This software component is licensed by ST under BSD 3-Clause license,
+** the "License"; You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at:
+** opensource.org/licenses/BSD-3-Clause
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 2496K
+ SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 4096K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ KEEP(*(.isr_vector)) /* Startup code */
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ } >FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } >FLASH
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32u5/linker/STM32U5F7xx_FLASH.ld b/hw/bsp/stm32u5/linker/STM32U5F7xx_FLASH.ld
new file mode 100644
index 000000000..bb9953440
--- /dev/null
+++ b/hw/bsp/stm32u5/linker/STM32U5F7xx_FLASH.ld
@@ -0,0 +1,168 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : STM32CubeIDE
+**
+** Abstract : Linker script for STM32U5F7xJ Device from STM32U5 series
+** 4096Kbytes FLASH
+** 2528Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** © Copyright (c) 2023 STMicroelectronics.
+** All rights reserved.
+**
+** This software component is licensed by ST under BSD 3-Clause license,
+** the "License"; You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at:
+** opensource.org/licenses/BSD-3-Clause
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 2496K
+ SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 4096K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ KEEP(*(.isr_vector)) /* Startup code */
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ } >FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } >FLASH
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32u5/linker/STM32U5F9xx_FLASH.ld b/hw/bsp/stm32u5/linker/STM32U5F9xx_FLASH.ld
new file mode 100644
index 000000000..d8f1f4c5f
--- /dev/null
+++ b/hw/bsp/stm32u5/linker/STM32U5F9xx_FLASH.ld
@@ -0,0 +1,168 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : STM32CubeIDE
+**
+** Abstract : Linker script for STM32U5F9xJ Device from STM32U5 series
+** 4096Kbytes FLASH
+** 2528Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** © Copyright (c) 2023 STMicroelectronics.
+** All rights reserved.
+**
+** This software component is licensed by ST under BSD 3-Clause license,
+** the "License"; You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at:
+** opensource.org/licenses/BSD-3-Clause
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 2496K
+ SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 4096K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ KEEP(*(.isr_vector)) /* Startup code */
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ } >FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } >FLASH
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32u5/linker/STM32U5G7xx_FLASH.ld b/hw/bsp/stm32u5/linker/STM32U5G7xx_FLASH.ld
new file mode 100644
index 000000000..d02d6ebf1
--- /dev/null
+++ b/hw/bsp/stm32u5/linker/STM32U5G7xx_FLASH.ld
@@ -0,0 +1,168 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : STM32CubeIDE
+**
+** Abstract : Linker script for STM32U5G7xJ Device from STM32U5 series
+** 4096Kbytes FLASH
+** 2528Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** © Copyright (c) 2023 STMicroelectronics.
+** All rights reserved.
+**
+** This software component is licensed by ST under BSD 3-Clause license,
+** the "License"; You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at:
+** opensource.org/licenses/BSD-3-Clause
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 2496K
+ SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 4096K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ KEEP(*(.isr_vector)) /* Startup code */
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ } >FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } >FLASH
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/hw/bsp/stm32u5/linker/STM32U5G9xx_FLASH.ld b/hw/bsp/stm32u5/linker/STM32U5G9xx_FLASH.ld
new file mode 100644
index 000000000..1b072fdd4
--- /dev/null
+++ b/hw/bsp/stm32u5/linker/STM32U5G9xx_FLASH.ld
@@ -0,0 +1,168 @@
+/*
+******************************************************************************
+**
+** File : LinkerScript.ld
+**
+** Author : STM32CubeIDE
+**
+** Abstract : Linker script for STM32U5G9xJ Device from STM32U5 series
+** 4096Kbytes FLASH
+** 2528Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed as is without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** © Copyright (c) 2023 STMicroelectronics.
+** All rights reserved.
+**
+** This software component is licensed by ST under BSD 3-Clause license,
+** the "License"; You may not use this file except in compliance with the
+** License. You may obtain a copy of the License at:
+** opensource.org/licenses/BSD-3-Clause
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Memories definition */
+MEMORY
+{
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 2496K
+ SRAM4 (xrw) : ORIGIN = 0x28000000, LENGTH = 16K
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 4096K
+}
+
+/* Highest address of the user mode stack */
+_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
+
+_Min_Heap_Size = 0x200 ; /* required amount of heap */
+_Min_Stack_Size = 0x400 ; /* required amount of stack */
+
+/* Sections */
+SECTIONS
+{
+ /* The startup code into "FLASH" Rom type memory */
+ .isr_vector :
+ {
+ KEEP(*(.isr_vector)) /* Startup code */
+ } >FLASH
+
+ /* The program code and other data into "FLASH" Rom type memory */
+ .text :
+ {
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data into "FLASH" Rom type memory */
+ .rodata :
+ {
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ } >FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } >FLASH
+
+ .ARM :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* Used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections into "RAM" Ram type memory */
+ .data :
+ {
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+ *(.RamFunc) /* .RamFunc sections */
+ *(.RamFunc*) /* .RamFunc* sections */
+
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+ /* Uninitialized data section into "RAM" Ram type memory */
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss section */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+ /* Remove information from the compiler libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
diff --git a/lib/embedded-cli/embedded_cli.h b/lib/embedded-cli/embedded_cli.h
index 33354cd84..91c96f3a1 100644
--- a/lib/embedded-cli/embedded_cli.h
+++ b/lib/embedded-cli/embedded_cli.h
@@ -743,7 +743,7 @@ EmbeddedCli *embeddedCliNew(EmbeddedCliConfig *config) {
bool allocated = false;
if (config->cliBuffer == NULL) {
- config->cliBuffer = (CLI_UINT *) malloc(totalSize); // malloc guarantees alignment.
+// config->cliBuffer = (CLI_UINT *) malloc(totalSize); // malloc guarantees alignment.
if (config->cliBuffer == NULL)
return NULL;
allocated = true;
@@ -887,7 +887,7 @@ void embeddedCliFree(EmbeddedCli *cli) {
PREPARE_IMPL(cli);
if (IS_FLAG_SET(impl->flags, CLI_FLAG_ALLOCATED)) {
// allocation is done in single call to malloc, so need only single free
- free(cli);
+// free(cli);
}
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 076e1e1eb..272962332 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -41,7 +41,7 @@ function(add_tinyusb TARGET)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../lib/networking
)
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(${TARGET} PRIVATE
-Wall
-Wextra
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c
index 7ef0530ec..2e0a0c30d 100644
--- a/src/class/cdc/cdc_device.c
+++ b/src/class/cdc/cdc_device.c
@@ -43,10 +43,7 @@
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
-enum
-{
- BULK_PACKET_SIZE = (TUD_OPT_HIGH_SPEED ? 512 : 64)
-};
+#define BULK_PACKET_SIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
typedef struct
{
@@ -176,9 +173,11 @@ uint32_t tud_cdc_n_write(uint8_t itf, void const* buffer, uint32_t bufsize)
uint16_t ret = tu_fifo_write_n(&p_cdc->tx_ff, buffer, (uint16_t) TU_MIN(bufsize, UINT16_MAX));
// flush if queue more than packet size
- // may need to suppress -Wunreachable-code since most of the time CFG_TUD_CDC_TX_BUFSIZE < BULK_PACKET_SIZE
- if ( (tu_fifo_count(&p_cdc->tx_ff) >= BULK_PACKET_SIZE) || ((CFG_TUD_CDC_TX_BUFSIZE < BULK_PACKET_SIZE) && tu_fifo_full(&p_cdc->tx_ff)) )
- {
+ if ( tu_fifo_count(&p_cdc->tx_ff) >= BULK_PACKET_SIZE
+ #if CFG_TUD_CDC_TX_BUFSIZE < BULK_PACKET_SIZE
+ || tu_fifo_full(&p_cdc->tx_ff) // check full if fifo size is less than packet size
+ #endif
+ ) {
tud_cdc_n_write_flush(itf);
}
diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c
index 5bdd41f1f..133a10f6e 100644
--- a/src/class/cdc/cdc_host.c
+++ b/src/class/cdc/cdc_host.c
@@ -1079,7 +1079,7 @@ static uint32_t ftdi_232bm_baud_to_divisor(uint32_t baud) {
static bool ftdi_sio_set_baudrate(cdch_interface_t* p_cdc, uint32_t baudrate, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
uint16_t const divisor = (uint16_t) ftdi_232bm_baud_to_divisor(baudrate);
- TU_LOG_DRV("CDC FTDI Set BaudRate = %lu, divisor = 0x%04x\r\n", baudrate, divisor);
+ TU_LOG_DRV("CDC FTDI Set BaudRate = %" PRIu32 ", divisor = 0x%04x\r\n", baudrate, divisor);
p_cdc->user_control_cb = complete_cb;
p_cdc->requested_line_coding.bit_rate = baudrate;
@@ -1222,7 +1222,7 @@ static bool cp210x_set_line_coding(cdch_interface_t* p_cdc, cdc_line_coding_t co
}
static bool cp210x_set_baudrate(cdch_interface_t* p_cdc, uint32_t baudrate, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
- TU_LOG_DRV("CDC CP210x Set BaudRate = %lu\r\n", baudrate);
+ TU_LOG_DRV("CDC CP210x Set BaudRate = %" PRIu32 "\r\n", baudrate);
uint32_t baud_le = tu_htole32(baudrate);
p_cdc->user_control_cb = complete_cb;
return cp210x_set_request(p_cdc, CP210X_SET_BAUDRATE, 0, (uint8_t *) &baud_le, 4,
diff --git a/src/class/usbtmc/usbtmc_device.c b/src/class/usbtmc/usbtmc_device.c
index 286cbe108..f6cddfbd7 100644
--- a/src/class/usbtmc/usbtmc_device.c
+++ b/src/class/usbtmc/usbtmc_device.c
@@ -360,7 +360,7 @@ uint16_t usbtmcd_open_cb(uint8_t rhport, tusb_desc_interface_t const * itf_desc,
// processing a command (such as a clear). Returns true if it was
// in the NAK state and successfully transitioned to the ACK wait
// state.
-bool tud_usbtmc_start_bus_read()
+bool tud_usbtmc_start_bus_read(void)
{
usbtmcd_state_enum oldState = usbtmc_state.state;
switch(oldState)
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 1f08ce4ed..0d4082c03 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -65,6 +65,7 @@
// Standard Headers
#include
#include
+#include
#include
#include
#include
diff --git a/src/host/usbh.c b/src/host/usbh.c
index f8fddf394..7a47f5056 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -704,7 +704,7 @@ static bool usbh_control_xfer_cb (uint8_t daddr, uint8_t ep_addr, xfer_result_t
tusb_control_request_t const * request = &_ctrl_xfer.request;
if (XFER_RESULT_SUCCESS != result) {
- TU_LOG_USBH("[%u:%u] Control %s, xferred_bytes = %lu\r\n", rhport, daddr, result == XFER_RESULT_STALLED ? "STALLED" : "FAILED", xferred_bytes);
+ TU_LOG_USBH("[%u:%u] Control %s, xferred_bytes = %" PRIu32 "\r\n", rhport, daddr, result == XFER_RESULT_STALLED ? "STALLED" : "FAILED", xferred_bytes);
TU_LOG_BUF_USBH(request, 8);
// terminate transfer if any stage failed
diff --git a/src/portable/ehci/ehci.c b/src/portable/ehci/ehci.c
index e145cbb1b..01bbf62bf 100644
--- a/src/portable/ehci/ehci.c
+++ b/src/portable/ehci/ehci.c
@@ -92,7 +92,7 @@ CFG_TUH_MEM_SECTION TU_ATTR_ALIGNED(4096) static ehci_data_t ehci_data;
//--------------------------------------------------------------------+
// Debug
//--------------------------------------------------------------------+
-#if CFG_TUSB_DEBUG >= (EHCI_DBG + 1)
+#if 0 && CFG_TUSB_DEBUG >= (EHCI_DBG + 1)
static inline void print_portsc(ehci_registers_t* regs) {
TU_LOG_HEX(EHCI_DBG, regs->portsc);
TU_LOG(EHCI_DBG, " Connect Status : %u\r\n", regs->portsc_bm.current_connect_status);
diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c
index 38d37bfc6..2fe721d6b 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -58,7 +58,8 @@
/* Try to detect nrfx version if not configured with CFG_TUD_NRF_NRFX_VERSION
* nrfx v1 and v2 are concurrently developed. There is no NRFX_VERSION only MDK VERSION which is as follows:
- * - v2.6.0: 8.44.1, v2.5.0: 8.40.2, v2.4.0: 8.37.0, v2.3.0: 8.35.0, v2.2.0: 8.32.1, v2.1.0: 8.30.2, v2.0.0: 8.29.0
+ * - v3.0.0: 8.53.1 (conflict with v2.11.0), v3.1.0: 8.55.0 ...
+ * - v2.11.0: 8.53.1, v2.6.0: 8.44.1, v2.5.0: 8.40.2, v2.4.0: 8.37.0, v2.3.0: 8.35.0, v2.2.0: 8.32.1, v2.1.0: 8.30.2, v2.0.0: 8.29.0
* - v1.9.0: 8.40.3, v1.8.6: 8.35.0 (conflict with v2.3.0), v1.8.5: 8.32.3, v1.8.4: 8.32.1 (conflict with v2.2.0),
* v1.8.2: 8.32.1 (conflict with v2.2.0), v1.8.1: 8.27.1
* Therefore the check for v1 would be:
@@ -118,7 +119,7 @@ static struct {
xfer_td_t xfer[EP_CBI_COUNT + 1][2];
// nRF can only carry one DMA at a time, this is used to guard the access to EasyDMA
- atomic_bool dma_running;
+ atomic_flag dma_running;
} _dcd;
/*------------------------------------------------------------------*/
@@ -146,7 +147,7 @@ static void start_dma(volatile uint32_t* reg_startep) {
static void edpt_dma_start(volatile uint32_t* reg_startep) {
if (atomic_flag_test_and_set(&_dcd.dma_running)) {
- usbd_defer_func((osal_task_func_t) edpt_dma_start, (void*) (uintptr_t) reg_startep, true);
+ usbd_defer_func((osal_task_func_t)(uintptr_t ) edpt_dma_start, (void*) (uintptr_t) reg_startep, true);
} else {
start_dma(reg_startep);
}
@@ -154,7 +155,6 @@ static void edpt_dma_start(volatile uint32_t* reg_startep) {
// DMA is complete
static void edpt_dma_end(void) {
- TU_ASSERT(_dcd.dma_running,);
atomic_flag_clear(&_dcd.dma_running);
}
@@ -617,7 +617,7 @@ void dcd_int_handler(uint8_t rhport) {
}
if (int_status & USBD_INTEN_USBEVENT_Msk) {
- TU_LOG(3, "EVENTCAUSE = 0x%04lX\r\n", NRF_USBD->EVENTCAUSE);
+ TU_LOG(3, "EVENTCAUSE = 0x%04" PRIX32 "\r\n", NRF_USBD->EVENTCAUSE);
enum {
EVT_CAUSE_MASK = USBD_EVENTCAUSE_SUSPEND_Msk | USBD_EVENTCAUSE_RESUME_Msk | USBD_EVENTCAUSE_USBWUALLOWED_Msk |
diff --git a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
index f4ed09d83..022904a3a 100644
--- a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
+++ b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
@@ -239,7 +239,7 @@ TU_ATTR_ALWAYS_INLINE static inline bool ep_is_iso(ep_cmd_sts_t* ep_cs, bool is_
return is_highspeed ? (ep_cs[0].cmd_sts.type && !ep_cs[0].cmd_sts.rf_tv) : ep_cs->cmd_sts.type;
}
-TU_ATTR_ALWAYS_INLINE static inline bool ep_is_bulk(ep_cmd_sts_t* ep_cs) {
+TU_ATTR_ALWAYS_INLINE TU_ATTR_UNUSED static inline bool ep_is_bulk(ep_cmd_sts_t* ep_cs) {
return (ep_cs[0].cmd_sts.type == 0) && (ep_cs[0].cmd_sts.rf_tv == 0);
}
diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c
index a824226c7..c2c09a1fc 100644
--- a/src/portable/synopsys/dwc2/dcd_dwc2.c
+++ b/src/portable/synopsys/dwc2/dcd_dwc2.c
@@ -174,7 +174,7 @@ static bool fifo_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t packet_size) {
// Check if free space is available
TU_ASSERT(_allocated_fifo_words_tx + fifo_size + dwc2->grxfsiz <= _dwc2_controller[rhport].ep_fifo_size / 4);
_allocated_fifo_words_tx += fifo_size;
- TU_LOG(DWC2_DEBUG, " Allocated %u bytes at offset %lu", fifo_size * 4,
+ TU_LOG(DWC2_DEBUG, " Allocated %u bytes at offset %" PRIu32, fifo_size * 4,
_dwc2_controller[rhport].ep_fifo_size - _allocated_fifo_words_tx * 4);
// DIEPTXF starts at FIFO #1.
@@ -419,9 +419,9 @@ void print_dwc2_info(dwc2_regs_t* dwc2) {
volatile uint32_t const* p = (volatile uint32_t const*) &dwc2->guid;
TU_LOG(DWC2_DEBUG, "guid, gsnpsid, ghwcfg1, ghwcfg2, ghwcfg3, ghwcfg4\r\n");
for (size_t i = 0; i < 5; i++) {
- TU_LOG(DWC2_DEBUG, "0x%08lX, ", p[i]);
+ TU_LOG(DWC2_DEBUG, "0x%08" PRIX32 ", ", p[i]);
}
- TU_LOG(DWC2_DEBUG, "0x%08lX\r\n", p[5]);
+ TU_LOG(DWC2_DEBUG, "0x%08" PRIX32 "\r\n", p[5]);
}
#endif
@@ -440,11 +440,15 @@ static void reset_core(dwc2_regs_t* dwc2) {
}
static bool phy_hs_supported(dwc2_regs_t* dwc2) {
- // note: esp32 incorrect report its hs_phy_type as utmi
+ (void) dwc2;
+
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
+ // note: esp32 incorrect report its hs_phy_type as utmi
+ return false;
+#elif !TUD_OPT_HIGH_SPEED
return false;
#else
- return TUD_OPT_HIGH_SPEED && dwc2->ghwcfg2_bm.hs_phy_type != HS_PHY_TYPE_NONE;
+ return dwc2->ghwcfg2_bm.hs_phy_type != HS_PHY_TYPE_NONE;
#endif
}
diff --git a/test/hil/hil_pi4.json b/test/hil/hil_pi4.json
index 17d9ff1fa..8aff81910 100644
--- a/test/hil/hil_pi4.json
+++ b/test/hil/hil_pi4.json
@@ -8,13 +8,13 @@
"flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\""
},
{
- "name": "espressif_s3_devkitc",
- "uid": "7CDFA1E073CC",
+ "name": "espressif_s3_devkitm",
+ "uid": "84F703C084E4",
"tests": [
"cdc_msc_freertos", "hid_composite_freertos"
],
"flasher": "esptool",
- "flasher_sn": "461cb8d7decdeb119be9b506e93fd3f1",
+ "flasher_sn": "3ea619acd1cdeb11a0a0b806e93fd3f1",
"flasher_args": "-b 1500000"
},
{
diff --git a/test/unit-test/project.yml b/test/unit-test/project.yml
index 82528f68c..7fbbabfe6 100644
--- a/test/unit-test/project.yml
+++ b/test/unit-test/project.yml
@@ -81,20 +81,20 @@
:tools:
:test_compiler:
- :executable: clang
- :name: 'clang compiler'
+ :executable: gcc
+ :name: 'gcc compiler'
:arguments:
- -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE #expands to -I search paths
- -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR #expands to -I search paths
- -D$: COLLECTION_DEFINES_TEST_AND_VENDOR #expands to all -D defined symbols
- - -fsanitize=address
+ #- -fsanitize=address
- -c ${1} #source code input file (Ruby method call param list sub)
- -o ${2} #object file output (Ruby method call param list sub)
:test_linker:
- :executable: clang
- :name: 'clang linker'
+ :executable: gcc
+ :name: 'gcc linker'
:arguments:
- - -fsanitize=address
+ #- -fsanitize=address
- ${1} #list of object files to link (Ruby method call param list sub)
- -o ${2} #executable file output (Ruby method call param list sub)
diff --git a/tools/build_make.py b/tools/build_make.py
index f79a452e4..240fc8d64 100644
--- a/tools/build_make.py
+++ b/tools/build_make.py
@@ -11,7 +11,6 @@ SKIPPED = "\033[33mskipped\033[0m"
build_separator = '-' * 106
-make_iar_option = 'TOOLCHAIN=iar'
def filter_with_input(mylist):
if len(sys.argv) > 1:
@@ -36,9 +35,10 @@ def build_family(example, family, make_option):
if __name__ == '__main__':
- # IAR CC
- if make_iar_option not in sys.argv:
- make_iar_option = ''
+ make_option = ''
+ for a in sys.argv:
+ if 'TOOLCHAIN=' in sys.argv:
+ make_option += ' ' + a
# If examples are not specified in arguments, build all
all_examples = []
@@ -67,7 +67,7 @@ if __name__ == '__main__':
for example in all_examples:
print(build_separator)
for family in all_families:
- fret = build_family(example, family, make_iar_option)
+ fret = build_family(example, family, make_option)
if len(fret) == len(total_result):
total_result = [total_result[i] + fret[i] for i in range(len(fret))]
diff --git a/tools/get_deps.py b/tools/get_deps.py
index 85c8c2126..bf6ef8c00 100644
--- a/tools/get_deps.py
+++ b/tools/get_deps.py
@@ -42,13 +42,13 @@ deps_optional = {
'0b79559eb411149d36e073c1635c620e576308d4',
'mm32'],
'hw/mcu/nordic/nrfx': ['https://github.com/NordicSemiconductor/nrfx.git',
- '2527e3c8449cfd38aee41598e8af8492f410ed15',
+ '7c47cc0a56ce44658e6da2458e86cd8783ccc4a2',
'nrf'],
'hw/mcu/nuvoton': ['https://github.com/majbthrd/nuc_driver.git',
'2204191ec76283371419fbcec207da02e1bc22fa',
'nuc'],
'hw/mcu/nxp/lpcopen': ['https://github.com/hathach/nxp_lpcopen.git',
- '84e0bd3e43910aaf71eefd62075cf57495418312',
+ '04bfe7a5f6ee74a89a28ad618d3367dcfcfb7d83',
'lpc11 lpc13 lpc15 lpc17 lpc18 lpc40 lpc43'],
'hw/mcu/nxp/mcux-sdk': ['https://github.com/hathach/mcux-sdk.git',
'144f1eb7ea8c06512e12f12b27383601c0272410',
@@ -84,7 +84,7 @@ deps_optional = {
'2615e866fa48fe1ff1af9e31c348813f2b19e7ec',
'stm32f4'],
'hw/mcu/st/cmsis_device_f7': ['https://github.com/STMicroelectronics/cmsis_device_f7.git',
- 'fc676ef1ad177eb874eaa06444d3d75395fc51f4',
+ '25b0463439303b7a38f0d27b161f7d2f3c096e79',
'stm32f7'],
'hw/mcu/st/cmsis_device_g0': ['https://github.com/STMicroelectronics/cmsis_device_g0.git',
'3a23e1224417f3f2d00300ecd620495e363f2094',
@@ -96,10 +96,10 @@ deps_optional = {
'60dc2c913203dc8629dc233d4384dcc41c91e77f',
'stm32h7'],
'hw/mcu/st/cmsis_device_h5': ['https://github.com/STMicroelectronics/cmsis_device_h5.git',
- '62b2cb0fbfe10c5791ee469bbde7b397c2fea8f5',
+ 'cd2d1d579743de57b88ccaf61a968b9c05848ffc',
'stm32h5'],
'hw/mcu/st/cmsis_device_l0': ['https://github.com/STMicroelectronics/cmsis_device_l0.git',
- '06748ca1f93827befdb8b794402320d94d02004f',
+ '69cd5999fd40ae6e546d4905b21635c6ca1bcb92',
'stm32l0'],
'hw/mcu/st/cmsis_device_l1': ['https://github.com/STMicroelectronics/cmsis_device_l1.git',
'7f16ec0a1c4c063f84160b4cc6bf88ad554a823e',
@@ -111,7 +111,7 @@ deps_optional = {
'd922865fc0326a102c26211c44b8e42f52c1e53d',
'stm32l5'],
'hw/mcu/st/cmsis_device_u5': ['https://github.com/STMicroelectronics/cmsis_device_u5.git',
- '06d7edade7167b0eafdd550bf77cfc4fa98eae2e',
+ '5ad9797c54ec3e55eff770fc9b3cd4a1aefc1309',
'stm32u5'],
'hw/mcu/st/cmsis_device_wb': ['https://github.com/STMicroelectronics/cmsis_device_wb.git',
'9c5d1920dd9fabbe2548e10561d63db829bb744f',
@@ -176,8 +176,10 @@ deps_optional = {
'lib/CMSIS_5': ['https://github.com/ARM-software/CMSIS_5.git',
'20285262657d1b482d132d20d755c8c330d55c1f',
'imxrt kinetis_k32l2 kinetis_kl lpc51 lpc54 lpc55 mcx mm32 msp432e4 nrf ra saml2x'
+ 'lpc11 lpc13 lpc15 lpc17 lpc18 lpc40 lpc43'
'stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32g0 stm32g4 stm32h5'
- 'stm32h7 stm32l0 stm32l1 stm32l4 stm32l5 stm32u5 stm32wb'],
+ 'stm32h7 stm32l0 stm32l1 stm32l4 stm32l5 stm32u5 stm32wb'
+ 'sam3x samd11 samd21 samd51 same5x same7x saml2x samg'],
'lib/sct_neopixel': ['https://github.com/gsteiert/sct_neopixel.git',
'e73e04ca63495672d955f9268e003cffe168fcd8',
'lpc55'],