Reducing code size.

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

Moderator: RoccoMarco

Post Reply
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

Reducing code size.

Post by rew »

(and/or RAM).

I have an application where I got the 16k version of the STM32F042. Stupid: should've gotten the 32k version. Anyway, my application barely fits in the 15k available for program memory.

One of the things I saw was an "thread-exit" function that was taking some space. I start the threads (main+one other), and never exit. I thought I remembered seeing here some way to disable code generation for the exit-a-thread part of chibios.

Is that still possible?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Reducing code size.

Post by Giovanni »

Hi,

The linker should remove unused functions, what you can disable is chThdWait() which takes some space in the thread structure.

Make also sure to remove the functions alignment optionin the Makefile, that should save some extra space, I assume you already used -Os there.

You could also consider NIL if you don't start/exit threads.

Giovanni
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

Re: Reducing code size.

Post by rew »

My code has a define that allows me to switch to "NIL" easily, but I switched back because it didn't have any result on the codesize.
Yes, I have -Os, I still have alignment.

Since I posted the openingspost, I found that LTO was still disabled. In the past, LTO crashed on my machine, so I had it turned off. An update brought in the fix it seems.... Frees up about 3k of memory. Should be enough for a short while. I'll build the next batch of these PCBs with the bigger chips.
Post Reply