Skip to content

STM32: #8286 Causes Tickless RTC Mode App to Hang #8473

Closed
@mattbrown015

Description

@mattbrown015

Description

cc @jeromecoutant

#8286 causes our app to hang and behave badly in ways that I find difficult to describe.

I've been using the previous PR, #8323, for several days without any problems. As soon as I apply the change from #8262 the app starts hanging.

From mbed_app.json:

{
...
"macros": [
...
,"MBED_TICKLESS"
...
],
"target_overrides": {
"*": {
...
,"target.lpticker_lptim": 0
,"target.lpticker_delay_ticks": 0
...
}

If I start the app from cold, i.e. RTC == 0, not very much happens. I don't see any of our debug trace from main but I can tell from the current consumption the STM is running.

If I attach a debugger I can see the following:

update_present_time (ticker=ticker@entry=0x803193c <lp_data>) at .\mbed-os\hal\mbed_ticker_api.c:127
127 ticker_event_queue_t *queue = ticker->queue;
(gdb) bt
#0 update_present_time (ticker=ticker@entry=0x803193c <lp_data>) at .\mbed-os\hal\mbed_ticker_api.c:127
#1 0x0800f96a in ticker_insert_event_us (ticker=0x803193c <lp_data>, obj=obj@entry=0x200045d0 <os_timer_data+8>, timestamp=, id=id@entry=536888776) at .\mbed-os\hal\mbed_ticker_api.c:353
#2 0x0800808e in mbed::TimerEvent::insert_absolute (this=this@entry=0x200045c8 <os_timer_data>, timestamp=) at .\mbed-os\drivers\TimerEvent.cpp:53
#3 0x080109ae in rtos::internal::SysTimer::schedule_tick (this=0x200045c8 <os_timer_data>, delta=delta@entry=1) at .\mbed-os\rtos\TARGET_CORTEX\SysTimer.cpp:128
#4 0x08010a48 in rtos::internal::SysTimer::handler (this=0x200045c8 <os_timer_data>) at .\mbed-os\rtos\TARGET_CORTEX\SysTimer.cpp:185
#5 0x0800f940 in ticker_irq_handler (ticker=0x803193c <lp_data>) at .\mbed-os\hal\mbed_ticker_api.c:313
#6 0x080188f2 in RTC_IRQHandler () at .\mbed-os\targets\TARGET_STM\rtc_api.c:331
#7
#8 hal_critical_section_exit () at .\mbed-os\hal\mbed_critical_section_api.c:60
#9 0x0800fc70 in core_util_critical_section_exit () at .\mbed-os\platform\mbed_critical.c:99
#10 0x080109b6 in rtos::internal::SysTimer::schedule_tick (this=, delta=delta@entry=1) at .\mbed-os\rtos\TARGET_CORTEX\SysTimer.cpp:130
#11 0x08010f96 in OS_Tick_Enable () at .\mbed-os\rtos\TARGET_CORTEX\mbed_rtx_idle.cpp:54
#12 0x080115b0 in svcRtxKernelStart () at .\mbed-os\rtos\TARGET_CORTEX\rtx5\RTX\Source\rtx_kernel.c:267
#13 0x08010fe2 in SVC_Handler () at irq_cm4f.S:63
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

Or something very similar.

If I use the debugger to reset the STM, I guess this doesn't reset the RTC, our app will start but then it gets stuck around the time it is likely to decided to sleep. If I fiddle around, resetting etc., it might start running normally. In other words, if I can get it running it then starts behaving itself.

I've tried applying #8013.

I've also tried adding more critical sections and/or making them larger in rtc_api.c.

I'm just going to try build with ARM GCC V6, instead of V7, but after that I haven't got any more ideas.

Can anyone suggest anything else to try?

Slightly related but not the cause of my problems...

It looks to me like rtc_write is missing a called to core_util_critical_section_exit if _rtc_localtime fails. Although in practice, I don't think _rtc_localtime will fail.

Issue request type

[ ] Question
[ ] Enhancement
[x] Bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions