Skip to content

Commit

Permalink
refactor: bootloader & cmake cleanup (EdgeTX#5232)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic authored Jul 7, 2024
1 parent 848d794 commit d575242
Show file tree
Hide file tree
Showing 35 changed files with 470 additions and 534 deletions.
15 changes: 10 additions & 5 deletions radio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -463,7 +468,6 @@ else()
endif()

if(NATIVE_BUILD)

set(RADIOLIB_NATIVE_SRC ${SRC})
if(SIMU_DISKIO)
set(RADIOLIB_NATIVE_SRC ${RADIOLIB_NATIVE_SRC}
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions radio/src/boards/generic_stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions radio/src/boards/generic_stm32/bl_keys.cpp
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions radio/src/fonts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
24 changes: 17 additions & 7 deletions radio/src/gui/128x64/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
12 changes: 12 additions & 0 deletions radio/src/gui/212x64/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
)
48 changes: 36 additions & 12 deletions radio/src/gui/colorlcd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
7 changes: 5 additions & 2 deletions radio/src/hal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)

Expand Down
22 changes: 0 additions & 22 deletions radio/src/targets/common/arm/stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,8 @@ if(NOT NATIVE_BUILD)
set(BOOTLOADER_SRC ${BOOTLOADER_SRC} $<TARGET_OBJECTS:stm32_drivers_w_dbg_bl>)
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()

Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit d575242

Please sign in to comment.