Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
1,948 Views

Regarding the soft reset of i2c

Hai everyone,

I'm using latest yocto image with 3.10.98 kernel version.I have integrated 4 sensors which uses the i2c pins on intel arduino expansion board individually.But if I'm connecting the four sensors at the same time , I'm not able to detect all the device addresses at the same time.So,I want to use the soft reset on the intel edison board for I2C so that I can find all the sensor device addresses at the same time without any disturbance.But I'm unable to softreset the intel edison board for I2C.The other is to kill the process ID but that too seems not perfect for all the sensor integration and device detection.

Can you please find me the way to detect all the sensors all the time by using soft reset or any other alternative.I have already gone through the below links.Hope the answer would be helpful and quick.Thanks in advance.

http://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line How do you reset a USB device from the command line? - Ask Ubuntu

Thanks and Regards,

Radhika.

18 Replies
Highlighted
Community Manager
14 Views

Hello Radhika.k,

 

 

How are you powering the sensors? You mention that you are not able to find the I2C addresses of every sensor when connected at the same time, right? If so, are you able to find the addresses of some of them? If that's the case, this might indicate that some sensors are not getting enough power to work.

 

 

So if you are using the Edison to power the sensors, I'd suggest you to power them with an external power supply to avoid this issue.

 

 

Also, you mention that you want to soft reset Edison's I2C but on the thread you posted soft reset means rebooting the board through software. What do you mean by soft reset I2C?

 

 

-Peter.
0 Kudos
Highlighted
New Contributor I
14 Views

Hello Peter,

Thanks for the reply.Yes,I'm using external power supply only.I'm able to find the addresses of few of them.As far as my observation ,as I'm using the same I2C for all the sensors,the busses are busy all the time and not giving the device addresses of all the sensors at the same time.So I want to soft reset the busses of I2C and make the busses for I2C free before doing the other operation.

Can I know how can I soft reset i.e, how can I make the busses not busy before doing other operation on the board.???

Thanks and Regards,

Radhika.

0 Kudos
Highlighted
Community Manager
14 Views

Could you please try the following test? Connect the I2C sensors one by one and test them individually. What happens? Are you able to interact with each of them separately? Or do you have issues with some of them?

 

 

Also, please send us a picture of how you are currently connecting the sensors and how they are being powered.

 

 

-Peter.
0 Kudos
Highlighted
New Contributor I
14 Views

Hi Peter,

Yes,I can able to find the device addresses if I connect them individually.The problem is that if we want to simultaneously run two or more tasks then the busses are busy .so I want to soft reset the edison whenever they are busy.Not only for the I2C but also for the other operations on edison.Is there any code or commands to soft reset the intel edison board.??

Thanks and Regards,

Radhika.

0 Kudos
Highlighted
Community Manager
14 Views

In case you would like to perform a soft reset on Edison you could use the command reboot. Nevertheless, this would not reset the I2C bus but instead it would restart the whole OS. The I2C bus is designed to work several with devices connected at the same time and there is no way to reset it. That's why I believe there might be something odd with how the sensors are being powered. So, could you please send us a picture of how they are being powered?

 

 

If you definitely need to clear the bus you would have to send null values from the master device, in this case the Edison, creating something similar to a soft reset.

 

 

-Peter.
0 Kudos
Highlighted
New Contributor I
14 Views

What is exactly the type of the four I2C sensors? I agree with Peter: a schematics would help greatly.

Istvan

Highlighted
Community Manager
14 Views

Hello Radhika.k,

 

 

Do you have any update on this?

 

 

-Peter.
0 Kudos
Highlighted
New Contributor I
14 Views

Hi all,

I would like to know about soft reset the intel edison (arduino expansion board),I know reboot(hard reset).My idea is to reboot only some services or processes not the whole edison board.

we are using different I2C sensors and we want to reboot only the i2c sensors without rebooting the whole edison board.This is because when we are running the I2C sensors all at a time by using external power supply only,when we are disconnecting or adding some of the sensors they are not responding immediately i.e,the devices addresses are not detecting according to the device,when we reboot the board they can be detected .But we don't want to reboot frequently as we are using some network configuration files and they will be lost if we reboot by the hardware.

we tried to kill the processes after the process is completed but I think killing the process is not the right option without rebooting.

