shell halting when code size gets too big
Moderators: RoccoMarco, lbednarz, tfAteba
-
hazelnusse
- Posts: 77
- Joined: Thu May 24, 2012 8:01 am
shell halting when code size gets too big
I am working from one of the demos, modified to add some extra shell commands. One of my shell commands results in a relatively large bit of code (~25kb) getting added to my project. Most of this is from static data associated with a lookup table, all of it statically allocated. Anyway, when I have this command enabled in the shell, any command I issue to the shell, including a do nothing shell command that returns immediately, results in the shell locking up and my CPU in _unhandled_exception(). The backtrace is corrupted so I can't see what the code path to this point is. Any ideas on how to debug? My total code size is ~58kb, and this is on a STM32F407 with 196kb of ram and 1Mb of flash, so I know I'm not running into storage limits. When I disable the command, the code is eliminated and code size drops back to about 23kB and the unhandled exception doesn't occur.
Again, the unhandled exception occurs regardless of which shell command I issue.
I have tried this with two different compilers and both give the same result, so I'm convinced it is not my toolchain (I am using gcc-arm-embedded as provided by ARM: https://launchpad.net/gcc-arm-embedded).
Could it be that the location of the shell commands affects the execution of the shell in a way that could result in an unhandled exception?
Thanks,
Luke
Again, the unhandled exception occurs regardless of which shell command I issue.
I have tried this with two different compilers and both give the same result, so I'm convinced it is not my toolchain (I am using gcc-arm-embedded as provided by ARM: https://launchpad.net/gcc-arm-embedded).
Could it be that the location of the shell commands affects the execution of the shell in a way that could result in an unhandled exception?
Thanks,
Luke
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: shell halting when code size gets too big
Hi,
Probably it is just a stack overflow, try increasing the shell stack size.
Giovanni
Probably it is just a stack overflow, try increasing the shell stack size.
Giovanni
-
hazelnusse
- Posts: 77
- Joined: Thu May 24, 2012 8:01 am
Re: shell halting when code size gets too big
Giovanni,
I doubled my stack size from 2048 to 4096 to 8192, finally to 32768 (riduculous, I know), and this did not fix it. It isn't obvious to me why the stack size would be an issue if the unhandled exception is occuring even with calls to simple things like help or a do nothing command that simply returns. The unhandled exception occurs even when I call a foo command like:
Is it possible that something with my linker script is causing this?
Thanks,
Luke
I doubled my stack size from 2048 to 4096 to 8192, finally to 32768 (riduculous, I know), and this did not fix it. It isn't obvious to me why the stack size would be an issue if the unhandled exception is occuring even with calls to simple things like help or a do nothing command that simply returns. The unhandled exception occurs even when I call a foo command like:
Code: Select all
static void cmd_foo(BaseSequentialStream *chp, int argc, char *argv[]) {
return;
}
static const ShellCommand commands[] = {
{"foo", cmd_foo},
{NULL, NULL}
};
Is it possible that something with my linker script is causing this?
Thanks,
Luke
Re: shell halting when code size gets too big
I don't know what your program looks like but the lines you pasted look good to me. Do you pass the arguments correctly as shown in all the examples?
From my early days of ChibiOS/RT, I remember having similar problems. When I wrote a bigger shell program, I ended up in an undhandled exception. However, back then I didn't know how to debug this properly and I don't know what the real issue way. But I had a ridiculous stack size as you as well...
~ Tectu
From my early days of ChibiOS/RT, I remember having similar problems. When I wrote a bigger shell program, I ended up in an undhandled exception. However, back then I didn't know how to debug this properly and I don't know what the real issue way. But I had a ridiculous stack size as you as well...
~ Tectu
Re: shell halting when code size gets too big
Can you post your linker script.
and the output map file.
--
mike
and the output map file.
--
mike
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: shell halting when code size gets too big
hi,
Does this occur also using a standard demo or just in your code? if it happens also with demos then it is something in your environment else create a minimal application for us to test.
Anyway, post the compiler files like theShed suggested.
Giovanni
Does this occur also using a standard demo or just in your code? if it happens also with demos then it is something in your environment else create a minimal application for us to test.
Anyway, post the compiler files like theShed suggested.
Giovanni
Re: shell halting when code size gets too big
Ah, this is a good one. Back then I used the summon-arm-toolchain. Many people have issues with their toolchain (together with ChibiOS/RT). I can suggest this one. I can promise that everything works 100% sure. I suggested this one to about a dozen people who had issues with their other toolchains - all of them are happy now.
~ Tectu
~ Tectu
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: shell halting when code size gets too big
He stated that he is already using that one. The question is, if he has more toolchains, which is really in use, it depends on the order of the PATH environment variable.
Giovanni
Giovanni
Re: shell halting when code size gets too big
Sorry, I have missed that one - or maybe he edited after I read the post.
~ Tectu
~ Tectu
Re: shell halting when code size gets too big
Hi all, I know this is an old thread, but did you resolve the issue ?
As I have a similar issue whereby I have an Array that is used to store values for RGB LED's this is then passed to the
DMA Stream and sent out on a PWM pin.
All is working well until I increase the size of the Array - the size is no more that 3.5k but suddenly the Shell Terminal stops responding.
The program is still running as I can also control it over a Wifi module connected to another Serial channel.
I have tried Increasing Stack size in the Makefile and declaring the array as Static.
The array is not in a Thread function and all other Threads appear to be working apart from the Shell.
Hardware Nucleo-F103RB Board. Shell Commands via the ST-Link V2.1 Terminal.
Any clues would be gratefully received.
As I have a similar issue whereby I have an Array that is used to store values for RGB LED's this is then passed to the
DMA Stream and sent out on a PWM pin.
All is working well until I increase the size of the Array - the size is no more that 3.5k but suddenly the Shell Terminal stops responding.
The program is still running as I can also control it over a Wifi module connected to another Serial channel.
I have tried Increasing Stack size in the Makefile and declaring the array as Static.
The array is not in a Thread function and all other Threads appear to be working apart from the Shell.
Hardware Nucleo-F103RB Board. Shell Commands via the ST-Link V2.1 Terminal.
Any clues would be gratefully received.