Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

west: linkserver: Add ELF file support to flash command #75276

Conversation

PetervdPerk-NXP
Copy link
Collaborator

The MCX N SoC has an internal flash but also supports external flash.
For builds with multiple regions use ELF file instead so that all regions get flashed.

dleach02
dleach02 previously approved these changes Jul 3, 2024
# Use .elf, .hex or .bin, preferring .elf over .hex over .bin
if self.elf_name is not None and os.path.isfile(self.elf_name):
flash_cmd = (["load", self.elf_name])
elif self.supports_hex and self.hex_name is not None and os.path.isfile(self.hex_name):
Copy link
Contributor

Choose a reason for hiding this comment

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

To have the same behavior as for all other runners, could you give the highest priority to .hex ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Put hex back to default, thanks for the remark.

Copy link
Contributor

Choose a reason for hiding this comment

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

Put hex back to default, thanks for the remark.

Thanks.

I have reviewed all runners, and .elf is used only for debugging.
For flashing are used .hex and .bin.
Only one OpenOCD runner is able to flash .elf, BUT only if the "use_elf" parameter is set intentionally.
Are you sure that you cannot use .hex for flashing instead?
Afraid, that can be some examples that require flashing of shifted .bin files, and flashing of .elf can brake them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The internal flash on a MCXN is on address 0x0000 0000 the external flash is on 0x8000 0000 when using both regions in your program results in a a generated hex file of around ~3GB. When using west flash it simply fails because I think it's actually trying to write the whole region.

ELF pretty much solves this because it contains a list of sections that need to be programmed.

Copy link
Contributor

Choose a reason for hiding this comment

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

The internal flash on a MCXN is on address 0x0000 0000 the external flash is on 0x8000 0000 when using both regions in your program results in a a generated hex file of around ~3GB. When using west flash it simply fails because I think it's actually trying to write the whole region.

ELF pretty much solves this because it contains a list of sections that need to be programmed.

Hi @PetervdPerk-NXP,
could you point to the example, to test it?

Copy link
Collaborator Author

@PetervdPerk-NXP PetervdPerk-NXP Jul 22, 2024

Choose a reason for hiding this comment

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

Added a new commit it seemed that Linkserver version detect never worked as intended thus faulting when flashing ihex files.

The internal flash on a MCXN is on address 0x0000 0000 the external flash is on 0x8000 0000 when using both regions in your program results in a a generated hex file of around 3GB. When using west flash it simply fails because I think it's actually trying to write the whole region.

Okay it turns you've to set CONFIG_BUILD_NO_GAP_FILL=y to avoid generating big hex files.

Only one OpenOCD runner is able to flash .elf, BUT only if the "use_elf" parameter is set intentionally.

Sure it seems that the other runners haven't implemented it yet, however the API exposes self.elf_name and when CONFIG_BUILD_OUTPUT_HEX=n and CONFIG_BUILD_OUTPUT_BIN=n the build system only outputs an elf file. Hence I believe we should support ELF files for our runner.

Copy link
Contributor

Choose a reason for hiding this comment

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

Added the DNM label.
As we have discussed off-line with @PetervdPerk-NXP

  • it will break MCUBoot examples by flashing .elf instead of signed.bin.
  • the huge .hex/bin issue can be solved by
CONFIG_BUILD_OUTPUT_HEX=y
CONFIG_BUILD_NO_GAP_FILL=y
CONFIG_BUILD_OUTPUT_BIN=n

My proposal:
The ,hex and .bin generation is optional.
As compromise, we can decrease .elf flashing priority.
So the flashing priority can be hex>bin>elf.
As the result, no existing example is broken and the .elf flashing can be supported.

@PetervdPerk-NXP PetervdPerk-NXP changed the title west: linkserver: Use ELF file for flashing west: linkserver: Add ELF file support to flash command Jul 4, 2024
dleach02
dleach02 previously approved these changes Jul 9, 2024
@butok butok requested a review from hakehuang July 19, 2024 12:45
bperseghetti
bperseghetti previously approved these changes Jul 19, 2024
For files with multiple regions use ELF file instead so that all regions
get flashed

Signed-off-by: Peter van der Perk <[email protected]>
version detect never occured correctly and always yielded true

Signed-off-by: Peter van der Perk <[email protected]>
@butok butok added the DNM This PR should not be merged (Do Not Merge) label Jul 23, 2024
@PetervdPerk-NXP
Copy link
Collaborator Author

Apparently MCUboot makes supporting ELF in west flash a pain thus I'm dropping this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: West West utility DNM This PR should not be merged (Do Not Merge)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants