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

Incomplete documentation for BOOT_LOADER_RAM_MEMCPY #14

Open
jannic opened this issue Nov 1, 2021 · 14 comments
Open

Incomplete documentation for BOOT_LOADER_RAM_MEMCPY #14

jannic opened this issue Nov 1, 2021 · 14 comments

Comments

@jannic
Copy link
Member

jannic commented Nov 1, 2021

As mentioned in #3 (comment), the documentation of BOOT_LOADER_RAM_MEMCPY seems to be incomplete.

@thejpster
Copy link
Member

Paging @debuti, who wrote I think wrote the memcpy bootloader.

@d0ntrash
Copy link

d0ntrash commented Mar 3, 2022

@jannic, do you have an update on this? Do you have an working copy-to-ram example?

@jannic
Copy link
Member Author

jannic commented Mar 3, 2022

@d0ntrash no, sorry, I don't have a working example ready. I don't really have a use case for this and only tried it out last September out of curiosity. The git branch I used back then probably still is somewhere on my hard drive, so I could dig it out if it would help you. But it wouldn't be documented at all, and I'm not sure if it was correct - all I verified was that I got a LED blinking, after applying some ugly hacks.

@d0ntrash
Copy link

d0ntrash commented Mar 3, 2022

@jannic If that wouldn't be a big hassle for you, that would help a lot.

@jannic
Copy link
Member Author

jannic commented Mar 3, 2022

@d0ntrash not at all. You can find the code here: https://github.com/jannic/rp2040-project-template/tree/run-from-ram

@sszilvasi
Copy link

@d0ntrash Have you had any luck with getting this to work?

@d0ntrash
Copy link

d0ntrash commented Mar 9, 2022

@sszilvasi I am not sure yet. I tried a few things but was not able to verify yet. I might have another look the next few days.

@sszilvasi
Copy link

@d0ntrash and @jannic: Do you know if there has been any rp-rs effort to implement the equivalent of the pico-sdk NO_FLASH option?

@sszilvasi
Copy link

For the no-FLASH option, I ended up creating a proof-of-concept RAM-only project template by comparing two memory layouts in pico-sdk:

  1. https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_standard_link/memmap_default.ld
  2. https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_standard_link/memmap_no_flash.ld

As the RP Pico used for development does actually have a FLASH, I "disabled" it by flashing picoblank to the boot loader region.

The RAM-only project currently works with elf2uf2-rs but not with probe-run.

@jannic
Copy link
Member Author

jannic commented Mar 18, 2022

Just to avoid confusion: @sszilvasi, if I understand your project correctly, you built something different, not really related to this ticket:

The BOOT_LOADER_RAM_MEMCPY is a second stage boot loader meant to be written to flash, which just copies the firmware from flash to RAM before calling it. That boot loader is not well documented, and that's what this ticket is about.

What you made is a firmware which can run on an RP2040 without accessing flash at all - i.e. on powerup, the boot ROM doesn't find a flash image and jumps to the USB boot mode implemented in ROM. Then you can push the firmware via USB and jump directly to the entry point, without a second stage boot loader at all.

Both approaches have their use cases and are perfectly valid, but they are different things and should not be confused.

@sszilvasi
Copy link

Correct, the above mentioned RAM-only project was a deviation from the original topic. It is very loosely related in that the firmware gets copied to RAM by some means before execution, but has otherwise little to do with the BOOT_LOADER_RAM_MEMCPY second stage boot loader implementation or its documentation.

@elfmimi
Copy link

elfmimi commented May 5, 2022

Thanks @jannic , your run-from-ram example helped much. though it didn't work as-is.

First, .vector_table has to be copied to RAM as well.

and there were some alignment related problems.

Finally, to convince elf2uf2 or elf2uf2-rs that your binary is meant to be placed into flash memory, you need to change entry point of the binary. That is , to change

ENTRY(Reset);

to

ENTRY(BOOT2_FIRMWARE);

Here is a complete working example.
https://github.com/elfmimi/rust-dap/tree/ram-lto-asm-unsafe/boards/rp2040_ram

@debuti
Copy link

debuti commented May 5, 2022

Hello

Sorry to be away, you can see how it is used in this project: https://github.com/debuti/keso

BR

@AkiyukiOkayasu
Copy link

Is there any further information on this?

The @jannic and @elfmimi samples are great, but the cortex-m-rt version is also up and I am having trouble getting it to work in my environment.
Yes, I'm not familiar with linker scripts...

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

No branches or pull requests

7 participants