Skip to contentSkip to conversation

Initial attempt at flashing instructions.

PATCH Applied [email protected] 2 participants 6 messages Jun 29, 2017

lore
Share & tools
lore
#0 lore raw

v3 cover Initial attempt at flashing instructions.

From: Drew Moseley <[email protected]>

* V3:

Cleanup README.

Add CHIP_UBI_PAGE_SIZE variable to reuse the data from the machine configuration.

* V2:

Updated README and layer dependencies.

Added error checking to flashing script

* V1:

This set of patches adds the native tools and target components needed to reflash the CHIP boards. Additionally a shell script is added to the deploy directory showing how to kick off a flash update. It's not ideal as I've hardcoded a max size for the UBI image into the script and didn't see much of an alternative. It does function though.

Drew

The following changes since commit 0079e6ac10fc371d6f527270c23b887561f717aa:

chip: Append to MACHINE_EXTRA_RRECOMMENDS rather than overwriting (2017-06-15 13:37:19 +0100)

are available in the git repository at:

[email protected]:drewmoseley/meta-chip.git flashing-instructions-v3

for you to fetch changes up to 69920ec23cef400687a2a8c1ab1a825a911278d2:

chip: Add chip-u-boot-scr recipe and flash script (2017-06-28 19:06:01 -0400)

----------------------------------------------------------------
Drew Moseley (4):
chip: Make page size into a variable.
u-boot-chip: Deploy the sunxi-spl-with-ecc.bin file.
chip: Build sunxi-tools-native.
chip: Add chip-u-boot-scr recipe and flash script

 README                                          | 94 ++++++++++++++++++++++++-
 conf/layer.conf                                 |  3 +
 conf/machine/chip.conf                          |  8 ++-
 recipes-bsp/chip-u-boot-scr/chip-u-boot-scr.bb  | 89 +++++++++++++++++++++++
 recipes-bsp/chip-u-boot-scr/files/boot.cmd.full | 32 +++++++++
 recipes-bsp/chip-u-boot-scr/files/boot.cmd.in   | 43 +++++++++++
 recipes-bsp/u-boot/u-boot-chip_git.bb           |  7 ++
 7 files changed, 272 insertions(+), 4 deletions(-)
 create mode 100644 recipes-bsp/chip-u-boot-scr/chip-u-boot-scr.bb
 create mode 100644 recipes-bsp/chip-u-boot-scr/files/boot.cmd.full
 create mode 100644 recipes-bsp/chip-u-boot-scr/files/boot.cmd.in

Drew Moseley (4):
chip: Make page size into a variable.
u-boot-chip: Deploy the sunxi-spl-with-ecc.bin file.
chip: Build sunxi-tools-native.
chip: Add chip-u-boot-scr recipe and flash script

 README                                          | 94 ++++++++++++++++++++++++-
 conf/layer.conf                                 |  3 +
 conf/machine/chip.conf                          |  8 ++-
 recipes-bsp/chip-u-boot-scr/chip-u-boot-scr.bb  | 89 +++++++++++++++++++++++
 recipes-bsp/chip-u-boot-scr/files/boot.cmd.full | 32 +++++++++
 recipes-bsp/chip-u-boot-scr/files/boot.cmd.in   | 43 +++++++++++
 recipes-bsp/u-boot/u-boot-chip_git.bb           |  7 ++
 7 files changed, 272 insertions(+), 4 deletions(-)
 create mode 100644 recipes-bsp/chip-u-boot-scr/chip-u-boot-scr.bb
 create mode 100644 recipes-bsp/chip-u-boot-scr/files/boot.cmd.full
 create mode 100644 recipes-bsp/chip-u-boot-scr/files/boot.cmd.in
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/4 chip: Make page size into a variable.

From: Drew Moseley <[email protected]>

---
 conf/machine/chip.conf | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
conf/machine/chip.conf +3 -2
index 0a45a2f..dad1bdb 100644
@@ -30,5 +30,6 @@ MACHINE_FEATURES = "usbgadget usbhost wifi"
 MACHINE_EXTRA_RRECOMMENDS += "kernel-module-r8723bs rtl8723bs"
 
 UBI_VOLNAME = "rootfs"
-MKUBIFS_ARGS = "--min-io-size 16384 --leb-size 2064384 --max-leb-cnt 2000"
-UBINIZE_ARGS = "--min-io-size 16384 --peb-size 2097152 --sub-page-size 16384"
+CHIP_UBI_PAGE_SIZE = "16384"
+MKUBIFS_ARGS = "--min-io-size ${CHIP_UBI_PAGE_SIZE} --leb-size 2064384 --max-leb-cnt 2000"
+UBINIZE_ARGS = "--min-io-size ${CHIP_UBI_PAGE_SIZE} --peb-size 2097152 --sub-page-size 16384"
Signature · 1 line
2.7.4
#2 lore raw

PATCH v3 2/4 u-boot-chip: Deploy the sunxi-spl-with-ecc.bin file.

In reply to [email protected]

From: Drew Moseley <[email protected]>

---
 conf/machine/chip.conf                | 1 +
 recipes-bsp/u-boot/u-boot-chip_git.bb | 6 ++++++
 2 files changed, 7 insertions(+)
conf/machine/chip.conf +1 -0
index dad1bdb..f053976 100644
@@ -21,6 +21,7 @@ KERNEL_IMAGETYPE = "zImage"
 KERNEL_DEVICETREE = "sun5i-r8-chip.dtb"
 
 SPL_BINARY = "sunxi-spl.bin"
+SPL_ECC_BINARY = "sunxi-spl-with-ecc.bin"
 UBOOT_BINARY = "u-boot-dtb.bin"
 UBOOT_MACHINE = "CHIP_defconfig"
 
recipes-bsp/u-boot/u-boot-chip_git.bb +6 -0
index 8e2be50..6de2e9d 100644
@@ -19,7 +19,13 @@ SRC_URI = " \
 S = "${WORKDIR}/git"
 
 do_compile_append() {
+    install ${B}/spl/${SPL_ECC_BINARY} ${B}/${SPL_ECC_BINARY}
     install ${B}/spl/${SPL_BINARY} ${B}/${SPL_BINARY}
 }
 
 COMPATIBLE_MACHINE = "chip"
+
+do_deploy_append() {
+    install -m 644 ${B}/${SPL_ECC_BINARY} ${DEPLOYDIR}/${SPL_ECC_BINARY}-${PV}-${PR}
+    ln -sf ${SPL_ECC_BINARY}-${PV}-${PR} ${DEPLOYDIR}/${SPL_ECC_BINARY}
+}
Signature · 1 line
2.7.4
#3 lore raw

PATCH v3 3/4 chip: Build sunxi-tools-native.

In reply to [email protected]

From: Drew Moseley <[email protected]>

Add LAYERDEPENDS on meta-sunxi and add the sunxi-tools-native pacakage to EXTRA_IMAGEDEPENDS.

---
 README                 | 3 +++
 conf/layer.conf        | 3 +++
 conf/machine/chip.conf | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)
README +3 -0
index cccf59e..32f70b2 100644
@@ -14,6 +14,9 @@ This layer depends on:
   layers: meta
   branch: master
 
+  URI: git://github.com/linux-sunxi/meta-sunxi.git
+  branch: master
+
 
 Patches
 =======
conf/layer.conf +3 -0
index 5dad66e..1f34ea0 100644
@@ -8,3 +8,6 @@ BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
 BBFILE_COLLECTIONS += "meta-chip"
 BBFILE_PATTERN_meta-chip = "^${LAYERDIR}/"
 BBFILE_PRIORITY_meta-chip = "6"
+
+# Add this to get access to sunxi-tools recipe
+LAYERDEPENDS_meta-chip = "meta-sunxi"
conf/machine/chip.conf +1 -1
index f053976..ff5a213 100644
@@ -5,7 +5,7 @@
 MACHINE_EXTRA_RRECOMMENDS = " kernel-modules"
 MACHINE_ESSENTIAL_EXTRA_RDEPENDS = " kernel-image kernel-devicetree"
 
-EXTRA_IMAGEDEPENDS += "u-boot"
+EXTRA_IMAGEDEPENDS += "u-boot sunxi-tools-native"
 
 DEFAULTTUNE ?= "cortexa8t-neon"
 include conf/machine/include/tune-cortexa8.inc
Signature · 1 line
2.7.4
#4 lore raw

PATCH v3 4/4 chip: Add chip-u-boot-scr recipe and flash script

In reply to [email protected]

From: Drew Moseley <[email protected]>

Add a U-Boot script to handle flashing the SPL, U-Boot and UBI root filesystem images into the onboard flash. Also generate a script showing how to execute the flash steps.

---
 README                                          | 91 ++++++++++++++++++++++++-
 recipes-bsp/chip-u-boot-scr/chip-u-boot-scr.bb  | 89 ++++++++++++++++++++++++
 recipes-bsp/chip-u-boot-scr/files/boot.cmd.full | 32 +++++++++
 recipes-bsp/chip-u-boot-scr/files/boot.cmd.in   | 43 ++++++++++++
 recipes-bsp/u-boot/u-boot-chip_git.bb           |  1 +
 5 files changed, 255 insertions(+), 1 deletion(-)
 create mode 100644 recipes-bsp/chip-u-boot-scr/chip-u-boot-scr.bb
 create mode 100644 recipes-bsp/chip-u-boot-scr/files/boot.cmd.full
 create mode 100644 recipes-bsp/chip-u-boot-scr/files/boot.cmd.in
README +90 -1
index 32f70b2..9fc1dd1 100644
@@ -62,4 +62,93 @@ To build a machine supported by this BSP layer follow the next steps:
 II. Flashing a C.H.I.P. board
 ========================================
 
-<TODO>
+As part of the build including this BSP layer, a U-Boot script and a
+shell script are created to assist in flashing your images to the CHIP
+board. Note that this script assumes a maximum size for your UBI
+image of 167772160 (0x0A000000) bytes. If your UBI image exceeds
+that, then you will need to adapt this to your environment.
+
+To successfully run this script you will first need to set your board
+into FEL mode. Insert a wire into the U14 header between pin 7 (FEL)
+and GND. Then connect the board with a USB cable to your host. More
+details here:
+    https://docs.getchip.com/chip.html#flash-chip-with-an-os
+
+You need to specify the base filename of your UBI image using the
+UBI_IMAGE shell variable before invoking the generated script as
+follows:
+
+# UBI_IMAGE=chip-hwup-image-chip.ubi \
+        ./tmp/deploy/images/chip/flash_CHIP_board.sh
+
+This script will take some time to execute. The output of this script
+as run on your host machine should look similar to the following:
+
+    # UBI_IMAGE=chip-hwup-image-chip.ubi ./tmp/deploy/images/chip/flash_CHIP_board.sh
+    100% [================================================]  3537 kB,  513.9 kB/s
+    100% [================================================]   619 kB,  551.1 kB/s
+    100% [================================================]     2 kB,  476.0 kB/s
+    100% [================================================] 71303 kB,  531.1 kB/s
+
+If you have a serial console connected to your board, you will see
+progress and a message on the console indicating when flashing is
+complete:
+
+    U-Boot 2016.01 (Jun 20 2017 - 02:54:42 -0400) Allwinner Technology
+    
+    CPU:   Allwinner A13 (SUN5I)
+    I2C:   ready
+    DRAM:  512 MiB
+    NAND:  8192 MiB
+    video-mode 720x480-24@60 not available, falling back to 1024x768-24@60
+    Setting up a 720x480i composite-ntsc console (overscan 40x20)
+    In:    serial
+    Out:   serial
+    Err:   serial
+    Net:   usb_ether
+    starting USB...
+    No controllers found
+    Hit any key to stop autoboot:  0
+    (FEL boot)
+    ## Executing script at 43100000
+    Erasing NAND
+    
+    NAND erase.chip: device 0 whole chip
+    Skipping bad block at  0xeb000000
+    Skipping bad block at  0x1b1000000
+    Erasing at 0x1ffc00000 -- 100% complete.
+    OK
+    Writing SPL (with ECC) to NAND address 0x00000000
+    
+    NAND write:  3537408 bytes written: OK
+    Writing SPL (with ECC) to NAND address 0x400000
+    
+    NAND write:  3537408 bytes written: OK
+    Writing UBoot image to address 0x800000
+    
+    NAND write: device 0 offset 0x800000, size 0x97236
+     619062 bytes written: OK
+    Enabling Splash
+    Setting Video Mode
+    Saving default environment
+    Saving Environment to NAND...
+    Erasing NAND...
+    Erasing at 0xc00000 -- 100% complete.
+    Writing to NAND... OK
+    Writing UBI rootfs to NAND address 0x1000000
+    
+    NAND write: device 0 offset 0x1000000, size 0xa000000
+     167772160 bytes written: OK
+    ===========================================================
+    Flashing Complete. Please power down and disable FEL mode.
+    ===========================================================
+
+Additionally, once the image is properly flashed, the status LED on
+the CHIP board will flash on and off every 2 seconds. This indicates
+that it is safe to power down your board and disable FEL mode.
+
+WARNING: This will erase the entire contents of your CHIP board.
+
+NOTE: This setup is still compatible with the CHIP flashing utility
+available at http://flash.getchip.com if you choose to reinstall the
+stock images.
recipes-bsp/chip-u-boot-scr/chip-u-boot-scr.bb new file +89 -0

89 lines not on this page · raw message

recipes-bsp/chip-u-boot-scr/files/boot.cmd.full new file +32 -0
new file mode 100644
index 0000000..9589c87
@@ -0,0 +1,32 @@
+echo Scrubbing NAND
+nand scrub -y 0x0 0x200000000
+echo Writing SPL (with ECC) to NAND address 0x0
+nand write.raw.noverify $SPL_MEM_ADDR 0x0 $PADDED_SPL_SIZE
+echo Writing SPL (with ECC) to NAND address 0x400000
+nand write.raw.noverify $SPL_MEM_ADDR 0x400000 $PADDED_SPL_SIZE
+echo Writing UBoot image to address 0x800000
+nand write $UBOOT_MEM_ADDR 0x800000 $PADDED_UBOOT_SIZE
+
+# Setup the default environment
+setenv bootargs root=ubi0:rootfs rootfstype=ubifs rw earlyprintk ubi.mtd=4
+setenv bootcmd 'mtdparts; ubi part UBI; ubifsmount ubi0:rootfs; ubifsload \$fdt_addr_r /boot/sun5i-r8-chip.dtb; ubifsload \$kernel_addr_r /boot/zImage; bootz \$kernel_addr_r - \$fdt_addr_r'
+setenv fel_booted 0
+
+echo Enabling Splash
+setenv stdout serial
+setenv stderr serial
+setenv splashpos m,m
+
+echo Setting Video Mode
+setenv video-mode sunxi:640x480-24@60,monitor=composite-ntsc,overscan_x=40,overscan_y=20
+
+echo Saving default environment
+saveenv
+
+echo Writing UBI rootfs to NAND address 0x1000000
+nand write.slc-mode.trimffs $UBI_MEM_ADDR 0x1000000 $UBI_SIZE
+
+echo ===========================================================
+echo Flashing Complete.  Please power down and disable FEL mode.
+echo ===========================================================
+
recipes-bsp/chip-u-boot-scr/files/boot.cmd.in new file +43 -0

43 lines not on this page · raw message

recipes-bsp/u-boot/u-boot-chip_git.bb +1 -0
index 6de2e9d..6f08654 100644
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://Licenses/README;md5=0507cd7da8e7ad6d6701926ec9b84c95"
 
 DEPENDS += "dtc-native"
 PROVIDES += "u-boot"
+RDEPENDS_${PN}_append_chip = " chip-u-boot-scr"
 
 UBOOT_VERSION ?= "2016.01"
 PV = "${UBOOT_VERSION}+git${SRCPV}"
Signature · 1 line
2.7.4