diff --git a/CMakeLists.txt b/CMakeLists.txt index 06c96d374c4..ee51818440e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ if(EdgeTX_SUPERBUILD) BINARY_DIR ${CMAKE_BINARY_DIR}/arm-none-eabi CMAKE_ARGS ${CMAKE_ARGS} -Wno-dev -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} CMAKE_CACHE_ARGS - -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_SOURCE_DIR}/cmake/toolchain/arm-none-eabi.cmake + -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_SOURCE_DIR}/cmake/toolchain/gcc-arm-none-eabi.cmake -DEdgeTX_SUPERBUILD:BOOL=0 -DNATIVE_BUILD:BOOL=0 INSTALL_COMMAND "" diff --git a/cmake/toolchain/arm-none-eabi.cmake b/cmake/toolchain/gcc-arm-none-eabi.cmake similarity index 77% rename from cmake/toolchain/arm-none-eabi.cmake rename to cmake/toolchain/gcc-arm-none-eabi.cmake index 6ec5d6204b6..10f33f973a6 100644 --- a/cmake/toolchain/arm-none-eabi.cmake +++ b/cmake/toolchain/gcc-arm-none-eabi.cmake @@ -31,16 +31,20 @@ set(CMAKE_EXECUTABLE_SUFFIX ".elf") set(CMAKE_EXECUTABLE_SUFFIX_C ".elf") set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf") +# Optimize for code size by default +set(C_FLAGS_INIT "-Os -Wall -fdata-sections -ffunction-sections -fomit-frame-pointer -fno-asynchronous-unwind-tables") +set(CXX_FLAGS_INIT "${C_FLAGS_INIT} -fno-rtti -fno-exceptions -fno-unwind-tables -fno-threadsafe-statics") + # Default C compiler flags -set(CMAKE_C_FLAGS_DEBUG_INIT "-g3 -Og -Wall -pedantic -DDEBUG") -set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT}" CACHE STRING "" FORCE) -set(CMAKE_C_FLAGS_RELEASE_INIT "-O3 -Wall") +set(CMAKE_C_FLAGS_INIT "${C_FLAGS_INIT} -g3") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT}" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE_INIT "${C_FLAGS_INIT}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT}" CACHE STRING "" FORCE) # Default C++ compiler flags -set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g3 -Og -Wall -pedantic -DDEBUG") -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT}" CACHE STRING "" FORCE) -set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -Wall") +set(CMAKE_CXX_FLAGS_INIT "${CXX_FLAGS_INIT}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT}" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CXX_FLAGS_INIT}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT}" CACHE STRING "" FORCE) # customize linker command diff --git a/cmake/toolchain/llvm-embedded.cmake b/cmake/toolchain/llvm-embedded.cmake new file mode 100644 index 00000000000..63a9a5cd158 --- /dev/null +++ b/cmake/toolchain/llvm-embedded.cmake @@ -0,0 +1,60 @@ +# arm-none-eabi toolchain +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR arm) +set(CMAKE_CXX_STANDARD 11) + +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +if(MINGW OR WIN32) + set(EXE_SUFFIX ".exe") + set(CMAKE_OBJECT_PATH_MAX 200) +endif() + +if(ARM_TOOLCHAIN_DIR) + cmake_path(SET ARM_TOOLCHAIN_DIR NORMALIZE ${ARM_TOOLCHAIN_DIR}) + set(ARM_TOOLCHAIN_DIR "${ARM_TOOLCHAIN_DIR}/") +endif() + +set(CMAKE_AR ${ARM_TOOLCHAIN_DIR}llvm-ar${EXE_SUFFIX}) +set(CMAKE_ASM_COMPILER ${ARM_TOOLCHAIN_DIR}clang${EXE_SUFFIX}) +set(CMAKE_C_COMPILER ${ARM_TOOLCHAIN_DIR}clang${EXE_SUFFIX}) +set(CMAKE_CXX_COMPILER ${ARM_TOOLCHAIN_DIR}clang++${EXE_SUFFIX}) +set(CMAKE_LINKER ${ARM_TOOLCHAIN_DIR}lld${EXE_SUFFIX}) +set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}llvm-objcopy${EXE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_RANLIB ${ARM_TOOLCHAIN_DIR}llvm-ranlib${EXE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}llvm-size${EXE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_STRIP ${ARM_TOOLCHAIN_DIR}llvm-strip${EXE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_GCOV ${ARM_TOOLCHAIN_DIR}llvm-cov${EXE_SUFFIX} CACHE INTERNAL "") + +# Generate .elf files +set(CMAKE_EXECUTABLE_SUFFIX ".elf") +set(CMAKE_EXECUTABLE_SUFFIX_C ".elf") +set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf") + +# Optimize for code size by default +set(C_FLAGS_INIT "-Oz -Wall -fdata-sections -ffunction-sections -fomit-frame-pointer") +set(CXX_FLAGS_INIT "${C_FLAGS_INIT} -Wno-deprecated-register -fno-rtti -fno-exceptions -fno-unwind-tables -fno-c++-static-destructors -fno-threadsafe-statics") + +# Default ASM compiler flags +set(CMAKE_ASM_FLAGS "-Wno-unused-command-line-argument") + +# Default C compiler flags +set(CMAKE_C_FLAGS_INIT "${C_FLAGS_INIT} -g3") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT}" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE_INIT "${C_FLAGS_INIT}") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT}" CACHE STRING "" FORCE) + +# Default C++ compiler flags +set(CMAKE_CXX_FLAGS_INIT "${CXX_FLAGS_INIT}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT}" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CXX_FLAGS_INIT}") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT}" CACHE STRING "" FORCE) + +# customize linker command +set(CMAKE_EXE_LINKER_FLAGS "") +set(CMAKE_C_LINK_EXECUTABLE " -o ") +set(CMAKE_CXX_LINK_EXECUTABLE " -o ") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index bc9fa4fe13f..33bb168fde3 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -46,7 +46,6 @@ option(DEBUG_SEGGER_RTT "Debug output to Segger RTT" OFF) option(DEBUG_WINDOWS "Turn on windows traces" OFF) option(DEBUG_YAML "Turn on YAML traces" OFF) option(DEBUG_LABELS "Turn on Labels traces" OFF) -option(NANO "Use nano newlib and binalloc") option(TEST_BUILD_WARNING "Warn this is a test build" OFF) option(MODULE_PROTOCOL_FCC "Add support for FCC modules" ON) option(MODULE_PROTOCOL_LBT "Add support for EU/LBT modules" ON) @@ -480,55 +479,24 @@ if(NATIVE_BUILD) return() endif() -set(CMAKE_C_FLAGS "${FIRMWARE_C_FLAGS}") -set(CMAKE_C_FLAGS_DEBUG "${FIRMWARE_C_FLAGS_DEBUG}") -set(CMAKE_C_FLAGS_RELEASE "${FIRMWARE_C_FLAGS}") - -set(CMAKE_CXX_FLAGS "${FIRMWARE_CXX_FLAGS}") -set(CMAKE_CXX_FLAGS_DEBUG "${FIRMWARE_CXX_FLAGS_DEBUG}") -set(CMAKE_CXX_FLAGS_RELEASE "${FIRMWARE_CXX_FLAGS}") - find_program(BASH bash HINTS "c:/cygwin/bin/" "c:/msys/bin/" DOC "bash shell for firmware size report (eg. c:/cygwin/bin/bash.exe on Windows)." ) -set(OPT "s" CACHE STRING "Optimization mode (0/1/2/s") - -set(COMMON_FLAGS "-mcpu=${MCU} -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=firmware.lst") -set(COMMON_FLAGS "${COMMON_FLAGS} -gdwarf-2 -fno-exceptions -fdata-sections -ffunction-sections") -set(COMMON_FLAGS "${COMMON_FLAGS} -DHSE_VALUE=${HSE_VALUE}") -set(COMMON_FLAGS "${COMMON_FLAGS} -O${OPT} ${FPU_FLAGS}") -set(COMMON_FLAGS "${COMMON_FLAGS} ${WARNING_FLAGS}") +# if(SEMIHOSTING) +# add_definitions(-DSEMIHOSTING) +# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=rdimon.specs") +# endif() -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS} -Wimplicit") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} -fno-rtti") - -# these are in addition to CMAKE_CXX_FLAGS -set(CMAKE_EXE_LINKER_FLAGS "-lm -T${RADIO_SRC_DIR}/${LINKER_SCRIPT}") -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=firmware.map,--cref,--no-warn-mismatch,--gc-sections") - -if(SEMIHOSTING) - add_definitions(-DSEMIHOSTING) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=rdimon.specs") -endif() - -# Use newlib nano, which saves a few kilobytes. -if(NOT NANO STREQUAL NO) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nano.specs") - if(LUA) - # Lua needs %g and %f - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -u _printf_float -u _scanf_float") - endif() - if(SDRAM) - # Target with SDRAM do not need a custom allocator for now - # as the custom allocator has alignement issues - message("Target has SDRAM, do not use BIN_ALLOCATOR") - else() - # Nano's malloc does work well with lua, use our own - add_definitions(-DUSE_BIN_ALLOCATOR) - set(SRC ${SRC} bin_allocator.cpp) - endif() +if(SDRAM) + # Target with SDRAM do not need a custom allocator for now + # as the custom allocator has alignement issues + message("Target has SDRAM, do not use BIN_ALLOCATOR") +else() + # Nano's malloc does work well with lua, use our own + add_definitions(-DUSE_BIN_ALLOCATOR) + set(SRC ${SRC} bin_allocator.cpp) endif() # Bootloader @@ -545,6 +513,38 @@ link_libraries(firmware -lstdc++) add_dependencies(firmware ${RADIO_DEPENDENCIES}) set_target_properties(firmware PROPERTIES EXCLUDE_FROM_ALL TRUE) +target_link_options(firmware PRIVATE + -lm -T${LINKER_DIR}/firmware.ld + -Wl,-Map=firmware.map,--cref,--no-warn-mismatch,--gc-sections +) + +if (DEFINED TARGET_FLASH_SIZE) + message("TARGET_FLASH_SIZE = ${TARGET_FLASH_SIZE}") + target_link_options(firmware PRIVATE + -Wl,--defsym=__flash_size=${TARGET_FLASH_SIZE} + ) +endif() + +if (DEFINED TARGET_SDRAM_START) + message("TARGET_SDRAM_START = ${TARGET_SDRAM_START}") + target_link_options(firmware PRIVATE + -Wl,--defsym=__sdram_start=${TARGET_SDRAM_START} + ) +endif() + +if (LUA) + # ??? Lua needs %g and %f ??? + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_link_options(firmware PRIVATE + -Wl,--defsym=vfprintf=__f_vfprintf + ) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_link_options(firmware PRIVATE + "SHELL:-u _printf_float" "SHELL:-u _scanf_float" + ) + endif() +endif() + if(ACCESS_DENIED) add_subdirectory(thirdparty/AccessDenied) include_directories(thirdparty/AccessDenied) diff --git a/radio/src/boards/generic_stm32/linker/bootloader.ld b/radio/src/boards/generic_stm32/linker/bootloader.ld new file mode 100644 index 00000000000..d74a893b3f6 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/bootloader.ld @@ -0,0 +1,27 @@ +/* + Generic bootloader linker script for STM32 +*/ + +INCLUDE definitions.ld + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + KEEP(*(.version)) + KEEP(*(.bootversiondata)) + + INCLUDE common_text.ld + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + INCLUDE common_sections.ld +} diff --git a/radio/src/boards/generic_stm32/linker/common_sections.ld b/radio/src/boards/generic_stm32/linker/common_sections.ld new file mode 100644 index 00000000000..7c044207209 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/common_sections.ld @@ -0,0 +1,89 @@ + +/* + * Needs to be in its own segment with the PLT entries first + * so that the linker will compute the offsets to those + * entries correctly. + */ +.got : { + *(.got.plt) + *(.got) +} >FLASH AT>FLASH :text + +.toc : { + *(.toc .toc.*) +} >FLASH AT>FLASH :text + +/* Initialized data sections goes into RAM, load LMA copy after code */ +.data : { + *(.data .data*) + *(.gnu.linkonce.d.*) + + . = ALIGN(4); + *(.sdata .sdata.* .sdata2.*) + *(.gnu.linkonce.s.*) +} >REGION_DATA AT>FLASH :ram_init + +/* Thread local storage */ +.tdata : ALIGN(8) { + *(.tdata .tdata.* .gnu.linkonce.td.*) + PROVIDE(__data_end = .); + PROVIDE(__tdata_end = .); +} >REGION_DATA AT>FLASH :tls :ram_init + +PROVIDE(__data_start = ADDR(.data)); +PROVIDE(__data_source = LOADADDR(.data)); + +PROVIDE( _sdata = __data_start); +PROVIDE( _edata = __data_end); +PROVIDE( _sidata = __data_source); + +/* Thread local storage */ +.tbss (NOLOAD) : { + *(.tbss .tbss.* .gnu.linkonce.tb.*) + *(.tcommon) + PROVIDE( __tls_end = . ); + PROVIDE( __tbss_end = . ); +} >REGION_BSS AT>REGION_BSS :ram + +/* Uninitialized data section */ +.bss(NOLOAD) : { + *(.sbss*) + *(.gnu.linkonce.sb.*) + *(.bss .bss*) + *(.gnu.linkonce.b.*) + *(COMMON) + + . = ALIGN(4); + __bss_end = .; +} >REGION_BSS AT>REGION_BSS :ram + +PROVIDE( _sbss = ADDR(.tbss) ); +PROVIDE( _ebss = __bss_end ); + +/* collect all uninitialized .ram sections (force DMA accessible) */ +.ram (NOLOAD) : +{ + . = ALIGN(4); + _sram = .; + *(.ram) + . = ALIGN(4); + _eram = .; +} >REGION_RAM AT>REGION_RAM :ram + +INCLUDE extra_sections.ld + +/DISCARD/ : +{ + /* Remove information from the standard libraries */ + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + + /* Throw away C++ exception handling information */ + *(.note .note.*) + *(.eh_frame .eh_frame.*) + *(.ARM.extab* .gnu.linkonce.armextab.*) + *(.ARM.exidx*) +} + +.ARM.attributes 0 : { *(.ARM.attributes) } diff --git a/radio/src/boards/generic_stm32/linker/common_text.ld b/radio/src/boards/generic_stm32/linker/common_text.ld new file mode 100644 index 00000000000..4ced6c6bc96 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/common_text.ld @@ -0,0 +1,52 @@ +/* .text sections (code) */ +*(.text .text* .gnu.linkonce.t.*) + +/* read-only data */ +*(.rdata) +*(.rodata .rodata*) +*(.data.rel.ro .data.rel.ro.*) +*(.srodata .srodata.*) +*(.data.rel.ro .data.rel.ro.*) + +/* GCC / newlib special treatment */ +*(.eh_frame) +*(.data.__global_locale) + +/* + C++ Runtime: initializers for static variables. + C Runtime: designated constructors +*/ +. = ALIGN(4); +KEEP(*(.init)) +. = ALIGN(4); +__preinit_array_start = .; +KEEP (*(.preinit_array)) +__preinit_array_end = .; + +. = ALIGN(4); +__init_array_start = .; +KEEP (*(SORT(.init_array.*))) +KEEP (*(.init_array)) +__init_array_end = .; + +/* + C++ runtime: destructors for static variables. + C runtime: designated finializers +*/ +. = ALIGN(4); +KEEP(*(.fini)) + +. = ALIGN(4); +__fini_array_start = .; +KEEP (*(.fini_array)) +KEEP (*(SORT(.fini_array.*))) +__fini_array_end = .; + +/* + C++ runtime: static constructors +*/ +. = ALIGN(4); +KEEP (*crtbegin.o(.ctors)) +KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) +KEEP (*(SORT(.ctors.*))) +KEEP (*crtend.o(.ctors)) diff --git a/radio/src/boards/generic_stm32/linker/definitions.ld b/radio/src/boards/generic_stm32/linker/definitions.ld new file mode 100644 index 00000000000..07cc72538b3 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/definitions.ld @@ -0,0 +1,22 @@ +INCLUDE layout.ld + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Stack address */ +_estack = STACK_ADDRESS; + +/* Main stack end */ +_main_stack_start = _estack - MAIN_STACK_SIZE; + +/* Higest heap address */ +__heap_end = HEAP_ADDRESS; +__heap_size = __heap_end - __heap_start; + +PHDRS +{ + text PT_LOAD; + ram PT_LOAD; + ram_init PT_LOAD; + tls PT_TLS; +} diff --git a/radio/src/boards/generic_stm32/linker/firmware.ld b/radio/src/boards/generic_stm32/linker/firmware.ld new file mode 100644 index 00000000000..0ab82efae63 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/firmware.ld @@ -0,0 +1,37 @@ +/* + Generic firmware linker script for STM32 +*/ + +INCLUDE definitions.ld + +/* Define output sections */ +SECTIONS +{ + /* Bootloader code */ + .bootloader : { + KEEP(*(.bootloader)) + } >BOOTLOADER AT>BOOTLOADER :text + + .bootloader_fill : { + FILL(0xFFFF) + . = ORIGIN(BOOTLOADER) + LENGTH(BOOTLOADER); + } >BOOTLOADER AT>BOOTLOADER :text + + /* The program code and other data goes into FLASH */ + .text : + { + FILL(0xFFFF) + CREATE_OBJECT_SYMBOLS + + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + KEEP(*(.fwversiondata)) + + INCLUDE common_text.ld + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } > FLASH AT>FLASH :text + + INCLUDE common_sections.ld +} diff --git a/radio/src/boards/generic_stm32/linker/section_ccm.ld b/radio/src/boards/generic_stm32/linker/section_ccm.ld new file mode 100644 index 00000000000..1a333440fb2 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/section_ccm.ld @@ -0,0 +1,8 @@ +.ccm (NOLOAD) : +{ + . = ALIGN(4); + _sccm = .; + *(.ccm) + . = ALIGN(4); + _eccm = .; +} >CCM AT>CCM :ram diff --git a/radio/src/boards/generic_stm32/linker/stm32f20x/extra_sections.ld b/radio/src/boards/generic_stm32/linker/stm32f20x/extra_sections.ld new file mode 100644 index 00000000000..29fa393902a --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f20x/extra_sections.ld @@ -0,0 +1,11 @@ + +PROVIDE(__heap_start = _eram); + +/* Reserve stack and heap space in RAM */ +.stack(NOLOAD) : +{ + . = ALIGN(4); + . = . + MIN_HEAP_SIZE; + . = . + MAIN_STACK_SIZE; + . = ALIGN(4); +} > REGION_RAM diff --git a/radio/src/boards/generic_stm32/linker/stm32f20x/layout.ld b/radio/src/boards/generic_stm32/linker/stm32f20x/layout.ld new file mode 100644 index 00000000000..3be42a1b1bc --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f20x/layout.ld @@ -0,0 +1,35 @@ + +/* Required amount of stack for interrupt stack (Main stack) */ +MAIN_STACK_SIZE = 1024; + +/* Maximum bootloader code size */ +BOOTLOADER_SIZE = 0x8000; + +/* Minimum Heap Size (indicative) */ +MIN_HEAP_SIZE = 0; + +/* Specify the memory areas */ +MEMORY +{ + BOOTLOADER (rx) : + ORIGIN = 0x08000000, + LENGTH = BOOTLOADER_SIZE + + FLASH (rx) : + ORIGIN = ORIGIN(BOOTLOADER) + LENGTH(BOOTLOADER), + LENGTH = 512K - LENGTH(BOOTLOADER) + + RAM (xrw) : + ORIGIN = 0x20000000, + LENGTH = 128K +} + +/* Highest address of the user mode stack */ +STACK_ADDRESS = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ + +/* Highest heap address */ +HEAP_ADDRESS = STACK_ADDRESS - MAIN_STACK_SIZE; + +REGION_ALIAS("REGION_DATA", RAM); +REGION_ALIAS("REGION_BSS", RAM); +REGION_ALIAS("REGION_RAM", RAM); diff --git a/radio/src/boards/generic_stm32/linker/stm32f40x/extra_sections.ld b/radio/src/boards/generic_stm32/linker/stm32f40x/extra_sections.ld new file mode 100644 index 00000000000..21b82ee9146 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f40x/extra_sections.ld @@ -0,0 +1,20 @@ + +PROVIDE(__heap_start = _eram); + +INCLUDE section_ccm.ld + +/* Reserve heap space in RAM */ +._user_heap(NOLOAD) : +{ + . = ALIGN(4); + . = . + MIN_HEAP_SIZE; + . = ALIGN(4); +} > REGION_RAM + +/* Reserve stack space in CCM */ +.stack(NOLOAD) : +{ + . = ALIGN(4); + . = . + MAIN_STACK_SIZE; + . = ALIGN(4); +} > CCM diff --git a/radio/src/boards/generic_stm32/linker/stm32f40x/layout.ld b/radio/src/boards/generic_stm32/linker/stm32f40x/layout.ld new file mode 100644 index 00000000000..51c4ed39fd9 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f40x/layout.ld @@ -0,0 +1,34 @@ + +/* Required amount of stack for interrupt stack (Main stack) */ +MAIN_STACK_SIZE = 1024; + +/* Maximum bootloader code size */ +BOOTLOADER_SIZE = 0x8000; + +/* Minimum Heap Size (indicative) */ +MIN_HEAP_SIZE = 0; + +/* Specify the memory areas */ +MEMORY +{ + BOOTLOADER (rx) : + ORIGIN = 0x08000000, + LENGTH = BOOTLOADER_SIZE + + FLASH (rx) : + ORIGIN = 0x08008000, + LENGTH = DEFINED(__flash_size) ? __flash_size : 512K + + CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +} + +/* Highest address of the user mode stack */ +STACK_ADDRESS = ORIGIN(CCM) + LENGTH(CCM); /* end of CCM */ + +/* Highest heap address */ +HEAP_ADDRESS = ORIGIN(RAM) + LENGTH(RAM); + +REGION_ALIAS("REGION_DATA", CCM); +REGION_ALIAS("REGION_BSS", CCM); +REGION_ALIAS("REGION_RAM", RAM); diff --git a/radio/src/boards/generic_stm32/linker/stm32f413/extra_sections.ld b/radio/src/boards/generic_stm32/linker/stm32f413/extra_sections.ld new file mode 100644 index 00000000000..29fa393902a --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f413/extra_sections.ld @@ -0,0 +1,11 @@ + +PROVIDE(__heap_start = _eram); + +/* Reserve stack and heap space in RAM */ +.stack(NOLOAD) : +{ + . = ALIGN(4); + . = . + MIN_HEAP_SIZE; + . = . + MAIN_STACK_SIZE; + . = ALIGN(4); +} > REGION_RAM diff --git a/radio/src/boards/generic_stm32/linker/stm32f413/layout.ld b/radio/src/boards/generic_stm32/linker/stm32f413/layout.ld new file mode 100644 index 00000000000..da864bc39d0 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f413/layout.ld @@ -0,0 +1,26 @@ + +/* Highest address of the user mode stack */ +STACK_ADDRESS = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */ + +/* Required amount of stack for interrupt stack (Main stack) */ +MAIN_STACK_SIZE = 1024; + +/* Maximum bootloader code size */ +BOOTLOADER_SIZE = 0x8000; + +/* Minimum Heap Size (indicative) */ +MIN_HEAP_SIZE = 0; + +/* Highest heap address */ +HEAP_ADDRESS = STACK_ADDRESS - MAIN_STACK_SIZE; + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K +} + +REGION_ALIAS("REGION_DATA", RAM); +REGION_ALIAS("REGION_BSS", RAM); +REGION_ALIAS("REGION_RAM", RAM); diff --git a/radio/src/boards/generic_stm32/linker/stm32f429_sdram/extra_sections.ld b/radio/src/boards/generic_stm32/linker/stm32f429_sdram/extra_sections.ld new file mode 100644 index 00000000000..cbed1fd6235 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f429_sdram/extra_sections.ld @@ -0,0 +1,28 @@ + +INCLUDE section_ccm.ld + +/* Reserve stack space in CCM */ +.stack(NOLOAD) : +{ + . = ALIGN(4); + . = . + MAIN_STACK_SIZE; + . = ALIGN(4); +} > CCM AT>CCM :ram + +.sdram(NOLOAD) : +{ + . = ALIGN(4); + *(.sdram) + *(.sdram*) + *(.sdram_rodata) + *(.sdram_rodata*) + + . = ALIGN(4); + _esdram = .; + + /* Reserve heap space in RAM */ + . = . + MIN_HEAP_SIZE; + . = ALIGN(4); +} > SDRAM AT>SDRAM :ram + +PROVIDE(__heap_start = _esdram); diff --git a/radio/src/boards/generic_stm32/linker/stm32f429_sdram/layout.ld b/radio/src/boards/generic_stm32/linker/stm32f429_sdram/layout.ld new file mode 100644 index 00000000000..fc19031ed92 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f429_sdram/layout.ld @@ -0,0 +1,47 @@ + +/* Required amount of stack for interrupt stack (Main stack) */ +MAIN_STACK_SIZE = 8192; + +/* Maximum bootloader code size */ +BOOTLOADER_SIZE = 0x20000; + +/* Minimum Heap Size (indicative) */ +MIN_HEAP_SIZE = 4096K; + +/* SDRAM definitions */ +SDRAM_START = DEFINED(__sdram_start) ? __sdram_start : 0xD0000000; +SDRAM_SIZE = DEFINED(__sdram_size) ? __sdram_size : 8192K; + +/* Specify the memory areas */ +MEMORY +{ + BOOTLOADER (rx) : + ORIGIN = 0x08000000, + LENGTH = BOOTLOADER_SIZE + + FLASH (rx) : + ORIGIN = ORIGIN(BOOTLOADER) + LENGTH(BOOTLOADER), + LENGTH = 2048K - LENGTH(BOOTLOADER) + + CCM (xrw) : + ORIGIN = 0x10000000, + LENGTH = 64K + + RAM (xrw) : + ORIGIN = 0x20000000, + LENGTH = 192K + + SDRAM(xrw) : + ORIGIN = SDRAM_START, + LENGTH = SDRAM_SIZE +} + +/* Highest address of the user mode stack */ +STACK_ADDRESS = ORIGIN(CCM) + LENGTH(CCM); + +/* Highest heap address */ +HEAP_ADDRESS = ORIGIN(SDRAM) + LENGTH(SDRAM); + +REGION_ALIAS("REGION_DATA", RAM); +REGION_ALIAS("REGION_BSS", RAM); +REGION_ALIAS("REGION_RAM", RAM); diff --git a/radio/src/boards/generic_stm32/startup/startup_stm32f205xx.s b/radio/src/boards/generic_stm32/startup/startup_stm32f205xx.s new file mode 100644 index 00000000000..90ef9b9c354 --- /dev/null +++ b/radio/src/boards/generic_stm32/startup/startup_stm32f205xx.s @@ -0,0 +1,497 @@ +/** + ****************************************************************************** + * @file startup_stm32f205xx.s + * @author MCD Application Team + * @brief STM32F205xx Devices vector table for Atollic TrueSTUDIO toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M3 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 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 + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m3 + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Copy the data segment initializers from flash to SRAM */ + ldr r0, =_sdata + ldr r1, =_edata + ldr r2, =_sidata + movs r3, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r4, [r2, r3] + str r4, [r0, r3] + adds r3, r3, #4 + +LoopCopyDataInit: + adds r4, r0, r3 + cmp r4, r1 + bcc CopyDataInit + +/* jump to soft power control as soon as possible */ + bl pwrResetHandler + +/* Zero fill the bss segment. */ + ldr r2, =_sbss + ldr r4, =_ebss + movs r3, #0 + b LoopFillZerobss + +FillZerobss: + str r3, [r2] + adds r2, r2, #4 + +LoopFillZerobss: + cmp r2, r4 + bcc FillZerobss + +/* Call the clock system initialization function.*/ + bl SystemInit +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M3. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + + +g_pfnVectors: + .word _estack + .word Reset_Handler + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_IRQHandler /* PVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word CAN1_TX_IRQHandler /* CAN1 TX */ + .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ + .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ + .word CAN1_SCE_IRQHandler /* CAN1 SCE */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ + .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ + .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FSMC_IRQHandler /* FSMC */ + .word SDIO_IRQHandler /* SDIO */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word CAN2_TX_IRQHandler /* CAN2 TX */ + .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ + .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ + .word CAN2_SCE_IRQHandler /* CAN2 SCE */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word HASH_RNG_IRQHandler /* Hash and Rng */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_IRQHandler + .thumb_set PVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak CAN1_TX_IRQHandler + .thumb_set CAN1_TX_IRQHandler,Default_Handler + + .weak CAN1_RX0_IRQHandler + .thumb_set CAN1_RX0_IRQHandler,Default_Handler + + .weak CAN1_RX1_IRQHandler + .thumb_set CAN1_RX1_IRQHandler,Default_Handler + + .weak CAN1_SCE_IRQHandler + .thumb_set CAN1_SCE_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_TIM9_IRQHandler + .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler + + .weak TIM1_UP_TIM10_IRQHandler + .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_TIM11_IRQHandler + .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FSMC_IRQHandler + .thumb_set FSMC_IRQHandler,Default_Handler + + .weak SDIO_IRQHandler + .thumb_set SDIO_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak CAN2_TX_IRQHandler + .thumb_set CAN2_TX_IRQHandler,Default_Handler + + .weak CAN2_RX0_IRQHandler + .thumb_set CAN2_RX0_IRQHandler,Default_Handler + + .weak CAN2_RX1_IRQHandler + .thumb_set CAN2_RX1_IRQHandler,Default_Handler + + .weak CAN2_SCE_IRQHandler + .thumb_set CAN2_SCE_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak HASH_RNG_IRQHandler + .thumb_set HASH_RNG_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/src/targets/taranis/startup_stm32f40_41xxx.s b/radio/src/boards/generic_stm32/startup/startup_stm32f40_41xxx.s similarity index 93% rename from radio/src/targets/taranis/startup_stm32f40_41xxx.s rename to radio/src/boards/generic_stm32/startup/startup_stm32f40_41xxx.s index 95336855c95..f84d41fbe0a 100644 --- a/radio/src/targets/taranis/startup_stm32f40_41xxx.s +++ b/radio/src/boards/generic_stm32/startup/startup_stm32f40_41xxx.s @@ -2,16 +2,11 @@ ****************************************************************************** * @file startup_stm32f40_41xxx.s * @author MCD Application Team - * @version V1.3.0 - * @date 08-November-2013 - * @brief STM32F40xxx/41xxx Devices vector table for RIDE7 toolchain. + * @brief STM32F407xx Devices vector table for GCC based toolchains. * This module performs: * - Set the initial SP * - Set the initial PC == Reset_Handler, * - Set the vector table entries with the exceptions ISR address - * - Configure the clock system and the external SRAM mounted on - * STM324xG-EVAL board to be used as data memory (optional, - * to be enabled by user) * - Branches to main in the C library (which eventually * calls main()). * After Reset the Cortex-M4 processor is in Thread mode, @@ -19,19 +14,13 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2013 STMicroelectronics

