reducing flash usage
Posted: Fri Dec 29, 2017 9:33 am
Hello,
I am working on an embedded systems framework based on ChibiOS/RT. The framework is intended for UAV peripherals, and provides device drivers, UAVCAN protocol support, publish-subscribe and worker threads. A lot of common functionality (e.g., transmitting UAVCAN heartbeats, retrieving messages left in RAM by the bootloader) is supported just by adding a single line to the Makefile.
I'd like to reduce the flash footprint in general, but especially for a particular use-case: a bootloader. The bootloader can be single threaded, but because all of these modules use publish-subscribe and worker threads in order to be self-sufficient and independent of each other, that single thread needs to be a worker thread. Currently, I can get the footprint for an "empty application" - that is, an application with all of the UAVCAN functionality - down to about 15k. I am targetting 12k for the bootloader, so I need to cut out at least probably 4-5k of flash. Since the bootloader can be single threaded, it shouldn't need to use ChibiOS/RT - it can just use the ChibiOS startup code and the ChibiOS HAL. But most modules use ChibiOS/RT APIs -
primarily, the coremem allocator, mailboxes, threading APIs and mutexes. Obviously, I'll have to ifdef away all of the threading APIs and mutexes, but I can't do that to the coremem allocator and mailboxes. Will I have to re-implement those or can they be easily used stand-alone?
A couple of notes and questions from what I've seen in the nm output:
- "0000008c r pal_default_config" I'd prefer to just leave GPIOs in their reset state and use PAL APIs to configure them individually.
- For some reason I'm getting about 90 of these: "00000002 T Vector1C" - it seems like, given that this is a weak symbol that just aliases to _unhandled_exception, they shouldn't be emitted individually. Anyone know why they are?
- "000001a0 D _vectors" - does this need to be in RAM? 416 bytes is a bit of a blow when you only have 16k. (I'll investigate this further tomorrow.)
Thanks,
Jonathan
I am working on an embedded systems framework based on ChibiOS/RT. The framework is intended for UAV peripherals, and provides device drivers, UAVCAN protocol support, publish-subscribe and worker threads. A lot of common functionality (e.g., transmitting UAVCAN heartbeats, retrieving messages left in RAM by the bootloader) is supported just by adding a single line to the Makefile.
I'd like to reduce the flash footprint in general, but especially for a particular use-case: a bootloader. The bootloader can be single threaded, but because all of these modules use publish-subscribe and worker threads in order to be self-sufficient and independent of each other, that single thread needs to be a worker thread. Currently, I can get the footprint for an "empty application" - that is, an application with all of the UAVCAN functionality - down to about 15k. I am targetting 12k for the bootloader, so I need to cut out at least probably 4-5k of flash. Since the bootloader can be single threaded, it shouldn't need to use ChibiOS/RT - it can just use the ChibiOS startup code and the ChibiOS HAL. But most modules use ChibiOS/RT APIs -
primarily, the coremem allocator, mailboxes, threading APIs and mutexes. Obviously, I'll have to ifdef away all of the threading APIs and mutexes, but I can't do that to the coremem allocator and mailboxes. Will I have to re-implement those or can they be easily used stand-alone?
A couple of notes and questions from what I've seen in the nm output:
- "0000008c r pal_default_config" I'd prefer to just leave GPIOs in their reset state and use PAL APIs to configure them individually.
- For some reason I'm getting about 90 of these: "00000002 T Vector1C" - it seems like, given that this is a weak symbol that just aliases to _unhandled_exception, they shouldn't be emitted individually. Anyone know why they are?
- "000001a0 D _vectors" - does this need to be in RAM? 416 bytes is a bit of a blow when you only have 16k. (I'll investigate this further tomorrow.)
Thanks,
Jonathan