Skip to content

Commit

Permalink
- add screen/display support for st77xx
Browse files Browse the repository at this point in the history
- able to make spi transfer, but data seem to be off
  • Loading branch information
hathach committed Jan 5, 2024
1 parent 101a54d commit 79add7b
Show file tree
Hide file tree
Showing 10 changed files with 676 additions and 53 deletions.
39 changes: 32 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ set(TUSB ${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb/src)
#-------------------
set(CMAKE_EXECUTABLE_SUFFIX .elf)
add_executable(bootloader)
#set_target_properties(bootloader PROPERTIES OUTPUT_NAME "${BOARD}_bootloader.elf")


# SD_VERSION can be overwritten by board.cmake
if(NOT DEFINED SD_VERSION)
Expand All @@ -51,6 +49,8 @@ target_sources(bootloader PUBLIC
src/dfu_init.c
src/flash_nrf5x.c
src/main.c
src/screen.c
src/images.c
src/boards/boards.c
# nrfx
${NRFX}/drivers/src/nrfx_power.c
Expand Down Expand Up @@ -112,19 +112,37 @@ target_include_directories(bootloader PUBLIC
${SOFTDEVICE}/mbr/headers
)

# Debug option
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# TODO not work yet, also need to add segger rtt, DFU_APP_DATA_RESERVED=0, BOOTLOADER_REGION_START=0xED000
set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}_debug.ld)
message(FATAL_ERROR "Debug build not supported yet")

target_sources(bootloader PUBLIC
lib/SEGGER_RTT/RTT/SEGGER_RTT.c
)
target_include_directories(bootloader PUBLIC
lib/SEGGER_RTT/RTT
)

target_compile_definitions(bootloader PUBLIC
CFG_DEBUG
SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
DFU_APP_DATA_RESERVED=0
)

if (MCU_VARIANT STREQUAL "nrf52840")
target_compile_definitions(bootloader PUBLIC BOOTLOADER_REGION_START=0xEA000)
else ()
target_compile_definitions(bootloader PUBLIC BOOTLOADER_REGION_START=0x6D000)
endif ()
else ()
set(LD_FILE ${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}.ld)
endif ()

target_link_options(bootloader PUBLIC
"LINKER:--script=${LD_FILE}"
-L${NRFX}/mdk
--specs=nosys.specs
--specs=nano.specs
--specs=nosys.specs --specs=nano.specs
)
target_compile_options(bootloader PUBLIC
-fno-builtin
Expand All @@ -149,7 +167,6 @@ target_compile_options(bootloader PUBLIC
)
target_compile_definitions(bootloader PUBLIC
SOFTDEVICE_PRESENT
DFU_APP_DATA_RESERVED=7*4096
)

if (TRACE_ETM STREQUAL "1")
Expand Down Expand Up @@ -195,6 +212,7 @@ endif ()
if (MCU_VARIANT STREQUAL "nrf52")
set(SD_NAME s132)
set(DFU_DEV_REV 0xADAF)
set(DFU_APP_DATA_RESERVED 7*4096)
target_compile_definitions(bootloader PUBLIC
NRF52
NRF52832_XXAA
Expand All @@ -207,6 +225,7 @@ if (MCU_VARIANT STREQUAL "nrf52")
elseif (MCU_VARIANT STREQUAL "nrf52833")
set(SD_NAME s140)
set(DFU_DEV_REV 52833)
set(DFU_APP_DATA_RESERVED 7*4096)
target_compile_definitions(bootloader PUBLIC
NRF52833_XXAA
S140
Expand All @@ -218,6 +237,8 @@ elseif (MCU_VARIANT STREQUAL "nrf52833")
elseif (MCU_VARIANT STREQUAL "nrf52840")
set(SD_NAME s140)
set(DFU_DEV_REV 52840)
# App reserved 40KB (8+32) to match circuitpython for 840
set(DFU_APP_DATA_RESERVED 10*4096)
target_compile_definitions(bootloader PUBLIC
NRF52840_XXAA
S140
Expand All @@ -233,6 +254,10 @@ endif ()
set(SD_FILENAME ${SD_NAME}_nrf52_${SD_VERSION})
set(SD_HEX ${SOFTDEVICE}/${SD_FILENAME}/${SD_FILENAME}_softdevice.hex)

if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(bootloader PUBLIC DFU_APP_DATA_RESERVED=${DFU_APP_DATA_RESERVED})
endif ()

#----------------------------------
# Get UF2 version from git
#----------------------------------
Expand All @@ -257,12 +282,12 @@ math(EXPR MK_BOOTLOADER_VERSION "(${RELEASE_VERSION_MAJOR} << 16) + (${RELEASE_V
cmake_print_variables(GIT_VERSION GIT_SUBMODULE_VERSIONS MK_BOOTLOADER_VERSION)

target_compile_definitions(bootloader PUBLIC
UF2_VERSION_BASE="${GIT_VERSION}"
UF2_VERSION="${GIT_VERSION} - ${GIT_SUBMODULE_VERSIONS}"
BLEDIS_FW_VERSION="${GIT_VERSION} ${SD_NAME} ${SD_VERSION}"
MK_BOOTLOADER_VERSION=${MK_BOOTLOADER_VERSION}
)


#----------------------------------
# Post build
#----------------------------------
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ else ifeq ($(MCU_SUB_VARIANT),nrf52840)
SD_NAME = s140
DFU_DEV_REV = 52840
CFLAGS += -DNRF52840_XXAA -DS140
# App reserved 40KB to match circuitpython for 840
# App reserved 40KB (8+32) to match circuitpython for 840
DFU_APP_DATA_RESERVED=10*4096
else
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
Expand Down Expand Up @@ -328,9 +328,9 @@ ifeq ($(DEBUG), 1)
C_SRC += $(RTT_SRC)/RTT/SEGGER_RTT.c
DFU_APP_DATA_RESERVED = 0

# expand bootloader address to 28KB of reserved app
# expand bootloader address to 28KB/40KB of reserved app
ifeq ($(MCU_SUB_VARIANT),nrf52840)
CFLAGS += -DBOOTLOADER_REGION_START=0xED000
CFLAGS += -DBOOTLOADER_REGION_START=0xEA000
else
CFLAGS += -DBOOTLOADER_REGION_START=0x6D000
endif
Expand Down
2 changes: 1 addition & 1 deletion linker/nrf52840_debug.ld
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MEMORY
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
*/
/* due to lack of flash for debug, we will use reserved app to extend bootloader size */
FLASH (rx) : ORIGIN = 0xF4000-28K, LENGTH = 0xFE000-0xF4000 - 2K + 28K /* 38 KB */
FLASH (rx) : ORIGIN = 0xF4000 - 40K, LENGTH = 0xFE000-0xF4000 - 2K + 40K /* 38 KB */

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

Expand Down
Loading

0 comments on commit 79add7b

Please sign in to comment.