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

doc: TRD: start non-XIP flash info document #4081

Merged
merged 12 commits into from
Jan 24, 2025
Merged

doc: TRD: start non-XIP flash info document #4081

merged 12 commits into from
Jan 24, 2025

Conversation

bradjc
Copy link
Contributor

@bradjc bradjc commented Jul 10, 2024

Pull Request Overview

From our breakout at TW7, one item that came up was creating a document to overview what Tock might look like on platforms that do not support executing code stored in flash. The hope was to 1) clarify the goals and constraints so everyone is on the same page, and 2) to have some public documentation about this goal that others who might be interested can find.

This is a start towards such a document. This reflects a very basic understanding that I took away from the breakout session; I am by no means an expert on what these platforms look like.

Testing Strategy

n/a

TODO or Help Wanted

Ideally others would contribute text to expand this document.

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

doc/reference/trd-non-xip.md Outdated Show resolved Hide resolved
doc/reference/trd-non-xip.md Outdated Show resolved Hide resolved
doc/reference/trd-non-xip.md Outdated Show resolved Hide resolved
doc/reference/trd-non-xip.md Outdated Show resolved Hide resolved
@alevy
Copy link
Member

alevy commented Jul 10, 2024

People who were there (and who's Github handle I know): @LawrenceEsswood, @lschuermann.

Note that I don't think it's necessary to get all the details in this document down now, but an opportunity to add or correct some stuff before we merge this initial draft.

@bradjc
Copy link
Contributor Author

bradjc commented Jul 10, 2024

@reynoldsbd

@lschuermann
Copy link
Member

Note that I don't think it's necessary to get all the details in this document down now, but an opportunity to add or correct some stuff before we merge this initial draft.

To clarify: do we want to have this merged in the current form (i.e., skeleton + some context + motivation + concerns) or do we want to add actual technical details in this first iteration?

@bradjc
Copy link
Contributor Author

bradjc commented Jul 10, 2024

I would like to add more. I think once this PR is merged the TRD is unlikely to change.

doc/reference/trd-non-xip.md Outdated Show resolved Hide resolved
doc/reference/trd-non-xip.md Outdated Show resolved Hide resolved
Comment on lines 64 to 90
- Non-xip platforms have less RAM that traditional platforms have XIP flash.
Further, this RAM on non-xip platforms must (at runtime) store both the
executable code and the conventional memory items (e.g., the stack and heap).
This results in significantly less room for program code than on traditional
platforms.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not universally true -- for example, TI sells the popular AM263x / AM263Px line of chips which have 2MB and 3MB of RAM, respectively.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Non-xip platforms have less RAM that traditional platforms have XIP flash.
Further, this RAM on non-xip platforms must (at runtime) store both the
executable code and the conventional memory items (e.g., the stack and heap).
This results in significantly less room for program code than on traditional
platforms.
- Non-xip platforms store (at runtime) both the
executable code and the conventional memory items (e.g., data, stack and heap).
This results in significantly less room for program code than on traditional
platforms.

Copy link
Member

Choose a reason for hiding this comment

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

Can confirm that understanding of one of the real use cases in question has order of MBs of RAM (another has 100s of KB so, again, both are correct).

@bradjc
Copy link
Contributor Author

bradjc commented Jul 17, 2024

I think what I'm learning from this discussion (and perhaps exactly why I think we need this document) is that "non-XIP" is too broad in practice to be meaningful. I don't think we can effectively design solutions for all non-XIP MCUs. This is no different than Tock not being designed for all "traditional" MCUs (eg 8 bit cores, multi cores, arm A, etc).

I think we need to start with narrowing down non-XIP to a subset for this document. My understanding, from the breakout, is that there is a need to support the small RAM, untrusted nonxip flash use case.

@bradjc
Copy link
Contributor Author

bradjc commented Jul 17, 2024

I took the liberty of updating the doc. Happy to bikeshed the name at some point.

@alevy alevy added the No-XIP Related to platforms that cannot execute code in palce label Jul 17, 2024
@lschuermann lschuermann self-requested a review August 30, 2024 16:25
@alevy
Copy link
Member

alevy commented Aug 30, 2024

This is blocked on feedback from relevant stakeholders either using or planning to use non-XIP platforms:

@LawrenceEsswood @reynoldsbd ?

@alevy alevy added the blocked Waiting on something, like a different PR or a dependency. label Aug 30, 2024
@ppannuto
Copy link
Member

@ZhekaS it sounds like this may also be relevant to your use case — we welcome any feedback you may have here as well!

@ZhekaS
Copy link

ZhekaS commented Nov 25, 2024

@ZhekaS it sounds like this may also be relevant to your use case — we welcome any feedback you may have here as well!

It is very relevant indeed. Rather than providing concrete feedback, I'd rather describe the use-case.
We have an SOC with many different cores on it, while at least one of them is expected to operate under Tock OS. All the firmwares are stored on external SPI-FLASH, and are cryptographically signed. In the boot-time relevant firmware is loaded into the specific component's SRAM where it is being validated (assuming SRAM is secure, it prevents TOCTOU which would be possible if validated in the flash). Then the firmware is being executed from SRAM.
I do not see a big deal with this flow (but I am surely not an expert in TockOS :) ). As long as the TockOS is linked for the correct SRAM location, it should be working out of the box. The only thing, is that the startup code does not need to copy the .data section as it's load address should be the same as execution address in SRAM. Not sure how much MPU/PMP settings need to be adjusted.

@ppannuto ppannuto removed the blocked Waiting on something, like a different PR or a dependency. label Jan 15, 2025
@ppannuto
Copy link
Member

This was discussed on the core team call today. While we would still like more feedback from downstream users, this is also version 1 of a draft document, and should not linger as a PR forever.

I'm going to attempt to resolve all of the open discussion threads now, and then ping folks for a merge.

@ppannuto ppannuto requested a review from alevy January 15, 2025 18:26
@ppannuto ppannuto added the last-call Final review period for a pull request. label Jan 15, 2025
@ppannuto
Copy link
Member

Done — this should be good to go. Will let it sit for a few hours in case anyone sees anything in my edits here they don't like.

@bradjc
Copy link
Contributor Author

bradjc commented Jan 23, 2025

Merge this?

@ppannuto ppannuto added this pull request to the merge queue Jan 23, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 23, 2025
@lschuermann
Copy link
Member

Huh, I thought that I removed the litex-sim-ci checks from being required.

@ppannuto
Copy link
Member

Rebased to pick up CI config changes.

@ppannuto ppannuto enabled auto-merge January 23, 2025 23:46
@ppannuto ppannuto added this pull request to the merge queue Jan 23, 2025
Merged via the queue into master with commit 0e3f412 Jan 24, 2025
21 checks passed
@ppannuto ppannuto deleted the trd-non-xip branch January 24, 2025 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation last-call Final review period for a pull request. No-XIP Related to platforms that cannot execute code in palce
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants