diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index c064f9a2f..577889d7d 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -229,8 +229,8 @@ if(ASTERISK) add_definitions(-DASTERISK) endif() -if(WATCHDOG) - add_definitions(-DWATCHDOG) +if(WATCHDOG AND NOT NATIVE_BUILD) + add_definitions(-DUSE_WATCHDOG) endif() if(SIMU_AUDIO) @@ -499,8 +499,10 @@ 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(LINKER_DIR ${RADIO_SRC_DIR}/boards/generic_stm32/linker) +set(CMAKE_EXE_LINKER_FLAGS "-lm -T${LINKER_DIR}/firmware.ld -L${LINKER_DIR} -L${LINKER_DIR}/${TARGET_LINKER_DIR}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=firmware.map,--cref,--no-warn-mismatch,--gc-sections") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TARGET_LINKER_PARAMS}") if(SEMIHOSTING) add_definitions(-DSEMIHOSTING) @@ -539,6 +541,13 @@ link_libraries(firmware -lstdc++) add_dependencies(firmware ${RADIO_DEPENDENCIES}) set_target_properties(firmware PROPERTIES EXCLUDE_FROM_ALL TRUE) +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(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 000000000..d74a893b3 --- /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 000000000..90e0d7d04 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/common_sections.ld @@ -0,0 +1,66 @@ + +/* C/C++ Exception handling (not used) */ +.ARM.extab : +{ + *(.ARM.extab* .gnu.linkonce.armextab.*) +} > FLASH + +.ARM : +{ + PROVIDE(__exidx_start = .); + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + PROVIDE(__exidx_end = .); +} > FLASH + +.reboot_buffer(NOLOAD) : +{ + . = ALIGN(4); + *(.reboot*) +} > REGION_DATA + +/* Initialized data sections goes into RAM, load LMA copy after code */ +.data : +{ + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data .data*) /* .data sections */ + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ +} > REGION_DATA AT> FLASH + +/* used by the startup to initialize data */ +_sidata = LOADADDR(.data); + +/* Uninitialized data section */ +.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 .bss*) + *(COMMON) + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ +} > REGION_BSS + +/* collect all uninitialized .ram sections (force DMA accessible) */ +.ram (NOLOAD) : +{ + . = ALIGN(4); + _sram = .; + *(.ram) + . = ALIGN(4); + _eram = .; +} > REGION_RAM + +INCLUDE extra_sections.ld + +/* Remove information from the standard libraries */ +/DISCARD/ : +{ + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) +} + +.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 000000000..796dad7b6 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/common_text.ld @@ -0,0 +1,48 @@ +/* .text sections (code) */ +*(.text .text* .gnu.linkonce.t.*) +*(.rodata .rodata* .gnu.linkonce.r.*) + +*(.glue_7) /* glue arm to thumb code */ +*(.glue_7t) /* glue thumb to arm code */ + +*(.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 000000000..47d1ac07b --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/definitions.ld @@ -0,0 +1,13 @@ +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; 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 000000000..52518e167 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/firmware.ld @@ -0,0 +1,36 @@ +/* + Generic firmware 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 : + { + FILL(0xFFFF) + + CREATE_OBJECT_SYMBOLS + + /* Bootloader code */ + KEEP(*(.bootloader)) + + . = BOOTLOADER_SIZE; /* 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)) + + 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/section_ccm.ld b/radio/src/boards/generic_stm32/linker/section_ccm.ld new file mode 100644 index 000000000..65a5876d5 --- /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 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 000000000..f1212b4f6 --- /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 000000000..65988e36a --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f20x/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 = 512K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +} + +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 000000000..e1ce179fd --- /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 000000000..67f6dc706 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f40x/layout.ld @@ -0,0 +1,30 @@ + +/* Highest address of the user mode stack */ +STACK_ADDRESS = ORIGIN(CCM) + LENGTH(CCM); /* end of CCM */ + +/* 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 = ORIGIN(RAM) + LENGTH(RAM); + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : + ORIGIN = 0x08000000, + LENGTH = DEFINED(__flash_size) ? __flash_size : 512K + + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K + CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K +} + +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 000000000..f1212b4f6 --- /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 000000000..da864bc39 --- /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 000000000..c8e26f0bd --- /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 + +.sdram(NOLOAD) : +{ + . = ALIGN(4); + *(.sdram) + *(.sdram*) + *(.sdram_rodata) + *(.sdram_rodata*) + + . = ALIGN(4); + _esdram = .; + + /* Reserve heap space in RAM */ + . = . + MIN_HEAP_SIZE; + . = ALIGN(4); +} > SDRAM + +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 000000000..5e26ddd82 --- /dev/null +++ b/radio/src/boards/generic_stm32/linker/stm32f429_sdram/layout.ld @@ -0,0 +1,32 @@ + +/* Highest address of the user mode stack */ +STACK_ADDRESS = 0x10010000; /* end of 64K CCM */ + +/* 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; + +/* Highest heap address */ +HEAP_ADDRESS = SDRAM_START + SDRAM_SIZE; + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K + CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K + SDRAM(xrw) : ORIGIN = SDRAM_START, LENGTH = SDRAM_SIZE +} + +REGION_ALIAS("REGION_DATA", CCM); +REGION_ALIAS("REGION_BSS", RAM); +REGION_ALIAS("REGION_RAM", RAM); diff --git a/radio/src/thirdparty/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s b/radio/src/boards/generic_stm32/startup/startup_stm32f205xx.s similarity index 54% rename from radio/src/thirdparty/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s rename to radio/src/boards/generic_stm32/startup/startup_stm32f205xx.s index e521a2f5f..90ef9b9c3 100644 --- a/radio/src/thirdparty/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s +++ b/radio/src/boards/generic_stm32/startup/startup_stm32f205xx.s @@ -1,17 +1,12 @@ /** ****************************************************************************** - * @file startup_stm32f2xx.s + * @file startup_stm32f205xx.s * @author MCD Application Team - * @version V1.1.3 - * @date 05-March-2012 - * @brief STM32F2xx Devices vector table for RIDE7 toolchain. + * @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 - * - Configure the system clock and the external SRAM mounted on - * STM322xG-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-M3 processor is in Thread mode, @@ -19,26 +14,19 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2012 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 * ****************************************************************************** */ .syntax unified .cpu cortex-m3 - .fpu softvfp .thumb .global g_pfnVectors @@ -70,53 +58,46 @@ defined in linker script */ .weak Reset_Handler .type Reset_Handler, %function Reset_Handler: + ldr sp, =_estack /* set stack pointer */ - bl pwrResetHandler /*jump to WDT reset handler where soft power control pin is turned on as soon as possible */ - -/* Copy the data segment initializers from flash to SRAM */ - movs r1, #0 - b LoopCopyDataInit +/* 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 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 - ldr r2, =_sbss - b LoopFillZerobss -/* Zero fill the bss segment. */ + 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: - 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 - -/* Call the clock system intitialization function.*/ - bl SystemInit - -/* Call C++ constructors for static objects */ - bl __libc_init_array + 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 @@ -145,7 +126,8 @@ Infinite_Loop: .type g_pfnVectors, %object .size g_pfnVectors, .-g_pfnVectors - + + g_pfnVectors: .word _estack .word Reset_Handler @@ -165,105 +147,104 @@ g_pfnVectors: .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 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 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 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 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 +* 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 @@ -280,250 +261,237 @@ g_pfnVectors: .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 + .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 95336855c..f84d41fbe 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 - ldr r2, =_sbss - b LoopFillZerobss + 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 + 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 155b477ef..e890a7a87 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/targets/horus/startup_stm32f42_43xxx.s b/radio/src/boards/generic_stm32/startup/startup_stm32f42_43xxx.s similarity index 94% rename from radio/src/targets/horus/startup_stm32f42_43xxx.s rename to radio/src/boards/generic_stm32/startup/startup_stm32f42_43xxx.s index 327324481..fcdb80656 100644 --- a/radio/src/targets/horus/startup_stm32f42_43xxx.s +++ b/radio/src/boards/generic_stm32/startup/startup_stm32f42_43xxx.s @@ -2,16 +2,11 @@ ****************************************************************************** * @file startup_stm32f42_43xx.s * @author MCD Application Team - * @version V1.3.0 - * @date 08-November-2013 * @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 - * - Configure the clock system and the external SRAM mounted on - * STM32F4xG-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 * ****************************************************************************** */ @@ -71,45 +60,40 @@ defined in linker script */ .type Reset_Handler, %function Reset_Handler: ldr sp, =_estack /* set stack pointer */ - bl pwrResetHandler /* jump to WDT reset handler where soft power control pin is turned on 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 - ldr r2, =_sbss - b LoopFillZerobss + 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: - 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 diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index d0c453dba..8a06aaa92 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -24,7 +24,7 @@ #include "opentx.h" #include "timers_driver.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" #if defined(BLUETOOTH) #include "bluetooth_driver.h" @@ -862,7 +862,7 @@ int cliStackInfo(const char ** argv) return 0; } -extern int _end; +extern int _heap_start; extern int _heap_end; extern unsigned char *heap; @@ -889,10 +889,10 @@ int cliMemoryInfo(const char ** argv) cliSerialPrint("\tkeepcost %d bytes", info.keepcost); cliSerialPrint("\nHeap:"); - cliSerialPrint("\tstart %p", (unsigned char *)&_end); + cliSerialPrint("\tstart %p", (unsigned char *)&_heap_start); cliSerialPrint("\tend %p", (unsigned char *)&_heap_end); cliSerialPrint("\tcurr %p", heap); - cliSerialPrint("\tused %d bytes", (int)(heap - (unsigned char *)&_end)); + cliSerialPrint("\tused %d bytes", (int)(heap - (unsigned char *)&_heap_start)); cliSerialPrint("\tfree %d bytes", (int)((unsigned char *)&_heap_end - heap)); #if defined(LUA) diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 60af23702..2459207fd 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -601,10 +601,12 @@ enum Functions { #endif FUNC_DISABLE_AUDIO_AMP, FUNC_RGB_LED, + FUNC_TEST, // MUST remain last #if defined(DEBUG) - FUNC_TEST, // should remain the last before MAX as not added in Companion -#endif FUNC_MAX SKIP +#else + FUNC_MAX SKIP = FUNC_TEST - 1 +#endif }; enum TimerModes { diff --git a/radio/src/datastructs_private.h b/radio/src/datastructs_private.h index 8c018464c..b149e4e12 100644 --- a/radio/src/datastructs_private.h +++ b/radio/src/datastructs_private.h @@ -883,7 +883,7 @@ PACK(struct RadioData { NOBACKUP(int8_t beepLength:3 CUST(r_5pos,w_5pos)); NOBACKUP(int8_t hapticStrength:3 CUST(r_5pos,w_5pos)); NOBACKUP(uint8_t gpsFormat:1); - NOBACKUP(uint8_t unexpectedShutdown:1 SKIP); + NOBACKUP(uint8_t __spare2:1 SKIP); NOBACKUP(uint8_t speakerPitch CUST(r_spPitch,w_spPitch)); NOBACKUP(int8_t speakerVolume CUST(r_vol,w_vol)); NOBACKUP(int8_t vBatMin CUST(r_vbat_min,w_vbat_min)); diff --git a/radio/src/definitions.h b/radio/src/definitions.h index 6021eaf54..136199bfa 100644 --- a/radio/src/definitions.h +++ b/radio/src/definitions.h @@ -56,24 +56,20 @@ #if defined(SIMU) #define __DMA -#elif (defined(STM32F4) && !defined(BOOT)) || defined(SDRAM) - #define __DMA __attribute__((section(".ram"), aligned(4))) #else - #define __DMA __ALIGNED(4) + #define __DMA __attribute__((section(".ram"), aligned(4))) #endif #if defined(CCMRAM) && !defined(SIMU) - #define __CCMRAM __attribute__((section(".ccm"), aligned(4))) + #define __CCMRAM __attribute__((section(".ccm"), aligned(4))) #else #define __CCMRAM #endif #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/globals.h b/radio/src/globals.h index a4c6e3fa0..a64e2057c 100644 --- a/radio/src/globals.h +++ b/radio/src/globals.h @@ -27,12 +27,11 @@ #include "opentx_types.h" PACK(struct GlobalData { - uint8_t unexpectedShutdown:1; uint8_t externalAntennaEnabled:1; uint8_t authenticationCount:2; uint8_t upgradeModulePopup:1; uint8_t internalModuleVersionChecked:1; - uint8_t spare:2; + uint8_t spare:3; }); extern GlobalData globalData; diff --git a/radio/src/gui/128x64/view_main.cpp b/radio/src/gui/128x64/view_main.cpp index c4c6cadac..4dc2932b4 100644 --- a/radio/src/gui/128x64/view_main.cpp +++ b/radio/src/gui/128x64/view_main.cpp @@ -59,6 +59,22 @@ #define CLOCK_X 53 #define CLOCK_Y 57 +#if defined(ASTERISK) || !defined(USE_WATCHDOG) || defined(LOG_TELEMETRY) || \ + defined(LOG_BLUETOOTH) || defined(DEBUG_LATENCY) + +static bool isAsteriskDisplayed() { + return true; +} + +#else + +#include "hal/abnormal_reboot.h" + +static bool isAsteriskDisplayed() { + return UNEXPECTED_SHUTDOWN(); +} +#endif + void drawExternalAntennaAndRSSI() { #if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA) diff --git a/radio/src/gui/212x64/view_main.cpp b/radio/src/gui/212x64/view_main.cpp index c3c951ce9..f262a441e 100644 --- a/radio/src/gui/212x64/view_main.cpp +++ b/radio/src/gui/212x64/view_main.cpp @@ -76,6 +76,22 @@ const unsigned char icons[] = { #define ICON_REBOOT 91, 11 #define ICON_ALTITUDE 102, 9 +#if defined(ASTERISK) || !defined(USE_WATCHDOG) || defined(LOG_TELEMETRY) || \ + defined(LOG_BLUETOOTH) || defined(DEBUG_LATENCY) + +static bool isAsteriskDisplayed() { + return true; +} + +#else + +#include "hal/abnormal_reboot.h" + +static bool isAsteriskDisplayed() { + return UNEXPECTED_SHUTDOWN(); +} +#endif + void doMainScreenGraphics() { int16_t calibStickVert = calibratedAnalogs[ADC_MAIN_LV]; diff --git a/radio/src/gui/colorlcd/draw_functions.cpp b/radio/src/gui/colorlcd/draw_functions.cpp index 7dd4b0491..b23610e86 100644 --- a/radio/src/gui/colorlcd/draw_functions.cpp +++ b/radio/src/gui/colorlcd/draw_functions.cpp @@ -25,7 +25,7 @@ #include "libopenui.h" #include "theme.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" coord_t drawStringWithIndex(BitmapBuffer * dc, coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix) { @@ -185,7 +185,7 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, void drawFatalErrorScreen(const char * message) { - backlightEnable(100); + backlightEnable(BACKLIGHT_LEVEL_MAX); lcdInitDirectDrawing(); lcd->clear(COLOR2FLAGS(BLACK)); lcd->drawText(LCD_W/2, LCD_H/2-20, message, FONT(XL)|CENTERED|COLOR2FLAGS(WHITE)); diff --git a/radio/src/gui/colorlcd/fullscreen_dialog.cpp b/radio/src/gui/colorlcd/fullscreen_dialog.cpp index 9b4ac7233..79a81972c 100644 --- a/radio/src/gui/colorlcd/fullscreen_dialog.cpp +++ b/radio/src/gui/colorlcd/fullscreen_dialog.cpp @@ -26,7 +26,7 @@ #include "libopenui.h" #include "theme.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" #if LCD_W > LCD_H constexpr uint32_t ALERT_FRAME_TOP = 50; diff --git a/radio/src/gui/colorlcd/popups.cpp b/radio/src/gui/colorlcd/popups.cpp index 3a35b8c07..33c514665 100644 --- a/radio/src/gui/colorlcd/popups.cpp +++ b/radio/src/gui/colorlcd/popups.cpp @@ -24,7 +24,7 @@ #include "libopenui.h" #include "pwr.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" static void _run_popup_dialog(const char* title, const char* msg, const char* info = nullptr) diff --git a/radio/src/gui/colorlcd/splash.cpp b/radio/src/gui/colorlcd/splash.cpp index bc5039586..1e37f12f3 100644 --- a/radio/src/gui/colorlcd/splash.cpp +++ b/radio/src/gui/colorlcd/splash.cpp @@ -23,10 +23,9 @@ #include "inactivity_timer.h" #include "stamp.h" -extern void checkSpeakerVolume(); +#include "hal/abnormal_reboot.h" -#include "opentx.h" -#include "stamp.h" +extern void checkSpeakerVolume(); #if defined(VERSION_TAG) const std::string ver_str = "" VERSION_TAG; diff --git a/radio/src/hal/abnormal_reboot.h b/radio/src/hal/abnormal_reboot.h new file mode 100644 index 000000000..63704be79 --- /dev/null +++ b/radio/src/hal/abnormal_reboot.h @@ -0,0 +1,48 @@ +/* + * 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 + +enum AbnormalRebootCause { + ARC_None = 0, + ARC_Watchdog, + ARC_Software, +}; + +// Enable detecting abnormal reboots +// This should be called after booting +void abnormalRebootEnableDetection(); + +// Disable detecting abnormal reboots +// This should be called on normal shutdowns / reboots +void abnormalRebootDisableDetection(); + +// Test for abnormal reboot conditions +// (see AbnormalRebootCause) +uint32_t abnormalRebootGetCause(); + +#define UNEXPECTED_SHUTDOWN() \ + (abnormalRebootGetCause() == ARC_Watchdog) + +#define WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() \ + (abnormalRebootGetCause() != ARC_None) diff --git a/radio/src/targets/common/arm/stm32/watchdog_driver.h b/radio/src/hal/watchdog_driver.h similarity index 58% rename from radio/src/targets/common/arm/stm32/watchdog_driver.h rename to radio/src/hal/watchdog_driver.h index 60d82ae52..b511cb63c 100644 --- a/radio/src/targets/common/arm/stm32/watchdog_driver.h +++ b/radio/src/hal/watchdog_driver.h @@ -21,34 +21,20 @@ #pragma once -#define WDG_DURATION 500 /*ms*/ +#include +#define WDG_DURATION 500 /*ms*/ + +// Initializes IWDG with a duration in milliseconds void watchdogInit(unsigned int duration); -#if defined(SIMU) +// Resets IWDG timer +void watchdogReset(); -#define WAS_RESET_BY_WATCHDOG() (false) -#define WAS_RESET_BY_SOFTWARE() (false) -#define WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() (false) -#define WDG_ENABLE(x) -#define WDG_RESET() - -#else // SIMU - -#if defined(WATCHDOG) +#if defined(USE_WATCHDOG) #define WDG_ENABLE(x) watchdogInit(x) - #define WDG_RESET() IWDG->KR = 0xAAAA + #define WDG_RESET() watchdogReset() #else #define WDG_ENABLE(x) #define WDG_RESET() #endif - -#define WAS_RESET_BY_WATCHDOG() \ - (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF)) - -#define WAS_RESET_BY_SOFTWARE() (RCC->CSR & RCC_CSR_SFTRSTF) - -#define WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() \ - (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF | RCC_CSR_SFTRSTF)) - -#endif diff --git a/radio/src/io/bootloader_flash.cpp b/radio/src/io/bootloader_flash.cpp index 6f0c738a0..a6ee58194 100644 --- a/radio/src/io/bootloader_flash.cpp +++ b/radio/src/io/bootloader_flash.cpp @@ -24,7 +24,7 @@ #include "bootloader_flash.h" #include "timers_driver.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" #if defined(LIBOPENUI) #include "libopenui.h" diff --git a/radio/src/io/multi_firmware_update.cpp b/radio/src/io/multi_firmware_update.cpp index 429140e4c..e3c326289 100644 --- a/radio/src/io/multi_firmware_update.cpp +++ b/radio/src/io/multi_firmware_update.cpp @@ -31,7 +31,7 @@ #include "debug.h" #include "timers_driver.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" #include diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index f169a8b23..e9cd936df 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -28,7 +28,7 @@ #include "definitions.h" #include "timers_driver.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" #include "hal/rotary_encoder.h" // required by watchdog macro.. diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 4c6130368..0d38e5546 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -20,8 +20,10 @@ */ #include "opentx.h" + #include "hal/adc_driver.h" #include "hal/storage.h" +#include "hal/abnormal_reboot.h" #if defined(LIBOPENUI) #include "libopenui.h" @@ -312,7 +314,7 @@ void checkEeprom() { #if defined(RTC_BACKUP_RAM) && !defined(SIMU) if (TIME_TO_BACKUP_RAM()) { - if (!globalData.unexpectedShutdown) { + if (!UNEXPECTED_SHUTDOWN()) { rambackupWrite(); } rambackupDirtyMsk = 0; @@ -565,12 +567,8 @@ void perMain() checkHatsAsKeys(); #endif -#if !defined(LIBOPENUI) - event_t evt = getEvent(); -#endif - #if defined(RTC_BACKUP_RAM) - if (globalData.unexpectedShutdown) { + if (UNEXPECTED_SHUTDOWN()) { drawFatalErrorScreen(STR_EMERGENCY_MODE); return; } @@ -584,7 +582,7 @@ void perMain() #if !defined(EEPROM) // In case the SD card is removed during the session if ((!usbPlugged() || (getSelectedUsbMode() == USB_UNSELECTED_MODE)) - && !SD_CARD_PRESENT() && !globalData.unexpectedShutdown) { + && !SD_CARD_PRESENT() && !UNEXPECTED_SHUTDOWN()) { // TODO: implement for b/w #if defined(COLORLCD) @@ -612,7 +610,11 @@ void perMain() #if defined(MULTIMODULE) checkFailsafeMulti(); #endif - + +#if !defined(LIBOPENUI) + event_t evt = getEvent(); +#endif + #if defined(KEYS_GPIO_REG_BIND) && defined(BIND_KEY) bindButtonHandler(evt); #endif diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 837a71643..89632b754 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -29,9 +29,10 @@ #include "hal/adc_driver.h" #include "hal/switch_driver.h" #include "hal/storage.h" +#include "hal/watchdog_driver.h" +#include "hal/abnormal_reboot.h" #include "timers_driver.h" -#include "watchdog_driver.h" #include "switches.h" #include "inactivity_timer.h" @@ -1064,11 +1065,9 @@ void edgeTxClose(uint8_t shutdown) if (sessionTimer > 0) { g_eeGeneral.globalTimer += sessionTimer; sessionTimer = 0; + storageDirty(EE_GENERAL); } - - g_eeGeneral.unexpectedShutdown = 0; - storageDirty(EE_GENERAL); storageCheck(true); while (IS_PLAYING(ID_PLAY_PROMPT_BASE + AU_BYE)) { @@ -1122,11 +1121,6 @@ void edgeTxResume() #endif referenceSystemAudioFiles(); - - if (!g_eeGeneral.unexpectedShutdown) { - g_eeGeneral.unexpectedShutdown = 1; - storageDirty(EE_GENERAL); - } } #define INSTANT_TRIM_MARGIN 10 /* around 1% */ @@ -1273,7 +1267,7 @@ void runStartupAnimation() } } - if (duration < PWR_PRESS_DURATION_MIN() || duration >= PWR_PRESS_DURATION_MAX) { + if (duration <= PWR_PRESS_DURATION_MIN() || duration >= PWR_PRESS_DURATION_MAX) { boardOff(); } } @@ -1386,24 +1380,9 @@ void edgeTxInit() #endif #endif - // Radios handle UNEXPECTED_SHUTDOWN() differently: - // * radios with WDT and EEPROM and CPU controlled power use Reset status register - // and eeGeneral.unexpectedShutdown - // * radios with SDCARD model storage use Reset status register and special - // variables in RAM. They can not use eeGeneral.unexpectedShutdown - // * radios without CPU controlled power can only use Reset status register (if available) - if (UNEXPECTED_SHUTDOWN()) { - TRACE("Unexpected Shutdown detected"); - globalData.unexpectedShutdown = 1; - } - -#if defined(RTC_BACKUP_RAM) - SET_POWER_REASON(0); -#endif - #if defined(SDCARD) - // SDCARD related stuff, only done if not unexpectedShutdown - if (!globalData.unexpectedShutdown) { + // SDCARD related stuff, only enable if normal boot + if (!UNEXPECTED_SHUTDOWN()) { if (!sdMounted()) sdInit(); @@ -1435,16 +1414,17 @@ void edgeTxInit() #endif // defined(SDCARD) #if defined(EEPROM) - if (!radioSettingsValid) + if (!radioSettingsValid) { storageReadRadioSettings(); + } storageReadCurrentModel(); #else (void)radioSettingsValid; #endif #if defined(COLORLCD) && defined(LUA) - if (!globalData.unexpectedShutdown) { - // ??? lua widget state must be prepared before the call to storageReadAll() + if (!UNEXPECTED_SHUTDOWN()) { + // lua widget state must be prepared before the call to storageReadAll() luaInitThemesAndWidgets(); } #endif @@ -1452,7 +1432,7 @@ void edgeTxInit() // handling of storage for radios that have no EEPROM #if !defined(EEPROM) #if defined(RTC_BACKUP_RAM) && !defined(SIMU) - if (globalData.unexpectedShutdown) { + if (UNEXPECTED_SHUTDOWN()) { // SDCARD not available, try to restore last model from RAM TRACE("rambackupRestore"); rambackupRestore(); @@ -1464,7 +1444,7 @@ void edgeTxInit() storageReadAll(); #endif #endif // #if !defined(EEPROM) - + initSerialPorts(); currentSpeakerVolume = requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF; @@ -1495,7 +1475,7 @@ void edgeTxInit() resetBacklightTimeout(); } - if (!globalData.unexpectedShutdown) { + if (!UNEXPECTED_SHUTDOWN()) { uint8_t calibration_needed = !(startOptions & OPENTX_START_NO_CALIBRATION) && (g_eeGeneral.chkSum != evalChkSum()); @@ -1551,13 +1531,6 @@ void edgeTxInit() #endif } -#if !defined(RTC_BACKUP_RAM) - if (!g_eeGeneral.unexpectedShutdown) { - g_eeGeneral.unexpectedShutdown = 1; - storageDirty(EE_GENERAL); - } -#endif - #if defined(GUI) && !defined(COLORLCD) && !defined(STARTUP_ANIMATION) lcdSetContrast(); #endif diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 491fc703f..101d417d2 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -958,15 +958,6 @@ enum JackMode { extern uint8_t latencyToggleSwitch; #endif -inline bool isAsteriskDisplayed() -{ -#if defined(ASTERISK) || !defined(WATCHDOG) || defined(LOG_TELEMETRY) || defined(LOG_BLUETOOTH) || defined(DEBUG_LATENCY) - return true; -#endif - - return globalData.unexpectedShutdown; -} - #include "module.h" extern CircularBuffer luaSetStickySwitchBuffer; diff --git a/radio/src/pulses/multi.cpp b/radio/src/pulses/multi.cpp index b9aad3978..27ddaf56c 100644 --- a/radio/src/pulses/multi.cpp +++ b/radio/src/pulses/multi.cpp @@ -25,6 +25,7 @@ #include "io/multi_protolist.h" #include "telemetry/multi.h" #include "mixer_scheduler.h" +#include "hal/abnormal_reboot.h" // for the MULTI protocol definition // see https://github.com/pascallanger/DIY-Multiprotocol-TX-Module @@ -240,8 +241,10 @@ static void* multiInit(uint8_t module) getMultiModuleStatus(module).flags = 0; #if defined(MULTI_PROTOLIST) - TRACE("enablePulsesInternalModule(): trigger scan"); - MultiRfProtocols::instance(module)->triggerScan(); + if (!UNEXPECTED_SHUTDOWN()) { + TRACE("enablePulsesInternalModule(): trigger scan"); + MultiRfProtocols::instance(module)->triggerScan(); + } #endif return mod_st; diff --git a/radio/src/storage/sdcard_common.cpp b/radio/src/storage/sdcard_common.cpp index 0b078db4b..c9f4e3ba4 100644 --- a/radio/src/storage/sdcard_common.cpp +++ b/radio/src/storage/sdcard_common.cpp @@ -25,6 +25,8 @@ #include "modelslist.h" #include "model_init.h" +#include "hal/abnormal_reboot.h" + #if defined(COLORLCD) #include "theme.h" #endif @@ -76,7 +78,7 @@ void storageFormat() void storageCheck(bool immediately) { // Don't write anything to SD card if in EM - if (globalData.unexpectedShutdown) return; + if (UNEXPECTED_SHUTDOWN()) return; if (storageDirtyMsk & EE_GENERAL) { TRACE("eeprom write general"); diff --git a/radio/src/storage/yaml/yaml_datastructs_128x64.cpp b/radio/src/storage/yaml/yaml_datastructs_128x64.cpp index 43dd463cc..28d605c41 100644 --- a/radio/src/storage/yaml/yaml_datastructs_128x64.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_128x64.cpp @@ -91,6 +91,7 @@ const struct YamlIdStr enum_Functions[] = { { FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_TEST, "TEST" }, { 0, NULL } }; const struct YamlIdStr enum_TimerModes[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp index 1d8421998..8d6ce30de 100644 --- a/radio/src/storage/yaml/yaml_datastructs_nv14.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_nv14.cpp @@ -93,6 +93,7 @@ const struct YamlIdStr enum_Functions[] = { { FUNC_SET_SCREEN, "SET_SCREEN" }, { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_TEST, "TEST" }, { 0, NULL } }; const struct YamlIdStr enum_TimerModes[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_t20.cpp b/radio/src/storage/yaml/yaml_datastructs_t20.cpp index 90c14ecf7..2229e097b 100644 --- a/radio/src/storage/yaml/yaml_datastructs_t20.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_t20.cpp @@ -91,6 +91,7 @@ const struct YamlIdStr enum_Functions[] = { { FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_TEST, "TEST" }, { 0, NULL } }; const struct YamlIdStr enum_TimerModes[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp index d7e60d69c..0ef153a79 100644 --- a/radio/src/storage/yaml/yaml_datastructs_tpro.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_tpro.cpp @@ -91,6 +91,7 @@ const struct YamlIdStr enum_Functions[] = { { FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_TEST, "TEST" }, { 0, NULL } }; const struct YamlIdStr enum_TimerModes[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x10.cpp b/radio/src/storage/yaml/yaml_datastructs_x10.cpp index 639daf572..66ea8d1f7 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x10.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x10.cpp @@ -93,6 +93,7 @@ const struct YamlIdStr enum_Functions[] = { { FUNC_SET_SCREEN, "SET_SCREEN" }, { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_TEST, "TEST" }, { 0, NULL } }; const struct YamlIdStr enum_TimerModes[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp index 639daf572..66ea8d1f7 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x12s.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x12s.cpp @@ -93,6 +93,7 @@ const struct YamlIdStr enum_Functions[] = { { FUNC_SET_SCREEN, "SET_SCREEN" }, { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_TEST, "TEST" }, { 0, NULL } }; const struct YamlIdStr enum_TimerModes[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp index 1a8dd840d..080accc11 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9d.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9d.cpp @@ -91,6 +91,7 @@ const struct YamlIdStr enum_Functions[] = { { FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_TEST, "TEST" }, { 0, NULL } }; const struct YamlIdStr enum_TimerModes[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp index e5ada7904..cbb0f609a 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9e.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9e.cpp @@ -91,6 +91,7 @@ const struct YamlIdStr enum_Functions[] = { { FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_TEST, "TEST" }, { 0, NULL } }; const struct YamlIdStr enum_TimerModes[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp b/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp index 1d99307b3..14a3329de 100644 --- a/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_x9lite.cpp @@ -91,6 +91,7 @@ const struct YamlIdStr enum_Functions[] = { { FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_TEST, "TEST" }, { 0, NULL } }; const struct YamlIdStr enum_TimerModes[] = { diff --git a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp index cb9fe3378..0258d5039 100644 --- a/radio/src/storage/yaml/yaml_datastructs_xlites.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_xlites.cpp @@ -91,6 +91,7 @@ const struct YamlIdStr enum_Functions[] = { { FUNC_RACING_MODE, "RACING_MODE" }, { FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" }, { FUNC_RGB_LED, "RGB_LED" }, + { FUNC_TEST, "TEST" }, { 0, NULL } }; const struct YamlIdStr enum_TimerModes[] = { diff --git a/radio/src/syscalls.c b/radio/src/syscalls.c index d57597bba..2435e6698 100644 --- a/radio/src/syscalls.c +++ b/radio/src/syscalls.c @@ -27,10 +27,10 @@ #undef errno extern int errno; -extern int _end; +extern int _heap_start; extern int _heap_end; -unsigned char * heap = (unsigned char *)&_end; +unsigned char * heap = (unsigned char *)&_heap_start; extern caddr_t _sbrk(int nbytes) { diff --git a/radio/src/targets/common/arm/stm32/CMakeLists.txt b/radio/src/targets/common/arm/stm32/CMakeLists.txt index a861b3bc8..214d39d0b 100644 --- a/radio/src/targets/common/arm/stm32/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/CMakeLists.txt @@ -54,6 +54,8 @@ set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} ../common/arm/stm32/stm32_exti_driver.cpp ../common/arm/stm32/mixer_scheduler_driver.cpp ../common/arm/stm32/pwr_driver.cpp + ../common/arm/stm32/watchdog_driver.cpp + ../common/arm/stm32/abnormal_reboot.cpp ) if(IMU) diff --git a/radio/src/targets/common/arm/stm32/abnormal_reboot.cpp b/radio/src/targets/common/arm/stm32/abnormal_reboot.cpp new file mode 100644 index 000000000..efa94dbc4 --- /dev/null +++ b/radio/src/targets/common/arm/stm32/abnormal_reboot.cpp @@ -0,0 +1,81 @@ +/* + * 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 "hal/abnormal_reboot.h" + +#include "stm32_hal_ll.h" + +#define __REBOOT_DATA __attribute__((section(".rebootdata"), aligned(4))) + +// This variable is define at a fixed memory location +// and is used in bootloader and firmware to pass +// commands across reboot. +uint32_t _reboot_cmd __REBOOT_DATA; + +constexpr uint32_t _SOFTRESET_REQUEST = 0xCAFEDEAD; +constexpr uint32_t _SHUTDOWN_REQUEST = 0xDEADBEEF; + +constexpr uint32_t _REBOOT_CAUSE_DEFAULT = 0xFFFFFFFF; + +static uint32_t _reboot_cause = _REBOOT_CAUSE_DEFAULT; + +#if defined(DEBUG) +uint32_t _dbg_csr = 0xFFFFFFFF; +#endif + +void _init_reboot_cause() +{ + if (_reboot_cause != _REBOOT_CAUSE_DEFAULT) return; + +#if defined(DEBUG) + _dbg_csr = LL_RCC_ReadReg(CSR); +#endif + + if (LL_RCC_IsActiveFlag_IWDGRST()) { + _reboot_cause = ARC_Watchdog; + } else if (LL_RCC_IsActiveFlag_SFTRST()) { + _reboot_cause = ARC_Software; + } else { + _reboot_cause = ARC_None; + } + +#if !defined(BOOT) + LL_RCC_ClearResetFlags(); +#endif +} + +void abnormalRebootEnableDetection() +{ + _init_reboot_cause(); + _reboot_cmd = 0; +} + +void abnormalRebootRequestSoftReset() +{ + _reboot_cmd = _SOFTRESET_REQUEST; +} + + +uint32_t abnormalRebootGetCause() +{ + _init_reboot_cause(); + return _reboot_cause; +} diff --git a/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt b/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt index 33741fc9e..117e1c643 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt @@ -41,6 +41,8 @@ set(BOOTLOADER_SRC ../stm32_gpio_driver.cpp ../stm32_timer.cpp ../stm32_dma.cpp + ../watchdog_driver.cpp + ../abnormal_reboot.cpp init.c boot.cpp bin_files.cpp @@ -137,11 +139,17 @@ remove_definitions(-DLUA) remove_definitions(-DCLI) remove_definitions(-DSEMIHOSTING) remove_definitions(-DUSB_SERIAL) -remove_definitions(-DWATCHDOG) +remove_definitions(-DUSE_WATCHDOG) 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") +set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -nostartfiles -lm") + +set(LINKER_DIR ${RADIO_SRC_DIR}/boards/generic_stm32/linker) +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T${LINKER_DIR}/bootloader.ld -L${LINKER_DIR} -L${LINKER_DIR}/${TARGET_LINKER_DIR}") + +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -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") diff --git a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp index 72efdcc05..a83ab59af 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp +++ b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp @@ -35,8 +35,7 @@ #include "debug.h" #include "timers_driver.h" -#include "watchdog_driver.h" - +#include "hal/abnormal_reboot.h" #include "hal/rotary_encoder.h" #if defined(DEBUG_SEGGER_RTT) @@ -80,8 +79,6 @@ const uint8_t bootloaderVersion[] __attribute__ ((section(".version"), used)) = {'B', 'O', 'O', 'T', '1', '0'}; #endif -#define SOFTRESET_REQUEST 0xCAFEDEAD - volatile tmr10ms_t g_tmr10ms; volatile uint8_t tenms = 1; @@ -309,13 +306,10 @@ int bootloaderMain() #if defined(PWR_BUTTON_PRESS) // wait until power button is released - while (pwrPressed()) { - WDG_RESET(); - } + while (pwrPressed()) {} #endif for (;;) { - WDG_RESET(); if (tenms) { tenms = 0; @@ -560,10 +554,6 @@ int bootloaderMain() if (state == ST_REBOOT) { sdDone(); #if !defined(SIMU) -#if defined(RTC_BACKUP_RAM) - rtcInit(); - RTC->BKP0R = SOFTRESET_REQUEST; -#endif blExit(); NVIC_SystemReset(); #else diff --git a/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt b/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt index 6c2001a1e..23de4ea7f 100644 --- a/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/f2/CMakeLists.txt @@ -47,7 +47,7 @@ set(STM32_STDPERIPH_DIR ${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver) add_library(stm32_stdperiph OBJECT EXCLUDE_FROM_ALL targets/common/arm/stm32/f2/system_stm32f2xx.c - ${STM32LIB_DIR}/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s + boards/generic_stm32/startup/startup_stm32f205xx.s ${STM32_STDPERIPH_DIR}/src/misc.c ${STM32_STDPERIPH_DIR}/src/stm32f2xx_gpio.c ${STM32_STDPERIPH_DIR}/src/stm32f2xx_dbgmcu.c diff --git a/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt b/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt index 1d7ed31be..c7f651859 100644 --- a/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/f4/CMakeLists.txt @@ -73,17 +73,17 @@ 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_stm32f413xx.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() diff --git a/radio/src/targets/common/arm/stm32/flash_driver.cpp b/radio/src/targets/common/arm/stm32/flash_driver.cpp index 84e0b1e45..b4cf20ec1 100644 --- a/radio/src/targets/common/arm/stm32/flash_driver.cpp +++ b/radio/src/targets/common/arm/stm32/flash_driver.cpp @@ -20,7 +20,7 @@ */ #include "board.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" void waitFlashIdle() { diff --git a/radio/src/targets/common/arm/stm32/pwr_driver.cpp b/radio/src/targets/common/arm/stm32/pwr_driver.cpp index 2fa175d58..46a50b36e 100644 --- a/radio/src/targets/common/arm/stm32/pwr_driver.cpp +++ b/radio/src/targets/common/arm/stm32/pwr_driver.cpp @@ -20,7 +20,7 @@ */ #include "board.h" -#include "watchdog_driver.h" +#include "hal/abnormal_reboot.h" void pwrInit() { diff --git a/radio/src/targets/common/arm/stm32/stm32_hal_ll.h b/radio/src/targets/common/arm/stm32/stm32_hal_ll.h index 467998ecc..7cf3b445a 100644 --- a/radio/src/targets/common/arm/stm32/stm32_hal_ll.h +++ b/radio/src/targets/common/arm/stm32/stm32_hal_ll.h @@ -40,6 +40,7 @@ extern "C" { #include "STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h" #include "STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_adc.h" #include "STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_spi.h" + #include "STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_iwdg.h" #elif defined(STM32F2) #include "STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_bus.h" #include "STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_gpio.h" @@ -51,6 +52,7 @@ extern "C" { #include "STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_rcc.h" #include "STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_adc.h" #include "STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_spi.h" + #include "STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_iwdg.h" #endif #if defined(__cplusplus) diff --git a/radio/src/targets/common/arm/stm32/timers_driver.cpp b/radio/src/targets/common/arm/stm32/timers_driver.cpp index 4681af421..f96a5af5e 100644 --- a/radio/src/targets/common/arm/stm32/timers_driver.cpp +++ b/radio/src/targets/common/arm/stm32/timers_driver.cpp @@ -24,7 +24,7 @@ #include "stm32_hal_ll.h" #include "hal.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" static volatile uint32_t _ms_ticks; diff --git a/radio/src/targets/common/arm/stm32/watchdog_driver.cpp b/radio/src/targets/common/arm/stm32/watchdog_driver.cpp new file mode 100644 index 000000000..f8dcb1848 --- /dev/null +++ b/radio/src/targets/common/arm/stm32/watchdog_driver.cpp @@ -0,0 +1,40 @@ +/* + * 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 "hal/watchdog_driver.h" +#include "stm32_hal_ll.h" + +void watchdogInit(unsigned int duration) +{ + LL_IWDG_EnableWriteAccess(IWDG); + LL_IWDG_SetPrescaler(IWDG, LL_IWDG_PRESCALER_32); + + LL_IWDG_EnableWriteAccess(IWDG); + LL_IWDG_SetReloadCounter(IWDG, duration); + + LL_IWDG_ReloadCounter(IWDG); + LL_IWDG_Enable(IWDG); +} + +void watchdogReset() +{ + LL_IWDG_ReloadCounter(IWDG); +} diff --git a/radio/src/targets/horus/CMakeLists.txt b/radio/src/targets/horus/CMakeLists.txt index 512de78d8..8d409d6cf 100644 --- a/radio/src/targets/horus/CMakeLists.txt +++ b/radio/src/targets/horus/CMakeLists.txt @@ -27,14 +27,9 @@ 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() - # for size report script set(CPU_TYPE_FULL STM32F429xI) +set(TARGET_LINKER_DIR stm32f429_sdram) set(SIZE_TARGET_MEM_DEFINE "MEM_SIZE_SDRAM2=8192") add_definitions(-DPCBFRSKY) diff --git a/radio/src/targets/horus/board.cpp b/radio/src/targets/horus/board.cpp index 23a22836a..1bbcd435c 100644 --- a/radio/src/targets/horus/board.cpp +++ b/radio/src/targets/horus/board.cpp @@ -42,46 +42,9 @@ #include "flysky_gimbal_driver.h" #endif -enum PowerReason { - SHUTDOWN_REQUEST = 0xDEADBEEF, - SOFTRESET_REQUEST = 0xCAFEDEAD, -}; - -constexpr uint32_t POWER_REASON_SIGNATURE = 0x0178746F; - -bool UNEXPECTED_SHUTDOWN() -{ -#if defined(SIMU) || defined(NO_UNEXPECTED_SHUTDOWN) - return false; -#else - if (WAS_RESET_BY_WATCHDOG()) - return true; - else if (WAS_RESET_BY_SOFTWARE()) - return RTC->BKP0R != SOFTRESET_REQUEST; - else - return RTC->BKP1R == POWER_REASON_SIGNATURE && RTC->BKP0R != SHUTDOWN_REQUEST; -#endif -} - -void SET_POWER_REASON(uint32_t value) -{ - RTC->BKP0R = value; - RTC->BKP1R = POWER_REASON_SIGNATURE; -} - HardwareOptions hardwareOptions; bool boardBacklightOn = false; -void watchdogInit(unsigned int duration) -{ - IWDG->KR = 0x5555; // Unlock registers - IWDG->PR = 3; // Divide by 32 => 1kHz clock - IWDG->KR = 0x5555; // Unlock registers - IWDG->RLR = duration; - IWDG->KR = 0xAAAA; // reload - IWDG->KR = 0xCCCC; // start -} - #if !defined(BOOT) #include "opentx.h" @@ -231,7 +194,7 @@ void boardOff() hapticDone(); rtcDisableBackupReg(); - RTC->BKP0R = SHUTDOWN_REQUEST; + // RTC->BKP0R = SHUTDOWN_REQUEST; pwrOff(); @@ -258,6 +221,5 @@ void boardOff() bool isBacklightEnabled() { - if (globalData.unexpectedShutdown) return true; return boardBacklightOn; } diff --git a/radio/src/targets/horus/board.h b/radio/src/targets/horus/board.h index d56344281..9fa72d12f 100644 --- a/radio/src/targets/horus/board.h +++ b/radio/src/targets/horus/board.h @@ -30,9 +30,9 @@ #include "board_common.h" #include "hal.h" -#include "hal/serial_port.h" -#include "watchdog_driver.h" +#include "hal/serial_port.h" +#include "hal/watchdog_driver.h" #if defined(HARDWARE_TOUCH) #include "tp_gt911.h" @@ -173,8 +173,8 @@ void SDRAM_Init(); #define BATTERY_MAX 115 // 11.5V #endif -bool UNEXPECTED_SHUTDOWN(); -void SET_POWER_REASON(uint32_t value); +// bool UNEXPECTED_SHUTDOWN(); +// void SET_POWER_REASON(uint32_t value); #if defined(__cplusplus) && !defined(SIMU) extern "C" { @@ -238,21 +238,19 @@ void backlightEnable(uint8_t dutyCycle); void backlightFullOn(); bool isBacklightEnabled(); -#define BACKLIGHT_ENABLE() \ - { \ - boardBacklightOn = true; \ - backlightEnable(globalData.unexpectedShutdown \ - ? BACKLIGHT_LEVEL_MAX \ - : BACKLIGHT_LEVEL_MAX - currentBacklightBright); \ +#define BACKLIGHT_ENABLE() \ + { \ + boardBacklightOn = true; \ + backlightEnable(BACKLIGHT_LEVEL_MAX - currentBacklightBright); \ } -#define BACKLIGHT_DISABLE() \ - { \ - boardBacklightOn = false; \ - backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX \ - : ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && \ - (g_eeGeneral.backlightMode != e_backlight_mode_off)) \ - ? 0 \ - : g_eeGeneral.blOffBright); \ + +#define BACKLIGHT_DISABLE() \ + { \ + boardBacklightOn = false; \ + backlightEnable(((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && \ + (g_eeGeneral.backlightMode != e_backlight_mode_off)) \ + ? 0 \ + : g_eeGeneral.blOffBright); \ } #if !defined(SIMU) diff --git a/radio/src/targets/horus/stm32_ramboot.ld b/radio/src/targets/horus/stm32_ramboot.ld deleted file mode 100644 index 9f712951f..000000000 --- a/radio/src/targets/horus/stm32_ramboot.ld +++ /dev/null @@ -1,187 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32f4_flash.ld -** -** Abstract : Linker script for STM32F439 Device with -** 2MByte FLASH, 192KByte 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 = 0x20030000; /* end of 192K RAM */ -_heap_end = 0xD0800000; /* end of 8192K SDRAM */ - -/* 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 = 2048K - 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 -} - -/* 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 : - { - . = 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 */ - .bss : - { - . = 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*) - *(COMMON) - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - } >RAM - - /* Non-zeroed data section */ - . = ALIGN(4); - .noinit (NOLOAD) : - { - *(.noinit) - } >RAM - - /* collect all uninitialized .ccm sections */ - .ram (NOLOAD) : - { - . = ALIGN(4); - _sram = .; - *(.ram) - } >RAM - - .ccm (NOLOAD) : - { - . = ALIGN(4); - _sccm = .; - *(.ccm) - . = ALIGN(4); - . = . + _Main_Stack_Size; - _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) - *(.sdram*) - *(.sdram_rodata) - *(.sdram_rodata*) - . = ALIGN(4); - _eram = .; - } >SDRAM - - PROVIDE ( end = _eram ); - PROVIDE ( _end = _eram ); - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/radio/src/targets/horus/stm32f4_flash.ld b/radio/src/targets/horus/stm32f4_flash.ld deleted file mode 100644 index a1561cef4..000000000 --- a/radio/src/targets/horus/stm32f4_flash.ld +++ /dev/null @@ -1,189 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32f4_flash.ld -** -** Abstract : Linker script for STM32F439 Device with -** 2MByte FLASH, 192KByte 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 = 0xD0800000; /* end of 8192K SDRAM */ - -/* 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 = 2048K - 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 -} - -/* 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 - - _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 (*(.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 */ - } >CCM - - /* Non-zeroed data section */ - . = ALIGN(4); - .noinit (NOLOAD) : - { - *(.noinit) - } >CCM - - /* collect all uninitialized .ccm sections */ - .ram (NOLOAD) : - { - . = ALIGN(4); - _sram = .; - *(.ram) - } >RAM - - /* 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 - - .sdram (NOLOAD) : - { - *(.sdram) - *(.sdram*) - *(.sdram_rodata) - *(.sdram_rodata*) - . = ALIGN(4); - _eram = .; - } >SDRAM - - PROVIDE ( end = _eram ); - PROVIDE ( _end = _eram ); - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/radio/src/targets/horus/stm32f4_flash_bootloader.ld b/radio/src/targets/horus/stm32f4_flash_bootloader.ld deleted file mode 100644 index d5661a548..000000000 --- a/radio/src/targets/horus/stm32f4_flash_bootloader.ld +++ /dev/null @@ -1,195 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32f4_flash.ld -** -** Abstract : Linker script for STM32F439 Device with -** 2MByte FLASH, 192KByte 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 = 0xD0800000; /* end of 8192K SDRAM */ - -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 4096K; /* required amount of heap */ -_Main_Stack_Size = 8192; /* 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 = 2048K - 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 -} - -/* 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 */ - - . = 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 (*(.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 */ - .bss : - { - . = 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*) - *(COMMON) - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - } >RAM - - /* Non-zeroed data section */ - . = ALIGN(4); - .noinit (NOLOAD) : - { - *(.noinit) - } >RAM - - /* collect all uninitialized .ram sections */ - .ram (NOLOAD) : - { - . = ALIGN(4); - _sram = .; - *(.ram) - } >RAM - - .ccm (NOLOAD) : - { - . = ALIGN(4); - _sccm = .; - *(.ccm) - . = ALIGN(4); - . = . + _Main_Stack_Size; - _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) - *(.sdram*) - *(.sdram_rodata) - *(.sdram_rodata*) - _eram = .; - . = ALIGN(4); - . = . + _Min_Heap_Size; - . = ALIGN(4); - } >SDRAM - - PROVIDE ( end = _eram ); - PROVIDE ( _end = _eram ); - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/radio/src/targets/nv14/CMakeLists.txt b/radio/src/targets/nv14/CMakeLists.txt index 4a3e55214..cc502c930 100644 --- a/radio/src/targets/nv14/CMakeLists.txt +++ b/radio/src/targets/nv14/CMakeLists.txt @@ -21,17 +21,16 @@ set(HARDWARE_EXTERNAL_MODULE YES) set(TARGET_DIR nv14) add_definitions(-DHARDWARE_TRAINER_JACK) -if(BOOTLOADER) - set(LINKER_SCRIPT targets/nv14/stm32f4_flash_bootloader.ld) -else() - set(LINKER_SCRIPT targets/nv14/stm32f4_flash.ld) -endif() - set(RTC_BACKUP_RAM YES) set(PPM_LIMITS_SYMETRICAL YES) + # for size report script set(CPU_TYPE_FULL STM32F429xI) -set(SIZE_TARGET_MEM_DEFINE "MEM_SIZE_SDRAM2=8192") +set(TARGET_LINKER_DIR stm32f429_sdram) +set(TARGET_LINKER_PARAMS "-Wl,--defsym=__SDRAM_START__=0xC0000000") + +set(SIZE_TARGET_MEM_DEFINE "MEM_SIZE_SDRAM1=8192") + option(USB_SERIAL "Enable USB serial (CDC)" ON) set(RF_BAUD_RATE 921600 230400 115200 57600 38400 19200 9600 4800 2400 1200) @@ -68,7 +67,7 @@ set(FLYSKY_GIMBAL ON) add_definitions( -DSTM32F429_439xx -DSTM32F429xx - -DSDRAM -DCOLORLCD -DLIBOPENUI + -DSDRAM -DCCMRAM -DCOLORLCD -DLIBOPENUI -DHARDWARE_TOUCH -DHARDWARE_KEYS) set(SDRAM ON) diff --git a/radio/src/targets/nv14/backlight_driver.cpp b/radio/src/targets/nv14/backlight_driver.cpp index b68c0d259..1533c319f 100644 --- a/radio/src/targets/nv14/backlight_driver.cpp +++ b/radio/src/targets/nv14/backlight_driver.cpp @@ -96,6 +96,5 @@ bool boardBacklightOn; bool isBacklightEnabled() { - if (globalData.unexpectedShutdown) return true; return boardBacklightOn; } diff --git a/radio/src/targets/nv14/board.cpp b/radio/src/targets/nv14/board.cpp index 67522258f..becfd623c 100644 --- a/radio/src/targets/nv14/board.cpp +++ b/radio/src/targets/nv14/board.cpp @@ -27,6 +27,8 @@ #include "hal/adc_driver.h" #include "hal/trainer_driver.h" #include "hal/switch_driver.h" +#include "hal/abnormal_reboot.h" +#include "hal/watchdog_driver.h" #include "globals.h" #include "sdcard.h" @@ -40,7 +42,6 @@ #include "lcd_driver.h" #include "battery_driver.h" #include "touch_driver.h" -#include "watchdog_driver.h" #include "bitmapbuffer.h" #include "colors.h" @@ -59,45 +60,8 @@ extern "C" { // common ADC driver extern const etx_hal_adc_driver_t _adc_driver; -enum PowerReason { - SHUTDOWN_REQUEST = 0xDEADBEEF, - SOFTRESET_REQUEST = 0xCAFEDEAD, -}; - -constexpr uint32_t POWER_REASON_SIGNATURE = 0x0178746F; - -bool UNEXPECTED_SHUTDOWN() -{ -#if defined(SIMU) || defined(NO_UNEXPECTED_SHUTDOWN) - return false; -#else - if (WAS_RESET_BY_WATCHDOG()) - return true; - else if (WAS_RESET_BY_SOFTWARE()) - return RTC->BKP0R != SOFTRESET_REQUEST; - else - return RTC->BKP1R == POWER_REASON_SIGNATURE && RTC->BKP0R != SHUTDOWN_REQUEST; -#endif -} - -void SET_POWER_REASON(uint32_t value) -{ - RTC->BKP0R = value; - RTC->BKP1R = POWER_REASON_SIGNATURE; -} - HardwareOptions hardwareOptions; -void watchdogInit(unsigned int duration) -{ - IWDG->KR = 0x5555; // Unlock registers - IWDG->PR = 3; // Divide by 32 => 1kHz clock - IWDG->KR = 0x5555; // Unlock registers - IWDG->RLR = duration; // 1.5 seconds nominal - IWDG->KR = 0xAAAA; // reload - IWDG->KR = 0xCCCC; // start -} - #if defined(SEMIHOSTING) extern "C" void initialise_monitor_handles(); #endif @@ -310,12 +274,12 @@ void boardOff() if (usbPlugged()) { delay_ms(100); // Add a delay to wait for lcdOff - RTC->BKP0R = SOFTRESET_REQUEST; + // RTC->BKP0R = SOFTRESET_REQUEST; NVIC_SystemReset(); } else { - RTC->BKP0R = SHUTDOWN_REQUEST; + // RTC->BKP0R = SHUTDOWN_REQUEST; pwrOff(); } diff --git a/radio/src/targets/nv14/board.h b/radio/src/targets/nv14/board.h index 29589fc60..af203d5de 100644 --- a/radio/src/targets/nv14/board.h +++ b/radio/src/targets/nv14/board.h @@ -27,9 +27,9 @@ #include "board_common.h" #include "hal.h" -#include "hal/serial_port.h" -#include "watchdog_driver.h" +#include "hal/serial_port.h" +#include "hal/watchdog_driver.h" #define FLASHSIZE 0x200000 #define BOOTLOADER_SIZE 0x20000 @@ -135,17 +135,6 @@ extern HardwareOptions hardwareOptions; #define BATTERY_MIN 35 // 3.5V #define BATTERY_MAX 42 // 4.2V -enum EnumPowerupState -{ - BOARD_POWER_OFF = 0xCAFEDEAD, - BOARD_POWER_ON = 0xDEADBEEF, - BOARD_STARTED = 0xBAADF00D, - BOARD_REBOOT = 0xC00010FF, -}; - -bool UNEXPECTED_SHUTDOWN(); -void SET_POWER_REASON(uint32_t value); - #if defined(__cplusplus) && !defined(SIMU) extern "C" { #endif @@ -196,22 +185,19 @@ void backlightEnable(uint8_t dutyCycle); void backlightFullOn(); bool isBacklightEnabled(); -#define BACKLIGHT_ENABLE() \ - { \ - boardBacklightOn = true; \ - backlightEnable(globalData.unexpectedShutdown \ - ? BACKLIGHT_LEVEL_MAX \ - : BACKLIGHT_LEVEL_MAX - currentBacklightBright); \ +#define BACKLIGHT_ENABLE() \ + { \ + boardBacklightOn = true; \ + backlightEnable(BACKLIGHT_LEVEL_MAX - currentBacklightBright); \ } -#define BACKLIGHT_DISABLE() \ - { \ - boardBacklightOn = false; \ - backlightEnable(globalData.unexpectedShutdown ? BACKLIGHT_LEVEL_MAX \ - : ((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && \ - (g_eeGeneral.backlightMode != e_backlight_mode_off)) \ - ? 0 \ - : g_eeGeneral.blOffBright); \ +#define BACKLIGHT_DISABLE() \ + { \ + boardBacklightOn = false; \ + backlightEnable(((g_eeGeneral.blOffBright == BACKLIGHT_LEVEL_MIN) && \ + (g_eeGeneral.backlightMode != e_backlight_mode_off)) \ + ? 0 \ + : g_eeGeneral.blOffBright); \ } #if !defined(SIMU) diff --git a/radio/src/targets/nv14/startup_stm32f42_43xxx.s b/radio/src/targets/nv14/startup_stm32f42_43xxx.s deleted file mode 100644 index 68671dc34..000000000 --- a/radio/src/targets/nv14/startup_stm32f42_43xxx.s +++ /dev/null @@ -1,565 +0,0 @@ -/** - ****************************************************************************** - * @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. - * 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, - * priority is Privileged, and the Stack is set to Main. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2013 STMicroelectronics

- * - * 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. - * - ****************************************************************************** - */ - - .syntax unified - .cpu cortex-m3 - .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: - - bl pwrResetHandler /*jump to WDT reset handler where soft power control pin is turned on as soon as possible */ - -/* Copy the data segment initializers from flash to SRAM */ - movs r1, #0 - b LoopCopyDataInit - -CopyDataInit: - ldr r3, =_sidata - ldr r3, [r3, r1] - str r3, [r0, r1] - adds r1, r1, #4 - -LoopCopyDataInit: - ldr r0, =_sdata - ldr r3, =_edata - adds r2, r0, r1 - cmp r2, r3 - bcc CopyDataInit - ldr r2, =_sbss - b LoopFillZerobss -/* Zero fill the bss segment. */ -FillZerobss: - movs r3, #0 - str r3, [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 - -/* 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 -.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/targets/nv14/stm32_ramboot.ld b/radio/src/targets/nv14/stm32_ramboot.ld deleted file mode 100644 index b15c1aa04..000000000 --- a/radio/src/targets/nv14/stm32_ramboot.ld +++ /dev/null @@ -1,188 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32f4_flash.ld -** -** Abstract : Linker script for STM32F439 Device with -** 2MByte FLASH, 192KByte 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 = 0x2002FFF0; /* end of 192K RAM */ -_heap_end = 0xC0800000; /* end of 8192K SDRAM */ - -/* 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 = 2048K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K - CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 65520 - NO_INIT (xrw) : ORIGIN = 0x1000FFF0, LENGTH = 16 - MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K - SDRAM(xrw) : ORIGIN = 0xC0000000, LENGTH = 8192K -} - -/* 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 */ - } >CCM - - /* 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 */ - } >CCM - - /* Non-zeroed data section */ - . = ALIGN(4); - .noinit (NOLOAD) : - { - *(.noinit) - } >NO_INIT - - - /* collect all uninitialized .ccm sections */ - .ram (NOLOAD) : - { - . = ALIGN(4); - _sram = .; - *(.ram) - } >RAM - - /* 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 - - .sdram (NOLOAD) : - { - *(.sdram) - *(.sdram*) - *(.sdram_rodata) - *(.sdram_rodata*) - . = ALIGN(4); - _eram = .; - } >SDRAM - - PROVIDE ( end = _eram ); - PROVIDE ( _end = _eram ); - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/radio/src/targets/nv14/stm32f4_flash.ld b/radio/src/targets/nv14/stm32f4_flash.ld deleted file mode 100644 index ac5c7ef74..000000000 --- a/radio/src/targets/nv14/stm32f4_flash.ld +++ /dev/null @@ -1,197 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32f4_flash.ld -** -** Abstract : Linker script for STM32F439 Device with -** 2MByte FLASH, 192KByte 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 */ -_heap_end = 0xC0800000; /* end of 8192K SDRAM */ - -/* 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 = 2048K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K - CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 65520 - NO_INIT (xrw) : ORIGIN = 0x1000FFF0, LENGTH = 16 - MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K - SDRAM(xrw) : ORIGIN = 0xC0000000, LENGTH = 8192K -} - -/* Main stack end */ -_estack = 0x10000000 + LENGTH(CCM); -_main_stack_start = _estack - _Main_Stack_Size; - -/* 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 - - - - - _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 (*(.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 */ - } >CCM - - /* 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 */ - } >CCM - - /* Non-zeroed data section */ - . = ALIGN(4); - .noinit (NOLOAD) : - { - *(.noinit) - } >NO_INIT - - - /* collect all uninitialized .ccm sections */ - .ram (NOLOAD) : - { - . = ALIGN(4); - _sram = .; - *(.ram) - } >RAM - - /* 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 - - .sdram (NOLOAD) : - { - *(.sdram) - *(.sdram*) - *(.sdram_rodata) - *(.sdram_rodata*) - . = ALIGN(4); - _eram = .; - } >SDRAM - - PROVIDE ( end = _eram ); - PROVIDE ( _end = _eram ); - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/radio/src/targets/nv14/stm32f4_flash_bootloader.ld b/radio/src/targets/nv14/stm32f4_flash_bootloader.ld deleted file mode 100644 index 5160bfd9e..000000000 --- a/radio/src/targets/nv14/stm32f4_flash_bootloader.ld +++ /dev/null @@ -1,195 +0,0 @@ -/* -***************************************************************************** -** -** File : stm32f4_flash.ld -** -** Abstract : Linker script for STM32F439 Device with -** 2MByte FLASH, 192KByte 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 = 0xC0800000; /* end of 8192K SDRAM */ - -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 4096K; /* required amount of heap */ -_Main_Stack_Size = 8192; /* 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 = 2048K - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K - CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K - MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K - SDRAM(xrw) : ORIGIN = 0xC0000000, LENGTH = 8192K -} - -/* 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 */ - - . = 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 (*(.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 */ - .bss : - { - . = 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*) - *(COMMON) - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - } >RAM - - /* Non-zeroed data section */ - . = ALIGN(4); - .noinit (NOLOAD) : - { - *(.noinit) - } >RAM - - /* collect all uninitialized .ccm sections */ - .ram (NOLOAD) : - { - . = ALIGN(4); - _sram = .; - *(.ram) - } >RAM - - .ccm (NOLOAD) : - { - . = ALIGN(4); - _sccm = .; - *(.ccm) - . = ALIGN(4); - . = . + _Main_Stack_Size; - _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) - *(.sdram*) - *(.sdram_rodata) - *(.sdram_rodata*) - _eram = .; - . = ALIGN(4); - . = . + _Min_Heap_Size; - . = ALIGN(4); - } >SDRAM - - PROVIDE ( end = _eram ); - PROVIDE ( _end = _eram ); - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} diff --git a/radio/src/targets/simu/CMakeLists.txt b/radio/src/targets/simu/CMakeLists.txt index 0a64d99fe..8b63fe4c6 100644 --- a/radio/src/targets/simu/CMakeLists.txt +++ b/radio/src/targets/simu/CMakeLists.txt @@ -19,6 +19,7 @@ set(SIMU_DRIVERS gyro_driver.cpp bt_driver.cpp timers_driver.cpp + abnormal_reboot.cpp ) set(HW_DESC_JSON ${FLAVOUR}.json) diff --git a/radio/src/targets/simu/abnormal_reboot.cpp b/radio/src/targets/simu/abnormal_reboot.cpp new file mode 100644 index 000000000..e63175d86 --- /dev/null +++ b/radio/src/targets/simu/abnormal_reboot.cpp @@ -0,0 +1,27 @@ +/* + * 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 "hal/abnormal_reboot.h" + +uint32_t abnormalRebootGetCause() +{ + return ARC_None; +} diff --git a/radio/src/targets/taranis/CMakeLists.txt b/radio/src/targets/taranis/CMakeLists.txt index eb9312f8f..7fc9ef211 100644 --- a/radio/src/targets/taranis/CMakeLists.txt +++ b/radio/src/targets/taranis/CMakeLists.txt @@ -215,7 +215,7 @@ elseif(PCB STREQUAL X7) set(MODULE_SIZE_STD YES) set(FLAVOUR tx12mk2) set(NAVIGATION_TYPE x7) - set(CPU_TYPE_FULL STM32F407xE) + set(CPU_TYPE_FULL STM32F413xG) set(ROTARY_ENCODER YES) set(USB_CHARGER YES) if (NOT BLUETOOTH) @@ -460,22 +460,22 @@ elseif(PCB STREQUAL XLITES) add_definitions(-DMANUFACTURER_FRSKY) endif() +message("CPU_TYPE_FULL = ${CPU_FULL_TYPE}") if(CPU_TYPE_FULL STREQUAL STM32F205xE) set(CPU_TYPE STM32F2) add_definitions(-DSTM32F205xx) - set(LINKER_SCRIPT targets/taranis/stm32f2_flash.ld) -elseif (CPU_TYPE_FULL STREQUAL STM32F407xE) + set(TARGET_LINKER_DIR stm32f20x) +elseif ((CPU_TYPE_FULL STREQUAL STM32F407xE) OR (CPU_TYPE_FULL STREQUAL STM32F407xG)) set(CPU_TYPE STM32F4) - 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) + add_definitions(-DSTM32F40_41xxx -DSTM32F407xx -DCCMRAM) + set(TARGET_LINKER_DIR stm32f40x) + if (CPU_TYPE_FULL STREQUAL STM32F407xG) + set(TARGET_FLASH_SIZE 1M) + endif() elseif (CPU_TYPE_FULL STREQUAL STM32F413xG) set(CPU_TYPE STM32F4) add_definitions(-DSTM32F40_41xxx -DSTM32F413xx) - set(LINKER_SCRIPT targets/taranis/stm32f413_flash.ld) + set(TARGET_LINKER_DIR stm32f413) else() message( FATAL_ERROR "Unknown CPU_TYPE_FULL" ) endif() diff --git a/radio/src/targets/taranis/board.cpp b/radio/src/targets/taranis/board.cpp index 228b0ccf2..882e3bf56 100644 --- a/radio/src/targets/taranis/board.cpp +++ b/radio/src/targets/taranis/board.cpp @@ -25,6 +25,7 @@ #include "hal/trainer_driver.h" #include "hal/switch_driver.h" #include "hal/module_port.h" +#include "hal/abnormal_reboot.h" #include "board.h" #include "boards/generic_stm32/module_ports.h" @@ -62,26 +63,8 @@ extern "C" { } #endif -#if !defined(BOOT) -bool UNEXPECTED_SHUTDOWN() -{ - return WAS_RESET_BY_WATCHDOG() - || g_eeGeneral.unexpectedShutdown; -} -#endif - HardwareOptions hardwareOptions; -void watchdogInit(unsigned int duration) -{ - IWDG->KR = 0x5555; // Unlock registers - IWDG->PR = 3; // Divide by 32 => 1kHz clock - IWDG->KR = 0x5555; // Unlock registers - IWDG->RLR = duration; - IWDG->KR = 0xAAAA; // reload - IWDG->KR = 0xCCCC; // start -} - #if !defined(BOOT) #if defined(FUNCTION_SWITCHES) diff --git a/radio/src/targets/taranis/board.h b/radio/src/targets/taranis/board.h index d830df0fe..26bfff7d1 100644 --- a/radio/src/targets/taranis/board.h +++ b/radio/src/targets/taranis/board.h @@ -25,7 +25,7 @@ #include #include "hal.h" #include "hal/serial_port.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" #include "definitions.h" #include "opentx_constants.h" @@ -215,8 +215,6 @@ uint32_t pwrPressedDuration(); void pwrResetHandler(); #define pwrForcePressed() false -bool UNEXPECTED_SHUTDOWN(); - // Backlight driver #if defined(OLED_SCREEN) #define BACKLIGHT_DISABLE() lcdSetRefVolt(0) diff --git a/radio/src/targets/taranis/lcd_driver_aspi.cpp b/radio/src/targets/taranis/lcd_driver_aspi.cpp index ade0d3025..39b3b3951 100644 --- a/radio/src/targets/taranis/lcd_driver_aspi.cpp +++ b/radio/src/targets/taranis/lcd_driver_aspi.cpp @@ -21,6 +21,7 @@ #include "board.h" #include "lcd.h" +#include "hal/abnormal_reboot.h" #if !defined(BOOT) #include "myeeprom.h" diff --git a/radio/src/targets/taranis/lcd_driver_spi.cpp b/radio/src/targets/taranis/lcd_driver_spi.cpp index 0b40ee587..2f8f9ee35 100644 --- a/radio/src/targets/taranis/lcd_driver_spi.cpp +++ b/radio/src/targets/taranis/lcd_driver_spi.cpp @@ -23,6 +23,8 @@ #include "debug.h" #include "lcd.h" +#include "hal/abnormal_reboot.h" + #if !defined(BOOT) #include "opentx.h" #endif diff --git a/radio/src/targets/taranis/stm32_ramboot.ld b/radio/src/targets/taranis/stm32_ramboot.ld deleted file mode 100644 index 94c7d3e2d..000000000 --- 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 04fb20683..000000000 --- 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 8c98ab1ea..000000000 --- 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_512k_flash.ld b/radio/src/targets/taranis/stm32f4_512k_flash.ld deleted file mode 100644 index 70c9b7e02..000000000 --- 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 11ec821b2..cc1d3ef6d 100644 --- a/radio/src/tasks.cpp +++ b/radio/src/tasks.cpp @@ -21,11 +21,12 @@ #include "opentx.h" #include "timers_driver.h" +#include "hal/abnormal_reboot.h" +#include "hal/watchdog_driver.h" #include "tasks.h" #include "tasks/mixer_task.h" -#include "watchdog_driver.h" RTOS_TASK_HANDLE menusTaskId; RTOS_DEFINE_STACK(menusTaskId, menusStack, MENUS_STACK_SIZE); diff --git a/radio/src/tasks/mixer_task.cpp b/radio/src/tasks/mixer_task.cpp index 0e4bdd887..eaf762f11 100644 --- a/radio/src/tasks/mixer_task.cpp +++ b/radio/src/tasks/mixer_task.cpp @@ -26,7 +26,7 @@ #include "opentx.h" #include "switches.h" -#include "watchdog_driver.h" +#include "hal/watchdog_driver.h" RTOS_TASK_HANDLE mixerTaskId; RTOS_DEFINE_STACK(mixerTaskId, mixerStack, MIXER_STACK_SIZE);