[U-Boot] [PATCH 0/5] sunxi: doc: Add fastboot example + misc cleanups

While writing a sample fastboot usage tutorial for sunxi, I also found bunch of discrepancies in the existing docs.
Series also includes one simple constification patch that has been sitting in my tree for ages.
Priit Laes (5): sunxi: Fix typos of spelling Allwinner sunxi: docs: Unify the formatting style and add some paragraph breaks sunxi: docs: Mention CONFIG_NAND requirement sunxi: display: Mark sunxi_rgb2yuv_coef array as const sunxi: doc: Add basic fastboot example
arch/arm/mach-sunxi/dram_sun4i.c | 2 +- arch/arm/mach-sunxi/p2wi.c | 2 +- board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++- board/sunxi/README.nand | 24 +++---- board/sunxi/README.sunxi64 | 25 +++++--- drivers/video/sunxi/sunxi_display.c | 2 +- 6 files changed, 130 insertions(+), 23 deletions(-) create mode 100644 board/sunxi/README.fastboot
base-commit: 3ae192c2a4d52a755031e93fa6cc3a31ba90f29f

Signed-off-by: Priit Laes plaes@plaes.org --- arch/arm/mach-sunxi/dram_sun4i.c | 2 +- arch/arm/mach-sunxi/p2wi.c | 2 +- board/sunxi/README.sunxi64 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-sunxi/dram_sun4i.c b/arch/arm/mach-sunxi/dram_sun4i.c index 8562302..396c042 100644 --- a/arch/arm/mach-sunxi/dram_sun4i.c +++ b/arch/arm/mach-sunxi/dram_sun4i.c @@ -5,7 +5,7 @@ * (C) Copyright 2013 Luke Kenneth Casson Leighton lkcl@lkcl.net * * Based on sun4i Linux kernel sources mach-sunxi/pm/standby/dram*.c - * and earlier U-Boot Allwiner A10 SPL work + * and earlier U-Boot Allwinner A10 SPL work * * (C) Copyright 2007-2012 * Allwinner Technology Co., Ltd. <www.allwinnertech.com> diff --git a/arch/arm/mach-sunxi/p2wi.c b/arch/arm/mach-sunxi/p2wi.c index 82ad254..e84e1d8 100644 --- a/arch/arm/mach-sunxi/p2wi.c +++ b/arch/arm/mach-sunxi/p2wi.c @@ -5,7 +5,7 @@ * (C) Copyright 2013 Oliver Schinagl oliver@schinagl.nl * http://linux-sunxi.org * - * Based on sun6i sources and earlier U-Boot Allwiner A10 SPL work + * Based on sun6i sources and earlier U-Boot Allwinner A10 SPL work * * (C) Copyright 2006-2013 * Allwinner Technology Co., Ltd. <www.allwinnertech.com> diff --git a/board/sunxi/README.sunxi64 b/board/sunxi/README.sunxi64 index df1dbc8..bba2e01 100644 --- a/board/sunxi/README.sunxi64 +++ b/board/sunxi/README.sunxi64 @@ -130,7 +130,7 @@ U-Boot prompt on the serial console.
(Legacy) boot0 method --------------------- -boot0 is Allwiner's secondary program loader and it can be used as some kind +boot0 is Allwinner's secondary program loader and it can be used as some kind of SPL replacement to get U-Boot up and running from an microSD card. For some time using boot0 was the only option to get the Pine64 booted. With working DRAM init code in U-Boot's SPL this is no longer necessary,

On Tue, Oct 23, 2018 at 08:20:28PM +0300, Priit Laes wrote:
Signed-off-by: Priit Laes plaes@plaes.org
Acked-by: Maxime Ripard maxime.ripard@bootlin.com
Thanks! Maxime

On Tue, Oct 23, 2018 at 10:51 PM Priit Laes plaes@plaes.org wrote:
Signed-off-by: Priit Laes plaes@plaes.org
Applied to u-boot-sunxi/master