Here the sensors are optional,but for any other operation how can we reboot only some processes without rebooting the whole edison board???Hope the answer would be useful.Any or every reply is appreciated.

Thanks and Regards,

Radhika.

0 Kudos
Highlighted
Community Manager
14 Views

If you have a service that is in charge of the I2C program you can indeed reset the service but if the service only starts a script that handles the I2C part then resetting the service won't be enough. I mean, if you reset the service with systemctl restart YOUR_SERVICE.service, the service will be indeed reset but the script won't be affected instead it could cause some issues as the service would try to start the I2C script again. So, you will probably have to kill the process in order to reset the service.

 

 

But as I mentioned, if you have set a system service that handles I2C, you should be able to reset it with:

 

 

systemctl restart YOUR_SERVICE.service

 

 

I hope this helps.

 

-Peter.
0 Kudos
Highlighted
New Contributor I
14 Views

Hi Peter,

Thanks for the reply,I have my script file in /home/root/demo/edison_script.sh and created the service in ls /lib/systemd/system and my service file consists of

[Unit]

Description=edison_script.service

After=network.target

[Service]

ExecStart=/home/root/demo/edison_script.sh

Restart=always

[Install]

WantedBy=multi-user.target

I have tried the way to kill the process by the command sudo kill -9 `ps | grep edison_script.sh | awk '{print $1}'` and the process is killed after that restarting the service using

systemctl daemon-reload

systemctl restart edison_script.service

systemctl status edison_script.service

but the status of my service is failed and is inactive(dead) although it is running in the other terminal.

The edison_script file consists of

# ! /bin/sh

echo "I2C script"

echo 28 > /sys/class/gpio/export|echo 27 > /sys/class/gpio/export|echo 204 > /sys/class/gpio/export| echo 205 > /sys/class/gpio/export |

echo 236 > /sys/class/gpio/export |echo 237 > /sys/class/gpio/export|echo 14 > /sys/class/gpio/export |echo 165 > /sys/class/gpio/export| echo 212 > /sys/class/gpio/export|echo 213 > /sys/class/gpio/export |echo 214 > /sys/class/gpio/export |

echo low > /sys/class/gpio/gpio214/direction|echo low > /sys/class/gpio/gpio204/direction | echo low > /sys/class/gpio/gpio205/direction |

echo in > /sys/class/gpio/gpio14/direction|echo in > /sys/class/gpio/gpio165/direction|echo low > /sys/class/gpio/gpio236/direction| echo low > /sys/class/gpio/gpio237/direction|echo in > /sys/class/gpio/gpio212/direction |echo in > /sys/class/gpio/gpio213/direction|

echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pinmux |echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pinmux|

echo high > /sys/class/gpio/gpio214/direction

i2cdetect -r 6

I'm not knowing how to approach to my problem.Is there any way to approach to soft reset.Are there any changes in the service file in system.??Or should I go for another Service in /lib/systemd/system?If I should go to another service ..which service for I2C should be restarted.??Can I configure GPIO pins to restart the process??(not only for I2C)

Please let me know the process to soft reset the edison only for some processes without effecting the other files in edison.Hoping the positive result from you.

Thanks and Regards,

Radhika.

0 Kudos
Highlighted
Community Manager
14 Views

Hi Radhika.k,

 

 

What do you mean by "...it is running in the other terminal…"? In "...but the status of my service is failed and is inactive(dead) although it is running in the other terminal.…"

 

 

-Peter.
0 Kudos
Highlighted
New Contributor I
14 Views

Hi Peter,

The process is getting killed after that if I follow the procedure of

systemctl daemon-reload

systemctl restart edison_script.service

systemctl status edison_script.service

I'm getting the below error

The Service code and the script code is given above.If there are any modifications please let me know.Any help or every help is appreciated.

Thanks and Regards,

Radhika.

0 Kudos
Highlighted
Community Manager
14 Views

Could you please post your script here (and anything else needed to replicate the issue)? I would like to check if I'm able to replicate the behavior.

 

 

-Peter.
0 Kudos
Highlighted
New Contributor I
14 Views

Hi Peter,

Here are my service file and script file.

My service file consists of

[Unit]

Description=edison_script.service

After=network.target

[Service]

ExecStart=/home/root/demo/edison_script.sh

