Minimizing "boot" time ?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
geoffrey.brown
Posts: 122
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 18 times

Minimizing "boot" time ?

Post by geoffrey.brown »

If you use standby mode on the stm32l4 then every return from standby requires a "reboot" of ChibiOS. I'm curious how to configure ChibiOS to minimize this cost. I'm doing some things to keep stuff out of initialized memory, but I'm not sure I'm doing the best job. The only device drivers I need are SPI, I2C, and RTC.

Geoffrey
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Minimizing "boot" time ?

Post by Giovanni »

Hi,

Exiting from standby involves reinitializing the clock tree, the time is spent there waiting for PLLs, drivers initialization does not take much time. Reducing initialized memory helps for sure. Avoid those options that require memory manipulation, filling of stacks for example.

Giovanni
geoffrey.brown
Posts: 122
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 18 times

Re: Minimizing "boot" time ?

Post by geoffrey.brown »

Thanks ! Just using MSI so no PLLs. Which things might be expensive from memory manipulation besides filling stacks (is that always done ?).
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Minimizing "boot" time ?

Post by Giovanni »

Uninitialized variables need zeroing, initialized variables need initialization which is just a bit slower. Note that placing variables into an uninitialized RAM is a dubious advantage because you will still need to initialize them at some point, however it allows to defer initialization.

In general:
- Defer initializations of small variables where applicable but this will not give you huge advantages.
- Put large buffers in uninitialized areas, probably you don't need to clear those at all. The ChibiOS heap is an example, it is not initialized.
- Prefer automatic variables to static ones, static const variables to writable ones.
- In general make your DATA and BSS segments as small as possible.
- Do not initialize (and enable) drivers you don't need or defer the activation with xxxStart().

Giovanni
geoffrey.brown
Posts: 122
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 18 times

Re: Minimizing "boot" time ?

Post by geoffrey.brown »

Thanks again ! I think I'm doing most of those things, although I do need to systematically go through all the allocated variables to make sure.
Geoffrey
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

Re: Minimizing "boot" time ?

Post by rew »

There is this trick that defeats some security mechanisms. You boot the processor, let it run for some number of microseconds and then halt the CPU. To recover the protected FLASH, you need to read SRAM memory, but in your case you should take note of the PC value. Now you have a profile of what costs a lot of time and what doesn't.... Doing performance improvements based on a measurement of the performance is much more effective than just guessing.
Post Reply