Signed-off-by: Priit Laes plaes@plaes.org --- board/sunxi/README.nand | 18 +++++++++--------- board/sunxi/README.sunxi64 | 23 ++++++++++++++++------- 2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/board/sunxi/README.nand b/board/sunxi/README.nand index a5d4ff0..77a8c7d 100644 --- a/board/sunxi/README.nand +++ b/board/sunxi/README.nand @@ -29,26 +29,26 @@ board is in FEL mode, you'll need the sunxi-tools that you can find at this repository: https://github.com/linux-sunxi/sunxi-tools
Then, you'll need to first load an SPL to initialise the RAM: -sunxi-fel spl spl/sunxi-spl.bin +$ sunxi-fel spl spl/sunxi-spl.bin
Load the binaries we'll flash into RAM: -sunxi-fel write 0x4a000000 u-boot-dtb.bin -sunxi-fel write 0x43000000 spl/sunxi-spl-with-ecc.bin +$ sunxi-fel write 0x4a000000 u-boot-dtb.bin +$ sunxi-fel write 0x43000000 spl/sunxi-spl-with-ecc.bin
And execute U-Boot -sunxi-fel exe 0x4a000000 +$ sunxi-fel exe 0x4a000000
On your board, you'll now have all the needed binaries into RAM, so you only need to erase the NAND...
-nand erase.chip +$ nand erase.chip
Then write the SPL and its backup:
-nand write.raw.noverify 0x43000000 0 40 -nand write.raw.noverify 0x43000000 0x400000 40 +$ nand write.raw.noverify 0x43000000 0 40 +$ nand write.raw.noverify 0x43000000 0x400000 40
And finally write the U-Boot binary: -nand write 0x4a000000 0x800000 0xc0000 +$ nand write 0x4a000000 0x800000 0xc0000
-You can now reboot and enjoy your NAND. \ No newline at end of file +You can now reboot and enjoy your NAND. diff --git a/board/sunxi/README.sunxi64 b/board/sunxi/README.sunxi64 index bba2e01..63cd8bb 100644 --- a/board/sunxi/README.sunxi64 +++ b/board/sunxi/README.sunxi64 @@ -32,9 +32,10 @@ to build it first. Checkout the "allwinner" branch from the github repository [1] and build it: $ export CROSS_COMPILE=aarch64-linux-gnu- $ make PLAT=sun50iw1p1 DEBUG=1 bl31 + The resulting binary is build/sun50iw1p1/debug/bl31.bin. Either put the location of this file into the BL31 environment variable or copy this to -the root of your U-Boot build directory (or create a symbolic link). +the root of your U-Boot build directory (or create a symbolic link): $ export BL31=/src/arm-trusted-firmware/build/sun50iw1p1/debug/bl31.bin (adjust the actual path accordingly)
@@ -48,7 +49,8 @@ binaries in the firmware repository[3], purely for convenience reasons. ------------ Both U-Boot proper and the SPL are using the 64-bit mode. As the boot ROM enters the SPL still in AArch32 secure SVC mode, there is some shim code to -enter AArch64 very early. The rest of the SPL runs in AArch64 EL3. +enter AArch64 very early. The rest of the SPL runs in AArch64 EL3 mode. + U-Boot proper runs in EL2 and can load any AArch64 code (using the "go" command), EFI applications (with "bootefi") or arm64 Linux kernel images (often named "Image"), using the "booti" command. @@ -95,15 +97,15 @@ feature is disabled in the configuration at the moment. microSD card ------------ Transfer the SPL and the U-Boot FIT image directly to an uSD card: -# dd if=spl/sunxi-spl.bin of=/dev/sdx bs=8k seek=1 -# dd if=u-boot.itb of=/dev/sdx bs=8k seek=5 -# sync +$ dd if=spl/sunxi-spl.bin of=/dev/sdx bs=8k seek=1 +$ dd if=u-boot.itb of=/dev/sdx bs=8k seek=5 +$ sync (replace /dev/sdx with you SD card device file name, which could be /dev/mmcblk[x] as well).
Alternatively you can use the SPL and the U-Boot FIT image combined into a single file and transfer that instead: -# dd if=u-boot-sunxi-with-spl.bin of=/dev/sdx bs=8k seek=1 +$ dd if=u-boot-sunxi-with-spl.bin of=/dev/sdx bs=8k seek=1
You can partition the microSD card, but leave the first MB unallocated (most partitioning tools will do this anyway). @@ -118,13 +120,17 @@ Now connect either an "A to A" USB cable to the upper USB port on the Pine64 or get an adaptor and use a regular A-microB cable connected to it. Other boards often have a proper micro-B USB socket connected to the USB OTB port. Remove a microSD card from the slot and power on the board. + On your host computer download and build the sunxi-tools package[2], then use "sunxi-fel" to access the board: $ ./sunxi-fel ver -v -p + This should give you an output starting with: AWUSBFEX soc=00001689(A64) ... + Now use the sunxi-fel tool to write to the NOR flash: $ ./sunxi-fel spiflash-write 0 spl/sunxi-spl.bin $ ./sunxi-fel spiflash-write 32768 u-boot.itb + Now boot the board without an SD card inserted and you should see the U-Boot prompt on the serial console.
@@ -142,10 +148,11 @@ by this method. The boot0 binary is a 32 KByte blob and contained in the official Pine64 images distributed by Pine64 or Allwinner. It can be easily extracted from a micro SD card or an image file: -# dd if=/dev/sd<x> of=boot0.bin bs=8k skip=1 count=4 +$ dd if=/dev/sd<x> of=boot0.bin bs=8k skip=1 count=4 where /dev/sd<x> is the device name of the uSD card or the name of the image file. Apparently Allwinner allows re-distribution of this proprietary code "as-is". + This boot0 blob takes care of DRAM initialisation and loads the remaining firmware parts, then switches the core into AArch64 mode. The original boot0 code looks for U-Boot at a certain place on an uSD card @@ -159,8 +166,10 @@ places on the uSD card and works around unused, but mandatory parts by using trampoline code. See the output of "boot0img -h" for more information. boot0img can also patch boot0 to avoid loading U-Boot from 19MB, instead fetching it from just behind the boot0 binary (-B option). + $ ./boot0img -o firmware.img -B boot0.img -u u-boot-dtb.bin -e -s bl31.bin \ -a 0x44008 -d trampoline64:0x44000 + Then write this image to a microSD card, replacing /dev/sdx with the right device file (see above): $ dd if=firmware.img of=/dev/sdx bs=8k seek=1

On Tue, Oct 23, 2018 at 08:20:29PM +0300, Priit Laes wrote:
Signed-off-by: Priit Laes plaes@plaes.org
board/sunxi/README.nand | 18 +++++++++--------- board/sunxi/README.sunxi64 | 23 ++++++++++++++++------- 2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/board/sunxi/README.nand b/board/sunxi/README.nand index a5d4ff0..77a8c7d 100644 --- a/board/sunxi/README.nand +++ b/board/sunxi/README.nand @@ -29,26 +29,26 @@ board is in FEL mode, you'll need the sunxi-tools that you can find at this repository: https://github.com/linux-sunxi/sunxi-tools
Then, you'll need to first load an SPL to initialise the RAM: -sunxi-fel spl spl/sunxi-spl.bin +$ sunxi-fel spl spl/sunxi-spl.bin
Load the binaries we'll flash into RAM: -sunxi-fel write 0x4a000000 u-boot-dtb.bin -sunxi-fel write 0x43000000 spl/sunxi-spl-with-ecc.bin +$ sunxi-fel write 0x4a000000 u-boot-dtb.bin +$ sunxi-fel write 0x43000000 spl/sunxi-spl-with-ecc.bin
And execute U-Boot -sunxi-fel exe 0x4a000000 +$ sunxi-fel exe 0x4a000000
On your board, you'll now have all the needed binaries into RAM, so you only need to erase the NAND...
-nand erase.chip +$ nand erase.chip
Then write the SPL and its backup:
-nand write.raw.noverify 0x43000000 0 40 -nand write.raw.noverify 0x43000000 0x400000 40 +$ nand write.raw.noverify 0x43000000 0 40 +$ nand write.raw.noverify 0x43000000 0x400000 40
And finally write the U-Boot binary: -nand write 0x4a000000 0x800000 0xc0000 +$ nand write 0x4a000000 0x800000 0xc0000
-You can now reboot and enjoy your NAND. \ No newline at end of file +You can now reboot and enjoy your NAND. diff --git a/board/sunxi/README.sunxi64 b/board/sunxi/README.sunxi64 index bba2e01..63cd8bb 100644 --- a/board/sunxi/README.sunxi64 +++ b/board/sunxi/README.sunxi64 @@ -32,9 +32,10 @@ to build it first. Checkout the "allwinner" branch from the github repository [1] and build it: $ export CROSS_COMPILE=aarch64-linux-gnu- $ make PLAT=sun50iw1p1 DEBUG=1 bl31
The resulting binary is build/sun50iw1p1/debug/bl31.bin. Either put the location of this file into the BL31 environment variable or copy this to -the root of your U-Boot build directory (or create a symbolic link). +the root of your U-Boot build directory (or create a symbolic link): $ export BL31=/src/arm-trusted-firmware/build/sun50iw1p1/debug/bl31.bin (adjust the actual path accordingly)
@@ -48,7 +49,8 @@ binaries in the firmware repository[3], purely for convenience reasons.
Both U-Boot proper and the SPL are using the 64-bit mode. As the boot ROM enters the SPL still in AArch32 secure SVC mode, there is some shim code to -enter AArch64 very early. The rest of the SPL runs in AArch64 EL3. +enter AArch64 very early. The rest of the SPL runs in AArch64 EL3 mode.
U-Boot proper runs in EL2 and can load any AArch64 code (using the "go" command), EFI applications (with "bootefi") or arm64 Linux kernel images (often named "Image"), using the "booti" command. @@ -95,15 +97,15 @@ feature is disabled in the configuration at the moment. microSD card
Transfer the SPL and the U-Boot FIT image directly to an uSD card: -# dd if=spl/sunxi-spl.bin of=/dev/sdx bs=8k seek=1 -# dd if=u-boot.itb of=/dev/sdx bs=8k seek=5 -# sync +$ dd if=spl/sunxi-spl.bin of=/dev/sdx bs=8k seek=1 +$ dd if=u-boot.itb of=/dev/sdx bs=8k seek=5 +$ sync
Usually, these will need to be run as root, hence the #.
Looks good otherwise.
Maxime

Signed-off-by: Priit Laes plaes@plaes.org --- board/sunxi/README.nand | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/board/sunxi/README.nand b/board/sunxi/README.nand index 77a8c7d..dac603c 100644 --- a/board/sunxi/README.nand +++ b/board/sunxi/README.nand @@ -20,9 +20,9 @@ pages. In order to accomodate that, we create a tool that will generate an SPL image that is ready to be programmed directly embedding the ECCs, randomized, and with the necessary bits needed to reduce the number of -bitflips. The U-Boot build system, when configured for the NAND will -also generate the image sunxi-spl-with-ecc.bin that will have been -generated by that tool. +bitflips. The U-Boot build system, when configured for the NAND (with +CONFIG_NAND=y) will also generate the image sunxi-spl-with-ecc.bin +that will have been generated by that tool.
In order to flash your U-Boot image onto a board, assuming that the board is in FEL mode, you'll need the sunxi-tools that you can find at

On Tue, Oct 23, 2018 at 08:20:30PM +0300, Priit Laes wrote:
Signed-off-by: Priit Laes plaes@plaes.org
Acked-by: Maxime Ripard maxime.ripard@bootlin.com
Maxime

On Tue, Oct 23, 2018 at 10:51 PM Priit Laes plaes@plaes.org wrote:
Signed-off-by: Priit Laes plaes@plaes.org
Applied to u-boot-sunxi/master

sunxi_rgb2yuv_coef is readonly and never modified.
Signed-off-by: Priit Laes plaes@plaes.org --- drivers/video/sunxi/sunxi_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/sunxi/sunxi_display.c b/drivers/video/sunxi/sunxi_display.c index 5c8f88c..6dd9bec 100644 --- a/drivers/video/sunxi/sunxi_display.c +++ b/drivers/video/sunxi/sunxi_display.c @@ -460,7 +460,7 @@ static void sunxi_composer_init(void) setbits_le32(&de_be->mode, SUNXI_DE_BE_MODE_ENABLE); }
-static u32 sunxi_rgb2yuv_coef[12] = { +static const u32 sunxi_rgb2yuv_coef[12] = { 0x00000107, 0x00000204, 0x00000064, 0x00000108, 0x00003f69, 0x00003ed6, 0x000001c1, 0x00000808, 0x000001c1, 0x00003e88, 0x00003fb8, 0x00000808

On Tue, 23 Oct 2018 20:20:31 +0300 Priit Laes plaes@plaes.org wrote:
sunxi_rgb2yuv_coef is readonly and never modified.
Signed-off-by: Priit Laes plaes@plaes.org
Acked-by: Anatolij Gustschin agust@denx.de

On Tue, Oct 23, 2018 at 08:20:31PM +0300, Priit Laes wrote:
sunxi_rgb2yuv_coef is readonly and never modified.
Signed-off-by: Priit Laes plaes@plaes.org
Acked-by: Maxime Ripard maxime.ripard@bootlin.com
Thanks! Maxime

On Tue, Oct 23, 2018 at 10:51 PM Priit Laes plaes@plaes.org wrote:
sunxi_rgb2yuv_coef is readonly and never modified.
Signed-off-by: Priit Laes plaes@plaes.org
Applied to u-boot-sunxi/master

From: Priit Laes priit.laes@paf.com
Signed-off-by: Priit Laes plaes@plaes.org --- board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+) create mode 100644 board/sunxi/README.fastboot
diff --git a/board/sunxi/README.fastboot b/board/sunxi/README.fastboot new file mode 100644 index 0000000..470fa6f --- /dev/null +++ b/board/sunxi/README.fastboot @@ -0,0 +1,98 @@ +Using fastboot on sunxi devices +=============================== + +Fastboot is a diagnostic protocol, primarily used to modify the +filesystems on the flash device via USB or UDP. It requires that +the device is started in a boot loader or Seconday Boot Loader mode. + +This document currently walks through an installation with a device +with eMMC storage. + +Prerequisites +------------- + +* fastboot binaries installed on client machine +* sunxi-tools installed on client machine (optional) +* u-boot tools (mkimage) +* u-boot binaries for the target sunxi device +* filesystem images + * root file system containing operating system + * vfat file system +* Sunxi device connected to client via OTG port + +Getting your device into Fastboot mode +-------------------------------------- + +To enter into fastboot mode, execute the `fastboot` command in +U-Boot: + +$ fastboot usb 0 + +On the client machine, you can check whether the device is visible +using the `fastboot devices` command. And for fun, you can also +fetch the bootloader version using the fastboot protocol: + +$ fastboot devices +1234567890abcdef fastboot +$ fastboot getvar bootloader-version +bootloader-version: U-Boot 2018.11-rc2-00033-ge3beca3a2f +finished. total time: 0.000s + +Preparing the device for flashing +--------------------------------- + +Now that the device is in the fastboot mode, we can continue with +creating the partitions on the device. By default, u-boot for sunxi +defines following partitions: + +* loader1 - partition for secondary program loader +* loader2 - partition for u-boot +* esp - EFI system partition, also used for u-boot to look up boot.scr +* system - Root partition for system + +These partitions have also assigned GUID's according to Discoverable +Partitions Specification [1], to enable automatic discovery of partitions +and their mountpoints. + +You can start by formatting the internal storage by executing the +`fastboot oem format` command from client: + +$ fastboot oem format + +This equivalent to running the `gpt write mmc 1 $partitions` from u-boot. + +[1] https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/ + +Flashing the device +------------------- + +Now that we have the partitions created, all that is left for us +is to flash the data. + +`loader1` is used for storing the Seconday Program Loader, in our +case, it is the `spl/sunxi-spl.bin` in the u-boot directory: + +$ fastboot flash loader1 spl/sunxi-spl.bin + +`loader2` is for storing the u-boot binary. `u-boot.img` in the +u-boot source directory: + +$ fastboot flash loader2 u-boot.img + +`esp` partition (EFI System Partition) can be kept empty, although +if it is VFAT partition, u-boot automatically looks up the `boot.scr` +file for device-specific configuration. (You can create empty vfat +partition by `fallocate -l 32M esp.img && mkfs.vfat esp.img`) + +$ fastboot flash esp esp.img + +`system` partition is where the operating system resides. Creating +that is left as an exercise to the reader. + +$ fastboot flash system system.img + +Now, if everything has been properly set up (aka proper kernel +with machine-specific dtb installed on system.img, and boot.scr +on esp partition), you can reboot the machine: + +$ fastboot reboot

Hi Priit,
On Wed, 24 Oct 2018 at 04:21, Priit Laes plaes@plaes.org wrote:
From: Priit Laes priit.laes@paf.com
Signed-off-by: Priit Laes plaes@plaes.org
board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+) create mode 100644 board/sunxi/README.fastboot
diff --git a/board/sunxi/README.fastboot b/board/sunxi/README.fastboot new file mode 100644 index 0000000..470fa6f --- /dev/null +++ b/board/sunxi/README.fastboot @@ -0,0 +1,98 @@ +Using fastboot on sunxi devices +===============================
+Fastboot is a diagnostic protocol, primarily used to modify the +filesystems on the flash device via USB or UDP. It requires that +the device is started in a boot loader or Seconday Boot Loader mode.
"Seconday" -> "Secondary"
+This document currently walks through an installation with a device +with eMMC storage.
+Prerequisites +-------------
+* fastboot binaries installed on client machine +* sunxi-tools installed on client machine (optional) +* u-boot tools (mkimage) +* u-boot binaries for the target sunxi device +* filesystem images
- root file system containing operating system
- vfat file system
+* Sunxi device connected to client via OTG port
+Getting your device into Fastboot mode +--------------------------------------
+To enter into fastboot mode, execute the `fastboot` command in +U-Boot:
+$ fastboot usb 0
+On the client machine, you can check whether the device is visible +using the `fastboot devices` command. And for fun, you can also +fetch the bootloader version using the fastboot protocol:
+$ fastboot devices +1234567890abcdef fastboot +$ fastboot getvar bootloader-version +bootloader-version: U-Boot 2018.11-rc2-00033-ge3beca3a2f +finished. total time: 0.000s
+Preparing the device for flashing +---------------------------------
+Now that the device is in the fastboot mode, we can continue with +creating the partitions on the device. By default, u-boot for sunxi +defines following partitions:
+* loader1 - partition for secondary program loader +* loader2 - partition for u-boot +* esp - EFI system partition, also used for u-boot to look up boot.scr +* system - Root partition for system
+These partitions have also assigned GUID's according to Discoverable +Partitions Specification [1], to enable automatic discovery of partitions +and their mountpoints.
+You can start by formatting the internal storage by executing the +`fastboot oem format` command from client:
+$ fastboot oem format
+This equivalent to running the `gpt write mmc 1 $partitions` from u-boot.
+[1] https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/
+Flashing the device +-------------------
+Now that we have the partitions created, all that is left for us +is to flash the data.
+`loader1` is used for storing the Seconday Program Loader, in our +case, it is the `spl/sunxi-spl.bin` in the u-boot directory:
"Seconday" -> "Secondary"
+$ fastboot flash loader1 spl/sunxi-spl.bin
+`loader2` is for storing the u-boot binary. `u-boot.img` in the +u-boot source directory:
+$ fastboot flash loader2 u-boot.img
+`esp` partition (EFI System Partition) can be kept empty, although +if it is VFAT partition, u-boot automatically looks up the `boot.scr` +file for device-specific configuration. (You can create empty vfat +partition by `fallocate -l 32M esp.img && mkfs.vfat esp.img`)
+$ fastboot flash esp esp.img
+`system` partition is where the operating system resides. Creating +that is left as an exercise to the reader.
+$ fastboot flash system system.img
+Now, if everything has been properly set up (aka proper kernel +with machine-specific dtb installed on system.img, and boot.scr +on esp partition), you can reboot the machine:
+$ fastboot reboot
git-series 0.9.1
-- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Regards, Jonathan

On Tue, Oct 23, 2018 at 08:20:32PM +0300, Priit Laes wrote:
From: Priit Laes priit.laes@paf.com
Signed-off-by: Priit Laes plaes@plaes.org
board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+) create mode 100644 board/sunxi/README.fastboot
diff --git a/board/sunxi/README.fastboot b/board/sunxi/README.fastboot new file mode 100644 index 0000000..470fa6f --- /dev/null +++ b/board/sunxi/README.fastboot @@ -0,0 +1,98 @@ +Using fastboot on sunxi devices +===============================
+Fastboot is a diagnostic protocol, primarily used to modify the +filesystems on the flash device via USB or UDP. It requires that +the device is started in a boot loader or Seconday Boot Loader mode.
+This document currently walks through an installation with a device +with eMMC storage.
+Prerequisites +-------------
+* fastboot binaries installed on client machine +* sunxi-tools installed on client machine (optional) +* u-boot tools (mkimage) +* u-boot binaries for the target sunxi device +* filesystem images
- root file system containing operating system
- vfat file system
+* Sunxi device connected to client via OTG port
+Getting your device into Fastboot mode +--------------------------------------
+To enter into fastboot mode, execute the `fastboot` command in +U-Boot:
+$ fastboot usb 0
+On the client machine, you can check whether the device is visible +using the `fastboot devices` command. And for fun, you can also +fetch the bootloader version using the fastboot protocol:
+$ fastboot devices +1234567890abcdef fastboot +$ fastboot getvar bootloader-version +bootloader-version: U-Boot 2018.11-rc2-00033-ge3beca3a2f +finished. total time: 0.000s
+Preparing the device for flashing +---------------------------------
+Now that the device is in the fastboot mode, we can continue with +creating the partitions on the device. By default, u-boot for sunxi +defines following partitions:
+* loader1 - partition for secondary program loader +* loader2 - partition for u-boot +* esp - EFI system partition, also used for u-boot to look up boot.scr +* system - Root partition for system
+These partitions have also assigned GUID's according to Discoverable +Partitions Specification [1], to enable automatic discovery of partitions +and their mountpoints.
+You can start by formatting the internal storage by executing the +`fastboot oem format` command from client:
+$ fastboot oem format
+This equivalent to running the `gpt write mmc 1 $partitions` from u-boot.
Now that I used this approach with clean devices, I discovered an issue where after `oem format`, the fastboot does not recognize the partitions:
$ fastboot flash loader1 data/sunxi-spl.bin target reported max download size of 33554432 bytes sending 'loader1' (24 KB)... OKAY [ 0.008s] writing 'loader1'... FAILED (remote: cannot find partition)
I had to run following in the u-boot shell:
=> mmc dev 1 switch to partitions #0, OK mmc1(part 0) is current device => mmc part [..skipped the list of correct partition printout..] => fastboot usb 0 ...
And then flashing from the host worked.
Any hints where to look to properly fix it?
+[1] https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/
+Flashing the device +-------------------
+Now that we have the partitions created, all that is left for us +is to flash the data.
+`loader1` is used for storing the Seconday Program Loader, in our +case, it is the `spl/sunxi-spl.bin` in the u-boot directory:
+$ fastboot flash loader1 spl/sunxi-spl.bin
+`loader2` is for storing the u-boot binary. `u-boot.img` in the +u-boot source directory:
+$ fastboot flash loader2 u-boot.img
+`esp` partition (EFI System Partition) can be kept empty, although +if it is VFAT partition, u-boot automatically looks up the `boot.scr` +file for device-specific configuration. (You can create empty vfat +partition by `fallocate -l 32M esp.img && mkfs.vfat esp.img`)
+$ fastboot flash esp esp.img
+`system` partition is where the operating system resides. Creating +that is left as an exercise to the reader.
+$ fastboot flash system system.img
+Now, if everything has been properly set up (aka proper kernel +with machine-specific dtb installed on system.img, and boot.scr +on esp partition), you can reboot the machine:
+$ fastboot reboot
git-series 0.9.1

On Tue, Oct 23, 2018 at 08:20:32PM +0300, Priit Laes wrote:
From: Priit Laes priit.laes@paf.com
Signed-off-by: Priit Laes plaes@plaes.org
I don't have a particular objection to the documentation itself, except that most of it isn't specific to the sunxi platform, but is entirely generic, and should be documented in a generic place.
Maxime

On Wed, Oct 24, 2018 at 05:34:12PM +0100, Maxime Ripard wrote:
On Tue, Oct 23, 2018 at 08:20:32PM +0300, Priit Laes wrote:
From: Priit Laes priit.laes@paf.com
Signed-off-by: Priit Laes plaes@plaes.org
I don't have a particular objection to the documentation itself, except that most of it isn't specific to the sunxi platform, but is entirely generic, and should be documented in a generic place.
Indeed.
I guess mentioning which binary goes to which partition is enough, and eveything else I can put to linux-sunxi wiki.
Maxime
-- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
-- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.

On Tue, Oct 23, 2018 at 10:51 PM Priit Laes plaes@plaes.org wrote:
From: Priit Laes priit.laes@paf.com
Signed-off-by: Priit Laes plaes@plaes.org
board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+) create mode 100644 board/sunxi/README.fastboot
diff --git a/board/sunxi/README.fastboot b/board/sunxi/README.fastboot
We have enough documentation about fastboot in other platforms, people easily explore the changes wrt sunxi if needed.

On Wed, Oct 24, 2018 at 10:06:05PM +0530, Jagan Teki wrote:
On Tue, Oct 23, 2018 at 10:51 PM Priit Laes plaes@plaes.org wrote:
From: Priit Laes priit.laes@paf.com
Signed-off-by: Priit Laes plaes@plaes.org
board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+) create mode 100644 board/sunxi/README.fastboot
diff --git a/board/sunxi/README.fastboot b/board/sunxi/README.fastboot
We have enough documentation about fastboot in other platforms, people easily explore the changes wrt sunxi if needed.
Well, if someone felt that it's worth writing a doc, maybe it's not so easy to find or understand and we should make the doc better?
Maxime
participants (5)
-
Anatolij Gustschin
-
Jagan Teki
-
Jonathan Liu
-
Maxime Ripard
-
Priit Laes