From d84c487a60bad1bd1cbe6d32d35f88122f6fa943 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 1 Mar 2018 16:51:52 +1100 Subject: [PATCH] HAL_ChibiOS: generate env.py from hwdef.dat allowing for environment override in hwdef.dat --- .../AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 14 +++++++++++++- .../AP_HAL_ChibiOS/hwdef/skyviper-f412/hwdef.dat | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index db2721a290..e7498c0856 100755 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -3,7 +3,7 @@ setup board.h for chibios ''' -import argparse, sys, fnmatch, os, dma_resolver, shlex +import argparse, sys, fnmatch, os, dma_resolver, shlex, pickle parser = argparse.ArgumentParser("chibios_pins.py") parser.add_argument( @@ -56,6 +56,9 @@ spi_list = [] # all config lines in order alllines = [] +# allow for extra env vars +env_vars = {} + mcu_type = None @@ -293,6 +296,7 @@ def write_mcu_config(f): f.write('#define HAL_USE_SDC TRUE\n') else: f.write('#define HAL_USE_SDC FALSE\n') + env_vars['CHIBIOS_FATFS_FLAG'] = 'USE_FATFS=no' if 'OTG1' in bytype: f.write('#define STM32_USB_USE_OTG1 TRUE\n') f.write('#define HAL_USE_USB TRUE\n') @@ -942,6 +946,11 @@ def process_line(line): continue newpins.append(pin) allpins = newpins + if a[0] == 'env': + print("Adding environment %s" % ' '.join(a[1:])) + if len(a[1:]) < 2: + error("Bad env line for %s" % a[0]) + env_vars[a[1]] = ' '.join(a[2:]) def process_file(filename): @@ -989,3 +998,6 @@ write_hwdef_header(os.path.join(outdir, "hwdef.h")) # write out ldscript.ld write_ldscript(os.path.join(outdir, "ldscript.ld")) +# write out env.py +pickle.dump(env_vars, open(os.path.join(outdir, "env.py"), "w")) + diff --git a/libraries/AP_HAL_ChibiOS/hwdef/skyviper-f412/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/skyviper-f412/hwdef.dat index 0cefaccb5c..b4f1703d56 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/skyviper-f412/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/skyviper-f412/hwdef.dat @@ -137,3 +137,6 @@ define HAL_BARO_20789_I2C_ADDR_ICM 0x68 # unstick 20789 on I2C on boot define HAL_I2C_CLEAR_BUS + +env DEFINES CONFIG_HAL_BOARD_SUBTYPE='HAL_BOARD_SUBTYPE_CHIBIOS_SKYVIPER_F412' +env DEFAULT_PARAMETERS '../../Tools/Frame_params/SkyViper-F412/defaults.parm'