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

Add section attributes to combined firmware blobs and metadata #97

Closed
wants to merge 2 commits into from

Conversation

mvds00
Copy link

@mvds00 mvds00 commented Nov 8, 2023

This change will not do much for regular builds, but it allows to put the firmware blob in a specific flash area.

In cases where multiple firmware versions run on the same device, this allows re-use of the firmware blob. On such case is picowota, the Raspberry Pi Pico W OTA flash bootloader. Until now, picowota users effectively have the firmware on their devices twice.

Another use case is that in a firmware update, the CYW firmware can be left untouched.

The pointer to the blob is put in a struct that also contains some metadata, which is put in a separate section to allow linker script writers to prepend the binary blob with something like a header.

To store the cyw firmware at a particular location in flash, these changes can be made to the linker script:

MEMORY {
...
   FLASH_FW_CYW(rx):            ORIGIN = 0x10040000, LENGTH = 256k
...
}

and

SECTIONS {
...
    .fw_cyw43 : { 
        . = ALIGN(4k);
        KEEP(*(.fw_cyw43.meta))
        . = ALIGN(512);
        *(.fw_cyw43.blob)
    } > FLASH_FW_CYW
...
}

(edit: renamed flash memory and section to FLASH_FW_CYW and .fw_cyw43)

@peterharperuk
Copy link
Collaborator

Looks ok to me and a quick test suggests it doesn't break anything. We'd just have to be careful when updating the firmware that we don't break this, but I guess that's not a big issue.

Do you not care about the Bluetooth firmware? I guess it's fairly small.

@mvds00
Copy link
Author

mvds00 commented Nov 9, 2023

As I only use w43439A0_7_95_49_00_combined I was only able to test that, and modified anything that closely resembled it. For bluetooth the issue seems less severe as it is small indeed. Apparently I missed a new firmware header (w4343WA1_7_45_98_102_combined.h) which was not part of my (local) commit, so I amended the commit.

This change will not do much for regular builds, but it allows to put the
firmware blob in a specific flash area.

In cases where multiple firmware versions run on the same device, this allows
re-use of the firmware blob. On such case is picowota, the Raspberry Pi Pico W
OTA flash bootloader. Until now, picowota users effectively have the firmware
on their devices twice.

Another use case is that in a firmware update, the CYW firmware can be left
untouched.

The pointer to the blob is put in a struct that also contains some metadata,
which is put in a separate section to allow linker script writers to prepend
the binary blob with something like a header.

To store the cyw firmware at a particular location in flash, these changes
can be made to the linker script:

MEMORY {
...
FLASH_FW_CYW(rx):            ORIGIN = 0x10040000, LENGTH = 256k
...
}

and

SECTIONS {
...
    .fw_cyw43 : {
        . = ALIGN(4k);
        KEEP(*(.fw_cyw43.meta))
        . = ALIGN(512);
        *(.fw_cyw43.blob)
    } > FLASH_FW_CYW
...
}
@mvds00 mvds00 closed this Mar 7, 2024
@mvds00 mvds00 deleted the pullreq1 branch March 7, 2024 03:35
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.

3 participants