]> git.sur5r.net Git - u-boot/commitdiff
Merge branch 'master' of /home/wd/git/u-boot/custodians
authorWolfgang Denk <wd@denx.de>
Fri, 30 Mar 2012 18:17:11 +0000 (20:17 +0200)
committerWolfgang Denk <wd@denx.de>
Fri, 30 Mar 2012 18:17:11 +0000 (20:17 +0200)
* 'master' of /home/wd/git/u-boot/custodians:
  lzma: fix printf warnings
  Remove CONFIG_SYS_EXTBDINFO from snapper9260.h
  cmd_pxe.c: fix strict-aliasing warnings
  net: smc91111: use mdelay()
  doc: Fix some typos in different files
  disk/part.c: Fix device enumeration through API
  mkenvimage: Really set the redundant byte when applicable
  mkenvimage: Don't try to detect comments in the input file
  mkenvimage: Use mmap() when reading from a regular file
  mkenvimage: Read/Write from/to stdin/out by default or if the filename is "-"
  mkenvimage: More error handling
  mkenvimage: Correct an include and add a missing one
  mkenvimage: correct and clarify comments and error messages
  MAKEALL: display SPL size if present
  ARMV7/Vexpress: add missing get_ticks() and get_tbclk()
  mkenvimage: fix usage message
  cmd_fat: add FAT write command
  fs/fat/fat_write.c: Fix GCC 4.6 warnings
  FAT write: Fix compile errors

28 files changed:
MAKEALL
README
board/armltd/vexpress/ca9x4_ct_vxp.c
common/cmd_fat.c
common/cmd_pxe.c
disk/part.c
doc/README.AVR32-port-muxing
doc/README.SNTP
doc/README.Sandpoint8240
doc/README.at91
doc/README.ebony
doc/README.fsl-ddr
doc/README.mpc832xemds
doc/README.mpc8360emds
doc/README.mpc837xemds
doc/README.mpc8544ds
doc/README.mpc8572ds
doc/README.mpc85xxads
doc/README.mvbc_p
doc/README.mvblm7
doc/README.mvsmr
doc/README.ocotea
doc/README.p2020rdb
drivers/net/smc91111.c
fs/fat/fat_write.c
include/configs/snapper9260.h
lib/lzma/LzmaTools.c
tools/mkenvimage.c

diff --git a/MAKEALL b/MAKEALL
index 0f2b4a1b9491652f24c9873c70d721ed6f93d0c9..c33be1d4b53668cf16a2bada88d3c95c1c9eaec0 100755 (executable)
--- a/MAKEALL
+++ b/MAKEALL
@@ -511,8 +511,12 @@ build_target() {
 
        TOTAL_CNT=$((TOTAL_CNT + 1))
 
-       ${CROSS_COMPILE}size ${BUILD_DIR}/u-boot \
-                               | tee -a ${LOG_DIR}/$target.MAKELOG
+       OBJS=${BUILD_DIR}/u-boot
+       if [ -e ${BUILD_DIR}/spl/u-boot-spl ]; then
+               OBJS="${OBJS} ${BUILD_DIR}/spl/u-boot-spl"
+       fi
+
+       ${CROSS_COMPILE}size ${OBJS} | tee -a ${LOG_DIR}/$target.MAKELOG
 }
 build_targets() {
        for t in "$@" ; do
diff --git a/README b/README
index d4799e222f55cb5c7035e077a5f97b0426148282..92a11b4e11fc53f251ff235d2313e6aeb3565959 100644 (file)
--- a/README
+++ b/README
@@ -1236,8 +1236,12 @@ The following options need to be configured:
 
 - FAT(File Allocation Table) filesystem write function support:
                CONFIG_FAT_WRITE
-               Support for saving memory data as a file
-               in FAT formatted partition
+
+               Define this to enable support for saving memory data as a
+               file in FAT formatted partition.
+
+               This will also enable the command "fatwrite" enabling the
+               user to write files to FAT.
 
 - Keyboard Support:
                CONFIG_ISA_KEYBOARD
index da6f14d9888302592df5956007410b1e545f74f6..0b36d1280a87ae32c939126dd3632f71981ad328 100644 (file)
@@ -226,3 +226,13 @@ void lowlevel_init(void)
 ulong get_board_rev(void){
        return readl((u32 *)SYS_ID);
 }
+
+unsigned long long get_ticks(void)
+{
+       return get_timer(0);
+}
+
+ulong get_tbclk (void)
+{
+       return (ulong)CONFIG_SYS_HZ;
+}
index 022049434343dc04cf6acea10ab8c1e821cc875e..559a16d6195c6ca8f432dd700949ef34d2086814 100644 (file)
@@ -184,3 +184,60 @@ U_BOOT_CMD(
        "<interface> <dev[:part]>\n"
        "    - print information about filesystem from 'dev' on 'interface'"
 );
+
+#ifdef CONFIG_FAT_WRITE
+static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag,
+               int argc, char * const argv[])
+{
+       long size;
+       unsigned long addr;
+       unsigned long count;
+       block_dev_desc_t *dev_desc = NULL;
+       int dev = 0;
+       int part = 1;
+       char *ep;
+
+       if (argc < 5)
+               return cmd_usage(cmdtp);
+
+       dev = (int)simple_strtoul(argv[2], &ep, 16);
+       dev_desc = get_dev(argv[1], dev);
+       if (dev_desc == NULL) {
+               puts("\n** Invalid boot device **\n");
+               return 1;
+       }
+       if (*ep) {
+               if (*ep != ':') {
+                       puts("\n** Invalid boot device, use `dev[:part]' **\n");
+                       return 1;
+               }
+               part = (int)simple_strtoul(++ep, NULL, 16);
+       }
+       if (fat_register_device(dev_desc, part) != 0) {
+               printf("\n** Unable to use %s %d:%d for fatwrite **\n",
+                       argv[1], dev, part);
+               return 1;
+       }
+       addr = simple_strtoul(argv[3], NULL, 16);
+       count = simple_strtoul(argv[5], NULL, 16);
+
+       size = file_fat_write(argv[4], (void *)addr, count);
+       if (size == -1) {
+               printf("\n** Unable to write \"%s\" from %s %d:%d **\n",
+                       argv[4], argv[1], dev, part);
+               return 1;
+       }
+
+       printf("%ld bytes written\n", size);
+
+       return 0;
+}
+
+U_BOOT_CMD(
+       fatwrite,       6,      0,      do_fat_fswrite,
+       "write file into a dos filesystem",
+       "<interface> <dev[:part]> <addr> <filename> <bytes>\n"
+       "    - write file 'filename' from the address 'addr' in RAM\n"
+       "      to 'dev' on 'interface'"
+);
+#endif
index 8a68fa1ae34257be43aed1386968ef5a00ce7fb5..b3c1f67a33022c1ad5ec21781e07d3aba76e616c 100644 (file)
@@ -318,7 +318,7 @@ static int
 do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        char *pxefile_addr_str;
-       void *pxefile_addr_r;
+       unsigned long pxefile_addr_r;
        int err;
 
        if (argc != 1)
@@ -339,10 +339,10 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
         * Keep trying paths until we successfully get a file we're looking
         * for.
         */
-       if (pxe_uuid_path(pxefile_addr_r) > 0
-               || pxe_mac_path(pxefile_addr_r) > 0
-               || pxe_ipaddr_paths(pxefile_addr_r) > 0
-               || get_pxelinux_path("default", pxefile_addr_r) > 0) {
+       if (pxe_uuid_path((void *)pxefile_addr_r) > 0
+               || pxe_mac_path((void *)pxefile_addr_r) > 0
+               || pxe_ipaddr_paths((void *)pxefile_addr_r) > 0
+               || get_pxelinux_path("default", (void *)pxefile_addr_r) > 0) {
 
                printf("Config file found\n");
 
@@ -363,7 +363,7 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  */
 static int get_relfile_envaddr(char *file_path, char *envaddr_name)
 {
-       void *file_addr;
+       unsigned long file_addr;
        char *envaddr;
 
        envaddr = from_env(envaddr_name);
@@ -371,10 +371,10 @@ static int get_relfile_envaddr(char *file_path, char *envaddr_name)
        if (!envaddr)
                return -ENOENT;
 
-       if (strict_strtoul(envaddr, 16, (unsigned long *)&file_addr) < 0)
+       if (strict_strtoul(envaddr, 16, &file_addr) < 0)
                return -EINVAL;
 
-       return get_relfile(file_path, file_addr);
+       return get_relfile(file_path, (void *)file_addr);
 }
 
 /*
index f07a17feb8a0e5e03663d986754e346779efe0ad..8ca5d4bdfc7a7203dede5d7b6bc6f8a226ca0b5a 100644 (file)
@@ -80,6 +80,9 @@ block_dev_desc_t *get_dev(char* ifname, int dev)
        block_dev_desc_t* (*reloc_get_dev)(int dev);
        char *name;
 
+       if (!ifname)
+               return NULL;
+
        name = drvr->name;
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
        name += gd->reloc_off;
index b53799d338199bd46f8d94d29355ed71e5f9deed..8c1718cdca19eccd5f90c1f6273516830215bf0b 100644 (file)
@@ -91,7 +91,7 @@ of the flags are the same on all implementations.
        PORTMUX_DIR_OUTPUT
        PORTMUX_DIR_INPUT
 
-These mutually-exlusive flags configure the initial direction of the
+These mutually-exclusive flags configure the initial direction of the
 pins. PORTMUX_DIR_OUTPUT means that the pins are driven by the CPU,
 while PORTMUX_DIR_INPUT means that the pins are tristated by the CPU.
 These flags are ignored by portmux_select_peripheral().
@@ -125,7 +125,7 @@ PORTMUX_PULL_UP.
        PORTMUX_DRIVE_HIGH
        PORTMUX_DRIVE_MAX
 
-These mutually-exlusive flags determine the drive strength of the
+These mutually-exclusive flags determine the drive strength of the
 pins. PORTMUX_DRIVE_MIN will give low power-consumption, but may cause
 corruption of high-speed signals. PORTMUX_DRIVE_MAX will give high
 power-consumption, but may be necessary on pins toggling at very high
index 9edc957c6f1cd90b29b9bde13ae53986badbfabd..da9ec459ad46a454d9d2f0a4f095e1b96d9eb2ed 100644 (file)
@@ -6,7 +6,7 @@ syncronize RTC of the board. This command needs the command line
 parameter of server's IP address or environment variable
 "ntpserverip". The network time is sent as UTC. So if you want to
 set local time to RTC, set the offset in second from UTC to the
-enviroment variable "time offset".
+environment variable "time offset".
 
 If the DHCP server provides time server's IP or time offset, you
 don't need to set the above environment variables yourself.
index a41b69acedb8817fe1ddd1eca2ed50696879dd0e..fa846dc33e13e35f19fb4f02bf4046a8d38c4143 100644 (file)
@@ -236,7 +236,7 @@ PART 10)
 => setenv serverip 192.168.0.10
 => setenv gatewayip=192.168.0.1
 => saveenv
-Saving Enviroment to Flash...
+Saving Environment to Flash...
 Un-Protected 1 sectors
 Erasing Flash...
  done
@@ -296,7 +296,7 @@ Erase Flash Bank # 2 - missing
 => cp.b 0x100000 FFF00000 1f28c
 Copy to Flash... done
 => saveenv
-Saving Enviroment to Flash...
+Saving Environment to Flash...
 Un-Protected 1 sectors
 Erasing Flash...
  done
@@ -330,7 +330,7 @@ Erase Flash from 0xfff00000 to 0xfff3ffff
  done
 Erased 7 sectors
 Copy to Flash... done
-Saving Enviroment to Flash...
+Saving Environment to Flash...
 Un-Protected 1 sectors
 Erasing Flash...
  done
index 84b5595a92b8cbfa9dee23ad7d809ba052cfedb2..b51df00da701e5469ee9c489f5c63bf7390d6037 100644 (file)
@@ -62,16 +62,16 @@ Environment variables
        U-Boot environment variables can be stored at different places:
                - Dataflash on SPI chip select 0 (dataflash card)
                - Nand flash.
-               - Nor falsh (not populate by default)
+               - Nor flash (not populate by default)
 
        You can choose your storage location at config step (here for at91sam9260ek) :
                make at91sam9263ek_config               - use data flash (spi cs0) (default)
                make at91sam9263ek_nandflash_config     - use nand flash
                make at91sam9263ek_dataflash_cs0_config - use data flash (spi cs0)
-               make at91sam9263ek_norflash_config      - use nor falsh
+               make at91sam9263ek_norflash_config      - use nor flash
 
        You can choose to boot directly from U-Boot at config step
-               make at91sam9263ek_norflash_boot_config - boot from nor falsh
+               make at91sam9263ek_norflash_boot_config - boot from nor flash
 
 
 ------------------------------------------------------------------------------
index a8479a4799dc2748cfb9db611e3a36d200f102c4..4df00b35612d4b25d105505a782dd8e427a85bd3 100644 (file)
@@ -4,7 +4,7 @@
 =======================================================================
 
 This file contains some handy info regarding U-Boot and the AMCC
-Ebony evalutation board. See the README.ppc440 for additional
+Ebony evaluation board. See the README.ppc440 for additional
 information.
 
 
index 1d50153d58c2a4802f1b48fcd8f7291734f98cf5..5e21658765958b0812d8037e80497d772fe4aa7f 100644 (file)
@@ -250,7 +250,7 @@ print [c<n>] [d<n>] [spd] [dimmparms] [commonparms] [opts] [addresses] [regs]
        c<n>            - the controller number, eg. c0, c1
        d<n>            - the DIMM number, eg. d0, d1
        spd             - print SPD data
-       dimmparms       - DIMM paramaters, calcualted from SPD
+       dimmparms       - DIMM parameters, calculated from SPD
        commonparms     - lowest common parameters for all DIMMs
        opts            - options
        addresses       - address assignment (not implemented yet)
@@ -260,7 +260,7 @@ edit <c#> <d#> <spd|dimmparms|commonparms|opts|addresses|regs> <element> <value>
        c<n>            - the controller number, eg. c0, c1
        d<n>            - the DIMM number, eg. d0, d1
        spd             - print SPD data
-       dimmparms       - DIMM paramaters, calcualted from SPD
+       dimmparms       - DIMM parameters, calculated from SPD
        commonparms     - lowest common parameters for all DIMMs
        opts            - options
        addresses       - address assignment (not implemented yet)
index 688bdbb201bcd958d16272a63d214b5595ad7bca..4142aa9c8d5702aa9a906b5f2da7e11b589b774a 100644 (file)
@@ -15,7 +15,7 @@ Freescale MPC832XEMDS Board
                "On"  == 0
 
        SW3 is switch 18 as silk-screened onto the board.
-       SW4[8] is the bit labled 8 on Switch 4.
+       SW4[8] is the bit labeled 8 on Switch 4.
        SW5[1:6] refers to bits labeled 1 through 6 in order on switch 5.
        SW6[7:1] refers to bits labeled 7 through 1 in order on switch 6.
        SW7[1:8]= 0000_0001 refers to bits labeled 1 through 6 is set as "On"
index 2b39160418d957aa320214ce4874a77d51b2a4b1..6afa753969015f2d2e8a908e40e5f04ca5118e66 100644 (file)
@@ -15,7 +15,7 @@ Freescale MPC8360EMDS Board
                "On"  == 0
 
        SW18 is switch 18 as silk-screened onto the board.
-       SW4[8] is the bit labled 8 on Switch 4.
+       SW4[8] is the bit labeled 8 on Switch 4.
        SW2[1:6] refers to bits labeled 1 through 6 in order on switch 2.
        SW3[7:1] refers to bits labeled 7 through 1 in order on switch 3.
        SW3[1:8]= 0000_0001 refers to bits labeled 1 through 6 is set as "On"
index aa767ae7d8426a5985e2e57e9fdfd2039cd2945e..faf21c9ffb6d13625875b350be25c1d075848ebb 100644 (file)
@@ -14,7 +14,7 @@ Freescale MPC837xEMDS Board
                "Off" == 1
                "On"  == 0
 
-       SW4[8] is the bit labled 8 on Switch 4.
+       SW4[8] is the bit labeled 8 on Switch 4.
        SW2[1:6] refers to bits labeled 1 through 6 in order on switch 2.
        SW2[1:8]= 0000_0001 refers to bits labeled 1 through 7 is set as "On"
                and bits labeled 8 is set as "Off".
index bf257a0054f83eb99d86d21837db716421bf5b77..b49c3c07c40586545ec82ff3349dd58ebf2d39ee 100644 (file)
@@ -22,7 +22,7 @@ boot bank at 0xfff8_0000.
 Memory Map
 ----------
 
-0xff80_0000 - 0xffbf_ffff      Alernate bank           4MB
+0xff80_0000 - 0xffbf_ffff      Alternate bank          4MB
 0xffc0_0000 - 0xffff_ffff      Boot bank               4MB
 
 0xffb8_0000                    Alternate image start   512KB
index 06dab596bea52ab8d8c2ba89d86f793cc4881ccb..57fd2ad616062f5bd17996baeea61203e14c0448 100644 (file)
@@ -19,7 +19,7 @@ Booting is always from the boot bank at 0xec00_0000.
 Memory Map
 ----------
 
-0xe800_0000 - 0xebff_ffff      Alernate bank           64MB
+0xe800_0000 - 0xebff_ffff      Alternate bank          64MB
 0xec00_0000 - 0xefff_ffff      Boot bank               64MB
 
 0xebf8_0000 - 0xebff_ffff      Alternate u-boot address        512KB
@@ -115,7 +115,7 @@ Implementing AMP(Asymmetric MultiProcessing)
           - Select "Advanced setup" -> " Prompt for advanced kernel
             configuration options"
                - Select "Set physical address where the kernel is loaded" and
-                 set it to 0x20000000, asssuming core1 will start from 512MB.
+                 set it to 0x20000000, assuming core1 will start from 512MB.
                - Select "Set custom page offset address"
                - Select "Set custom kernel base address"
                - Select "Set maximum low memory"
index d059a979817ff0e97d89d8f569a963c25bee7e67..28bbcbe095dfa20b8af64369e47a5b6d667e69b2 100644 (file)
@@ -35,7 +35,7 @@ Updated 13-July-2004 Jon Loeliger
     "On"  == 0
 
     SW18 is switch 18 as silk-screened onto the board.
-    SW4[8] is the bit labled 8 on Switch 4.
+    SW4[8] is the bit labeled 8 on Switch 4.
     SW2[1:6] refers to bits labeled 1 through 6 in order on switch 2
     SW3[7:1] refers to bits labeled 7 through 1 in order on switch 3
 
index e3fcb4eb1bc6319e83fb13cd7d045b21169d2859..a691137550e578f16a932cd97fe7cb93289b7942 100644 (file)
@@ -33,7 +33,7 @@ Matrix Vision mvBlueCOUGAR-P (mvBC-P)
 2.4    I2C
        LM75 @ 0x90 for temperature monitoring.
        EEPROM @ 0xA0 for vendor specifics.
-       image sensor interface (slave adresses depend on sensor)
+       image sensor interface (slave addresses depend on sensor)
 
 3      Flash layout.
 
index 3ee9396540b45b1924f873512da3032625b4cb24..a0686f7fa5789447e9809e663587875f1c30c465 100644 (file)
@@ -40,10 +40,10 @@ Matrix Vision mvBlueLYNX-M7 (mvBL-M7)
                MAX5381 DAC @ 0x60 for 1st digital input threshold.
                LM75 @ 0x90 for temperature monitoring.
                EEPROM @ 0xA0 for system setup (HRCW etc.) + vendor specifics.
-               1st image sensor interface (slave adresses depend on sensor)
+               1st image sensor interface (slave addresses depend on sensor)
        Bus2:
                MAX5381 DAC @ 0x60 for 2nd digital input threshold.
-               2nd image sensor interface (slave adresses depend on sensor)
+               2nd image sensor interface (slave addresses depend on sensor)
 
 3      Flash layout.
 
index d729ea6fbe39f825a06a9e929cb5ad1d7463bb12..8e34cb7838519f8f3a6308926432225225e81048 100644 (file)
@@ -23,7 +23,7 @@ Matrix Vision mvSMR
 
 2.4    I2C
        EEPROM @ 0xA0 for vendor specifics.
-       image sensor interface (slave adresses depend on sensor)
+       image sensor interface (slave addresses depend on sensor)
 
 3      Flash layout.
 
index 9ac3a184cb8181c4d14a6dc5cab5292bbbe1f949..be79b03c8a0be4c82d4fb50f1455c37124e98368 100644 (file)
@@ -4,7 +4,7 @@
 =======================================================================
 
 This file contains some handy info regarding U-Boot and the AMCC
-Ocotea 440gx  evalutation board. See the README.ppc440 for additional
+Ocotea 440gx  evaluation board. See the README.ppc440 for additional
 information.
 
 
index 8a2302fa99df5e6b4d47d47f3e0210d3b6a783a4..cb664a5bd7d2bd7cdfe9c75be126bc86dffc16f1 100644 (file)
@@ -17,7 +17,7 @@ Booting by default is always from the boot bank at 0xef00_0000.
 
 Memory Map
 ----------
-0xef00_0000 - 0xef7f_ffff      Alernate bank           8MB
+0xef00_0000 - 0xef7f_ffff      Alternate bank          8MB
 0xe800_0000 - 0xefff_ffff      Boot bank               8MB
 
 0xef78_0000 - 0xef7f_ffff      Alternate u-boot address        512KB
@@ -89,7 +89,7 @@ Implementing AMP(Asymmetric MultiProcessing)
                "Prompt for advanced kernel configuration options"
                - Select
                        "Set physical address where the kernel is loaded"
-                       and set it to 0x20000000, asssuming core1 will
+                       and set it to 0x20000000, assuming core1 will
                        start from 512MB.
                - Select "Set custom page offset address"
                - Select "Set custom kernel base address"
index 9b8236ddf0dcebaf3a0fa869a87fc3f5978599e8..5cfef4dd7b463f13d0bc956078fdabddfae14368 100644 (file)
@@ -1168,17 +1168,6 @@ static void smc_write_phy_register (struct eth_device *dev, byte phyreg,
 #endif /* !CONFIG_SMC91111_EXT_PHY */
 
 
-/*------------------------------------------------------------
- . Waits the specified number of milliseconds - kernel friendly
- .-------------------------------------------------------------*/
-#ifndef CONFIG_SMC91111_EXT_PHY
-static void smc_wait_ms(unsigned int ms)
-{
-       udelay(ms*1000);
-}
-#endif /* !CONFIG_SMC91111_EXT_PHY */
-
-
 /*------------------------------------------------------------
  . Configures the specified PHY using Autonegotiation. Calls
  . smc_phy_fixed() if the user has requested a certain config.
@@ -1205,7 +1194,7 @@ static void smc_phy_configure (struct eth_device *dev)
                        break;
                }
 
-               smc_wait_ms (500);      /* wait 500 millisecs */
+               mdelay(500);    /* wait 500 millisecs */
        }
 
        if (timeout < 1) {
@@ -1270,7 +1259,7 @@ static void smc_phy_configure (struct eth_device *dev)
                        break;
                }
 
-               smc_wait_ms (500);      /* wait 500 millisecs */
+               mdelay(500);    /* wait 500 millisecs */
 
                /* Restart auto-negotiation if remote fault */
                if (status & PHY_STAT_REM_FLT) {
index 3bfc1c4b32be78a7256580801ea67601768c6814..a6181e71b558c0f509ef2c67b5d9e40437c9c23d 100644 (file)
@@ -41,23 +41,19 @@ static void uppercase(char *str, int len)
 }
 
 static int total_sector;
-static int disk_write(__u32 startblock, __u32 getsize, __u8 *bufptr)
+static int disk_write(__u32 block, __u32 nr_blocks, void *buf)
 {
-       if (cur_dev == NULL)
+       if (!cur_dev || !cur_dev->block_write)
                return -1;
 
-       if (startblock + getsize > total_sector) {
+       if (cur_part_info.start + block + nr_blocks >
+               cur_part_info.start + total_sector) {
                printf("error: overflow occurs\n");
                return -1;
        }
 
-       startblock += part_offset;
-
-       if (cur_dev->block_read) {
-               return cur_dev->block_write(cur_dev->dev, startblock, getsize,
-                                          (unsigned long *) bufptr);
-       }
-       return -1;
+       return cur_dev->block_write(cur_dev->dev,
+                       cur_part_info.start + block, nr_blocks, buf);
 }
 
 /*
@@ -797,7 +793,7 @@ static int check_overflow(fsdata *mydata, __u32 clustnum, unsigned long size)
        if (size % mydata->sect_size)
                sect_num++;
 
-       if (startsect + sect_num > total_sector)
+       if (startsect + sect_num > cur_part_info.start + total_sector)
                return -1;
 
        return 0;
@@ -827,7 +823,6 @@ static dir_entry *empty_dentptr;
 static dir_entry *find_directory_entry(fsdata *mydata, int startsect,
        char *filename, dir_entry *retdent, __u32 start)
 {
-       __u16 prevcksum = 0xffff;
        __u32 curclust = (startsect - mydata->data_begin) / mydata->clust_size;
 
        debug("get_dentfromdir: %s\n", filename);
@@ -861,8 +856,6 @@ static dir_entry *find_directory_entry(fsdata *mydata, int startsect,
 #ifdef CONFIG_SUPPORT_VFAT
                                if ((dentptr->attr & ATTR_VFAT) &&
                                    (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
-                                       prevcksum =
-                                       ((dir_slot *)dentptr)->alias_checksum;
                                        get_long_file_name(mydata, curclust,
                                                     get_dentfromdir_block,
                                                     &dentptr, l_name);
@@ -926,7 +919,6 @@ static int do_fat_write(const char *filename, void *buffer,
        unsigned long size)
 {
        dir_entry *dentptr, *retdent;
-       dir_slot *slotptr;
        __u32 startsect;
        __u32 start_cluster;
        boot_sector bs;
@@ -934,7 +926,7 @@ static int do_fat_write(const char *filename, void *buffer,
        fsdata datablock;
        fsdata *mydata = &datablock;
        int cursect;
-       int root_cluster, ret = -1, name_len;
+       int ret = -1, name_len;
        char l_filename[VFAT_MAXLEN_BYTES];
        int write_size = size;
 
@@ -947,9 +939,7 @@ static int do_fat_write(const char *filename, void *buffer,
 
        total_sector = bs.total_sect;
        if (total_sector == 0)
-               total_sector = part_size;
-
-       root_cluster = bs.root_cluster;
+               total_sector = cur_part_info.size;
 
        if (mydata->fatsize == 32)
                mydata->fatlength = bs.fat32_length;
@@ -1051,8 +1041,6 @@ static int do_fat_write(const char *filename, void *buffer,
                        goto exit;
                }
        } else {
-               slotptr = (dir_slot *)empty_dentptr;
-
                /* Set short name to set alias checksum field in dir_slot */
                set_name(empty_dentptr, filename);
                fill_dir_slot(mydata, &empty_dentptr, filename);
index cb3c674f496415ffe3d8d95ac54062d17305a3aa..cee65d1695e988f22d69cf6a98bd1ba4c91e1193 100644 (file)
 #define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE +            \
                                         sizeof(CONFIG_SYS_PROMPT) + 16)
 #define CONFIG_SYS_LONGHELP
-#define CONFIG_SYS_EXTBDINFO
 #define CONFIG_CMDLINE_EDITING
 #define CONFIG_AUTO_COMPLETE
 #define CONFIG_SYS_HUSH_PARSER
index 2eafad246e9e090970b59f321ddf615f029bc8e4..28a8aefc2ce7776afbc222185fc49a85b5c2e1e5 100644 (file)
@@ -107,8 +107,8 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
         }
     }
 
