Skip to content

Commit

Permalink
STM32 platform upgrade (#1169)
Browse files Browse the repository at this point in the history
* Update base platform to v15

Upgrade all the STM32 variant files
Adding -flto to targets that don't fit in flash on platform v15

* Adjust bootloader to support upgraded main firmware platform

* Rebuild of bootloader firmware to support updated main platform

* add monitor speed for stm32

* correct NamimnoRC Flash BL

* Fix another couple of bootloader upload commands

Co-authored-by: StonedDawg <st.kenneth93@gmail.com>
Co-authored-by: Jye <JyeSmith@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 22, 2021
1 parent 4540c15 commit 7f25cd8
Show file tree
Hide file tree
Showing 66 changed files with 101 additions and 39 deletions.
Binary file removed src/bootloader/bootloader_sx1280_rx_ccg_nano_v05.bin
Binary file not shown.
Binary file modified src/bootloader/fm30_mini_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/fm30_mini_rxtx_bootloader.bin
Binary file not shown.
Binary file added src/bootloader/ghost/ghost_atto_bootloader.bin
Binary file not shown.
Binary file removed src/bootloader/ghost/ghost_atto_v1.2_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/ghost/ghost_tx_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/jumper_r900_bootloader.bin
Binary file not shown.
Binary file removed src/bootloader/jumper_r900_bootloader_no_btn.bin
Binary file not shown.
Binary file added src/bootloader/jumper_r900_no_btn_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/namimnorc/rx/flash_2400_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/namimnorc/rx/voyager_900_bootloader.bin
Binary file not shown.
Binary file removed src/bootloader/namimnorc/tx/firmware.bin
Binary file not shown.
Binary file not shown.
Binary file modified src/bootloader/r9m_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/r9m_elrs_bl.frk
Binary file not shown.
Binary file modified src/bootloader/r9m_lite_pro_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/r9mm_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/r9mm_elrs_bl.frk
Binary file not shown.
Binary file modified src/bootloader/r9mm_no_btn_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/r9mm_no_btn_elrs_bl.frk
Binary file not shown.
Binary file modified src/bootloader/r9mx_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/r9mx_elrs_bl.frk
Binary file not shown.
Binary file modified src/bootloader/r9mx_no_btn_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/r9mx_no_btn_elrs_bl.frk
Binary file not shown.
Binary file added src/bootloader/r9slim_bootloader.bin
Binary file not shown.
Binary file added src/bootloader/r9slim_elrs_bl.frk
Binary file not shown.
Binary file modified src/bootloader/r9slim_no_btn_bootloader.bin
Binary file not shown.
Binary file added src/bootloader/r9slim_no_btn_elrs_bl.frk
Binary file not shown.
Binary file modified src/bootloader/r9slim_plus_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/r9slim_plus_elrs_bl.frk
Binary file not shown.
Binary file added src/bootloader/r9slim_plus_no_btn_bootloader.bin
Binary file not shown.
Binary file added src/bootloader/r9slim_plus_no_btn_elrs_bl.frk
Binary file not shown.
Binary file modified src/bootloader/r9slim_plus_ota_bootloader.bin
Binary file not shown.
Binary file modified src/bootloader/r9slim_plus_ota_elrs_bl.frk
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions src/bootloader/src/Src/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ int8_t flash_check_app_loaded(void)
uintptr_t app_reset = *(volatile uintptr_t *)(FLASH_APP_START_ADDRESS + 4u);
uintptr_t app_nmi = *(volatile uintptr_t *)(FLASH_APP_START_ADDRESS + 8u);
if (((uint16_t)(app_stack >> 20) == 0x200) &&
((uint16_t)(app_reset >> 16) == 0x0800) &&
((uint16_t)(app_nmi >> 16) == 0x0800)) {
((uint16_t)((app_reset >> 16) & 0xFFFC) == 0x0800) &&
((uint16_t)((app_nmi >> 16) & 0xFFFC) == 0x0800)) {
return 0;
}
return -1;
Expand Down
2 changes: 1 addition & 1 deletion src/bootloader/src/Src/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void USARTx_IRQ_handler(USART_TypeDef * uart)
uint8_t data = (uint8_t)LL_USART_ReceiveData8(uart);
// If RX is in interrupt mode, the RX not-empty bit is set, and the received byte
// has no framing errors (framing errors still generate RXNE), add to the RX fifo
if ((CR & USART_CR1_RXNEIE) && (SR & USART_SR_RXNE) && !(SR & USART_ISR_FE)) {
if ((CR & USART_CR1_RXNEIE) && (SR & USART_SR_RXNE) && !(SR & USART_SR_FE)) {
uint8_t next = rx_head;
if ((next + 1) != rx_tail) {
rx_buffer[rx_head++] = data;
Expand Down
6 changes: 3 additions & 3 deletions src/bootloader/src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ src_dir = Src
lib_dir = Drivers

[env]
#platform = ststm32@7.2.0
platform = ststm32 #@8.1.0
#platform = ststm32 @8.1.0
platform = ststm32 @9.0.0
framework = stm32cube
build_unflags = -nostartfiles -nostdlib
board_build.ldscript = linker/stm32.ld
Expand All @@ -16,7 +16,7 @@ debug_tool = stlink
monitor_speed = 420000

[generic]
VERSION = -D BOOTLOADER_VERSION=0.5.3
VERSION = -D BOOTLOADER_VERSION=0.5.4
flags_hal =
${generic.VERSION}
-Wl,-Map,firmware.map
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/lib/EEPROM/elrs_eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
extEEPROM EEPROM(kbits_2, 1, 1, TARGET_EEPROM_ADDR);
#else
#define STM32_USE_FLASH
#include <stm32_eeprom.h>
#include <utility/stm32_eeprom.h>
#endif
#else
#include <EEPROM.h>
Expand Down
3 changes: 2 additions & 1 deletion src/targets/common.ini
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bf_upload_command =

# ------------------------- COMMON STM32 DEFINITIONS -----------------
[env_common_stm32]
platform = ststm32@8.0.0
platform = ststm32@15.1.0
board = bluepill_f103c8
build_unflags = -Os
build_flags =
Expand All @@ -88,3 +88,4 @@ build_flags =
src_filter = ${common_env_data.src_filter} -<ESP32*.*> -<ESP8266*.*> -<WS281B*.*>
lib_deps =
paolop74/extEEPROM @ ^3.4.1
monitor_speed = 420000
7 changes: 3 additions & 4 deletions src/targets/diy_2400.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ build_flags =
-D VTABLES_IN_FLASH=1
-O2
src_filter = ${env_common_esp32.src_filter} -<rx_*.cpp>
lib_deps =
lib_deps =
${env_common_esp32.lib_deps}
olikraus/U8g2@^2.28.8

Expand All @@ -41,7 +41,7 @@ build_flags =
-D VTABLES_IN_FLASH=1
-O2
src_filter = ${env_common_esp32.src_filter} -<rx_*.cpp>
lib_deps =
lib_deps =
${env_common_esp32.lib_deps}
olikraus/U8g2@^2.28.8

Expand Down Expand Up @@ -92,7 +92,6 @@ extends = env:DIY_2400_RX_PWMP_via_UART

[env:DIY_2400_RX_STM32_CCG_Nano_v0_5_via_STLINK]
extends = env_common_stm32, radio_2400
platform = ststm32@9.0.0
board = l432kb
# max size = 131072 - 0x4000 = 114688
board_upload.maximum_size = 114688
Expand All @@ -113,7 +112,7 @@ build_flags =
-Wl,--defsym=FLASH_APP_OFFSET=16K
src_filter = ${env_common_stm32.src_filter} -<tx_*.cpp>
upload_flags =
BOOTLOADER=bootloader/bootloader_sx1280_rx_ccg_nano_v05.bin
BOOTLOADER=bootloader/sx1280_rx_nano_pcb_v0.5_bootloader.bin
VECT_OFFSET=0x4000

[env:DIY_2400_RX_STM32_CCG_Nano_v0_5_via_BetaflightPassthrough]
Expand Down
2 changes: 1 addition & 1 deletion src/targets/diy_900.ini
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ upload_speed = 420000
upload_command = ${env_common_esp82xx.bf_upload_command}

[env:DIY_900_RX_HUZZAH_RFM95W_via_WIFI]
extends = DIY_900_RX_HUZZAH_RFM95W_via_UART
extends = env:DIY_900_RX_HUZZAH_RFM95W_via_UART

[env:DIY_900_RX_PWMP_via_UART]
extends = env_common_esp82xx
Expand Down
4 changes: 1 addition & 3 deletions src/targets/frsky.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
## TODO: R9M STLINK/stock and R9M Lite targets can be merged
[env:Frsky_TX_R9M_via_STLINK]
extends = env_common_stm32, radio_900
platform = ststm32@15.1.0
build_flags =
${env_common_stm32.build_flags}
${common_env_data.build_flags_tx}
Expand Down Expand Up @@ -35,6 +34,7 @@ extends = env:Frsky_TX_R9M_via_STLINK
build_flags =
${env_common_stm32.build_flags}
${common_env_data.build_flags_tx}
${radio_900.build_flags}
-include target/Frsky_TX_R9M_LITE.h
-flto
-D HSE_VALUE=12000000U
Expand All @@ -45,15 +45,13 @@ extends = env:Frsky_TX_R9M_LITE_via_STLINK

[env:Frsky_TX_R9M_LITE_PRO_via_STLINK]
extends = env_common_stm32, radio_900
platform = ststm32@9.0.0
board = robotdyn_blackpill_f303cc
build_flags =
${env_common_stm32.build_flags}
${common_env_data.build_flags_tx}
${radio_900.build_flags}
-include target/Frsky_TX_R9M_LITE_PRO.h
-D HSE_VALUE=12000000U
-O2
-DVECT_TAB_OFFSET=0x8000U
board_build.ldscript = variants/R9M_Lite_Pro_ldscript.ld
board_build.flash_offset = 0x8000
Expand Down
1 change: 0 additions & 1 deletion src/targets/happymodel_900.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

[env:HappyModel_TX_ES915TX_via_STLINK]
extends = env_common_stm32, radio_900
platform = ststm32@15.1.0
build_flags =
${env_common_stm32.build_flags}
${common_env_data.build_flags_tx}
Expand Down
4 changes: 1 addition & 3 deletions src/targets/imrc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

[env:GHOST_2400_TX_via_STLINK]
extends = env_common_stm32, radio_2400
platform = ststm32@11.0.0
board = GHOST_TX
build_flags =
${env_common_stm32.build_flags}
Expand Down Expand Up @@ -36,7 +35,6 @@ build_flags =

[env:GHOST_ATTO_2400_RX_via_STLINK]
extends = env_common_stm32, radio_2400
platform = ststm32@11.0.0
board = GHOST_ATTO
build_flags =
${env_common_stm32.build_flags}
Expand All @@ -50,7 +48,7 @@ src_filter = ${env_common_stm32.src_filter} -<tx_*.cpp>
lib_deps =
lib_ignore = Servo
upload_flags =
BOOTLOADER=bootloader/ghost/ghost_atto_v1.2_bootloader.bin
BOOTLOADER=bootloader/ghost/ghost_atto_bootloader.bin
VECT_OFFSET=0x4000

[env:GHOST_ATTO_2400_RX_via_BetaflightPassthrough]
Expand Down
2 changes: 1 addition & 1 deletion src/targets/namimnorc_2400.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ build_flags =
board_build.ldscript = variants/NamimnoRC_Alpha.ld
src_filter = ${env_common_stm32.src_filter} -<rx_*.cpp>
upload_flags =
BOOTLOADER=bootloader/namimnorc/tx/firmware.bin
BOOTLOADER=bootloader/namimnorc/tx/namimnorc_tx_bootloader.bin
VECT_OFFSET=0x4000

[env:NamimnoRC_FLASH_2400_TX_via_WIFI]
Expand Down
7 changes: 4 additions & 3 deletions src/targets/namimnorc_900.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ build_flags =
${env_common_stm32.build_flags}
${common_env_data.build_flags_tx}
${radio_900.build_flags}
-include target/NamimnoRC_VOYAGER_900_TX.h
-flto
-D HSE_VALUE=12000000U
-D VECT_TAB_OFFSET=0x4000U
-include target/NamimnoRC_VOYAGER_900_TX.h
board_build.ldscript = variants/NamimnoRC_Alpha.ld
src_filter = ${env_common_stm32.src_filter} -<rx_*.cpp>
upload_flags =
Expand All @@ -24,14 +25,14 @@ extends = env:NamimnoRC_VOYAGER_900_TX_via_STLINK

[env:NamimnoRC_VOYAGER_900_OLED_TX_via_UART]
extends = env_common_esp32
build_flags =
build_flags =
${env_common_esp32.build_flags}
${common_env_data.build_flags_tx}
-include target/NamimnoRC_VOYAGER_900_OLED_TX.h
-D VTABLES_IN_FLASH=1
-O2
src_filter = ${env_common_esp32.src_filter} -<rx_*.cpp>
lib_deps =
lib_deps =
${env_common_esp32.lib_deps}
olikraus/U8g2@^2.28.8

Expand Down
2 changes: 0 additions & 2 deletions src/targets/siyi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ extends = env:FM30_TX_via_STLINK

[env:FM30_RX_MINI_via_STLINK]
extends = env_common_stm32, radio_2400
platform = ststm32@13.0.0
board = FM30_mini
build_flags =
${env_common_stm32.build_flags}
Expand All @@ -50,7 +49,6 @@ extends = env:FM30_RX_MINI_via_STLINK

[env:FM30_RX_MINI_AS_TX_via_STLINK]
extends = env_common_stm32, radio_2400
platform = ststm32@13.0.0
board = FM30_mini
build_flags =
${env_common_stm32.build_flags}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ const PinName digitalPin[] = {
PA_14, //D34 - SWCLK
};

// If analog pins are not contiguous in the digitalPin array:
// Add the analogInputPin array without defining NUM_ANALOG_FIRST
// Analog (Ax) pin number array
// where x is the index to retrieve the digital pin number
const uint32_t analogInputPin[] = {
PA0,
PA1,
PA2,
PA3,
PA4,
PA5,
PA6,
PA7,
PB0,
PB1
};
#ifdef __cplusplus
}
#endif
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/variants/FM30_mini/PeripheralPins.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,6 @@ WEAK const PinMap PinMap_USB[] = {
//*** No SD ***

//*** PWM ***
WEAK const PinMap PinMap_PWM[] = {
{NC, NP, 0}
};
// WEAK const PinMap PinMap_PWM[] = {
// {NC, NP, 0}
// };
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ extern "C" {
// Extra HAL modules
//#define HAL_DAC_MODULE_ENABLED

#define ALT1 (1 << (STM_PIN_AFNUM_SHIFT+0))
#define ALT2 (1 << (STM_PIN_AFNUM_SHIFT+1))
#define ALT3 (1 << (STM_PIN_AFNUM_SHIFT+2))
#define ALT4 (1 << (STM_PIN_AFNUM_SHIFT+3))
// #define ALT1 (1 << (STM_PIN_AFNUM_SHIFT+0))
// #define ALT2 (1 << (STM_PIN_AFNUM_SHIFT+1))
// #define ALT3 (1 << (STM_PIN_AFNUM_SHIFT+2))
// #define ALT4 (1 << (STM_PIN_AFNUM_SHIFT+3))

// Adjust IRQ priority
#define TIM_IRQ_PRIO 4
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ const PinName digitalPin[] = {
PA_14, //D34 - SWCLK
};

// If analog pins are not contiguous in the digitalPin array:
// Add the analogInputPin array without defining NUM_ANALOG_FIRST
// Analog (Ax) pin number array
// where x is the index to retrieve the digital pin number
const uint32_t analogInputPin[] = {
20,
21,
22,
23, // Not sure about this one beecasue NUM is 9 in the header, and this is RCX
24,
25,
26,
27,
28,
29
};

#ifdef __cplusplus
}
#endif
Expand All @@ -87,7 +104,7 @@ WEAK void SystemClock_Config(void)

RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInit;
// RCC_PeriphCLKInitTypeDef PeriphClkInit;

/**Initializes the CPU, AHB and APB busses clocks
*/
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ const PinName digitalPin[] = {
PA_15 //D22 - STLink Rx
};

// If analog pins are not contiguous in the digitalPin array:
// Add the analogInputPin array without defining NUM_ANALOG_FIRST
// Analog (Ax) pin number array
// where x is the index to retrieve the digital pin number
const uint32_t analogInputPin[] = {
PA0,
PA1,
PA3,
PA4,
PA5,
PA6,
PA7
};

#ifdef __cplusplus
}
#endif
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,27 @@ const PinName digitalPin[] = {
PC_5 //D59/A13 = D35
};

// If analog pins are not contiguous in the digitalPin array:
// Add the analogInputPin array without defining NUM_ANALOG_FIRST
// Analog (Ax) pin number array
// where x is the index to retrieve the digital pin number
const uint32_t analogInputPin[] = {
PA0,
PA1,
PA4,
PB0,
PC1,
PC0,
PA7,
PA6,
PA5,
PC2,
PC3,
PB1,
PC4,
PC5
};

#ifdef __cplusplus
}
#endif
Expand All @@ -118,8 +139,8 @@ extern "C" {
* @param None
* @retval None
*/
//64MHZ Internal Clock

//64MHZ Internal Clock
// WEAK void SystemClock_Config(void)
// {
// RCC_OscInitTypeDef RCC_OscInitStruct;
Expand Down Expand Up @@ -162,8 +183,8 @@ void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Initializes the CPU, AHB and APB busses clocks

/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
Expand All @@ -176,7 +197,7 @@ void SystemClock_Config(void)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB busses clocks
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 7f25cd8

Please sign in to comment.