Trying to open a file via fopen getting error : no such file or directory

Hello Toradex Community,

First of all concerning my HW, I am using a Yavia V1.0A as a carrier board and a Verdin iMX8MM Q 2GB WB IT V1.1E as a module.
Here is the thing, I am writing a C program on VisualStudioCode because I want to retrieve informations from the module config file such as serial number, version, temperature, etc.
When I use a “fopen()” inside my program, some of my files don’t want to open and I’m getting a “No such file or directory” error. I have double checked the path of the files and I can see them inside my module directrory.
Has anyone ever encountered this issue ?
Thank you for your help,

Regards,

Hi @Muzzy ,

are you using the Linux BSP or Torizon? And which version of the OS are you using?

Best Regards
Kevin

Hello @kevin.tx ,

Thank you for your support,
I am currently using TorizonCore 6.1.0-devel image on my HW.

Best regards,

Hi @Muzzy ,

Is it possible that your running your code inside in a container, while the files you want to open are not shared in the container?

Where are your files located?

Can you share some logs of your errors?

Best Regards
Kevin

Hello @kevin.tx ,
Sorry for the delay,
The file I want to open is located here :
/sys/firmware/devicetree/base/serial-number.
And I have the following error :
image

For example when I want to open other files like this one located here: /sys/devices/virtual/thermal/thermal_zone0/temp
I have no problem and i can get the Temperature right :
image

Thank you for helping me,

Best regards,

Hi @Muzzy ,

I just checked on my end. If you are inside a container for example chromium or as I understand your application. Then /sys/devices/virtual/thermal/thermal_zone0/temp is readable but /sys/firmware/devicetree/base/serial-number is not.

If I am directly on the device (and not inside a container) then /sys/firmware/devicetree/base/serial-number is there and I am able to read it.

How do you start your application? Can you send me the docker file that you use?

Best Regards
Kevin

Hello @kevin.tx ,

Thank you for your support,
I wasn’t located into the container and I was searching for the files directly on my device.
Thank you again for your help,

Best regards,

Hi @Muzzy ,

Glad that we were to solve that.

Thanks for marking the solution.

Have a great day!

Best Regards
Kevin