Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ Example:
cr52 0x500000 App_CDD_ICCOM_S4_Sample_CR52.srec s4_qspi
g4mh 0x900000 App_CDD_ICCOM_S4_Sample_G4MH.srec s4_qspi

If some loader may have more than one filename, then this loader will be listed multiple times:

Loader Flash address Default file Flash target
------------------------------------------------------------------------------------------------------
bootparam 0x0 bootparam_sa0-4x2g.srec gen3_hf
bl2 0x40000 bl2-h3ulcb-4x2g.srec gen3_hf
bl2 0x40000 bl2-salvator-x-4x1g.srec gen3_hf

### `flash` sub-command

Expand Down Expand Up @@ -399,7 +406,20 @@ For each board there are multiple options possible:

- `ipls` - mandatory - list of bootloaders that can be flashed to this
board. Each entry should have the following options:
- `file` - default file name for said bootloader
- `file` - default file name for said bootloader. Two formats are
supported: string and list. For example

file: bl2-h3ulcb-4x2g.srec

means that only specified file is expected.

file:
- bl2-h3ulcb-4x2g.srec
- bl2-salvator-x-4x1g.srec

means that two filenames are supported, and the script will search
for the files according to the provided list. The first found file
will be used.
- `flash_addr` - address in flash memory where to write this bootloader
- `flash_target` - which "flash_target" to use while writing this
bootloader. Flash targets are described in the one of the
Expand Down
43 changes: 33 additions & 10 deletions rcar_flash/rcar_flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,15 @@ def do_list_loaders(conf, args):
print(header)
print("-" * len(header))
ipls = board["ipls"]
loaders = [
(x, f'0x{ipls[x]["flash_addr"]:x}', ipls[x]["file"], ipls[x]["flash_target"])
for x in ipls.keys()
]

loaders = []
for key, val in ipls.items():
file_field = val["file"]
if isinstance(file_field, str):
file_field = [file_field]
for f in file_field:
loaders.append([key, f'0x{val["flash_addr"]:x}', f, val["flash_target"]])

# Sort twice. First time by address...
loaders.sort(key=lambda x: int(x[1], 16))
# And second time - by "flash_target" attribute
Expand Down Expand Up @@ -156,11 +161,18 @@ def do_flash(conf, args): # noqa: C901
if len(args.loaders) > 1:
raise Exception(
"You can either use 'all' or define list of loaders")
for k in board["ipls"].keys():
loaders[k] = os.path.join(args.path, board["ipls"][k]["file"])
if not os.path.exists(loaders[k]):
for k, ipl_info in board["ipls"].items():
raw_file = ipl_info.get("file", [])
file_candidates = [raw_file] if isinstance(raw_file, str) else raw_file
for filename in file_candidates:
full_path = os.path.join(args.path, filename)
if os.path.exists(full_path):
loaders[k] = full_path
break
else:
raise Exception(
f"File {loaders[k]} for loader {k} does not exists!")
f"No file found for loader '{k}' in {file_candidates}."
)
elif loader_arg == "none":
# "none" is used when you need to upload flash_writer only
# without any flashing of loaders
Expand All @@ -178,8 +190,19 @@ def do_flash(conf, args): # noqa: C901
ipl_name = loader_arg
if ipl_name not in board["ipls"]:
raise Exception(f"Unknown loader name: {ipl_name}")
ipl_file = os.path.join(args.path,
board["ipls"][ipl_name]["file"])

raw_file = board["ipls"][ipl_name].get("file", [])
file_candidates = [raw_file] if isinstance(raw_file, str) else raw_file
for filename in file_candidates:
full_path = os.path.join(args.path, filename)
if os.path.exists(full_path):
ipl_file = full_path
break
else:
raise Exception(
f"No file found for loader '{k}' in {file_candidates}."
)

if not os.path.exists(ipl_file):
raise Exception(
f"File {ipl_file} for loader {ipl_name} does not exists!")
Expand Down