Skip to content

Commit

Permalink
AP_HAL_ChibiOS: fix setting APP_RAM size
Browse files Browse the repository at this point in the history
also allows passing APP_RAM_START index through hwdef
  • Loading branch information
bugobliterator committed Oct 16, 2023
1 parent 1255f97 commit 85a5dfd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -1111,16 +1112,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])
Expand Down Expand Up @@ -3039,6 +3041,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):
Expand Down

0 comments on commit 85a5dfd

Please sign in to comment.