mirror of https://github.com/ArduPilot/ardupilot
HAL_ChibiOS: fixed a bug in processing STORAGE_FLASH_PAGE
when we look in hwdef.dat for STORAGE_FLASH_PAGE we need to recurse into includes, or we may miss it
This commit is contained in:
parent
341b0632af
commit
2a40e85356
|
@ -785,6 +785,20 @@ def get_flash_page_offset_kb(sector):
|
||||||
offset += pages[i]
|
offset += pages[i]
|
||||||
return offset
|
return offset
|
||||||
|
|
||||||
|
def load_file_with_include(fname):
|
||||||
|
'''load a file as an array of lines, processing any include lines'''
|
||||||
|
lines = open(fname,'r').readlines()
|
||||||
|
ret = []
|
||||||
|
for line in lines:
|
||||||
|
if line.startswith("include"):
|
||||||
|
a = shlex.split(line)
|
||||||
|
if len(a) > 1 and a[0] == "include":
|
||||||
|
fname2 = os.path.relpath(os.path.join(os.path.dirname(fname), a[1]))
|
||||||
|
ret.extend(load_file_with_include(fname2))
|
||||||
|
continue
|
||||||
|
ret.append(line)
|
||||||
|
return ret
|
||||||
|
|
||||||
def get_storage_flash_page():
|
def get_storage_flash_page():
|
||||||
'''get STORAGE_FLASH_PAGE either from this hwdef or from hwdef.dat
|
'''get STORAGE_FLASH_PAGE either from this hwdef or from hwdef.dat
|
||||||
in the same directory if this is a bootloader
|
in the same directory if this is a bootloader
|
||||||
|
@ -796,7 +810,7 @@ def get_storage_flash_page():
|
||||||
hwdefdat = args.hwdef[0].replace("-bl", "")
|
hwdefdat = args.hwdef[0].replace("-bl", "")
|
||||||
if os.path.exists(hwdefdat):
|
if os.path.exists(hwdefdat):
|
||||||
ret = None
|
ret = None
|
||||||
lines = open(hwdefdat,'r').readlines()
|
lines = load_file_with_include(hwdefdat)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
result = re.match(r'STORAGE_FLASH_PAGE\s*([0-9]+)', line)
|
result = re.match(r'STORAGE_FLASH_PAGE\s*([0-9]+)', line)
|
||||||
if result:
|
if result:
|
||||||
|
|
Loading…
Reference in New Issue