NSH: ps command broken between release 12.0 and 12.1
I noticed, that the ps command of the NSH library broke between release 12.0 and 12.1.
Specifically, I am testing the nucleo-h743zi2:nsh config, where I enabled CONFIG_FS_PROCFS and CONFIG_NSH_ARCHINIT to get the ps command in NSH. When executing the command (sometimes only on the second try) I get a hardfault. This starts happening with release 12.1 (still apparent with 12.3) and works as expected on 12.0.
Before debugging this in more detail. maybe somebody can help pointing in the right direction? I see that the LR points to tls_get_info and the PC to getumask during the hardfault.
Thanks!
@maxikrie I faced similar issue helping @JorgeGzm with witte board powered by stm32h753bi. I think it could be some issues related to STM32H7, because in other boards the issues doesn't happen
I tracked it down to changes introduced in nsh_console.c, nsh_console.h, nsh_proccmds.c between 12.0 and 12.1. If I revert only these files to 12.0, I don't see this issue.
I haven't reviewed these files in detail, but isn't the nsh library hardware agnostic? So how could this be a STM32H7 specific issue?
@maxikrie so maybe this is not the same issue we are seeing in our board.
Confirming that ps on stm32f4discovery still working:
nsh> uname -a
NuttX 12.3.0 ffc7a192a0-dirty Dec 23 2023 17:58:59 arm stm32f4discovery
nsh> free
total used free maxused maxfree nused nfree
Umem: 193400 7832 185568 9336 125008 37 3
nsh> ps
PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK COMMAND
0 0 0 FIFO Kthread - Ready 0000000000000000 001008 Idle_Task
2 2 100 RR Task - Running 0000000000000000 002008 nsh_main
nsh>
Hi!
PTAL at https://github.com/apache/nuttx/pull/11425
On ESP32-S2, the problem with the ps command was related to the NSH's task stack size. The error didn't occur every time the command was run, but eventually. Increasing the stack size fixed the problem. My guess: TCB increased and requires more space depending on the arch.
Yes, I noticed this as well.
I increased the stack size for NSH task
CONFIG_SYSTEM_NSH_STACKSIZE=4096
but I also had to increase the stack size of the init task (@tmedicci, thanks for the link - I see you had to do the same)
CONFIG_INIT_STACKSIZE=4096
Does this make any sense or is this simply obfuscating the problem? How is the init task related to this? In any case, so far I am not witnessing any crashes.
@maxikrie good question, I think more investigation will be needed. Note that I'm using the default stacksize in stm32f4discovery board.