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

Update RP2040 memory.x #2139

Merged
merged 2 commits into from
Nov 19, 2023
Merged

Update RP2040 memory.x #2139

merged 2 commits into from
Nov 19, 2023

Conversation

jamesmunns
Copy link
Contributor

The RP2040 has 264KiB of memory, not 256KiB.

Citation: https://www.raspberrypi.com/documentation/microcontrollers/rp2040.html#technical-specification

264kB on-chip SRAM in six independent banks

Copy link
Member

@lulf lulf left a comment

Choose a reason for hiding this comment

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

Good catch, thanks! Could you update these too?

  • boot/bootloader/rp/memory.x
  • boot/application/rp/memory.x

@Athorus
Copy link

Athorus commented Nov 8, 2023

Above 0x20040000, the 8 KB of SRAM are not striped ! So I am not sure it is a good idea to mix non striped SRAM with striped SRAM.
See page 25 of the datasheet https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf

@jamesmunns
Copy link
Contributor Author

@Athorus that's fair! on one hand: using unstriped ram primarily for the core might be good, if it is uncontended with DMA access.

On the other hand: we have no control over that for user code, and if we only give 4K of stack for each core, that might not reasonably be enough.

@Athorus
Copy link

Athorus commented Nov 8, 2023

With 256K, at the end of the program I got as expected :
(HOST) INFO program has used at least 26.55/141.34 KiB (18.8%) of stack space

But with 264K I got this strange message !
(HOST) WARN program has used at least 4.00/4.00 KiB (100.1%) of stack space

In both cases, the program seems to work fine

@Dirbaio
Copy link
Member

Dirbaio commented Nov 19, 2023

Good catch, thanks! Could you update these too?

* `boot/bootloader/rp/memory.x`

* `boot/application/rp/memory.x`

ping @jamesmunns :)

@Dirbaio
Copy link
Member

Dirbaio commented Nov 19, 2023

Above 0x20040000, the 8 KB of SRAM are not striped ! So I am not sure it is a good idea to mix non striped SRAM with striped SRAM. See page 25 of the datasheet https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf

examples are supposed to be simple, and "the default memory.x allows me to use all RAM" makes a lot of sense for examples. The datasheet specifically says the ram is laid out like that so you can pretend it's a contiguous 264k block. for the majority of applications it's likely to increase perf (moves core activity to sram4-5, while dma is most likely to use sram0-3). and only for very particular circumstances (several DMAs adding up more than 1 word/cycle out of stack) it might reduce perf. So IMO it's worth doing this change.

With 256K, at the end of the program I got as expected : (HOST) INFO program has used at least 26.55/141.34 KiB (18.8%) of stack space

But with 264K I got this strange message ! (HOST) WARN program has used at least 4.00/4.00 KiB (100.1%) of stack space

In both cases, the program seems to work fine

This is knurling-rs/probe-run#415 (the regions are separate in the probe-rs target definition). it's a bit moot now that probe-run is deprecated though.

Copy link
Member

@Dirbaio Dirbaio left a comment

Choose a reason for hiding this comment

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

thank you!

@Dirbaio Dirbaio enabled auto-merge November 19, 2023 22:12
@Dirbaio Dirbaio added this pull request to the merge queue Nov 19, 2023
Merged via the queue into embassy-rs:main with commit ff2f104 Nov 19, 2023
@Athorus
Copy link

Athorus commented Nov 19, 2023

This is knurling-rs/probe-run#415 (the regions are separate in the probe-rs target definition). it's a bit moot now that probe-run is deprecated though.

Shoud I use probe-rs instead of probe-run ?

@Dirbaio
Copy link
Member

Dirbaio commented Nov 19, 2023

yes https://ferrous-systems.com/blog/probe-run-deprecation/

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