From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 12/14] scripts: sunxi: Build an raw SPL image
Date: Tue, 22 Nov 2016 17:20:24 +0100 [thread overview]
Message-ID: <58347048.3050908@denx.de> (raw)
In-Reply-To: <11c45bde0ca5204d34b0187144face033c006019.1479817585.git-series.maxime.ripard@free-electrons.com>
Hello Maxime,
Am 22.11.2016 um 13:38 schrieb Maxime Ripard:
> Introduce a new sunxi-spl-with-ecc.bin image with already the right header,
> ECC, randomizer and padding for the BROM to be able to read it.
>
> It needs to be flashed using a raw access to the NAND so that the
> controller doesn't change a thing to it, since we already have all the
> right parameters.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> Makefile | 3 ++-
> board/sunxi/README.nand | 54 ++++++++++++++++++++++++++++++++++++++++++-
> scripts/Makefile.spl | 15 ++++++++++++-
> 3 files changed, 72 insertions(+), 0 deletions(-)
> create mode 100644 board/sunxi/README.nand
Thanks for adding a README.
Reviewed-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
>
> diff --git a/Makefile b/Makefile
> index 37cbcb28f75e..12a248e297b5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1345,6 +1345,9 @@ spl/u-boot-spl: tools prepare \
> spl/sunxi-spl.bin: spl/u-boot-spl
> @:
>
> +spl/sunxi-spl-with-ecc.bin: spl/sunxi-spl.bin
> + @:
> +
> spl/u-boot-spl.sfp: spl/u-boot-spl
> @:
>
> diff --git a/board/sunxi/README.nand b/board/sunxi/README.nand
> new file mode 100644
> index 000000000000..a5d4ff0e90a3
> --- /dev/null
> +++ b/board/sunxi/README.nand
> @@ -0,0 +1,54 @@
> +Allwinner NAND flashing
> +=======================
> +
> +A lot of Allwinner devices, especially the older ones (pre-H3 era),
> +comes with a NAND. NANDs storages are a pretty weak choice when it
> +comes to the reliability, and it comes with a number of flaws like
> +read and write disturbs, data retention issues, bloks becoming
> +unusable, etc.
> +
> +In order to mitigate that, various strategies have been found to be
> +able to recover from those issues like ECC, hardware randomization,
> +and of course, redundancy for the critical parts.
> +
> +This is obviously something that we will take into account when
> +creating our images. However, the BROM will use a quite weird pattern
> +when accessing the NAND, and will access only at most 4kB per page,
> +which means that we also have to split that binary accross several
> +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.
> +
> +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
> +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
> +
> +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
> +
> +And execute U-Boot
> +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
> +
> +Then write the SPL and its backup:
> +
> +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
> +
> +You can now reboot and enjoy your NAND.
> \ No newline at end of file
> diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
> index e0b0117dc9b6..6a381f26d21a 100644
> --- a/scripts/Makefile.spl
> +++ b/scripts/Makefile.spl
> @@ -168,6 +168,10 @@ endif
>
> ifdef CONFIG_ARCH_SUNXI
> ALL-y += $(obj)/sunxi-spl.bin
> +
> +ifdef CONFIG_NAND_SUNXI
> +ALL-y += $(obj)/sunxi-spl-with-ecc.bin
> +endif
> endif
>
> ifeq ($(CONFIG_SYS_SOC),"at91")
> @@ -276,6 +280,17 @@ cmd_mksunxiboot = $(objtree)/tools/mksunxiboot $< $@
> $(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin FORCE
> $(call if_changed,mksunxiboot)
>
> +quiet_cmd_sunxi_spl_image_builder = SUNXI_SPL_IMAGE_BUILDER $@
> +cmd_sunxi_spl_image_builder = $(objtree)/tools/sunxi-spl-image-builder \
> + -c $(CONFIG_NAND_SUNXI_SPL_ECC_STRENGTH)/$(CONFIG_NAND_SUNXI_SPL_ECC_SIZE) \
> + -p $(CONFIG_SYS_NAND_PAGE_SIZE) \
> + -o $(CONFIG_SYS_NAND_OOBSIZE) \
> + -u $(CONFIG_NAND_SUNXI_SPL_USABLE_PAGE_SIZE) \
> + -e $(CONFIG_SYS_NAND_BLOCK_SIZE) \
> + -s -b $< $@
> +$(obj)/sunxi-spl-with-ecc.bin: $(obj)/sunxi-spl.bin
> + $(call if_changed,sunxi_spl_image_builder)
> +
> # Rule to link u-boot-spl
> # May be overridden by arch/$(ARCH)/config.mk
> quiet_cmd_u-boot-spl ?= LD $@
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2016-11-22 16:20 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-22 12:38 [U-Boot] [PATCH v2 0/14] sunxi: Add support for the CHIP Pro Maxime Ripard
2016-11-22 12:38 ` [U-Boot] [PATCH v2 1/14] nand: sunxi: Fix modulo by zero error Maxime Ripard
2016-11-22 12:43 ` Boris Brezillon
2017-01-04 22:11 ` Scott Wood
2016-11-22 12:38 ` [U-Boot] [PATCH v2 2/14] mtd: nand: add support for the TC58NVG2S0H chip Maxime Ripard
2016-11-22 12:38 ` [U-Boot] [PATCH v2 3/14] bch: Allow to build for the host Maxime Ripard
2016-11-22 15:12 ` Tom Rini
2016-11-25 17:05 ` Jagan Teki
2016-11-29 8:49 ` Maxime Ripard
2016-11-22 12:38 ` [U-Boot] [PATCH v2 4/14] tools: sunxi: Add spl image builder Maxime Ripard
2016-11-22 12:38 ` [U-Boot] [PATCH v2 5/14] common: Move environment choice to Kconfig Maxime Ripard
2016-11-22 15:17 ` Tom Rini
2016-11-22 12:38 ` [U-Boot] [PATCH v2 6/14] cmd: Add Kconfig option for CMD_MTDPARTS and related options Maxime Ripard
2016-11-22 15:14 ` Tom Rini
2017-01-04 9:10 ` Boris Brezillon
2017-01-09 8:28 ` Maxime Ripard
2016-11-22 12:38 ` [U-Boot] [PATCH v2 7/14] mtd: sunxi: Select the U-Boot location config option Maxime Ripard
2016-11-22 12:38 ` [U-Boot] [PATCH v2 8/14] mtd: sunxi: Change U-Boot offset Maxime Ripard
2016-11-22 15:20 ` Tom Rini
2016-11-22 12:38 ` [U-Boot] [PATCH v2 9/14] sunxi: Enable UBI and NAND support Maxime Ripard
2016-11-22 12:58 ` Boris Brezillon
2016-11-22 15:24 ` Tom Rini
2016-11-22 15:47 ` Peter Robinson
2016-11-22 15:54 ` Maxime Ripard
2016-11-22 16:40 ` Tom Rini
2016-11-22 12:38 ` [U-Boot] [PATCH v2 10/14] sunxi: Add the default mtdids and mtdparts to our env Maxime Ripard
2016-11-22 15:18 ` Tom Rini
2016-11-22 12:38 ` [U-Boot] [PATCH v2 11/14] nand: sunxi: Add options for the SPL NAND configuration Maxime Ripard
2016-11-22 12:38 ` [U-Boot] [PATCH v2 12/14] scripts: sunxi: Build an raw SPL image Maxime Ripard
2016-11-22 13:06 ` Boris Brezillon
2016-11-22 16:20 ` Heiko Schocher [this message]
2016-11-22 12:38 ` [U-Boot] [PATCH v2 13/14] sunxi: Sync GR8 DTS and AXP209 with the kernel Maxime Ripard
2016-12-03 13:49 ` Jagan Teki
2016-12-05 10:41 ` Maxime Ripard
2016-11-22 12:38 ` [U-Boot] [PATCH v2 14/14] sunxi: Add support for the CHIP Pro Maxime Ripard
2016-12-04 7:19 ` [U-Boot] [PATCH v2 0/14] " Jagan Teki
2016-12-05 21:33 ` Jagan Teki
2016-12-07 15:10 ` Jagan Teki
2016-12-09 8:18 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58347048.3050908@denx.de \
--to=hs@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox