Discussion:
up_assert: Assertion failed at file:sched/sched_removereadytorun.c
(too old to reply)
Alan Carvalho de Assis acassis@gmail.com [nuttx]
2018-01-05 21:10:19 UTC
Permalink
Hi Greg,

I'm facing this strange assertion when trying to use the bq2425x
battery driver. This driver was working fine in an ancient NuttX (tag:
nuttx-7.16).

Analyzing the stack dump I can see references to stm32_i2c_transfer()
and at 0x0801748c I see these strange __FUNCTION__.xxxx

08016eb8 t g_ledbits
08016ec8 t __FUNCTION__.5512
08016f78 t __FUNCTION__.6120
08016f81 t g_idlename
08016f8c T g_tasklisttable
0801700e t __FUNCTION__.5553
0801704e t __FUNCTION__.5300
0801708c t __FUNCTION__.5624
080170bd t g_noname
080170ea t __FUNCTION__.5670
0801715e t __FUNCTION__.5689
0801722b t __FUNCTION__.5854
08017287 t __FUNCTION__.5696
08017442 t __FUNCTION__.5318
080174a8 t __FUNCTION__.4501
080174bc t g_batteryops
080174dc t __FUNCTION__.4507
08017540 t __FUNCTION__.5707
08017550 t __FUNCTION__.5699
08017560 t __FUNCTION__.5774
08017574 t __FUNCTION__.5811
0801758a t __FUNCTION__.5782
0801759a t __FUNCTION__.5797
080175aa t __FUNCTION__.5790
080175ba t __FUNCTION__.5804
080175cc t g_bq2425xops
080175e8 t __FUNCTION__.5719
080175f6 t __FUNCTION__.5726

To find the place there the error was happening, I only kept the call
"ret = bq2425x_reset(priv);" at bq2425x_initialize() and discovered
that the error happens when the "i2c_write(priv->i2c, &config,
&regaddr, 1);" is called at bq2425x_getreg8().

I enabled the I2C Debug, the Power-related debug and the Scheduler
debug, but I only got these messages before the assertion:

Aï¿œCDF
os_start: Entry
uart_register: Registering /dev/console
uart_register: Registering /dev/ttyS0
uart_register: Registering /dev/ttyS1
uart_register: Registering /dev/ttyS2
work_lpstart: Starting low-priority kernel worker thread(s)
up_release_pending: From TCB=200007c0
bq2425x_getreg8: addr: 01
clock_gettime: clock_id=0
clock_gettime: Returning tp=(1323129600,20000000)
clock_gettime: clock_id=0
clock_gettime: Returning tp=(1323129600,20000000)
up_assert: Assertion failed at file:sched/sched_removereadytorun.c
line: 93 task: Idle Task
up_dumpstate: sp: 20002f98
up_dumpstate: stack base: 20003108
up_dumpstate: stack size: 00000400
up_stackdump: 20002f80: 00000000 20002f90 08000d8f 08016b4a 08016ac1
00000400 0000005d 200008b8
up_stackdump: 20002fa0: 200007c0 08011815 200007c0 08011815 200007c0
08011815 200007c0 08011815
up_stackdump: 20002fc0: 00000001 20002614 00000000 08005969 200007c0
00000000 00000001 20000918
up_stackdump: 20002fe0: 00000000 08011c4f 00000032 200007c0 20000136
08011e33 00000000 0801748c
up_stackdump: 20003000: 08017442 00000032 01312d00 20000128 00000000
00000000 20000134 1dcd6500
up_stackdump: 20003020: 3b9ac9ff 080056db 08012f41 08012f41 4edd5b00
1efe9200 20002a3c 0000006a
up_stackdump: 20003040: 100028e0 200030a7 00000ed8 0000006a 20000128
080042e5 000186a0 0000006a
up_stackdump: 20003060: 2000307f 00000001 100028e0 08003647 20002a3c
08004d69 100028e0 01004efd
up_stackdump: 20003080: 00000000 00000014 000186a0 0807006a 100028e0
080175cc 000186a0 080039a1
up_stackdump: 200030a0: 20000128 0000006a 000186a0 00000000 2000261c
00000003 00000000 200008b8
up_stackdump: 200030c0: 00000000 0800157b 000007d0 00000000 00007fff
08001307 00000000 080017ad
up_stackdump: 200030e0: 00000000 00000000 200007c0 08001723 2000310c
0001cef4 00000000 0800050d
up_stackdump: 20003100: 00000000 ffffffff 32462554 9ee27cf7 00000008
80000000 00000190 80000008

The battery charger is at I2C3 (I2C1 and I2C2 are not enabled).

Do you have some idea what could be causing it?

In the nuttx-7.16 the I2C was initialized this way:

FAR struct i2c_dev_s *i2c;

i2c = up_i2cinitialize(BQ2425X_I2CBUS);
if (!i2c)
{
dbg("ERROR: Failed to initialize I2C%d\n", BQ2425X_I2CBUS);
return -1;
}

Now the current NuttX needs to initialize it this way:

FAR struct i2c_master_s *i2c;

i2c = stm32_i2cbus_initialize(BQ2425X_I2CBUS);
if (!i2c)
{
_err("ERROR: Failed to initialize I2C%d\n", BQ2425X_I2CBUS);
return -1;
}

The board uses a STM32F407 MCU, same of the STM32F4Discovery board.

BR,

