Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Reboot devices connected to OTG by cutting power to OTG?

Featured Replies

I'm powering a small PCB via the OTG port on my OPI PC Plus, however sometimes I need to be able to reboot the device.  It is possible to cut power to the OTG port momentarily to force a reboot?  I've seen mention of PL2 GPIO, but it is unclear to me how this should be setup.  I've also looked at uhubctl, but that didn't work.  Thoughts? 

32 minutes ago, MarshallMCH said:

I'm not familiar with devmem2.

"devmem2" is a small piece of code used to access kernel memory directly from userspace. You can find a copy of it here : https://bootlin.com/pub/mirror/devmem2.c

Compile it (using "gcc -o devmem2 devmem2.c" ) and give first a try by reading the PL_DAT register which is at the 0x01F02C10 address :

./devmem2 1F02C10 h

Then, since PL2 is the third bit of that PL_DAT register, you can write into it, this bring the PL2 to HIGH :

./devmem2 1F02C10 h 0004

EDIT : Almost forgot, if it is already HIGH during reading, then to bring it LOW by writing 0000 instead of 0004.

  • Author

Hi Martin, here's what I see when running those commands:

 

root@device:~# ./devmem2 1F02C10 h
/dev/mem opened.
Memory mapped at address 0xb6f52000.
Value at address 0x1 (0xb6f52001): 0x61A

root@device:~# ./devmem2 1F02C10 h 0000
/dev/mem opened.
Memory mapped at address 0xb6f2b000.
Value at address 0x1 (0xb6f2b001): 0x61A
Written 0x0; readback 0x0

root@device:~# ./devmem2 1F02C10 h 0004
/dev/mem opened.
Memory mapped at address 0xb6fce000.
Value at address 0x1 (0xb6fce001): 0x0
Written 0x4; readback 0x4

However, I do not see my PCB turn off after running those commands. 

23 minutes ago, MarshallMCH said:

Hi Martin, here's what I see when running those commands:

Ok ! I figured out : my bad, it needs HEX prefix "0x" :

./devmem2 0x1F02C10 h

This should probably read 0x0480 or 0x0484 ...

Then, let's do the opposite level, if 0x0480, then write 0x0484, or the reverse :

./devmem2 0x1F02C10 h 0x0484

 

  • Author

Hm, after I run:

./devmem2 0x1F02C10 h

 

then I run either:

 

 

./devmem2 0x1F02C10 h 0x0484

or:

./devmem2 0x1F02C10 h 0x0484

My board freezes, and I need to do a hard powercycle. 

  • Author

Here's what I get:

 

root@device:~# ./devmem2 0x1F02C10 h
/dev/mem opened.
Memory mapped at address 0xb6fe5000.
Value at address 0x1F02C10 (0xb6fe5c10): 0x784

 

  • Author

Hi Martin, it does not hang, but still does not turn off the OTG port, unfortunately:

 

root@device:~# ./devmem2 0x1F02C10 h
/dev/mem opened.
Memory mapped at address 0xb6f70000.
Value at address 0x1F02C10 (0xb6f70c10): 0x784

root@device:~# ./devmem2 0x1F02C10 h 0x0780
/dev/mem opened.
Memory mapped at address 0xb6fb7000.
Value at address 0x1F02C10 (0xb6fb7c10): 0x784
Written 0x780; readback 0x780

root@device:~# ./devmem2 0x1F02C10 h 0x0784
/dev/mem opened.
Memory mapped at address 0xb6f02000.
Value at address 0x1F02C10 (0xb6f02c10): 0x780
Written 0x784; readback 0x784

 

6 minutes ago, MarshallMCH said:

but still does not turn off the OTG port, unfortunately

Can you provide output of "cat /sys/kernel/debug/gpio" ?

And maybe also output "./devmem2 0x1F02C04 w" ...

 

When you say OTG port, you are talking about MicroUSB, right ?

If not and you mean normal USB, then it is USB1-DRVVBUS that you need to switch, therefore PL3 instead of PL2, which mean the toggling value would be 0x780 and 0x788 ...

  • Author

Here are the outputs:

 

cat /sys/kernel/debug/gpio
GPIOs 0-383, platform/sunxi-pinctrl, sunxi-pinctrl:
 gpio-15  (red_led             ) out lo
 gpio-16  (?                   ) out hi
 gpio-166 (cd                  ) in  hi
 gpio-354 (?                   ) out lo
 gpio-362 (green_led           ) out hi
./devmem2 0x1F02C04 w
/dev/mem opened.
Memory mapped at address 0xb6f1c000.
Illegal data type '▒'.

Yes, I am talking about the MicroUSB port.  Thanks!

12 minutes ago, MarshallMCH said:

gpio-354 (? ) out lo

Which kernel/image are you using ?

Because the output should be :

gpio-354 (                    |usb0-vbus           ) out lo

Could you reboot your OS and do again the "cat /sys/kernel/debug/gpio" right after login to see if gpio-354 is still shown the way you provided ?

 

You can also try with Armbian Mainline-DEV 5.1.y image, it is what I'm using ...

 

  • Author

Here is the output of uname -a

Linux 3.4.113-sun8i #10 SMP PREEMPT Thu Feb 23 19:55:00 CET 2017 armv7l GNU/Linux

Here's the output after a fresh reboot:

 

cat /sys/kernel/debug/gpio
GPIOs 0-383, platform/sunxi-pinctrl, sunxi-pinctrl:
 gpio-15  (red_led             ) out lo
 gpio-16  (?                   ) out hi
 gpio-166 (cd                  ) in  hi
 gpio-354 (?                   ) out hi
 gpio-362 (green_led           ) out hi

 

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.