WP77 problems with SPI and i2c

Hi,

I am having some troubles getting SPI and i2c buses working on WP77.
Some background on the specs I am working with:

  • mangOH Red board
  • WP77 module with firmware SWI9X06Y_02.13.02.00
  • Legato 17.11
  • Toolchain for WP76

I am trying to get the built-in i2c sensors on the board working (gyro, accelerometer, pressure, temperature) but it cannot find any i2c devices under /sys/devices. I am using the same code for a WP8548 module that works fine.
These is what is in my required: file:

/sys/devices/i2c-0/0-0068/iio:device0/in_accel_x_raw /sys/devices/i2c-0/0-0068/iio:device0/
/sys/devices/i2c-0/0-0068/iio:device0/in_accel_y_raw /sys/devices/i2c-0/0-0068/iio:device0/
/sys/devices/i2c-0/0-0068/iio:device0/in_accel_z_raw /sys/devices/i2c-0/0-0068/iio:device0/
/sys/devices/i2c-0/0-0068/iio:device0/in_accel_scale /sys/devices/i2c-0/0-0068/iio:device0/
/sys/devices/i2c-0/0-0068/iio:device0/in_anglvel_x_raw /sys/devices/i2c-0/0-0068/iio:device0/
/sys/devices/i2c-0/0-0068/iio:device0/in_anglvel_y_raw /sys/devices/i2c-0/0-0068/iio:device0/
/sys/devices/i2c-0/0-0068/iio:device0/in_anglvel_z_raw /sys/devices/i2c-0/0-0068/iio:device0/
/sys/devices/i2c-0/0-0068/iio:device0/in_anglvel_scale /sys/devices/i2c-0/0-0068/iio:device0/
/sys/devices/i2c-0/0-0076/iio:device1/in_temp_input /sys/devices/i2c-0/0-0076/iio:device1/
/sys/devices/i2c-0/0-0076/iio:device1/in_pressure_input /sys/devices/i2c-0/0-0076/iio:device1/

And when running the program I get error:

Jan 31 06:49:51 | supervisor[643]/supervisor T=main | app.c CreateFileLink() 1485 | Could not stat file at ‘/sys/devices/i2c-0/0-0068/iio:device0/in_accel_scale’. No such file or directory

For SPI when trying to run code working on WP8548 this is what I get:

Jan 31 07:03:30 | supervisor[7972]/supervisor T=main | app.c GetDevID() 644 | Could not get file info for ‘/dev/spidev0.0’. No such file or directory.
Jan 31 07:03:30 | supervisor[7972]/supervisor T=main | app.c SetCfgDevicePermissions() 754 | Failed to set permissions (rw) for app ‘spiService’ on device ‘/dev/spidev0.0’.

So, I went through everything multiple times. Installed spisvc kernel etc. Checked lsmod which gives:

root@swi-mdm9x28:~# lsmod
Tainted: G
spisvc 1069 0 - Live 0xbf000000 (O)

Tried modprobe:

root@swi-mdm9x28:~# modprobe spidev
modprobe: module spidev not found in modules.dep

The only spidev device found (which is not found on WP8548) is:

root@swi-mdm9x28:~# ls /dev/spi
/dev/spidev1.0

Sidenote:
I also had some issues with OpenSSL that I solved with a workaround, and somehow leads me to believe there might be a issue with the firmware, please correct me if I am wrong. I could not find most files needed installed on the board (despite OpenSSL library should be in the toolchain), so I manually copied them to /home/root on the device and pointed the program to that instead.

I understand WP77 is still WIP, but I understood you have atleast gotten i2c working so maybe I am missing something. Thank you very much, and please let me know if something is unclear.

1 Like

Hi,

Can you try with the toolchain of WP77?
https://source.sierrawireless.com/resources/airprime/software/wp77xx/wp77xx-firmware-release-7-components/

I can compile the MangOH Red i2c sensors driver with above toolchain for WP77.

Hi @jyijyi,

For some reason I cannot compile the WP77XX toolchain? sh: Permission denied
Yes, I tried as sudo also. I can compile other toolchains (WP85, WP76). Have you experienced this?

Hi,

can you attach the full log for your compilation?

Hi,

Sorry nevermind. The toolchain did not have execute permission enabled. Just needed to enable it and now it works.

Actually seems like there is still some problem. Or it throws an error but not sure if relevant.

Poky (Yocto Project Reference Distro) SDK installer version 2.2.2
=================================================================
Enter target directory for SDK (default: /opt/swi/y22-ext):
You are about to install the SDK to “/opt/swi/y22-ext”. Proceed[Y/n]? y
Extracting SDK…done
Setting it up…done
Makefile:662: Cannot use CONFIG_CC_STACKPROTECTOR_REGULAR: -fstack-protector not supported by compiler
HOSTCC scripts/basic/fixdep
scripts/basic/fixdep.c:462:1: fatal error: opening dependency file scripts/basic/.fixdep.d: Permission denied
}
^
compilation terminated.
scripts/Makefile.host:91: recipe for target ‘scripts/basic/fixdep’ failed
make[1]: *** [scripts/basic/fixdep] Error 1
Makefile:455: recipe for target ‘scripts_basic’ failed
make: *** [scripts_basic] Error 2
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
$ . /opt/swi/y22-ext/environment-setup-armv7a-neon-poky-linux-gnueabi

