summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2012-03-30 20:17:02 +0200
committerWolfgang Denk <wd@denx.de>2012-03-30 20:17:02 +0200
commita939ea3ab459d5fb3d1eaaec289c6ca85f2f74c1 (patch)
treeb343c2aeb1dbfbd9a64cfb9da9f39d70e6d077f9
parentbc6f6c87b685bcdcd5bef522982d15209b6b9601 (diff)
parentf3e6110a10b694b3beb1ba7704fb7632cc371844 (diff)
downloadu-boot-imx-a939ea3ab459d5fb3d1eaaec289c6ca85f2f74c1.zip
u-boot-imx-a939ea3ab459d5fb3d1eaaec289c6ca85f2f74c1.tar.gz
u-boot-imx-a939ea3ab459d5fb3d1eaaec289c6ca85f2f74c1.tar.bz2
Merge branch 'agust@denx.de' of git://git.denx.de/u-boot-staging
* 'agust@denx.de' of git://git.denx.de/u-boot-staging: 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
-rwxr-xr-xMAKEALL8
-rw-r--r--README8
-rw-r--r--board/armltd/vexpress/ca9x4_ct_vxp.c10
-rw-r--r--common/cmd_fat.c57
-rw-r--r--common/cmd_pxe.c16
-rw-r--r--disk/part.c3
-rw-r--r--doc/README.AVR32-port-muxing4
-rw-r--r--doc/README.SNTP2
-rw-r--r--doc/README.Sandpoint82406
-rw-r--r--doc/README.at916
-rw-r--r--doc/README.ebony2
-rw-r--r--doc/README.fsl-ddr4
-rw-r--r--doc/README.mpc832xemds2
-rw-r--r--doc/README.mpc8360emds2
-rw-r--r--doc/README.mpc837xemds2
-rw-r--r--doc/README.mpc8544ds2
-rw-r--r--doc/README.mpc8572ds4
-rw-r--r--doc/README.mpc85xxads2
-rw-r--r--doc/README.mvbc_p2
-rw-r--r--doc/README.mvblm74
-rw-r--r--doc/README.mvsmr2
-rw-r--r--doc/README.ocotea2
-rw-r--r--doc/README.p2020rdb4
-rw-r--r--drivers/net/smc91111.c15
-rw-r--r--fs/fat/fat_write.c30
-rw-r--r--include/configs/snapper9260.h1
-rw-r--r--lib/lzma/LzmaTools.c4
-rw-r--r--tools/mkenvimage.c138
28 files changed, 210 insertions, 132 deletions
diff --git a/MAKEALL b/MAKEALL
index 0f2b4a1..c33be1d 100755
--- 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 d4799e2..92a11b4 100644
--- 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
diff --git a/board/armltd/vexpress/ca9x4_ct_vxp.c b/board/armltd/vexpress/ca9x4_ct_vxp.c
index da6f14d..0b36d12 100644
--- a/board/armltd/vexpress/ca9x4_ct_vxp.c
+++ b/board/armltd/vexpress/ca9x4_ct_vxp.c
@@ -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;
+}
diff --git a/common/cmd_fat.c b/common/cmd_fat.c
index 0220494..559a16d 100644
--- a/common/cmd_fat.c
+++ b/common/cmd_fat.c
@@ -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
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index 8a68fa1..b3c1f67 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -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);
}
/*
diff --git a/disk/part.c b/disk/part.c
index f07a17f..8ca5d4b 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -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;
diff --git a/doc/README.AVR32-port-muxing b/doc/README.AVR32-port-muxing
index b53799d..8c1718c 100644
--- a/doc/README.AVR32-port-muxing
+++ b/doc/README.AVR32-port-muxing
@@ -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
diff --git a/doc/README.SNTP b/doc/README.SNTP
index 9edc957..da9ec45 100644
--- a/doc/README.SNTP
+++ b/doc/README.SNTP
@@ -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.
diff --git a/doc/README.Sandpoint8240 b/doc/README.Sandpoint8240
index a41b69a..fa846dc 100644
--- a/doc/README.Sandpoint8240
+++ b/doc/README.Sandpoint8240
@@ -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
diff --git a/doc/README.at91 b/doc/README.at91
index 84b5595..b51df00 100644
--- a/doc/README.at91
+++ b/doc/README.at91
@@ -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
------------------------------------------------------------------------------
diff --git a/doc/README.ebony b/doc/README.ebony
index a8479a4..4df00b3 100644
--- a/doc/README.ebony
+++ b/doc/README.ebony
@@ -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.
diff --git a/doc/README.fsl-ddr b/doc/README.fsl-ddr
index 1d50153..5e21658 100644
--- a/doc/README.fsl-ddr
+++ b/doc/README.fsl-ddr
@@ -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)
diff --git a/doc/README.mpc832xemds b/doc/README.mpc832xemds
index 688bdbb..4142aa9 100644
--- a/doc/README.mpc832xemds
+++ b/doc/README.mpc832xemds
@@ -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"
diff --git a/doc/README.mpc8360emds b/doc/README.mpc8360emds
index 2b39160..6afa753 100644
--- a/doc/README.mpc8360emds
+++ b/doc/README.mpc8360emds
@@ -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"
diff --git a/doc/README.mpc837xemds b/doc/README.mpc837xemds
index aa767ae..faf21c9 100644
--- a/doc/README.mpc837xemds
+++ b/doc/README.mpc837xemds
@@ -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".
diff --git a/doc/README.mpc8544ds b/doc/README.mpc8544ds
index bf257a0..b49c3c0 100644
--- a/doc/README.mpc8544ds
+++ b/doc/README.mpc8544ds
@@ -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
diff --git a/doc/README.mpc8572ds b/doc/README.mpc8572ds
index 06dab59..57fd2ad 100644
--- a/doc/README.mpc8572ds
+++ b/doc/README.mpc8572ds
@@ -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"
diff --git a/doc/README.mpc85xxads b/doc/README.mpc85xxads
index d059a97..28bbcbe 100644
--- a/doc/README.mpc85xxads
+++ b/doc/README.mpc85xxads
@@ -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
diff --git a/doc/README.mvbc_p b/doc/README.mvbc_p
index e3fcb4e..a691137 100644
--- a/doc/README.mvbc_p
+++ b/doc/README.mvbc_p
@@ -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.
diff --git a/doc/README.mvblm7 b/doc/README.mvblm7
index 3ee9396..a0686f7 100644
--- a/doc/README.mvblm7
+++ b/doc/README.mvblm7
@@ -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.
diff --git a/doc/README.mvsmr b/doc/README.mvsmr
index d729ea6..8e34cb7 100644
--- a/doc/README.mvsmr
+++ b/doc/README.mvsmr
@@ -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.
diff --git a/doc/README.ocotea b/doc/README.ocotea
index 9ac3a18..be79b03 100644
--- a/doc/README.ocotea
+++ b/doc/README.ocotea
@@ -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.
diff --git a/doc/README.p2020rdb b/doc/README.p2020rdb
index 8a2302f..cb664a5 100644
--- a/doc/README.p2020rdb
+++ b/doc/README.p2020rdb
@@ -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"
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 9b8236d..5cfef4d 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -1169,17 +1169,6 @@ static void smc_write_phy_register (struct eth_device *dev, byte phyreg,
/*------------------------------------------------------------
- . 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) {
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 3bfc1c4..a6181e7 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -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);
diff --git a/include/configs/snapper9260.h b/include/configs/snapper9260.h
index cb3c674..cee65d1 100644
--- a/include/configs/snapper9260.h
+++ b/include/configs/snapper9260.h
@@ -157,7 +157,6 @@
#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
diff --git a/lib/lzma/LzmaTools.c b/lib/lzma/LzmaTools.c
index 2eafad2..28a8aef 100644
--- a/lib/lzma/LzmaTools.c
+++ b/lib/lzma/LzmaTools.c
@@ -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;
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index f781731..9dbb3b2 100644
--- a/tools/mkenvimage.c
+++ b/tools/mkenvimage.c
@@ -31,13 +31,15 @@
#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>
@@ -45,12 +47,9 @@
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) !=