Problem I2C file is missing


#1

Hello,

I need help for one little problem. I try to compile the BatteryChargerReading program with this command ;
mkapp -t wp77xx batteryReading.adef

I want to use this program and edit it to make work some I2C devices that my company developped.

It can’t compile. Here is the error :

mangoh@mangoh-vm:~/mangOH/samples/tutorials/mangOH_Red/i2c/BatteryChargerReading$ mkapp -t wp77xx batteryReading.adef
[1/9] Compiling C source
_FAILED: _build_batteryReading/wp77xx/component/703af1bcdfe6b9325199aaa5cfacdbc0/obj/68d2ff43610d92f80456d9e70b60ae53.o _
_/opt/swi/y22-ext-wp77xx/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=/opt/swi/y22-ext-wp77xx/sysroots/armv7a-neon-poky-linux-gnueabi -MMD -MF _build_batteryReading/wp77xx/component/703af1bcdfe6b9325199aaa5cfacdbc0/obj/68d2ff43610d92f80456d9e70b60ae53.o.d -c /home/mangoh/mangOH/samples/tutorials/mangOH_Red/i2c/BatteryChargerReading/batteryReadingComponent/batteryReading.c -o _build_batteryReading/wp77xx/component/703af1bcdfe6b9325199aaa5cfacdbc0/obj/68d2ff43610d92f80456d9e70b60ae53.o -DLE_FILENAME=basename /home/mangoh/mangOH/samples/tutorials/mangOH_Red/i2c/BatteryChargerReading/batteryReadingComponent/batteryReading.c -Wall -fPIC -Werror -fvisibility=hidden -DMK_TOOLS_BUILD -DLEGATO_EMBEDDED -I ./_build_batteryReading/wp77xx -I/home/mangoh/legato_framework/legato/interfaces -I/home/mangoh/legato_framework/legato/framework/include -I/home/mangoh/mangOH/samples/tutorials/mangOH_Red/i2c/BatteryChargerReading -I./_build_batteryReading/wp77xx/component/703af1bcdfe6b9325199aaa5cfacdbc0/src -DLE_COMPONENT_NAME=batteryReadingComponent -DLE_LOG_SESSION=batteryReadingComponent_LogSession -DLE_LOG_LEVEL_FILTER_PTR=batteryReadingComponent_LogLevelFilterPtr "-DCOMPONENT_INIT=LE_CI_LINKAGE LE_SHARED void batteryReadingComponent_COMPONENT_INIT()"
/home/mangoh/mangOH/samples/tutorials/mangOH_Red/i2c/BatteryChargerReading/batteryReadingComponent/batteryReading.c:14:32: fatal error: linux/i2c-dev-user.h: No such file or directory
_ #include <linux/i2c-dev-user.h>_
_ ^_
compilation terminated.
[3/9] Compiling C source
ninja: build stopped: subcommand failed.

It seems that this is file is missing : linux/i2c-dev-user.h

Can you help me? I’m new Linux and legato programming I would appreciate any help.

Thank you !


#2

i2c-utils was removed from the root filesystem and toolchain for the wp76/77 a while back. You can try changing to #include <linux/i2c-dev.h> and see if that works. If it doesn’t, you can look at the workaround I put in for the same issue in GpioExpander.


#3

Okay thank you for the answer.

When I change the includes with the one you gave me the i2c-file is found.
But the function used in the batteryReadingCharger are not the same so they are not declared and I can t build.

I will try your workaround for the GPIOExpander.


#4

I tried to include the <linux/i2c-dev.h> and I added the modifications you made for the GPIOExpander.

I can make the app and I can update it on the WP7702 but when I want to start it there is a problem :slight_smile:

There was an error. Application ‘batteryReading’ could not be started.
Check the system log for error messages.

How can I check the log for error messages?

Thanks to help a beginner !!!


#5

Do logread -f & to launch the logread program in follow mode in the background so that you will see new log messages. Then run app start batteryReading to launch the app. The log should specify why the app couldn’t be started.


#6

Okay thank you for your reply.

Here is the log .

Jan 6 00:24:21 swi-mdm9x28 user.warn Legato: -WRN- | supervisor[644]/supervisor T=main | proc.c GetWatchdogAction() 359 | batteryReading watchdogAction ‘’ in proc section
Jan 6 00:24:21 swi-mdm9x28 user.warn Legato: -WRN- | supervisor[644]/supervisor T=main | proc.c GetWatchdogAction() 359 | batteryReading watchdogAction ‘’ in proc section
Jan 6 00:24:21 swi-mdm9x28 user.err Legato: =ERR= | supervisor[644]/supervisor T=main | app.c GetDevID() 645 | Could not get file info for ‘/dev/i2c-0’. No such file or directory.
Jan 6 00:24:21 swi-mdm9x28 user.err Legato: =ERR= | supervisor[644]/supervisor T=main | app.c SetCfgDevicePermissions() 755 | Failed to set permissions (rw) for app ‘batteryReading’ on device ‘/dev/i2c-0’.
Jan 6 00:24:21 swi-mdm9x28 user.info Legato: INFO | supervisor[644]/supervisor T=main | supervisor.c SigChildHandler() 781 | Reaping unconfigured child process 4243.

It seems that I can’t acces the file of i2c-0.

Any idea how to fix it?

Thank you.


#7

I installed the package i2c-tool and now I can scan the i2c bus with the command : sudo i2cdetect -y 0

But I can’t find any slave …

 _0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f_

_00: – -- – -- – -- – -- – -- – -- – _
_10: – -- – -- – -- – -- – -- – -- – -- – -- _
_20: – -- – -- – -- – -- – -- – -- – -- – -- _
_30: – -- – -- – -- – -- – -- – -- – -- – -- _
_40: – -- – -- – -- – -- – -- – -- – -- – -- _
_50: – -- – -- – -- – -- – -- – -- – -- – -- _
_60: – -- – -- – -- – -- – -- – -- – -- – -- _
70: – -- – -- – -- – --

The app can’t run and I still have this problem of non existing folder : dev/i2c-0’. No such file or directory.

Any one can help me?

Thank you


#8

Hi @Fabian,

If you’re using a wp76 or wp77, then the first i2c bus is actually 4. So try to execute i2cdetect -y -r 4.

As a side note, if you want to embed a chunk of console output in your post, you can wrap the multi-line content in triple backticks.


#9

Hi dfrey,

Thanks to you I’m Learning a lot but I can’t open the 4th bus. I only have the bus 0.

mangoh@mangoh-vm:~$ i2cdetect -l
i2c-0	unknown   	SMBus PIIX4 adapter at 4100     	N/A
mangoh@mangoh-vm:~$ i2cdetect -y -r 4
Error: Could not open file `/dev/i2c-4' or `/dev/i2c/4': No such file or directory