Flashing SD card over USB
#1
Hello all,

I'm developing my own PCB around the A64 and am currently using a Pine64 to develop my flashing procedure (want to have just eMMC on the board). For right now what I'm trying to do is flash a linux image to the blank SD card on the Pine64 using only the USB OTG port. It seemed like this was supported when I found Ayufan's USB Mass Storage, but I didn't get it to boot. The FEL interface becomes unresponsive, and the serial output shows us getting up to 'pmbus ready' I've got serial output from a few runs here: https://pastebin.com/tDve7G3t

After chatting with marcushh777 on the #Pine64 IRC channel, I decided to put that aside to try and better understand the boot process. The last couple of weeks I've been experimenting with different branches of u-boot/u-boot-sunxi and Longsleep's build-pine64-image repo, and was able to build that image, write it to RAM (over a period of hours) using u-boot over serial, and then write that image to the board. That's pretty exciting, and was a great learning experience, but I'm not quite sure what I should do next to get to achieve my single-port goal.

I was thinking about embedding an RNDIS driver into u-boot, but that would still require a second interface to initiate a TFTP transfer, though maybe another endpoint could be established to present the serial over USB as well. I'm not quite sure where to start with u-boot, either. I haven't managed to boot the mainline u-boot with ported H3 DRAM drivers, but a sunxi branch (20160126-wip-a64) with AW's libdram does boot.

It seems to me that I must be missing something, because this functionality seems like something that must have been implemented somewhere, even if it hasn't been ported to the A64. Does anyone have any suggestions for how I can proceed from here?

Thanks!
#2
(07-22-2017, 01:48 AM)ccben Wrote: Hello all,

I'm developing my own PCB around the A64 and am currently using a Pine64 to develop my flashing procedure (want to have just eMMC on the board).
<snip>
After chatting with marcushh777 on the #Pine64 IRC channel, 
<snip>

Does anyone have any suggestions for how I can proceed from here?

I told you on the irc that this discussion is beyond the scope of the irc chat room, and the Pine forum.

You persist, so I'll give you my opinion;  others are free to join in to.  The ideal setup is to have both eMMC and SD bootups;  in an ideal world also SPI flash.

boot priority:   SPI flash ---> SD card ---> eMMC

Having only a single mode of booting is restrictive and a PITA frankly.  I will give you an example of this:  the Rock64 is supposed to be able to be loaded with an RK tool that will load the eMMC ;  the problem is that it doesn't work well, and unless you know what you're doing (not noobs) it doesn't work at all, and ofc requires some setup or it does not work period. The way I'm loading my eMMC on the Rock64 board is by using another image on the SD card and then 'curl' -ing the image from the network directly to the eMMC.

I will give you another example;  the pinebook uses both eMMC and SD card !  I have my primary image on the eMMC, and I have four secondary images (two 32G, two 64G) in my man bag with the pinebook;  these images are for different purposes ;  but one of the purposes beyond dual booting is the ability to cross-backup between the SD cards and the eMMC;  this has been fantastic;  and most recently I'm experimenting with using the SDIO for gpio control;  something entirely not considered in the design phase.


The Pine forum and the irc channels  #Pine64, #Padi, #Rock64, exist to discuss Pine products, not to facilitate building competitive products. That is not to say that Pine related dev will not be discussed that might help you;  to the contrary;  however, the irc nor the forum are designed to teach kernel dev image building, nor the development of competitive products or product schemes. The dev community is here to support the development of software(s) for the Pine products specifically.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
#3
(07-22-2017, 01:48 AM)ccben Wrote: I'm developing my own PCB around the A64 and am currently using a Pine64 to develop my flashing procedure (want to have just eMMC on the board). For right now what I'm trying to do is flash a linux image to the blank SD card on the Pine64 using only the USB OTG port. It seemed like this was supported when I found Ayufan's USB Mass Storage, but I didn't get it to boot. The FEL interface becomes unresponsive, and the serial output shows us getting up to 'pmbus ready' I've got serial output from a few runs here: https://pastebin.com/tDve7G3t