Alan
Alan Carvalho de Assis acassis@gmail.com [nuttx]
2018-01-06 11:07:05 UTC
Permalink
Finally I figured-out what was happening:

The CONFIG_BOARD_INITIALIZE and CONFIG_NSH_ARCHINIT were enabled.

Because CONFIG_BOARD_INITIALIZE was enabled the stm32_bringup() that
calls the battery driver was called early.

Keeping only CONFIG_NSH_ARCHINIT fixed the issue.

BR,

Alan
Post by Alan Carvalho de Assis ***@gmail.com [nuttx]
Hi Greg,
I'm facing this strange assertion when trying to use the bq2425x
nuttx-7.16).
Analyzing the stack dump I can see references to stm32_i2c_transfer()
and at 0x0801748c I see these strange __FUNCTION__.xxxx
08016eb8 t g_ledbits
08016ec8 t __FUNCTION__.5512
08016f78 t __FUNCTION__.6120
08016f81 t g_idlename
08016f8c T g_tasklisttable
0801700e t __FUNCTION__.5553
0801704e t __FUNCTION__.5300
0801708c t __FUNCTION__.5624
080170bd t g_noname
080170ea t __FUNCTION__.5670
0801715e t __FUNCTION__.5689
0801722b t __FUNCTION__.5854
08017287 t __FUNCTION__.5696
08017442 t __FUNCTION__.5318
080174a8 t __FUNCTION__.4501
080174bc t g_batteryops
080174dc t __FUNCTION__.4507
08017540 t __FUNCTION__.5707
08017550 t __FUNCTION__.5699
08017560 t __FUNCTION__.5774
08017574 t __FUNCTION__.5811
0801758a t __FUNCTION__.5782
0801759a t __FUNCTION__.5797
080175aa t __FUNCTION__.5790
080175ba t __FUNCTION__.5804
080175cc t g_bq2425xops
080175e8 t __FUNCTION__.5719
080175f6 t __FUNCTION__.5726
To find the place there the error was happening, I only kept the call
"ret = bq2425x_reset(priv);" at bq2425x_initialize() and discovered
that the error happens when the "i2c_write(priv->i2c, &config,
&regaddr, 1);" is called at bq2425x_getreg8().
I enabled the I2C Debug, the Power-related debug and the Scheduler
Aï¿œCDF
os_start: Entry
uart_register: Registering /dev/console
uart_register: Registering /dev/ttyS0
uart_register: Registering /dev/ttyS1
uart_register: Registering /dev/ttyS2
work_lpstart: Starting low-priority kernel worker thread(s)
up_release_pending: From TCB=200007c0
bq2425x_getreg8: addr: 01
clock_gettime: clock_id=0
clock_gettime: Returning tp=(1323129600,20000000)
clock_gettime: clock_id=0
clock_gettime: Returning tp=(1323129600,20000000)
up_assert: Assertion failed at file:sched/sched_removereadytorun.c
line: 93 task: Idle Task
up_dumpstate: sp: 20002f98
up_dumpstate: stack base: 20003108
up_dumpstate: stack size: 00000400
up_stackdump: 20002f80: 00000000 20002f90 08000d8f 08016b4a 08016ac1
00000400 0000005d 200008b8
up_stackdump: 20002fa0: 200007c0 08011815 200007c0 08011815 200007c0
08011815 200007c0 08011815
up_stackdump: 20002fc0: 00000001 20002614 00000000 08005969 200007c0
00000000 00000001 20000918
up_stackdump: 20002fe0: 00000000 08011c4f 00000032 200007c0 20000136
08011e33 00000000 0801748c
up_stackdump: 20003000: 08017442 00000032 01312d00 20000128 00000000
00000000 20000134 1dcd6500
up_stackdump: 20003020: 3b9ac9ff 080056db 08012f41 08012f41 4edd5b00
1efe9200 20002a3c 0000006a
up_stackdump: 20003040: 100028e0 200030a7 00000ed8 0000006a 20000128
080042e5 000186a0 0000006a
up_stackdump: 20003060: 2000307f 00000001 100028e0 08003647 20002a3c
08004d69 100028e0 01004efd
up_stackdump: 20003080: 00000000 00000014 000186a0 0807006a 100028e0
080175cc 000186a0 080039a1
up_stackdump: 200030a0: 20000128 0000006a 000186a0 00000000 2000261c
00000003 00000000 200008b8
up_stackdump: 200030c0: 00000000 0800157b 000007d0 00000000 00007fff
08001307 00000000 080017ad
up_stackdump: 200030e0: 00000000 00000000 200007c0 08001723 2000310c
0001cef4 00000000 0800050d
up_stackdump: 20003100: 00000000 ffffffff 32462554 9ee27cf7 00000008
80000000 00000190 80000008
The battery charger is at I2C3 (I2C1 and I2C2 are not enabled).
Do you have some idea what could be causing it?
FAR struct i2c_dev_s *i2c;
i2c = up_i2cinitialize(BQ2425X_I2CBUS);
if (!i2c)
{
dbg("ERROR: Failed to initialize I2C%d\n", BQ2425X_I2CBUS);
return -1;
}
FAR struct i2c_master_s *i2c;
i2c = stm32_i2cbus_initialize(BQ2425X_I2CBUS);
if (!i2c)
{
_err("ERROR: Failed to initialize I2C%d\n", BQ2425X_I2CBUS);
return -1;
}
The board uses a STM32F407 MCU, same of the STM32F4Discovery board.
BR,
Alan
Loading...