# Problem I2C file is missing

**URL:** https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487
**Category:** mangOH Red
**Created:** [May 29, 2018, 10:07am UTC](https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487 "2018-05-29T10:07:53Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Fabian](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/fabian/32/472_2.png) [@Fabian](https://mangoh.discourse.group/u/Fabian)
#### Post date: [May 29, 2018, 10:07am UTC](https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487/1 "2018-05-29T10:07:53Z")

</div>

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 !

---

<div class="post-metadata">

### Author: ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)
#### Post date: [May 29, 2018, 4:45pm UTC](https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487/2 "2018-05-29T16:45:03Z")

</div>

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](https://github.com/mangOH/GpioExpander/commit/eddfe628188b60efb32a988dfac9c62f50ef6206).

---

<div class="post-metadata">

### Author: ![Fabian](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/fabian/32/472_2.png) [@Fabian](https://mangoh.discourse.group/u/Fabian)
#### Post date: [May 30, 2018, 8:40am UTC](https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487/3 "2018-05-30T08:40:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Fabian](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/fabian/32/472_2.png) [@Fabian](https://mangoh.discourse.group/u/Fabian)
#### Post date: [May 31, 2018, 2:16pm UTC](https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487/4 "2018-05-31T14:16:50Z")

</div>

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 🙂

_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 !!!

---

<div class="post-metadata">

### Author: ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)
#### Post date: [May 31, 2018, 5:00pm UTC](https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487/5 "2018-05-31T17:00:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Fabian](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/fabian/32/472_2.png) [@Fabian](https://mangoh.discourse.group/u/Fabian)
#### Post date: [June 1, 2018, 7:47am UTC](https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487/6 "2018-06-01T07:47:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Fabian](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/fabian/32/472_2.png) [@Fabian](https://mangoh.discourse.group/u/Fabian)
#### Post date: [June 4, 2018, 9:29am UTC](https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487/7 "2018-06-04T09:29:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)
#### Post date: [June 4, 2018, 9:34am UTC](https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487/8 "2018-06-04T09:34:18Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Fabian](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/fabian/32/472_2.png) [@Fabian](https://mangoh.discourse.group/u/Fabian)
#### Post date: [June 4, 2018, 11:52am UTC](https://mangoh.discourse.group/t/problem-i2c-file-is-missing/1487/9 "2018-06-04T11:52:47Z")

</div>

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
```
