sunxi: doc: Add fastboot example + misc cleanups
cover 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
Signature · 1 line
git-series 0.9.1
PATCH 1/5 sunxi: Fix typos of spelling Allwinner
--- 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(-)
arch/arm/mach-sunxi/dram_sun4i.c +1 -1
@@ -5,7 +5,7 @@* (C) Copyright 2013 Luke Kenneth Casson Leighton <[email protected]> * * 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>
arch/arm/mach-sunxi/p2wi.c +1 -1
@@ -5,7 +5,7 @@* (C) Copyright 2013 Oliver Schinagl <[email protected]> * 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>
board/sunxi/README.sunxi64 +1 -1
@@ -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,
Signature · 1 line
git-series 0.9.1
PATCH 1/5 sunxi: Fix typos of spelling Allwinner
Quoted 1 line · Priit Laes
Signed-off-by Priit Laes <[email protected]>
Thanks!
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/5 sunxi: Fix typos of spelling Allwinner
In reply to Priit LaesQuoted 3 lines · Priit Laes
Signed-off-by Priit Laes <[email protected]>---
Applied to u-boot-sunxi/master
PATCH 2/5 sunxi: docs: Unify the formatting style and add some paragraph breaks
In reply to Priit Laes--- board/sunxi/README.nand | 18 +++++++++--------- board/sunxi/README.sunxi64 | 23 ++++++++++++++++------- 2 files changed, 25 insertions(+), 16 deletions(-)
board/sunxi/README.nand +9 -9
@@ -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. +You can now reboot and enjoy your NAND.
board/sunxi/README.sunxi64 +16 -7
@@ -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
Signature · 1 line
git-series 0.9.1
PATCH 2/5 sunxi: docs: Unify the formatting style and add some paragraph breaks
Quoted 74 lines · Priit Laes
Signed-off-by Priit Laes <[email protected]>--- board/sunxi/README.nand | 18 +++++++++--------- board/sunxi/README.sunxi64 | 23 ++++++++++++++++------- 2 files changed, 25 insertions(+), 16 deletions(-)board/sunxi/README.nand +9
-9@@ -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. +You can now reboot and enjoy your NAND.board/sunxi/README.sunxi64 +4
-2@@ -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.
board/sunxi/README.sunxi64 feature is disabled in the configuration at the moment. · line 102
Quoted 9 lines
board/sunxi/README.sunxi64 +3
-3@@ -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
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 3/5 sunxi: docs: Mention CONFIG_NAND requirement
In reply to Priit Laes--- board/sunxi/README.nand | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
board/sunxi/README.nand +3 -3
@@ -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
Signature · 1 line
git-series 0.9.1
PATCH 3/5 sunxi: docs: Mention CONFIG_NAND requirement
Quoted 1 line · Priit Laes
Signed-off-by Priit Laes <[email protected]>
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 3/5 sunxi: docs: Mention CONFIG_NAND requirement
In reply to Priit LaesQuoted 3 lines · Priit Laes
Signed-off-by Priit Laes <[email protected]>---
Applied to u-boot-sunxi/master
PATCH 4/5 sunxi: display: Mark sunxi_rgb2yuv_coef array as const
In reply to Priit Laessunxi_rgb2yuv_coef is readonly and never modified.
--- drivers/video/sunxi/sunxi_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/sunxi/sunxi_display.c +1 -1
@@ -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
Signature · 1 line
git-series 0.9.1
PATCH 4/5 sunxi: display: Mark sunxi_rgb2yuv_coef array as const
Quoted 3 lines · On Tue, 23 Oct 2018 20:20:31 +0300 Priit Laes plaes at plaes.org wrote:
sunxi_rgb2yuv_coefis readonly and never modified.Signed-off-by Priit Laes <[email protected]>
PATCH 4/5 sunxi: display: Mark sunxi_rgb2yuv_coef array as const
In reply to Priit LaesQuoted 3 lines · Priit Laes
sunxi_rgb2yuv_coefis readonly and never modified.Signed-off-by Priit Laes <[email protected]>
Thanks!
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 4/5 sunxi: display: Mark sunxi_rgb2yuv_coef array as const
In reply to Priit LaesQuoted 5 lines · Priit Laes
sunxi_rgb2yuv_coefis readonly and never modified.Signed-off-by Priit Laes <[email protected]>---
Applied to u-boot-sunxi/master
PATCH 5/5 sunxi: doc: Add basic fastboot example
In reply to Priit LaesFrom: Priit Laes <[email protected]>
--- board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+) create mode 100644 board/sunxi/README.fastboot
board/sunxi/README.fastboot new file +98 -0
@@ -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
Signature · 1 line
git-series 0.9.1
PATCH 5/5 sunxi: doc: Add basic fastboot example
Hi Priit,
Quoted 15 lines · Priit Laes
From: Priit Laes <[email protected]>
Signed-off-by Priit Laes <[email protected]>--- board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+) create mode 100644 board/sunxi/README.fastbootboard/sunxi/README.fastboot new file +0
-0
board/sunxi/README.fastboot line 6
Quoted 7 lines
board/sunxi/README.fastboot new file +6
-0@@ -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"
Quoted 58 lines
board/sunxi/README.fastboot new file +58
-0+ +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/
board/sunxi/README.fastboot line 73
Quoted 10 lines
board/sunxi/README.fastboot new file +9
-0+ +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"
Quoted 28 lines
board/sunxi/README.fastboot new file +25
-1+ +$ 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
Quoted 4 lines
--
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 at googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Regards,
Jonathan
PATCH 5/5 sunxi: doc: Add basic fastboot example
In reply to Priit LaesQuoted 66 lines · Priit Laes
From: Priit Laes <[email protected]>
Signed-off-by Priit Laes <[email protected]>--- board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+) create mode 100644 board/sunxi/README.fastbootboard/sunxi/README.fastboot new file +52
-0@@ -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 +
board/sunxi/README.fastboot line 62
Quoted 10 lines
board/sunxi/README.fastboot new file +10
-0+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?
Quoted 38 lines
board/sunxi/README.fastboot new file +36
-0+ +[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 rebootSignature · 1 line
git-series 0.9.1
PATCH 5/5 sunxi: doc: Add basic fastboot example
In reply to Priit LaesQuoted 3 lines · Priit Laes
From: Priit Laes <[email protected]>
Signed-off-by Priit Laes <[email protected]>
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
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
[U-Boot] [linux-sunxi] Re: [PATCH 5/5] sunxi: doc: Add basic fastboot example
Quoted 8 lines · Maxime Ripard
Quoted 3 lines · Priit Laes
From: Priit Laes <[email protected]>
Signed-off-by Priit Laes <[email protected]>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.
Quoted 12 lines
Maxime
Signature · 8 lines
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 at googlegroups.com. For more options, visit https://groups.google.com/d/optout.
PATCH 5/5 sunxi: doc: Add basic fastboot example
In reply to Priit Laesboard/sunxi/README.fastboot
Quoted 10 lines · Priit Laes
From: Priit Laes <[email protected]>
Signed-off-by Priit Laes <[email protected]>--- board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+) create mode 100644 board/sunxi/README.fastbootboard/sunxi/README.fastboot +0
-0
We have enough documentation about fastboot in other platforms, people easily explore the changes wrt sunxi if needed.
PATCH 5/5 sunxi: doc: Add basic fastboot example
Quoted 10 lines · Jagan Teki
Quoted 9 lines · Priit Laes
From: Priit Laes <[email protected]>
Signed-off-by Priit Laes <[email protected]>--- board/sunxi/README.fastboot | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+) create mode 100644 board/sunxi/README.fastboot
Quoted 4 lines
board/sunxi/README.fastboot
Quoted 1 line
board/sunxi/README.fastboot +0
-0We 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
Signature · 10 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 228 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181024/676747b4/attachment.sig>