Skip to content

Add big endian support #9

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

Merged
merged 2 commits into from
May 7, 2025
Merged

Conversation

xobs
Copy link
Contributor

@xobs xobs commented May 7, 2025

Add support for generating flash algorithms that work on big endian machines.

There are two patches in this patchset:

  1. The first patch ensures that functions from TI end up in the text section. TI prefixes text symbols with .text: rather than .text.. We can try changing it to *(.text*), but I thought it better to explicitly target symbols this way.
  2. The second patch adds .to_le() to the end of each section. This ensures that all numbers are stored in the header in little endian format, which is preferrable as the header is usually read on a little endian host system. This also necessitates casting the DeviceType to a u16 so we can perform the swap, however the actual type isn't currently used so this is fine.

I have tested this on a TMS570, and the values come through fine with this change. The name field is not swapped, which indicates to me that this is the correct approach.

xobs and others added 2 commits May 7, 2025 12:34
TI names their sections with a `:`. For example,
`.text:Fapi_issueAsyncCommand`. Add this as a recognized section prefix when
placing symbols into the text section.

Signed-off-by: Sean Cross <[email protected]>
With big endian devices, the symbols are stored in big endian order. This is
fine if the header is getting loaded onto the target, however the header is
only for use with the host system, which is almost alays little endian.

Ensure each field of the header is correctly swapped by adding `.to_le()` to
each field. Additionally, ensure all fields are primitive integer types, as
byte swapping is undefined for Rust types.

Signed-off-by: Sean Cross <[email protected]>
Copy link
Member

@Yatekii Yatekii left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@Yatekii Yatekii merged commit be44533 into probe-rs:master May 7, 2025
1 check passed
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.

2 participants