Page 1 of 1

Reducing code size.

Posted: Mon Oct 10, 2016 6:16 pm
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?

Re: Reducing code size.

Posted: Mon Oct 10, 2016 6:27 pm
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

Re: Reducing code size.

Posted: Mon Oct 10, 2016 9:15 pm
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.