Skip to contentSkip to conversation

RFC: 'fastboot boot' uses wrong address when calling bootm

U-Boot Peter.Chubb at data61.csiro.au 2 participants 2 messages Sep 7, 2016 – Sep 8, 2016 USB

lore
Share & tools
lore
#0 lore raw

Hi Folks,
If you set CONFIG_FASTBOOT_BUF_ADDR to anything other than the same as $loadaddr then the call to do_bootm() in the fastboot code will call do_bootm on a memory region that has nothing to do with the image downloaded. Sometimes the result is a hung system, other times the system reboots.

I'm not sure of the correct fix. The possibilities are:
1. Get rid of CONFIG_FASTBOOT_BUF_ADDR and use $loadaddr instead. All the defconfigs that enable fastboot currently set CONFIG_FASTBOOT_BUF_ADDR to the same value as CONFIG_LOADADDR at present.

2. memcpy from the downloaded image to $loadaddr if possible. This would allow other payloads than ANDROID boot images, with a bit more work. (For example, I'd love to be able to boot ELF images using fastboot -- which doesn't work at present, because the entry point in the elf header isn't used)

3. The simplest: call do_bootm() with the address where the image has just been downloaded. The attached patch does this.

What do you think?

Peter C

 drivers/usb/gadget/f_fastboot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/f_fastboot.c +1 -1
Index: u-boot/drivers/usb/gadget/f_fastboot.c
===================================================================
@@ -553,7 +553,7 @@ static void do_bootm_on_complete(struct
 
 	puts("Booting kernel..\n");
 
-	sprintf(boot_addr_start, "0x%lx", load_addr);
+	sprintf(boot_addr_start, "0x%lx", CONFIG_FASTBOOT_BUF_ADDR);
 	do_bootm(NULL, 0, 2, bootm_args);
 
 	/* This only happens if image is somehow faulty so we start over */
Signature · 2 lines
Dr Peter Chubb         Tel: +61 2 9490 5852      http://ts.data61.csiro.au/
Trustworthy Systems Group                           Data61 (formerly NICTA)
#1 lore raw
Quoted 19 lines · On Wed, Sep 07, 2016 at 09:37:48AM +0000, Peter.Chubb at data61.csiro.au wrote:

Hi Folks,
If you set CONFIG_FASTBOOT_BUF_ADDR to anything other than the same as $loadaddr then the call to do_bootm() in the fastboot code will call do_bootm on a memory region that has nothing to do with the image downloaded. Sometimes the result is a hung system, other times the system reboots.

I'm not sure of the correct fix. The possibilities are:
1. Get rid of CONFIG_FASTBOOT_BUF_ADDR and use $loadaddr instead. All the defconfigs that enable fastboot currently set CONFIG_FASTBOOT_BUF_ADDR to the same value as CONFIG_LOADADDR at present.

2. memcpy from the downloaded image to $loadaddr if possible. This would allow other payloads than ANDROID boot images, with a bit more work. (For example, I'd love to be able to boot ELF images using fastboot -- which doesn't work at present, because the entry point in the elf header isn't used)

Quoted 4 lines

3. The simplest: call do_bootm() with the address where the image has just been downloaded. The attached patch does this.

What do you think?

Since it's possible that one would want the buf addr to be different from loadaddr later on, I think #3 is the path of least surprise, please re-submit as a formal patch, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160908/88d65e53/attachment.sig>