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
10 hours ago, MarshallMCH said:

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

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

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

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
9 minutes ago, MarshallMCH said:

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

Then, maybe I missed something ... Let me try myself on my board, and I will get back to you ...

Posted
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

 

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
9 minutes ago, MarshallMCH said:

Hm, after I run:

What was the value returned by the reading ?

 

9 minutes ago, MarshallMCH said:

My board freezes,

Strange, with my board, it didn't freeze, and I was even able to toggle green power led by toggling its PL10 bit between 0x0080 and 0x0480 ...

 

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
6 minutes ago, MarshallMCH said:

Here's what I get:

Since you got 0x784, to avoid any other change on other pins other than PL2, then the write value should be toggled between 0x780 and 0x784, only the third bit toggling ...

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

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

 

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

 

Posted
18 hours ago, MarshallMCH said:

Linux 3.4.113-sun8i

That is Legacy image... Is there any reason you using this ?

Maybe you can try with Mainline NEXT or DEV images ...

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines