Here are the commands to run on a Linux host to create a bootable SDcard from a full image file and boot a Renesas R-Car Gen3 board (Starter Kit Pro / M3ULCB).
Requirements:
Using wget or any other tool, download the raw image (named *.wic.xz) and the associated bmap file (*.bmap) from this folder
wget http://...../*.wic.xz
wget http://...../*.wic.bmap
Find your device and set DEVICE variable:
$ lsblk -dli -o NAME,TYPE,HOTPLUG | grep "disk\s\+1$"
sdk disk 1 # <= use /dev/sdk
$ DEVICE=/dev/sdX
Run bmaptool:
sudo bmaptool copy *.wic.xz $DEVICE
Enjoy! (if your firmware and uboot config are correct - see below)
Bmap-tools is a generic tool for creating the block map (bmap) from a sparse file and copy a raw image using the block map. The idea is that large files, like raw system image files, can be copied or flashed a lot faster and more reliably with bmaptool than with traditional tools, like "dd" or "cp".
Bmap-tools sources are available on github:intel/bmap-tools. Full documentation is also available (a bit old, but still relevant).
Note: Even if Bmap-tools is not strictly required for operation, it's highly recommended. You can still skip this section if you do not wish to install bmap-tools or don't find any package for it.
Bmap-tools is available as a noarch package here: bmap-tools-3.3-1.17.1.noarch.rpm
For example, on Opensuse 42.X:
sudo zypper in http://iot.bzh/download/public/tools/bmap-tools/bmap-tools-3.3-1.17.1.noarch.rpm
bmap-tool is available in Debian distribution (not tested).
sudo apt-get install bmap-tools
Download the image and the associated bmap file:
Insert a SDcard (minimum 2GB)
Find the removable device for your card:
The following commands which lists all removable disks can help to find the information:
$ lsblk -dli -o NAME,TYPE,HOTPLUG | grep "disk\s+1$"
sdk disk 1
Here, the device we'll use is /dev/sdk.
Alternatively, a look at the kernel log will help:
$ dmesg | tail -50
...
[710812.225836] sd 18:0:0:0: Attached scsi generic sg12 type 0
[710812.441406] sd 18:0:0:0: [sdk] 31268864 512-byte logical blocks: (16.0 GB/14.9 GiB)
[710812.442016] sd 18:0:0:0: [sdk] Write Protect is off
[710812.442019] sd 18:0:0:0: [sdk] Mode Sense: 03 00 00 00
[710812.442642] sd 18:0:0:0: [sdk] No Caching mode page found
[710812.442644] sd 18:0:0:0: [sdk] Assuming drive cache: write through
[710812.446794] sdk: sdk1
[710812.450905] sd 18:0:0:0: [sdk] Attached SCSI removable disk
...
For the rest of these instructions, we assume that the variable $DEVICE contains the name of the device to write to (/dev/sd? or /dev/mmcblk?). Export the variable:
export DEVICE=/dev/[replace-by-your-device-name]
If the card is mounted automatically, unmount it through desktop helper or directly wih the command line:
sudo umount ${DEVICE}*
Write onto SDcard
Using bmap-tools:
$ sudo bmaptool copy *.wic.xz $DEVICE
bmaptool: info: discovered bmap file 'XXXXXXXXX.wic.bmap'
bmaptool: info: block map format version 2.0
bmaptool: info: 524288 blocks of size 4096 (2.0 GiB), mapped 364283 blocks (1.4 GiB or 69.5%)
bmaptool: info: copying image 'XXXXXXXX.wic.xz' to block device '/dev/sdk' using bmap file 'XXXXXXXX.wic.bmap'
bmaptool: info: 100% copied
bmaptool: info: synchronizing '/dev/sdk'
bmaptool: info: copying time: 4m 26.9s, copying speed 5.3 MiB/sec
Using standard dd command (more dangerous):
xz -cd *.wic.xz | sudo dd of=$DEVICE bs=4M; sync
To support the Kingfisher board, it's necessary to upgrade the M3 to a recent firmware.
The procedure to upgrade the M3 board is documented on the M3SK page on eLinux.org.
IoT.bzh has tested successfully the following procedure using ''minicom'':
After a successful flashing, the following versions (or later) should be available on the console boot log:
[ 0.000193] NOTICE: BL2: R-Car Gen3 Initial Program Loader(CA57) Rev.1.0.16
[ 0.005757] NOTICE: BL2: PRR is R-Car M3 Ver1.0
[ 0.010339] NOTICE: BL2: Board is Starter Kit Rev1.0
[ 0.015366] NOTICE: BL2: Boot device is HyperFlash(80MHz)
[ 0.020792] NOTICE: BL2: LCM state is CM
[ 0.024833] NOTICE: BL2: AVS setting succeeded. DVFS_SetVID=0x53
[ 0.030814] NOTICE: BL2: DDR3200(rev.0.27)NOTICE: [COLD_BOOT]NOTICE: ..0
[ 0.054032] NOTICE: BL2: DRAM Split is 2ch
[ 0.057917] NOTICE: BL2: QoS is default setting(rev.0.19)
[ 0.063415] NOTICE: BL2: Lossy Decomp areas
[ 0.067594] NOTICE: Entry 0: DCMPAREACRAx:0x80000540 DCMPAREACRBx:0x570
[ 0.074679] NOTICE: Entry 1: DCMPAREACRAx:0x40000000 DCMPAREACRBx:0x0
[ 0.081591] NOTICE: Entry 2: DCMPAREACRAx:0x20000000 DCMPAREACRBx:0x0
[ 0.088506] NOTICE: BL2: v1.3(release):b330e0e
[ 0.092995] NOTICE: BL2: Built : 08:53:12, Dec 22 2017
[ 0.098183] NOTICE: BL2: Normal boot
[ 0.101824] NOTICE: BL2: dst=0xe631f208 src=0x8180000 len=512(0x200)
[ 0.108373] NOTICE: BL2: dst=0x43f00000 src=0x8180400 len=6144(0x1800)
[ 0.114832] NOTICE: BL2: dst=0x44000000 src=0x81c0000 len=65536(0x10000)
[ 0.122057] NOTICE: BL2: dst=0x44100000 src=0x8200000 len=524288(0x80000)
[ 0.132536] NOTICE: BL2: dst=0x50000000 src=0x8640000 len=1048576(0x100000)
U-Boot 2015.04 (Dec 22 2017 - 09:53:06)
CPU: Renesas Electronics R8A7796 rev 1.0
Board: M3ULCB
I2C: ready
DRAM: 1.9 GiB
Flash: 64 MiB
MMC: sh-sdhi: 0, sh-sdhi: 1
In: serial
Out: serial
Err: serial
...
Next step is to configure uboot properly.
If not already done, you'll have to configure Uboot parameters.
Connect serial console on M3 board and start a terminal emulator on the USB serial port. Here, we use 'screen' on device /dev/ttyUSB0 but you could use any terminal emulator able to open the serial port at 115200 bauds (minicom , picocom ...)
screen /dev/ttyUSB0 115200
Power up the board
Break at uboot prompt (press any key)
Set the following uboot variables:
WARNING: don't make a big copy/paste or some garbage characters may be sent to the console (issue with usb/serial port buffering?). Instead, copy one or two lines at a time.
env default -a
setenv board m3ulcb
setenv socnum r8a7796
setenv bootmmc '0:1'
setenv set_bootkfile 'setenv bootkfile Image'
setenv bootkaddr 0x48080000
setenv set_bootdfile 'setenv bootdfile devicetree-Image-${socnum}-${board}.dtb'
setenv bootdaddr 0x48000000
setenv bootargs_console 'console=ttySC0,115200 ignore_loglevel'
setenv bootargs_video 'vmalloc=384M video=HDMI-A-1:1920x1080-32@60'
setenv bootargs_extra 'rw rootfstype=ext4 rootwait rootdelay=2'
setenv bootkload_sd 'ext4load mmc ${bootmmc} ${bootkaddr} boot/${bootkfile}'
setenv bootdload_sd 'ext4load mmc ${bootmmc} ${bootdaddr} boot/${bootdfile}'
setenv bootargs_root_sd 'root=/dev/mmcblk0p1'
setenv bootload_sd 'run set_bootkfile; run bootkload_sd; run set_bootdfile; run bootdload_sd'
setenv bootcmd 'setenv bootargs ${bootargs_console} ${bootargs_video} ${bootargs_root_sd} ${bootargs_extra}; run bootload_sd; booti ${bootkaddr} - ${bootdaddr}'
Then save environment in NV flash:
saveenv
At uboot prompt, type:
```
run bootcmd
```
Alternatively, simply reset the board.
NOTE: Due to initial operations, first AGL boot can take longer (a few mintutes) than next ones.