Skip to main content
Ala
Senior
July 30, 2022
Question

adding a few cases in switch() gives below error "....ANY selector matching ..."

  • July 30, 2022
  • 18 replies
  • 2915 views

hi there

I have a STM32f030c8t6 which has 64kbyte FLASH. I've compiled my code before and I can see that only 34Kbyte is used.

now I want to develop my code.

I have a timer which interrupts every 4ms. entering timer interrupt, I have a function which is just a switch()/case with 15 cases. when I add 6 more cases I get below error

"...Error: L6406E: No space in execution regions with .ANY selector matching ...."

which is indicting that I do not have enough space in FLASH.

why is that? I mean, the code size was 33Kbytes, how can adding some more cases consume all of FLASH?

This topic has been closed for replies.

18 replies

KnarfB
Super User
July 30, 2022

Compilers tend to create jump tables for switch statements with many cases. If the numerical difference between your cases is large, that table may get huge. Seems like the compiler is not smart enough to find a way out here. Try refactoring your code by using if statements, breaking the code into several switch statements, or fiddling with the compiler options. Looks like you are using a commerical product, so ask the compiler support for specific help.

hth

KnarfB

Ala
AlaAuthor
Senior
July 30, 2022

I tried to write all of my cases(they are 63) using if/else statements. this also gave me that .ANY ERROR...

no it's a PCB board I designed for a process and I use CubeMX and Keil

Piranha
Principal III
July 30, 2022

Are those cases currently empty? Or do they call something that pulls in something big?

Ala
AlaAuthor
Senior
July 30, 2022

the cases are invoked every time the switch() variable changes to those cases. i.e

switch(page_cmg)

{

case(1):

//do something

break;

....

case(63):

//do something

break;

}

here in program I change page_cmd variable so every time it should enter different case

MM..1
Super User
July 30, 2022

No space for execution regions - free version of keil - Keil forum - Support forums - Arm Community

you can switch to CubeIDE and gcc or optimize your code under 32k.

S.Ma
Principal
July 30, 2022

Change compile options or break the big switch case into several by range to workaround compiler. What happen if using if elsif elseif..... ?

Ala
AlaAuthor
Senior
July 30, 2022

how can I change compiler options? and which options? and change them to what value?

using 63 if elseif elseif s... also give me .ANY error

Tesla DeLorean
Guru
July 30, 2022

Perhaps it's the secondary effect of the functions and related call trees of the code that are now needed, that the linker had previously dumped via dead code elimination.

Say it had functions using floating point, or sprintf, etc​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Ala
AlaAuthor
Senior
July 30, 2022

can you explain a bit more? I didnt get that entirely...

MM..1
Super User
July 30, 2022

Is your Keul free? If yes you are over limit

MM..1
Super User
July 30, 2022

Is your conf ?0693W00000QMWusQAH.png

Ala
AlaAuthor
Senior
July 31, 2022

yes it is. how should I change it?

Tesla DeLorean
Guru
July 30, 2022

The .MAP file (or verbose linker output) should be able to break down usage.

One trick to get closure is to make the FLASH section larger than the device's resources, now while the binary won't be usable it will allow the linker to complete in a way you can analyze/review the output.

Keil can decompose .AXF (ELF format) files with the FromELF tool, this can also disassemble and dump via FromELF -csd filename.elf >filename.lst

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..