+ *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

* - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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 * ****************************************************************************** */ @@ -70,53 +59,44 @@ defined in linker script */ .weak Reset_Handler .type Reset_Handler, %function Reset_Handler: - - bl pwrResetHandler /*jump to WDT reset handler where soft power control pin is turned on as soon as possible */ + ldr sp, =_estack /* set stack pointer */ + bl pwrResetHandler /* jump to soft power control as soon as possible */ /* Copy the data segment initializers from flash to SRAM */ - movs r1, #0 + ldr r0, =_sdata + ldr r1, =_edata + ldr r2, =_sidata + movs r3, #0 b LoopCopyDataInit CopyDataInit: - ldr r3, =_sidata - ldr r3, [r3, r1] - str r3, [r0, r1] - adds r1, r1, #4 + ldr r4, [r2, r3] + str r4, [r0, r3] + adds r3, r3, #4 LoopCopyDataInit: - ldr r0, =_sdata - ldr r3, =_edata - adds r2, r0, r1 - cmp r2, r3 - bcc CopyDataInit + adds r4, r0, r3 + cmp r4, r1 + bcc CopyDataInit + +/* Zero fill the bss segment. */ ldr r2, =_sbss + ldr r4, =_ebss + movs r3, #0 b LoopFillZerobss -/* Zero fill the bss segment. */ + FillZerobss: - movs r3, #0 - str r3, [r2], #4 + str r3, [r2] + adds r2, r2, #4 LoopFillZerobss: - ldr r3, = _ebss - cmp r2, r3 - bcc FillZerobss - -/*Paint Main Stack */ - ldr r2, = _main_stack_start -PaintMainStack: - movs r3, #0x55555555 - str r3, [r2], #4 -LoopPaintMainStack: - ldr r3, = _estack - cmp r2, r3 - bcc PaintMainStack + cmp r2, r4 + bcc FillZerobss /* Call the clock system intitialization function.*/ bl SystemInit - /* Call C++ constructors for static objects */ bl __libc_init_array - /* Call the application's entry point.*/ bl main bx lr diff --git a/radio/src/targets/taranis/startup_stm32f413vgtx.s b/radio/src/boards/generic_stm32/startup/startup_stm32f413xx.s similarity index 97% rename from radio/src/targets/taranis/startup_stm32f413vgtx.s rename to radio/src/boards/generic_stm32/startup/startup_stm32f413xx.s index 155b477efb1..e890a7a874f 100644 --- a/radio/src/targets/taranis/startup_stm32f413vgtx.s +++ b/radio/src/boards/generic_stm32/startup/startup_stm32f413xx.s @@ -14,12 +14,13 @@ ****************************************************************************** * @attention * - * Copyright (c) 2017 STMicroelectronics. - * All rights reserved. + *

© Copyright (c) 2017 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. + * 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 * ****************************************************************************** */ @@ -57,8 +58,9 @@ defined in linker script */ .section .text.Reset_Handler .weak Reset_Handler .type Reset_Handler, %function -Reset_Handler: - bl pwrResetHandler /*jump to WDT reset handler where soft power control pin is turned on as soon as possible */ +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + bl pwrResetHandler /* jump to soft power control as soon as possible */ /* Copy the data segment initializers from flash to SRAM */ ldr r0, =_sdata @@ -91,17 +93,7 @@ LoopFillZerobss: cmp r2, r4 bcc FillZerobss -/*Paint Main Stack */ - ldr r2, = _main_stack_start -PaintMainStack: - movs r3, #0x55555555 - str r3, [r2], #4 -LoopPaintMainStack: - ldr r3, = _estack - cmp r2, r3 - bcc PaintMainStack - -/* Call the clock system initialization function.*/ +/* Call the clock system intitialization function.*/ bl SystemInit /* Call static constructors */ bl __libc_init_array @@ -573,3 +565,4 @@ g_pfnVectors: .weak DFSDM2_FLT3_IRQHandler .thumb_set DFSDM2_FLT3_IRQHandler,Default_Handler +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/src/boards/generic_stm32/startup/startup_stm32f42_43xxx.s b/radio/src/boards/generic_stm32/startup/startup_stm32f42_43xxx.s new file mode 100644 index 00000000000..fcdb806561b --- /dev/null +++ b/radio/src/boards/generic_stm32/startup/startup_stm32f42_43xxx.s @@ -0,0 +1,549 @@ +/** + ****************************************************************************** + * @file startup_stm32f42_43xx.s + * @author MCD Application Team + * @brief STM32F42xxx/43xxx Devices vector table for RIDE7 toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M4 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 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 + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m4 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Copy the data segment initializers from flash to SRAM */ + ldr r0, =_sdata + ldr r1, =_edata + ldr r2, =_sidata + movs r3, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r4, [r2, r3] + str r4, [r0, r3] + adds r3, r3, #4 + +LoopCopyDataInit: + adds r4, r0, r3 + cmp r4, r1 + bcc CopyDataInit + +/* jump to soft power control as soon as possible */ + bl pwrResetHandler + +/* Zero fill the bss segment. */ + ldr r2, =_sbss + ldr r4, =_ebss + movs r3, #0 + b LoopFillZerobss + +FillZerobss: + str r3, [r2] + adds r2, r2, #4 + +LoopFillZerobss: + cmp r2, r4 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M3. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_IRQHandler /* PVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word CAN1_TX_IRQHandler /* CAN1 TX */ + .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ + .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ + .word CAN1_SCE_IRQHandler /* CAN1 SCE */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ + .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ + .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FSMC_IRQHandler /* FSMC */ + .word SDIO_IRQHandler /* SDIO */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word CAN2_TX_IRQHandler /* CAN2 TX */ + .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ + .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ + .word CAN2_SCE_IRQHandler /* CAN2 SCE */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word CRYP_IRQHandler /* CRYP crypto */ + .word HASH_RNG_IRQHandler /* Hash and Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word LTDC_IRQHandler /* LTDC */ + .word LTDC_ER_IRQHandler /* LTDC error */ + .word DMA2D_IRQHandler /* DMA2D */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_IRQHandler + .thumb_set PVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak CAN1_TX_IRQHandler + .thumb_set CAN1_TX_IRQHandler,Default_Handler + + .weak CAN1_RX0_IRQHandler + .thumb_set CAN1_RX0_IRQHandler,Default_Handler + + .weak CAN1_RX1_IRQHandler + .thumb_set CAN1_RX1_IRQHandler,Default_Handler + + .weak CAN1_SCE_IRQHandler + .thumb_set CAN1_SCE_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_TIM9_IRQHandler + .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler + + .weak TIM1_UP_TIM10_IRQHandler + .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_TIM11_IRQHandler + .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FSMC_IRQHandler + .thumb_set FSMC_IRQHandler,Default_Handler + + .weak SDIO_IRQHandler + .thumb_set SDIO_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak CAN2_TX_IRQHandler + .thumb_set CAN2_TX_IRQHandler,Default_Handler + + .weak CAN2_RX0_IRQHandler + .thumb_set CAN2_RX0_IRQHandler,Default_Handler + + .weak CAN2_RX1_IRQHandler + .thumb_set CAN2_RX1_IRQHandler,Default_Handler + + .weak CAN2_SCE_IRQHandler + .thumb_set CAN2_SCE_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak CRYP_IRQHandler + .thumb_set CRYP_IRQHandler,Default_Handler + + .weak HASH_RNG_IRQHandler + .thumb_set HASH_RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak LTDC_IRQHandler + .thumb_set LTDC_IRQHandler,Default_Handler + + .weak LTDC_ER_IRQHandler + .thumb_set LTDC_ER_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index d0c453dbaa7..441aad9378d 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -55,7 +55,7 @@ #define CLI_PRINT_BUFFER_SIZE 128 RTOS_TASK_HANDLE cliTaskId; -RTOS_DEFINE_STACK(cliTaskId, cliStack, CLI_STACK_SIZE); +RTOS_DEFINE_STACK(cliStack, CLI_STACK_SIZE); static uint8_t cliRxBufferStorage[CLI_RX_BUFFER_SIZE]; static StaticStreamBuffer_t cliRxBufferStatic; diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index 0582c28a43a..9a928845a24 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -392,7 +392,7 @@ PACK(struct TelemetrySensor { uint8_t persistent:1; uint8_t onlyPositive:1; uint8_t spare2:1 SKIP; - union { + PACK(union { NOBACKUP(PACK(struct { uint16_t ratio; int16_t offset; @@ -415,7 +415,7 @@ PACK(struct TelemetrySensor { uint16_t spare SKIP; }) dist); uint32_t param; - } NAME(cfg) FUNC(select_sensor_cfg); + }) NAME(cfg) FUNC(select_sensor_cfg); NOBACKUP( void init(const char *label, uint8_t unit=UNIT_RAW, uint8_t prec=0); void init(uint16_t id); diff --git a/radio/src/debug.cpp b/radio/src/debug.cpp index 94df3b665b8..1d0a7c67673 100644 --- a/radio/src/debug.cpp +++ b/radio/src/debug.cpp @@ -182,3 +182,10 @@ const char * const debugTimerNames[DEBUG_TIMERS_COUNT] = { }; #endif + +#if !defined(SIMU) + #include + #if defined(_LIBCPP_VERSION) + void std::__libcpp_verbose_abort(char const* format, ...) { std::abort(); } + #endif +#endif diff --git a/radio/src/definitions.h b/radio/src/definitions.h index 6021eaf54e2..147aacb1cb2 100644 --- a/radio/src/definitions.h +++ b/radio/src/definitions.h @@ -70,10 +70,8 @@ #if defined(SDRAM) && !defined(SIMU) #define __SDRAM __attribute__((section(".sdram"), aligned(4))) - #define __NOINIT __attribute__((section(".noinit"))) #else #define __SDRAM __DMA - #define __NOINIT #endif #if __GNUC__ diff --git a/radio/src/gui/128x64/view_statistics.cpp b/radio/src/gui/128x64/view_statistics.cpp index eb4e082d9f8..664c11f3a9a 100644 --- a/radio/src/gui/128x64/view_statistics.cpp +++ b/radio/src/gui/128x64/view_statistics.cpp @@ -210,12 +210,12 @@ void menuStatisticsDebug(event_t event) lcdDrawText(lcdLastRightPos, y, "ms)"); y += FH; - lcdDrawTextAlignedLeft(y, STR_FREE_STACK); - lcdDrawNumber(MENU_DEBUG_COL1_OFS, y, menusStack.available(), LEFT); - lcdDrawText(lcdLastRightPos, y, "/"); - lcdDrawNumber(lcdLastRightPos, y, mixerStack.available(), LEFT); - lcdDrawText(lcdLastRightPos, y, "/"); - lcdDrawNumber(lcdLastRightPos, y, audioStack.available(), LEFT); + // lcdDrawTextAlignedLeft(y, STR_FREE_STACK); + // lcdDrawNumber(MENU_DEBUG_COL1_OFS, y, menusStack.available(), LEFT); + // lcdDrawText(lcdLastRightPos, y, "/"); + // lcdDrawNumber(lcdLastRightPos, y, mixerStack.available(), LEFT); + // lcdDrawText(lcdLastRightPos, y, "/"); + // lcdDrawNumber(lcdLastRightPos, y, audioStack.available(), LEFT); y += FH; #if defined(DEBUG_LATENCY) diff --git a/radio/src/gui/212x64/view_statistics.cpp b/radio/src/gui/212x64/view_statistics.cpp index 4ca9f92cbd8..5598839cc4e 100644 --- a/radio/src/gui/212x64/view_statistics.cpp +++ b/radio/src/gui/212x64/view_statistics.cpp @@ -186,15 +186,15 @@ void menuStatisticsDebug(event_t event) lcdDrawText(lcdLastRightPos, y, STR_MS); y += FH; - lcdDrawTextAlignedLeft(y, STR_FREE_STACK); - lcdDrawText(MENU_DEBUG_COL1_OFS, y+1, "[M]", SMLSIZE); - lcdDrawNumber(lcdLastRightPos, y, menusStack.available(), LEFT); - lcdDrawText(lcdLastRightPos+2, y+1, "[X]", SMLSIZE); - lcdDrawNumber(lcdLastRightPos, y, mixerStack.available(), LEFT); - lcdDrawText(lcdLastRightPos+2, y+1, "[A]", SMLSIZE); - lcdDrawNumber(lcdLastRightPos, y, audioStack.available(), LEFT); - lcdDrawText(lcdLastRightPos+2, y+1, "[I]", SMLSIZE); - lcdDrawNumber(lcdLastRightPos, y, mainStackAvailable(), LEFT); + // lcdDrawTextAlignedLeft(y, STR_FREE_STACK); + // lcdDrawText(MENU_DEBUG_COL1_OFS, y+1, "[M]", SMLSIZE); + // lcdDrawNumber(lcdLastRightPos, y, menusStack.available(), LEFT); + // lcdDrawText(lcdLastRightPos+2, y+1, "[X]", SMLSIZE); + // lcdDrawNumber(lcdLastRightPos, y, mixerStack.available(), LEFT); + // lcdDrawText(lcdLastRightPos+2, y+1, "[A]", SMLSIZE); + // lcdDrawNumber(lcdLastRightPos, y, audioStack.available(), LEFT); + // lcdDrawText(lcdLastRightPos+2, y+1, "[I]", SMLSIZE); + // lcdDrawNumber(lcdLastRightPos, y, mainStackAvailable(), LEFT); y += FH; #if defined(DEBUG_LATENCY) diff --git a/radio/src/gui/colorlcd/CMakeLists.txt b/radio/src/gui/colorlcd/CMakeLists.txt index 087fb0c14e8..33a077f3670 100644 --- a/radio/src/gui/colorlcd/CMakeLists.txt +++ b/radio/src/gui/colorlcd/CMakeLists.txt @@ -17,7 +17,6 @@ file(GLOB WIDGETS_SRC RELATIVE ${RADIO_SRC_DIR}/gui/colorlcd set(GUI_SRC ${GUI_SRC} - str_functions.cpp colors.cpp lcd.cpp splash.cpp diff --git a/radio/src/gui/colorlcd/model_select.cpp b/radio/src/gui/colorlcd/model_select.cpp index 25906de830d..ba342008a7e 100644 --- a/radio/src/gui/colorlcd/model_select.cpp +++ b/radio/src/gui/colorlcd/model_select.cpp @@ -33,7 +33,6 @@ #include "model_templates.h" #include "opentx.h" #include "standalone_lua.h" -#include "str_functions.h" #include "view_channels.h" // bitmaps for toolbar diff --git a/radio/src/gui/colorlcd/model_telemetry.cpp b/radio/src/gui/colorlcd/model_telemetry.cpp index 254dabfef12..a415202ccb2 100644 --- a/radio/src/gui/colorlcd/model_telemetry.cpp +++ b/radio/src/gui/colorlcd/model_telemetry.cpp @@ -19,9 +19,8 @@ * GNU General Public License for more details. */ -#include -#include #include "model_telemetry.h" + #include "opentx.h" #include "libopenui.h" @@ -610,9 +609,12 @@ class SensorEditWindow : public Page { num->setWidth((lv_pct(28))); #endif num->setDisplayHandler([](int32_t value) { - std::stringstream stream; - stream << std::hex << value; - return stream.str(); + char buf[4]; + buf[0] = hex2char((value & 0xf000) >> 12); + buf[1] = hex2char((value & 0x0f00) >> 8); + buf[2] = hex2char((value & 0x00f0) >> 4); + buf[3] = hex2char((value & 0x000f) >> 0); + return std::string(buf, sizeof(buf)); }); num = new NumberEdit(paramLines[P_ID], rect_t{}, 0, 0xff, GET_SET_DEFAULT(sensor->instance)); #if LCD_H > LCD_W diff --git a/radio/src/gui/colorlcd/model_templates.cpp b/radio/src/gui/colorlcd/model_templates.cpp index d2c46ef2090..c35e529a171 100644 --- a/radio/src/gui/colorlcd/model_templates.cpp +++ b/radio/src/gui/colorlcd/model_templates.cpp @@ -22,7 +22,6 @@ #include "model_templates.h" #include "standalone_lua.h" -#include "str_functions.h" static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; diff --git a/radio/src/gui/colorlcd/radio_theme.cpp b/radio/src/gui/colorlcd/radio_theme.cpp index aeeac8b8be1..0b94911c07d 100644 --- a/radio/src/gui/colorlcd/radio_theme.cpp +++ b/radio/src/gui/colorlcd/radio_theme.cpp @@ -522,6 +522,17 @@ void ThemeSetupPage::checkEvents() } } +static void removeAllWhiteSpace(char *str) +{ + int len = strlen(str); + int origLen = len; + while(len) { + if (isspace(str[len])) + memmove(str + len, str + len + 1, origLen - len); + len--; + } +} + void ThemeSetupPage::displayThemeMenu(Window *window, ThemePersistance *tp) { auto menu = new Menu(listBox,false); diff --git a/radio/src/gui/colorlcd/str_functions.cpp b/radio/src/gui/colorlcd/str_functions.cpp deleted file mode 100644 index d6e9bafb92b..00000000000 --- a/radio/src/gui/colorlcd/str_functions.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include -#include -#include -#include "str_functions.h" - -static const char splitChars[] = { " -\t" }; - -void removeAllWhiteSpace(char *str) -{ - int len = strlen(str); - int origLen = len; - while(len) { - if (iswspace(str[len])) - memmove(str + len, str + len + 1, origLen - len); - len--; - } -} - -char *trim(char *str) -{ - char *end; - - // Trim leading space - while(isspace((unsigned char)*str)) str++; - - if(*str == 0) // All spaces? - return str; - - // Trim trailing space - end = str + strlen(str) - 1; - while(end > str && isspace((unsigned char)*end)) end--; - - // Write new null terminator character - end[1] = '\0'; - - return str; -} - -std::string trim_start(std::string str) -{ - uint32_t i; - for (i = 0; i < str.length(); i++) - if (!iswspace(str[i])) - break; - - return str.substr(i); -} - -std::vector Explode(std::string str, const char *splitChars) -{ - std::vector parts; - int startIndex = 0; - while (true) - { - size_t index = str.find_first_of(splitChars, startIndex); - - if (index == std::string::npos) - { - parts.emplace_back(str.substr(startIndex)); - return parts; - } - - std::string word = str.substr(startIndex, index - startIndex); - char nextChar = str.substr(index, 1)[0]; - - // Dashes and the likes should stick to the word occuring before it. Whitespace doesn't have to. - if (iswspace(nextChar)) - { - parts.emplace_back(word); - parts.emplace_back(std::string(&nextChar, 1)); - } - else - { - parts.emplace_back(word + nextChar); - } - - startIndex = index + 1; - } -} - -std::string wrap(std::string str, uint32_t width) -{ - std::vector words = Explode(str, splitChars); - - uint32_t curLineLength = 0; - std::ostringstream strBuilder; - - for(uint32_t i = 0; i < words.size(); i++) - { - std::string word = words[i]; - // If adding the new word to the current line would be too long, - // then put it on a new line (and split it up if it's too long). - if (curLineLength + word.length() > width) - { - // Only move down to a new line if we have text on the current line. - // Avoids situation where wrapped whitespace causes emptylines in text. - if (curLineLength > 0) - { - strBuilder << "\n"; - curLineLength = 0; - } - - // If the current word is too long to fit on a line even on it's own then - // split the word up. - while (word.length() > width) - { - strBuilder << word.substr(0, width - 1) + "-"; - word = word.substr(width - 1); - - strBuilder << "\n"; - } - - // Remove leading whitespace from the word so the new line starts flush to the left. - word = trim_start(word); - } - - strBuilder << word; - curLineLength += word.length(); - } - - return strBuilder.str(); -} diff --git a/radio/src/gui/colorlcd/str_functions.h b/radio/src/gui/colorlcd/str_functions.h deleted file mode 100644 index 5d9c64559f6..00000000000 --- a/radio/src/gui/colorlcd/str_functions.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#pragma once -#include -#include -#include -#include -#include - -extern char *trim(char *str); -extern void removeAllWhiteSpace(char *str); -extern std::string trim_start(std::string str); -extern std::string wrap(std::string str, uint32_t width); diff --git a/radio/src/gui/colorlcd/theme_manager.h b/radio/src/gui/colorlcd/theme_manager.h index c81e48fb5f5..c719d8e036d 100644 --- a/radio/src/gui/colorlcd/theme_manager.h +++ b/radio/src/gui/colorlcd/theme_manager.h @@ -27,7 +27,6 @@ #include "debug.h" #include "opentx.h" #include "sdcard.h" -#include "str_functions.h" #define COLOR_COUNT 13 diff --git a/radio/src/gui/colorlcd/view_statistics.cpp b/radio/src/gui/colorlcd/view_statistics.cpp index 7d4409d6c23..d4551315cbd 100644 --- a/radio/src/gui/colorlcd/view_statistics.cpp +++ b/radio/src/gui/colorlcd/view_statistics.cpp @@ -329,18 +329,18 @@ void DebugViewPage::build(FormWindow* window) line->padAll(0); line->padLeft(10); #endif - new DebugInfoNumber( - line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT}, - [] { return menusStack.available(); }, COLOR_THEME_PRIMARY1, - STR_STACK_MENU, nullptr); - new DebugInfoNumber( - line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT}, - [] { return mixerStack.available(); }, COLOR_THEME_PRIMARY1, - STR_STACK_MIX, nullptr); - new DebugInfoNumber( - line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT}, - [] { return audioStack.available(); }, COLOR_THEME_PRIMARY1, - STR_STACK_AUDIO, nullptr); + // new DebugInfoNumber( + // line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT}, + // [] { return menusStack.available(); }, COLOR_THEME_PRIMARY1, + // STR_STACK_MENU, nullptr); + // new DebugInfoNumber( + // line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT}, + // [] { return mixerStack.available(); }, COLOR_THEME_PRIMARY1, + // STR_STACK_MIX, nullptr); + // new DebugInfoNumber( + // line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT}, + // [] { return audioStack.available(); }, COLOR_THEME_PRIMARY1, + // STR_STACK_AUDIO, nullptr); #if defined(DEBUG_LATENCY) line = form->newLine(&grid2); diff --git a/radio/src/gui/colorlcd/widgets_container.h b/radio/src/gui/colorlcd/widgets_container.h index d9d7a02771b..057667a14d9 100644 --- a/radio/src/gui/colorlcd/widgets_container.h +++ b/radio/src/gui/colorlcd/widgets_container.h @@ -62,10 +62,10 @@ struct ZonePersistentData { }; template -struct WidgetsContainerPersistentData { +PACK(struct WidgetsContainerPersistentData { ZonePersistentData zones[N]; ZoneOptionValueTyped options[O]; -}; +}); #if !defined(YAML_GENERATOR) typedef WidgetsContainerPersistentData TopBarPersistentData; diff --git a/radio/src/lua/api_filesystem.cpp b/radio/src/lua/api_filesystem.cpp index 47cf67bd331..79e9dd62e65 100644 --- a/radio/src/lua/api_filesystem.cpp +++ b/radio/src/lua/api_filesystem.cpp @@ -75,7 +75,8 @@ int luaDir(lua_State* L) FRESULT res = f_opendir(dir, path); if (res != FR_OK) { - printf("luaDir cannot open %s\n", path); + TRACE("luaDir cannot open %s\n", path); + return 0; } lua_pushcclosure(L, dir_iter, 1); @@ -129,7 +130,7 @@ int luaFstat(lua_State* L) res = f_stat(path, &info); if (res != FR_OK) { - printf("luaFstat cannot open %s\n", path); + TRACE("luaFstat cannot open %s\n", path); return 0; } @@ -174,7 +175,8 @@ int luaDelete(lua_State* L) FRESULT res = f_unlink(filename); if (res != FR_OK) { - printf("luaDelete cannot delete file/folder %s\n", filename); + TRACE("luaDelete cannot delete file/folder %s\n", filename); + return 0; } lua_pushunsigned(L, res); diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 35f992eb274..2c64505718c 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1934,12 +1934,10 @@ uint32_t availableMemory() #if defined(SIMU) return 1000; #else - extern unsigned char *heap; - extern int _heap_end; + extern uint32_t __heap_size; struct mallinfo info = mallinfo(); - - return ((uint32_t)((unsigned char *)&_heap_end - heap)) + info.fordblks; + return __heap_size - info.arena + info.fordblks; #endif } diff --git a/radio/src/rtos.h b/radio/src/rtos.h index dfb6218c48d..953005009df 100644 --- a/radio/src/rtos.h +++ b/radio/src/rtos.h @@ -81,33 +81,12 @@ extern "C++" { pthread_mutex_unlock(&mutex); } - template - class TaskStack - { - public: - TaskStack() - { - } - - void paint() - { - } - - uint32_t size() - { - return SIZE; - } - - uint32_t available() - { - return SIZE / 2; - } - }; - #define RTOS_DEFINE_STACK(taskHandle, name, size) TaskStack name - - #define TASK_FUNCTION(task) void* task(void *) - - inline void RTOS_CREATE_TASK(pthread_t &taskId, void * (*task)(void *), const char * name) + #define RTOS_DEFINE_STACK(name, size) + #define RTOS_DECLARE_STACK(name, size) + + #define TASK_FUNCTION(task) void* task(void *) + + inline void _RTOS_CREATE_TASK(pthread_t &taskId, void * (*task)(void *), const char * name) { pthread_create(&taskId, nullptr, task, nullptr); #ifdef __linux__ @@ -115,15 +94,8 @@ extern "C++" { #endif } - template - inline void RTOS_CREATE_TASK(pthread_t &taskId, void *(*task)(void *), - const char *name, TaskStack &, - unsigned size = 0, unsigned priority = 0) - { - (void)size; - (void)priority; - RTOS_CREATE_TASK(taskId, task, name); - } + #define RTOS_CREATE_TASK(h,task,name,stack,stackSize,prio) \ + _RTOS_CREATE_TASK(h,task,name) #define TASK_RETURN() return nullptr @@ -201,8 +173,8 @@ extern "C++" { puxStackBuffer, &h->task_struct); } - #define RTOS_CREATE_TASK(h,task,name,stackStruct,stackSize,prio) \ - _RTOS_CREATE_TASK(&h,task,name,stackStruct.stack,stackSize,prio) + #define RTOS_CREATE_TASK(h,task,name,stack,stackSize,prio) \ + _RTOS_CREATE_TASK(&h,task,name,stack,stackSize,prio) static inline void _RTOS_CREATE_MUTEX(RTOS_MUTEX_HANDLE* h) { @@ -227,32 +199,6 @@ extern "C++" { #define RTOS_UNLOCK_MUTEX(handle) _RTOS_UNLOCK_MUTEX(&handle) - static inline uint32_t getStackAvailable(void * address, uint32_t size) - { - uint32_t * array = (uint32_t *)address; - uint32_t i = 0; - while (i < size && array[i] == 0x55555555) { - i++; - } - return i; - } - - extern int _estack; - extern int _main_stack_start; - static inline uint32_t stackSize() - { - return ((unsigned char *)&_estack - (unsigned char *)&_main_stack_start) / 4; - } - - static inline uint32_t mainStackAvailable() - { - return getStackAvailable(&_main_stack_start, stackSize()); - } - - //#define RTOS_CREATE_FLAG(flag) flag = CoCreateFlag(false, false) - //#define RTOS_SET_FLAG(flag) (void)CoSetFlag(flag) - //#define RTOS_CLEAR_FLAG(flag) (void)CoClearFlag(flag) - // returns true if timeout static inline bool _RTOS_WAIT_FLAG(RTOS_FLAG_HANDLE* flag, uint32_t timeout) { @@ -275,31 +221,6 @@ extern "C++" { #define RTOS_ISR_SET_FLAG(flag) _RTOS_ISR_SET_FLAG(&flag) -#ifdef __cplusplus - template - class TaskStack - { - public: - TaskStack(RTOS_TASK_HANDLE *h) { - this->h = h; - } - - uint32_t size() - { - return SIZE * 4; - } - - uint32_t available() - { - return uxTaskGetStackHighWaterMark(h->rtos_handle); - } - - StackType_t stack[SIZE]; - protected: - RTOS_TASK_HANDLE *h; - }; -#endif // __cplusplus - static inline TickType_t RTOS_GET_TIME(void) { return xTaskGetTickCount(); @@ -311,7 +232,8 @@ extern "C++" { } // stack must be aligned to 8 bytes otherwise printf for %f does not work! - #define RTOS_DEFINE_STACK(taskHandle, name, size) TaskStack __ALIGNED(8) name __CCMRAM (&taskHandle) + #define RTOS_DEFINE_STACK(name, size) StackType_t __ALIGNED(8) name[size] __CCMRAM + #define RTOS_DECLARE_STACK(name, size) extern StackType_t name[size] #define TASK_FUNCTION(task) void task(void *) #define TASK_RETURN() vTaskDelete(nullptr) diff --git a/radio/src/storage/modelslist.cpp b/radio/src/storage/modelslist.cpp index 1fa3e28d912..f42137d446a 100644 --- a/radio/src/storage/modelslist.cpp +++ b/radio/src/storage/modelslist.cpp @@ -442,15 +442,25 @@ std::string ModelMap::toCSV(const LabelsVector &labels) * @return vector of all labels */ -LabelsVector ModelMap::fromCSV(const char *str) +LabelsVector ModelMap::fromCSV(const char* str) { LabelsVector lbls; - std::istringstream f(str); - std::string lbl; - while (std::getline(f, lbl, ',')) { + const char* prev_c = str; + const char* c = strchr(prev_c, ','); + while(c != nullptr) { + std::string lbl(prev_c, c - prev_c); unEscapeCSV(lbl); lbls.push_back(lbl); + prev_c = ++c; + c = strchr(c, ','); } + + { + std::string lbl(prev_c); + unEscapeCSV(lbl); + lbls.push_back(lbl); + } + return lbls; } diff --git a/radio/src/storage/yaml/yaml_node.h b/radio/src/storage/yaml/yaml_node.h index c5a43a7d0e0..aa8748ef8e4 100644 --- a/radio/src/storage/yaml/yaml_node.h +++ b/radio/src/storage/yaml/yaml_node.h @@ -116,25 +116,25 @@ struct YamlNode .tag=(str) #define YAML_IDX \ - { .size=0, .type=YDT_IDX, 0, YAML_TAG("idx") } + { .size=0, .type=YDT_IDX, .elmts=0, YAML_TAG("idx") } #define YAML_IDX_CUST(tag, f_read, f_write) \ - { .size=0, .type=YDT_IDX, 0, YAML_TAG(tag), .u={._cust_idx={.read=(f_read), .write=(f_write) }} } + { .size=0, .type=YDT_IDX, .elmts=0, YAML_TAG(tag), .u={._cust_idx={.read=(f_read), .write=(f_write) }} } #define YAML_SIGNED(tag, bits) \ - { .size=(bits), .type=YDT_SIGNED, 0, YAML_TAG(tag) } + { .size=(bits), .type=YDT_SIGNED, .elmts=0, YAML_TAG(tag) } #define YAML_UNSIGNED(tag, bits) \ - { .size=(bits), .type=YDT_UNSIGNED, 0, YAML_TAG(tag) } + { .size=(bits), .type=YDT_UNSIGNED, .elmts=0, YAML_TAG(tag) } #define YAML_SIGNED_CUST(tag, bits, f_cust_to_uint, f_uint_to_cust) \ - { .size=(bits), .type=YDT_SIGNED, 0, YAML_TAG(tag), .u={._cust={ .cust_to_uint=f_cust_to_uint, .uint_to_cust=f_uint_to_cust }} } + { .size=(bits), .type=YDT_SIGNED, .elmts=0, YAML_TAG(tag), .u={._cust={ .cust_to_uint=f_cust_to_uint, .uint_to_cust=f_uint_to_cust }} } #define YAML_UNSIGNED_CUST(tag, bits, f_cust_to_uint, f_uint_to_cust) \ - { .size=(bits), .type=YDT_UNSIGNED, 0, YAML_TAG(tag), .u={._cust={ .cust_to_uint=f_cust_to_uint, .uint_to_cust=f_uint_to_cust }} } + { .size=(bits), .type=YDT_UNSIGNED, .elmts=0, YAML_TAG(tag), .u={._cust={ .cust_to_uint=f_cust_to_uint, .uint_to_cust=f_uint_to_cust }} } #define YAML_STRING(tag, max_len) \ - { .size=((max_len)<<3), .type=YDT_STRING, 0, YAML_TAG(tag) } + { .size=((max_len)<<3), .type=YDT_STRING, .elmts=0, YAML_TAG(tag) } #define YAML_STRUCT(tag, bits, nodes, f_is_active) \ { .size=(bits), .type=YDT_ARRAY, .elmts=1, YAML_TAG(tag), .u={._array={ .child=(nodes), .u={.is_active=(f_is_active)}}} } @@ -143,16 +143,16 @@ struct YamlNode { .size=(bits), .type=YDT_ARRAY, .elmts=(max_elmts), YAML_TAG(tag), .u={._array={ .child=(nodes), .u={.is_active=(f_is_active)}}} } #define YAML_ENUM(tag, bits, id_strs) \ - { .size=(bits), .type=YDT_ENUM, 0, YAML_TAG(tag), .u={._enum={ .choices=(id_strs) }} } + { .size=(bits), .type=YDT_ENUM, .elmts=0, YAML_TAG(tag), .u={._enum={ .choices=(id_strs) }} } #define YAML_UNION(tag, bits, nodes, f_sel_m) \ - { .size=(bits), .type=YDT_UNION, 0, YAML_TAG(tag), .u={._array={ .child=(nodes), .u={.select_member=(f_sel_m) }}} } + { .size=(bits), .type=YDT_UNION, .elmts=0, YAML_TAG(tag), .u={._array={ .child=(nodes), .u={.select_member=(f_sel_m) }}} } #define YAML_PADDING(bits) \ { .size=(bits), .type=YDT_PADDING } #define YAML_CUSTOM(tag, f_read, f_write) \ - { .size=0, .type=YDT_CUSTOM, 0, YAML_TAG(tag), .u={._cust_attr={.read=(f_read), .write=(f_write) }} } + { .size=0, .type=YDT_CUSTOM, .elmts=0, YAML_TAG(tag), .u={._cust_attr={.read=(f_read), .write=(f_write) }} } #define YAML_END \ { .size=0, .type=YDT_NONE } diff --git a/radio/src/strhelpers.cpp b/radio/src/strhelpers.cpp index 51d56d66f02..7ca3457b739 100644 --- a/radio/src/strhelpers.cpp +++ b/radio/src/strhelpers.cpp @@ -997,7 +997,7 @@ char *strAppendFilename(char *dest, const char *filename, const int size) return dest; } -#if defined(RTCLOCK) +#if defined(RTCLOCK) && !defined(BOOT) #include "rtc.h" char *strAppendDate(char *str, bool time) diff --git a/radio/src/syscalls.c b/radio/src/syscalls.c index d57597bbac8..336f08063e9 100644 --- a/radio/src/syscalls.c +++ b/radio/src/syscalls.c @@ -20,22 +20,22 @@ #include #include +#include #include #include #include #include "debug.h" -#undef errno -extern int errno; -extern int _end; -extern int _heap_end; +#if !defined(__PICOLIBC__) +extern char __heap_start[]; +extern char __heap_end[]; -unsigned char * heap = (unsigned char *)&_end; +static char* heap = __heap_start; extern caddr_t _sbrk(int nbytes) { - if (heap + nbytes < (unsigned char *)&_heap_end) { - unsigned char * prev_heap = heap; + if (heap + nbytes < __heap_end) { + char* prev_heap = heap; heap += nbytes; return (caddr_t)prev_heap; } @@ -44,12 +44,45 @@ extern caddr_t _sbrk(int nbytes) return ((void *)-1); } } +#endif #if defined(THREADSAFE_MALLOC) && !defined(BOOT) #include #include +#if defined(__PICOLIBC__) + +#define _LOCK_T void* + +_LOCK_T __lock___libc_recursive_mutex; + +void __retarget_lock_init(_LOCK_T* lock) {} +void __retarget_lock_init_recursive(_LOCK_T* lock) {} + +void __retarget_lock_close(_LOCK_T lock) {} +void __retarget_lock_close_recursive(_LOCK_T lock) {} + +void __retarget_lock_acquire(_LOCK_T lock) {} + +void __retarget_lock_acquire_recursive(_LOCK_T lock) +{ + (void)(lock); + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + vTaskSuspendAll(); +} + +void __retarget_lock_release(_LOCK_T lock) {} + +void __retarget_lock_release_recursive(_LOCK_T lock) +{ + (void)(lock); + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + (void)xTaskResumeAll(); +} + +#else // __PICOLIBC__ + void __malloc_lock(struct _reent *r) { (void)(r); @@ -63,13 +96,14 @@ void __malloc_unlock(struct _reent *r) if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) (void)xTaskResumeAll(); }; -#endif + +#endif // __PICOLIBC__ + +#endif // THREADSAFE_MALLOC && !BOOT #if !defined(SEMIHOSTING) -extern int _gettimeofday(void *p1, void *p2) -{ - return 0; -} +extern int _gettimeofday(void *p1, void *p2) { return 0; } +extern int gettimeofday(void *p1, void *p2) { return 0; } extern int _link(char *old, char *nw) { @@ -117,10 +151,29 @@ extern int _write(int file, char *ptr, int len) return 0; } -extern int _getpid() +extern int _getpid() { return -1; } + +#if defined(__PICOLIBC__) + +#include + +static int fake_putc(char c, FILE *file) { - return -1; + (void) file; + return c; } + +static const FILE __stdio = FDEV_SETUP_STREAM(fake_putc, + NULL, + NULL, + _FDEV_SETUP_READ); + +FILE *const stdin = (FILE *const)&__stdio; +__strong_reference(stdin, stdout); +__strong_reference(stdin, stderr); + +#endif // USE_PICOLIBC + #endif extern void _exit(int status) diff --git a/radio/src/targets/common/arm/CMakeLists.txt b/radio/src/targets/common/arm/CMakeLists.txt index a24ee4e8242..4176d786deb 100644 --- a/radio/src/targets/common/arm/CMakeLists.txt +++ b/radio/src/targets/common/arm/CMakeLists.txt @@ -221,7 +221,13 @@ endif() if(MULTIMODULE) add_definitions(-DMULTIMODULE) - set(SRC ${SRC} pulses/multi.cpp telemetry/hitec.cpp telemetry/hott.cpp telemetry/mlink.cpp telemetry/multi.cpp io/multi_firmware_update.cpp) + set(SRC ${SRC} + pulses/multi.cpp + telemetry/hitec.cpp + telemetry/hott.cpp + telemetry/mlink.cpp + telemetry/multi.cpp + io/multi_firmware_update.cpp) endif() if(MULTIMODULE OR AFHDS3) diff --git a/radio/src/targets/common/arm/stm32/CMakeLists.txt b/radio/src/targets/common/arm/stm32/CMakeLists.txt index a861b3bc8e0..899bb55fc6e 100644 --- a/radio/src/targets/common/arm/stm32/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/CMakeLists.txt @@ -10,6 +10,9 @@ set(ARCH ARM) set(STM32USB_DIR ${THIRDPARTY_DIR}/STM32_USB-Host-Device_Lib_V2.2.0/Libraries) add_definitions(-DSTM32 -DLUA_INPUTS -DVARIO) +set(LINKER_DIR ${RADIO_SRC_DIR}/boards/generic_stm32/linker) +add_link_options(-L${LINKER_DIR} -L${LINKER_DIR}/${TARGET_LINKER_DIR}) + include_directories(${RADIO_SRC_DIR}/targets/common/arm/stm32) include_directories(${STM32USB_DIR}/STM32_USB_OTG_Driver/inc) include_directories(${STM32USB_DIR}/STM32_USB_Device_Library/Core/inc) diff --git a/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt b/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt index 33741fc9ee4..8df2073e922 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt @@ -41,7 +41,6 @@ set(BOOTLOADER_SRC ../stm32_gpio_driver.cpp ../stm32_timer.cpp ../stm32_dma.cpp - init.c boot.cpp bin_files.cpp ) @@ -141,13 +140,14 @@ remove_definitions(-DWATCHDOG) add_definitions(-DBOOT) -set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -nostartfiles -lm -T${RADIO_SRC_DIR}/targets/${TARGET_DIR}/stm32_ramboot.ld -Wl,-Map=bootloader.map,--cref,--no-warn-mismatch,--gc-sections") -# use smaller nano libc -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nano.specs") - add_executable(bootloader EXCLUDE_FROM_ALL ${BOOTLOADER_SRC}) add_dependencies(bootloader ${BITMAPS_TARGET}) +target_link_options(bootloader PRIVATE + -lm -T${LINKER_DIR}/bootloader.ld + -Wl,-Map=bootloader.map,--cref,--no-warn-mismatch,--gc-sections +) + target_include_directories(bootloader PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp index d2d2635b4bc..a06410ef20b 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp +++ b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp @@ -573,6 +573,6 @@ int bootloaderMain() return 0; } -#if !defined(SIMU) && (defined(PCBHORUS) || defined(PCBNV14)) -void *__dso_handle = nullptr; -#endif +// #if !defined(SIMU) && (defined(PCBHORUS) || defined(PCBNV14)) +// void *__dso_handle = nullptr; +// #endif diff --git a/radio/src/targets/common/arm/stm32/bootloader/init.c b/radio/src/targets/common/arm/stm32/bootloader/init.c deleted file mode 100644 index 16bee9834b7..00000000000 --- a/radio/src/targets/common/arm/stm32/bootloader/init.c +++ /dev/null @@ -1,9 +0,0 @@ -void _init (void) -{ - -} - -void _fini(void) -{ - -} diff --git a/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt b/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt index 6c2001a1e75..4c9e2ad3aac 100644 --- a/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt @@ -1,8 +1,31 @@ + set(CPU_FAMILY STM32) -set(MCU cortex-m3) -set(FPU_FLAGS "") if(NOT NATIVE_BUILD) + + # Add MCU specific flags + add_compile_options( + -mcpu=cortex-m3 -mfloat-abi=soft + ) + add_link_options( + -mcpu=cortex-m3 -mfloat-abi=soft + ) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # using Clang + add_compile_options( + --target=arm-none-eabi + ) + add_link_options( + --target=arm-none-eabi + ) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # using GCC + add_link_options( + --specs=nano.specs + ) + endif() + # STM32 HAL/LL library set(STM32CUBE_DIR ${THIRDPARTY_DIR}/STM32F2xx_HAL_Driver) include_directories(${STM32CUBE_DIR}/Inc) diff --git a/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt b/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt index 1d7ed31beb6..be16ec881ed 100644 --- a/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt @@ -1,8 +1,31 @@ + set(CPU_FAMILY STM32) -set(MCU cortex-m4) -set(FPU_FLAGS "-mfloat-abi=hard -mfpu=fpv4-sp-d16") if(NOT NATIVE_BUILD) + + # Add MCU specific flags + add_compile_options( + -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 + ) + add_link_options( + -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 + ) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # using Clang + add_compile_options( + --target=arm-none-eabi + ) + add_link_options( + --target=arm-none-eabi + ) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # using GCC + add_link_options( + --specs=nano.specs + ) + endif() + # STM32 HAL/LL library set(STM32CUBE_DIR ${THIRDPARTY_DIR}/STM32F4xx_HAL_Driver) include_directories(${STM32CUBE_DIR}/Inc) @@ -73,18 +96,18 @@ set(STM32_STDPERIPH_SRC if(CPU_TYPE_FULL STREQUAL STM32F429xI) set(STM32_STDPERIPH_SRC ${STM32_STDPERIPH_SRC} - targets/${TARGET_DIR}/startup_stm32f42_43xxx.s + boards/generic_stm32/startup/startup_stm32f42_43xxx.s ${STM32_STDPERIPH_DIR}/src/stm32f4xx_fmc.c ${STM32_STDPERIPH_DIR}/src/stm32f4xx_dma.c ) elseif (CPU_TYPE_FULL STREQUAL STM32F413xG) set(STM32_STDPERIPH_SRC ${STM32_STDPERIPH_SRC} - targets/${TARGET_DIR}/startup_stm32f413vgtx.s + boards/generic_stm32/startup/startup_stm32f413vgtx.s ) else() set(STM32_STDPERIPH_SRC ${STM32_STDPERIPH_SRC} - targets/${TARGET_DIR}/startup_stm32f40_41xxx.s - ) + boards/generic_stm32/startup/startup_stm32f40_41xxx.s + ) endif() add_library(stm32_stdperiph OBJECT EXCLUDE_FROM_ALL diff --git a/radio/src/targets/common/arm/stm32/usb_driver.cpp b/radio/src/targets/common/arm/stm32/usb_driver.cpp index 57545f2e90b..928ee9f018f 100644 --- a/radio/src/targets/common/arm/stm32/usb_driver.cpp +++ b/radio/src/targets/common/arm/stm32/usb_driver.cpp @@ -123,7 +123,7 @@ void usbStop() USBD_DeInit(&USB_OTG_dev); } -#if defined(USBJ_EX) +#if defined(USBJ_EX) && !defined(BOOT) void usbJoystickRestart() { if (getSelectedUsbMode() != USB_JOYSTICK_MODE) return; diff --git a/radio/src/targets/horus/CMakeLists.txt b/radio/src/targets/horus/CMakeLists.txt index 537fb5d31cf..b160e2a9729 100644 --- a/radio/src/targets/horus/CMakeLists.txt +++ b/radio/src/targets/horus/CMakeLists.txt @@ -27,14 +27,10 @@ set(USB_SERIAL ON CACHE BOOL "Enable USB serial (CDC)") set(ROTARY_ENCODER YES) set(HARDWARE_EXTERNAL_MODULE YES) -if(BOOTLOADER) - set(LINKER_SCRIPT targets/horus/stm32f4_flash_bootloader.ld) -else() - set(LINKER_SCRIPT targets/horus/stm32f4_flash.ld) -endif() +set(CPU_TYPE_FULL STM32F429xI) +set(TARGET_LINKER_DIR stm32f429_sdram) # for size report script -set(CPU_TYPE_FULL STM32F429xI) set(SIZE_TARGET_MEM_DEFINE "MEM_SIZE_SDRAM2=8192") if(SPLASH STREQUAL OFF) diff --git a/radio/src/targets/horus/stm32_ramboot.ld b/radio/src/targets/horus/stm32_ramboot.ld index 9f712951fa2..4ae39962c08 100644 --- a/radio/src/targets/horus/stm32_ramboot.ld +++ b/radio/src/targets/horus/stm32_ramboot.ld @@ -22,6 +22,7 @@ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ _estack = 0x20030000; /* end of 192K RAM */ _heap_end = 0xD0800000; /* end of 8192K SDRAM */ +__heap_end = _heap_end; /* Generate a link error if heap and stack don't fit into RAM */ _Min_Heap_Size = 0; /* required amount of heap */ @@ -33,7 +34,7 @@ _main_stack_start = _estack - _Main_Stack_Size; /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K @@ -68,15 +69,19 @@ SECTIONS _etext = .; /* define a global symbols at end of code */ } >FLASH - .ARM.extab : - { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } >FLASH + + .ARM : + { __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; + *(.ARM.exidx*) + __exidx_end = .; } >FLASH - .preinit_array : + .preinit_array : { PROVIDE_HIDDEN (__preinit_array_start = .); KEEP (*(.preinit_array*)) @@ -114,7 +119,7 @@ SECTIONS } >RAM AT> FLASH /* Uninitialized data section */ - .bss : + .bss (NOLOAD) : { . = ALIGN(4); /* This is used by the startup in order to initialize the .bss secion */ @@ -174,6 +179,7 @@ SECTIONS PROVIDE ( end = _eram ); PROVIDE ( _end = _eram ); + PROVIDE ( __heap_start = _end ); /* Remove information from the standard libraries */ /DISCARD/ : diff --git a/radio/src/targets/horus/stm32f4_flash_bootloader.ld b/radio/src/targets/horus/stm32f4_flash_bootloader.ld index d5661a54872..4b9171f433d 100644 --- a/radio/src/targets/horus/stm32f4_flash_bootloader.ld +++ b/radio/src/targets/horus/stm32f4_flash_bootloader.ld @@ -22,6 +22,7 @@ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ _estack = 0x10010000; /* end of 64K CCM */ _heap_end = 0xD0800000; /* end of 8192K SDRAM */ +__heap_end = _heap_end; /* Generate a link error if heap and stack don't fit into RAM */ _Min_Heap_Size = 4096K; /* required amount of heap */ @@ -33,77 +34,90 @@ _main_stack_start = _estack - _Main_Stack_Size; /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K + BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 128K + FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 1920K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K - MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K SDRAM(xrw) : ORIGIN = 0xD0000000, LENGTH = 8192K } +PHDRS +{ + text PT_LOAD; + ram PT_LOAD; + ram_init PT_LOAD; + tls PT_TLS; +} + + /* Define output sections */ SECTIONS { /* The startup code goes first into FLASH */ + .bootloader : + { + KEEP(*(.bootloader)) /* Bootloader code */ + } >BOOTLOADER AT>BOOTLOADER :text + + .bootloader_fill : + { + FILL(0xFFFF) + . = ORIGIN(BOOTLOADER) + LENGTH(BOOTLOADER); + } >BOOTLOADER AT>BOOTLOADER :text /* The program code and other data goes into FLASH */ .text : { FILL(0xFFFF) - CREATE_OBJECT_SYMBOLS - KEEP(*(.bootloader)) /* Bootloader code */ - - . = 0x20000; /* Set the start of the main program */ - _stext = .; /* Provide the name for the start of this section */ . = ALIGN(4); KEEP(*(.isr_vector)) /* Startup code */ KEEP(*(.fwversiondata)) *(.text) /* .text sections (code) */ *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) + KEEP (*(SORT_BY_NAME(.init) SORT_BY_NAME(.init.*))) + KEEP (*(.fini .fini.*)) + _etext = .; /* define a global symbols at end of code */ - KEEP (*(.init)) - KEEP (*(.fini)) + /* read-only data */ + *(.rdata) + *(.rodata .rodata*) + *(.gnu.linkonce.r.*) + *(.srodata .srodata.*) + *(.data.rel.ro .data.rel.ro.*) . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >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*)) + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP (*(.init_array .ctors)) PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(.fini_array*)) - KEEP (*(SORT(.fini_array.*))) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH + PROVIDE_HIDDEN ( __fini_array_start = . ); + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) + KEEP (*(.fini_array .dtors)) + PROVIDE_HIDDEN ( __fini_array_end = . ); + + } >FLASH AT>FLASH :text + + /* + * Needs to be in its own segment with the PLT entries first + * so that the linker will compute the offsets to those + * entries correctly. + */ + .got : { + *(.got.plt) + *(.got) + } >FLASH AT>FLASH :text + + .toc : { + *(.toc .toc.*) + } >FLASH AT>FLASH :text /* used by the startup to initialize data */ _sidata = .; @@ -111,34 +125,49 @@ SECTIONS /* Initialized data sections goes into RAM, load LMA copy after code */ .data : { + *(.data .data*) + *(.gnu.linkonce.d.*) + . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH + *(.sdata .sdata.* .sdata2.*) + *(.gnu.linkonce.s.*) + } >RAM AT>FLASH :ram_init + + .tdata : ALIGN(__tls_align) { + *(.tdata .tdata.* .gnu.linkonce.td.*) + PROVIDE(__data_end = .); + PROVIDE(__tdata_end = .); + } >RAM AT>FLASH :tls :ram_init + + PROVIDE( __tls_align = MAX(ALIGNOF(.tdata),ALIGNOF(.tbss)) ); + + PROVIDE( _sdata = ADDR(.data) ); + PROVIDE( _edata = __data_end ); + + .tbss (NOLOAD) : { + *(.tbss .tbss.* .gnu.linkonce.tb.*) + *(.tcommon) + PROVIDE( __tls_end = . ); + PROVIDE( __tbss_end = . ); + } >RAM + + PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); /* Uninitialized data section */ - .bss : + .bss (NOLOAD) : { - . = ALIGN(4); - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - /* __bss_start__ = _sbss; */ - *(.bss) - *(.bss*) + *(.sbss*) + *(.gnu.linkonce.sb.*) + *(.bss .bss*) + *(.gnu.linkonce.b.*) *(COMMON) + . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ + __bss_end = .; } >RAM - /* Non-zeroed data section */ - . = ALIGN(4); - .noinit (NOLOAD) : - { - *(.noinit) - } >RAM + PROVIDE( _sbss = ADDR(.tbss) ); + PROVIDE( _ebss = __bss_end ); /* collect all uninitialized .ram sections */ .ram (NOLOAD) : @@ -158,16 +187,6 @@ SECTIONS _eccm = .; } >CCM - /* MEMORY_bank1 section, code must be located here explicitly */ - /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ - .memory_b1_text : - { - *(.mb1text) /* .mb1text sections (code) */ - *(.mb1text*) /* .mb1text* sections (code) */ - *(.mb1rodata) /* read-only data (constants) */ - *(.mb1rodata*) - } >MEMORY_B1 - .sdram (NOLOAD) : { *(.sdram) @@ -182,13 +201,20 @@ SECTIONS PROVIDE ( end = _eram ); PROVIDE ( _end = _eram ); + PROVIDE ( __heap_start = _end ); - /* Remove information from the standard libraries */ /DISCARD/ : { + /* Remove information from the standard libraries */ libc.a ( * ) libm.a ( * ) libgcc.a ( * ) + + /* Throw away C++ exception handling information */ + *(.note .note.*) + *(.eh_frame .eh_frame.*) + *(.ARM.extab* .gnu.linkonce.armextab.*) + *(.ARM.exidx*) } .ARM.attributes 0 : { *(.ARM.attributes) } diff --git a/radio/src/targets/nv14/CMakeLists.txt b/radio/src/targets/nv14/CMakeLists.txt index 4a3e552141d..802369e2d44 100644 --- a/radio/src/targets/nv14/CMakeLists.txt +++ b/radio/src/targets/nv14/CMakeLists.txt @@ -29,9 +29,14 @@ endif() set(RTC_BACKUP_RAM YES) set(PPM_LIMITS_SYMETRICAL YES) -# for size report script + set(CPU_TYPE_FULL STM32F429xI) +set(TARGET_LINKER_DIR stm32f429_sdram) +set(TARGET_SDRAM_START 0xC0000000) + +# for size report script set(SIZE_TARGET_MEM_DEFINE "MEM_SIZE_SDRAM2=8192") + option(USB_SERIAL "Enable USB serial (CDC)" ON) set(RF_BAUD_RATE 921600 230400 115200 57600 38400 19200 9600 4800 2400 1200) diff --git a/radio/src/targets/simu/simueeprom.cpp b/radio/src/targets/simu/simueeprom.cpp index dcd07213d18..e2dc6856159 100644 --- a/radio/src/targets/simu/simueeprom.cpp +++ b/radio/src/targets/simu/simueeprom.cpp @@ -157,7 +157,7 @@ void startEepromThread(const char * filename) sem_init(eeprom_write_sem, 0, 0); #endif - RTOS_CREATE_TASK(eeprom_thread_pid, eeprom_thread_function, "eeprom"); + _RTOS_CREATE_TASK(eeprom_thread_pid, eeprom_thread_function, "eeprom"); } void stopEepromThread() diff --git a/radio/src/targets/taranis/CMakeLists.txt b/radio/src/targets/taranis/CMakeLists.txt index 3999f8f7fde..e183df47287 100644 --- a/radio/src/targets/taranis/CMakeLists.txt +++ b/radio/src/targets/taranis/CMakeLists.txt @@ -443,18 +443,18 @@ endif() if(CPU_TYPE_FULL STREQUAL STM32F205xE) set(CPU_TYPE STM32F2) + set(TARGET_LINKER_DIR stm32f20x) add_definitions(-DSTM32F205xx) - set(LINKER_SCRIPT targets/taranis/stm32f2_flash.ld) -elseif (CPU_TYPE_FULL STREQUAL STM32F407xE) +elseif ((CPU_TYPE_FULL STREQUAL STM32F407xE) OR (CPU_TYPE_FULL STREQUAL STM32F407xG)) set(CPU_TYPE STM32F4) + set(TARGET_LINKER_DIR stm32f40x) add_definitions(-DSTM32F40_41xxx -DSTM32F407xx) - set(LINKER_SCRIPT targets/taranis/stm32f4_512k_flash.ld) -elseif (CPU_TYPE_FULL STREQUAL STM32F407xG) - set(CPU_TYPE STM32F4) - add_definitions(-DSTM32F40_41xxx -DSTM32F407xx) - set(LINKER_SCRIPT targets/taranis/stm32f4_1m_flash.ld) + if (CPU_TYPE_FULL STREQUAL STM32F407xG) + set(TARGET_FLASH_SIZE 1M) + endif() elseif (CPU_TYPE_FULL STREQUAL STM32F413xG) set(CPU_TYPE STM32F4) + set(TARGET_LINKER_DIR stm32f413) add_definitions(-DSTM32F40_41xxx -DSTM32F413xx) set(LINKER_SCRIPT targets/taranis/stm32f413_flash.ld) else() @@ -530,7 +530,8 @@ if(AUTOUPDATE) add_definitions(-DAUTOUPDATE) endif() -set(HSE_VALUE 12000000) +add_compile_options(-DHSE_VALUE=12000000) + set(SDCARD YES) set(TARGET_DIR taranis) set(PPM_LIMITS_SYMETRICAL YES) diff --git a/radio/src/targets/taranis/stm32_ramboot.ld b/radio/src/targets/taranis/stm32_ramboot.ld deleted file mode 100644 index 94c7d3e2daf..00000000000 --- a/radio/src/targets/taranis/stm32_ramboot.ld +++ /dev/null @@ -1,160 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32_flashboot.ld -** -** Abstract : Linker script for STM32F205 Device with -** 0.5MByte FLASH, 128KByte SRAM -** -** 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 -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x20020000; /* end of 128K SRAM */ - -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0; /* required amount of heap */ -_Main_Stack_Size = 1024; /* required amount of stack for interrupt stack (Main stack) */ - -/* Main stack end */ -_main_stack_start = _estack - _Main_Stack_Size; -_heap_end = _main_stack_start; - -/* Specify the memory areas */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K - MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - KEEP(*(.version)) - KEEP(*(.bootversiondata)) - . = ALIGN(4); /* Align the start of the text part */ - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - *(.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 - - - .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 (*(.fini_array*)) - KEEP (*(SORT(.fini_array.*))) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = .; - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _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 - - PROVIDE ( end = _ebss ); - PROVIDE ( _end = _ebss ); - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(4); - . = . + _Min_Heap_Size; - . = . + _Main_Stack_Size; - . = ALIGN(4); - } >RAM - - /* MEMORY_bank1 section, code must be located here explicitly */ - /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ - .memory_b1_text : - { - *(.mb1text) /* .mb1text sections (code) */ - *(.mb1text*) /* .mb1text* sections (code) */ - *(.mb1rodata) /* read-only data (constants) */ - *(.mb1rodata*) - } >MEMORY_B1 - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/radio/src/targets/taranis/stm32f2_flash.ld b/radio/src/targets/taranis/stm32f2_flash.ld deleted file mode 100644 index 04fb206832b..00000000000 --- a/radio/src/targets/taranis/stm32f2_flash.ld +++ /dev/null @@ -1,168 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32f2_flash.ld -** -** Abstract : Linker script for STM32F205 Device with -** 0.5MByte FLASH, 128KByte SRAM -** -** 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 -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x20020000; /* end of 128K SRAM */ - -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0; /* required amount of heap */ -_Main_Stack_Size = 1024; /* required amount of stack for interrupt stack (Main stack) */ - -/* Main stack end */ -_main_stack_start = _estack - _Main_Stack_Size; -_heap_end = _main_stack_start; - -/* Specify the memory areas */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K - MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - - /* The program code and other data goes into FLASH */ - .text : - { - FILL(0xFFFF) - - CREATE_OBJECT_SYMBOLS - - KEEP(*(.bootloader)) /* Bootloader code */ - - . = 0x8000; /* Set the start of the main program */ - _stext = .; /* Provide the name for the start of this section */ - - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - KEEP(*(.fwversiondata)) - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - *(.data.__global_locale) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >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 (*(.fini_array*)) - KEEP (*(SORT(.fini_array.*))) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = .; - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _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 - - PROVIDE ( end = _ebss ); - PROVIDE ( _end = _ebss ); - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(4); - . = . + _Min_Heap_Size; - . = . + _Main_Stack_Size; - . = ALIGN(4); - } >RAM - - /* MEMORY_bank1 section, code must be located here explicitly */ - /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ - .memory_b1_text : - { - *(.mb1text) /* .mb1text sections (code) */ - *(.mb1text*) /* .mb1text* sections (code) */ - *(.mb1rodata) /* read-only data (constants) */ - *(.mb1rodata*) - } >MEMORY_B1 - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/radio/src/targets/taranis/stm32f413_flash.ld b/radio/src/targets/taranis/stm32f413_flash.ld deleted file mode 100644 index 8c98ab1ea39..00000000000 --- a/radio/src/targets/taranis/stm32f413_flash.ld +++ /dev/null @@ -1,172 +0,0 @@ -/* -****************************************************************************** -** -** @file : LinkerScript.ld -** -** @brief : Linker script for STM32F413VGTx Device from STM32F4 series -** 1024Kbytes FLASH -** 320Kbytes 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 -** -****************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ -_heap_end = 0x20050000; /* end of 320K SRAM */ - -_Min_Heap_Size = 0 ; /* required amount of heap */ -_Min_Stack_Size = 0x400 ; /* required amount of stack */ - -_Main_Stack_Size = 1024; /* required amount of stack for interrupt stack (Main stack) */ - -/* Main stack end */ -_main_stack_start = _estack - _Main_Stack_Size; - -/* Memories definition */ -MEMORY -{ - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K - FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K -} - -/* Sections */ -SECTIONS -{ - /* The program code and other data into "FLASH" Rom type memory */ - .text : - { - FILL(0xFFFF) - - CREATE_OBJECT_SYMBOLS - - KEEP(*(.bootloader)) /* Bootloader code */ - - . = 0x8000; /* Set the start of the main program */ - _stext = .; /* Provide the name for the start of this section */ - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - KEEP(*(.fwversiondata)) - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - *(.data.__global_locale) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - .ARM.extab : { - . = ALIGN(4); - *(.ARM.extab* .gnu.linkonce.armextab.*) - . = ALIGN(4); - } >FLASH - - .ARM : { - . = ALIGN(4); - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - . = ALIGN(4); - } >FLASH - - .preinit_array : - { - . = ALIGN(4); - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - . = ALIGN(4); - } >FLASH - - .init_array : - { - . = ALIGN(4); - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - . = ALIGN(4); - } >FLASH - - .fini_array : - { - . = 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/radio/src/targets/taranis/stm32f4_1m_flash.ld b/radio/src/targets/taranis/stm32f4_1m_flash.ld deleted file mode 100644 index 9dfd15c2cc4..00000000000 --- a/radio/src/targets/taranis/stm32f4_1m_flash.ld +++ /dev/null @@ -1,180 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32f4_1m_flash.ld -** -** Abstract : Linker script for STM32F407 Device with -** 1MByte FLASH, 128KByte SRAM, 64KByte CCM -** -** 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 -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x10010000; /* end of 64K CCM */ -_heap_end = 0x20020000; /* end of 128K SRAM */ - -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0; /* required amount of heap */ -_Main_Stack_Size = 1024; /* required amount of stack for interrupt stack (Main stack) */ - -/* Main stack end */ -_main_stack_start = _estack - _Main_Stack_Size; - -/* Specify the memory areas */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K - CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K - MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - - /* The program code and other data goes into FLASH */ - .text : - { - FILL(0xFFFF) - - CREATE_OBJECT_SYMBOLS - - KEEP(*(.bootloader)) /* Bootloader code */ - - . = 0x8000; /* Set the start of the main program */ - _stext = .; /* Provide the name for the start of this section */ - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - KEEP(*(.fwversiondata)) - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - *(.data.__global_locale) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >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 (*(.fini_array*)) - KEEP (*(SORT(.fini_array.*))) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = .; - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >CCM AT> FLASH - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _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; */ - } >CCM - - /* collect all uninitialized .ccm sections */ - .ram (NOLOAD) : - { - . = ALIGN(4); - _sram = .; - /* __ccm_start__ = _sccm; */ - *(.ram) - . = ALIGN(4); - _eram = .; - /* __ccm_end__ = _eccm; */ - } >RAM - - PROVIDE ( end = _eram ); - PROVIDE ( _end = _eram ); - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(4); - . = . + _Min_Heap_Size; - . = . + _Main_Stack_Size; - . = ALIGN(4); - } >RAM - - /* MEMORY_bank1 section, code must be located here explicitly */ - /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ - .memory_b1_text : - { - *(.mb1text) /* .mb1text sections (code) */ - *(.mb1text*) /* .mb1text* sections (code) */ - *(.mb1rodata) /* read-only data (constants) */ - *(.mb1rodata*) - } >MEMORY_B1 - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/radio/src/targets/taranis/stm32f4_512k_flash.ld b/radio/src/targets/taranis/stm32f4_512k_flash.ld deleted file mode 100644 index 70c9b7e024f..00000000000 --- a/radio/src/targets/taranis/stm32f4_512k_flash.ld +++ /dev/null @@ -1,180 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32f4_512k_flash.ld -** -** Abstract : Linker script for STM32F407 Device with -** 0.5MByte FLASH, 128KByte SRAM, 64KByte CCM -** -** 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 -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x10010000; /* end of 64K CCM */ -_heap_end = 0x20020000; /* end of 128K SRAM */ - -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0; /* required amount of heap */ -_Main_Stack_Size = 1024; /* required amount of stack for interrupt stack (Main stack) */ - -/* Main stack end */ -_main_stack_start = _estack - _Main_Stack_Size; - -/* Specify the memory areas */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K - CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K - MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - - /* The program code and other data goes into FLASH */ - .text : - { - FILL(0xFFFF) - - CREATE_OBJECT_SYMBOLS - - KEEP(*(.bootloader)) /* Bootloader code */ - - . = 0x8000; /* Set the start of the main program */ - _stext = .; /* Provide the name for the start of this section */ - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - KEEP(*(.fwversiondata)) - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - *(.data.__global_locale) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >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 (*(.fini_array*)) - KEEP (*(SORT(.fini_array.*))) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = .; - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >CCM AT> FLASH - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _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; */ - } >CCM - - /* collect all uninitialized .ccm sections */ - .ram (NOLOAD) : - { - . = ALIGN(4); - _sram = .; - /* __ccm_start__ = _sccm; */ - *(.ram) - . = ALIGN(4); - _eram = .; - /* __ccm_end__ = _eccm; */ - } >RAM - - PROVIDE ( end = _eram ); - PROVIDE ( _end = _eram ); - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(4); - . = . + _Min_Heap_Size; - . = . + _Main_Stack_Size; - . = ALIGN(4); - } >RAM - - /* MEMORY_bank1 section, code must be located here explicitly */ - /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ - .memory_b1_text : - { - *(.mb1text) /* .mb1text sections (code) */ - *(.mb1text*) /* .mb1text* sections (code) */ - *(.mb1rodata) /* read-only data (constants) */ - *(.mb1rodata*) - } >MEMORY_B1 - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/radio/src/tasks.cpp b/radio/src/tasks.cpp index 2260ad54a92..db65064e53f 100644 --- a/radio/src/tasks.cpp +++ b/radio/src/tasks.cpp @@ -28,10 +28,10 @@ #include "watchdog_driver.h" RTOS_TASK_HANDLE menusTaskId; -RTOS_DEFINE_STACK(menusTaskId, menusStack, MENUS_STACK_SIZE); +RTOS_DEFINE_STACK(menusStack, MENUS_STACK_SIZE); RTOS_TASK_HANDLE audioTaskId; -RTOS_DEFINE_STACK(audioTaskId, audioStack, AUDIO_STACK_SIZE); +RTOS_DEFINE_STACK(audioStack, AUDIO_STACK_SIZE); RTOS_MUTEX_HANDLE audioMutex; diff --git a/radio/src/tasks.h b/radio/src/tasks.h index 0e6181e5660..99e3b31f568 100644 --- a/radio/src/tasks.h +++ b/radio/src/tasks.h @@ -47,12 +47,12 @@ #endif -extern TaskStack menusStack; -extern TaskStack mixerStack; -extern TaskStack audioStack; +RTOS_DECLARE_STACK(menusStack, MENUS_STACK_SIZE); +RTOS_DECLARE_STACK(mixerStack, MIXER_STACK_SIZE); +RTOS_DECLARE_STACK(audioStack, AUDIO_STACK_SIZE); #if defined(CLI) -extern TaskStack cliStack; +RTOS_DECLARE_STACK(cliStack, CLI_STACK_SIZE); #endif void tasksStart(); diff --git a/radio/src/tasks/mixer_task.cpp b/radio/src/tasks/mixer_task.cpp index 0e4bdd8871d..51cd7c2c858 100644 --- a/radio/src/tasks/mixer_task.cpp +++ b/radio/src/tasks/mixer_task.cpp @@ -29,7 +29,7 @@ #include "watchdog_driver.h" RTOS_TASK_HANDLE mixerTaskId; -RTOS_DEFINE_STACK(mixerTaskId, mixerStack, MIXER_STACK_SIZE); +RTOS_DEFINE_STACK(mixerStack, MIXER_STACK_SIZE); // mixer hold this mutex while computing // channels and sending them out diff --git a/radio/src/thirdparty/FatFs/ffconf.h b/radio/src/thirdparty/FatFs/ffconf.h index fda61e9edcf..2029cf9ba06 100644 --- a/radio/src/thirdparty/FatFs/ffconf.h +++ b/radio/src/thirdparty/FatFs/ffconf.h @@ -247,7 +247,11 @@ / Note that enabling exFAT discards ANSI C (C89) compatibility. */ -#define FF_FS_NORTC 0 +#if !defined(BOOT) + #define FF_FS_NORTC 0 +#else + #define FF_FS_NORTC 1 +#endif #define FF_NORTC_MON 1 #define FF_NORTC_MDAY 1 #define FF_NORTC_YEAR 2016 diff --git a/radio/src/thirdparty/Lua/src/lauxlib.c b/radio/src/thirdparty/Lua/src/lauxlib.c index b3ef28d4a91..452e8dd066c 100644 --- a/radio/src/thirdparty/Lua/src/lauxlib.c +++ b/radio/src/thirdparty/Lua/src/lauxlib.c @@ -216,6 +216,20 @@ LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { +#if defined(USE_FATFS) + if (stat) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (fname) + lua_pushfstring(L, "%s: file error", fname); + else + lua_pushstring(L, "file error"); + return 2; + } +#else int en = errno; /* calls to Lua API may change this value */ if (stat) { lua_pushboolean(L, 1); @@ -230,6 +244,7 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { lua_pushinteger(L, en); return 3; } +#endif } @@ -619,9 +634,14 @@ static const char *getF (lua_State *L, void *ud, size_t *size) { static int errfile (lua_State *L, const char *what, int fnameindex) { +#if defined(USE_FATFS) + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s", what, filename); +#else const char *serr = strerror(errno); const char *filename = lua_tostring(L, fnameindex) + 1; lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); +#endif lua_remove(L, fnameindex); return LUA_ERRFILE; } diff --git a/radio/src/thirdparty/Lua/src/luaconf.h b/radio/src/thirdparty/Lua/src/luaconf.h index 1e9d544a04f..3c3d74822f5 100644 --- a/radio/src/thirdparty/Lua/src/luaconf.h +++ b/radio/src/thirdparty/Lua/src/luaconf.h @@ -18,6 +18,9 @@ // force ANSI mode: lua_number2integer() behaves the same way on all platforms (#3826) #define LUA_ANSI +// prevent localeconv() +#define getlocaledecpoint() ('.') + /* ** ================================================================== ** Search for "@@" to find all configurable definitions. diff --git a/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/CMSIS/Include/core_cmFunc.h b/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/CMSIS/Include/core_cmFunc.h index 881904a1a93..6321fa681e2 100644 --- a/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/CMSIS/Include/core_cmFunc.h +++ b/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/CMSIS/Include/core_cmFunc.h @@ -602,6 +602,9 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) { #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) +#if __has_builtin(__builtin_arm_get_fpscr) + return __builtin_arm_get_fpscr(); +#else uint32_t result; /* Empty asm statement works as a scheduling barrier */ @@ -609,6 +612,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); __ASM volatile (""); return(result); +#endif #else return(0); #endif @@ -624,11 +628,15 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) { #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) +#if __has_builtin(__builtin_arm_set_fpscr) + __builtin_arm_set_fpscr(fpscr); +#else /* Empty asm statement works as a scheduling barrier */ __ASM volatile (""); __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); __ASM volatile (""); #endif +#endif } #endif /* (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07) */