public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] u-boot USB question
@ 2013-05-16 22:32 Lance Beck
  2013-05-17  1:22 ` Bo Shen
  0 siblings, 1 reply; 7+ messages in thread
From: Lance Beck @ 2013-05-16 22:32 UTC (permalink / raw)
  To: u-boot

We are using u-boot on an AT91SAM9G20 platform with NAND Flash and running Linux.  Is there a means to update the kernel and root fs image by reading them from a USB memory device and writing the new images to flash?  I have built the fw_printenv tool thinking I might be able to use this to somehow trigger that action.

Not sure where to go from here...

Thanks,

Lance

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] u-boot USB question
  2013-05-16 22:32 [U-Boot] u-boot USB question Lance Beck
@ 2013-05-17  1:22 ` Bo Shen
  2013-05-17  2:20   ` Lance Beck
  2013-05-17  5:45   ` Andreas Bießmann
  0 siblings, 2 replies; 7+ messages in thread
From: Bo Shen @ 2013-05-17  1:22 UTC (permalink / raw)
  To: u-boot

Hi Lance,

On 5/17/2013 06:32, Lance Beck wrote:
> We are using u-boot on an AT91SAM9G20 platform with NAND Flash and running Linux.  Is there a means to update the kernel and root fs image by reading them from a USB memory device and writing the new images to flash?  I have built the fw_printenv tool thinking I might be able to use this to somehow trigger that action.

Yes. Please take the following example (using the mainline 
u-boot-2013.04) for updating related image from USB disk.

1. connect usb to board and power up
U-boot> usb start
(Re)start USB...
USB:   scanning bus for devices... 2 USB Device(s) found
        scanning bus for storage devices... 1 Storage Device(s) found
U-boot> fatls usb 0
...
2396352 uImage
...
U-boot> fatload usb 0 0x20000000 uImage
U-boot> nand erase 0x200000 0x600000
U-boot> nand write 0x20000000 0x200000 <uImage_size>

If all steps are successfully, then you have updated linux kernel uImage.

BTW, the fw_printenv is used with Linux file system to access u-boot 
environment.

> Not sure where to go from here...
>
> Thanks,
>
> Lance

Best Regards,
Bo Shen

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] u-boot USB question
  2013-05-17  1:22 ` Bo Shen
@ 2013-05-17  2:20   ` Lance Beck
  2013-05-17  3:04     ` Bo Shen
  2013-05-17  5:54     ` Andreas Bießmann
  2013-05-17  5:45   ` Andreas Bießmann
  1 sibling, 2 replies; 7+ messages in thread
From: Lance Beck @ 2013-05-17  2:20 UTC (permalink / raw)
  To: u-boot

Thanks Bo!  

My thinking with fw_printev (setenv) was that I would use it to set the environment variables from our user space app.  This way, we can control when the USB stick will be used for a kernel or rootfs upgrade.  Any thoughts on show this could be scripted and run?  We would like to be able to have a customer in the field do this without having to do anything but send a command from the user app, insert the USB drive and reboot.

Lance


-----Original Message-----
From: Bo Shen [mailto:voice.shen at atmel.com] 
Sent: Thursday, May 16, 2013 7:22 PM
To: Lance Beck
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] u-boot USB question

Hi Lance,

On 5/17/2013 06:32, Lance Beck wrote:
> We are using u-boot on an AT91SAM9G20 platform with NAND Flash and running Linux.  Is there a means to update the kernel and root fs image by reading them from a USB memory device and writing the new images to flash?  I have built the fw_printenv tool thinking I might be able to use this to somehow trigger that action.

Yes. Please take the following example (using the mainline
u-boot-2013.04) for updating related image from USB disk.

1. connect usb to board and power up
U-boot> usb start
(Re)start USB...
USB:   scanning bus for devices... 2 USB Device(s) found
        scanning bus for storage devices... 1 Storage Device(s) found
U-boot> fatls usb 0
...
2396352 uImage
...
U-boot> fatload usb 0 0x20000000 uImage
U-boot> nand erase 0x200000 0x600000
U-boot> nand write 0x20000000 0x200000 <uImage_size>

If all steps are successfully, then you have updated linux kernel uImage.

BTW, the fw_printenv is used with Linux file system to access u-boot environment.

> Not sure where to go from here...
>
> Thanks,
>
> Lance

Best Regards,
Bo Shen

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] u-boot USB question
  2013-05-17  2:20   ` Lance Beck
@ 2013-05-17  3:04     ` Bo Shen
  2013-05-17  3:39       ` Michael Trimarchi
  2013-05-17  5:54     ` Andreas Bießmann
  1 sibling, 1 reply; 7+ messages in thread
From: Bo Shen @ 2013-05-17  3:04 UTC (permalink / raw)
  To: u-boot

Hi Lance,

On 5/17/2013 10:20, Lance Beck wrote:
> Thanks Bo!
>
> My thinking with fw_printev (setenv) was that I would use it to set the environment variables from our user space app.  This way, we can control when the USB stick will be used for a kernel or rootfs upgrade.  Any thoughts on show this could be scripted and run?  We would like to be able to have a customer in the field do this without having to do anything but send a command from the user app, insert the USB drive and reboot.

Maybe you can test reference in <include/configs/am3517_evm.h>
---8>---
#define CONFIG_EXTRA_ENV_SETTINGS \
         "loadaddr=0x82000000\0" \
         "console=ttyO2,115200n8\0" \
         "mmcdev=0\0" \
         "mmcargs=setenv bootargs console=${console} " \
                 "root=/dev/mmcblk0p2 rw rootwait\0" \
         "nandargs=setenv bootargs console=${console} " \
                 "root=/dev/mtdblock4 rw " \
                 "rootfstype=jffs2\0" \
         "loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr\0" \
         "bootscript=echo Running bootscript from mmc ...; " \
                 "source ${loadaddr}\0" \
         "loaduimage=fatload mmc ${mmcdev} ${loadaddr} uImage\0" \
         "mmcboot=echo Booting from mmc ...; " \
                 "run mmcargs; " \
                 "bootm ${loadaddr}\0" \
         "nandboot=echo Booting from nand ...; " \
                 "run nandargs; " \
                 "nand read ${loadaddr} 280000 400000; " \
                 "bootm ${loadaddr}\0" \

#define CONFIG_BOOTCOMMAND \
         "mmc dev ${mmcdev}; if mmc rescan; then " \
                 "if run loadbootscript; then " \
                         "run bootscript; " \
                 "else " \
                         "if run loaduimage; then " \
                                 "run mmcboot; " \
                         "else run nandboot; " \
                         "fi; " \
                 "fi; " \
         "else run nandboot; fi"
---<8---

Best Regards,
Bo Shen

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] u-boot USB question
  2013-05-17  3:04     ` Bo Shen
@ 2013-05-17  3:39       ` Michael Trimarchi
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Trimarchi @ 2013-05-17  3:39 UTC (permalink / raw)
  To: u-boot

Hi

On 17/05/13 05:04, Bo Shen wrote:
> Hi Lance,
> 
> On 5/17/2013 10:20, Lance Beck wrote:
>> Thanks Bo!
>>
>> My thinking with fw_printev (setenv) was that I would use it to set the environment variables from our user space app.  This way, we can control when the USB stick will be used for a kernel or rootfs upgrade.  Any thoughts on show this could be scripted and run?  We would like to be able to have a customer in the field do this without having to do anything but send a command from the user app, insert the USB drive and reboot.
> 

If the cpu doesn't have any register for rebooting reason, you can write in environment a variable
that said that you want update at the next reboot and then using and autoscript you can flash it

Michael 

> Maybe you can test reference in <include/configs/am3517_evm.h>
> ---8>---
> #define CONFIG_EXTRA_ENV_SETTINGS \
>         "loadaddr=0x82000000\0" \
>         "console=ttyO2,115200n8\0" \
>         "mmcdev=0\0" \
>         "mmcargs=setenv bootargs console=${console} " \
>                 "root=/dev/mmcblk0p2 rw rootwait\0" \
>         "nandargs=setenv bootargs console=${console} " \
>                 "root=/dev/mtdblock4 rw " \
>                 "rootfstype=jffs2\0" \
>         "loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr\0" \
>         "bootscript=echo Running bootscript from mmc ...; " \
>                 "source ${loadaddr}\0" \
>         "loaduimage=fatload mmc ${mmcdev} ${loadaddr} uImage\0" \
>         "mmcboot=echo Booting from mmc ...; " \
>                 "run mmcargs; " \
>                 "bootm ${loadaddr}\0" \
>         "nandboot=echo Booting from nand ...; " \
>                 "run nandargs; " \
>                 "nand read ${loadaddr} 280000 400000; " \
>                 "bootm ${loadaddr}\0" \
> 
> #define CONFIG_BOOTCOMMAND \
>         "mmc dev ${mmcdev}; if mmc rescan; then " \
>                 "if run loadbootscript; then " \
>                         "run bootscript; " \
>                 "else " \
>                         "if run loaduimage; then " \
>                                 "run mmcboot; " \
>                         "else run nandboot; " \
>                         "fi; " \
>                 "fi; " \
>         "else run nandboot; fi"
> ---<8---
> 
> Best Regards,
> Bo Shen
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] u-boot USB question
  2013-05-17  1:22 ` Bo Shen
  2013-05-17  2:20   ` Lance Beck
@ 2013-05-17  5:45   ` Andreas Bießmann
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Bießmann @ 2013-05-17  5:45 UTC (permalink / raw)
  To: u-boot

Hi Lance, Bo,

On 17.05.13 03:22, Bo Shen wrote:
> Hi Lance,
> 
> On 5/17/2013 06:32, Lance Beck wrote:
>> We are using u-boot on an AT91SAM9G20 platform with NAND Flash and
>> running Linux.  Is there a means to update the kernel and root fs
>> image by reading them from a USB memory device and writing the new
>> images to flash?  I have built the fw_printenv tool thinking I might
>> be able to use this to somehow trigger that action.
> 
> Yes. Please take the following example (using the mainline
> u-boot-2013.04) for updating related image from USB disk.
> 
> 1. connect usb to board and power up
> U-boot> usb start
> (Re)start USB...
> USB:   scanning bus for devices... 2 USB Device(s) found
>        scanning bus for storage devices... 1 Storage Device(s) found
> U-boot> fatls usb 0
> ...
> 2396352 uImage
> ...
> U-boot> fatload usb 0 0x20000000 uImage
> U-boot> nand erase 0x200000 0x600000
> U-boot> nand write 0x20000000 0x200000 <uImage_size>

just a pointer ...
All these load commands (fat, ubi, ...) set an env named filesize. Just
write

U-boot> nand write 0x20000000 0x200000 $filesize

There is another magic env that can be used here. One can define
CONFIG_LOADADDR (or was it CONFIG_SYS_LOADADDR ... there was a
discussion to consolidate this) to have env 'loadaddr' set. With that
you can use $loadaddr instead of 0x20000000 in the example above.

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] u-boot USB question
  2013-05-17  2:20   ` Lance Beck
  2013-05-17  3:04     ` Bo Shen
@ 2013-05-17  5:54     ` Andreas Bießmann
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Bießmann @ 2013-05-17  5:54 UTC (permalink / raw)
  To: u-boot

Hi Lance,

please do not top post.

On 17.05.13 04:20, Lance Beck wrote:
> Thanks Bo!  
> 
> My thinking with fw_printev (setenv) was that I would use it to set the environment variables
> from our user space app.  

That's the intended use of fw_setenv ;)

> This way, we can control when the USB stick will be used for a kernel
> or rootfs upgrade.  Any thoughts on show this could be scripted and run? 

As Bo mentioned. But why don't just do this in userspace?

First thing would be to have a script that stops services, remount
everything ro and write the respective blobs to /dev/mtdX.
Another solution (or enhancement) could be to spawn a kexec kernel and
do all the stuff in a clean environment.
The advantage of this solution is to have a full blown environment with
sophisticated UI. I think this is the most annoying thing in u-boot ...
we do lack a good environment for UI represented to the end user. Well,
we have to discuss if this is a drawback ;)

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-05-17  5:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-16 22:32 [U-Boot] u-boot USB question Lance Beck
2013-05-17  1:22 ` Bo Shen
2013-05-17  2:20   ` Lance Beck
2013-05-17  3:04     ` Bo Shen
2013-05-17  3:39       ` Michael Trimarchi
2013-05-17  5:54     ` Andreas Bießmann
2013-05-17  5:45   ` Andreas Bießmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox