Skip to content

Add feature to disable .data copy when using a copying bootloader #609

@BenChung

Description

@BenChung

This is an issue that I found when getting boot2's copy-to-RAM setup working on RP2040. The boot2 bootloader sets up the SPI flash, copies all of it (including the .data region) into memory, and then de-initializes the SPI flash so it's no longer mapped into the memory space. If the LMA and VMAs are set up correctly with __sidata = LOADADDR(.data) cortex-m-rt's apploader will then come along and try to copy the .data region out of flash again, but since the SPI flash is no longer mapped it gets nonsense bytes.

I was able to proximally solve the issue by setting __sidata = ADDR(.data) in my linker script, which causes the app loader to copy the .data region to itself in RAM after boot2 is done. A better solution would be to add a feature flag to the library that lets me disable the copy entirely (which would then let me use a correct definition for __sidata), but I wanted to open an issue to see if there's a better way to solve it before opening a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions