Davinci: Utility for MMC boot
PATCH 1/1 Davinci: Utility for MMC boot
From: Alagu Sankar <[email protected]>
This is a Linux command line tool specific to TI's Davinci platforms, for flashing UBL (User Boot Loader), u-boot and u-boot Environment in the MMC/SD card. This MMC/SD card can be used for booting Davinci platforms that supports MMC/SD boot option.
This patch was submitted by Alagu Sankar
(http://www.mail-archive.com/u-boot at lists.denx.de/msg32309.html),
but couldn't make into mainline. Resubmitting the patch, with modifications to build with u-boot, Fixed compilation issues and fixed uflash.c to write u-boot properly.
--- Makefile | 2 +- tools/Makefile | 2 +- tools/uflash/Makefile | 13 ++ tools/uflash/README | 125 +++++++++++++++ tools/uflash/config.txt | 11 ++ tools/uflash/uflash.c | 383 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 534 insertions(+), 2 deletions(-) create mode 100644 tools/uflash/Makefile create mode 100644 tools/uflash/README create mode 100644 tools/uflash/config.txt create mode 100644 tools/uflash/uflash.c
Makefile +1 -1
@@ -726,7 +726,7 @@ clean: @rm -f $(obj)examples/api/demo{,.bin} @rm -f $(obj)tools/bmp_logo $(obj)tools/easylogo/easylogo \ $(obj)tools/env/{fw_printenv,fw_setenv} \ - $(obj)tools/envcrc \ + $(obj)tools/envcrc $(obj)tools/uflash/uflash \ $(obj)tools/gdb/{astest,gdbcont,gdbsend} \ $(obj)tools/gen_eth_addr $(obj)tools/img2srec \ $(obj)tools/mk{env,}image $(obj)tools/mpc86x_clk \
tools/Makefile +1 -1
@@ -21,7 +21,7 @@ # MA 02111-1307 USA # -TOOLSUBDIRS = +TOOLSUBDIRS = uflash # # Include this after HOSTOS HOSTARCH check
tools/uflash/Makefile new file +13 -0
@@ -0,0 +1,13 @@ +include $(TOPDIR)/config.mk + +all: $(obj)uflash + +HOSTCFLAGS_NOPED += -I $(SRCTREE)/include -DUSE_HOSTCC + +$(obj)uflash: $(SRCTREE)/tools/uflash/uflash.c $(SRCTREE)/lib/crc32.c $(SRCTREE)/lib/errno.c + $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $^ + +clean: + rm -f $(obj)uflash + +.PHONY: all clean
tools/uflash/README new file +125 -0
125 lines not on this page · raw message
tools/uflash/config.txt new file +11 -0
@@ -0,0 +1,11 @@ +bootargs=console=ttyS0,115200n8 root=/dev/mmcblk0p1 rootwait rootfstype=ext3 rw +bootcmd=ext2load mmc 0 0x80700000 boot/uImage; bootm 0x80700000 +bootdelay=1 +baudrate=115200 +bootfile="uImage" +stdin=serial +stdout=serial +stderr=serial +ethact=dm9000 +videostd=ntsc +
tools/uflash/uflash.c new file +383 -0
383 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 1/1 Davinci: Utility for MMC boot
Dear Prabhakar Lad,
Quoted 6 lines · In message <[email protected]> you wrote:
From: Alagu Sankar <[email protected]>
This is a Linux command line tool specific to TI's Davinci platforms, for flashing UBL (User Boot Loader), u-boot and u-boot Environment in the MMC/SD card. This MMC/SD card can be used for booting Davinci platforms that supports MMC/SD boot option.
Do we also build UBL as part of the U-Boot source tree?
If not, then why is this tool supposed to be part of the U-Boot tree?
How does this work with a SPL?
Makefile clean: · line 732
Quoted 11 lines
Makefile +1
-1@@ -726,7 +726,7 @@ clean: @rm -f $(obj)examples/api/demo{,.bin} @rm -f $(obj)tools/bmp_logo $(obj)tools/easylogo/easylogo \ $(obj)tools/env/{fw_printenv,fw_setenv} \ - $(obj)tools/envcrc \ + $(obj)tools/envcrc $(obj)tools/uflash/uflash \ $(obj)tools/gdb/{astest,gdbcont,gdbsend} \ $(obj)tools/gen_eth_addr $(obj)tools/img2srec \ $(obj)tools/mk{env,}image $(obj)tools/mpc86x_clk \
Please keep list sorted.
Makefile
Quoted 2 lines
Makefile +2
-0+e. Using the 'uflash' utility, place the UBL and u-uoot binaries on the MMC + card. Copy the u-boot.bin to tools/uflash directory
Why is this copy operation needed?
And where is the UBL binary coming from?
Quoted 6 lines
tools/uflash/config.txt new file +0
-0
tools/uflash/config.txt line 10
Quoted 10 lines
tools/uflash/config.txt new file +10
-0@@ -0,0 +1,11 @@ +bootargs=console=ttyS0,115200n8 root=/dev/mmcblk0p1 rootwait rootfstype=ext3 rw +bootcmd=ext2load mmc 0 0x80700000 boot/uImage; bootm 0x80700000 +bootdelay=1 +baudrate=115200 +bootfile="uImage" +stdin=serial +stdout=serial +stderr=serial +ethact=dm9000 +videostd=ntsc
This looks like U-Boot environment settings? Why are these in the tools/uflash/ directory? I would expect these are board specific? For example, what in case a board uses a different baud rate?
Is this really supposed to be board independent? It doesn't look so...
tools/uflash/config.txt line 11
Quoted 1 line
tools/uflash/config.txt new file +1
-0+
And please, no trailing empty lines!
...
tools/uflash/config.txt
Quoted 13 lines
tools/uflash/config.txt new file +13
-0+ if (!strcmp(platform, "DM3XX")) { + if (!uboot_load_address) + uboot_load_address = DM3XX_UBOOT_LOAD_ADDRESS; + if (!uboot_entry_point) + uboot_entry_point = DM3XX_UBOOT_LOAD_ADDRESS; + } + + if (!strcmp(platform, "OMAPL138")) { + if (!uboot_load_address) + uboot_load_address = DA850_UBOOT_LOAD_ADDRESS; + if (!uboot_entry_point) + uboot_entry_point = DA850_UBOOT_LOAD_ADDRESS; + }
So this is actually all hardwired for a few very specific board configurations, right?
.
Quoted 5 lines
tools/uflash/config.txt new file +5
-0+static int get_file_size(char *fname) +{ + FILE *fp; + int size; +
tools/uflash/config.txt
Quoted 10 lines
tools/uflash/config.txt new file +10
-0+ fp = fopen(fname, "rb"); + if (fp == NULL) { + fprintf(stdout, "File %s Open Error : %s\n", + fname, strerror(errno)); + return -1; + } + + fseek(fp, 0, SEEK_END); + size = ftell(fp); + fclose(fp);
Why not simply using stat() ?
Quoted 14 lines
tools/uflash/config.txt new file +14
-0+static int write_file(int devfd, char *fname) +{ + FILE *fp; + int readlen, writelen; + + fp = fopen(fname, "rb"); + if (fp == NULL) { + fprintf(stderr, "File %s Open Error: %s", + fname, strerror(errno)); + return -1; + } + + while ((readlen = fread(readbuf, 1, BLOCK_SIZE, fp)) > 0) { + if (readlen < BLOCK_SIZE)
tools/uflash/config.txt
Quoted 10 lines
tools/uflash/config.txt new file +10
-0+ memset(&readbuf[readlen], 0, BLOCK_SIZE-readlen); + + writelen = write(devfd, readbuf, BLOCK_SIZE); + if (writelen < BLOCK_SIZE) { + close(devfd); + return -1; + } + } + + fclose(fp);
You don't even print a warning or error message in case of read errors? Ouch...
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
C makes it easy for you to shoot yourself in the foot. C++ makes that
harder, but when you do, it blows away your whole leg.
-- Bjarne StroustrupLad
PATCH 1/1 Davinci: Utility for MMC boot
Hi Wolfgang,
Quoted 12 lines · Wolfgang Denk
Dear Prabhakar Lad,
Quoted 6 lines · In message <[email protected]> you wrote:
From: Alagu Sankar <[email protected]>
This is a Linux command line tool specific to TI's Davinci platforms, for flashing UBL (User Boot Loader), u-boot and u-boot Environment in the MMC/SD card. This MMC/SD card can be used for booting Davinci platforms that supports MMC/SD boot option.
Do we also build UBL as part of the U-Boot source tree?
No, we do not build UBL as part of U-Boot.
Quoted 4 lines
If not, then why is this tool supposed to be part of the U-Boot tree?
How does this work with a SPL?
This command has options to flash u-boot images to MMC/SD card. When SPL is supported, this command can be used to flash the single SPL image to MMC/SD card.
Quoted 5 lines
Quoted 5 lines
Makefile +0
-0@@ -726,7 +726,7 @@ clean: @rm -f $(obj)examples/api/demo{,.bin} @rm -f $(obj)tools/bmp_logo $(obj)tools/easylogo/easylogo \
Quoted 9 lines
Makefile clean: · line 732
Quoted 6 lines
Makefile +1
-1$(obj)tools/env/{fw_printenv,fw_setenv} \ - $(obj)tools/envcrc \ + $(obj)tools/envcrc $(obj)tools/uflash/uflash \ $(obj)tools/gdb/{astest,gdbcont,gdbsend} \ $(obj)tools/gen_eth_addr $(obj)tools/img2srec \ $(obj)tools/mk{env,}image $(obj)tools/mpc86x_clk \Please keep list sorted.
Ok.
Quoted 6 lines
Makefile
Quoted 3 lines
Makefile +2
-0+e. Using the 'uflash' utility, place the UBL and u-uoot binaries on the MMC + card. Copy the u-boot.bin to tools/uflash directoryWhy is this copy operation needed?
This copy is not needed as long as the path to u-boot.bin is specified Correctly in command line.
Quoted 2 lines
And where is the UBL binary coming from?
UBL binary is optional. We can flash only u-boot.bin.
Quoted 23 lines
Quoted 8 lines
tools/uflash/config.txt new file +0
-0tools/uflash/config.txt line 10
Quoted 10 lines
tools/uflash/config.txt new file +10
-0@@ -0,0 +1,11 @@ +bootargs=console=ttyS0,115200n8 root=/dev/mmcblk0p1 rootwait rootfstype=ext3 rw +bootcmd=ext2load mmc 0 0x80700000 boot/uImage; bootm 0x80700000 +bootdelay=1 +baudrate=115200 +bootfile="uImage" +stdin=serial +stdout=serial +stderr=serial +ethact=dm9000 +videostd=ntscThis looks like U-Boot environment settings? Why are these in the
tools/uflash/directory? I would expect these are board specific? For example, what in case a board uses a different baud rate?
Quoted 3 lines
Is this really supposed to be board independent? It doesn't look so...
I agree with this. Can you think of any other scenario?
Quoted 4 lines
tools/uflash/config.txt line 11
Quoted 1 line
tools/uflash/config.txt new file +1
-0+And please, no trailing empty lines!
Ok.
Quoted 18 lines
...
tools/uflash/config.txt
Quoted 13 lines
tools/uflash/config.txt new file +13
-0+ if (!strcmp(platform, "DM3XX")) { + if (!uboot_load_address) + uboot_load_address = DM3XX_UBOOT_LOAD_ADDRESS; + if (!uboot_entry_point) + uboot_entry_point = DM3XX_UBOOT_LOAD_ADDRESS; + } + + if (!strcmp(platform, "OMAPL138")) { + if (!uboot_load_address) + uboot_load_address = DA850_UBOOT_LOAD_ADDRESS; + if (!uboot_entry_point) + uboot_entry_point = DA850_UBOOT_LOAD_ADDRESS; + }So this is actually all hardwired for a few very specific board configurations, right?
Yes.
Quoted 10 lines
.
Quoted 9 lines
tools/uflash/config.txt new file +9
-0+static int get_file_size(char *fname) +{ + FILE *fp; + int size; + + fp = fopen(fname, "rb"); + if (fp == NULL) { + fprintf(stdout, "File %s Open Error : %s\n", + fname, strerror(errno));
Quoted 9 lines
tools/uflash/config.txt
Quoted 6 lines
tools/uflash/config.txt new file +6
-0+ return -1; + } + + fseek(fp, 0, SEEK_END); + size = ftell(fp); + fclose(fp);Why not simply using
stat()?
Yes that makes sense.
Quoted 19 lines
Quoted 19 lines
tools/uflash/config.txt new file +19
-0+static int write_file(int devfd, char *fname) +{ + FILE *fp; + int readlen, writelen; + + fp = fopen(fname, "rb"); + if (fp == NULL) { + fprintf(stderr, "File %s Open Error: %s", + fname, strerror(errno)); + return -1; + } + + while ((readlen = fread(readbuf, 1, BLOCK_SIZE, fp)) > 0) { + if (readlen < BLOCK_SIZE) + memset(&readbuf[readlen], 0, BLOCK_SIZE-readlen); + + writelen = write(devfd, readbuf, BLOCK_SIZE); + if (writelen < BLOCK_SIZE) { + close(devfd);
Quoted 9 lines
tools/uflash/config.txt
Quoted 5 lines
tools/uflash/config.txt new file +5
-0+ return -1; + } + } + + fclose(fp);You don't even print a warning or error message in case of read errors? Ouch...
Ok , I'll fix it in V2 version.
Thx,
--Prabhakar Lad
Quoted 13 lines
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de C makes it easy for you to shoot yourself in the foot. C++ makes that harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup
PATCH 1/1 Davinci: Utility for MMC boot
Dear "Lad, Prabhakar",
Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 8 lines
Quoted 5 lines
This is a Linux command line tool specific to TI's Davinci platforms, f> or flashing UBL (User Boot Loader), u-boot and u-boot Environment in the M> MC/SD card. This MMC/SD card can be used for booting Davinci platforms that s> upports MMC/SD boot option.
Do we also build UBL as part of the U-Boot source tree?
No, we do not build UBL as part of U-Boot.
Why not?
I assume by adding this tool to the U-Boot tree you want to provide a single, self-contained build system for the boot loader on such boards. But this doesn;t work if we are not also building the UBL image.
Quoted 7 lines
Quoted 4 lines
If not, then why is this tool supposed to be part of the U-Boot tree?
How does this work with a SPL?
This command has options to flash u-boot images to MMC/SD card. When SPL is supported, this command can be used to flash the single SPL image to MMC/SD card.
How exactly does this work? You do not document this use case.
Quoted 11 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+e. Using the 'uflash' utility, place the UBL and u-uoot binaries on th> e MMC + card. Copy the u-boot.bin to tools/uflash directoryWhy is this copy operation needed?
This copy is not needed as long as the path to u-boot.bin is specified Correctly in command line.
Quoted 2 lines
And where is the UBL binary coming from?
UBL binary is optional. We can flash only u-boot.bin.
I did not understand this from your documentation. Can you please add this information?
Quoted 8 lines
Quoted 7 lines
This looks like U-Boot environment settings? Why are these in the
tools/uflash/directory? I would expect these are board specific? For example, what in case a board uses a different baud rate?Is this really supposed to be board independent? It doesn't look so...
I agree with this. Can you think of any other scenario?
I have no idea what you are trying to do here. The envrionment settings are inherently part of U-Boot, and I don't understand why you are adding another set of settings here.
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
tools/uflash/uflash.c new file +8
-0+if (!strcmp (platform,"DM3XX" )) { +if (!uboot_load_address) + uboot_load_address =DM3XX_UBOOT_LOAD_ADDRESS ; +if (!uboot_entry_point) + uboot_entry_point =DM3XX_UBOOT_LOAD_ADDRESS ; + } + +if (!strcmp (platform,"OMAPL138" )) {Quoted 9 lines
tools/uflash/uflash.c line 150
Quoted 5 lines
tools/uflash/uflash.c new file +5
-0+if (!uboot_load_address) + uboot_load_address =DA850_UBOOT_LOAD_ADDRESS ; +if (!uboot_entry_point) + uboot_entry_point =DA850_UBOOT_LOAD_ADDRESS ; + }So this is actually all hardwired for a few very specific board configurations, right?
Quoted 1 line
Yes.
Sorry, but this doesn't make sense then. It doesn't scale. It should be possible to use such a tool with any such board - and without changing the code of the tool. Instead of gard-coding all this information, you should make the tool data driven, so that it's sufficient to provide respective configuration data - actually I think all this information is already present in the existing header files, especially the board configuration file. So why not just reuse this information?
Quoted 4 lines
Quoted 3 lines
You don't even print a warning or error message in case of read errors? Ouch...
Ok , I'll fix it in V2 version.
Please check error checking / handling for all system calls and calls to library functions.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I have often regretted my speech, never my silence.