Skip to content

[Feature] Build HAT RAM usage #2484

@dlech

Description

@dlech

Currently, the way the Raspberry Pi Build HAT works is that when it starts up, it runs the the Build HAT Bootloader (BHBL) from the flash memory on the Build HAT. (Refer to #2482 for discussion about flash memory.) The BHBL is then used to load the actual firmware into RAM on the Build HAT and run it from there.

There is 256KiB RAM, so this should be plenty for both the Pybricks firmware and user programs and a decent heap memory size for user programs. The Build HAT doesn't have things like Bluetooth, so the firmware size won't be quite as big as on other hubs. Currently, the Pybricks firmware size is sitting at less than 150KiB.

We copied the linker script from the official Build HAT source code. This reserves part of the RAM for the bootloader. However, I don't think that this is necessary. We need to make sure that the firmware size fits in the RAM minus the bootloader size so that when the bootloader is loading the firmware, it doesn't write over itself. But after the bootloader jumps to the firmware, that area of the RAM previously occupied by the bootloader should be free to use.

One way we could do this to to have 2 RAM sections in the linker script and put uninitialized data in the 2nd one. Or we might just be able to have one RAM section and just have an assert to catch if .text + .data size gets over the allowable size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededhub: buildhatIssues related to the Raspberry Pi Build HATtopic: MicroPythonIssues related to the MicroPython programming language

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions