[U-Boot] [RFC PATCH 0/5] move boot0 hook in the beginning for armv7

Dr. Philipp Tomsich philipp.tomsich at theobroma-systems.com
Tue Jun 13 18:59:28 UTC 2017


Jagan,

> On 13 Jun 2017, at 19:10, Jagan Teki <jagannadh.teki at gmail.com> wrote:
> 
>>> I know this must break socfpga platform, and as I have said in cover letter,
>>> I think this patch also break bcm and sunxi platform, I add 'RFC' for this patch
>>> set because I don't know the detail requirement of hook0 for other 3 platform,
>>> I'm not asking if this patch set break other 3 platforms or not, but I'm asking for
>>> the solution for those 3 platform so that we can apply this patch set.
>> 
>> The following platforms have a boot0-hook implemented:
>> 
>> ./arch/arm/include/asm/arch-rockchip/boot0.h
>> ./arch/arm/include/asm/arch-bcm235xx/boot0.h
>> ./arch/arm/include/asm/arch-sunxi/boot0.h
>> ./arch/arm/include/asm/arch-bcm281xx/boot0.h
>> ./arch/arm/mach-socfpga/include/mach/boot0.h
>> 
>>> I think my patch is correct in what HOOK0 wants to do, just like Philipp's opinion
>>> in another mail.
>>> I hope to get help from maintainer for socfpga, bcm, sunxi platform.
> 
> for sunxi32 boot0 hook does normal execution (b reset) but the image
> changed 4 bytes with this change.
> 
> w/o the change:
> 0000000 0016 ea00 4765 4e4f 422e 3054 cf32 4cc6
> 0000010 6000 0000 5053 024c 0000 0000 0000 0000
> 
> with the change:
> 0000000 0016 ea00 4765 4e4f 422e 3054 da15 4b6f
> 0000010 6000 0000 5053 024c 0000 0000 0000 0000
> 
> of-course board not booting.

You may be looking at the wrong part of the image, as this is
part of the header (the code from vectors.S starts at 0x60):

00000000  16 00 00 ea 65 47 4f 4e  2e 42 54 30 24 45 26 97  |....eGON.BT0$E&.|
00000010  00 60 00 00 53 50 4c 02  00 00 00 00 00 00 00 00  |.`..SPL.........|
00000020  2c 00 00 00 00 00 00 00  00 00 00 00 73 75 6e 38  |,...........sun8|
00000030  69 2d 68 33 2d 6f 72 61  6e 67 65 70 69 2d 70 63  |i-h3-orangepi-pc|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000060  0f 00 00 ea 14 f0 9f e5  14 f0 9f e5 14 f0 9f e5  |................|
00000070  14 f0 9f e5 14 f0 9f e5  14 f0 9f e5 14 f0 9f e5  |................|
00000080  a0 00 00 00 a0 00 00 00  a0 00 00 00 a0 00 00 00  |................|
00000090  a0 00 00 00 a0 00 00 00  a0 00 00 00 ef be ad de  |…………….|

When looking at the header-definition in spl.h, the changed word is the length:

/* boot head definition from sun4i boot code */
struct boot_file_head {
        uint32_t b_instruction; /* one intruction jumping to real code */
        uint8_t magic[8];       /* ="eGON.BT0" or "eGON.BT1", not C-style str */
        uint32_t check_sum;     /* generated by PC */
        uint32_t length;        /* generated by PC */

With Kever’s change I’d expect something to happen at 0x60.
And if it moves code around there, it’s likely to break the mksunxiboot.c
implementation, which builds the instruction:
        /* fill the header */
        img.header.b_instruction =      /* b instruction */
                0xEA000000 |    /* jump to the first instr after the header */
                ((sizeof(struct boot_file_head) / sizeof(int) - 2)
                 & 0x00FFFFFF);

In fact, I now wonder whether most of the header chould already
be generated by the boot0-hook, such that only the length and
the checksum would need to be patched in by mksunxiboot.c… 
…but that is me taking the second step before the first ;-)

—Phil.


More information about the U-Boot mailing list