How to enable USB power with u-boot?

379 views
Skip to first unread message

Sergey Manucharian

unread,
Jun 30, 2017, 2:21:50 PM6/30/17
to BeagleBoard
I'd like to use uboot's USB subsystem to boot off a USB flash drive.
However, the USB power is disabled at boot/reset. When I provide external power everything works as expected,

So, how to enable USB power at CPU power-up/reset or with u-boot itself?
Thanks for advises!

Robert Nelson

unread,
Jun 30, 2017, 3:16:08 PM6/30/17
to Beagle Board, Sergey Manucharian
Once you boot into "U-Boot" from the microSD/eMMC, load the files from
the USB flash drive and jump into that rootfs..

Regards,

--
Robert Nelson
https://rcn-ee.com/

Sergey Manucharian

unread,
Jun 30, 2017, 3:19:54 PM6/30/17
to BeagleBoard, s...@ara-ler.com
That's exactly what I do, it works fine, the problem is that the USB has no power at that time, I have to use an external power supply.

Sergey Manucharian

unread,
Jun 30, 2017, 10:50:24 PM6/30/17
to BeagleBoard, s...@ara-ler.com
From this thread https://e2e.ti.com/support/arm/sitara_arm/f/791/t/270060:
Modifying bit 0 of 8 bit register address 0x47401C60 it switch on/off USB1_DRVVBUS pin

Is it possible to do from u-boot environment or I'll need to modify u-boot source code?

William Hermans

unread,
Jun 30, 2017, 11:46:27 PM6/30/17
to beagl...@googlegroups.com

On Fri, Jun 30, 2017 at 7:50 PM, Sergey Manucharian <s...@ara-ler.com> wrote:
From this thread https://e2e.ti.com/support/arm/sitara_arm/f/791/t/270060:
Modifying bit 0 of 8 bit register address 0x47401C60 it switch on/off USB1_DRVVBUS pin

But I don't think you have to do all that. Read my post from nearly 4 years ago here: http://www.embeddedhobbyist.com/2013/07/beaglebone-black-usb-boot/

Scroll down where I talk about uEnv.txt. "usb start" should initiate power, and the driver. Note that I'm calling it first before loading files over USB. If you require in depth details, you'll have to read through the source code. But I might be able to answer *some* questions. I'm by no means a uboot expert.

Sergey Manucharian

unread,
Jul 1, 2017, 12:04:56 AM7/1/17
to BeagleBoard
Oh, thanks, William, I was inspired doing this by your post!

The problem is that "usb start" starts u-boot's USB subsystem, it (probably) has nothing to do with the CPU.
You explicitly mentioned that used a USB HDD with external power supply, but I'm trying to boot off a USB flash drive. The CPU doesn't provide USB power at early stage. If I provide power from an external source, everything works fine.

The latest u-boot supports loading overlays, I'm not sure whether it's possible to load an overlays with the correct configuration of that pin and then load kernel and stuff from USB flash drive.

William Hermans

unread,
Jul 1, 2017, 12:59:37 AM7/1/17
to beagl...@googlegroups.com
On Fri, Jun 30, 2017 at 9:04 PM, Sergey Manucharian <s...@ara-ler.com> wrote:
Oh, thanks, William, I was inspired doing this by your post!
 
Oh, cool ! Glad someone reads my stuff now and then ;)

The problem is that "usb start" starts u-boot's USB subsystem, it (probably) has nothing to do with the CPU.
You explicitly mentioned that used a USB HDD with external power supply, but I'm trying to boot off a USB flash drive. The CPU doesn't provide USB power at early stage. If I provide power from an external source, everything works fine.

Right so in that case, I explicitly mentioned using external power for a hard drive. As many hard drives need at least 1-3A when spinning up, then typically for a 3.5" HDD 1A after that. I just assumed that flash stick would / should work, because most of them are pulling less than 500mA, or is what I'd guess at any rate. However, you tested it seems, where I did not.

The latest u-boot supports loading overlays, I'm not sure whether it's possible to load an overlays with the correct configuration of that pin and then load kernel and stuff from USB flash drive.

So I do not know all the specifics, and quite honestly Robert would probably know better than I. But *maybe* there is a way you can create a new overlay, based on the board file, to get the USB power up. A lot of overlays are already set in the board file by default, or more specifically references to hardware are in the board file, and in some cases all you need to do is write an overlay that targets the hardware in question, and provide status="okay". With that said. . . I'm not 100% sure how soon the overlays get loaded. As in if they're actually loaded in uboot, or if they're somehow loaded just prior, or simotaneously when the kernel is loaded via cmdline options.