-    debug ("LZMA: Uncompresed size............ 0x%x\n", outSizeFull);
-    debug ("LZMA: Compresed size.............. 0x%x\n", compressedSize);
+    debug("LZMA: Uncompresed size............ 0x%zx\n", outSizeFull);
+    debug("LZMA: Compresed size.............. 0x%zx\n", compressedSize);
 
     g_Alloc.Alloc = SzAlloc;
     g_Alloc.Free = SzFree;
index f78173163f815d4ff5f7f34e708d254059293e77..9dbb3b210b4b4bcccbcb713cfa2bad8020a33349 100644 (file)
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
 #include <unistd.h>
-#include <compiler.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/mman.h>
 
+#include "compiler.h"
 #include <u-boot/crc.h>
 #include <version.h>
 
 
 static void usage(const char *exec_name)
 {
-       fprintf(stderr, "%s [-h] [-r] [-b] [-p <byte>] "
-              "-s <environment partition size> -o <output> <input file>\n"
+       fprintf(stderr, "%s [-h] [-r] [-b] [-p <byte>] -s <environment partition size> -o <output> <input file>\n"
               "\n"
-              "This tool takes a key=value input file (same as would a "
-              "`printenv' show) and generates the corresponding environment "
-              "image, ready to be flashed.\n"
+              "This tool takes a key=value input file (same as would a `printenv' show) and generates the corresponding environment image, ready to be flashed.\n"
               "\n"
               "\tThe input file is in format:\n"
               "\t\tkey1=value1\n"
@@ -58,14 +57,31 @@ static void usage(const char *exec_name)
               "\t\t...\n"
               "\t-r : the environment has multiple copies in flash\n"
               "\t-b : the target is big endian (default is little endian)\n"
-              "\t-p <byte> : fill the image with <byte> bytes instead of "
-              "0xff bytes\n"
+              "\t-p <byte> : fill the image with <byte> bytes instead of 0xff bytes\n"
               "\t-V : print version information and exit\n"
               "\n"
               "If the input file is \"-\", data is read from standard input\n",
               exec_name);
 }
 
+long int xstrtol(const char *s)
+{
+       long int tmp;
+
+       errno = 0;
+       tmp = strtol(s, NULL, 0);
+       if (!errno)
+               return tmp;
+
+       if (errno == ERANGE)
+               fprintf(stderr, "Bad integer format: %s\n",  s);
+       else
+               fprintf(stderr, "Error while parsing %s: %s\n", s,
+                               strerror(errno));
+
+       exit(EXIT_FAILURE);
+}
+
 int main(int argc, char **argv)
 {
        uint32_t crc, targetendian_crc;
@@ -95,13 +111,12 @@ int main(int argc, char **argv)
        while ((option = getopt(argc, argv, ":s:o:rbp:hV")) != -1) {
                switch (option) {
                case 's':
-                       datasize = strtol(optarg, NULL, 0);
+                       datasize = xstrtol(optarg);
                        break;
                case 'o':
                        bin_filename = strdup(optarg);
                        if (!bin_filename) {
-                               fprintf(stderr, "Can't strdup() the output "
-                                               "filename\n");
+                               fprintf(stderr, "Can't strdup() the output filename\n");
                                return EXIT_FAILURE;
                        }
                        break;
@@ -112,7 +127,7 @@ int main(int argc, char **argv)
                        bigendian = 1;
                        break;
                case 'p':
-                       padbyte = strtol(optarg, NULL, 0);
+                       padbyte = xstrtol(optarg);
                        break;
                case 'h':
                        usage(prg);
@@ -123,7 +138,7 @@ int main(int argc, char **argv)
                case ':':
                        fprintf(stderr, "Missing argument for option -%c\n",
                                optopt);
-                       usage(argv[0]);
+                       usage(prg);
                        return EXIT_FAILURE;
                default:
                        fprintf(stderr, "Wrong option -%c\n", optopt);
@@ -134,22 +149,21 @@ int main(int argc, char **argv)
 
        /* Check datasize and allocate the data */
        if (datasize == 0) {
-               fprintf(stderr,
-                       "Please specify the size of the environment "
-                       "partition.\n");
+               fprintf(stderr, "Please specify the size of the environment partition.\n");
                usage(prg);
                return EXIT_FAILURE;
        }
 
        dataptr = malloc(datasize * sizeof(*dataptr));
        if (!dataptr) {
-               fprintf(stderr, "Can't alloc dataptr.\n");
+               fprintf(stderr, "Can't alloc %d bytes for dataptr.\n",
+                               datasize);
                return EXIT_FAILURE;
        }
 
        /*
         * envptr points to the beginning of the actual environment (after the
-        * crc and possible `redundant' bit
+        * crc and possible `redundant' byte
         */
        envsize = datasize - (CRC_SIZE + redundant);
        envptr = dataptr + CRC_SIZE + redundant;
@@ -158,24 +172,28 @@ int main(int argc, char **argv)
        memset(envptr, padbyte, envsize);
 
        /* Open the input file ... */
-       if (optind >= argc) {
-               fprintf(stderr, "Please specify an input filename\n");
-               return EXIT_FAILURE;
-       }
-
-       txt_filename = argv[optind];
-       if (strcmp(txt_filename, "-") == 0) {
+       if (optind >= argc || strcmp(argv[optind], "-") == 0) {
                int readbytes = 0;
-               int readlen = sizeof(*envptr) * 2048;
+               int readlen = sizeof(*envptr) * 4096;
                txt_fd = STDIN_FILENO;
 
                do {
                        filebuf = realloc(filebuf, readlen);
+                       if (!filebuf) {
+                               fprintf(stderr, "Can't realloc memory for the input file buffer\n");
+                               return EXIT_FAILURE;
+                       }
                        readbytes = read(txt_fd, filebuf + filesize, readlen);
+                       if (errno) {
+                               fprintf(stderr, "Error while reading stdin: %s\n",
+                                               strerror(errno));
+                               return EXIT_FAILURE;
+                       }
                        filesize += readbytes;
                } while (readbytes == readlen);
 
        } else {
+               txt_filename = argv[optind];
                txt_fd = open(txt_filename, O_RDONLY);
                if (txt_fd == -1) {
                        fprintf(stderr, "Can't open \"%s\": %s\n",
@@ -185,28 +203,36 @@ int main(int argc, char **argv)
                /* ... and check it */
                ret = fstat(txt_fd, &txt_file_stat);
                if (ret == -1) {
-                       fprintf(stderr, "Can't stat() on \"%s\": "
-                                       "%s\n", txt_filename, strerror(errno));
+                       fprintf(stderr, "Can't stat() on \"%s\": %s\n",
+                                       txt_filename, strerror(errno));
                        return EXIT_FAILURE;
                }
 
                filesize = txt_file_stat.st_size;
-               /* Read the raw input file and transform it */
-               filebuf = malloc(sizeof(*envptr) * filesize);
-               ret = read(txt_fd, filebuf, sizeof(*envptr) * filesize);
-               if (ret != sizeof(*envptr) * filesize) {
-                       fprintf(stderr, "Can't read the whole input file\n");
-                       return EXIT_FAILURE;
+
+               filebuf = mmap(NULL, sizeof(*envptr) * filesize, PROT_READ,
+                              MAP_PRIVATE, txt_fd, 0);
+               if (filebuf == MAP_FAILED) {
+                       fprintf(stderr, "mmap (%ld bytes) failed: %s\n",
+                                       sizeof(*envptr) * filesize,
+                                       strerror(errno));
+                       fprintf(stderr, "Falling back to read()\n");
+
+                       filebuf = malloc(sizeof(*envptr) * filesize);
+                       ret = read(txt_fd, filebuf, sizeof(*envptr) * filesize);
+                       if (ret != sizeof(*envptr) * filesize) {
+                               fprintf(stderr, "Can't read the whole input file (%ld bytes): %s\n",
+                                       sizeof(*envptr) * filesize,
+                                       strerror(errno));
+
+                               return EXIT_FAILURE;
+                       }
                }
                ret = close(txt_fd);
        }
-       /*
-        * The right test to do is "=>" (not ">") because of the additional
-        * ending \0. See below.
-        */
-       if (filesize >= envsize) {
-               fprintf(stderr, "The input file is larger than the "
-                               "environment partition size\n");
+       /* The +1 is for the additionnal ending \0. See below. */
+       if (filesize + 1 > envsize) {
+               fprintf(stderr, "The input file is larger than the environment partition size\n");
                return EXIT_FAILURE;
        }
 
@@ -232,14 +258,6 @@ int main(int argc, char **argv)
                                /* End of a variable */
                                envptr[ep++] = '\0';
                        }
-               } else if (filebuf[fp] == '#') {
-                       if (fp != 0 && filebuf[fp-1] == '\n') {
-                               /* This line is a comment, let's skip it */
-                               while (fp < txt_file_stat.st_size && fp++ &&
-                                      filebuf[fp] != '\n');
-                       } else {
-                               envptr[ep++] = filebuf[fp];
-                       }
                } else {
                        envptr[ep++] = filebuf[fp];
                }
@@ -255,8 +273,7 @@ int main(int argc, char **argv)
                 * check the env size again to make sure we have room for two \0
                 */
                if (ep >= envsize) {
-                       fprintf(stderr, "The environment file is too large for "
-                                       "the target environment storage\n");
+                       fprintf(stderr, "The environment file is too large for the target environment storage\n");
                        return EXIT_FAILURE;
                }
                envptr[ep] = '\0';
@@ -268,13 +285,20 @@ int main(int argc, char **argv)
        crc = crc32(0, envptr, envsize);
        targetendian_crc = bigendian ? cpu_to_be32(crc) : cpu_to_le32(crc);
 
-       memcpy(dataptr, &targetendian_crc, sizeof(uint32_t));
+       memcpy(dataptr, &targetendian_crc, sizeof(targetendian_crc));
+       if (redundant)
+               dataptr[sizeof(targetendian_crc)] = 1;
 
-       bin_fd = creat(bin_filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
-       if (bin_fd == -1) {
-               fprintf(stderr, "Can't open output file \"%s\": %s\n",
-                               bin_filename, strerror(errno));
-               return EXIT_FAILURE;
+       if (!bin_filename || strcmp(bin_filename, "-") == 0) {
+               bin_fd = STDOUT_FILENO;
+       } else {
+               bin_fd = creat(bin_filename, S_IRUSR | S_IWUSR | S_IRGRP |
+                                            S_IWGRP);
+               if (bin_fd == -1) {
+                       fprintf(stderr, "Can't open output file \"%s\": %s\n",
+                                       bin_filename, strerror(errno));
+                       return EXIT_FAILURE;
+               }
        }
 
        if (write(bin_fd, dataptr, sizeof(*dataptr) * datasize) !=