@@ -35,8 +35,6 @@ set(TUSB ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src)
3535#-------------------
3636set (CMAKE_EXECUTABLE_SUFFIX .elf)
3737add_executable (bootloader)
38- #set_target_properties(bootloader PROPERTIES OUTPUT_NAME "${BOARD}_bootloader.elf")
39-
4038
4139# SD_VERSION can be overwritten by board.cmake
4240if (NOT DEFINED SD_VERSION)
@@ -51,6 +49,8 @@ target_sources(bootloader PUBLIC
5149 src/dfu_init.c
5250 src/flash_nrf5x.c
5351 src/main.c
52+ src/screen.c
53+ src/images.c
5454 src/boards/boards.c
5555 # nrfx
5656 ${NRFX} /drivers/src/nrfx_power.c
@@ -112,19 +112,37 @@ target_include_directories(bootloader PUBLIC
112112 ${SOFTDEVICE} /mbr/headers
113113 )
114114
115+ # Debug option
115116if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
116117 # TODO not work yet, also need to add segger rtt, DFU_APP_DATA_RESERVED=0, BOOTLOADER_REGION_START=0xED000
117118 set (LD_FILE ${CMAKE_CURRENT_LIST_DIR} /linker/${MCU_VARIANT} _debug.ld)
118- message (FATAL_ERROR "Debug build not supported yet" )
119+
120+ target_sources (bootloader PUBLIC
121+ lib/SEGGER_RTT/RTT/SEGGER_RTT.c
122+ )
123+ target_include_directories (bootloader PUBLIC
124+ lib/SEGGER_RTT/RTT
125+ )
126+
127+ target_compile_definitions (bootloader PUBLIC
128+ CFG_DEBUG
129+ SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
130+ DFU_APP_DATA_RESERVED=0
131+ )
132+
133+ if (MCU_VARIANT STREQUAL "nrf52840" )
134+ target_compile_definitions (bootloader PUBLIC BOOTLOADER_REGION_START=0xEA000)
135+ else ()
136+ target_compile_definitions (bootloader PUBLIC BOOTLOADER_REGION_START=0x6D000)
137+ endif ()
119138else ()
120139 set (LD_FILE ${CMAKE_CURRENT_LIST_DIR} /linker/${MCU_VARIANT} .ld)
121140endif ()
122141
123142target_link_options (bootloader PUBLIC
124143 "LINKER:--script=${LD_FILE} "
125144 -L${NRFX} /mdk
126- --specs=nosys.specs
127- --specs=nano.specs
145+ --specs=nosys.specs --specs=nano.specs
128146 )
129147target_compile_options (bootloader PUBLIC
130148 -fno-builtin
@@ -149,7 +167,6 @@ target_compile_options(bootloader PUBLIC
149167 )
150168target_compile_definitions (bootloader PUBLIC
151169 SOFTDEVICE_PRESENT
152- DFU_APP_DATA_RESERVED=7*4096
153170 )
154171
155172if (TRACE_ETM STREQUAL "1" )
@@ -195,6 +212,7 @@ endif ()
195212if (MCU_VARIANT STREQUAL "nrf52" )
196213 set (SD_NAME s132)
197214 set (DFU_DEV_REV 0xADAF)
215+ set (DFU_APP_DATA_RESERVED 7*4096)
198216 target_compile_definitions (bootloader PUBLIC
199217 NRF52
200218 NRF52832_XXAA
@@ -207,6 +225,7 @@ if (MCU_VARIANT STREQUAL "nrf52")
207225elseif (MCU_VARIANT STREQUAL "nrf52833" )
208226 set (SD_NAME s140)
209227 set (DFU_DEV_REV 52833)
228+ set (DFU_APP_DATA_RESERVED 7*4096)
210229 target_compile_definitions (bootloader PUBLIC
211230 NRF52833_XXAA
212231 S140
@@ -218,6 +237,8 @@ elseif (MCU_VARIANT STREQUAL "nrf52833")
218237elseif (MCU_VARIANT STREQUAL "nrf52840" )
219238 set (SD_NAME s140)
220239 set (DFU_DEV_REV 52840)
240+ # App reserved 40KB (8+32) to match circuitpython for 840
241+ set (DFU_APP_DATA_RESERVED 10*4096)
221242 target_compile_definitions (bootloader PUBLIC
222243 NRF52840_XXAA
223244 S140
@@ -233,6 +254,10 @@ endif ()
233254set (SD_FILENAME ${SD_NAME} _nrf52_${SD_VERSION} )
234255set (SD_HEX ${SOFTDEVICE} /${SD_FILENAME} /${SD_FILENAME} _softdevice.hex)
235256
257+ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
258+ target_compile_definitions (bootloader PUBLIC DFU_APP_DATA_RESERVED=${DFU_APP_DATA_RESERVED} )
259+ endif ()
260+
236261#----------------------------------
237262# Get UF2 version from git
238263#----------------------------------
@@ -257,12 +282,12 @@ math(EXPR MK_BOOTLOADER_VERSION "(${RELEASE_VERSION_MAJOR} << 16) + (${RELEASE_V
257282cmake_print_variables(GIT_VERSION GIT_SUBMODULE_VERSIONS MK_BOOTLOADER_VERSION)
258283
259284target_compile_definitions (bootloader PUBLIC
285+ UF2_VERSION_BASE="${GIT_VERSION} "
260286 UF2_VERSION="${GIT_VERSION} - ${GIT_SUBMODULE_VERSIONS} "
261287 BLEDIS_FW_VERSION="${GIT_VERSION} ${SD_NAME} ${SD_VERSION} "
262288 MK_BOOTLOADER_VERSION=${MK_BOOTLOADER_VERSION}
263289 )
264290
265-
266291#----------------------------------
267292# Post build
268293#----------------------------------
0 commit comments