mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_HAL_ChibiOS: add and use AP_BOOTLOADER_FLASHING_ENABLED
This commit is contained in:
parent
401de797ed
commit
926c7d64b1
@ -253,9 +253,10 @@ uint64_t Util::get_hw_rtc() const
|
|||||||
return stm32_get_utc_usec();
|
return stm32_get_utc_usec();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(HAL_NO_FLASH_SUPPORT) && !defined(HAL_NO_ROMFS_SUPPORT)
|
|
||||||
|
|
||||||
#include <GCS_MAVLink/GCS.h>
|
#include <GCS_MAVLink/GCS.h>
|
||||||
|
|
||||||
|
#if AP_BOOTLOADER_FLASHING_ENABLED
|
||||||
|
|
||||||
#if HAL_GCS_ENABLED
|
#if HAL_GCS_ENABLED
|
||||||
#define Debug(fmt, args ...) do { gcs().send_text(MAV_SEVERITY_INFO, fmt, ## args); } while (0)
|
#define Debug(fmt, args ...) do { gcs().send_text(MAV_SEVERITY_INFO, fmt, ## args); } while (0)
|
||||||
#endif // HAL_GCS_ENABLED
|
#endif // HAL_GCS_ENABLED
|
||||||
@ -264,6 +265,10 @@ uint64_t Util::get_hw_rtc() const
|
|||||||
#define Debug(fmt, args ...) do { hal.console->printf(fmt, ## args); } while (0)
|
#define Debug(fmt, args ...) do { hal.console->printf(fmt, ## args); } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAL_NO_FLASH_SUPPORT
|
||||||
|
#error "Bootloader-flashing enabled but no flashing support"
|
||||||
|
#endif
|
||||||
|
|
||||||
Util::FlashBootloader Util::flash_bootloader()
|
Util::FlashBootloader Util::flash_bootloader()
|
||||||
{
|
{
|
||||||
uint32_t fw_size;
|
uint32_t fw_size;
|
||||||
@ -371,7 +376,7 @@ Util::FlashBootloader Util::flash_bootloader()
|
|||||||
AP_ROMFS::free(fw);
|
AP_ROMFS::free(fw);
|
||||||
return FlashBootloader::FAIL;
|
return FlashBootloader::FAIL;
|
||||||
}
|
}
|
||||||
#endif // !HAL_NO_FLASH_SUPPORT && !HAL_NO_ROMFS_SUPPORT
|
#endif // AP_BOOTLOADER_FLASHING_ENABLED
|
||||||
|
|
||||||
/*
|
/*
|
||||||
display system identifer - board type and serial number
|
display system identifer - board type and serial number
|
||||||
|
@ -30,6 +30,10 @@ class ExpandingString;
|
|||||||
#define HAL_ENABLE_SAVE_PERSISTENT_PARAMS (defined(STM32F7) || defined(STM32H7))
|
#define HAL_ENABLE_SAVE_PERSISTENT_PARAMS (defined(STM32F7) || defined(STM32H7))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef AP_BOOTLOADER_FLASHING_ENABLED
|
||||||
|
#define AP_BOOTLOADER_FLASHING_ENABLED 0
|
||||||
|
#endif
|
||||||
|
|
||||||
class ChibiOS::Util : public AP_HAL::Util {
|
class ChibiOS::Util : public AP_HAL::Util {
|
||||||
public:
|
public:
|
||||||
static Util *from(AP_HAL::Util *util) {
|
static Util *from(AP_HAL::Util *util) {
|
||||||
@ -126,7 +130,7 @@ private:
|
|||||||
get system clock in UTC microseconds
|
get system clock in UTC microseconds
|
||||||
*/
|
*/
|
||||||
uint64_t get_hw_rtc() const override;
|
uint64_t get_hw_rtc() const override;
|
||||||
#if !defined(HAL_NO_FLASH_SUPPORT) && !defined(HAL_NO_ROMFS_SUPPORT)
|
#if AP_BOOTLOADER_FLASHING_ENABLED
|
||||||
FlashBootloader flash_bootloader() override;
|
FlashBootloader flash_bootloader() override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ define AP_PERIPH_RANGEFINDER_PORT_DEFAULT 3
|
|||||||
|
|
||||||
# we're too low on flash with old compiler for bootloader
|
# we're too low on flash with old compiler for bootloader
|
||||||
define HAL_NO_ROMFS_SUPPORT
|
define HAL_NO_ROMFS_SUPPORT
|
||||||
|
define AP_BOOTLOADER_FLASHING_ENABLED 0
|
||||||
|
|
||||||
# setup for MSP
|
# setup for MSP
|
||||||
define HAL_MSP_ENABLED 1
|
define HAL_MSP_ENABLED 1
|
||||||
|
@ -137,5 +137,6 @@ IOMCU_FW 1
|
|||||||
MAIN_STACK 0x200
|
MAIN_STACK 0x200
|
||||||
PROCESS_STACK 0x250
|
PROCESS_STACK 0x250
|
||||||
define HAL_DISABLE_LOOP_DELAY
|
define HAL_DISABLE_LOOP_DELAY
|
||||||
|
define AP_BOOTLOADER_FLASHING_ENABLED 0
|
||||||
|
|
||||||
AUTOBUILD_TARGETS iofirmware
|
AUTOBUILD_TARGETS iofirmware
|
||||||
|
@ -138,4 +138,6 @@ MAIN_STACK 0x200
|
|||||||
PROCESS_STACK 0x250
|
PROCESS_STACK 0x250
|
||||||
define HAL_DISABLE_LOOP_DELAY
|
define HAL_DISABLE_LOOP_DELAY
|
||||||
|
|
||||||
|
define AP_BOOTLOADER_FLASHING_ENABLED 0
|
||||||
|
|
||||||
AUTOBUILD_TARGETS iofirmware
|
AUTOBUILD_TARGETS iofirmware
|
||||||
|
@ -2381,21 +2381,23 @@ def bootloader_path():
|
|||||||
"Tools",
|
"Tools",
|
||||||
"bootloaders",
|
"bootloaders",
|
||||||
bootloader_filename)
|
bootloader_filename)
|
||||||
if os.path.exists(bootloader_path):
|
return bootloader_path
|
||||||
return os.path.realpath(bootloader_path)
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def add_bootloader():
|
def embed_bootloader(f):
|
||||||
'''added bootloader to ROMFS'''
|
'''added bootloader to ROMFS'''
|
||||||
bp = bootloader_path()
|
if not intdefines.get('AP_BOOTLOADER_FLASHING_ENABLED', 1):
|
||||||
if bp is not None and int(get_config('BOOTLOADER_EMBED', required=False, default='1')):
|
# or, you know, not...
|
||||||
romfs["bootloader.bin"] = bp
|
return
|
||||||
env_vars['BOOTLOADER_EMBED'] = 1
|
|
||||||
else:
|
|
||||||
env_vars['BOOTLOADER_EMBED'] = 0
|
|
||||||
|
|
||||||
|
bp = bootloader_path()
|
||||||
|
if not os.path.exists(bp):
|
||||||
|
return
|
||||||
|
|
||||||
|
bp = os.path.realpath(bp)
|
||||||
|
|
||||||
|
romfs["bootloader.bin"] = bp
|
||||||
|
f.write("#define AP_BOOTLOADER_FLASHING_ENABLED 1\n")
|
||||||
|
|
||||||
|
|
||||||
def write_ROMFS(outdir):
|
def write_ROMFS(outdir):
|
||||||
@ -2559,7 +2561,7 @@ def write_hwdef_header(outfilename):
|
|||||||
setup_apj_IDs()
|
setup_apj_IDs()
|
||||||
write_USB_config(f)
|
write_USB_config(f)
|
||||||
|
|
||||||
add_bootloader()
|
embed_bootloader(f)
|
||||||
|
|
||||||
if len(romfs) > 0:
|
if len(romfs) > 0:
|
||||||
f.write('#define HAL_HAVE_AP_ROMFS_EMBEDDED_H 1\n')
|
f.write('#define HAL_HAVE_AP_ROMFS_EMBEDDED_H 1\n')
|
||||||
|
Loading…
Reference in New Issue
Block a user