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

ports/stm32f4: Keep bootloader within first 32K #420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

petejohanson
Copy link
Contributor

@petejohanson petejohanson commented Nov 11, 2024

In order to free up sectors 2 and 3 for the application, limit the bootloader to the first 16K sector, config to the next 16K. We keep the application still starting at 0x10000 so that 0x8000 and 0xC000 sectors can be used by the application for settings/config storage.

Checklist

By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes

  • Please provide specific title of the PR describing the change
  • Please provide related links (eg. Issue which will be closed by this Pull Request)

This checklist items that are not applicable to your PR can be deleted.


Description of Change

While trying to set up an stm32f401cb based board to run ZMK (using Zephyr under the hood), I ran into an issue trying to use Zephy's NVS driver for persistence of settings. Zephyr's NVS expects two sectors of 16K, which basically means I need to use sectors 2 and 3 for this:

image

I was able to make this work with the correct partitioning on the Zephyr/ZMK side, and properly fit the bootloader into the first two sectors with the changes in this PR. The device runs, and properly store settings as expected.

@petejohanson
Copy link
Contributor Author

So, based on the CI failure... A few things are clear:

  • tinyuf2 only fits with bare minimum features enabled. Feather build fails, for example, when the neopixel code gets built too. Setting the number of pixels to 0 for that board makes the build pass again here locally.
  • I realize that changing this also means the config location would change for a lot of boards, probably breaking things for existing devices.

Thoughts on making this an optional different linker file/set of offsets that boards can opt in to?

In order to free up sectors 2 and 3 for the application, limit the
bootloader to the first 16K sector, config to the next 16K. We keep
the application still starting at 0x10000 so that 0x8000 and 0xC000
sectors can be used by the application for settings/config storage.

Available by setting COMPACT_BOOTLOADER in board.mk
@petejohanson petejohanson force-pushed the stm32f4-port/reduce-bootloader-flash-size branch from 76da845 to 608a8d4 Compare November 11, 2024 22:54
@petejohanson
Copy link
Contributor Author

Ok, I've made this change "opt in" by setting COMPACT_BOOTLOADER in board.mk, so existing boards don't have any change to the flash usage. Thoughts?

@kbladewht
Copy link

Great work. one question I tried, seems after this change , we still can't change starting at 0x10000 ? to 0x0C000 ? is there any restrict on APP Start Addr ?

@petejohanson
Copy link
Contributor Author

Great work. one question I tried, seems after this change , we still can't change starting at 0x10000 ? to 0x0C000 ? is there any restrict on APP Start Addr ?

I haven't tried, but I don't see why you couldn't. In my case, I specifically need the two sectors starting at 0xC000 for application settings storage, so I want to keep the same start address.

@kbladewht
Copy link

Thanks your reply, yes, I am not sure where is the issue, after check log , it stuck on __set_MSP(sp); from board.c

image

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.

2 participants