Skip to content

Conversation

@mehrdadh
Copy link
Member

@mehrdadh mehrdadh commented Jan 7, 2023

This PR adds serial number to flash command (nrfjprog) to fix cases where multiple devices are available.

cc @gromero

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jan 7, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@github-actions github-actions bot requested a review from gromero January 7, 2023 01:45
@mehrdadh mehrdadh requested a review from guberti January 9, 2023 18:54
Copy link
Member

@guberti guberti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just two nits.

if _get_flash_runner() == "openocd" and serial_number:
flash_extra_args = ["--cmd-pre-init", f"""hla_serial {serial_number}"""]
if flash_runner == "openocd" and serial_number:
flash_extra_args += ["--cmd-pre-init", f"""hla_serial {serial_number}"""]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
flash_extra_args += ["--cmd-pre-init", f"""hla_serial {serial_number}"""]
flash_extra_args += ["--cmd-pre-init", f"hla_serial {serial_number}"]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember testing this without "" around the hla_serial option and it was not working

Copy link
Contributor

@gromero gromero Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mehrdadh I wonder if it would be f'"hla_serial {serial_number}"', because afaics the triple double-quote in f-string won't expand to an additional double quote -- as I think @guberti pointed out, but I also think it's necessary one double-quite in the final string for the command as you said / experimented.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will test this again and fix it in a follow up PR if that was the case

def _get_nrf_device_args(serial_number: str = None) -> list:
# iSerial has string type which could mistmatch with
# the output of `nrfjprog --ids`. Example: 001050007848 vs 1050007848
serial_number = str(int(serial_number))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be cleaner to do this? Not sure.

Suggested change
serial_number = str(int(serial_number))
serial_number = serial_number.lstrip("0")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@gromero gromero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@gromero gromero changed the title [microTVM][Zephyr]Fix flash command for nrfjprog [microTVM][Zephyr] Fix flash command for nrfjprog Jan 9, 2023
@mehrdadh mehrdadh merged commit 687ec78 into main Jan 9, 2023
@mehrdadh mehrdadh deleted the micro/fix_nrf_flash branch January 9, 2023 22:24
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
This PR adds serial number to flash command (nrfjprog) to fix cases where multiple devices are available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants