Shell doesn't respawn in demo

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
hazelnusse
Posts: 77
Joined: Thu May 24, 2012 8:01 am

Shell doesn't respawn in demo

Post by hazelnusse »

I've tried the ARMCM3-STM32F107-FATFS demo and when I type exit into the shell, a new shell isn't respawned. When I type "exit", no response comes back (it isn't echoed), and the system goes into the idle thread. I have experienced the same issue in my own code and can't figure out what the issue is. I have even tried using shellCreateStatic() rather shellCreate() and it seems to make no difference. Everything else about the session seems to be fine. Here is an example session:

Code: Select all

ChibiOS/RT Shell
ch> help
Commands: help exit info systime mem threads test tree
ch> info
Kernel:       2.5.0
Compiler:     GCC 4.7.2 20120701 (prerelease)
Architecture: ARMv7-M
Core Variant: Cortex-M3
Port Info:    Advanced kernel mode
Platform:     STM32F1 Connectivity Line
Board:        Olimex STM32-P107 Rev.A
Build time:   Aug  5 2012 - 12:08:33
ch> systime
9549
ch> threads
    addr    stack prio refs     state time
20000908 20000794   64    1   WTOREVT 0
20000950 200009CC    1    1     READY 12035
20001DA0 20001E6C   64    1  SLEEPING 0
200014D8 20001C44   64    1   CURRENT 5
ch> tree
File System not mounted
ch> mem
core free memory : 56560 bytes
heap fragments   : 0
heap free total  : 0 bytes
ch> exit


the last line should trigger a new shell to respawn and then show the shell prompt again (main.c, lines 365-373), but it doesn't. Any ideas why?

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

Re: Shell doesn't respawn in demo

Post by Giovanni »

Hi,

Before respawning the shell the demo waits for an event, for example the extraction of the card. If you want to shell to respawn immediately you may add a timeout to chEvtWaitOne() in the main loop, make it

Code: Select all

chEvtWaitOneTimeout(ALL_EVENTS, MS2ST(500))


for example.

Giovanni
hazelnusse
Posts: 77
Joined: Thu May 24, 2012 8:01 am

Re: Shell doesn't respawn in demo

Post by hazelnusse »

Giovanni,
Thank you for the response, that makes sense. Without that change, it seems that this demo takes two events in order to respawn the shell. For example, if the SD card is inserted (LED blinking fast), then type exit, I have to remove, then insert the card again before the shell will respawn. If the SD card is removed (LED blinking slow), then type exit, I have to insert then remove the card before the shell will respawn. Is this expected? I can't see why the shell wouldn't be respawned upon the the first event. Am I missing something?

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

Re: Shell doesn't respawn in demo

Post by Giovanni »

It is a side effect of how that loop is written, it cleans the old shell after the first event and launch a new one after the second event.

Giovanni
hazelnusse
Posts: 77
Joined: Thu May 24, 2012 8:01 am

Re: Shell doesn't respawn in demo

Post by hazelnusse »

Ok, I think I understand. chEvtWaitOne(ALL_EVENTS) waits (blocking) for an insert/removal event. If the user ends the shell, then the first event after ending the shell (insert or remove) will cause chEvtWaitOne() to return, and the loop will proceed, and the first part of the loop will be skipped since shelltp != NULL. chThdTerminated(shelltp) returns true, so shelltp is set to NULL. Then chEvtWaitOne() waits for a second event (remove or insert), and when it occurs, the loop proceeds and this time shelltp==NULL, so !shelltp evaluates as true and a new shell is spawned.

Thanks for the help with this and forgive my thinking out loud. Hopefully others will find this useful.
Post Reply