It's a really interesting problem to solve, one that I'd like to figure out myself - even.  If only I were not already busy with a ton of things at work :/ Which, yeah, I'll probably be spending part of my weekend doing too . . .

Robert Nelson

unread,
Jul 1, 2017, 10:50:01 AM7/1/17
to Beagle Board
On Fri, Jun 30, 2017 at 11:04 PM, Sergey Manucharian <s...@ara-ler.com> wrote:
> Oh, thanks, William, I was inspired doing this by your post!
>
> The problem is that "usb start" starts u-boot's USB subsystem, it (probably)
> has nothing to do with the CPU.
> You explicitly mentioned that used a USB HDD with external power supply, but
> I'm trying to boot off a USB flash drive. The CPU doesn't provide USB power
> at early stage. If I provide power from an external source, everything works
> fine.
>
> The latest u-boot supports loading overlays, I'm not sure whether it's
> possible to load an overlays with the correct configuration of that pin and
> then load kernel and stuff from USB flash drive.

Why not?

zImage:

"loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}\0" \

https://github.com/eewiki/u-boot-patches/blob/master/v2017.07-rc2/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch#L507

overlay:

"load ${devtype} ${bootpart} ${rdaddr} ${uboot_overlay}; " \

https://github.com/eewiki/u-boot-patches/blob/master/v2017.07-rc2/0002-U-Boot-BeagleBone-Cape-Manager.patch#L800

both use the devtype & bootpart references.. Thus if the kernel/dtb
are on the same partition of the usb flash drive as the overlays,
everything just works..

But, you'll need to add the usb options here:

https://github.com/eewiki/u-boot-patches/blob/master/v2017.07-rc2/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch#L277

Sergey Manucharian

unread,
Jul 1, 2017, 11:02:44 AM7/1/17
to BeagleBoard
Thanks, Robert!

However, those "loads" just copy kernel/dtb into RAM for subsequent use, they are not going to change the CPU configuration at u-boot level. They cannot turn on the USB power until the control is passed to the kernel. That way works: I load kernel and dtbs from eMMC, but tell them "root=/dev/sda1 rootwait" (i.e. USB drive), so the kernel enables the USB power, then mount the USB stick. With this approach you cannot load a kernel from USB drive.

Robert Nelson

unread,
Jul 1, 2017, 11:19:42 AM7/1/17
to Beagle Board
Then that's a u-boot bug, usb should be on after USB start.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/8fe903c1-9d73-42b5-888a-9b49653aaa56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sergey Manucharian

unread,
Jul 1, 2017, 2:24:23 PM7/1/17
to BeagleBoard
Most likely you're right assuming that u-boot must be aware of what particular CPU it's dealing with (otherwise it's not possible since there is no standard API for such things as USB power).

Sergey Manucharian

unread,
Jul 1, 2017, 3:41:59 PM7/1/17
to BeagleBoard
Robert is right, it must be a u-boot bug, these treads below are evidences of a proper (more or less) work in the past, in particular, the register mentioned above, is defined.

http://u-boot.10912.n7.nabble.com/PATCH-v3-0-3-AM335x-Add-USB-support-in-u-boot-td127575.html
http://u-boot.10912.n7.nabble.com/USB-Host-not-enumerating-properly-on-AM335x-based-board-td196920.html

Since I'll be traveling the next 10 days, will not be able to try different versions or look into u-boot's code...
Will report the results later.

Robert Nelson

unread,
Jul 1, 2017, 4:42:30 PM7/1/17
to Beagle Board
Exactly, 'it' knows... USB should be enabled and powered up by default for us.. like I said.. u-boot bug...

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.

Sergey Manucharian

unread,
Jul 20, 2017, 5:04:13 PM7/20/17
to BeagleBoard
I've found the problem: the USB flash drive I used was USB-3!
Everything works as expected with USB-2 devices.


On Saturday, July 1, 2017 at 2:42:30 PM UTC-6, RobertCNelson wrote:
Exactly, 'it' knows... USB should be enabled and powered up by default for us.. like I said.. u-boot bug...
On Jul 1, 2017 1:24 PM, "Sergey Manucharian" <s...@ara-ler.com> wrote:
Most likely you're right assuming that u-boot must be aware of what particular CPU it's dealing with (otherwise it's not possible since there is no standard API for such things as USB power).


On Saturday, July 1, 2017 at 9:19:42 AM UTC-6, RobertCNelson wrote:
Then that's a u-boot bug, usb should be on after USB start.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages