Page 1 of 1

dbg_panic_msg notes chThdSleepS

Posted: Tue Oct 25, 2016 10:14 pm
by kb1gtt
I have a project, which was working, I made some small changes, and it now appears to be jumping into the weeds. My changes were around main.c line 417, and it now fails between lines 444 and 445 on it's first scan through main.c. When I suspend it, I see it's in chSysHalt with a dbg_panic_msg. I see the stack has unused space for all threads. When I try to F5 step into code, to get beyond line 444, it appears to jump around semi-erratically as it would do if I had code optimization turned on. So I'm having trouble getting down to the exact cause of the dbg panic. How do I find what is causing the panic?

main.c snippet and other general information below.

Code: Select all

444 gdispFillStringBox(2, 71, 95, 12, "P1 Potable Pump",  gdispOpenFont("DejaVu*"), Black, White, justifyLeft);
445 gdispFillStringBox(2, 83, 40, 12, "Target",  gdispOpenFont("DejaVu*"), Black, White, justifyLeft);

Capture.PNG
Capture.PNG (6.2 KiB) Viewed 3805 times
dbg_panic_msg --> chThdSleepS
dbg_isr_cnt --> not within ISR
dbg_lock_cnt --> within lock

This is chibios 3.0.1, with uGFX, on a STM32F429 compiled by Chibi Studio GCC 4.9. My starting point was found as a demo from uGFX, which included Chibios. I have most dbg features enabled in chconf.h

Code: Select all

#define CH_DBG_STATISTICS                   TRUE
#define CH_DBG_SYSTEM_STATE_CHECK           TRUE
#define CH_DBG_ENABLE_CHECKS                TRUE
#define CH_DBG_ENABLE_ASSERTS               TRUE
#define CH_DBG_ENABLE_TRACE                 TRUE
#define CH_DBG_ENABLE_STACK_CHECK           TRUE
#define CH_DBG_FILL_THREADS                 TRUE
#define CH_DBG_THREADS_PROFILING            FALSE

My make file does it like this, not the -ggdb -O0 -g3

Code: Select all

arm-none-eabi-gcc -c -ggdb -O0 -g3 -mcpu=cortex-m4 -falign-functions=16 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm -MMD -MP -MF .build/dep/fakethumbfile.o.d -I. -Iugfx -Iugfx/3rdparty/tinygl-0.4-ugfx/include -Iugfx/boards/base/STM32F429i-Discovery -Iugfx/drivers/gdisp/STM32LTDC -Ichibios_3.0.1/os/common/ports/ARMCMx/devices/STM32F4xx -Ichibios_3.0.1/os/ext/CMSIS/include -Ichibios_3.0.1/os/ext/CMSIS/ST -Ichibios_3.0.1/os/rt/include -Ichibios_3.0.1/os/rt/ports/ARMCMx -Ichibios_3.0.1/os/rt/ports/ARMCMx/compilers/GCC -Ichibios_3.0.1/os/hal/osal/rt -Ichibios_3.0.1/os/hal/include -Ichibios_3.0.1/os/hal/ports/common/ARMCMx -Ichibios_3.0.1/os/hal/ports/STM32/STM32F4xx -Ichibios_3.0.1/os/hal/ports/STM32/LLD -Ichibios_3.0.1/os/hal/ports/STM32/LLD/DACv1 -Ichibios_3.0.1/os/hal/ports/STM32/LLD/GPIOv2 -Ichibios_3.0.1/os/hal/ports/STM32/LLD/I2Cv1 -Ichibios_3.0.1/os/hal/ports/STM32/LLD/OTGv1 -Ichibios_3.0.1/os/hal/ports/STM32/LLD/RTCv2 -Ichibios_3.0.1/os/hal/ports/STM32/LLD/SPIv1 -Ichibios_3.0.1/os/hal/ports/STM32/LLD/TIMv1 -Ichibios_3.0.1/os/hal/ports/STM32/LLD/USARTv1 -Ichibios_3.0.1/os/hal/ports/STM32/LLD/FSMCv1 -Ichibios_3.0.1/os/hal/boards/ST_STM32F429I_DISCOVERY -Ichibios_3.0.1/os/hal/lib/streams/ -Ichibios_3.0.1/os/various -DGFX_USE_OS_CHIBIOS=TRUE -DGFX_USE_OS_CHIBIOS=TRUE -DCORTEX_USE_FPU=TRUE -DUSE_FPU=hard -DTHUMB_PRESENT -DTHUMB_NO_INTERWORKING -mthumb -DTHUMB fakethumbfile.c -o .build/obj/fakethumbfile.o
.

Re: dbg_panic_msg notes chThdSleepS

Posted: Wed Oct 26, 2016 8:24 am
by Giovanni
Hi,

You need the complete stack trace while in the halt function.

Giovanni

Re: dbg_panic_msg notes chThdSleepS

Posted: Wed Oct 26, 2016 11:13 am
by kb1gtt
Do you mean the "trace buffer" tab? I'm not sure I follow how to complete the stack trace. Here's my trace buffer, but I don't see much related to stack in that dialog.
Capture.PNG

Re: dbg_panic_msg notes chThdSleepS

Posted: Wed Oct 26, 2016 12:23 pm
by Giovanni
Hi,

The stack trace is the stack of function calls you can see in the Debug window (upper left in your image).

Giovanni

Re: dbg_panic_msg notes chThdSleepS

Posted: Wed Oct 26, 2016 2:39 pm
by kb1gtt
Ah, there we have it, I see under the thread one was main.c, which was a call for chThdSleepMicroseconds which was set with 0. I changed it such that the min is 1, and now it's working again.

Thanks for the help.