Jump to content

Recommended Posts

Posted

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? 

Posted
  On 6/5/2019 at 2:12 AM, MarshallMCH said:

I've seen mention of PL2 GPIO, but it is unclear to me how this should be setup.

Expand  

You can try to bring PL2 to LOW level using "devmem2" directly on pincontroller register, and then bringing it back to HIGH.

Posted
  On 6/5/2019 at 1:49 PM, MarshallMCH said:

I'm not familiar with devmem2.

Expand  

"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.

Posted

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. 

Posted
  On 6/5/2019 at 2:33 PM, MarshallMCH said:

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

Expand  

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

 

Posted

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. 

Posted

Here's what I get:

 

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

 

Posted

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

 

Posted
  On 6/5/2019 at 5:17 PM, MarshallMCH said:

but still does not turn off the OTG port, unfortunately

Expand  

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

Posted

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!

Posted
  On 6/5/2019 at 5:45 PM, MarshallMCH said:

gpio-354 (? ) out lo

Expand  

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

 

Posted

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.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines