From 8e6fa5e23304de71601275b7eb8e564d846fe27a Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Mon, 16 Oct 2023 18:05:20 +1100 Subject: [PATCH] AP_HAL_ChibiOS: fix setting APP_RAM size also allows passing APP_RAM_START index through hwdef --- .../AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 8cb3f1fbfc1f91..f4d86a87b51b21 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -749,7 +749,8 @@ def has_sdcard_spi(self): def get_ram_map(self): '''get RAM_MAP. May be different for bootloader''' - self.env_vars['APP_RAM_START'] = None + if 'APP_RAM_START' not in self.env_vars: + self.env_vars['APP_RAM_START'] = None if args.bootloader: ram_map = self.get_mcu_config('RAM_MAP_BOOTLOADER', False) if ram_map is not None: @@ -1099,16 +1100,17 @@ def write_mcu_config(self, f): cc_regions = [] total_memory = 0 for (address, size, flags) in ram_map: - cc_regions.append('{0x%08x, 0x%08x, CRASH_CATCHER_BYTE }' % (address, address + size*1024)) + size *= 1024 + cc_regions.append('{0x%08x, 0x%08x, CRASH_CATCHER_BYTE }' % (address, address + size)) if self.env_vars['APP_RAM_START'] is not None and address == ram_map[self.env_vars['APP_RAM_START']][0]: ram_reserve_start = self.get_ram_reserve_start() address += ram_reserve_start size -= ram_reserve_start - regions.append('{(void*)0x%08x, 0x%08x, 0x%02x }' % (address, size*1024, flags)) + regions.append('{(void*)0x%08x, 0x%08x, 0x%02x }' % (address, size, flags)) total_memory += size f.write('#define HAL_MEMORY_REGIONS %s\n' % ', '.join(regions)) f.write('#define HAL_CC_MEMORY_REGIONS %s\n' % ', '.join(cc_regions)) - f.write('#define HAL_MEMORY_TOTAL_KB %u\n' % total_memory) + f.write('#define HAL_MEMORY_TOTAL_KB %u\n' % (total_memory/1024)) if self.env_vars['APP_RAM_START'] is not None: f.write('#define HAL_RAM0_START 0x%08x\n' % ram_map[self.env_vars['APP_RAM_START']][0]) @@ -3027,6 +3029,8 @@ def process_line(self, line): value = ' '.join(a[2:]) if name == 'AP_PERIPH' and value != "1": raise ValueError("AP_PERIPH may only have value 1") + if name == 'APP_RAM_START': + value = int(value, 0) self.env_vars[name] = value def process_file(self, filename):