Hi again @jyijyi,

I did some testing with the WP77 toolchain, and cannot get i2c working. More specifically the internal sensors on the mangOH red.

Screenshot from /sys/devices on WP8548:
wp8548_devices

Screenshot from /sys/devices on WP7702:

Also, with the new framework most library files for SSL are located either under /usr/lib or /lib/ but for some reason libcrypto.so and libssl.so are still missing.

Hi,

From dmesg of WP77xx, I can see a line: (not sure if you have the same)


mangoh mangoh red dv3: Failed to get I2C adapter 0.


Probably this is where blocks the initialization of the sensor.
Still looking around the code…

This is what I get from dmesg:

[97948.873265] usb 3-6: new high-speed USB device number 53 using xhci_hcd
[97949.018811] usb 3-6: config 1 has an invalid interface number: 8 but max is 5
[97949.018816] usb 3-6: config 1 has an invalid interface number: 19 but max is 5
[97949.018818] usb 3-6: config 1 has an invalid interface number: 20 but max is 5
[97949.018821] usb 3-6: config 1 has an invalid interface number: 20 but max is 5
[97949.018824] usb 3-6: config 1 has no interface number 1
[97949.018826] usb 3-6: config 1 has no interface number 4
[97949.018828] usb 3-6: config 1 has no interface number 5
[97949.026852] usb 3-6: New USB device found, idVendor=1199, idProduct=68c0
[97949.026857] usb 3-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[97949.026860] usb 3-6: Product: Sierra Wireless WP7702
[97949.026863] usb 3-6: Manufacturer: Sierra Wireless, Incorporated
[97949.026865] usb 3-6: SerialNumber: VU73537052100105
[97949.030000] qcserial 3-6:1.0: Qualcomm USB modem converter detected
[97949.030206] usb 3-6: Qualcomm USB modem converter now attached to ttyUSB0
[97949.031962] qcserial 3-6:1.2: Qualcomm USB modem converter detected
[97949.032209] usb 3-6: Qualcomm USB modem converter now attached to ttyUSB1
[97949.033867] qcserial 3-6:1.3: Qualcomm USB modem converter detected
[97949.034066] usb 3-6: Qualcomm USB modem converter now attached to ttyUSB2
[97949.036038] qmi_wwan 3-6:1.8: cdc-wdm0: USB WDM device
[97949.036621] qmi_wwan 3-6:1.8 wwan0: register ‘qmi_wwan’ at usb-0000:00:14.0-6, WWAN/QMI device, 06:59:2c:51:ef:5c
[97949.042248] cdc_ether 3-6:1.19 usb0: register ‘cdc_ether’ at usb-0000:00:14.0-6, CDC Ethernet Device, 92:29:60:bc:82:5e
[97949.087016] cdc_ether 3-6:1.19 enp0s20u6i19: renamed from usb0
[97949.112349] qmi_wwan 3-6:1.8 wwp0s20u6i8: renamed from wwan0
[97949.125704] IPv6: ADDRCONF(NETDEV_UP): enp0s20u6i19: link is not ready
[97949.125782] cdc_ether 3-6:1.19 enp0s20u6i19: kevent 12 may have been dropped
[97949.125789] cdc_ether 3-6:1.19 enp0s20u6i19: kevent 12 may have been dropped

Hi,

Now I can see the pressure sensor information here: (Please check whether you see the same)
root@swi-mdm9x28:/sys/devices/78b8000.i2c/i2c-4/4-0076/iio:device1# ls
dev
in_pressure_input
in_pressure_oversampling_ratio_available
in_temp_input
in_temp_oversampling_ratio_available
name
power
subsystem
uevent

Hi,

These are found under /i2c-4/ directory:

root@swi-mdm9x28:~# ls /sys/devices/78b8000.i2c/i2c-4/
4-001a delete_device i2c-dev new_device subsystem
4-003a device name power uevent

And in 4-001a:

root@swi-mdm9x28:~# ls /sys/devices/78b8000.i2c/i2c-4/4-001a/
driver name subsystem wm8944-codec
modalias power uevent wm8944-gpio

And 4-003a:

root@swi-mdm9x28:~# ls /sys/devices/78b8000.i2c/i2c-4/4-003a/
driver name subsystem swimcu-hwmon
modalias power swimcu-gpio uevent

And these at least 4-001a is audio driver (wm8944) if I am not mistaken. Cannot find what you are seeing.

Hi,
That means it is working fine for the i2c on your board.
To have the sensor working on mangOH red board, you need to integrate those sensor driver.
However, you need to change some code inside \linux_kernel_modules\mangoh\board_red_dv3.c.
All the “i2c_get_adapter(0)” should be changed to “i2c_get_adapter(4)”.

Hi @jyijyi,

What drivers exactly are needed for the pressure/temp & gyro/acc sensors? Is it bmp280 & bmi160? I am having some trouble actually installing those.

