forked from Archive/PX4-Autopilot
bl_update: build and include board bootloader if config available
This commit is contained in:
parent
850821f47f
commit
a694f0bbdd
|
@ -120,6 +120,15 @@ add_custom_command(
|
|||
# copy extras into ROMFS
|
||||
set(extras_dependencies)
|
||||
|
||||
if(config_bl_file)
|
||||
file(MAKE_DIRECTORY ${PX4_BINARY_DIR}/romfs_extras)
|
||||
configure_file(${config_bl_file} ${PX4_BINARY_DIR}/romfs_extras COPYONLY)
|
||||
|
||||
list(APPEND extras_dependencies
|
||||
${config_bl_file}
|
||||
)
|
||||
endif()
|
||||
|
||||
# copy px4io binary if configured
|
||||
if(config_io_board)
|
||||
list(APPEND extras_dependencies
|
||||
|
@ -128,13 +137,10 @@ if(config_io_board)
|
|||
)
|
||||
endif()
|
||||
|
||||
|
||||
if(config_bl_file)
|
||||
file(MAKE_DIRECTORY ${PX4_BINARY_DIR}/romfs_extras)
|
||||
configure_file(${config_bl_file} ${PX4_BINARY_DIR}/romfs_extras COPYONLY)
|
||||
|
||||
if(config_build_bootloader)
|
||||
list(APPEND extras_dependencies
|
||||
${config_bl_file}
|
||||
copy_bootloader_bin
|
||||
${bootloader_bin}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ px4_add_board(
|
|||
TOOLCHAIN arm-none-eabi
|
||||
ARCHITECTURE cortex-m7
|
||||
ROMFSROOT px4fmu_common
|
||||
BUILD_BOOTLOADER
|
||||
IO px4_io-v2_default
|
||||
TESTING
|
||||
# UAVCAN_INTERFACES 2 - No H7 or FD can support in UAVCAN
|
||||
|
|
|
@ -4,6 +4,24 @@
|
|||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#
|
||||
# Bootloader upgrade
|
||||
#
|
||||
set BL_FILE /etc/extras/holybro_durandal-v1_bootloader.bin
|
||||
if [ -f $BL_FILE ]
|
||||
then
|
||||
if param compare SYS_BL_UPDATE 1
|
||||
then
|
||||
param set SYS_BL_UPDATE 0
|
||||
param save
|
||||
echo "BL update..." >> $LOG_FILE
|
||||
bl_update $BL_FILE
|
||||
echo "BL update done" >> $LOG_FILE
|
||||
reboot
|
||||
fi
|
||||
fi
|
||||
unset BL_FILE
|
||||
|
||||
if [ $AUTOCNF = yes ]
|
||||
then
|
||||
# Enable IMU thermal control
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
# [ TOOLCHAIN <string> ]
|
||||
# [ ARCHITECTURE <string> ]
|
||||
# [ ROMFSROOT <string> ]
|
||||
# [ BUILD_BOOTLOADER ]
|
||||
# [ IO <string> ]
|
||||
# [ BOOTLOADER <string> ]
|
||||
# [ UAVCAN_INTERFACES <string> ]
|
||||
|
@ -67,6 +68,7 @@
|
|||
# TOOLCHAIN : cmake toolchain
|
||||
# ARCHITECTURE : name of the CPU CMake is building for (used by the toolchain)
|
||||
# ROMFSROOT : relative path to the ROMFS root directory (currently NuttX only)
|
||||
# BUILD_BOOTLOADER : flag to enable building and including the bootloader config
|
||||
# IO : name of IO board to be built and included in the ROMFS (requires a valid ROMFSROOT)
|
||||
# BOOTLOADER : bootloader file to include for flashing via bl_update (currently NuttX only)
|
||||
# UAVCAN_INTERFACES : number of interfaces for UAVCAN
|
||||
|
@ -148,6 +150,7 @@ function(px4_add_board)
|
|||
SERIAL_PORTS
|
||||
DF_DRIVERS
|
||||
OPTIONS
|
||||
BUILD_BOOTLOADER
|
||||
CONSTRAINED_FLASH
|
||||
TESTING
|
||||
REQUIRED
|
||||
|
@ -204,6 +207,10 @@ function(px4_add_board)
|
|||
if(ROMFSROOT)
|
||||
set(config_romfs_root ${ROMFSROOT} CACHE INTERNAL "ROMFS root" FORCE)
|
||||
|
||||
if(BUILD_BOOTLOADER)
|
||||
set(config_build_bootloader "1" CACHE INTERNAL "build bootloader" FORCE)
|
||||
endif()
|
||||
|
||||
# IO board (placed in ROMFS)
|
||||
if(IO)
|
||||
set(config_io_board ${IO} CACHE INTERNAL "IO" FORCE)
|
||||
|
|
|
@ -39,3 +39,42 @@ px4_add_module(
|
|||
SRCS
|
||||
bl_update.c
|
||||
)
|
||||
|
||||
if(config_build_bootloader)
|
||||
# include the bootloader binary in ROMFS
|
||||
set(bootloader_config "${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader")
|
||||
|
||||
if(NOT EXISTS ${PX4_BOARD_DIR}/nuttx-config/bootloader)
|
||||
message(FATAL_ERROR "${bootloader_config} does not exist")
|
||||
endif()
|
||||
|
||||
message(STATUS "Building and including bootloader ${bootloader_config}")
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(bootloader_firmware
|
||||
SOURCE_DIR ${CMAKE_SOURCE_DIR}
|
||||
DOWNLOAD_COMMAND ""
|
||||
UPDATE_COMMAND ""
|
||||
CMAKE_ARGS -DCONFIG=${bootloader_config}
|
||||
INSTALL_COMMAND ""
|
||||
USES_TERMINAL_BUILD true
|
||||
DEPENDS git_nuttx git_nuttx_apps
|
||||
BUILD_ALWAYS 1
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(bootloader_firmware BINARY_DIR)
|
||||
|
||||
set(bootloader_exe "${BINARY_DIR}/${bootloader_config}.elf")
|
||||
set(bootloader_bin "${PX4_BINARY_DIR}/romfs_extras/${bootloader_config}.bin" CACHE FILEPATH "bootloader binary path")
|
||||
|
||||
file(RELATIVE_PATH bootloader_exe_relative ${CMAKE_CURRENT_BINARY_DIR} ${bootloader_exe})
|
||||
file(RELATIVE_PATH bootloader_bin_relative ${CMAKE_CURRENT_BINARY_DIR} ${bootloader_bin})
|
||||
|
||||
add_custom_command(OUTPUT ${bootloader_bin}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${PX4_BINARY_DIR}/romfs_extras
|
||||
COMMAND ${CMAKE_OBJCOPY} -O binary ${bootloader_exe_relative} ${bootloader_bin_relative}
|
||||
DEPENDS bootloader_firmware
|
||||
COMMENT "Copying ${bootloader_config} to ROMFS extras"
|
||||
)
|
||||
add_custom_target(copy_bootloader_bin DEPENDS ${bootloader_bin})
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue