Skip to content

Commit 64d8e34

Browse files
authored
Merge pull request #319 from adafruit/add-slash-screen
Add slash screen
2 parents 101a54d + 3d920bf commit 64d8e34

File tree

14 files changed

+757
-55
lines changed

14 files changed

+757
-55
lines changed

CMakeLists.txt

+44-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cmake_minimum_required(VERSION 3.17)
2+
find_package(Python COMPONENTS Interpreter)
23

34
if (NOT DEFINED BOARD)
45
message(FATAL_ERROR "BOARD is not defined")
@@ -30,13 +31,14 @@ set(SDK ${CMAKE_CURRENT_LIST_DIR}/lib/sdk/components)
3031
set(SOFTDEVICE ${CMAKE_CURRENT_LIST_DIR}/lib/softdevice)
3132
set(TUSB ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src)
3233

34+
set(UF2CONV_PY ${CMAKE_CURRENT_LIST_DIR}/lib/uf2/utils/uf2conv.py)
35+
set(UF2_FAMILY_ID_BOOTLOADER 0xd663823c)
36+
3337
#-------------------
3438
# Bootloader
3539
#-------------------
3640
set(CMAKE_EXECUTABLE_SUFFIX .elf)
3741
add_executable(bootloader)
38-
#set_target_properties(bootloader PROPERTIES OUTPUT_NAME "${BOARD}_bootloader.elf")
39-
4042

4143
# SD_VERSION can be overwritten by board.cmake
4244
if(NOT DEFINED SD_VERSION)
@@ -51,6 +53,8 @@ target_sources(bootloader PUBLIC
5153
src/dfu_init.c
5254
src/flash_nrf5x.c
5355
src/main.c
56+
src/screen.c
57+
src/images.c
5458
src/boards/boards.c
5559
# nrfx
5660
${NRFX}/drivers/src/nrfx_power.c
@@ -112,19 +116,37 @@ target_include_directories(bootloader PUBLIC
112116
${SOFTDEVICE}/mbr/headers
113117
)
114118

119+
# Debug option
115120
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
116121
# TODO not work yet, also need to add segger rtt, DFU_APP_DATA_RESERVED=0, BOOTLOADER_REGION_START=0xED000
117122
set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}_debug.ld)
118-
message(FATAL_ERROR "Debug build not supported yet")
123+
124+
target_sources(bootloader PUBLIC
125+
lib/SEGGER_RTT/RTT/SEGGER_RTT.c
126+
)
127+
target_include_directories(bootloader PUBLIC
128+
lib/SEGGER_RTT/RTT
129+
)
130+
131+
target_compile_definitions(bootloader PUBLIC
132+
CFG_DEBUG
133+
SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
134+
DFU_APP_DATA_RESERVED=0
135+
)
136+
137+
if (MCU_VARIANT STREQUAL "nrf52840")
138+
target_compile_definitions(bootloader PUBLIC BOOTLOADER_REGION_START=0xEA000)
139+
else ()
140+
target_compile_definitions(bootloader PUBLIC BOOTLOADER_REGION_START=0x6D000)
141+
endif ()
119142
else ()
120143
set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}.ld)
121144
endif ()
122145

