-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
For some of the MSPM0 parts, especially those with little RAM, the GPIO wakers take up a considerable amount of RAM. The numbers are based off the current size of AtomicWaker
being 8 bytes at the time of writing.
For example with C110x, objdump is telling me that 25% of RAM (C110x has 1KB of RAM) is used just for GPIO wakers:
i509vcb@verdigris:~/Dev/embassy/examples/mspm0c1104$ objdump -C -t ./target/thumbv6m-none-eabi/release/button | grep '.bss'
200000d8 l O .bss 00000100 embassy_mspm0::gpio::PORTA_WAKERS
20000050 l O .bss 00000004 button::__embassy_main::POOL
20000054 l O .bss 00000084 embassy_executor::_export::ARENA
200001d9 l O .bss 00000001 defmt_rtt::TAKEN
200001da l O .bss 00000001 defmt_rtt::CS_RESTORE
200001db l O .bss 00000001 defmt_rtt::ENCODER
200001dc l O .bss 00000001 defmt_rtt::ENCODER
200001dd l O .bss 00000001 defmt_rtt::ENCODER
200001d8 g O .bss 00000001 _EMBASSY_DEVICE_PERIPHERALS
20000050 g .bss 00000000 __sbss
200001e0 g .bss 00000000 __ebss
In addition, C1104 will only ever have up to 18 GPIO pins. This means that 14 slots, or 112 bytes of RAM used for GPIO wakers is just wasted space. For L1306 the GPIO wakers still take up 6.25% of RAM. The waste is less on L1306, but its still 32 bytes of RAM that is wasted by the 4 unused slots.
For both of these parts, the numbers come from the button
example which only ever needs a single waker. This means there is 248 bytes of memory wasted in these examples.
What would be desirable is a way to only allocate the waker in RAM, if and only if the pin is actually used as an async input. Somehow we would need to know what pins are available and then only actually use the RAM for those wakers.
I was told about #1016 but that approach falls apart when applied to AnyPin
.
Enabling turbo wakers would halve the memory usage, but unused pins still waste space.