[U-Boot] [PATCH 1/5] nand: sunxi: change BLOCK_SIZE in mksunxiboot to match NAND block size
Daniel Kochmański
dkochmanski at turtle-solutions.eu
Tue May 5 11:02:03 CEST 2015
Ian Campbell writes:
> On Wed, 2015-04-29 at 17:02 +0200, Daniel Kochmański wrote:
>> This change is necessary to calculate correct checksum for NAND
>> boot. Works both for MMC and NAND. Without it BROM rejects boot image
>> as invalid (bad checksum). (Changes block size from 0x200 to 0x2000).
>
> I'm inferring here that for MMC boot this checksum is ignored by the
> BROM? If that is the case then I think it should be explicitly
> mentioned.
It isn't ignored, just larger block is taken into checksum and put in
header (which is read by BROM). I think, that in NAND case BROM just
ignores length field in header, and calculates checksum for whole page
(8KB), while on MMC it respects this field, hence 0x2000 works for
both.
I've tried to put garbage into checksum field, and MMC doesn't boot if
checksum isn't correct.
>
> As well as the checksum this also changes the header's length field,
> FWIW.
>
Yes, this is true. Should I change it to set block size conditionally
depending on defines - if it's SPL NAND boot, then use 0x2000, in other
occasion use 0x200? Whole `u-boot-sunxi-with-spl.bin` size doesn't
increase tough (probably because of space between spl and proper
u-boot).
>
>> Signed-off-by: Daniel Kochmański <dkochmanski at turtle-solutions.eu>
>> Cc: Ian Campbell <ijc at hellion.org.uk>
>> Cc: Hans De Goede <hdegoede at redhat.com>
>> ---
>>
>> tools/mksunxiboot.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/mksunxiboot.c b/tools/mksunxiboot.c
>> index 0035f6e..bef0c79 100644
>> --- a/tools/mksunxiboot.c
>> +++ b/tools/mksunxiboot.c
>> @@ -65,7 +65,7 @@ int gen_check_sum(struct boot_file_head *head_p)
>>
>> #define SUN4I_SRAM_SIZE 0x7600 /* 0x7748+ is used by BROM */
>> #define SRAM_LOAD_MAX_SIZE (SUN4I_SRAM_SIZE - sizeof(struct boot_file_head))
>> -#define BLOCK_SIZE 512
>> +#define BLOCK_SIZE 0x2000
>>
>> struct boot_img {
>> struct boot_file_head header;
--
Daniel Kochmański | Poznań, Poland
;; aka jackdaniel
"Be the change that you wish to see in the world." - Mahatma Gandhi
More information about the U-Boot
mailing list