Hi,
In the morning my remaining neurons seem to work better, I found the other problem. Could you confirm this fixes it?
Giovanni
"chVTResetI(), #1" panic from i2c_lld_master_timeout
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: "chVTResetI(), #1" panic from i2c_lld_master_timeout
- Attachments
-
- i2c_lld.zip
- (5.67 KiB) Downloaded 439 times
Re: "chVTResetI(), #1" panic from i2c_lld_master_timeout
Still fails at seemingly the same place when running the benchmark tests, but the panic is different..
For completeness, I'm using this compiler:
and compiling with these options:
USE_OPT= -ggdb3 -fomit-frame-pointer
Code: Select all
port_halt () at ../../chibios/stable_2.4.x/os/ports/GCC/ARMCMx/chcore.c:48
48 port_disable();
(gdb) bt
#0 port_halt () at ../../chibios/stable_2.4.x/os/ports/GCC/ARMCMx/chcore.c:48
#1 0x08000d36 in chDbgPanic (msg=0x80122d8 "SV#6") at ../../chibios/stable_2.4.x/os/kernel/src/chdebug.c:274
#2 0x08000aea in dbg_check_lock_from_isr () at ../../chibios/stable_2.4.x/os/kernel/src/chdebug.c:141
#3 0x0800b536 in i2c_lld_safety_timeout (p=0x20001c14) at ../../chibios/stable_2.4.x/os/hal/platforms/STM32/i2c_lld.c:168
#4 0x080009f6 in chSysTimerHandlerI () at ../../chibios/stable_2.4.x/os/kernel/src/chsys.c:146
#5 0x080005a6 in SysTickVector () at ../../chibios/stable_2.4.x/os/ports/GCC/ARMCMx/chcore_v7m.c:52
#6 0xfffffffc in ?? ()
#7 0xfffffffc in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) frame 2
#2 0x08000aea in dbg_check_lock_from_isr () at ../../chibios/stable_2.4.x/os/kernel/src/chdebug.c:141
141 chDbgPanic("SV#6");
(gdb) list
136 * @notapi
137 */
138 void dbg_check_lock_from_isr(void) {
139
140 if ((dbg_isr_cnt <= 0) || (dbg_lock_cnt != 0))
141 chDbgPanic("SV#6");
142 dbg_lock_cnt = 1;
143 }
144
145 /**
(gdb) p dbg_isr_cnt
$1 = 1
(gdb) p dbg_lock_cnt
$2 = 1
(gdb) up
#3 0x0800b536 in i2c_lld_safety_timeout (p=0x20001c14) at ../../chibios/stable_2.4.x/os/hal/platforms/STM32/i2c_lld.c:168
168 chSysLockFromIsr();
(gdb) list
163 * @notapi
164 */
165 static void i2c_lld_safety_timeout(void *p) {
166 I2CDriver *i2cp = (I2CDriver *)p;
167
168 chSysLockFromIsr();
169 if (i2cp->thread) {
170 Thread *tp = i2cp->thread;
171 i2c_lld_abort_operation(i2cp);
172 i2cp->thread = NULL;
(gdb) p *i2cp
$3 = {state = I2C_ACTIVE_TX, config = 0x8015bf0, errors = 0, mutex = {m_queue = {p_next = 0x20001c20, p_prev = 0x20001c20}, m_owner = 0x20002690,
m_next = 0x0}, thread = 0x0, addr = 59, dmamode = 4234, dmarx = 0x8014248, dmatx = 0x801423c, i2c = 0x40005400}
(gdb) up
#4 0x080009f6 in chSysTimerHandlerI () at ../../chibios/stable_2.4.x/os/kernel/src/chsys.c:146
146 chVTDoTickI();
(gdb) list
141 rlist.r_preempt--;
142 #endif
143 #if CH_DBG_THREADS_PROFILING
144 currp->p_time++;
145 #endif
146 chVTDoTickI();
147 #if defined(SYSTEM_TICK_EVENT_HOOK)
148 SYSTEM_TICK_EVENT_HOOK();
149 #endif
150 }
(gdb) up
#5 0x080005a6 in SysTickVector () at ../../chibios/stable_2.4.x/os/ports/GCC/ARMCMx/chcore_v7m.c:52
52 chSysTimerHandlerI();
(gdb)
(gdb) p dbg_trace_buffer
$4 = {tb_size = 64, tb_ptr = 0x200012e4, tb_buffer = {{se_time = 30237, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30237,
se_tp = 0x20000f28, se_wtobjp = 0xffffffff, se_state = 2 '\002'}, {se_time = 30237, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {
se_time = 30237, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 2 '\002'}, {se_time = 30237, se_tp = 0x20002690, se_wtobjp = 0x0,
se_state = 0 '\000'}, {se_time = 30237, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 6 '\006'}, {se_time = 30247, se_tp = 0x20002690,
se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30247, se_tp = 0x20000f28, se_wtobjp = 0xffffffff, se_state = 2 '\002'}, {se_time = 30247,
se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30247, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 2 '\002'}, {
se_time = 30247, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30247, se_tp = 0x20000f28, se_wtobjp = 0x0,
se_state = 6 '\006'}, {se_time = 30257, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30257, se_tp = 0x20000f28,
se_wtobjp = 0xffffffff, se_state = 2 '\002'}, {se_time = 30257, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30257,
se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 2 '\002'}, {se_time = 30257, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {
se_time = 30257, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 6 '\006'}, {se_time = 30267, se_tp = 0x20002690, se_wtobjp = 0x0,
se_state = 0 '\000'}, {se_time = 30267, se_tp = 0x20000f28, se_wtobjp = 0xffffffff, se_state = 2 '\002'}, {se_time = 30267, se_tp = 0x20002690,
se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30267, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 2 '\002'}, {se_time = 30267,
se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30267, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 6 '\006'}, {
se_time = 30277, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30277, se_tp = 0x20000f28, se_wtobjp = 0xffffffff,
se_state = 2 '\002'}, {se_time = 30277, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30277, se_tp = 0x20000f28,
se_wtobjp = 0x0, se_state = 2 '\002'}, {se_time = 30277, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30277,
se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 6 '\006'}, {se_time = 30287, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {
se_time = 30287, se_tp = 0x20000f28, se_wtobjp = 0xffffffff, se_state = 2 '\002'}, {se_time = 30287, se_tp = 0x20002690, se_wtobjp = 0x0,
se_state = 0 '\000'}, {se_time = 30287, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 2 '\002'}, {se_time = 30287, se_tp = 0x20002690,
se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30287, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 6 '\006'}, {se_time = 30296,
se_tp = 0x20000fe8, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30296, se_tp = 0x20000f28, se_wtobjp = 0xffffffff, se_state = 6 '\006'}, {
se_time = 30297, se_tp = 0x20000fe8, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30300, se_tp = 0x20002848, se_wtobjp = 0xffffffff,
se_state = 0 '\000'}, {se_time = 30300, se_tp = 0x20002690, se_wtobjp = 0xffffffff, se_state = 6 '\006'}, {se_time = 30300, se_tp = 0x20000fe8,
se_wtobjp = 0xffffffff, se_state = 2 '\002'}, {se_time = 30197, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30197,
se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 6 '\006'}, {se_time = 30200, se_tp = 0x20002848, se_wtobjp = 0x0, se_state = 0 '\000'}, {
se_time = 30200, se_tp = 0x20000f28, se_wtobjp = 0xffffffff, se_state = 6 '\006'}, {se_time = 30207, se_tp = 0x20002690, se_wtobjp = 0x0,
se_state = 0 '\000'}, {se_time = 30207, se_tp = 0x20000f28, se_wtobjp = 0xffffffff, se_state = 2 '\002'}, {se_time = 30207, se_tp = 0x20002690,
se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30207, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 2 '\002'}, {se_time = 30207,
se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30207, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 6 '\006'}, {
se_time = 30217, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30217, se_tp = 0x20000f28, se_wtobjp = 0xffffffff,
se_state = 2 '\002'}, {se_time = 30217, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30217, se_tp = 0x20000f28,
se_wtobjp = 0x0, se_state = 2 '\002'}, {se_time = 30217, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30217,
se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 6 '\006'}, {se_time = 30227, se_tp = 0x20002690, se_wtobjp = 0x0, se_state = 0 '\000'}, {
se_time = 30227, se_tp = 0x20000f28, se_wtobjp = 0xffffffff, se_state = 2 '\002'}, {se_time = 30227, se_tp = 0x20002690, se_wtobjp = 0x0,
se_state = 0 '\000'}, {se_time = 30227, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 2 '\002'}, {se_time = 30227, se_tp = 0x20002690,
se_wtobjp = 0x0, se_state = 0 '\000'}, {se_time = 30227, se_tp = 0x20000f28, se_wtobjp = 0x0, se_state = 6 '\006'}}}
(gdb)
For completeness, I'm using this compiler:
Code: Select all
$ arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/Users/louie/Documents/Bluetooth/tools/yagarto-4.6.2/bin/../libexec/gcc/arm-none-eabi/4.6.2/lto-wrapper
Target: arm-none-eabi
Configured with: ../gcc-4.6.2/configure --target=arm-none-eabi --prefix=/Users/mfischer/Projects/yagarto/install --disable-nls --disable-shared --disable-threads --with-gcc --with-gnu-ld --with-gnu-as --with-dwarf2 --enable-languages=c,c++ --enable-interwork --enable-multilib --with-newlib --with-headers=../newlib-1.19.0/newlib/libc/include --disable-libssp --disable-libstdcxx-pch --disable-libmudflap --disable-libgomp -v
Thread model: single
gcc version 4.6.2 (GCC)
and compiling with these options:
USE_OPT= -ggdb3 -fomit-frame-pointer
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: "chVTResetI(), #1" panic from i2c_lld_master_timeout
The file I sent is done for the version in trunk, you are using 2.4.x. There is an important difference, in the new version callbacks are not called within a lock. In 2.4.x the callback is invoked from within a lock. Sorry, it slipped from my mind.
You should remove chSysLockFromIsr() and chSysUnlockFromIsr() from the callback i2c_lld_safety_timeout(). The error you are getting is the state checker informing you about two consecutive locks.
Thanks for all the testing.
Giovanni
You should remove chSysLockFromIsr() and chSysUnlockFromIsr() from the callback i2c_lld_safety_timeout(). The error you are getting is the state checker informing you about two consecutive locks.
Thanks for all the testing.
Giovanni
Re: "chVTResetI(), #1" panic from i2c_lld_master_timeout
I removed the two lines as suggested, and I'm very happy to report that the problem I was seeing is gone. I'm pretty encouraged, since I could reliably reproduce the issue previously, and I've run through the same testing process 4 times now without a hint of the problem.
Thanks very much for looking at this, especially over the weekend. I know how difficult it can be to do this sort of debugging by "remote control."
Thanks very much for looking at this, especially over the weekend. I know how difficult it can be to do this sort of debugging by "remote control."
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: "chVTResetI(), #1" panic from i2c_lld_master_timeout
You are welcome, really thanks for helping me in fixing this issue. The repository has been updated with the fix.
Giovanni
Giovanni
Re: "chVTResetI(), #1" panic from i2c_lld_master_timeout
I met same problem.
When I2C timeout occurs, i2cp->state becomes I2C_LOCKED.
When I call I2C transfer next time, it rises exception, because I2C expects that state have to be I2C_READY.
Do you know workaroud for this (I cannot use TIME_INFINITE because I2C bus can have uncorrect state, and I have to reset it manually)?
Should I do stop/start i2c every time when I met timeout or you know better solution?
Thanks!
When I2C timeout occurs, i2cp->state becomes I2C_LOCKED.
When I call I2C transfer next time, it rises exception, because I2C expects that state have to be I2C_READY.
Do you know workaroud for this (I cannot use TIME_INFINITE because I2C bus can have uncorrect state, and I have to reset it manually)?
Should I do stop/start i2c every time when I met timeout or you know better solution?
Thanks!
Re: "chVTResetI(), #1" panic from i2c_lld_master_timeout
And this is not a single problem.
I was tried to use my I2C STM8S driver, but met a problem - when I start to use OS hard (many threads and so on), I2C started to make some funny things, like marking START and STOP conditions at same time.
As I understand, this is happened because of OS frequently disables and enabled interrupts, so some bytes can be received before I2C interrupt, broking all statuses inside. Rising priority of IRQ helps a lot, but main problem is disabling IRQ in locked states. So, I cannot see some way to implement interrupt-driven I2C HAL driver..
May be, I should write some code to make blocking I2C transfers?.. I don't know..
I was tried to use my I2C STM8S driver, but met a problem - when I start to use OS hard (many threads and so on), I2C started to make some funny things, like marking START and STOP conditions at same time.
As I understand, this is happened because of OS frequently disables and enabled interrupts, so some bytes can be received before I2C interrupt, broking all statuses inside. Rising priority of IRQ helps a lot, but main problem is disabling IRQ in locked states. So, I cannot see some way to implement interrupt-driven I2C HAL driver..
May be, I should write some code to make blocking I2C transfers?.. I don't know..
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: "chVTResetI(), #1" panic from i2c_lld_master_timeout
Hi,
The OS does not block interrupts for long time, probably it is the I2C peripheral that is "not optimal", even the STM32 I2C peripheral has similar issues, they finally revamped the I2C in the very latest STM32F0 devices.
My suggestion is to drop it and use a bit banged I2C implementation in the low level driver.
Giovanni
The OS does not block interrupts for long time, probably it is the I2C peripheral that is "not optimal", even the STM32 I2C peripheral has similar issues, they finally revamped the I2C in the very latest STM32F0 devices.
My suggestion is to drop it and use a bit banged I2C implementation in the low level driver.
Giovanni