How to Write an Image to the eMMC Module Tutorial
#1
Brick 
Greetings,

The purpose of this post is to document the procedure for writing gnu+linux images to the eMMC module on the Rock64 board; the procedure is fairly straight-forward and is not difficult with some small planning and care. First I'll give just a little discussion of the overall theory, then list the materials that you will need, and finally we'll cover the step-by-step detail.

Theory

The overarching goal is to copy the desired image from the network directly to the eMMC module; in order to do this we need to boot-up the Rock64 board from an SD card containing a minimal gnu+linux image -- this is NOT the image that will be written to the eMMC module necessarily, it is only the image that we will use to do the work. Once the Rock64 is booted from SD card, we can then issue the command (or run the automated script) that will download the desired image from the network directly to the eMMC module; then its simply a matter of rebooting the Rock64. The interesting part of the procedure (detailed below) is that the eMMC module needs to be visible to the system AND the system has to be forced to boot from the SD card. This will be explained.

Materials Required

This procedure will require the following bill of materials: 1) Rock64 board, 2) eMMC module, 3) two pin jumper, 4) bootable SD card (gnu+linux), 5) serial console adapter cable, PC or Mac and serial terminal software like minicom, screen, or cu.  For the purposes of this tutorial we assume that you already have the Rock64 board with eMMC module installed, and that you have a bootable SD card (minimal gnu+linux image), also that the bootable SD card has the curl command utility installed.  The two pin jumper can be the standard plastic block two pin header jumper connector, or it can be a six inch jumper wire with standard header female (F-F) connectors both ends. Lastly you will need a serial console ttl to usb bridge cable adapter and serial console terminal software.  This can be any of a number of supported chipsets (cp2102, pl2303hx, ch340g). The challenge is that the standard serial console uart baud rate is 1.5M (1500000 baud, 8n1). Not all combinations of serial bridge adapters and software support 1.5M baud rate. I have tested the cp2102, the pl2303hx;  the pl2303ta does NOT work.  Minicom is the best software for serial terminal;  the reason we need a serial terminal (software and bridge cable) is that we will need to watch the boot sequence so that we can 'stop' the boot-up at the uboot three second timer (described later).

Background

In order to boot-up the Rock64 from the SD card, so that the eMMC module is also available, we have to force the boot-up with a 'jumper' using two special pins on the main board, and we also have to interrupt the boot-up (at the uboot three second timer) so that the SD card system can detect the eMMC module for writing later!  The important things to be aware of are: 1) the jumper shorts the clock signal on the eMMC module to ground (be careful, don't ESD shock it), and 2) the jumper must be removed before the SD image comes up so that the eMMC clock will be active and the linux image on the SD card will "see" the eMMC module;  failure to do this will result in not being able to write the network image to the eMMC module.  Also, if you do not have a serial console active you will not be able to see when the uboot timer is running so that you can interrupt it.  The serial console is very important because the normal display does not show boot-up messages!

Preparation steps

The preparation steps are very important and will setup things so that the main procedure will be successful. Make sure that the preparation steps run smoothly and that they can be repeated easily before moving on to the main procedure:  this is very important !

1) make sure the eMMC module is snapped in place on the Rock64 main board

2  make sure the bootable SD card is installed in the SD card slot;  this should be one of our gnu+linux images containing the curl utility tools;  again, this image is NOT copied to the eMMC and is only used to do the required work.

3)  install the jumper on the two special pins on the Rock64 main board;  these two pins are directly next to the small "recovery button" on the main board. Either a two pin plastic block jumper connector may be used, or a six inch jumper wire with F-F female header connectors on each end.

4) make certain that your serial console works!  Connect the appropriate Tx Rx and Gnd pins of the bridge adapter cable to the uart pins of the Rock64 header (see serial console tutorial) and then plug the other end (usb) into your PC or Mac;  use serial terminal software like minicom, screen, or cu to "talk" to the Rock64 board over the serial connection. While the serial console is connected and "running" boot the Rock64 board;  this is just a test of the serial console... you should see the boot-up messages flying by on the serial terminal software and when fully booted you should see a logon prompt.  Logon to the Rock64 board and then enter the command  sudo halt  and you will see the Rock64 shutdown including the shutdown message stream.

( repeat step [3] a couple of times to make sure that you understand what is happening, and that the serial console is working;  also (important) pay attention to the messages and be looking for the uboot three second timer !  This is the timer that you must interrupt (later) in order to remove the jumper at the right time.  Also, you will need a good ethernet network connection, so make certain your eth cat5 or cat6 cable is plugged into a good router connection. )

Note:  see step (7) of the main procedure (below) because the command sd2emmc.sh  script file needs to be on your SD bootable card in the rock64 home directory.   (important)

Main Procedure

These are the main steps of the procedure that will copy the desired image from the network to the eMMC module;  yes, you will need a good network connection, the faster the better.  We are assuming that the preparation steps are complete and that everything is working; if not, procede no further until the preparation steps are complete.

1)  boot-up the Rock64 (as in preparation) with the jumper in place and the serial console running and prepare to stop (interrupt) the boot-up at the uboot three second timer.  To interrupt boot at the timer, just press a key to stop the timer.

2)  To interrupt the uboot three second timer press a key and the timer will stop;  if this does not work the first time, or you miss it, just shutdown and try try again.  Once the uboot three second timer has been interruped move on to step three (3).

3)  Carefully remove the jumper from the main board;  do not short against any other pins.

4)  Continue with the boot-up by entering the command   boot

5)  Once the boot-up has completed and you have the logon prompt on the serial console, logon to the serial console and prepare to issue the curl command detailed below:

6)  First,  make sure that both of your storage devices are present.  If they are NOT present, then shutdown with  sudo halt  and start over from the beginning (by booting with the jumper in place). To see if the devices are present use the command  sudo fdisk -l

    sudo  fdisk  -l

6b) You should see two kinds of devices in the list:  
        /dev/mmcblk1xx   This is your SD card
        /dev/mmcblk0xx   This is your eMMC module

     If you do NOT see both mmcblk0 and mmcblk1 devices you must start over.  

[  Please read both step(s)  7a  and  7b  before proceding;  ]

7a)  We are now ready to copy the image from the network to the eMMC module;  it is important that you 'know' which image you want to copy from the github site;  the one listed in this example is 0.4.16 ; however, you will want the last stable release ( not pre release ).  Enter the curl command below ( or automated script which does the same thing ) and wait until it is finished;  the command copies the image directly from the network github site to the eMMC module.    (we are working on a port of the install script to automate this step, soon)

sd2emmc.sh

Code:
curl -L https://github.com/ayufan-rock64/linux-build/releases/download/0.4.16/xenial-mate-rock64-0.4.16-83-arm64.img.xz | unxz -c > /dev/mmcblk0

It is best to place the above command into a file like  sd2emmc.sh  and make the file executable;  

      sudo chmod 0754 sd2emmc.sh

then execute the file (bash script) as sudo;  

      sudo sd2emmc.sh


It is my experience that the curl command works best when executed from within a shell script;  rather than directly on the command line.

The above command is a single line with a pipe character ( | ) and a redirection character ( > ). It writes (copies) the image from github, piped through the decompression tool, and then redirected to the /dev/mmcblk0  eMMC module device.  In this example the ubuntu mate xenial image was selected;  you may want a different image !

Be careful that the image file is spelled correctly;  pay particular attention to all the dots, hypens, slashes, etc.  

7b)  Please see this link for the alternative automated scripts for writing SD and eMMC images directly from the network repos.  

      The command rock64_install_to_emmc.sh may be placed on your bootable SD card , which serves the same purpose the the identical script (functionally) as the Pinebook to eMMC script.  Please read the link carefully.

      The command rock64_install_to_SD.sh may be placed on your PC to make SD cards directly from the network repos ( or even copy to the eMMC module with an adapter ) without intermediary steps or hassle;  again, please read the link carefully.

8)  When this command completes then shutdown with   sudo halt

9)  make certain the jumper is removed

10) make sure the SD card is removed

11) boot-up the Rock64;  you may leave the serial console running ( recommended )

12) logon to the new eMMC module image !

At this point you are running from the eMMC module and are ready to do whatever customizing or further installing as you see fit;  its your system, enjoy !

Big Grin
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! )
#2
Thanks for the tutorial, I think this desperatly needed it's own thread even though you described the process in some of your posts. Sadly I cheaped out on the serial adapter but bought a 32gb eMMC, so I have two questions:

* is it possible to do this without the serial adapter or should I order one?
* is the jumper included or do I need to purchase it? (SBC newbie here)

edit: maybe put this thread into the 'tutorial' category
#3
(08-15-2017, 06:16 AM)Lexstar Wrote: Thanks for the tutorial, I think this desperatly needed it's own thread even though you described the process in some of your posts. Sadly I cheaped out on the serial adapter but bought a 32gb eMMC, so I have two questions:

* is it possible to do this without the serial adapter or should I order one?
* is the jumper included or do I need to purchase it? (SBC newbie here)

edit: maybe put this thread into the 'tutorial' category

Don't try it without a serial adapter;  words to the wise.  Also, the jumper is not included but is a 'standard' jumper used throughout the industry.  They were even used back in the day (like modems, sound cards etc) as configuration options if you remember those days;  but it can just be a jumper wire (six inch standard cable).
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! )
#4
I guess something like this would work (AliExpress)? Or do you have other recommendations from AliExpress? I will buy some jumpers there too, is there anything else I should buy that you think I could need in the future?

Excuse the many questions, I'm a SBC noob sadly and thanks for helping.
#5
Wow, I am surprised that the board doesn't come with the required jumper. It feels like that is an important component that costs almost nothing. Disappointing. I am sure that I have one around somewhere, but it is frustrating.

Question, can I use a female to female dupont cable for this?

Sent from my SM-T537V using Tapatalk
#6
It is important that you NOT choose a pl2303ta chip ! If it has pl2303hx it will be fine. I use the cp2102 from the pine store; also works fine. Any jumper will do, either block (two pin) or jumper wire F-F.
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! )
#7
I just searched the forums and cannot find the serial console tutorial that you refer to. Can you provide a link? I have a serial cable that I have used with RPis over the years and so am hoping that I can use that one.

Sent from my SM-T537V using Tapatalk

My apologies, I found it here: https://forum.pine64.org/showthread.php?tid=4674

Sent from my SM-T537V using Tapatalk
#8
I pushed a new file @ github :

rock64_install_to_emmc.sh ; a port of pine64_install_to_emmc.sh
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! )
#9
Really good guide!

But I would just like to make it clear that this guide is for Linux images!  Maybe you should mention that clearly in the OP, Mark. Wink

If you are looking for how to install Android onto eMMC, there are much easier ways. Such as my own SADIE script. Windows version of SADIE is still in the works, hopefully for release later this week. Smile
Community administrator and sysadmin for PINE64
(Translation: If something breaks on the website, forum, or chat network, I'm a good person to yell at about it)

#10
(08-15-2017, 11:46 AM)fire219 Wrote: Really good guide!

But I would just like to make it clear that this guide is for Linux images!  Maybe you should mention that clearly in the OP, Mark. Wink

If you are looking for how to install Android onto eMMC, there are much easier ways. Such as my own SADIE script. Windows version of SADIE is still in the works, hopefully for release later this week. Smile


Noted, and corrected.  Actually, this process is much much easier than it at first glance appears;  I used this procedure today during test and loaded my new Rock64 board eMMC in less than ten minutes from start to finish -- no hits, no runs, no errors !

I also have ported ayufan's script to the rock64 -- rock64_install_to_emmc,  which further simplifies things by allowing the user to select the system and version, as well automatically generating the curl file;  very nice.

Thanks for the tip fire219.

(08-15-2017, 08:06 AM)jl_678 Wrote: I just searched the forums and cannot find the serial console tutorial that you refer to. Can you provide a link? I have a serial cable that I have used with RPis over the years and so am hoping that I can use that one.

Sent from my SM-T537V using Tapatalk

My apologies, I found it here: https://forum.pine64.org/showthread.php?tid=4674

Sent from my SM-T537V using Tapatalk


Thank you for the tip;  I corrected the post with the hyper-link;  the intended one you may get right here.
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! )


Possibly Related Threads…
Thread Author Replies Views Last Post
  Rock64 u-boot for eMMC Build Error mexicanflyer 0 1,397 09-18-2022, 02:29 PM
Last Post: mexicanflyer
Thumbs Up USB3.0 to eMMC Adapter... MattDralle 2 3,676 10-28-2021, 12:20 PM
Last Post: tllim
  Pine Rock64 eMMC lifespan moonspell79 3 4,342 08-19-2021, 06:46 PM
Last Post: bcnaz
  Download IDB fail when trying to flash Android image cherkasoff 0 5,276 04-05-2020, 07:41 AM
Last Post: cherkasoff
  Receiving errors about eMMC (?) acasta 11 18,143 09-24-2019, 10:26 PM
Last Post: ridgarou
  USB -> eMMC is now available. Luke 15 33,055 07-27-2019, 04:27 PM
Last Post: tllim
  Rock 64 network error as soon as I try to write or read. georgegohl888 1 3,369 03-12-2019, 09:35 AM
Last Post: georgegohl888
  Rock64 scipy, numpy, scikit-image, matplotlib issue with pip3 ictele 0 2,242 02-05-2019, 05:41 PM
Last Post: ictele
  flash image to sd/emmc through ethernet LMM 0 2,513 02-04-2019, 07:36 AM
Last Post: LMM
  HW image transitions in Python gaggleoxfoggy 7 9,010 11-24-2018, 10:41 AM
Last Post: gaggleoxfoggy

Forum Jump:


Users browsing this thread: 1 Guest(s)