AP_HAL_ChibiOS: avoid use of global args in ChibiOSHWdef object

This commit is contained in:
Peter Barker 2024-09-03 14:55:38 +10:00 committed by Peter Barker
parent b971046a07
commit 53b726271f
1 changed files with 8 additions and 8 deletions

View File

@ -866,8 +866,8 @@ class ChibiOSHWDef(object):
storage_flash_page = self.get_config('STORAGE_FLASH_PAGE', default=None, type=int, required=False)
if storage_flash_page is not None:
return storage_flash_page
if self.is_bootloader_fw() and args.hwdef[0].find("-bl") != -1:
hwdefdat = args.hwdef[0].replace("-bl", "")
if self.is_bootloader_fw() and self.hwdef[0].find("-bl") != -1:
hwdefdat = self.hwdef[0].replace("-bl", "")
if os.path.exists(hwdefdat):
ret = None
lines = self.load_file_with_include(hwdefdat)
@ -927,7 +927,7 @@ class ChibiOSHWDef(object):
def write_mcu_config(self, f):
'''write MCU config defines'''
f.write('#define CHIBIOS_BOARD_NAME "%s"\n' % os.path.basename(os.path.dirname(args.hwdef[0])))
f.write('#define CHIBIOS_BOARD_NAME "%s"\n' % os.path.basename(os.path.dirname(self.hwdef[0])))
f.write('// MCU type (ChibiOS define)\n')
f.write('#define %s_MCUCONF\n' % self.get_config('MCU'))
mcu_subtype = self.get_config('MCU', 1)
@ -2464,7 +2464,7 @@ INCLUDE common.ld
# always embed a bootloader if it is available
this_dir = os.path.realpath(__file__)
rootdir = os.path.relpath(os.path.join(this_dir, "../../../../.."))
hwdef_dirname = os.path.basename(os.path.dirname(args.hwdef[0]))
hwdef_dirname = os.path.basename(os.path.dirname(self.hwdef[0]))
# allow re-using of bootloader from different build:
use_bootloader_from_board = self.get_config('USE_BOOTLOADER_FROM_BOARD', default=None, required=False)
if use_bootloader_from_board is not None:
@ -2493,7 +2493,7 @@ INCLUDE common.ld
self.error('''Bootloader (%s) does not exist and AP_BOOTLOADER_FLASHING_ENABLED
Please run: Tools/scripts/build_bootloaders.py %s
''' %
(bp, os.path.basename(os.path.dirname(args.hwdef[0]))))
(bp, os.path.basename(os.path.dirname(self.hwdef[0]))))
bp = os.path.realpath(bp)
@ -2888,8 +2888,8 @@ Please run: Tools/scripts/build_bootloaders.py %s
def write_processed_defaults_file(self, filepath):
# see if board has a defaults.parm file or a --default-parameters file was specified
defaults_filename = os.path.join(os.path.dirname(args.hwdef[0]), 'defaults.parm')
defaults_path = os.path.join(os.path.dirname(args.hwdef[0]), args.params)
defaults_filename = os.path.join(os.path.dirname(self.hwdef[0]), 'defaults.parm')
defaults_path = os.path.join(os.path.dirname(self.hwdef[0]), args.params)
defaults_abspath = None
if os.path.exists(defaults_path):
@ -2934,7 +2934,7 @@ Please run: Tools/scripts/build_bootloaders.py %s
if relative_to_base:
romfs_dir = os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', dirname)
else:
romfs_dir = os.path.join(os.path.dirname(args.hwdef[0]), dirname)
romfs_dir = os.path.join(os.path.dirname(self.hwdef[0]), dirname)
if not self.is_bootloader_fw() and os.path.exists(romfs_dir):
for root, d, files in os.walk(romfs_dir):
for f in files: