diff mbox

[U-Boot,6/7] scripts: sunxi: Build an raw SPL image

Message ID e16ddb81605d02ea3c385c1a637543e273f2d018.1478621974.git-series.maxime.ripard@free-electrons.com
State Superseded
Delegated to: Hans de Goede
Headers show

Commit Message

Maxime Ripard Nov. 8, 2016, 4:21 p.m. UTC
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>
---
 Makefile             |  3 +++
 scripts/Makefile.spl | 12 ++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

Comments

Boris Brezillon Nov. 8, 2016, 4:33 p.m. UTC | #1
On Tue,  8 Nov 2016 17:21:16 +0100
Maxime Ripard <maxime.ripard@free-electrons.com> wrote:

> 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 +++
>  scripts/Makefile.spl | 12 ++++++++++++
>  2 files changed, 15 insertions(+), 0 deletions(-)
> 
> 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/scripts/Makefile.spl b/scripts/Makefile.spl
> index e0b0117dc9b6..b41b4e427cc5 100644
> --- a/scripts/Makefile.spl
> +++ b/scripts/Makefile.spl
> @@ -168,6 +168,7 @@ endif
>  
>  ifdef CONFIG_ARCH_SUNXI
>  ALL-y	+= $(obj)/sunxi-spl.bin
> +ALL-y	+= $(obj)/sunxi-spl-with-ecc.bin
>  endif
>  
>  ifeq ($(CONFIG_SYS_SOC),"at91")
> @@ -276,6 +277,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      $@
Hans de Goede Nov. 14, 2016, 11:19 a.m. UTC | #2
Hi,

On 08-11-16 17:21, Maxime Ripard wrote:
> 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>

Looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>  Makefile             |  3 +++
>  scripts/Makefile.spl | 12 ++++++++++++
>  2 files changed, 15 insertions(+), 0 deletions(-)
>
> 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/scripts/Makefile.spl b/scripts/Makefile.spl
> index e0b0117dc9b6..b41b4e427cc5 100644
> --- a/scripts/Makefile.spl
> +++ b/scripts/Makefile.spl
> @@ -168,6 +168,7 @@ endif
>
>  ifdef CONFIG_ARCH_SUNXI
>  ALL-y	+= $(obj)/sunxi-spl.bin
> +ALL-y	+= $(obj)/sunxi-spl-with-ecc.bin
>  endif
>
>  ifeq ($(CONFIG_SYS_SOC),"at91")
> @@ -276,6 +277,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      $@
>
Hans de Goede Nov. 14, 2016, 11:30 a.m. UTC | #3
Hi,

On 14-11-16 12:19, Hans de Goede wrote:
> Hi,
>
> On 08-11-16 17:21, Maxime Ripard wrote:
>> 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>
>
> Looks good to me:
>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Scrap that, this causes all sunxi boars to fail to build:

+--page is missing
+sunxi-nand-image-builder 2016.11-rc3-00069-gabe4d57
+Usage: sunxi-nand-image-builder [OPTIONS] source-image output-image
+Creates a raw NAND image that can be read by the sunxi NAND controller.
+-h               --help               Display this help and exit
+-c <str>/<step>  --ecc=<str>/<step>   ECC config (strength/step-size)
+-p <size>        --page=<size>        Page size
+-o <size>        --oob=<size>         OOB size
+-u <size>        --usable=<size>      Usable page size
+-e <size>        --eraseblock=<size>  Erase block size
+-b               --boot0              Build a boot0 image.
+-s               --scramble           Scramble data
+  Valid ECC strengths: 16, 24, 28, 32, 40, 48, 56, 60 and 64
+  Valid ECC step size: 512 and 1024
+If you are building a boot0 image, you'll have specify extra options.
+These options should be chosen based on the layouts described here:
+  http://linux-sunxi.org/NAND#More_information_on_BROM_NAND
+  --usable should be assigned the 'Hardware page' value
+  --ecc should be assigned the 'ECC capacity'/'ECC page' values
+  --usable should be smaller than --page
+The --address option is only required for non-boot0 images that are
+meant to be programmed at a non eraseblock aligned offset.
+Examples:
+  The H27UCG8T2BTR-BC NAND exposes
+  * 16k pages
+  * 1280 OOB bytes per page
+  * 4M eraseblocks
+  * requires data scrambling
+  * expects a minimum ECC of 40bits/1024bytes
+  A normal image can be generated with
+    sunxi-nand-image-builder -p 16384 -o 1280 -e 0x400000 -s -c 40/1024
+  A boot0 image can be generated with
+    sunxi-nand-image-builder -p 16384 -o 1280 -e 0x400000 -s -b -u 4096 -c 64/1024
+make[2]: *** [spl/sunxi-spl-with-ecc.bin] Error 255
+make[1]: *** [spl/u-boot-spl] Error 2

I've dropped this patch.


Regards,

Hans


>
> Regards,
>
> Hans
>
>
>
>> ---
>>  Makefile             |  3 +++
>>  scripts/Makefile.spl | 12 ++++++++++++
>>  2 files changed, 15 insertions(+), 0 deletions(-)
>>
>> 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/scripts/Makefile.spl b/scripts/Makefile.spl
>> index e0b0117dc9b6..b41b4e427cc5 100644
>> --- a/scripts/Makefile.spl
>> +++ b/scripts/Makefile.spl
>> @@ -168,6 +168,7 @@ endif
>>
>>  ifdef CONFIG_ARCH_SUNXI
>>  ALL-y    += $(obj)/sunxi-spl.bin
>> +ALL-y    += $(obj)/sunxi-spl-with-ecc.bin
>>  endif
>>
>>  ifeq ($(CONFIG_SYS_SOC),"at91")
>> @@ -276,6 +277,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      $@
>>
diff mbox

Patch

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/scripts/Makefile.spl b/scripts/Makefile.spl
index e0b0117dc9b6..b41b4e427cc5 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -168,6 +168,7 @@  endif
 
 ifdef CONFIG_ARCH_SUNXI
 ALL-y	+= $(obj)/sunxi-spl.bin
+ALL-y	+= $(obj)/sunxi-spl-with-ecc.bin
 endif
 
 ifeq ($(CONFIG_SYS_SOC),"at91")
@@ -276,6 +277,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      $@