From 29b1e3409986539a7407ece32238b0a454745038 Mon Sep 17 00:00:00 2001 From: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Date: Sun, 12 May 2024 11:11:47 +0200 Subject: [PATCH 1/7] refactor: bootloader & cmake cleanup --- radio/src/CMakeLists.txt | 15 +- radio/src/boards/generic_stm32/CMakeLists.txt | 1 + radio/src/boards/generic_stm32/bl_keys.cpp | 24 +++ radio/src/fonts/CMakeLists.txt | 7 +- radio/src/gui/128x64/CMakeLists.txt | 24 ++- radio/src/gui/212x64/CMakeLists.txt | 12 ++ radio/src/gui/colorlcd/CMakeLists.txt | 48 +++-- radio/src/hal/CMakeLists.txt | 7 +- .../targets/common/arm/stm32/CMakeLists.txt | 22 --- .../arm/stm32/bootloader/CMakeLists.txt | 123 ++---------- .../common/arm/stm32/bootloader/boot.cpp | 72 +++---- radio/src/targets/horus/CMakeLists.txt | 176 ++++++++++-------- radio/src/targets/horus/board.h | 2 + radio/src/targets/horus/cst8xx_driver.cpp | 15 +- .../src/targets/horus/lcd_st7796s_driver.cpp | 5 +- radio/src/targets/nv14/CMakeLists.txt | 92 ++++----- radio/src/targets/nv14/board.cpp | 2 +- radio/src/targets/nv14/board.h | 6 +- radio/src/targets/pl18/CMakeLists.txt | 93 ++++----- radio/src/targets/pl18/board.cpp | 2 +- radio/src/targets/pl18/board.h | 6 +- radio/src/targets/taranis/CMakeLists.txt | 130 +++++++------ radio/src/targets/taranis/board.h | 12 ++ .../thirdparty/libopenui/src/CMakeLists.txt | 10 +- .../libopenui/thirdparty/CMakeLists.txt | 45 +---- 25 files changed, 452 insertions(+), 499 deletions(-) create mode 100644 radio/src/boards/generic_stm32/bl_keys.cpp diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index ffa760b8007..0c6f11a8b71 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -254,6 +254,11 @@ if(SDCARD) set(FIRMWARE_SRC ${FIRMWARE_SRC}) endif() +if(BLUETOOTH) + add_definitions(-DBLUETOOTH) + set(SRC ${SRC} bluetooth.cpp) +endif() + if(SHUTDOWN_CONFIRMATION) add_definitions(-DSHUTDOWN_CONFIRMATION) endif() @@ -431,11 +436,11 @@ endif() if(USBJ_EX) add_definitions(-DUSBJ_EX) - set(SRC - ${SRC} + set(SRC ${SRC} usb_joystick.cpp - ) + ) endif() + foreach(FILE ${TARGET_SRC}) set(SRC targets/${TARGET_DIR}/${FILE} ${SRC}) endforeach() @@ -463,7 +468,6 @@ else() endif() if(NATIVE_BUILD) - set(RADIOLIB_NATIVE_SRC ${SRC}) if(SIMU_DISKIO) set(RADIOLIB_NATIVE_SRC ${RADIOLIB_NATIVE_SRC} @@ -472,7 +476,8 @@ if(NATIVE_BUILD) # Pack all radio sources into an object lib add_library(radiolib_native OBJECT EXCLUDE_FROM_ALL - ${RADIOLIB_NATIVE_SRC}) + ${RADIOLIB_NATIVE_SRC} + ) # Add -DSIMU here PUBLIC, so it can be imported by other targets # via INTERFACE_COMPILE_OPTIONS diff --git a/radio/src/boards/generic_stm32/CMakeLists.txt b/radio/src/boards/generic_stm32/CMakeLists.txt index d1492a863f8..dccc90585a5 100644 --- a/radio/src/boards/generic_stm32/CMakeLists.txt +++ b/radio/src/boards/generic_stm32/CMakeLists.txt @@ -13,6 +13,7 @@ set(MINIMAL_BOARD_LIB_SRC boards/generic_stm32/inputs.cpp boards/generic_stm32/i2c_bus.cpp + boards/generic_stm32/bl_keys.cpp ) # Dependencies only used in firmware diff --git a/radio/src/boards/generic_stm32/bl_keys.cpp b/radio/src/boards/generic_stm32/bl_keys.cpp new file mode 100644 index 00000000000..3ce9aa136c9 --- /dev/null +++ b/radio/src/boards/generic_stm32/bl_keys.cpp @@ -0,0 +1,24 @@ +#include "board.h" +#include "hal/key_driver.h" + +#if defined(BOOTLOADER_KEYS) + +bool boardBLStartCondition() +{ + // Trims combo activated + bool result = (readTrims() == BOOTLOADER_KEYS); +#if defined(SECONDARY_BOOTLOADER_KEYS) + result &= (readTrims() == SECONDARY_BOOTLOADER_KEYS); +#endif + return result; +} + +#elif (defined(RADIO_T8) || defined(RADIO_COMMANDO8)) && !defined(RADIOMASTER_RELEASE) + +bool boardBLStartCondition() +{ + // Bind button pressed + return (KEYS_GPIO_REG_BIND->IDR & KEYS_GPIO_PIN_BIND) == 0; +} + +#endif diff --git a/radio/src/fonts/CMakeLists.txt b/radio/src/fonts/CMakeLists.txt index 7a464fb34bd..ea3ec255203 100644 --- a/radio/src/fonts/CMakeLists.txt +++ b/radio/src/fonts/CMakeLists.txt @@ -2,10 +2,13 @@ # LVGL fonts # -set(LVGL_FONT_DIR fonts/lvgl) - file(GLOB LVGL_FONTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/.. lvgl/lv_font_*.c) set(LVGL_FONT_SOURCES ${LVGL_FONTS} PARENT_SCOPE) + +set(LVGL_FONT_SOURCES_MINIMAL + fonts/lvgl/lv_font_roboto_bl_16.c + PARENT_SCOPE +) diff --git a/radio/src/gui/128x64/CMakeLists.txt b/radio/src/gui/128x64/CMakeLists.txt index d9a9a2971f5..296b28eccc2 100644 --- a/radio/src/gui/128x64/CMakeLists.txt +++ b/radio/src/gui/128x64/CMakeLists.txt @@ -19,20 +19,30 @@ set(GUI_SRC radio_calibration.cpp view_main.cpp view_statistics.cpp - ) +) if(FLIGHT_MODES) - set(GUI_SRC - ${GUI_SRC} + set(GUI_SRC ${GUI_SRC} model_flightmodes.cpp - ) + ) +endif() + +if(GVARS) + set(GUI_SRC ${GUI_SRC} + model_gvars.cpp + ) endif() if(LUA_MIXER) - set(GUI_SRC - ${GUI_SRC} + set(GUI_SRC ${GUI_SRC} model_custom_scripts.cpp - ) + ) endif() include(gui/common/stdlcd/CMakeLists.txt) + +set(BOOTLOADER_SRC ${BOOTLOADER_SRC} + ${RADIO_SRC_DIR}/gui/128x64/lcd.cpp + ${RADIO_SRC_DIR}/gui/common/stdlcd/fonts.cpp + ${RADIO_SRC_DIR}/gui/common/stdlcd/utf8.cpp +) diff --git a/radio/src/gui/212x64/CMakeLists.txt b/radio/src/gui/212x64/CMakeLists.txt index 3d0e23889c2..c348de55a65 100644 --- a/radio/src/gui/212x64/CMakeLists.txt +++ b/radio/src/gui/212x64/CMakeLists.txt @@ -28,6 +28,12 @@ if(FLIGHT_MODES) ) endif() +if(GVARS) + set(GUI_SRC ${GUI_SRC} + model_gvars.cpp + ) +endif() + if(LUA_MIXER) set(GUI_SRC ${GUI_SRC} @@ -36,3 +42,9 @@ if(LUA_MIXER) endif() include(gui/common/stdlcd/CMakeLists.txt) + +set(BOOTLOADER_SRC ${BOOTLOADER_SRC} + ${RADIO_SRC_DIR}/gui/212x64/lcd.cpp + ${RADIO_SRC_DIR}/gui/common/stdlcd/fonts.cpp + ${RADIO_SRC_DIR}/gui/common/stdlcd/utf8.cpp +) diff --git a/radio/src/gui/colorlcd/CMakeLists.txt b/radio/src/gui/colorlcd/CMakeLists.txt index 8fbd82e6a43..00af42705ed 100644 --- a/radio/src/gui/colorlcd/CMakeLists.txt +++ b/radio/src/gui/colorlcd/CMakeLists.txt @@ -113,13 +113,6 @@ set(GUI_SRC radio_version.cpp ) -if(FUNCTION_SWITCHES) - set(GUI_SRC ${GUI_SRC} - function_switches.cpp - radio_diagcustswitches.cpp - ) -endif() - macro(add_gui_src src) set(GUI_SRC ${GUI_SRC} @@ -141,6 +134,15 @@ if(LUA_MIXER) add_gui_src(model_mixer_scripts.cpp) endif() +if(FUNCTION_SWITCHES) + add_gui_src(function_switches.cpp) + add_gui_src(radio_diagcustswitches.cpp) +endif() + +if(GVARS) + add_gui_src(model_gvars.cpp) +endif() + if(HELI) add_gui_src(model_heli.cpp) endif() @@ -187,6 +189,10 @@ if(BLUETOOTH) add_gui_src(hw_bluetooth.cpp) endif() +if(USBJ_EX) + add_gui_src(model_usbjoystick.cpp) +endif() + set(SRC ${SRC} storage/modelslist.cpp) option(WINDOWS_INSPECT_BORDERS "Draw bounding boxes around windows" OFF) @@ -206,10 +212,28 @@ set(LVGL_SRC_DIR ${LIBOPENUI_SRC_DIR}/thirdparty/lvgl/src) include(${LIBOPENUI_SRC_DIR}/src/CMakeLists.txt) include(${LIBOPENUI_SRC_DIR}/thirdparty/CMakeLists.txt) -set(SRC ${SRC} ${LVGL_FONT_SOURCES}) +list(TRANSFORM LVGL_SOURCES_MINIMAL PREPEND ${RADIO_SRC_DIR}/) +list(TRANSFORM LVGL_FONT_SOURCES_MINIMAL PREPEND ${RADIO_SRC_DIR}/) + +set(BOOTLOADER_SRC ${BOOTLOADER_SRC} + ${LVGL_SOURCES_MINIMAL} + ${LVGL_FONT_SOURCES_MINIMAL} + ${RADIO_SRC_DIR}/gui/colorlcd/lcd.cpp + ${RADIO_SRC_DIR}/gui/colorlcd/fonts.cpp + ${RADIO_SRC_DIR}/gui/colorlcd/colors.cpp + ${RADIO_SRC_DIR}/gui/colorlcd/bitmaps.cpp + ${RADIO_SRC_DIR}/${LIBOPENUI_SRC_DIR}/thirdparty/lz4/lz4.c + ${RADIO_SRC_DIR}/${LIBOPENUI_SRC_DIR}/src/bitmapbuffer.cpp +) -add_definitions(-DLIBOPENUI) +set(SRC ${SRC} + ${LVGL_SOURCES} + ${LVGL_FONT_SOURCES} + ${LIBOPENUI_SOURCES} +) -if(USBJ_EX) - add_gui_src(model_usbjoystick.cpp) -endif() +foreach(LVGL_FILE ${LVGL_SOURCES}) + SET_SOURCE_FILES_PROPERTIES(${LVGL_FILE} PROPERTIES COMPILE_FLAGS -O3) +endforeach() + +add_definitions(-DLIBOPENUI) diff --git a/radio/src/hal/CMakeLists.txt b/radio/src/hal/CMakeLists.txt index 856bbc9763d..1089a2e0a83 100644 --- a/radio/src/hal/CMakeLists.txt +++ b/radio/src/hal/CMakeLists.txt @@ -1,12 +1,15 @@ AddHWGenTarget(${HW_DESC_JSON} hal_keys hal_keys.inc) +# add_library(hal_keys OBJECT EXCLUDE_FROM_ALL +# ${CMAKE_CURRENT_BINARY_DIR}/hal_keys.inc +# hal/key_driver.cpp +# ) set(SRC ${SRC} ${CMAKE_CURRENT_BINARY_DIR}/hal_keys.inc - + hal/key_driver.cpp hal/module_port.cpp hal/adc_driver.cpp - hal/key_driver.cpp hal/switch_driver.cpp ) diff --git a/radio/src/targets/common/arm/stm32/CMakeLists.txt b/radio/src/targets/common/arm/stm32/CMakeLists.txt index c852cec2fb9..a08c55d9eb4 100644 --- a/radio/src/targets/common/arm/stm32/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/CMakeLists.txt @@ -117,26 +117,8 @@ if(NOT NATIVE_BUILD) set(BOOTLOADER_SRC ${BOOTLOADER_SRC} $) endif() -set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} - ../common/arm/stm32/rtc_driver.cpp - ../common/arm/stm32/delays_driver.cpp - ../common/arm/stm32/trainer_driver.cpp - ../common/arm/stm32/flash_driver.cpp - ../common/arm/stm32/stm32_softserial_driver.cpp - ../common/arm/stm32/stm32_pulse_driver.cpp - ../common/arm/stm32/module_timer_driver.cpp - ../common/arm/stm32/stm32_switch_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) add_definitions(-DIMU) - set(FIRMWARE_SRC ${FIRMWARE_SRC} - targets/common/arm/stm32/lsm6ds_driver.cpp - ) set(SRC ${SRC} gyro.cpp) endif() @@ -164,10 +146,6 @@ if(DEBUG OR CLI OR USB_SERIAL) message("-- Adding support for USB serial") endif() -if(GVARS) - set(GUI_SRC ${GUI_SRC} ${GVAR_SCREEN}) -endif() - set(FIRMWARE_SRC ${FIRMWARE_SRC} syscalls.c) set(TARGET_SRC ${TARGET_SRC} ../common/arm/stm32/cpu_id.cpp) diff --git a/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt b/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt index e50800abf6a..7727eac1c78 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt @@ -4,115 +4,23 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) AddHardwareDefTarget(${HW_DESC_JSON}) AddHWGenTarget(${HW_DESC_JSON} hal_keys hal_keys.inc) -set(BOOTLOADER_SRC - ${BOOTLOADER_SRC} - ../../../../../gui/${GUI_DIR}/lcd.cpp - ../../../../../keys.cpp - ../../../../../strhelpers.cpp - ../../../../../stamp.cpp - ../../../../../syscalls.c - ../../../../../targets/${TARGET_DIR}/${LCD_DRIVER} - ../../../../../targets/${TARGET_DIR}/backlight_driver.cpp - ../../../../../targets/${TARGET_DIR}/board.cpp - ../../../../../targets/${TARGET_DIR}/bootloader/boot_menu.cpp +set(BOOTLOADER_SRC ${BOOTLOADER_SRC} ${CMAKE_CURRENT_BINARY_DIR}/hal_keys.inc - ../pwr_driver.cpp - ../delays_driver.cpp - ../flash_driver.cpp - ../watchdog_driver.cpp - ../abnormal_reboot.cpp + ${RADIO_SRC_DIR}/keys.cpp + ${RADIO_SRC_DIR}/strhelpers.cpp + ${RADIO_SRC_DIR}/stamp.cpp + ${RADIO_SRC_DIR}/syscalls.c + ${RADIO_SRC_DIR}/crc.cpp boot.cpp bin_files.cpp - ) - -if(ROTARY_ENCODER) - set(BOOTLOADER_SRC - ${BOOTLOADER_SRC} - ../../../../../targets/common/arm/stm32/rotary_encoder_driver.cpp - ) -endif() - -if(BLUETOOTH) - set(BOOTLOADER_SRC - ${BOOTLOADER_SRC} - ../../../../../targets/common/arm/stm32/bluetooth_driver.cpp - ) -endif() +) if(DEBUG_SEGGER_RTT) - set(BOOTLOADER_SRC - ${BOOTLOADER_SRC} - ../../../../../thirdparty/Segger_RTT/RTT/SEGGER_RTT.c + set(BOOTLOADER_SRC ${BOOTLOADER_SRC} + ${RADIO_SRC_DIR}/thirdparty/Segger_RTT/RTT/SEGGER_RTT.c ) endif() -if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14 OR PCB STREQUAL PL18) - set(BOOTLOADER_SRC - ${BOOTLOADER_SRC} - ../../../../../gui/colorlcd/fonts.cpp - ../../../../../gui/colorlcd/colors.cpp - ../../../../../gui/colorlcd/bitmaps.cpp - ../../../../../fonts/lvgl/lv_font_roboto_bl_16.c - ../../../../../thirdparty/libopenui/src/bitmapbuffer.cpp - ../../../../../thirdparty/libopenui/thirdparty/lz4/lz4.c - ../../../../../targets/common/arm/stm32/dma2d.cpp - ../../../../../targets/common/arm/stm32/rtc_driver.cpp - ../../../../../targets/common/arm/stm32/diskio_spi_flash.cpp - ../../../../../targets/common/arm/stm32/spi_flash.cpp - ../../../../../drivers/frftl.cpp - ../../../../../crc.cpp - ../../../../../targets/common/arm/stm32/sdram_driver.cpp - ../../../../../targets/${TARGET_DIR}/haptic_driver.cpp - ) - - if(PCB STREQUAL PL18) - set(BOOTLOADER_SRC ${BOOTLOADER_SRC} - ../../../../../targets/pl18/key_driver.cpp - ) - endif() - - if(PCBREV STREQUAL F16) - set(BOOTLOADER_SRC ${BOOTLOADER_SRC} - ../../../../../targets/horus/videoswitch_driver.cpp - ) - endif() - - # Add LVGL sources - foreach(LVGL_FILE ${LVGL_SRC_FILES_MINIMAL}) - set(BOOTLOADER_SRC ${BOOTLOADER_SRC} ../../../../../${LVGL_FILE}) - endforeach() - - if(NOT (PCB STREQUAL NV14 OR PCB STREQUAL PL18)) - set(BOOTLOADER_SRC - ${BOOTLOADER_SRC} - ../../../../../targets/${TARGET_DIR}/led_driver.cpp - ) - endif() - - if(USB_CHARGER) - set(BOOTLOADER_SRC - ${BOOTLOADER_SRC} - ../../../../../targets/${TARGET_DIR}/usb_charger_driver.cpp - ) - endif() - - if(DEBUG) - set(ENABLE_BOOTLOADER_DEBUG true) - set(BOOTLOADER_SRC - ${BOOTLOADER_SRC} - ../../../../../serial.cpp - ../../../../../boards/generic_stm32/aux_ports.cpp - ) - endif() -else() - set(BOOTLOADER_SRC - ${BOOTLOADER_SRC} - ../../../../../gui/common/stdlcd/fonts.cpp - ../../../../../gui/common/stdlcd/utf8.cpp - ../../../../../crc.cpp - ) -endif() - # TODO: this shouldn't be needed at all remove_definitions(-DDISK_CACHE) remove_definitions(-DLUA) @@ -121,8 +29,6 @@ remove_definitions(-DSEMIHOSTING) remove_definitions(-DUSB_SERIAL) remove_definitions(-DUSE_WATCHDOG) -add_definitions(-DBOOT) - if(NOT NO_LTO) message("-- Use LTO to compile bootloader") target_compile_options(stm32cube_ll PRIVATE -flto) @@ -136,10 +42,13 @@ endif() add_executable(bootloader EXCLUDE_FROM_ALL ${BOOTLOADER_SRC}) add_dependencies(bootloader ${BITMAPS_TARGET}) -target_link_options(bootloader PRIVATE - -lm -T${LINKER_DIR}/bootloader.ld +target_compile_definitions(bootloader PRIVATE BOOT) +target_compile_definitions(board_bl PRIVATE BOOT) + +target_link_options(bootloader BEFORE PRIVATE + -T${LINKER_DIR}/bootloader.ld -Wl,-Map=bootloader.map,--cref,--no-warn-mismatch,--gc-sections - --specs=nano.specs + -lm --specs=nano.specs ) if (DEFINED TARGET_SDRAM_START) @@ -156,7 +65,7 @@ if (DEFINED TARGET_SDRAM_SIZE) ) endif() -if (DEFINED ENABLE_BOOTLOADER_DEBUG) +if (ENABLE_BOOTLOADER_DEBUG) target_compile_definitions(bootloader PUBLIC -DDEBUG) # uncomment to enable TRACE in drivers # target_compile_definitions(stm32_drivers_w_dbg_bl PRIVATE -DDEBUG) diff --git a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp index 1019c6d7025..43c59665c47 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp +++ b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp @@ -21,6 +21,7 @@ #if !defined(SIMU) #include "stm32_hal_ll.h" +#include "stm32_hal.h" #include "stm32_timer.h" #endif @@ -45,19 +46,7 @@ #include "thirdparty/Segger_RTT/RTT/SEGGER_RTT.h" #endif -#if defined(PCBXLITE) - #define BOOTLOADER_KEYS 0x0F -#elif defined(RADIO_MT12) - #define BOOTLOADER_KEYS 0x06 -#else - #define BOOTLOADER_KEYS 0x42 -#endif - -#if defined(RADIO_FAMILY_T20) - #define SECONDARY_BOOTLOADER_KEYS 0x1200 -#endif - -#define APP_START_ADDRESS (uint32_t)(FIRMWARE_ADDRESS + BOOTLOADER_SIZE) +#define APP_START_ADDRESS (uint32_t)(FIRMWARE_ADDRESS + BOOTLOADER_SIZE) #if defined(EEPROM) || defined(SPI_FLASH) #define MAIN_MENU_LEN 3 @@ -70,16 +59,6 @@ #define SEL_CLEAR_FLASH_STORAGE_MENU_LEN 2 #endif -typedef void (*voidFunction)(void); - -#define jumpTo(addr) do { \ - SCB->VTOR = addr; \ - __set_MSP(*(__IO uint32_t*)addr); \ - uint32_t jumpAddress = *(uint32_t*)(addr + 4); \ - voidFunction jumpFn = (voidFunction)jumpAddress; \ - jumpFn(); \ - } while(0) - #if !defined(SIMU) // Bootloader marker: // -> used to detect valid bootloader files @@ -180,6 +159,7 @@ int menuFlashFile(uint32_t index, event_t event) void flashWriteBlock() { + // TODO: use some board provided driver instead uint32_t blockOffset = 0; #if !defined(SIMU) while (BlockCount) { @@ -205,18 +185,26 @@ void writeEepromBlock() #endif #if !defined(SIMU) -void bootloaderInitApp() + +typedef void (*fctptr_t)(void); + +static __attribute__((noreturn)) void jumpTo(uint32_t addr) { - LL_AHB1_GRP1_EnableClock(LCD_RCC_AHB1Periph); -#if defined(LCD_RCC_APB2Periph) - LL_APB2_GRP1_EnableClock(LCD_RCC_APB2Periph); -#endif - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG); + __disable_irq(); + __set_MSP(*(uint32_t*)addr); + fctptr_t reset_handler = (fctptr_t)*(uint32_t*)(addr + 4); + reset_handler(); + while(1){} +} +// Optional board hook +__weak void boardBLInit() {} +__weak bool boardBLStartCondition() { return false; } +__weak void boardBLPreJump() {} -#if defined(HAVE_BOARD_BOOTLOADER_INIT) - boardBootloaderInit(); -#endif +void bootloaderInitApp() +{ + boardBLInit(); #if defined(DEBUG_SEGGER_RTT) SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP); @@ -232,22 +220,13 @@ void bootloaderInitApp() } } -#if (defined(RADIO_T8) || defined(RADIO_COMMANDO8)) && !defined(RADIOMASTER_RELEASE) - // Bind button not pressed - if ((~(KEYS_GPIO_REG_BIND->IDR) & KEYS_GPIO_PIN_BIND) == false) { -#else - // LHR & RHL trims not pressed simultanously -#if defined(SECONDARY_BOOTLOADER_KEYS) - if (readTrims() != BOOTLOADER_KEYS && readTrims() != SECONDARY_BOOTLOADER_KEYS) { -#else - if (readTrims() != BOOTLOADER_KEYS) { -#endif -#endif - // TODO: deInit before restarting + if (!boardBLStartCondition()) { // Start main application + boardBLPreJump(); jumpTo(APP_START_ADDRESS); } + // TODO: move all this into board specifics pwrOn(); #if defined(ROTARY_ENCODER_NAVIGATION) && !defined(USE_HATS_AS_KEYS) @@ -264,8 +243,10 @@ void bootloaderInitApp() TRACE("\nBootloader started :)"); + // TODO: move BT & EEPROM into board specifics #if defined(BLUETOOTH) - // we shutdown the bluetooth module now to be sure it will be detected on firmware start + // we shutdown the bluetooth module now to be sure it will be detected on + // firmware start bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, false); #endif @@ -592,4 +573,3 @@ int bootloaderMain() return 0; } - diff --git a/radio/src/targets/horus/CMakeLists.txt b/radio/src/targets/horus/CMakeLists.txt index e72028139a9..8d7054af374 100644 --- a/radio/src/targets/horus/CMakeLists.txt +++ b/radio/src/targets/horus/CMakeLists.txt @@ -50,19 +50,10 @@ set(HARDWARE_TOUCH YES) if (PCB STREQUAL X10) set(PCBREV "STD" CACHE STRING "PCB Revision") add_definitions(-DSOFTWARE_VOLUME) - set(FIRMWARE_SRC - ${FIRMWARE_SRC} - targets/common/arm/stm32/audio_dac_driver.cpp - ) - if (NOT (PCBREV STREQUAL TX16S OR PCBREV STREQUAL T15)) - set(FIRMWARE_SRC - ${FIRMWARE_SRC} - targets/common/arm/stm32/sticks_pwm_driver.cpp - ) - endif() + set(BITMAPS_TARGET x10_bitmaps) set(FONTS_TARGET x10_fonts) - set(LCD_DRIVER lcd_driver.cpp) + if (PCBREV STREQUAL EXPRESS) set(FLAVOUR x10express) set(DEFAULT_INTERNAL_MODULE ISRM_PXX2 CACHE STRING "Default internal module") @@ -162,10 +153,10 @@ elseif (PCB STREQUAL X12S) endif() set(INTERNAL_GPS_BAUDRATE "9600" CACHE STRING "Baud rate for internal GPS") set(AUX2_SERIAL ON) # wire to GPS - set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/common/arm/stm32/vs1053b.cpp) + set(USE_VS1053B ON) + set(USE_ADS79xx ON) set(BITMAPS_TARGET x12s_bitmaps) set(FONTS_TARGET x12s_fonts) - set(LCD_DRIVER lcd_driver.cpp) add_definitions(-DMANUFACTURER_FRSKY) endif() @@ -184,6 +175,9 @@ add_definitions(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE}) add_definitions(-DPWR_BUTTON_${PWR_BUTTON}) add_definitions(-DSTM32_SUPPORT_32BIT_TIMERS) +# Make malloc() thread-safe +add_definitions(-DTHREADSAFE_MALLOC) + set(SDRAM ON) if(FUNCTION_SWITCHES) @@ -219,32 +213,109 @@ if(ALLOW_TRAINER_MULTI) endif() if(DISK_CACHE) - set(SRC ${SRC} disk_cache.cpp) add_definitions(-DDISK_CACHE) + set(SRC ${SRC} disk_cache.cpp) endif() if(INTERNAL_GPS) - set(SRC ${SRC} gps.cpp gps_nmea.cpp gps_ubx.cpp) - add_definitions(-DINTERNAL_GPS) message("-- Internal GPS enabled") + add_definitions(-DINTERNAL_GPS) + set(SRC ${SRC} gps.cpp gps_nmea.cpp gps_ubx.cpp) endif() if(SPACEMOUSE) + message("-- SpaceMouse enabled") add_definitions(-DSPACEMOUSE) set(SRC ${SRC} spacemouse.cpp) - message("-- SpaceMouse enabled") endif() -set(GVAR_SCREEN model_gvars.cpp) +set(TARGET_SRC_DIR targets/${TARGET_DIR}) + +set(BOARD_COMMON_SRC + ${TARGET_SRC_DIR}/board.cpp + ${TARGET_SRC_DIR}/led_driver.cpp + ${TARGET_SRC_DIR}/haptic_driver.cpp + ${TARGET_SRC_DIR}/backlight_driver.cpp + targets/common/arm/stm32/abnormal_reboot.cpp + targets/common/arm/stm32/delays_driver.cpp + targets/common/arm/stm32/diskio_spi_flash.cpp + targets/common/arm/stm32/dma2d.cpp + targets/common/arm/stm32/flash_driver.cpp + targets/common/arm/stm32/pwr_driver.cpp + targets/common/arm/stm32/rotary_encoder_driver.cpp + targets/common/arm/stm32/rtc_driver.cpp + targets/common/arm/stm32/sdram_driver.cpp + targets/common/arm/stm32/spi_flash.cpp + targets/common/arm/stm32/watchdog_driver.cpp + drivers/frftl.cpp +) + +if(DEFINED LCD_DRIVER) + set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC} + ${TARGET_SRC_DIR}/${LCD_DRIVER} + ) +else() + set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC} + ${TARGET_SRC_DIR}/lcd_driver.cpp + ) +endif() + +if(BLUETOOTH) + set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC} + targets/common/arm/stm32/bluetooth_driver.cpp + ) +endif() + +if (VIDEO_SWITCH) + add_definitions(-DVIDEO_SWITCH) + set(BOARD_COMMON_SRC ${BOARD_COMMON_SRC} + targets/horus/videoswitch_driver.cpp + ) +endif() + +# Bootloader board library +add_library(board_bl OBJECT EXCLUDE_FROM_ALL + ${BOARD_COMMON_SRC} + ${TARGET_SRC_DIR}/bootloader/boot_menu.cpp +) +add_dependencies(board_bl ${BITMAPS_TARGET}) +set(BOOTLOADER_SRC ${BOOTLOADER_SRC} $) + +# Firmware board library +add_library(board OBJECT EXCLUDE_FROM_ALL + ${BOARD_COMMON_SRC} + targets/common/arm/stm32/delays_driver.cpp + targets/common/arm/stm32/heartbeat_driver.cpp + targets/common/arm/stm32/lsm6ds_driver.cpp + targets/common/arm/stm32/mixer_scheduler_driver.cpp + targets/common/arm/stm32/module_timer_driver.cpp + targets/common/arm/stm32/sticks_pwm_driver.cpp + targets/common/arm/stm32/stm32_pulse_driver.cpp + targets/common/arm/stm32/stm32_softserial_driver.cpp + targets/common/arm/stm32/stm32_switch_driver.cpp + targets/common/arm/stm32/trainer_driver.cpp +) +set(FIRMWARE_SRC ${FIRMWARE_SRC} $) if(HARDWARE_TOUCH) + add_definitions(-DHARDWARE_TOUCH) + if(FLAVOUR STREQUAL t15) - set(TOUCH_DRIVER cst8xx_driver.cpp) + target_sources(board PRIVATE ${TARGET_SRC_DIR}/cst8xx_driver.cpp) else() - set(TOUCH_DRIVER tp_gt911.cpp) add_definitions(-DTP_GT911) + target_sources(board PRIVATE ${TARGET_SRC_DIR}/tp_gt911.cpp) endif() - add_definitions(-DHARDWARE_TOUCH) +endif() + +if(USE_VS1053B) + target_sources(board PRIVATE targets/common/arm/stm32/vs1053b.cpp) +else() + target_sources(board PRIVATE targets/common/arm/stm32/audio_dac_driver.cpp) +endif() + +if(USE_ADS79xx) + target_sources(board PRIVATE targets/common/arm/stm32/ads79xx.cpp) endif() if(SWSERIALPOWER) @@ -252,70 +323,21 @@ if(SWSERIALPOWER) endif() if(USB_CHARGER) - set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} usb_charger_driver.cpp) add_definitions(-DUSB_CHARGER) + target_sources(board PRIVATE ${TARGET_SRC_DIR}/usb_charger_driver.cpp) endif() -if(BLUETOOTH) - add_definitions(-DBLUETOOTH) - set(FIRMWARE_SRC - ${FIRMWARE_SRC} - targets/common/arm/stm32/bluetooth_driver.cpp) - set(SRC - ${SRC} - bluetooth.cpp) - add_definitions(-DHARDWARE_TRAINER_BLUETOOTH) -endif() - -set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} - ${LCD_DRIVER} - ${TOUCH_DRIVER} - board.cpp - backlight_driver.cpp - led_driver.cpp - haptic_driver.cpp - ) - set(FIRMWARE_SRC ${FIRMWARE_SRC} - targets/common/arm/stm32/sdram_driver.cpp - targets/common/arm/stm32/rotary_encoder_driver.cpp - targets/common/arm/stm32/heartbeat_driver.cpp - targets/common/arm/stm32/ads79xx.cpp - targets/common/arm/stm32/dma2d.cpp - targets/common/arm/stm32/spi_flash.cpp - targets/common/arm/stm32/diskio_spi_flash.cpp - drivers/frftl.cpp - ) + targets/common/arm/loadboot.cpp +) -if (VIDEO_SWITCH) - add_definitions(-DVIDEO_SWITCH) - set(FIRMWARE_SRC - ${FIRMWARE_SRC} - targets/horus/videoswitch_driver.cpp - ) -endif() - -if(BOOTLOADER) - set(FIRMWARE_SRC - ${FIRMWARE_SRC} - targets/common/arm/loadboot.cpp - ) +if (MULTIMODULE) + add_definitions(-DMULTI_PROTOLIST) endif() set(SRC ${SRC} io/frsky_firmware_update.cpp io/multi_firmware_update.cpp - ) - -if (MULTIMODULE) - add_definitions(-DMULTI_PROTOLIST) - set(SRC ${SRC} - io/multi_protolist.cpp - ) -endif() - -# Make malloc() thread-safe -add_definitions(-DTHREADSAFE_MALLOC) - + io/multi_protolist.cpp +) diff --git a/radio/src/targets/horus/board.h b/radio/src/targets/horus/board.h index ff3c13fb4ae..0be8a617e13 100644 --- a/radio/src/targets/horus/board.h +++ b/radio/src/targets/horus/board.h @@ -30,6 +30,8 @@ // Defines used in board_common.h #define ROTARY_ENCODER_NAVIGATION +#define BOOTLOADER_KEYS 0x42 + #include "board_common.h" #include "hal.h" diff --git a/radio/src/targets/horus/cst8xx_driver.cpp b/radio/src/targets/horus/cst8xx_driver.cpp index aea76cc3274..36ac8426d77 100644 --- a/radio/src/targets/horus/cst8xx_driver.cpp +++ b/radio/src/targets/horus/cst8xx_driver.cpp @@ -20,6 +20,14 @@ */ #include "cst8xx_driver.h" +#include "stm32_hal.h" +#include "stm32_hal_ll.h" + +#include "stm32_exti_driver.h" +#include "stm32_gpio.h" +#include "stm32_gpio_driver.h" +#include "stm32_i2c_driver.h" +#include "timers_driver.h" #include "debug.h" #include "delays_driver.h" @@ -27,13 +35,6 @@ #include "hal/gpio.h" #include "hal/i2c_driver.h" #include "rtos.h" -#include "stm32_exti_driver.h" -#include "stm32_gpio.h" -#include "stm32_gpio_driver.h" -#include "stm32_hal.h" -#include "stm32_hal_ll.h" -#include "stm32_i2c_driver.h" -#include "timers_driver.h" volatile static bool touchEventOccured; diff --git a/radio/src/targets/horus/lcd_st7796s_driver.cpp b/radio/src/targets/horus/lcd_st7796s_driver.cpp index 3d9b12af083..2a6c66ff06e 100644 --- a/radio/src/targets/horus/lcd_st7796s_driver.cpp +++ b/radio/src/targets/horus/lcd_st7796s_driver.cpp @@ -19,6 +19,9 @@ * GNU General Public License for more details. */ +#include "stm32_hal.h" +#include "stm32_hal_ll.h" + #include "lcd_st7796s_driver.h" #include "board.h" @@ -28,8 +31,6 @@ #include "hal.h" #include "lcd.h" #include "opentx_types.h" -#include "stm32_hal.h" -#include "stm32_hal_ll.h" static LTDC_HandleTypeDef hltdc; static void* initialFrameBuffer = nullptr; diff --git a/radio/src/targets/nv14/CMakeLists.txt b/radio/src/targets/nv14/CMakeLists.txt index c5ac79e7fd4..140b077a7f1 100644 --- a/radio/src/targets/nv14/CMakeLists.txt +++ b/radio/src/targets/nv14/CMakeLists.txt @@ -71,7 +71,7 @@ add_definitions( set(SDRAM ON) -add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK) +add_definitions(-DAUDIO -DVOICE -DRTCLOCK) add_definitions(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE}) add_definitions(-DPWR_BUTTON_${PWR_BUTTON}) @@ -83,75 +83,75 @@ if(NOT UNEXPECTED_SHUTDOWN) add_definitions(-DNO_UNEXPECTED_SHUTDOWN) endif() -if(STICKS_DEAD_ZONE) - add_definitions(-DSTICK_DEAD_ZONE) -endif() - # VCP CLI set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough") set(CLI ON CACHE BOOL "Enable CLI") -include_directories(${RADIO_SRC_DIR}/fonts/colorlcd gui/${GUI_DIR} gui/${GUI_DIR}/layouts) - -file(GLOB THEMES_SRC RELATIVE ${RADIO_SRC_DIR}/gui/colorlcd ${RADIO_SRC_DIR}/gui/colorlcd/themes/*.cpp) -file(GLOB LAYOUTS_SRC RELATIVE ${RADIO_SRC_DIR}/gui/colorlcd ${RADIO_SRC_DIR}/gui/colorlcd/layouts/*.cpp) -file(GLOB WIDGETS_SRC RELATIVE ${RADIO_SRC_DIR}/gui/colorlcd ${RADIO_SRC_DIR}/gui/colorlcd/widgets/*.cpp) if(DISK_CACHE) set(SRC ${SRC} disk_cache.cpp) add_definitions(-DDISK_CACHE) endif() -#set(AUX_SERIAL_DRIVER ../common/arm/stm32/aux_serial_driver.cpp) +set(TARGET_SRC_DIR targets/${TARGET_DIR}) -set(GVAR_SCREEN model_gvars.cpp) - -set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} - board.cpp - ${LCD_DRIVER} - ${TOUCH_DRIVER} - battery_driver.cpp - backlight_driver.cpp - haptic_driver.cpp - ) - -set(FIRMWARE_SRC - ${FIRMWARE_SRC} - targets/common/arm/stm32/sdram_driver.cpp +set(BOARD_COMMON_SRC + ${TARGET_SRC_DIR}/board.cpp + ${TARGET_SRC_DIR}/haptic_driver.cpp + ${TARGET_SRC_DIR}/backlight_driver.cpp + ${TARGET_SRC_DIR}/${LCD_DRIVER} + targets/common/arm/stm32/abnormal_reboot.cpp + targets/common/arm/stm32/delays_driver.cpp + targets/common/arm/stm32/diskio_spi_flash.cpp targets/common/arm/stm32/dma2d.cpp + targets/common/arm/stm32/flash_driver.cpp + targets/common/arm/stm32/pwr_driver.cpp + targets/common/arm/stm32/rtc_driver.cpp + targets/common/arm/stm32/sdram_driver.cpp targets/common/arm/stm32/spi_flash.cpp - targets/common/arm/stm32/diskio_spi_flash.cpp + targets/common/arm/stm32/watchdog_driver.cpp drivers/frftl.cpp +) + +# Bootloader board library +add_library(board_bl OBJECT EXCLUDE_FROM_ALL + ${BOARD_COMMON_SRC} + ${TARGET_SRC_DIR}/bootloader/boot_menu.cpp +) +add_dependencies(board_bl ${BITMAPS_TARGET}) +set(BOOTLOADER_SRC ${BOOTLOADER_SRC} $) + +# Firmware board library +add_library(board OBJECT EXCLUDE_FROM_ALL + ${BOARD_COMMON_SRC} + ${TARGET_SRC_DIR}/${TOUCH_DRIVER} + ${TARGET_SRC_DIR}/battery_driver.cpp + targets/common/arm/stm32/delays_driver.cpp + targets/common/arm/stm32/heartbeat_driver.cpp + targets/common/arm/stm32/mixer_scheduler_driver.cpp + targets/common/arm/stm32/module_timer_driver.cpp + targets/common/arm/stm32/stm32_pulse_driver.cpp + targets/common/arm/stm32/stm32_softserial_driver.cpp + targets/common/arm/stm32/stm32_switch_driver.cpp + targets/common/arm/stm32/trainer_driver.cpp targets/common/arm/stm32/vs1053b.cpp - ) +) +set(FIRMWARE_SRC ${FIRMWARE_SRC} $) -if(BOOTLOADER) - set(FIRMWARE_SRC - ${FIRMWARE_SRC} - targets/common/arm/loadboot.cpp - ) -endif() +set(FIRMWARE_SRC + ${FIRMWARE_SRC} + targets/common/arm/loadboot.cpp +) set(SRC ${SRC} io/frsky_firmware_update.cpp io/multi_firmware_update.cpp - ) + io/multi_protolist.cpp +) if (MULTIMODULE) add_definitions(-DMULTI_PROTOLIST) - set(SRC ${SRC} - io/multi_protolist.cpp - ) endif() # Make malloc() thread-safe add_definitions(-DTHREADSAFE_MALLOC) - -set(STM32LIB_SRC - STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c - STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c - STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c - STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c - ) - diff --git a/radio/src/targets/nv14/board.cpp b/radio/src/targets/nv14/board.cpp index b0965202382..3ad79d63d94 100644 --- a/radio/src/targets/nv14/board.cpp +++ b/radio/src/targets/nv14/board.cpp @@ -85,7 +85,7 @@ static uint8_t boardGetPcbRev() } } -void boardBootloaderInit() +void boardBLInit() { #if defined(USB_SW_GPIO) gpio_init(USB_SW_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW); diff --git a/radio/src/targets/nv14/board.h b/radio/src/targets/nv14/board.h index 2c24a2b5173..55a1790772a 100644 --- a/radio/src/targets/nv14/board.h +++ b/radio/src/targets/nv14/board.h @@ -39,14 +39,12 @@ #define LUA_MEM_EXTRA_MAX (2 MB) // max allowed memory usage for Lua bitmaps (in bytes) #define LUA_MEM_MAX (6 MB) // max allowed memory usage for complete Lua (in bytes), 0 means unlimited +#define BOOTLOADER_KEYS 0x42 + extern uint16_t sessionTimer; #define SLAVE_MODE() (g_model.trainerData.mode == TRAINER_MODE_SLAVE) -// initilizes the board for the bootloader -#define HAVE_BOARD_BOOTLOADER_INIT 1 -void boardBootloaderInit(); - // Board driver void boardInit(); void boardOff(); diff --git a/radio/src/targets/pl18/CMakeLists.txt b/radio/src/targets/pl18/CMakeLists.txt index fb537c21ad1..f4c7e94298e 100644 --- a/radio/src/targets/pl18/CMakeLists.txt +++ b/radio/src/targets/pl18/CMakeLists.txt @@ -74,7 +74,7 @@ add_definitions( set(SDRAM ON) -add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK) +add_definitions(-DAUDIO -DVOICE -DRTCLOCK) add_definitions(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE}) add_definitions(-DPWR_BUTTON_${PWR_BUTTON}) add_definitions(-DCROSSFIRE_NATIVE) @@ -98,64 +98,71 @@ set(AFHDS3 ON) set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough") set(CLI ON CACHE BOOL "Enable CLI") -include_directories(${RADIO_SRC_DIR}/fonts/colorlcd gui/${GUI_DIR} gui/${GUI_DIR}/layouts) +set(TARGET_SRC_DIR targets/${TARGET_DIR}) -file(GLOB THEMES_SRC RELATIVE ${RADIO_SRC_DIR}/gui/colorlcd ${RADIO_SRC_DIR}/gui/colorlcd/themes/*.cpp) -file(GLOB LAYOUTS_SRC RELATIVE ${RADIO_SRC_DIR}/gui/colorlcd ${RADIO_SRC_DIR}/gui/colorlcd/layouts/*.cpp) -file(GLOB WIDGETS_SRC RELATIVE ${RADIO_SRC_DIR}/gui/colorlcd ${RADIO_SRC_DIR}/gui/colorlcd/widgets/*.cpp) - -set(GVAR_SCREEN model_gvars.cpp) - -set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} - ${LCD_DRIVER} - ${TOUCH_DRIVER} - board.cpp - key_driver.cpp - battery_driver.cpp - backlight_driver.cpp - led_driver.cpp - haptic_driver.cpp - ) - -set(FIRMWARE_SRC - ${FIRMWARE_SRC} +set(BOARD_COMMON_SRC + ${TARGET_SRC_DIR}/board.cpp + ${TARGET_SRC_DIR}/led_driver.cpp + ${TARGET_SRC_DIR}/haptic_driver.cpp + ${TARGET_SRC_DIR}/backlight_driver.cpp + ${TARGET_SRC_DIR}/${LCD_DRIVER} + targets/common/arm/stm32/abnormal_reboot.cpp + targets/common/arm/stm32/delays_driver.cpp + targets/common/arm/stm32/diskio_spi_flash.cpp + targets/common/arm/stm32/dma2d.cpp + targets/common/arm/stm32/flash_driver.cpp + targets/common/arm/stm32/pwr_driver.cpp + targets/common/arm/stm32/rtc_driver.cpp targets/common/arm/stm32/sdram_driver.cpp + targets/common/arm/stm32/spi_flash.cpp + targets/common/arm/stm32/watchdog_driver.cpp + drivers/frftl.cpp +) + +# Bootloader board library +add_library(board_bl OBJECT EXCLUDE_FROM_ALL + ${BOARD_COMMON_SRC} + ${TARGET_SRC_DIR}/bootloader/boot_menu.cpp +) +add_dependencies(board_bl ${BITMAPS_TARGET}) +set(BOOTLOADER_SRC ${BOOTLOADER_SRC} $) + +# Firmware board library +add_library(board OBJECT EXCLUDE_FROM_ALL + ${BOARD_COMMON_SRC} + ${TARGET_SRC_DIR}/${TOUCH_DRIVER} + ${TARGET_SRC_DIR}/battery_driver.cpp targets/common/arm/stm32/audio_dac_driver.cpp - targets/common/arm/stm32/dma2d.cpp + targets/common/arm/stm32/delays_driver.cpp + targets/common/arm/stm32/heartbeat_driver.cpp + targets/common/arm/stm32/mixer_scheduler_driver.cpp + targets/common/arm/stm32/module_timer_driver.cpp + targets/common/arm/stm32/stm32_pulse_driver.cpp + targets/common/arm/stm32/stm32_softserial_driver.cpp + targets/common/arm/stm32/stm32_switch_driver.cpp + targets/common/arm/stm32/stm32_ws2812.cpp + targets/common/arm/stm32/trainer_driver.cpp targets/common/arm/stm32/spi_flash.cpp targets/common/arm/stm32/diskio_spi_flash.cpp - targets/common/arm/stm32/stm32_ws2812.cpp boards/generic_stm32/rgb_leds.cpp drivers/frftl.cpp - ) +) +set(FIRMWARE_SRC ${FIRMWARE_SRC} $) -if(BOOTLOADER) - set(FIRMWARE_SRC - ${FIRMWARE_SRC} - targets/common/arm/loadboot.cpp - ) -endif() +set(FIRMWARE_SRC + ${FIRMWARE_SRC} + targets/common/arm/loadboot.cpp +) set(SRC ${SRC} io/frsky_firmware_update.cpp io/multi_firmware_update.cpp - ) + io/multi_protolist.cpp +) if (MULTIMODULE) add_definitions(-DMULTI_PROTOLIST) - set(SRC ${SRC} - io/multi_protolist.cpp - ) endif() # Make malloc() thread-safe add_definitions(-DTHREADSAFE_MALLOC) - -set(STM32LIB_SRC - STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c - STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c - STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c - STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c - ) - diff --git a/radio/src/targets/pl18/board.cpp b/radio/src/targets/pl18/board.cpp index c3fe9a69fc3..10dd58d02ee 100644 --- a/radio/src/targets/pl18/board.cpp +++ b/radio/src/targets/pl18/board.cpp @@ -85,7 +85,7 @@ void ledStripOff() ws2812_update(&_led_timer); } -void boardBootloaderInit() +void boardBLInit() { // USB charger status pins gpio_init(UCHARGER_GPIO, GPIO_IN, GPIO_PIN_SPEED_LOW); diff --git a/radio/src/targets/pl18/board.h b/radio/src/targets/pl18/board.h index f63ceb98de4..4a7a1ad7159 100644 --- a/radio/src/targets/pl18/board.h +++ b/radio/src/targets/pl18/board.h @@ -38,14 +38,12 @@ #define LUA_MEM_EXTRA_MAX (2 MB) // max allowed memory usage for Lua bitmaps (in bytes) #define LUA_MEM_MAX (6 MB) // max allowed memory usage for complete Lua (in bytes), 0 means unlimited +#define BOOTLOADER_KEYS 0x42 + extern uint16_t sessionTimer; #define SLAVE_MODE() (g_model.trainerData.mode == TRAINER_MODE_SLAVE) -// Initilizes the board for the bootloader -#define HAVE_BOARD_BOOTLOADER_INIT 1 -void boardBootloaderInit(); - // Board driver void boardInit(); void boardOff(); diff --git a/radio/src/targets/taranis/CMakeLists.txt b/radio/src/targets/taranis/CMakeLists.txt index c547a83aa92..5e56f2af9e7 100644 --- a/radio/src/targets/taranis/CMakeLists.txt +++ b/radio/src/targets/taranis/CMakeLists.txt @@ -10,8 +10,14 @@ option(BLUETOOTH "FrSky BT module support" OFF) set(USE_RTC_CLOCK YES) set(HARDWARE_EXTERNAL_MODULE YES) +set(TARGET_DIR taranis) + +set(HSE_VALUE 12000000) +set(SDCARD YES) +set(TARGET_DIR taranis) +set(PPM_LIMITS_SYMETRICAL YES) -add_definitions(-DPCBFRSKY) +add_definitions(-DPCBFRSKY -DPCBTARANIS -DAUDIO -DVOICE) if(PCB STREQUAL X9E) set(DEFAULT_INTERNAL_MODULE XJT_PXX1 CACHE STRING "Default internal module") @@ -36,7 +42,6 @@ if(PCB STREQUAL X9E) set(BITMAPS_TARGET taranis_bitmaps) set(FONTS_TARGET taranis_fonts) set(LCD_DRIVER lcd_driver_spi.cpp) - set(GVAR_SCREEN model_gvars.cpp) set(STATUS_LEDS NO) set(BLUETOOTH YES) set(ROTARY_ENCODER YES) @@ -51,7 +56,6 @@ elseif(PCB STREQUAL X9D+) set(BITMAPS_TARGET taranis_bitmaps) set(FONTS_TARGET taranis_fonts) set(LCD_DRIVER lcd_driver_spi.cpp) - set(GVAR_SCREEN model_gvars.cpp) set(PCBREV 2014 CACHE STRING "PCB Revision") #set(AFHDS3 NO) add_definitions(-DPCBREV=${PCBREV}) @@ -92,7 +96,6 @@ elseif(PCB STREQUAL X9D) set(FONTS_TARGET taranis_fonts) set(LCD_DRIVER lcd_driver_aspi.cpp) set(AUX_SERIAL ON) - set(GVAR_SCREEN model_gvars.cpp) set(STATUS_LEDS NO) add_definitions(-DMANUFACTURER_FRSKY) set(MODULE_SIZE_STD YES) @@ -104,7 +107,6 @@ elseif(PCB STREQUAL X7) set(BITMAPS_TARGET 9x_bitmaps) set(FONTS_TARGET 9x_fonts_1bit) set(LCD_DRIVER lcd_driver_spi.cpp) - set(GVAR_SCREEN model_gvars.cpp) set(STATUS_LEDS YES) add_definitions(-DPCBX7 -DSOFTWARE_VOLUME) add_definitions(-DPWR_BUTTON_${PWR_BUTTON}) @@ -387,7 +389,6 @@ elseif(PCB STREQUAL X9LITE) set(BITMAPS_TARGET 9x_bitmaps) set(FONTS_TARGET 9x_fonts_1bit) set(LCD_DRIVER lcd_driver_spi.cpp) - set(GVAR_SCREEN model_gvars.cpp) set(STATUS_LEDS YES) set(ROTARY_ENCODER YES) add_definitions(-DMANUFACTURER_FRSKY) @@ -410,7 +411,6 @@ elseif(PCB STREQUAL X9LITES) set(BITMAPS_TARGET 9x_bitmaps) set(FONTS_TARGET 9x_fonts_1bit) set(LCD_DRIVER lcd_driver_spi.cpp) - set(GVAR_SCREEN model_gvars.cpp) set(STATUS_LEDS YES) set(BLUETOOTH YES) set(ROTARY_ENCODER YES) @@ -433,7 +433,6 @@ elseif(PCB STREQUAL XLITE) set(BITMAPS_TARGET 9x_bitmaps) set(FONTS_TARGET 9x_fonts_1bit) set(LCD_DRIVER lcd_driver_spi.cpp) - set(GVAR_SCREEN model_gvars.cpp) set(STATUS_LEDS YES) set(BLUETOOTH YES) add_definitions(-DMANUFACTURER_FRSKY) @@ -454,7 +453,6 @@ elseif(PCB STREQUAL XLITES) set(BITMAPS_TARGET 9x_bitmaps) set(FONTS_TARGET 9x_fonts_1bit) set(LCD_DRIVER lcd_driver_spi.cpp) - set(GVAR_SCREEN model_gvars.cpp) set(STATUS_LEDS YES) set(PXX2 ON) set(BLUETOOTH YES) @@ -510,66 +508,92 @@ else() endif() +set(TARGET_SRC_DIR targets/${TARGET_DIR}) + +set(BOARD_COMMON_SRC + ${TARGET_SRC_DIR}/board.cpp + ${TARGET_SRC_DIR}/led_driver.cpp + ${TARGET_SRC_DIR}/haptic_driver.cpp + ${TARGET_SRC_DIR}/backlight_driver.cpp + ${TARGET_SRC_DIR}/${LCD_DRIVER} + targets/common/arm/stm32/abnormal_reboot.cpp + targets/common/arm/stm32/delays_driver.cpp + targets/common/arm/stm32/flash_driver.cpp + targets/common/arm/stm32/pwr_driver.cpp + targets/common/arm/stm32/rtc_driver.cpp + targets/common/arm/stm32/watchdog_driver.cpp +) + if(ROTARY_ENCODER) - set(FIRMWARE_SRC - ${FIRMWARE_SRC} + list(APPEND BOARD_COMMON_SRC targets/common/arm/stm32/rotary_encoder_driver.cpp - ) + ) +endif() + +if(BLUETOOTH) + list(APPEND BOARD_COMMON_SRC + targets/common/arm/stm32/bluetooth_driver.cpp + ) +endif() + +# Bootloader board library +add_library(board_bl OBJECT EXCLUDE_FROM_ALL + ${BOARD_COMMON_SRC} + ${TARGET_SRC_DIR}/bootloader/boot_menu.cpp +) +# add_dependencies(board_bl ${BITMAPS_TARGET}) +set(BOOTLOADER_SRC ${BOOTLOADER_SRC} $) + +# Firmware board library +add_library(board OBJECT EXCLUDE_FROM_ALL + ${BOARD_COMMON_SRC} + ${TARGET_SRC_DIR}/volume_i2c.cpp + ${TARGET_SRC_DIR}/eeprom_driver.cpp + targets/common/arm/stm32/audio_dac_driver.cpp + targets/common/arm/stm32/delays_driver.cpp + targets/common/arm/stm32/heartbeat_driver.cpp + targets/common/arm/stm32/mixer_scheduler_driver.cpp + targets/common/arm/stm32/module_timer_driver.cpp + targets/common/arm/stm32/stm32_pulse_driver.cpp + targets/common/arm/stm32/stm32_softserial_driver.cpp + targets/common/arm/stm32/stm32_switch_driver.cpp + targets/common/arm/stm32/trainer_driver.cpp +) +set(FIRMWARE_SRC ${FIRMWARE_SRC} $) + +if(STATUS_LEDS) + target_sources(board PRIVATE ${TARGET_SRC_DIR}/led_driver.cpp) endif() if(BIND_KEY) - set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} - bind_button_driver.cpp - ) add_definitions(-DBIND_KEY) + target_sources(board PRIVATE ${TARGET_SRC_DIR}/bind_button_driver.cpp) endif() if(USB_CHARGER) - set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} usb_charger_driver.cpp) add_definitions(-DUSB_CHARGER) + target_sources(board PRIVATE ${TARGET_SRC_DIR}/usb_charger_driver.cpp) endif() -if(BLUETOOTH) - add_definitions(-DBLUETOOTH) - set(FIRMWARE_SRC - ${FIRMWARE_SRC} - targets/common/arm/stm32/bluetooth_driver.cpp) - set(SRC - ${SRC} - bluetooth.cpp) - if(NOT PCB STREQUAL X9E) - # Bluetooth on X9E is compatible with almost nothing - add_definitions(-DHARDWARE_TRAINER_BLUETOOTH) - endif() +if(IMU) + target_sources(board PRIVATE targets/common/arm/stm32/lsm6ds_driver.cpp) endif() if(AUTOUPDATE) add_definitions(-DAUTOUPDATE) endif() -set(HSE_VALUE 12000000) -set(SDCARD YES) -set(TARGET_DIR taranis) -set(PPM_LIMITS_SYMETRICAL YES) - -add_definitions(-DPCBTARANIS) -add_definitions(-DAUDIO -DVOICE ) - if(USE_RTC_CLOCK) add_definitions(-DRTCLOCK) endif() -set(SRC - ${SRC} +set(SRC ${SRC} io/frsky_firmware_update.cpp io/multi_firmware_update.cpp - ) +) -set(GUI_SRC - ${GUI_SRC} +set(GUI_SRC ${GUI_SRC} model_input_edit.cpp model_mix_edit.cpp model_display.cpp @@ -579,22 +603,7 @@ set(GUI_SRC view_telemetry.cpp view_about.cpp bmp.cpp - ) - -if(STATUS_LEDS) - set(LED_DRIVER led_driver.cpp) -endif() - -set(FIRMWARE_TARGET_SRC - ${FIRMWARE_TARGET_SRC} - ${LED_DRIVER} - ${LCD_DRIVER} - board.cpp - volume_i2c.cpp - eeprom_driver.cpp - backlight_driver.cpp - haptic_driver.cpp - ) +) if(PCB STREQUAL XLITE OR PCB STREQUAL XLITES OR PCBREV STREQUAL COMMANDO8) set(FIRMWARE_SRC @@ -611,10 +620,7 @@ endif() set(FIRMWARE_SRC ${FIRMWARE_SRC} - hal/adc_driver.cpp targets/common/arm/loadboot.cpp - targets/common/arm/stm32/heartbeat_driver.cpp - targets/common/arm/stm32/audio_dac_driver.cpp ) set(RADIO_DEPENDENCIES ${RADIO_DEPENDENCIES} ${BITMAPS_TARGET}) diff --git a/radio/src/targets/taranis/board.h b/radio/src/targets/taranis/board.h index 354a297439a..652e8c89d0a 100644 --- a/radio/src/targets/taranis/board.h +++ b/radio/src/targets/taranis/board.h @@ -46,6 +46,18 @@ void rotaryEncoderCheck(); #define LUA_MEM_MAX (0) // max allowed memory usage for complete Lua (in bytes), 0 means unlimited +#if defined(PCBXLITE) +# define BOOTLOADER_KEYS 0x0F +#elif defined(RADIO_MT12) +# define BOOTLOADER_KEYS 0x06 +#else +# define BOOTLOADER_KEYS 0x42 +#endif + +#if defined(RADIO_FAMILY_T20) +# define SECONDARY_BOOTLOADER_KEYS 0x1200 +#endif + extern uint16_t sessionTimer; // Board driver diff --git a/radio/src/thirdparty/libopenui/src/CMakeLists.txt b/radio/src/thirdparty/libopenui/src/CMakeLists.txt index e2a75eeb1dd..588fa50a89c 100644 --- a/radio/src/thirdparty/libopenui/src/CMakeLists.txt +++ b/radio/src/thirdparty/libopenui/src/CMakeLists.txt @@ -6,7 +6,7 @@ if(HARWARE_TOUCH) add_definitions(-DHARDWARE_TOUCH) endif() -set(LIBOPENUI_SRC +set(LIBOPENUI_SOURCES libopenui_file.cpp bitmapbuffer.cpp bitmapbuffer_fileio.cpp @@ -35,10 +35,8 @@ set(LIBOPENUI_SRC keyboard_base.cpp ) -foreach(LIBOPENUI_FILE ${LIBOPENUI_SRC}) - set(LIBOPENUI_SRC_FILES ${LIBOPENUI_SRC_FILES} ${LIBOPENUI_SRC_DIR}/src/${LIBOPENUI_FILE}) -endforeach() +list(TRANSFORM LIBOPENUI_SOURCES PREPEND ${LIBOPENUI_SRC_DIR}/src/) -set(SRC ${SRC} ${LIBOPENUI_SRC_FILES} +set(LIBOPENUI_SOURCES ${LIBOPENUI_SOURCES} ${LIBOPENUI_SRC_DIR}/thirdparty/lz4/lz4.c - ) +) diff --git a/radio/src/thirdparty/libopenui/thirdparty/CMakeLists.txt b/radio/src/thirdparty/libopenui/thirdparty/CMakeLists.txt index 4c679649fa6..4960e42517c 100644 --- a/radio/src/thirdparty/libopenui/thirdparty/CMakeLists.txt +++ b/radio/src/thirdparty/libopenui/thirdparty/CMakeLists.txt @@ -93,33 +93,6 @@ set(LVGL_SOURCES hal/lv_hal_indev.c - # font/lv_font_unscii_8.c - # font/lv_font_unscii_16.c - # font/lv_font_simsun_16_cjk.c - # font/lv_font_dejavu_16_persian_hebrew.c - # font/lv_font_montserrat_8.c - # font/lv_font_montserrat_10.c - # font/lv_font_montserrat_12.c - # font/lv_font_montserrat_12_subpx.c - # font/lv_font_montserrat_14.c - # font/lv_font_montserrat_16.c - # font/lv_font_montserrat_18.c - # font/lv_font_montserrat_20.c - # font/lv_font_montserrat_22.c - # font/lv_font_montserrat_24.c - # font/lv_font_montserrat_26.c - # font/lv_font_montserrat_28.c - # font/lv_font_montserrat_28_compressed.c - # font/lv_font_montserrat_30.c - # font/lv_font_montserrat_32.c - # font/lv_font_montserrat_34.c - # font/lv_font_montserrat_36.c - # font/lv_font_montserrat_38.c - # font/lv_font_montserrat_40.c - # font/lv_font_montserrat_42.c - # font/lv_font_montserrat_44.c - # font/lv_font_montserrat_46.c - # font/lv_font_montserrat_48.c widgets/lv_line.c widgets/lv_dropdown.c widgets/lv_objx_templ.c @@ -176,21 +149,7 @@ set(LVGL_SOURCES extra/widgets/span/lv_span.c extra/widgets/keyboard/lv_keyboard.c extra/widgets/msgbox/lv_msgbox.c - # extra/themes/basic/lv_theme_basic.c - # extra/themes/default/lv_theme_default.c - # extra/themes/mono/lv_theme_mono.c ) -foreach(LVGL_FILE ${LVGL_SOURCES_MINIMAL}) - set(LVGL_SRC_FILES_MINIMAL ${LVGL_SRC_FILES_MINIMAL} ${LVGL_SRC_DIR}/${LVGL_FILE}) -endforeach() - -foreach(LVGL_FILE ${LVGL_SOURCES}) - set(LVGL_SRC_FILES ${LVGL_SRC_FILES} ${LVGL_SRC_DIR}/${LVGL_FILE}) -endforeach() - -foreach(LVGL_FILE ${LVGL_SRC_FILES}) - SET_SOURCE_FILES_PROPERTIES( ${LVGL_FILE} PROPERTIES COMPILE_FLAGS -O3 ) -endforeach() - -set(SRC ${SRC} ${LVGL_SRC_FILES}) +list(TRANSFORM LVGL_SOURCES_MINIMAL PREPEND ${LVGL_SRC_DIR}/) +list(TRANSFORM LVGL_SOURCES PREPEND ${LVGL_SRC_DIR}/) From 3f142bc660fbd7e849a8e2bfbd481b9c81f4c78c Mon Sep 17 00:00:00 2001 From: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Date: Sun, 7 Jul 2024 07:55:19 +0200 Subject: [PATCH 2/7] fix: F16 video switch --- radio/src/targets/horus/board.cpp | 2 +- radio/src/targets/horus/board.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/radio/src/targets/horus/board.cpp b/radio/src/targets/horus/board.cpp index dfb5d35058a..1be880c764d 100644 --- a/radio/src/targets/horus/board.cpp +++ b/radio/src/targets/horus/board.cpp @@ -54,7 +54,7 @@ bool boardBacklightOn = false; #if defined(VIDEO_SWITCH) #include "videoswitch_driver.h" -void boardBootloaderInit() +void boardBLInit() { videoSwitchInit(); } diff --git a/radio/src/targets/horus/board.h b/radio/src/targets/horus/board.h index 0be8a617e13..fba2352de22 100644 --- a/radio/src/targets/horus/board.h +++ b/radio/src/targets/horus/board.h @@ -63,12 +63,6 @@ extern uint16_t sessionTimer; #define SLAVE_MODE() (g_model.trainerData.mode == TRAINER_MODE_SLAVE) -#if defined(RADIO_F16) -// initilizes the board for the bootloader -#define HAVE_BOARD_BOOTLOADER_INIT 1 -void boardBootloaderInit(); -#endif - // Board driver void boardInit(); void boardOff(); From 0976b237e01ef346d806466df1f659bc2bfe9bdb Mon Sep 17 00:00:00 2001 From: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Date: Sun, 7 Jul 2024 07:55:56 +0200 Subject: [PATCH 3/7] fix: enable LTDC & GPIO periph clocks --- radio/src/targets/horus/lcd_driver.cpp | 1 + radio/src/targets/horus/lcd_st7796s_driver.cpp | 9 +++++++++ radio/src/targets/nv14/lcd_driver.cpp | 1 + radio/src/targets/pl18/lcd_driver.cpp | 1 + 4 files changed, 12 insertions(+) diff --git a/radio/src/targets/horus/lcd_driver.cpp b/radio/src/targets/horus/lcd_driver.cpp index 88e87b87ff6..6ef6db8858d 100644 --- a/radio/src/targets/horus/lcd_driver.cpp +++ b/radio/src/targets/horus/lcd_driver.cpp @@ -273,6 +273,7 @@ static void lcdReset(void) void LCD_Init_LTDC() { + __HAL_RCC_LTDC_CLK_ENABLE(); hltdc.Instance = LTDC; /* Configure PLLSAI prescalers for LCD */ diff --git a/radio/src/targets/horus/lcd_st7796s_driver.cpp b/radio/src/targets/horus/lcd_st7796s_driver.cpp index 2a6c66ff06e..136a4499ab9 100644 --- a/radio/src/targets/horus/lcd_st7796s_driver.cpp +++ b/radio/src/targets/horus/lcd_st7796s_driver.cpp @@ -21,6 +21,7 @@ #include "stm32_hal.h" #include "stm32_hal_ll.h" +#include "stm32_gpio_driver.h" #include "lcd_st7796s_driver.h" @@ -71,6 +72,10 @@ static void LCD_AF_GPIOConfig(void) | | LCD_G4 <-> PJ.11 | LCD_DE <-> PK.07 | | LCD_B3 <-> PJ.15 | */ + stm32_gpio_enable_clock(GPIOG); + stm32_gpio_enable_clock(GPIOI); + stm32_gpio_enable_clock(GPIOJ); + stm32_gpio_enable_clock(GPIOK); LL_GPIO_InitTypeDef GPIO_InitStructure; LL_GPIO_StructInit(&GPIO_InitStructure); @@ -103,6 +108,9 @@ static void LCD_AF_GPIOConfig(void) static void lcdSpiConfig(void) { + stm32_gpio_enable_clock(LCD_SPI_GPIO); + stm32_gpio_enable_clock(LCD_NRST_GPIO); + LL_GPIO_InitTypeDef GPIO_InitStructure; LL_GPIO_StructInit(&GPIO_InitStructure); @@ -321,6 +329,7 @@ void LCD_ST7796S_Off(void) { lcdWriteCommand(0x28); } void LCD_Init_LTDC() { + __HAL_RCC_LTDC_CLK_ENABLE(); hltdc.Instance = LTDC; /* Configure PLLSAI prescalers for LCD */ diff --git a/radio/src/targets/nv14/lcd_driver.cpp b/radio/src/targets/nv14/lcd_driver.cpp index 62cd7bc2531..56055a080a3 100644 --- a/radio/src/targets/nv14/lcd_driver.cpp +++ b/radio/src/targets/nv14/lcd_driver.cpp @@ -1104,6 +1104,7 @@ static void lcdReset() { } void LCD_Init_LTDC() { + __HAL_RCC_LTDC_CLK_ENABLE(); hltdc.Instance = LTDC; /* Configure PLLSAI prescalers for LCD */ diff --git a/radio/src/targets/pl18/lcd_driver.cpp b/radio/src/targets/pl18/lcd_driver.cpp index cfc41b1e84f..8b186f703a2 100644 --- a/radio/src/targets/pl18/lcd_driver.cpp +++ b/radio/src/targets/pl18/lcd_driver.cpp @@ -2690,6 +2690,7 @@ void LCD_NT35310_Off( void ) } void LCD_Init_LTDC() { + __HAL_RCC_LTDC_CLK_ENABLE(); hltdc.Instance = LTDC; /* Configure PLLSAI prescalers for LCD */ From 03dfc7429a5423421c44b0633f5b2cf2865ab75d Mon Sep 17 00:00:00 2001 From: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Date: Sun, 7 Jul 2024 08:25:18 +0200 Subject: [PATCH 4/7] fix: T20 bootloader keys --- radio/src/boards/generic_stm32/bl_keys.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/boards/generic_stm32/bl_keys.cpp b/radio/src/boards/generic_stm32/bl_keys.cpp index 3ce9aa136c9..413494a716b 100644 --- a/radio/src/boards/generic_stm32/bl_keys.cpp +++ b/radio/src/boards/generic_stm32/bl_keys.cpp @@ -8,7 +8,7 @@ bool boardBLStartCondition() // Trims combo activated bool result = (readTrims() == BOOTLOADER_KEYS); #if defined(SECONDARY_BOOTLOADER_KEYS) - result &= (readTrims() == SECONDARY_BOOTLOADER_KEYS); + result |= (readTrims() == SECONDARY_BOOTLOADER_KEYS); #endif return result; } From 78ccc850c398645ce42959b16a48e69d405f07d6 Mon Sep 17 00:00:00 2001 From: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Date: Sun, 7 Jul 2024 08:26:36 +0200 Subject: [PATCH 5/7] chores: remove useless LCD_RCC_xxx defs --- radio/src/targets/horus/board.cpp | 3 --- radio/src/targets/horus/hal.h | 5 ----- radio/src/targets/nv14/board.cpp | 6 ------ radio/src/targets/nv14/hal.h | 2 -- radio/src/targets/pl18/board.cpp | 4 ---- radio/src/targets/pl18/hal.h | 2 -- radio/src/targets/taranis/hal.h | 4 ---- radio/src/targets/taranis/lcd_driver_spi.cpp | 2 ++ 8 files changed, 2 insertions(+), 26 deletions(-) diff --git a/radio/src/targets/horus/board.cpp b/radio/src/targets/horus/board.cpp index 1be880c764d..18927589db1 100644 --- a/radio/src/targets/horus/board.cpp +++ b/radio/src/targets/horus/board.cpp @@ -65,9 +65,6 @@ void boardBLInit() void boardInit() { - LL_AHB1_GRP1_EnableClock(LCD_RCC_AHB1Periph); - LL_APB2_GRP1_EnableClock(LCD_RCC_APB2Periph); - #if defined(RADIO_FAMILY_T16) void board_set_bor_level(); board_set_bor_level(); diff --git a/radio/src/targets/horus/hal.h b/radio/src/targets/horus/hal.h index 2027ff83c83..5d5c2a121ba 100644 --- a/radio/src/targets/horus/hal.h +++ b/radio/src/targets/horus/hal.h @@ -663,9 +663,6 @@ // LCD #if defined(RADIO_T15) - #define LCD_RCC_AHB1Periph (LL_AHB1_GRP1_PERIPH_GPIOE | LL_AHB1_GRP1_PERIPH_GPIOG | LL_AHB1_GRP1_PERIPH_GPIOI | LL_AHB1_GRP1_PERIPH_GPIOJ | LL_AHB1_GRP1_PERIPH_GPIOK | LL_AHB1_GRP1_PERIPH_DMA2D) - #define LCD_RCC_APB1Periph 0 - #define LCD_RCC_APB2Periph LL_APB2_GRP1_PERIPH_LTDC #define LCD_NRST_GPIO GPIOG #define LCD_NRST_GPIO_PIN LL_GPIO_PIN_10 // PG.10 #define LCD_SPI_GPIO GPIOE @@ -676,8 +673,6 @@ #define LTDC_IRQ_PRIO 4 #define DMA_SCREEN_IRQ_PRIO 6 #else -#define LCD_RCC_AHB1Periph LL_AHB1_GRP1_PERIPH_DMA2D -#define LCD_RCC_APB2Periph LL_APB2_GRP1_PERIPH_LTDC #if defined(PCBX12S) #define LCD_GPIO_NRST GPIO_PIN(GPIOF, 10) // PF.10 #elif defined(PCBX10) diff --git a/radio/src/targets/nv14/board.cpp b/radio/src/targets/nv14/board.cpp index 3ad79d63d94..c1fe4e77d56 100644 --- a/radio/src/targets/nv14/board.cpp +++ b/radio/src/targets/nv14/board.cpp @@ -67,9 +67,6 @@ void delay_self(int count) } } -#define RCC_AHB1PeriphMinimum (LCD_RCC_AHB1Periph) -#define RCC_APB2PeriphMinimum (LCD_RCC_APB2Periph) - static uint8_t boardGetPcbRev() { gpio_init(INTMODULE_PWR_GPIO, GPIO_IN, GPIO_PIN_SPEED_LOW); @@ -107,9 +104,6 @@ void boardInit() #endif #if !defined(SIMU) - LL_AHB1_GRP1_EnableClock(RCC_AHB1PeriphMinimum); - LL_APB2_GRP1_EnableClock(RCC_APB2PeriphMinimum); - // enable interrupts __enable_irq(); #endif diff --git a/radio/src/targets/nv14/hal.h b/radio/src/targets/nv14/hal.h index b27f16aa32e..ca4f8b92e37 100644 --- a/radio/src/targets/nv14/hal.h +++ b/radio/src/targets/nv14/hal.h @@ -242,8 +242,6 @@ #define USB_SW_GPIO GPIO_PIN(GPIOI, 10) // PI.10 // LCD -#define LCD_RCC_AHB1Periph LL_AHB1_GRP1_PERIPH_DMA2D -#define LCD_RCC_APB2Periph LL_APB2_GRP1_PERIPH_LTDC #define LCD_NRST_GPIO GPIO_PIN(GPIOG, 9) // PG.09 #define LCD_SPI_CS_GPIO GPIO_PIN(GPIOE, 4) // PE.04 #define LCD_SPI_SCK_GPIO GPIO_PIN(GPIOE, 2) // PE.02 diff --git a/radio/src/targets/pl18/board.cpp b/radio/src/targets/pl18/board.cpp index 10dd58d02ee..b834dca2034 100644 --- a/radio/src/targets/pl18/board.cpp +++ b/radio/src/targets/pl18/board.cpp @@ -74,8 +74,6 @@ void delay_self(int count) for (; count > 0; count--); } } -#define RCC_AHB1PeriphMinimum (LCD_RCC_AHB1Periph) -#define RCC_APB2PeriphMinimum (LCD_RCC_APB2Periph) void ledStripOff() { @@ -98,8 +96,6 @@ void boardInit() #endif #if !defined(SIMU) - LL_AHB1_GRP1_EnableClock(RCC_AHB1PeriphMinimum); - LL_APB2_GRP1_EnableClock(RCC_APB2PeriphMinimum); // enable interrupts __enable_irq(); #endif diff --git a/radio/src/targets/pl18/hal.h b/radio/src/targets/pl18/hal.h index 29271167fc8..1d5976a95a3 100644 --- a/radio/src/targets/pl18/hal.h +++ b/radio/src/targets/pl18/hal.h @@ -398,8 +398,6 @@ #define USB_GPIO_AF GPIO_AF10 // LCD -#define LCD_RCC_AHB1Periph LL_AHB1_GRP1_PERIPH_DMA2D -#define LCD_RCC_APB2Periph LL_APB2_GRP1_PERIPH_LTDC #define LCD_NRST_GPIO GPIO_PIN(GPIOG, 9) // PG.09 #define LCD_SPI_CS_GPIO GPIO_PIN(GPIOE, 4) // PE.04 #define LCD_SPI_SCK_GPIO GPIO_PIN(GPIOE, 2) // PE.02 diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index 93969b6cbfd..cdbe2a6f15d 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -2387,7 +2387,6 @@ #define SSD1309_LCD #endif #if defined(PCBX9E) - #define LCD_RCC_AHB1Periph LL_AHB1_GRP1_PERIPH_DMA1 #define LCD_MOSI_GPIO GPIO_PIN(GPIOC, 12) // PC.12 #define LCD_CLK_GPIO GPIO_PIN(GPIOC, 10) // PC.10 #define LCD_A0_GPIO GPIO_PIN(GPIOC, 11) // PC.11 @@ -2402,7 +2401,6 @@ #define LCD_SPI SPI3 #define LCD_GPIO_AF GPIO_AF6 #elif defined(PCBXLITE) || defined(PCBX9LITE) - #define LCD_RCC_AHB1Periph LL_AHB1_GRP1_PERIPH_DMA1 #define LCD_MOSI_GPIO GPIO_PIN(GPIOC, 12) // PC.12 #define LCD_CLK_GPIO GPIO_PIN(GPIOC, 10) // PC.10 #define LCD_A0_GPIO GPIO_PIN(GPIOC, 11) // PC.11 @@ -2417,7 +2415,6 @@ #define LCD_SPI SPI3 #define LCD_GPIO_AF GPIO_AF6 #elif defined(PCBX9DP) || defined(PCBX7) - #define LCD_RCC_AHB1Periph LL_AHB1_GRP1_PERIPH_DMA1 #define LCD_MOSI_GPIO GPIO_PIN(GPIOC, 12) // PC.12 #define LCD_CLK_GPIO GPIO_PIN(GPIOC, 10) // PC.10 #define LCD_A0_GPIO GPIO_PIN(GPIOC, 11) // PC.11 @@ -2436,7 +2433,6 @@ #define LCD_SPI SPI3 #define LCD_GPIO_AF GPIO_AF6 #else - #define LCD_RCC_AHB1Periph 0 // Soft SPI: these pins are not connected to SPI periph on STM32F205 #define LCD_MOSI_GPIO GPIO_PIN(GPIOD, 10) // PD.10 #define LCD_CLK_GPIO GPIO_PIN(GPIOD, 11) // PD.11 diff --git a/radio/src/targets/taranis/lcd_driver_spi.cpp b/radio/src/targets/taranis/lcd_driver_spi.cpp index 153307bf8e9..9f723599f3d 100644 --- a/radio/src/targets/taranis/lcd_driver_spi.cpp +++ b/radio/src/targets/taranis/lcd_driver_spi.cpp @@ -22,6 +22,7 @@ #include "hal/gpio.h" #include "stm32_gpio.h" #include "stm32_spi.h" +#include "stm32_dma.h" #include "board.h" #include "debug.h" @@ -89,6 +90,7 @@ void lcdHardwareInit() gpio_init(LCD_RST_GPIO, GPIO_OUT, GPIO_PIN_SPEED_MEDIUM); gpio_init(LCD_A0_GPIO, GPIO_OUT, GPIO_PIN_SPEED_HIGH); + stm32_dma_enable_clock(LCD_DMA); LCD_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA LCD_DMA->HIFCR = LCD_DMA_FLAGS; // Write ones to clear bits LCD_DMA_Stream->CR = DMA_SxCR_PL_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0; From 5b6d26478aa69aeae229922a888db4b667bcca0c Mon Sep 17 00:00:00 2001 From: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Date: Sun, 7 Jul 2024 11:06:27 +0200 Subject: [PATCH 6/7] fix(pl18): GPIO periph clock used for key matrix --- radio/src/targets/pl18/key_driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/targets/pl18/key_driver.cpp b/radio/src/targets/pl18/key_driver.cpp index cd09c374d71..89f39913692 100644 --- a/radio/src/targets/pl18/key_driver.cpp +++ b/radio/src/targets/pl18/key_driver.cpp @@ -72,7 +72,7 @@ void keysInit() stm32_gpio_enable_clock(GPIOB); stm32_gpio_enable_clock(GPIOC); stm32_gpio_enable_clock(GPIOD); - stm32_gpio_enable_clock(GPIOF); + stm32_gpio_enable_clock(GPIOG); stm32_gpio_enable_clock(GPIOH); stm32_gpio_enable_clock(GPIOJ); From 54515574c85204392e144df210e0cced42ae33fd Mon Sep 17 00:00:00 2001 From: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Date: Sun, 7 Jul 2024 12:47:38 +0200 Subject: [PATCH 7/7] fix(pl18): missing key driver --- radio/src/targets/pl18/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/radio/src/targets/pl18/CMakeLists.txt b/radio/src/targets/pl18/CMakeLists.txt index f4c7e94298e..776542b38d2 100644 --- a/radio/src/targets/pl18/CMakeLists.txt +++ b/radio/src/targets/pl18/CMakeLists.txt @@ -103,6 +103,7 @@ set(TARGET_SRC_DIR targets/${TARGET_DIR}) set(BOARD_COMMON_SRC ${TARGET_SRC_DIR}/board.cpp ${TARGET_SRC_DIR}/led_driver.cpp + ${TARGET_SRC_DIR}/key_driver.cpp ${TARGET_SRC_DIR}/haptic_driver.cpp ${TARGET_SRC_DIR}/backlight_driver.cpp ${TARGET_SRC_DIR}/${LCD_DRIVER}