Add CMake `QSPI_FLASH` and `OCTOSPI_FLASH` options.

pull/278/head^2
David Garske 2023-01-19 13:06:05 -08:00 committed by Daniele Lacamera
parent 8dd0ee347f
commit e375363bbb
2 changed files with 34 additions and 3 deletions

View File

@ -113,6 +113,8 @@ add_option(
add_option("SIGN" "Configure Digital Signatures Algorithm (default: ECC256)" "ECC256" add_option("SIGN" "Configure Digital Signatures Algorithm (default: ECC256)" "ECC256"
"ECC256;ECC384;ECC521;ED25519;ED448;NONE;RSA2048;RSA4096") "ECC256;ECC384;ECC521;ED25519;ED448;NONE;RSA2048;RSA4096")
add_option("SPI_FLASH" "Use external SPI flash drivers (default: disabled)" "no" "yes;no") add_option("SPI_FLASH" "Use external SPI flash drivers (default: disabled)" "no" "yes;no")
add_option("QSPI_FLASH" "Use external QSPI flash drivers (default: disabled)" "no" "yes;no")
add_option("OCTOSPI_FLASH" "Use external OCTOSPI flash drivers (default: disabled)" "no" "yes;no")
add_option("SPMATH" "Use SP Math (default: disabled)" "no" "yes;no") add_option("SPMATH" "Use SP Math (default: disabled)" "no" "yes;no")
add_option("WOLFBOOT_TARGET" "Target platform to build for (default: stm32h7)" "stm32h7" add_option("WOLFBOOT_TARGET" "Target platform to build for (default: stm32h7)" "stm32h7"
"stm32f4;stm32h7;stm32l0;stm32u5;x86_64_efi;sim") "stm32f4;stm32h7;stm32l0;stm32u5;x86_64_efi;sim")
@ -461,6 +463,14 @@ if(SPI_FLASH)
set(EXT_FLASH ON) set(EXT_FLASH ON)
endif() endif()
if(OCTOSPI_FLASH)
set(QSPI_FLASH ON)
endif()
if(QSPI_FLASH)
set(EXT_FLASH ON)
endif()
if(UART_FLASH) if(UART_FLASH)
set(EXT_FLASH ON) set(EXT_FLASH ON)
endif() endif()
@ -568,6 +578,15 @@ if(SPI_FLASH)
list(APPEND WOLFBOOT_FLASH_SOURCES hal/spi/spi_drv_${SPI_TARGET}.c src/spi_flash.c) list(APPEND WOLFBOOT_FLASH_SOURCES hal/spi/spi_drv_${SPI_TARGET}.c src/spi_flash.c)
endif() endif()
if(QSPI_FLASH)
list(APPEND WOLFBOOT_DEFS QSPI_FLASH)
list(APPEND WOLFBOOT_FLASH_SOURCES hal/spi/spi_drv_${SPI_TARGET}.c src/qspi_flash.c)
endif()
if(OCTOSPI_FLASH)
list(APPEND WOLFBOOT_DEFS OCTOSPI_FLASH)
endif()
if(UART_FLASH) if(UART_FLASH)
list(APPEND WOLFBOOT_DEFS UART_FLASH) list(APPEND WOLFBOOT_DEFS UART_FLASH)
list(APPEND WOLFBOOT_FLASH_SOURCES hal/uart/uart_drv_${UART_TARGET}.c src/uart_flash.c) list(APPEND WOLFBOOT_FLASH_SOURCES hal/uart/uart_drv_${UART_TARGET}.c src/uart_flash.c)
@ -591,7 +610,7 @@ target_sources(wolfboothal PRIVATE include/hal.h hal/${WOLFBOOT_TARGET}.c ${WOLF
${PARTITION_SOURCE}) ${PARTITION_SOURCE})
target_link_libraries(wolfboothal target user_settings) target_link_libraries(wolfboothal target user_settings)
target_compile_definitions(wolfboothal PRIVATE ${WOLFBOOT_DEFS}) target_compile_definitions(wolfboothal PRIVATE ${WOLFBOOT_DEFS})
target_include_directories(wolfboothal PRIVATE include) target_include_directories(wolfboothal PRIVATE ${WOLFBOOT_ROOT} include)
target_compile_options(wolfboothal PRIVATE ${WOLFBOOT_COMPILE_OPTIONS} ${EXTRA_COMPILE_OPTIONS}) target_compile_options(wolfboothal PRIVATE ${WOLFBOOT_COMPILE_OPTIONS} ${EXTRA_COMPILE_OPTIONS})
if(PYTHON_KEYTOOLS) if(PYTHON_KEYTOOLS)

View File

@ -55,6 +55,15 @@ endif()
if(SPI_FLASH) if(SPI_FLASH)
list(APPEND TEST_APP_COMPILE_DEFINITIONS SPI_FLASH) list(APPEND TEST_APP_COMPILE_DEFINITIONS SPI_FLASH)
list(APPEND APP_SOURCES ../hal/spi/spi_drv_${SPI_TARGET}.c ../src/spi_flash.c)
endif()
if(OCTOSPI_FLASH)
set(QSPI_FLASH ON)
list(APPEND TEST_APP_COMPILE_DEFINITIONS OCTOSPI_FLASH)
endif()
if(QSPI_FLASH)
list(APPEND TEST_APP_COMPILE_DEFINITIONS QSPI_FLASH)
list(APPEND APP_SOURCES ../hal/spi/spi_drv_${SPI_TARGET}.c ../src/qspi_flash.c)
endif() endif()
math(EXPR WOLFBOOT_TEST_APP_ADDRESS "${WOLFBOOT_PARTITION_BOOT_ADDRESS} + ${IMAGE_HEADER_SIZE}" math(EXPR WOLFBOOT_TEST_APP_ADDRESS "${WOLFBOOT_PARTITION_BOOT_ADDRESS} + ${IMAGE_HEADER_SIZE}"
@ -95,7 +104,10 @@ add_executable(image)
target_sources(image PRIVATE ${APP_SOURCES}) target_sources(image PRIVATE ${APP_SOURCES})
target_include_directories(image PRIVATE ../include ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(image PRIVATE
../
../include
${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(image wolfboot target) target_link_libraries(image wolfboot target)
@ -118,7 +130,7 @@ if(WOLFBOOT_TARGET IN_LIST ARM_TARGETS)
# add boot address to cache # add boot address to cache
unset(${PLATFORM_NAME}_BOOT_ADDRESS CACHE) unset(${PLATFORM_NAME}_BOOT_ADDRESS CACHE)
set(${PLATFORM_NAME}_BOOT_ADDRESS ${WOLFBOOT_PARTITION_BOOT_ADDRESS} CACHE INTERNAL "") set(${PLATFORM_NAME}_BOOT_ADDRESS ${WOLFBOOT_PARTITION_BOOT_ADDRESS} CACHE INTERNAL "")
gen_wolfboot_factory_image(${PLATFORM_NAME} image) gen_wolfboot_factory_image(${PLATFORM_NAME} image)
else() else()
gen_wolfboot_signed_image(image) gen_wolfboot_signed_image(image)