123146
target_link_options(bootloader PUBLIC
124147
"LINKER:--script=${LD_FILE}"
125148
-L${NRFX}/mdk
126-
--specs=nosys.specs
127-
--specs=nano.specs
149+
--specs=nosys.specs --specs=nano.specs
128150
)
129151
target_compile_options(bootloader PUBLIC
130152
-fno-builtin
@@ -149,7 +171,6 @@ target_compile_options(bootloader PUBLIC
149171
)
150172
target_compile_definitions(bootloader PUBLIC
151173
SOFTDEVICE_PRESENT
152-
DFU_APP_DATA_RESERVED=7*4096
153174
)
154175

155176
if (TRACE_ETM STREQUAL "1")
@@ -195,6 +216,7 @@ endif ()
195216
if (MCU_VARIANT STREQUAL "nrf52")
196217
set(SD_NAME s132)
197218
set(DFU_DEV_REV 0xADAF)
219+
set(DFU_APP_DATA_RESERVED 7*4096)
198220
target_compile_definitions(bootloader PUBLIC
199221
NRF52
200222
NRF52832_XXAA
@@ -207,6 +229,7 @@ if (MCU_VARIANT STREQUAL "nrf52")
207229
elseif (MCU_VARIANT STREQUAL "nrf52833")
208230
set(SD_NAME s140)
209231
set(DFU_DEV_REV 52833)
232+
set(DFU_APP_DATA_RESERVED 7*4096)
210233
target_compile_definitions(bootloader PUBLIC
211234
NRF52833_XXAA
212235
S140
@@ -218,6 +241,8 @@ elseif (MCU_VARIANT STREQUAL "nrf52833")
218241
elseif (MCU_VARIANT STREQUAL "nrf52840")
219242
set(SD_NAME s140)
220243
set(DFU_DEV_REV 52840)
244+
# App reserved 40KB (8+32) to match circuitpython for 840
245+
set(DFU_APP_DATA_RESERVED 10*4096)
221246
target_compile_definitions(bootloader PUBLIC
222247
NRF52840_XXAA
223248
S140
@@ -233,6 +258,10 @@ endif ()
233258
set(SD_FILENAME ${SD_NAME}_nrf52_${SD_VERSION})
234259
set(SD_HEX ${SOFTDEVICE}/${SD_FILENAME}/${SD_FILENAME}_softdevice.hex)
235260

261+
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
262+
target_compile_definitions(bootloader PUBLIC DFU_APP_DATA_RESERVED=${DFU_APP_DATA_RESERVED})
263+
endif ()
264+
236265
#----------------------------------
237266
# Get UF2 version from git
238267
#----------------------------------
@@ -257,12 +286,12 @@ math(EXPR MK_BOOTLOADER_VERSION "(${RELEASE_VERSION_MAJOR} << 16) + (${RELEASE_V
257286
cmake_print_variables(GIT_VERSION GIT_SUBMODULE_VERSIONS MK_BOOTLOADER_VERSION)
258287

259288
target_compile_definitions(bootloader PUBLIC
289+
UF2_VERSION_BASE="${GIT_VERSION}"
260290
UF2_VERSION="${GIT_VERSION} - ${GIT_SUBMODULE_VERSIONS}"
261291
BLEDIS_FW_VERSION="${GIT_VERSION} ${SD_NAME} ${SD_VERSION}"
262292
MK_BOOTLOADER_VERSION=${MK_BOOTLOADER_VERSION}
263293
)
264294

265-
266295
#----------------------------------
267296
# Post build
268297
#----------------------------------
@@ -276,6 +305,8 @@ add_custom_command(TARGET bootloader POST_BUILD
276305
add_custom_command(TARGET bootloader POST_BUILD
277306
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.bin
278307
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:bootloader> $<TARGET_FILE_DIR:bootloader>/bootloader.hex
308+
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/tools/hexmerge.py --overlap=replace -o $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.hex $<TARGET_FILE_DIR:bootloader>/bootloader.hex ${MBR_HEX}
309+
COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID_BOOTLOADER} -c -o $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.uf2 $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.hex
279310
VERBATIM)
280311

281312
#----------------------------------
@@ -286,11 +317,16 @@ if (NOT DEFINED NRFJPROG)
286317
set(NRFJPROG nrfjprog)
287318
endif()
288319

289-
add_custom_target(flash
320+
add_custom_target(flash-jlink
290321
DEPENDS bootloader
291322
COMMAND ${NRFJPROG} --program $<TARGET_FILE:bootloader> --verify --sectoranduicrerase -f nrf52 --reset
292323
)
293324

325+
add_custom_target(flash-uf2
326+
DEPENDS bootloader
327+
COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID_BOOTLOADER} --deploy $<TARGET_FILE_DIR:bootloader>/bootloader_mbr.uf2
328+
)
329+
294330
add_custom_target(flash-sd
295331
COMMAND ${NRFJPROG} --program ${SD_HEX} --verify --sectorerase -f nrf52 --reset
296332
)

Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ else ifeq ($(MCU_SUB_VARIANT),nrf52840)
123123
SD_NAME = s140
124124
DFU_DEV_REV = 52840
125125
CFLAGS += -DNRF52840_XXAA -DS140
126-
# App reserved 40KB to match circuitpython for 840
126+
# App reserved 40KB (8+32) to match circuitpython for 840
127127
DFU_APP_DATA_RESERVED=10*4096
128128
else
129129
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
@@ -139,6 +139,8 @@ C_SRC += \
139139
src/dfu_init.c \
140140
src/flash_nrf5x.c \
141141
src/main.c \
142+
src/screen.c \
143+
src/images.c \
142144

143145
# all files in boards
144146
C_SRC += src/boards/boards.c
@@ -314,6 +316,7 @@ ifneq ($(USE_NFCT),yes)
314316
endif
315317

316318
CFLAGS += -DSOFTDEVICE_PRESENT
319+
CFLAGS += -DUF2_VERSION_BASE='"$(GIT_VERSION)"'
317320
CFLAGS += -DUF2_VERSION='"$(GIT_VERSION) $(GIT_SUBMODULE_VERSIONS)"'
318321
CFLAGS += -DBLEDIS_FW_VERSION='"$(GIT_VERSION) $(SD_NAME) $(SD_VERSION)"'
319322

@@ -328,9 +331,9 @@ ifeq ($(DEBUG), 1)
328331
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
329332
DFU_APP_DATA_RESERVED = 0
330333

331-
# expand bootloader address to 28KB of reserved app
334+
# expand bootloader address to 28KB/40KB of reserved app
332335
ifeq ($(MCU_SUB_VARIANT),nrf52840)
333-
CFLAGS += -DBOOTLOADER_REGION_START=0xED000
336+
CFLAGS += -DBOOTLOADER_REGION_START=0xEA000
334337
else
335338
CFLAGS += -DBOOTLOADER_REGION_START=0x6D000
336339
endif

linker/nrf52840_debug.ld

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ MEMORY
1212
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
1313
*/
1414
/* due to lack of flash for debug, we will use reserved app to extend bootloader size */
15-
FLASH (rx) : ORIGIN = 0xF4000-28K, LENGTH = 0xFE000-0xF4000 - 2K + 28K /* 38 KB */
15+
FLASH (rx) : ORIGIN = 0xF4000 - 40K, LENGTH = 0xFE000-0xF4000 - 2K + 40K /* 38 KB */
1616

1717
BOOTLOADER_CONFIG (r): ORIGIN = 0xFE000 - 2K, LENGTH = 2K
1818

0 commit comments

Comments
 (0)