Restart=always

[Install]

WantedBy=multi-user.target

My edison_script.sh file has

# ! /bin/sh

echo "I2C script"

echo 28 > /sys/class/gpio/export|echo 27 > /sys/class/gpio/export|echo 204 > /sys/class/gpio/export| echo 205 > /sys/class/gpio/export |

echo 236 > /sys/class/gpio/export |echo 237 > /sys/class/gpio/export|echo 14 > /sys/class/gpio/export |echo 165 > /sys/class/gpio/export| echo 212 > /sys/class/gpio/export|echo 213 > /sys/class/gpio/export |echo 214 > /sys/class/gpio/export |

echo low > /sys/class/gpio/gpio214/direction|echo low > /sys/class/gpio/gpio204/direction | echo low > /sys/class/gpio/gpio205/direction |

echo in > /sys/class/gpio/gpio14/direction|echo in > /sys/class/gpio/gpio165/direction|echo low > /sys/class/gpio/gpio236/direction| echo low > /sys/class/gpio/gpio237/direction|echo in > /sys/class/gpio/gpio212/direction |echo in > /sys/class/gpio/gpio213/direction|

echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pinmux |echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pinmux|

echo high > /sys/class/gpio/gpio214/direction

i2cdetect -r 6

Thanks and Regards,

Radhika

0 Kudos
Highlighted
Community Manager
14 Views

I just tested the script and the service you provided and unfortunately I'm not able to make it work. The service never starts, it throws a fail every time. I tried simply copying and pasting the information you provided and I tested with a little modification that I will post below but it fails every time. Is there any other step I have to take before enabling the service to make this work?

 

 

This is the modification I did (to edison_script.sh):

 

 

# ! /bin/sh

 

echo "I2C script"

 

echo 28 > /sys/class/gpio/export

 

echo 27 > /sys/class/gpio/export

 

echo 204 > /sys/class/gpio/export

 

echo 205 > /sys/class/gpio/export

 

echo 236 > /sys/class/gpio/export

 

echo 237 > /sys/class/gpio/export

 

echo 14 > /sys/class/gpio/export

 

echo 165 > /sys/class/gpio/export

 

echo 212 > /sys/class/gpio/export

 

echo 213 > /sys/class/gpio/export

 

echo 214 > /sys/class/gpio/export

 

echo low > /sys/class/gpio/gpio214/direction

 

echo low > /sys/class/gpio/gpio204/direction

 

echo low > /sys/class/gpio/gpio205/direction

 

echo in > /sys/class/gpio/gpio14/direction

 

echo in > /sys/class/gpio/gpio165/direction

 

echo low > /sys/class/gpio/gpio236/direction

 

echo low > /sys/class/gpio/gpio237/direction

 

echo in > /sys/class/gpio/gpio212/direction

 

echo in > /sys/class/gpio/gpio213/direction

 

echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pinmux

 

echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pinmux

 

echo high > /sys/class/gpio/gpio214/direction

 

sleep 1

 

i2cdetect -r 6

 

 

The script you provided does seem to work, so there might be a detail on the service.

 

-Peter.
0 Kudos
Highlighted
New Contributor I
14 Views

Hi Peter,

Especially for I2C ,I'm able to soft reset but the problem is I want to soft reset the edison board without rebooting the whole edison board.If I'm resetting by hardware,the whole edison board is rebooting,I don't want that rebooting.

The rebooting should be such that only particular ports should be rebooted not the whole edison board.Can you please help me in solving this issue.

Thanks in advance,Please do needful.

Thanks and Regards,

Radhika

0 Kudos
Highlighted
New Contributor I
14 Views

Hi Peter,

I soft reset for I2C is done by 'unexport' the gpio pins written in the script file,not by using the service. Can I know how can I reset only particular ports and processes ,not by killing.??

Waiting for the reply....Thank you in advance.

Kind Regards,

Radhika.

0 Kudos
Highlighted
Community Manager
14 Views

Unfortunately, I believe there's no way to reset the bus without killing the process. Even unexporting the GPIOs would make the process crash as it wouldn't find the I2C device when it requires it.

 

 

So, I believe the best option you would have is to set a service that kills and resets the I2C process whenever you need it.

 

 

-Peter.
0 Kudos