[U-Boot] add usb_system_autoupdate command.

Hi,
I have add the possibility to automatic update entire flash using a USB pendrive.
To make it, need the following steps: 1) insert usb pendrive. In pendrive must be present these files: install.dat and the files we want to copy. 2) from uboot console: => usb_system_autoupdate 3) the system update start, reading information from install.dat file.
The install.dat file raws has this syntax: <file_type> "<file_name>" <star_flash_addr_partition> <end_flash_addr_partition>
file_type values: kernel, uboot, fdt, rootfs.
In attachment there's an example of install.dat and the source code.
Now using it on my system (mpc5200, uboot_1.3.1) but there's a problem that I can't fix: if try to update uboot partition, it freeze in line 211 when call do_flerase().
debugging I can see that it freeze in: cmd_flash.c 434: printf ("Erased %d sectors\n", erased); after uboot partition erasing.
Can you help me?
Thanks in advance. Matteo Facchinetti

Matteo Facchinetti ha scritto:
Hi,
I have add the possibility to automatic update entire flash using a USB pendrive.
To make it, need the following steps:
- insert usb pendrive. In pendrive must be present these files:
install.dat and the files we want to copy. 2) from uboot console: => usb_system_autoupdate 3) the system update start, reading information from install.dat file.
The install.dat file raws has this syntax: <file_type> "<file_name>" <star_flash_addr_partition>
<end_flash_addr_partition>
file_type values: kernel, uboot, fdt, rootfs.
In attachment there's an example of install.dat and the source code.
Now using it on my system (mpc5200, uboot_1.3.1) but there's a problem that I can't fix: if try to update uboot partition, it freeze in line 211 when call do_flerase().
debugging I can see that it freeze in: cmd_flash.c 434: printf ("Erased %d sectors\n", erased); after uboot partition erasing.
Can you help me?
Posting output messages of the procedure may help.
Cordiali Saluti / Kindest Regards / mit freundlichen Grüssen -- Marco Cavallini | KOAN sas | Bergamo - Italia embedded and real-time software engineering Phone:+39-035-255.235 - Fax:+39-178-22.39.748 http://www.KoanSoftware.com

Hi Matteo,
in my opinion you should follow the "philosophy" of updater.c under the tools folder to erase the flash. This command is very interesting, let me know if you fix your problem.
Regards,
Marco
Matteo Facchinetti ha scritto:
Hi,
I have add the possibility to automatic update entire flash using a USB pendrive.
To make it, need the following steps:
- insert usb pendrive. In pendrive must be present these files:
install.dat and the files we want to copy. 2) from uboot console: => usb_system_autoupdate 3) the system update start, reading information from install.dat file.
The install.dat file raws has this syntax: <file_type> "<file_name>" <star_flash_addr_partition>
<end_flash_addr_partition>
file_type values: kernel, uboot, fdt, rootfs.
In attachment there's an example of install.dat and the source code.
Now using it on my system (mpc5200, uboot_1.3.1) but there's a problem that I can't fix: if try to update uboot partition, it freeze in line 211 when call do_flerase().
debugging I can see that it freeze in: cmd_flash.c 434: printf ("Erased %d sectors\n", erased); after uboot partition erasing.
Can you help me?
Thanks in advance. Matteo Facchinetti
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi Marco,
I looked updater.c and and I take that code as example.
Well, I removed all function as same as do_... (do_fat_fsload, do_protect, do_flerase, do_mem_cp). In this way, I could remove also strcpy() and sprintf() needed to made their parameters and the result is that I cleaned and emproved all code.
Now all works correctly. I think that the rewrite of the code, indirectly solve some bugs of memory corruption.
In attach, the code... and if anyone try it, I'm interesting to feedback or opinions.
Thanks at all. Matteo.
Marco wrote:
Hi Matteo,
in my opinion you should follow the "philosophy" of updater.c under the tools folder to erase the flash. This command is very interesting, let me know if you fix your problem.
Regards,
Marco
Matteo Facchinetti ha scritto:
Hi,
I have add the possibility to automatic update entire flash using a USB pendrive.
To make it, need the following steps:
- insert usb pendrive. In pendrive must be present these files:
install.dat and the files we want to copy. 2) from uboot console: => usb_system_autoupdate 3) the system update start, reading information from install.dat file.
The install.dat file raws has this syntax: <file_type> "<file_name>" <star_flash_addr_partition>
<end_flash_addr_partition>
file_type values: kernel, uboot, fdt, rootfs.
In attachment there's an example of install.dat and the source code.
Now using it on my system (mpc5200, uboot_1.3.1) but there's a problem that I can't fix: if try to update uboot partition, it freeze in line 211 when call do_flerase().
debugging I can see that it freeze in: cmd_flash.c 434: printf ("Erased %d sectors\n", erased); after uboot partition erasing.
Can you help me?
Thanks in advance. Matteo Facchinetti
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Dear Matteo,
In message 492176A0.7040101@sirius-es.it you wrote:
I looked updater.c and and I take that code as example.
I removed all function as same as do_... (do_fat_fsload, do_protect, do_flerase, do_mem_cp). In this way, I could remove also strcpy() and sprintf() needed to made their parameters and the result is that I cleaned and emproved all code.
Now all works correctly.
Hm... it may work for you, but it's mostly unusable by anybody else given the complete lack of documentation.
In attach, the code... and if anyone try it, I'm interesting to feedback or opinions.
Here a general comment first: we already have quitre a number of such auto-update mechanisms in U-Boot, including updates from USB mass storage device (like yours, or board/trab/auto_update.c or board/mcc200/auto_update.c or board/esd/common/auto_update.c), and updates over TFTP (see doc/README.update).
In my opinion, the code described in doc/README.update is probably the most advanced and powerful, as it moves the description of the update files from the code into the download image (using FIT image format).
So instead of adding yet another highly specific implementation for a pretty common task, I'd much rather see patches that come up with a generalization of this feature, i. e. something that allows reuse for other systems, eventually even replacing (parts of) the old, existing code.
Now for your patch:
* The Signed-off-by line is missing. * You exceed the maximum line length in many places. * You use an incorrect brace style. * There is lots of trailing white space. * It is not configurable (i.e. cannot be removed for boards that don't need it / don't want it. * And it has some pretty strange parts, like this error "handling":
error_exit: udelay(1000*1000*5); return 1;
I'm sorry, but this patch would need a major rework to make it acceptable for mainline, but as mentioned above, such efforts would (in my opinion) be better invested in designing and implementing a more general solution.
Best regards,
Wolfgang Denk
participants (4)
-
Marco
-
Marco Cavallini
-
Matteo Facchinetti
-
Wolfgang Denk