Skip to content

Commit 79add7b

Browse files
committed
- add screen/display support for st77xx
- able to make spi transfer, but data seem to be off
1 parent 101a54d commit 79add7b

File tree

10 files changed

+676
-53
lines changed

10 files changed

+676
-53
lines changed

CMakeLists.txt

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ set(TUSB ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src)
3535
#-------------------
3636
set(CMAKE_EXECUTABLE_SUFFIX .elf)
3737
add_executable(bootloader)
38-
#set_target_properties(bootloader PROPERTIES OUTPUT_NAME "${BOARD}_bootloader.elf")
39-
4038

4139
# SD_VERSION can be overwritten by board.cmake
4240
if(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
115116
if (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 ()
119138
else ()
120139
set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}.ld)
121140
endif ()
122141

123142
target_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
)
129147
target_compile_options(bootloader PUBLIC
130148
-fno-builtin
@@ -149,7 +167,6 @@ target_compile_options(bootloader PUBLIC
149167
)
150168
target_compile_definitions(bootloader PUBLIC
151169
SOFTDEVICE_PRESENT
152-
DFU_APP_DATA_RESERVED=7*4096
153170
)
154171

155172
if (TRACE_ETM STREQUAL "1")
@@ -195,6 +212,7 @@ endif ()
195212
if (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")
207225
elseif (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")
218237
elseif (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 ()
233254
set(SD_FILENAME ${SD_NAME}_nrf52_${SD_VERSION})
234255
set(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
257282
cmake_print_variables(GIT_VERSION GIT_SUBMODULE_VERSIONS MK_BOOTLOADER_VERSION)
258283

259284
target_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
#----------------------------------

Makefile

Lines changed: 3 additions & 3 deletions
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)
@@ -328,9 +328,9 @@ ifeq ($(DEBUG), 1)
328328
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
329329
DFU_APP_DATA_RESERVED = 0
330330

331-
# expand bootloader address to 28KB of reserved app
331+
# expand bootloader address to 28KB/40KB of reserved app
332332
ifeq ($(MCU_SUB_VARIANT),nrf52840)
333-
CFLAGS += -DBOOTLOADER_REGION_START=0xED000
333+
CFLAGS += -DBOOTLOADER_REGION_START=0xEA000
334334
else
335335
CFLAGS += -DBOOTLOADER_REGION_START=0x6D000
336336
endif

linker/nrf52840_debug.ld

Lines changed: 1 addition & 1 deletion
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)