rename hil json debugger to flasher, replace jlink cpu with flasher_args

This commit is contained in:
hathach 2023-12-11 15:23:09 +07:00
parent e1142d4527
commit aa21d50196
No known key found for this signature in database
GPG Key ID: F5D50C6D51D17CBA
3 changed files with 23 additions and 23 deletions

View File

@ -3,23 +3,23 @@
{
"name": "stm32l412nucleo",
"uid": "41003B000E504E5457323020",
"debugger": "jlink",
"debugger_sn": "774470029",
"cpu": "STM32L412KB"
"flasher": "jlink",
"flasher_sn": "774470029",
"flasher_args": "-device STM32L412KB"
},
{
"name": "stm32f746disco",
"uid": "210041000C51343237303334",
"debugger": "jlink",
"debugger_sn": "770935966",
"cpu": "STM32F746NG"
"flasher": "jlink",
"flasher_sn": "770935966",
"flasher_args": "-device STM32F746NG"
},
{
"name": "lpcxpresso43s67",
"uid": "08F000044528BAAA8D858F58C50700F5",
"debugger": "jlink",
"debugger_sn": "728973776",
"cpu": "LPC43S67_M4"
"flasher": "jlink",
"flasher_sn": "728973776",
"flasher_args": "-device LPC43S67_M4"
}
]
}

View File

@ -3,9 +3,9 @@
{
"name": "raspberry_pi_pico",
"uid": "E6614C311B764A37",
"debugger": "openocd",
"debugger_sn": "E6614103E72C1D2F",
"debugger_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\""
"flasher": "openocd",
"flasher_sn": "E6614103E72C1D2F",
"flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\""
},
{
"name": "espressif_s3_devkitc",
@ -13,9 +13,9 @@
"tests": [
"cdc_msc_freertos", "hid_composite_freertos"
],
"debugger": "esptool",
"debugger_sn": "461cb8d7decdeb119be9b506e93fd3f1",
"debugger_args": "-b 1500000"
"flasher": "esptool",
"flasher_sn": "461cb8d7decdeb119be9b506e93fd3f1",
"flasher_args": "-b 1500000"
}
]
}

View File

@ -43,7 +43,7 @@ def get_serial_dev(id, vendor_str, product_str, ifnum):
# known vendor and product
return f'/dev/serial/by-id/usb-{vendor_str}_{product_str}_{id}-if{ifnum:02d}'
else:
# just use id: mostly for cp210x/ftdi debugger
# just use id: mostly for cp210x/ftdi flasher
pattern = f'/dev/serial/by-id/usb-*_{id}-if{ifnum:02d}*'
port_list = glob.glob(pattern)
return port_list[0]
@ -100,14 +100,14 @@ def read_disk_file(id, fname):
# -------------------------------------------------------------
# Flash with debugger
# Flashing firmware
# -------------------------------------------------------------
def flash_jlink(board, firmware):
script = ['halt', 'r', f'loadfile {firmware}', 'r', 'go', 'exit']
with open('flash.jlink', 'w') as f:
f.writelines(f'{s}\n' for s in script)
ret = subprocess.run(
f'JLinkExe -USB {board["debugger_sn"]} -device {board["cpu"]} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink',
f'JLinkExe -USB {board["flasher_sn"]} {board["flasher_args"]} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink',
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
os.remove('flash.jlink')
return ret
@ -115,19 +115,19 @@ def flash_jlink(board, firmware):
def flash_openocd(board, firmware):
ret = subprocess.run(
f'openocd -c "adapter serial {board["debugger_sn"]}" {board["debugger_args"]} -c "program {firmware} reset exit"',
f'openocd -c "adapter serial {board["flasher_sn"]}" {board["flasher_args"]} -c "program {firmware} reset exit"',
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
return ret
def flash_esptool(board, firmware):
port = get_serial_dev(board["debugger_sn"], None, None, 0)
port = get_serial_dev(board["flasher_sn"], None, None, 0)
dir = os.path.dirname(firmware)
with open(f'{dir}/config.env') as f:
IDF_TARGET = json.load(f)['IDF_TARGET']
with open(f'{dir}/flash_args') as f:
flash_args = f.read().strip().replace('\n', ' ')
command = (f'esptool.py --chip {IDF_TARGET} -p {port} {board["debugger_args"]} '
command = (f'esptool.py --chip {IDF_TARGET} -p {port} {board["flasher_args"]} '
f'--before=default_reset --after=hard_reset write_flash {flash_args}')
ret = subprocess.run(command, shell=True, cwd=dir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
return ret
@ -286,7 +286,7 @@ def main(config_file, board):
for item in config_boards:
print(f'Testing board:{item["name"]}')
debugger = item['debugger'].lower()
flasher = item['flasher'].lower()
# default to all tests
if 'tests' in item:
@ -325,7 +325,7 @@ def main(config_file, board):
print(f' {test} ...', end='')
# flash firmware
ret = globals()[f'flash_{debugger}'](item, fw)
ret = globals()[f'flash_{flasher}'](item, fw)
assert ret.returncode == 0, 'Flash failed\n' + ret.stdout.decode()
# run test