I haven't played with the USB OTG / FEL mode programming. ayufan and Xalius would probably be the best people to talk to (and maybe also tkaiser if he's online). My only suggestion look at this would be that perhaps power is an issue? When doing USB OTG loading with my rock64 using the rkusb tool, there is insufficient power on the USB lead to ensure the the write is successful, so I use a USB lead though an adapter that lets me switch the USB power off, and power the rock64 via the rPi header (as that is how mine is currently powered). Maybe this is what is causing your unresponsive system?

(07-22-2017, 01:48 AM)ccben Wrote: It seems to me that I must be missing something, because this functionality seems like something that must have been implemented somewhere, even if it hasn't been ported to the A64. Does anyone have any suggestions for how I can proceed from here?

Marcus is indeed right in pointing out that the boo order is:

Code:
boot-> check fel key pressed (yes)--> FEL mode (boot from USB OTG)
                         \  
                     (no) \
                           \-------> 1) try to boot from SMHC0 (SD card)
                                     2) try to boot from SMHC2 (eMMC)
                                     3) try to boot from SPI0 (SPI NOR Flash)
                                     4) FEL mode (boot from USB OTG)

but (there's always a BUT, isn't there)... do you have to have FEL mode? If you are trying to do some sort of image load... can booting from the USB work for you? If you get uboot booted, but there is no valid boot target on the microSD, it will look at the USB next. So the boot sequence would become SD card -> uboot -> USB. Is that any use to you?

I hope you do get your project up and running, especially if it will be an open source design/project... the more people that are working in this space, the more we all prosper. Wink More the merrier!
#4
(07-22-2017, 03:28 AM)pfeerick Wrote: I haven't played with the USB OTG / FEL mode programming. ayufan and Xalius would probably be the best people to talk to (and maybe also tkaiser if he's online). My only suggestion look at this would be that perhaps power is an issue? When doing USB OTG loading with my rock64 using the rkusb tool, there is insufficient power on the USB lead to ensure the the write is successful, so I use a USB lead though an adapter that lets me switch the USB power off, and power the rock64 via the rPi header (as that is how mine is currently powered). Maybe this is what is causing your unresponsive system?

I tried this out and monitored the current draw from my USB A-A cable and my power supply. At 5V, whether through the Pi header's 5V or the Euler header's DCIN, the board is drawing ~80mA at reset and ~160mA from my bench supply after running 'make pine64_ums', and ~5mA from USB. It stops in the same place as in the original post. That 160mA is less than USB should provide anyway. Logs here: https://pastebin.com/NWNmvxGz

I also booted from an SD card into a really basic linux image (built with longsleep's build-pine-64 repo). With that, the board draws a max of about 270mA during the initial startup, and is at ~230 while idle at the shell prompt.

Based on that, it looks like power is not my issue; at least not at this stage.

(07-22-2017, 03:28 AM)pfeerick Wrote: Marcus is indeed right in pointing out that the boo order is:

Code:
boot-> check fel key pressed (yes)--> FEL mode (boot from USB OTG)
                         \  
                     (no) \
                           \-------> 1) try to boot from SMHC0 (SD card)
                                     2) try to boot from SMHC2 (eMMC)
                                     3) try to boot from SPI0 (SPI NOR Flash)
                                     4) FEL mode (boot from USB OTG)

but (there's always a BUT, isn't there)... do you have to have FEL mode? If you are trying to do some sort of image load... can booting from the USB work for you? If you get uboot booted, but there is no valid boot target on the microSD, it will look at the USB next. So the boot sequence would become SD card -> uboot -> USB. Is that any use to you?

I hope you do get your project up and running, especially if it will be an open source design/project... the more people that are working in this space, the more we all prosper. Wink More the merrier!

Our goal is to not require any additional hardware, other than a PC or smartphone that people will already have, and a USB cable. We're planning on a USB-C connector, so that would require an adapter or USB-C thumbdrive, too. Based on that, my understanding is that that will limit us to something with FEL mode.

