Skip to content

Commit

Permalink
fix: allow compilation of BW radio when DEBUG=Y (#4708)
Browse files Browse the repository at this point in the history
Co-authored-by: raphaelcoeffic <[email protected]>
  • Loading branch information
3djc and raphaelcoeffic authored Mar 30, 2024
1 parent d73d88a commit 0b3ced8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
5 changes: 5 additions & 0 deletions radio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ link_libraries(firmware -lstdc++)
add_dependencies(firmware ${RADIO_DEPENDENCIES})
set_target_properties(firmware PROPERTIES EXCLUDE_FROM_ALL TRUE)

if(DEBUG)
target_compile_definitions(firmware PRIVATE -DDEBUG)
target_compile_definitions(stm32_drivers_w_dbg_fw PRIVATE -DDEBUG)
endif()

target_link_options(firmware PRIVATE
-lm -T${LINKER_DIR}/firmware.ld
-Wl,-Map=firmware.map,--cref,--no-warn-mismatch,--gc-sections
Expand Down
4 changes: 0 additions & 4 deletions radio/src/targets/common/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ if(ENABLE_SERIAL_PASSTHROUGH)
add_definitions(-DENABLE_SERIAL_PASSTHROUGH)
endif()

if(DEBUG)
add_definitions(-DDEBUG)
endif()

if(HAPTIC)
add_definitions(-DHAPTIC)
set(SRC ${SRC} haptic.cpp)
Expand Down
12 changes: 11 additions & 1 deletion radio/src/targets/common/arm/stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ if(NOT NATIVE_BUILD)
add_library(stm32_drivers OBJECT EXCLUDE_FROM_ALL
${STM32_DRIVER_DIR}/stm32_hal.cpp
${STM32_DRIVER_DIR}/timers_driver.cpp
${STM32_DRIVER_DIR}/sdcard_spi.cpp
${STM32_DRIVER_DIR}/diskio_spi.cpp
${STM32_DRIVER_DIR}/stm32_exti_driver.cpp
${STM32_DRIVER_DIR}/stm32_serial_driver.cpp
Expand All @@ -96,14 +95,25 @@ if(NOT NATIVE_BUILD)
${STM32_DRIVER_DIR}/stm32_adc.cpp
)

# HAL/LL drivers using TRACE
add_library(stm32_drivers_w_dbg_fw OBJECT EXCLUDE_FROM_ALL
${STM32_DRIVER_DIR}/sdcard_spi.cpp
)
add_library(stm32_drivers_w_dbg_bl OBJECT EXCLUDE_FROM_ALL
${STM32_DRIVER_DIR}/sdcard_spi.cpp
)

if(NOT PCB STREQUAL PL18)
target_sources(stm32_drivers PUBLIC
${STM32_DRIVER_DIR}/diskio_sdio.cpp
)
endif()

set(FIRMWARE_SRC ${FIRMWARE_SRC} $<TARGET_OBJECTS:stm32_drivers>)
set(FIRMWARE_SRC ${FIRMWARE_SRC} $<TARGET_OBJECTS:stm32_drivers_w_dbg_fw>)

set(BOOTLOADER_SRC ${BOOTLOADER_SRC} $<TARGET_OBJECTS:stm32_drivers>)
set(BOOTLOADER_SRC ${BOOTLOADER_SRC} $<TARGET_OBJECTS:stm32_drivers_w_dbg_bl>)
endif()

set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC}
Expand Down
12 changes: 10 additions & 2 deletions radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14 OR PCB STREQUAL PL
)
endif()


if(USB_CHARGER)
set(BOOTLOADER_SRC
${BOOTLOADER_SRC}
Expand All @@ -92,6 +91,7 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14 OR PCB STREQUAL PL
endif()

if(DEBUG)
set(ENABLE_BOOTLOADER_DEBUG true)
set(BOOTLOADER_SRC
${BOOTLOADER_SRC}
../../../../../serial.cpp
Expand All @@ -105,9 +105,9 @@ else()
../../../../../gui/common/stdlcd/utf8.cpp
../../../../../crc.cpp
)
remove_definitions(-DDEBUG)
endif()

# TODO: this shouldn't be needed at all
remove_definitions(-DDISK_CACHE)
remove_definitions(-DLUA)
remove_definitions(-DCLI)
Expand All @@ -124,7 +124,9 @@ if(NOT NO_LTO)
target_compile_options(stm32usb_device_bl PRIVATE -flto)
target_compile_options(stm32usb_device_fw PRIVATE -flto)
target_compile_options(stm32_drivers PRIVATE -flto)
target_compile_options(stm32_drivers_w_dbg_bl PRIVATE -flto)
endif()

add_executable(bootloader EXCLUDE_FROM_ALL ${BOOTLOADER_SRC})
add_dependencies(bootloader ${BITMAPS_TARGET})

Expand All @@ -148,6 +150,12 @@ if (DEFINED TARGET_SDRAM_SIZE)
)
endif()

if (DEFINED 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)
endif()

target_include_directories(bootloader
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
Expand Down

0 comments on commit 0b3ced8

Please sign in to comment.