And onto your second point about changing the code. Did you mean /linux_kernel_modules/mangoh/mangoh_red.c ? There is one i2c_get_adapter(0) which I changed to 4 but due to my other issues I am not sure if this is correct.

In my sdef I have:

kernelModules:
{
$MANGOH_ROOT/linux_kernel_modules/mangoh/9-mangoh_red_dv3
$LEGATO_ROOT/drivers/spisvc/spisvc
}

And these are the ones giving me issues (when trying to put them into kernelModules:

// Required for bmp280 & bmi160
$MANGOH_ROOT/linux_kernel_modules/iio/0-iio
$MANGOH_ROOT/linux_kernel_modules/iio/1-iio-kfifo-buf
// Required for bmi160
$MANGOH_ROOT/linux_kernel_modules/iio/2-iio-triggered-buffer
$MANGOH_ROOT/linux_kernel_modules/bmp280/2-bmp280
$MANGOH_ROOT/linux_kernel_modules/bmp280/3-bmp280-i2c
$MANGOH_ROOT/linux_kernel_modules/bmi160/3-bmi160
$MANGOH_ROOT/linux_kernel_modules/bmi160/4-bmi160-i2c

yes, we need driver of bmp280 & bmi160.
As said before, I am changing the code in \linux_kernel_modules\mangoh\board_red_dv3.c.

Ok, I tried with this sdef:

kernelModules:
{
// $MANGOH_ROOT/linux_kernel_modules/mangoh/9-mangoh_red_dv2
$MANGOH_ROOT/linux_kernel_modules/mangoh/9-mangoh_red_dv3
// $MANGOH_ROOT/linux_kernel_modules/mangoh/9-mangoh_red_dv5
// Required for bmp280 & bmi160
$MANGOH_ROOT/linux_kernel_modules/iio/0-iio
$MANGOH_ROOT/linux_kernel_modules/iio/1-iio-kfifo-buf
// Required for bmi160
$MANGOH_ROOT/linux_kernel_modules/iio/2-iio-triggered-buffer
$MANGOH_ROOT/linux_kernel_modules/bmp280/2-bmp280
$MANGOH_ROOT/linux_kernel_modules/bmp280/3-bmp280-i2c
// Used on mangOH Red DV3 and later
$MANGOH_ROOT/linux_kernel_modules/bmi160/3-bmi160
$MANGOH_ROOT/linux_kernel_modules/bmi160/4-bmi160-i2c
// spisvc creates a spidev device which will appear as /dev/spidev0.0 once the spidev module is
// loaded.
$LEGATO_ROOT/drivers/spisvc/spisvc
}

And I get the following error when trying to compile: error (12.8 KB)

Ok, I cannot find any such C file (board_red_dv3.c) in that directory or on my PC. But perhaps it is the same as mangoh_red.c for me.

after you install the toolchain in /opt/swi/y22-ext, you need to go to “/opt/swi/y22-ext/sysroots/armv7a-neon-poky-linux-gnueabi/usr/src/kernel/include/linux/iio/trigger.h”, in line 137, change to the following:


//void iio_trigger_poll(struct iio_trigger *trig);
//void iio_trigger_poll_chained(struct iio_trigger *trig);

void iio_trigger_poll(struct iio_trigger *trig, s64 time);
void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time);


Thank you @jyijyi very much! This solved the issue, now I can compile the drivers and find them under /sys/devices directory.

I did not have to change anything in \linux_kernel_modules\mangoh\board_red_dv3.c. or similar as you described. I pulled newest version from mangOH git, and there are no i2c_get_adapter(0) anymore. The 0 is replaced with some variable for each i2c_get_adapter().

Is this something that will be fixed in later versions? Since I am working with both WP8548 and WP7702 I guess I need to change the trigger.h file accordingly to what module I am using?

And did you have any info on the SPI issues? Copied from original:

For SPI when trying to run code working on WP8548 this is what I get:

Jan 31 07:03:30 | supervisor[7972]/supervisor T=main | app.c GetDevID() 644 | Could not get file info for ‘/dev/spidev0.0’. No such file or directory.
Jan 31 07:03:30 | supervisor[7972]/supervisor T=main | app.c SetCfgDevicePermissions() 754 | Failed to set permissions (rw) for app ‘spiService’ on device ‘/dev/spidev0.0’.

So, I went through everything multiple times. Installed spisvc kernel etc. Checked lsmod which gives:

root@swi-mdm9x28:~# lsmod
Tainted: G
spisvc 1069 0 - Live 0xbf000000 (O)

Tried modprobe:

root@swi-mdm9x28:~# modprobe spidev
modprobe: module spidev not found in modules.dep

The only spidev device found (which is not found on WP8548) is:

root@swi-mdm9x28:~# ls /dev/spi
/dev/spidev1.0

Sorry, I have never tried on SPI interface before.
But suggest you trying on /dev/spidev1.0.

Yeah I tried but it does not seem to work. As spidev is not found in modules.dep I guess there is some driver issue here as well.

But anyway, thank you for your help. One step at a time!