And yes, this is an open-source project. Nothing released yet, I'm currently in the process of designing the hardware for our first rev using the A64, and am investigating this boot/flash process as I go, too.

Thanks!
#5
Yeah, that is sounding like you're going to want FEL mode then. Drats!

I can't help you any further with this atm though... as I have tried a quick prod at the FEL boot stuff, and you've got it booting further than what I did with recent ayufan pine64 image... ie.

Code:
HELLO! BOOT0 is starting!
boot0 commit : 045061a8bb2580cb3fa02e301f52a015040c158f
 
boot0 version : 4.0.0
set pll start
set pll end
rtc[0] value = 0x00000000
rtc[1] value = 0x00000000
rtc[2] value = 0x5aa5a55a
rtc[3] value = 0x00000000
rtc[4] value = 0x00000000
rtc[5] value = 0x00000000
eraly jump fel
HELLO! FES1 is starting 79624!
set pll start
set pll end
beign to init dram
DRAM driver version: V1.0

And forcing FEL mode through uboot didn't make any difference either (s at startup to stop, and use efex mode). 

I keep either getting either


Code:
ERROR: Allwinner USB FEL device not found!

 
or 


Code:
MMU is not enabled by BROM
=> Executing the SPL... done.
usb_bulk_send() ERROR -9: Pipe error

errors when running the sunxi-fel command manually i.e.

Code:
sudo sunxi-tools/sunxi-fel -v spl boot/pine64/fes1-pine64-plus.bin write-with-progress 0x4A000000 boot/pine64/u-boot-pine64-plus.bin writel 0x4A0000e0 0x55 writel 0x4A0000e4 0x0 exe 0x4A000000


Hopefully someone with better knowledge of this FEL mode side of the A64 can comment as to what is happening, as at the moment it doesn't seem to wanna play! Sad
#6
(07-24-2017, 02:04 AM)pfeerick Wrote: Yeah, that is sounding like you're going to want FEL mode then. Drats!

I can't help you any further with this atm though... as I have tried a quick prod at the FEL boot stuff, and you've got it booting further than what I did with recent ayufan pine64 image... ie.

I really appreciate you taking the time to look into this. In case I can interest you in looking further (and for anyone else who wants to help or who later has issues with this), here's some detail on my setup and the process I followed:

Board: Pine64 1G (PA641GB), date: 2016-03-21
Power: Board is powered through Pi header 5v pins from 5v supply with 1A limit
Host OS: Ubuntu 17.04 x64 (in Virtualbox on Win10)

Relevant package versions:
  • gcc 6.3.0 20170406
  • libusb-1.0-0-dev

Source repos:
Ayufan's USB Mass storage (master): https://github.com/ayufan-pine64/boot-tools

Process:
  1. Boot the P64 into FEL mode by installing a blank SD card into the receptacle.

  2. Alternatively (if you don't have a blank SD card):
    1. Pull the the SD card with the power off.
    2. Power the P64
    3. Put the SD card back in once booted.

  3. Once in FEL mode, run the following commands:
    Code:
    git clone https://github.com/ayufan-pine64/boot-tools
    cd boot-tools
    make pine64_ums


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I change the default sound card? zirconx 2 5,891 10-02-2016, 05:10 AM
Last Post: pfeerick
  MicroSD card won't format Andr3w 2 5,044 07-12-2016, 11:10 AM
Last Post: Luke
  microSD card performance comparison falk.ben@gmail.com 14 25,314 06-21-2016, 03:10 AM
Last Post: simonritchie
  Making a Ubuntu Server image for SD Card insignia96 3 7,160 04-06-2016, 09:46 PM
Last Post: insignia96
  How to get Ubuntu SD Card Bob123456789 7 11,864 01-25-2016, 04:08 PM
Last Post: Ghost

Forum Jump:


Users browsing this thread: 1 Guest(s)