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:
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
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?
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.