imx1050, 2 problems adding lpi2c driver and gpio interrupt for the fxos8700 in zephyr

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx1050, 2 problems adding lpi2c driver and gpio interrupt for the fxos8700 in zephyr

1,034 Views
natester
Contributor I

I have added the lpi2c driver to the imx1050 board in Zephyr to support the fxos8700, however I have a few small issues.

1. The first issues is that if I send a reset command to the 8700 (I have commented it out of the zephyr 8700 driver here: https://github.com/nathantsoi/zephyr/commit/cd5c79efb8f2857347cccd9e3d9bab71eb889009#diff-fa43f421b9...), the gyro no longer responds to commands and must be power cycled.

2. Polling mode is working fine, with a few changes to the sensor sample. However interrupt mode is not working.

Here it is in polling mode:

***** BOOTING ZEPHYR OS v1.11.0 - BUILD: Mar 24 2018 23:22:52 *****

sampling
AX= 0.009576 AY= -0.105345 AZ= 9.710881 MX= -0.100000 MY= -0.291000 MZ= 0.512000 T= 24.960000
sampling
AX= -0.019154 AY= -0.114922 AZ= 9.873687 MX= -0.095000 MY= -0.323000 MZ= 0.502000 T= 24.960000
sampling
AX= -0.038308 AY= -0.057461 AZ= 9.835380 MX= -0.107000 MY= -0.319000 MZ= 0.541000 T= 24.000000
sampling
AX= -0.057461 AY= -0.067038 AZ= 9.854534 MX= -0.083000 MY= -0.305000 MZ= 0.537000 T= 24.960000

However, enabling interrupt mode (by defining this thread https://github.com/nathantsoi/zephyr/commit/cd5c79efb8f2857347cccd9e3d9bab71eb889009#diff-b510f9e7a2... and uncommenting the code here: https://github.com/nathantsoi/zephyr/commit/cd5c79efb8f2857347cccd9e3d9bab71eb889009#diff-ca6f35b80b...) results in a hard fault:

***** MPU FAULT *****
Executing thread ID (thread): 0x200004b0
Faulting instruction address: 0x504c
Data Access Violation
Address: 0x0
Fatal fault in thread 0x200004b0! Aborting.
***** HARD FAULT *****
Fault escalation (see below)
***** MPU FAULT *****
Executing thread ID (thread): 0x200004b0
Faulting instruction address: 0x4fa8
Data Access Violation
Address: 0x0
Fatal fault in ISR! Spinning...

This originates in dlist.h

337 static inline void sys_dlist_append(sys_dlist_t *list, sys_dnode_t *node)
338 {
339 node->next = list;
340 node->prev = list->tail;
341
342 list->tail->next = node;
343 list->tail = node;
344 }

list appears to be 0x0

(gdb) p *list
$10 = {{head = 0x0 <isr_tables_syms>, next = 0x0 <isr_tables_syms>}, {tail = 0x0 <isr_tables_syms>, prev = 0x0 <isr_tables_syms>}}
(gdb) bt
#0 0x000050b0 in sys_dlist_append (node=0x200005ac <_main_thread_s>, list=0x2000008c <fxos8700_data+4>) at ../../../../include/misc/dlist.h:342
#1 _pend_thread (thread=0x200005ac <_main_thread_s>, wait_q=wait_q@entry=0x2000008c <fxos8700_data+4>, timeout=timeout@entry=-1)
at /Users/me/src/embedded/zephyr/kernel/sched.c:197
#2 0x000051f8 in _pend_current_thread (wait_q=0x2000008c <fxos8700_data+4>, timeout=-1) at /Users/me/src/embedded/zephyr/kernel/sched.c:215
#3 0x0000562c in _impl_k_sem_take (sem=sem@entry=0x2000008c <fxos8700_data+4>, timeout=timeout@entry=-1) at /Users/me/src/embedded/zephyr/kernel/sem.c:175
#4 0x000048d2 in k_sem_take (timeout=-1, sem=0x2000008c <fxos8700_data+4>) at zephyr/include/generated/syscalls/kernel.h:79
#5 fxos8700_trigger_set (dev=0x20001558 <__device_fxos8700>, trig=0x20000aec <_main_stack+916>, handler=0x1e89 <trigger_handler>)
at /Users/me/src/embedded/zephyr/drivers/sensor/fxos8700/fxos8700_trigger.c:149
#6 0x00001efa in sensor_trigger_set (handler=0x1e89 <trigger_handler>, trig=0x20000aec <_main_stack+916>, dev=0x20001558 <__device_fxos8700>)
at /Users/me/src/embedded/zephyr/include/sensor.h:341
#7 main () at ../src/main.c:60

You can see my changes here:

wip, i2c driver and fxos8700 (non-triggered) support for the imx1050 · nathantsoi/zephyr@cd5c79e · G... 

Or checkout the whole branch to run it:

GitHub - nathantsoi/zephyr at upstream-zephyr-v1.11.0-mimxrt1050-lpi2c 

Any direction would be much appreciated.

Thanks!

Tags (3)
0 Kudos
2 Replies

793 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hello Nathan,

     SDK and drivers for I.MXRT1050 we released are used for applications with non-OS or RTOS ( FreeRTOS), but for Zephyr RTOS, we also don't have corresponding materials for you reference.

    

Have a nice day!

TIC weidong sun

0 Kudos

793 Views
natester
Contributor I

I found the root cause of the 8700 issue, it looks like the hal lpi2c driver does not handle the missing stop flag. How do the supported RTOSes handle this?

This fixes it, but could cause other problems:

https://github.com/zephyrproject-rtos/zephyr/compare/master...nathantsoi:upstream-zephyr-v1.11.0-mim...

0 Kudos