I am using a khadas vim1.4 with kernel 5.16.0-rc2. I would like to turn the power to my USB device off so that I can hard reset the device. How can this be done?
In another post I saw that it should be possible to turn HDMIPWR_EN off, but I am unable to figure out how this can be doen? Is there a specific command for this?
Have tried controlling the GPIOH_3 but it’s in use so I can’t control the GPIO bit.
Thanks in advance
USB power control will be used by many devices at the same time, not only USB. I don’t recommend you to do this, what is the reason you need the hardware to reboot the USB?
I understand your concern. We are using a 3G dongle and after some hours it gets diconnected. The only way to get my connection back is to reset the dongle (by removing the power). I have tried unbinding the usb drivers, restarting the network services etc… but that doesn’t do the trick.
So for a last resort I would like the ability to remove the power to the dongle so that it gets a hard reboot. Or if you know of another way to get my connection back that would also be good.
@Dieter There is no other way to reset the USB here. Maybe you can modify the settings of your dongle?
Haven’t seen any option on the dongle that could resolve this issue.
If I look at the schematic of the vim1 I notice there is a mosfet between the power and the power to the USB. Couldn’t the power to the USB be switched off by using the HDMI_5V_EN? GPIOH3?
I know you don’t recommend it, but how could I toggle the HDMI_5V_EN?
@Dieter Controlling this switch can reload the USB, but this is a very dangerous operation and I’m not sure if it will affect other functions.
@Frank Ok, it’s at our own responsibility. I have searched but haven’t been able to find how I can switch this switch. How can I do this?
You can try with this docs to control GPIOH_3
I have tried that but I always get the error "-bash: echo: write error: Device or resource busy
" when I try todo the export. Even when I have unbind my usb drivers.
What is causing this error?
@Dieter I will find time to test it .
I can use it.
root@Khadas:/home/khadas# cat /sys/kernel/debug/pinctrl/pinctrl\@4b0/gpio-ranges
GPIO ranges handled:
0: periphs-banks GPIOS [401 - 500] PINS [0 - 99]
root@Khadas:/home/khadas# cat /sys/kernel/debug/pinctrl/pinctrl\@4b0/pins | grep GPIOH_3
pin 19 (GPIOH_3) pinctrl@4b0
root@Khadas:/home/khadas# echo 420 > /sys/class/gpio/export
I am still getting the error “write error: Device or resource busy”. What setting could cause this?
@Dieter Did you modify the code? I am using the latest firmware, which version are you using?
As far as I am aware off I didn’t change any code that could cause this. I started with the ubuntu 20.04 image and did an upgrade with apt.
What change in code could result in this?
Like I meantioned earlier, I was working with ubuntu 20.04. Isn’t this also an official image? http://dl.khadas.com/firmware/VIM1/Ubuntu/SD_USB/vim1-ubuntu-20.04-server-linux-5.18-fenix-1.1.1-220725.img.xz
I have tried it on ubuntu 18.04 and there I can control the GPIOH_3. It switches the power off when I place the direction to input and not when I change the value. Am I missing something?
Why isn’t this possible on the other release?
@Dieter I haven’t tested whether the firmware of the mainline can run WiringPi. Generally speaking, other adaptations are required for the mainline to be used.I can find time to test the main line, if you want to use the mainline
@Frank if you have time it would be interesting to know how to make this work on the mainline.
@Dieter If you want to do it my yourself, you can follow this commit
This is fixup vim3 mainline wiringPi, or you can wait for me.
@Frank Thank you for the feedback. I will try this when I have time. Hopefully this also works for the VIM1