mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
HAL_ChibiOS: shrink build size for bootloader
thanks to @sh83 for the idea
This commit is contained in:
parent
c28296e6f2
commit
14f66461a7
@ -238,14 +238,16 @@ def configure(cfg):
|
||||
|
||||
if env.BOOTLOADER:
|
||||
env.HWDEF = srcpath('libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef-bl.dat' % env.BOARD)
|
||||
env.BOOTLOADER_OPTION="--bootloader"
|
||||
else:
|
||||
env.HWDEF = srcpath('libraries/AP_HAL_ChibiOS/hwdef/%s/hwdef.dat' % env.BOARD)
|
||||
env.BOOTLOADER_OPTION=""
|
||||
hwdef_script = srcpath('libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py')
|
||||
hwdef_out = env.BUILDROOT
|
||||
if not os.path.exists(hwdef_out):
|
||||
os.mkdir(hwdef_out)
|
||||
try:
|
||||
cmd = "python '{0}' -D '{1}' '{2}'".format(hwdef_script, hwdef_out, env.HWDEF)
|
||||
cmd = "python '{0}' -D '{1}' '{2}' {3}".format(hwdef_script, hwdef_out, env.HWDEF, env.BOOTLOADER_OPTION)
|
||||
ret = subprocess.call(cmd, shell=True)
|
||||
except Exception:
|
||||
cfg.fatal("Failed to process hwdef.dat")
|
||||
@ -266,7 +268,7 @@ def build(bld):
|
||||
bld(
|
||||
# build hwdef.h and apj.prototype from hwdef.dat. This is needed after a waf clean
|
||||
source=bld.path.ant_glob(bld.env.HWDEF),
|
||||
rule="python '${AP_HAL_ROOT}/hwdef/scripts/chibios_hwdef.py' -D '${BUILDROOT}' %s" % bld.env.HWDEF,
|
||||
rule="python '${AP_HAL_ROOT}/hwdef/scripts/chibios_hwdef.py' -D '${BUILDROOT}' %s %s" % (bld.env.HWDEF, bld.env.BOOTLOADER_OPTION),
|
||||
group='dynamic_sources',
|
||||
target=['hwdef.h', 'apj.prototype', 'ldscript.ld']
|
||||
)
|
||||
|
@ -9,6 +9,8 @@ import shutil
|
||||
parser = argparse.ArgumentParser("chibios_pins.py")
|
||||
parser.add_argument(
|
||||
'-D', '--outdir', type=str, default=None, help='Output directory')
|
||||
parser.add_argument(
|
||||
'--bootloader', action='store_true', default=False, help='configure for bootloader')
|
||||
parser.add_argument(
|
||||
'hwdef', type=str, default=None, help='hardware definition file')
|
||||
|
||||
@ -434,6 +436,15 @@ def write_mcu_config(f):
|
||||
for v in build_info.keys():
|
||||
build_flags.append('%s=%s' % (v, build_info[v]))
|
||||
|
||||
# setup for bootloader build
|
||||
if args.bootloader:
|
||||
f.write('''
|
||||
#define HAL_BOOTLOADER_BUILD TRUE
|
||||
#define HAL_USE_ADC FALSE
|
||||
#define HAL_USE_EXT FALSE
|
||||
#define CH_DBG_STATISTICS FALSE
|
||||
''')
|
||||
|
||||
def write_ldscript(fname):
|
||||
'''write ldscript.ld for this board'''
|
||||
flash_size = get_config('FLASH_SIZE_KB', type=int)
|
||||
|
Loading…
Reference in New Issue
Block a user