mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
bl_update: build and include board bootloader if config available
This commit is contained in:
committed by
Lorenz Meier
parent
850821f47f
commit
a694f0bbdd
@@ -120,15 +120,6 @@ add_custom_command(
|
|||||||
# copy extras into ROMFS
|
# copy extras into ROMFS
|
||||||
set(extras_dependencies)
|
set(extras_dependencies)
|
||||||
|
|
||||||
# copy px4io binary if configured
|
|
||||||
if(config_io_board)
|
|
||||||
list(APPEND extras_dependencies
|
|
||||||
copy_px4io_bin
|
|
||||||
${fw_io_bin}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(config_bl_file)
|
if(config_bl_file)
|
||||||
file(MAKE_DIRECTORY ${PX4_BINARY_DIR}/romfs_extras)
|
file(MAKE_DIRECTORY ${PX4_BINARY_DIR}/romfs_extras)
|
||||||
configure_file(${config_bl_file} ${PX4_BINARY_DIR}/romfs_extras COPYONLY)
|
configure_file(${config_bl_file} ${PX4_BINARY_DIR}/romfs_extras COPYONLY)
|
||||||
@@ -138,6 +129,21 @@ if(config_bl_file)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# copy px4io binary if configured
|
||||||
|
if(config_io_board)
|
||||||
|
list(APPEND extras_dependencies
|
||||||
|
copy_px4io_bin
|
||||||
|
${fw_io_bin}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(config_build_bootloader)
|
||||||
|
list(APPEND extras_dependencies
|
||||||
|
copy_bootloader_bin
|
||||||
|
${bootloader_bin}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(OPTIONAL_BOARD_RC)
|
set(OPTIONAL_BOARD_RC)
|
||||||
list(APPEND OPTIONAL_BOARD_RC
|
list(APPEND OPTIONAL_BOARD_RC
|
||||||
rc.board_defaults
|
rc.board_defaults
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ px4_add_board(
|
|||||||
TOOLCHAIN arm-none-eabi
|
TOOLCHAIN arm-none-eabi
|
||||||
ARCHITECTURE cortex-m7
|
ARCHITECTURE cortex-m7
|
||||||
ROMFSROOT px4fmu_common
|
ROMFSROOT px4fmu_common
|
||||||
|
BUILD_BOOTLOADER
|
||||||
IO px4_io-v2_default
|
IO px4_io-v2_default
|
||||||
TESTING
|
TESTING
|
||||||
# UAVCAN_INTERFACES 2 - No H7 or FD can support in UAVCAN
|
# 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 ]
|
if [ $AUTOCNF = yes ]
|
||||||
then
|
then
|
||||||
# Enable IMU thermal control
|
# Enable IMU thermal control
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
# [ TOOLCHAIN <string> ]
|
# [ TOOLCHAIN <string> ]
|
||||||
# [ ARCHITECTURE <string> ]
|
# [ ARCHITECTURE <string> ]
|
||||||
# [ ROMFSROOT <string> ]
|
# [ ROMFSROOT <string> ]
|
||||||
|
# [ BUILD_BOOTLOADER ]
|
||||||
# [ IO <string> ]
|
# [ IO <string> ]
|
||||||
# [ BOOTLOADER <string> ]
|
# [ BOOTLOADER <string> ]
|
||||||
# [ UAVCAN_INTERFACES <string> ]
|
# [ UAVCAN_INTERFACES <string> ]
|
||||||
@@ -67,6 +68,7 @@
|
|||||||
# TOOLCHAIN : cmake toolchain
|
# TOOLCHAIN : cmake toolchain
|
||||||
# ARCHITECTURE : name of the CPU CMake is building for (used by the 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)
|
# 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)
|
# 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)
|
# BOOTLOADER : bootloader file to include for flashing via bl_update (currently NuttX only)
|
||||||
# UAVCAN_INTERFACES : number of interfaces for UAVCAN
|
# UAVCAN_INTERFACES : number of interfaces for UAVCAN
|
||||||
@@ -148,6 +150,7 @@ function(px4_add_board)
|
|||||||
SERIAL_PORTS
|
SERIAL_PORTS
|
||||||
DF_DRIVERS
|
DF_DRIVERS
|
||||||
OPTIONS
|
OPTIONS
|
||||||
|
BUILD_BOOTLOADER
|
||||||
CONSTRAINED_FLASH
|
CONSTRAINED_FLASH
|
||||||
TESTING
|
TESTING
|
||||||
REQUIRED
|
REQUIRED
|
||||||
@@ -204,6 +207,10 @@ function(px4_add_board)
|
|||||||
if(ROMFSROOT)
|
if(ROMFSROOT)
|
||||||
set(config_romfs_root ${ROMFSROOT} CACHE INTERNAL "ROMFS root" FORCE)
|
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)
|
# IO board (placed in ROMFS)
|
||||||
if(IO)
|
if(IO)
|
||||||
set(config_io_board ${IO} CACHE INTERNAL "IO" FORCE)
|
set(config_io_board ${IO} CACHE INTERNAL "IO" FORCE)
|
||||||
|
|||||||
@@ -38,4 +38,43 @@ px4_add_module(
|
|||||||
-Wno-cast-align # TODO: fix and enable
|
-Wno-cast-align # TODO: fix and enable
|
||||||
SRCS
|
SRCS
|
||||||
bl_update.c
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user