Skip to content

Commit

Permalink
started Cortexd M0 bootloader integration
Browse files Browse the repository at this point in the history
  • Loading branch information
gagarinlg committed Nov 26, 2022
1 parent c27bd91 commit 42b0dc8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/bootloader/src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,11 @@ build_flags =
# STK500 (OpenTX)= UART2
-D STK500=1
-D UART_TX_PIN="A,2"
# -D UART_RX_PIN="A,3"
-D UART_RX_PIN="A,3"
-D UART_INV=1
-D UART_TX_PIN_2ND="A,9"
-D UART_RX_PIN_2ND="A,10"
-D UART_BAUD=57600
-D UART_INV=1
-D FLASH_APP_OFFSET=0x2000u
-Wl,--defsym=RAM_SIZE=8K
-Wl,--defsym=FLASH_SIZE=65K
Expand Down
3 changes: 2 additions & 1 deletion src/targets/flysky.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ debug_tool = jlink
upload_tool = jlink
board_build.ldscript = variants/FRM301/ldscript.ld
build_flags =
-g
${env_common_stm32.build_flags}
${common_env_data.build_flags_tx}
${radio_2400.build_flags}
-include target/FRM301_TX.h
#-DHSE_VALUE=12000000U
-DVECT_TAB_OFFSET=0x2000U
-D VECT_TAB_OFFSET=0x2000U
-Wl,--defsym=FLASH_APP_OFFSET=0x2000
#-D SERIAL_UART_INSTANCE=2 # Remap default Serial to USART2
#-D PIN_SERIAL_RX=PA3
Expand Down
6 changes: 6 additions & 0 deletions src/variants/FRM301/ldscript.ld
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ _Min_Stack_Size = 0x400 ; /* required amount of stack */
/* Memories definition */
MEMORY
{
VTRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0xC0
RAM (xrw) : ORIGIN = 0x200000C0, LENGTH = 8K - 0xC0 /* leave room for the vector table */
FLASH (rx) : ORIGIN = 0x8000000 + + FLASH_APP_OFFSET, LENGTH = 64K - + FLASH_APP_OFFSET
}
Expand Down Expand Up @@ -120,6 +121,11 @@ SECTIONS
. = ALIGN(4);
} >FLASH

.RAMVectorTable(NOLOAD):
{
KEEP(*(.RAMVectorTable))
} > VTRAM

/* Used by the startup to initialize data */
_sidata = LOADADDR(.data);

Expand Down
19 changes: 19 additions & 0 deletions src/variants/FRM301/variant_FRM301.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,25 @@ WEAK void SystemClock_Config(void)
//}
}

#ifndef FLASH_BASE
#define FLASH_BASE ((uint32_t)0x08000000u)
#endif
#define FLASH_VECTOR_TAB_START_ADDRESS (FLASH_BASE + VECT_TAB_OFFSET)

volatile uint32_t VectorTable[48] __attribute__((section(".RAMVectorTable")));

void __attribute__((used)) initVariant(void)
{
uint32_t vecIndex = 0;

for(vecIndex = 0; vecIndex < 48; vecIndex++){
VectorTable[vecIndex] = *(volatile uint32_t*)(FLASH_VECTOR_TAB_START_ADDRESS + (vecIndex << 2));
}
__disable_irq();
__HAL_SYSCFG_REMAPMEMORY_SRAM();
__enable_irq();

}
#ifdef __cplusplus
}
#endif

0 comments on commit 42b0dc8

Please sign in to comment.