mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-10-05 02:50:44 +09:00
Merge branch 'master' of /home/wd/git/u-boot/custodians
* '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
This commit is contained in:
commit
7373323056
8
MAKEALL
8
MAKEALL
@ -511,8 +511,12 @@ build_target() {
|
|||||||
|
|
||||||
TOTAL_CNT=$((TOTAL_CNT + 1))
|
TOTAL_CNT=$((TOTAL_CNT + 1))
|
||||||
|
|
||||||
${CROSS_COMPILE}size ${BUILD_DIR}/u-boot \
|
OBJS=${BUILD_DIR}/u-boot
|
||||||
| tee -a ${LOG_DIR}/$target.MAKELOG
|
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() {
|
build_targets() {
|
||||||
for t in "$@" ; do
|
for t in "$@" ; do
|
||||||
|
8
README
8
README
@ -1236,8 +1236,12 @@ The following options need to be configured:
|
|||||||
|
|
||||||
- FAT(File Allocation Table) filesystem write function support:
|
- FAT(File Allocation Table) filesystem write function support:
|
||||||
CONFIG_FAT_WRITE
|
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:
|
- Keyboard Support:
|
||||||
CONFIG_ISA_KEYBOARD
|
CONFIG_ISA_KEYBOARD
|
||||||
|
@ -226,3 +226,13 @@ void lowlevel_init(void)
|
|||||||
ulong get_board_rev(void){
|
ulong get_board_rev(void){
|
||||||
return readl((u32 *)SYS_ID);
|
return readl((u32 *)SYS_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long long get_ticks(void)
|
||||||
|
{
|
||||||
|
return get_timer(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong get_tbclk (void)
|
||||||
|
{
|
||||||
|
return (ulong)CONFIG_SYS_HZ;
|
||||||
|
}
|
||||||
|
@ -184,3 +184,60 @@ U_BOOT_CMD(
|
|||||||
"<interface> <dev[:part]>\n"
|
"<interface> <dev[:part]>\n"
|
||||||
" - print information about filesystem from 'dev' on 'interface'"
|
" - 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
|
||||||
|
@ -318,7 +318,7 @@ static int
|
|||||||
do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
char *pxefile_addr_str;
|
char *pxefile_addr_str;
|
||||||
void *pxefile_addr_r;
|
unsigned long pxefile_addr_r;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (argc != 1)
|
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
|
* Keep trying paths until we successfully get a file we're looking
|
||||||
* for.
|
* for.
|
||||||
*/
|
*/
|
||||||
if (pxe_uuid_path(pxefile_addr_r) > 0
|
if (pxe_uuid_path((void *)pxefile_addr_r) > 0
|
||||||
|| pxe_mac_path(pxefile_addr_r) > 0
|
|| pxe_mac_path((void *)pxefile_addr_r) > 0
|
||||||
|| pxe_ipaddr_paths(pxefile_addr_r) > 0
|
|| pxe_ipaddr_paths((void *)pxefile_addr_r) > 0
|
||||||
|| get_pxelinux_path("default", pxefile_addr_r) > 0) {
|
|| get_pxelinux_path("default", (void *)pxefile_addr_r) > 0) {
|
||||||
|
|
||||||
printf("Config file found\n");
|
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)
|
static int get_relfile_envaddr(char *file_path, char *envaddr_name)
|
||||||
{
|
{
|
||||||
void *file_addr;
|
unsigned long file_addr;
|
||||||
char *envaddr;
|
char *envaddr;
|
||||||
|
|
||||||
envaddr = from_env(envaddr_name);
|
envaddr = from_env(envaddr_name);
|
||||||
@ -371,10 +371,10 @@ static int get_relfile_envaddr(char *file_path, char *envaddr_name)
|
|||||||
if (!envaddr)
|
if (!envaddr)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
if (strict_strtoul(envaddr, 16, (unsigned long *)&file_addr) < 0)
|
if (strict_strtoul(envaddr, 16, &file_addr) < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return get_relfile(file_path, file_addr);
|
return get_relfile(file_path, (void *)file_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -80,6 +80,9 @@ block_dev_desc_t *get_dev(char* ifname, int dev)
|
|||||||
block_dev_desc_t* (*reloc_get_dev)(int dev);
|
block_dev_desc_t* (*reloc_get_dev)(int dev);
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
if (!ifname)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
name = drvr->name;
|
name = drvr->name;
|
||||||
#ifdef CONFIG_NEEDS_MANUAL_RELOC
|
#ifdef CONFIG_NEEDS_MANUAL_RELOC
|
||||||
name += gd->reloc_off;
|
name += gd->reloc_off;
|
||||||
|
@ -91,7 +91,7 @@ of the flags are the same on all implementations.
|
|||||||
PORTMUX_DIR_OUTPUT
|
PORTMUX_DIR_OUTPUT
|
||||||
PORTMUX_DIR_INPUT
|
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,
|
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.
|
while PORTMUX_DIR_INPUT means that the pins are tristated by the CPU.
|
||||||
These flags are ignored by portmux_select_peripheral().
|
These flags are ignored by portmux_select_peripheral().
|
||||||
@ -125,7 +125,7 @@ PORTMUX_PULL_UP.
|
|||||||
PORTMUX_DRIVE_HIGH
|
PORTMUX_DRIVE_HIGH
|
||||||
PORTMUX_DRIVE_MAX
|
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
|
pins. PORTMUX_DRIVE_MIN will give low power-consumption, but may cause
|
||||||
corruption of high-speed signals. PORTMUX_DRIVE_MAX will give high
|
corruption of high-speed signals. PORTMUX_DRIVE_MAX will give high
|
||||||
power-consumption, but may be necessary on pins toggling at very high
|
power-consumption, but may be necessary on pins toggling at very high
|
||||||
|
@ -6,7 +6,7 @@ syncronize RTC of the board. This command needs the command line
|
|||||||
parameter of server's IP address or environment variable
|
parameter of server's IP address or environment variable
|
||||||
"ntpserverip". The network time is sent as UTC. So if you want to
|
"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
|
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
|
If the DHCP server provides time server's IP or time offset, you
|
||||||
don't need to set the above environment variables yourself.
|
don't need to set the above environment variables yourself.
|
||||||
|
@ -236,7 +236,7 @@ PART 10)
|
|||||||
=> setenv serverip 192.168.0.10
|
=> setenv serverip 192.168.0.10
|
||||||
=> setenv gatewayip=192.168.0.1
|
=> setenv gatewayip=192.168.0.1
|
||||||
=> saveenv
|
=> saveenv
|
||||||
Saving Enviroment to Flash...
|
Saving Environment to Flash...
|
||||||
Un-Protected 1 sectors
|
Un-Protected 1 sectors
|
||||||
Erasing Flash...
|
Erasing Flash...
|
||||||
done
|
done
|
||||||
@ -296,7 +296,7 @@ Erase Flash Bank # 2 - missing
|
|||||||
=> cp.b 0x100000 FFF00000 1f28c
|
=> cp.b 0x100000 FFF00000 1f28c
|
||||||
Copy to Flash... done
|
Copy to Flash... done
|
||||||
=> saveenv
|
=> saveenv
|
||||||
Saving Enviroment to Flash...
|
Saving Environment to Flash...
|
||||||
Un-Protected 1 sectors
|
Un-Protected 1 sectors
|
||||||
Erasing Flash...
|
Erasing Flash...
|
||||||
done
|
done
|
||||||
@ -330,7 +330,7 @@ Erase Flash from 0xfff00000 to 0xfff3ffff
|
|||||||
done
|
done
|
||||||
Erased 7 sectors
|
Erased 7 sectors
|
||||||
Copy to Flash... done
|
Copy to Flash... done
|
||||||
Saving Enviroment to Flash...
|
Saving Environment to Flash...
|
||||||
Un-Protected 1 sectors
|
Un-Protected 1 sectors
|
||||||
Erasing Flash...
|
Erasing Flash...
|
||||||
done
|
done
|
||||||
|
@ -62,16 +62,16 @@ Environment variables
|
|||||||
U-Boot environment variables can be stored at different places:
|
U-Boot environment variables can be stored at different places:
|
||||||
- Dataflash on SPI chip select 0 (dataflash card)
|
- Dataflash on SPI chip select 0 (dataflash card)
|
||||||
- Nand flash.
|
- 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) :
|
You can choose your storage location at config step (here for at91sam9260ek) :
|
||||||
make at91sam9263ek_config - use data flash (spi cs0) (default)
|
make at91sam9263ek_config - use data flash (spi cs0) (default)
|
||||||
make at91sam9263ek_nandflash_config - use nand flash
|
make at91sam9263ek_nandflash_config - use nand flash
|
||||||
make at91sam9263ek_dataflash_cs0_config - use data flash (spi cs0)
|
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
|
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
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
=======================================================================
|
=======================================================================
|
||||||
|
|
||||||
This file contains some handy info regarding U-Boot and the AMCC
|
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.
|
information.
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ print [c<n>] [d<n>] [spd] [dimmparms] [commonparms] [opts] [addresses] [regs]
|
|||||||
c<n> - the controller number, eg. c0, c1
|
c<n> - the controller number, eg. c0, c1
|
||||||
d<n> - the DIMM number, eg. d0, d1
|
d<n> - the DIMM number, eg. d0, d1
|
||||||
spd - print SPD data
|
spd - print SPD data
|
||||||
dimmparms - DIMM paramaters, calcualted from SPD
|
dimmparms - DIMM parameters, calculated from SPD
|
||||||
commonparms - lowest common parameters for all DIMMs
|
commonparms - lowest common parameters for all DIMMs
|
||||||
opts - options
|
opts - options
|
||||||
addresses - address assignment (not implemented yet)
|
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
|
c<n> - the controller number, eg. c0, c1
|
||||||
d<n> - the DIMM number, eg. d0, d1
|
d<n> - the DIMM number, eg. d0, d1
|
||||||
spd - print SPD data
|
spd - print SPD data
|
||||||
dimmparms - DIMM paramaters, calcualted from SPD
|
dimmparms - DIMM parameters, calculated from SPD
|
||||||
commonparms - lowest common parameters for all DIMMs
|
commonparms - lowest common parameters for all DIMMs
|
||||||
opts - options
|
opts - options
|
||||||
addresses - address assignment (not implemented yet)
|
addresses - address assignment (not implemented yet)
|
||||||
|
@ -15,7 +15,7 @@ Freescale MPC832XEMDS Board
|
|||||||
"On" == 0
|
"On" == 0
|
||||||
|
|
||||||
SW3 is switch 18 as silk-screened onto the board.
|
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.
|
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.
|
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"
|
SW7[1:8]= 0000_0001 refers to bits labeled 1 through 6 is set as "On"
|
||||||
|
@ -15,7 +15,7 @@ Freescale MPC8360EMDS Board
|
|||||||
"On" == 0
|
"On" == 0
|
||||||
|
|
||||||
SW18 is switch 18 as silk-screened onto the board.
|
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.
|
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[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"
|
SW3[1:8]= 0000_0001 refers to bits labeled 1 through 6 is set as "On"
|
||||||
|
@ -14,7 +14,7 @@ Freescale MPC837xEMDS Board
|
|||||||
"Off" == 1
|
"Off" == 1
|
||||||
"On" == 0
|
"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: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"
|
SW2[1:8]= 0000_0001 refers to bits labeled 1 through 7 is set as "On"
|
||||||
and bits labeled 8 is set as "Off".
|
and bits labeled 8 is set as "Off".
|
||||||
|
@ -22,7 +22,7 @@ boot bank at 0xfff8_0000.
|
|||||||
Memory Map
|
Memory Map
|
||||||
----------
|
----------
|
||||||
|
|
||||||
0xff80_0000 - 0xffbf_ffff Alernate bank 4MB
|
0xff80_0000 - 0xffbf_ffff Alternate bank 4MB
|
||||||
0xffc0_0000 - 0xffff_ffff Boot bank 4MB
|
0xffc0_0000 - 0xffff_ffff Boot bank 4MB
|
||||||
|
|
||||||
0xffb8_0000 Alternate image start 512KB
|
0xffb8_0000 Alternate image start 512KB
|
||||||
|
@ -19,7 +19,7 @@ Booting is always from the boot bank at 0xec00_0000.
|
|||||||
Memory Map
|
Memory Map
|
||||||
----------
|
----------
|
||||||
|
|
||||||
0xe800_0000 - 0xebff_ffff Alernate bank 64MB
|
0xe800_0000 - 0xebff_ffff Alternate bank 64MB
|
||||||
0xec00_0000 - 0xefff_ffff Boot bank 64MB
|
0xec00_0000 - 0xefff_ffff Boot bank 64MB
|
||||||
|
|
||||||
0xebf8_0000 - 0xebff_ffff Alternate u-boot address 512KB
|
0xebf8_0000 - 0xebff_ffff Alternate u-boot address 512KB
|
||||||
@ -115,7 +115,7 @@ Implementing AMP(Asymmetric MultiProcessing)
|
|||||||
- Select "Advanced setup" -> " Prompt for advanced kernel
|
- Select "Advanced setup" -> " Prompt for advanced kernel
|
||||||
configuration options"
|
configuration options"
|
||||||
- Select "Set physical address where the kernel is loaded" and
|
- 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 page offset address"
|
||||||
- Select "Set custom kernel base address"
|
- Select "Set custom kernel base address"
|
||||||
- Select "Set maximum low memory"
|
- Select "Set maximum low memory"
|
||||||
|
@ -35,7 +35,7 @@ Updated 13-July-2004 Jon Loeliger
|
|||||||
"On" == 0
|
"On" == 0
|
||||||
|
|
||||||
SW18 is switch 18 as silk-screened onto the board.
|
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
|
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[7:1] refers to bits labeled 7 through 1 in order on switch 3
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ Matrix Vision mvBlueCOUGAR-P (mvBC-P)
|
|||||||
2.4 I2C
|
2.4 I2C
|
||||||
LM75 @ 0x90 for temperature monitoring.
|
LM75 @ 0x90 for temperature monitoring.
|
||||||
EEPROM @ 0xA0 for vendor specifics.
|
EEPROM @ 0xA0 for vendor specifics.
|
||||||
image sensor interface (slave adresses depend on sensor)
|
image sensor interface (slave addresses depend on sensor)
|
||||||
|
|
||||||
3 Flash layout.
|
3 Flash layout.
|
||||||
|
|
||||||
|
@ -40,10 +40,10 @@ Matrix Vision mvBlueLYNX-M7 (mvBL-M7)
|
|||||||
MAX5381 DAC @ 0x60 for 1st digital input threshold.
|
MAX5381 DAC @ 0x60 for 1st digital input threshold.
|
||||||
LM75 @ 0x90 for temperature monitoring.
|
LM75 @ 0x90 for temperature monitoring.
|
||||||
EEPROM @ 0xA0 for system setup (HRCW etc.) + vendor specifics.
|
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:
|
Bus2:
|
||||||
MAX5381 DAC @ 0x60 for 2nd digital input threshold.
|
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.
|
3 Flash layout.
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ Matrix Vision mvSMR
|
|||||||
|
|
||||||
2.4 I2C
|
2.4 I2C
|
||||||
EEPROM @ 0xA0 for vendor specifics.
|
EEPROM @ 0xA0 for vendor specifics.
|
||||||
image sensor interface (slave adresses depend on sensor)
|
image sensor interface (slave addresses depend on sensor)
|
||||||
|
|
||||||
3 Flash layout.
|
3 Flash layout.
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
=======================================================================
|
=======================================================================
|
||||||
|
|
||||||
This file contains some handy info regarding U-Boot and the AMCC
|
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.
|
information.
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ Booting by default is always from the boot bank at 0xef00_0000.
|
|||||||
|
|
||||||
Memory Map
|
Memory Map
|
||||||
----------
|
----------
|
||||||
0xef00_0000 - 0xef7f_ffff Alernate bank 8MB
|
0xef00_0000 - 0xef7f_ffff Alternate bank 8MB
|
||||||
0xe800_0000 - 0xefff_ffff Boot bank 8MB
|
0xe800_0000 - 0xefff_ffff Boot bank 8MB
|
||||||
|
|
||||||
0xef78_0000 - 0xef7f_ffff Alternate u-boot address 512KB
|
0xef78_0000 - 0xef7f_ffff Alternate u-boot address 512KB
|
||||||
@ -89,7 +89,7 @@ Implementing AMP(Asymmetric MultiProcessing)
|
|||||||
"Prompt for advanced kernel configuration options"
|
"Prompt for advanced kernel configuration options"
|
||||||
- Select
|
- Select
|
||||||
"Set physical address where the kernel is loaded"
|
"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.
|
start from 512MB.
|
||||||
- Select "Set custom page offset address"
|
- Select "Set custom page offset address"
|
||||||
- Select "Set custom kernel base address"
|
- Select "Set custom kernel base address"
|
||||||
|
@ -1168,17 +1168,6 @@ static void smc_write_phy_register (struct eth_device *dev, byte phyreg,
|
|||||||
#endif /* !CONFIG_SMC91111_EXT_PHY */
|
#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
|
. Configures the specified PHY using Autonegotiation. Calls
|
||||||
. smc_phy_fixed() if the user has requested a certain config.
|
. 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
smc_wait_ms (500); /* wait 500 millisecs */
|
mdelay(500); /* wait 500 millisecs */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout < 1) {
|
if (timeout < 1) {
|
||||||
@ -1270,7 +1259,7 @@ static void smc_phy_configure (struct eth_device *dev)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
smc_wait_ms (500); /* wait 500 millisecs */
|
mdelay(500); /* wait 500 millisecs */
|
||||||
|
|
||||||
/* Restart auto-negotiation if remote fault */
|
/* Restart auto-negotiation if remote fault */
|
||||||
if (status & PHY_STAT_REM_FLT) {
|
if (status & PHY_STAT_REM_FLT) {
|
||||||
|
@ -41,23 +41,19 @@ static void uppercase(char *str, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int total_sector;
|
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;
|
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");
|
printf("error: overflow occurs\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
startblock += part_offset;
|
return cur_dev->block_write(cur_dev->dev,
|
||||||
|
cur_part_info.start + block, nr_blocks, buf);
|
||||||
if (cur_dev->block_read) {
|
|
||||||
return cur_dev->block_write(cur_dev->dev, startblock, getsize,
|
|
||||||
(unsigned long *) bufptr);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -797,7 +793,7 @@ static int check_overflow(fsdata *mydata, __u32 clustnum, unsigned long size)
|
|||||||
if (size % mydata->sect_size)
|
if (size % mydata->sect_size)
|
||||||
sect_num++;
|
sect_num++;
|
||||||
|
|
||||||
if (startsect + sect_num > total_sector)
|
if (startsect + sect_num > cur_part_info.start + total_sector)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -827,7 +823,6 @@ static dir_entry *empty_dentptr;
|
|||||||
static dir_entry *find_directory_entry(fsdata *mydata, int startsect,
|
static dir_entry *find_directory_entry(fsdata *mydata, int startsect,
|
||||||
char *filename, dir_entry *retdent, __u32 start)
|
char *filename, dir_entry *retdent, __u32 start)
|
||||||
{
|
{
|
||||||
__u16 prevcksum = 0xffff;
|
|
||||||
__u32 curclust = (startsect - mydata->data_begin) / mydata->clust_size;
|
__u32 curclust = (startsect - mydata->data_begin) / mydata->clust_size;
|
||||||
|
|
||||||
debug("get_dentfromdir: %s\n", filename);
|
debug("get_dentfromdir: %s\n", filename);
|
||||||
@ -861,8 +856,6 @@ static dir_entry *find_directory_entry(fsdata *mydata, int startsect,
|
|||||||
#ifdef CONFIG_SUPPORT_VFAT
|
#ifdef CONFIG_SUPPORT_VFAT
|
||||||
if ((dentptr->attr & ATTR_VFAT) &&
|
if ((dentptr->attr & ATTR_VFAT) &&
|
||||||
(dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
|
(dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
|
||||||
prevcksum =
|
|
||||||
((dir_slot *)dentptr)->alias_checksum;
|
|
||||||
get_long_file_name(mydata, curclust,
|
get_long_file_name(mydata, curclust,
|
||||||
get_dentfromdir_block,
|
get_dentfromdir_block,
|
||||||
&dentptr, l_name);
|
&dentptr, l_name);
|
||||||
@ -926,7 +919,6 @@ static int do_fat_write(const char *filename, void *buffer,
|
|||||||
unsigned long size)
|
unsigned long size)
|
||||||
{
|
{
|
||||||
dir_entry *dentptr, *retdent;
|
dir_entry *dentptr, *retdent;
|
||||||
dir_slot *slotptr;
|
|
||||||
__u32 startsect;
|
__u32 startsect;
|
||||||
__u32 start_cluster;
|
__u32 start_cluster;
|
||||||
boot_sector bs;
|
boot_sector bs;
|
||||||
@ -934,7 +926,7 @@ static int do_fat_write(const char *filename, void *buffer,
|
|||||||
fsdata datablock;
|
fsdata datablock;
|
||||||
fsdata *mydata = &datablock;
|
fsdata *mydata = &datablock;
|
||||||
int cursect;
|
int cursect;
|
||||||
int root_cluster, ret = -1, name_len;
|
int ret = -1, name_len;
|
||||||
char l_filename[VFAT_MAXLEN_BYTES];
|
char l_filename[VFAT_MAXLEN_BYTES];
|
||||||
int write_size = size;
|
int write_size = size;
|
||||||
|
|
||||||
@ -947,9 +939,7 @@ static int do_fat_write(const char *filename, void *buffer,
|
|||||||
|
|
||||||
total_sector = bs.total_sect;
|
total_sector = bs.total_sect;
|
||||||
if (total_sector == 0)
|
if (total_sector == 0)
|
||||||
total_sector = part_size;
|
total_sector = cur_part_info.size;
|
||||||
|
|
||||||
root_cluster = bs.root_cluster;
|
|
||||||
|
|
||||||
if (mydata->fatsize == 32)
|
if (mydata->fatsize == 32)
|
||||||
mydata->fatlength = bs.fat32_length;
|
mydata->fatlength = bs.fat32_length;
|
||||||
@ -1051,8 +1041,6 @@ static int do_fat_write(const char *filename, void *buffer,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
slotptr = (dir_slot *)empty_dentptr;
|
|
||||||
|
|
||||||
/* Set short name to set alias checksum field in dir_slot */
|
/* Set short name to set alias checksum field in dir_slot */
|
||||||
set_name(empty_dentptr, filename);
|
set_name(empty_dentptr, filename);
|
||||||
fill_dir_slot(mydata, &empty_dentptr, filename);
|
fill_dir_slot(mydata, &empty_dentptr, filename);
|
||||||
|
@ -157,7 +157,6 @@
|
|||||||
#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
|
#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
|
||||||
sizeof(CONFIG_SYS_PROMPT) + 16)
|
sizeof(CONFIG_SYS_PROMPT) + 16)
|
||||||
#define CONFIG_SYS_LONGHELP
|
#define CONFIG_SYS_LONGHELP
|
||||||
#define CONFIG_SYS_EXTBDINFO
|
|
||||||
#define CONFIG_CMDLINE_EDITING
|
#define CONFIG_CMDLINE_EDITING
|
||||||
#define CONFIG_AUTO_COMPLETE
|
#define CONFIG_AUTO_COMPLETE
|
||||||
#define CONFIG_SYS_HUSH_PARSER
|
#define CONFIG_SYS_HUSH_PARSER
|
||||||
|
@ -107,8 +107,8 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug ("LZMA: Uncompresed size............ 0x%x\n", outSizeFull);
|
debug("LZMA: Uncompresed size............ 0x%zx\n", outSizeFull);
|
||||||
debug ("LZMA: Compresed size.............. 0x%x\n", compressedSize);
|
debug("LZMA: Compresed size.............. 0x%zx\n", compressedSize);
|
||||||
|
|
||||||
g_Alloc.Alloc = SzAlloc;
|
g_Alloc.Alloc = SzAlloc;
|
||||||
g_Alloc.Free = SzFree;
|
g_Alloc.Free = SzFree;
|
||||||
|
@ -31,13 +31,15 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <compiler.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#include "compiler.h"
|
||||||
#include <u-boot/crc.h>
|
#include <u-boot/crc.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
@ -45,12 +47,9 @@
|
|||||||
|
|
||||||
static void usage(const char *exec_name)
|
static void usage(const char *exec_name)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s [-h] [-r] [-b] [-p <byte>] "
|
fprintf(stderr, "%s [-h] [-r] [-b] [-p <byte>] -s <environment partition size> -o <output> <input file>\n"
|
||||||
"-s <environment partition size> -o <output> <input file>\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"This tool takes a key=value input file (same as would a "
|
"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"
|
||||||
"`printenv' show) and generates the corresponding environment "
|
|
||||||
"image, ready to be flashed.\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"\tThe input file is in format:\n"
|
"\tThe input file is in format:\n"
|
||||||
"\t\tkey1=value1\n"
|
"\t\tkey1=value1\n"
|
||||||
@ -58,14 +57,31 @@ static void usage(const char *exec_name)
|
|||||||
"\t\t...\n"
|
"\t\t...\n"
|
||||||
"\t-r : the environment has multiple copies in flash\n"
|
"\t-r : the environment has multiple copies in flash\n"
|
||||||
"\t-b : the target is big endian (default is little endian)\n"
|
"\t-b : the target is big endian (default is little endian)\n"
|
||||||
"\t-p <byte> : fill the image with <byte> bytes instead of "
|
"\t-p <byte> : fill the image with <byte> bytes instead of 0xff bytes\n"
|
||||||
"0xff bytes\n"
|
|
||||||
"\t-V : print version information and exit\n"
|
"\t-V : print version information and exit\n"
|
||||||
"\n"
|
"\n"
|
||||||
"If the input file is \"-\", data is read from standard input\n",
|
"If the input file is \"-\", data is read from standard input\n",
|
||||||
exec_name);
|
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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
uint32_t crc, targetendian_crc;
|
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) {
|
while ((option = getopt(argc, argv, ":s:o:rbp:hV")) != -1) {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 's':
|
case 's':
|
||||||
datasize = strtol(optarg, NULL, 0);
|
datasize = xstrtol(optarg);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
bin_filename = strdup(optarg);
|
bin_filename = strdup(optarg);
|
||||||
if (!bin_filename) {
|
if (!bin_filename) {
|
||||||
fprintf(stderr, "Can't strdup() the output "
|
fprintf(stderr, "Can't strdup() the output filename\n");
|
||||||
"filename\n");
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -112,7 +127,7 @@ int main(int argc, char **argv)
|
|||||||
bigendian = 1;
|
bigendian = 1;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
padbyte = strtol(optarg, NULL, 0);
|
padbyte = xstrtol(optarg);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(prg);
|
usage(prg);
|
||||||
@ -123,7 +138,7 @@ int main(int argc, char **argv)
|
|||||||
case ':':
|
case ':':
|
||||||
fprintf(stderr, "Missing argument for option -%c\n",
|
fprintf(stderr, "Missing argument for option -%c\n",
|
||||||
optopt);
|
optopt);
|
||||||
usage(argv[0]);
|
usage(prg);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Wrong option -%c\n", optopt);
|
fprintf(stderr, "Wrong option -%c\n", optopt);
|
||||||
@ -134,22 +149,21 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Check datasize and allocate the data */
|
/* Check datasize and allocate the data */
|
||||||
if (datasize == 0) {
|
if (datasize == 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr, "Please specify the size of the environment partition.\n");
|
||||||
"Please specify the size of the environment "
|
|
||||||
"partition.\n");
|
|
||||||
usage(prg);
|
usage(prg);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataptr = malloc(datasize * sizeof(*dataptr));
|
dataptr = malloc(datasize * sizeof(*dataptr));
|
||||||
if (!dataptr) {
|
if (!dataptr) {
|
||||||
fprintf(stderr, "Can't alloc dataptr.\n");
|
fprintf(stderr, "Can't alloc %d bytes for dataptr.\n",
|
||||||
|
datasize);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* envptr points to the beginning of the actual environment (after the
|
* 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);
|
envsize = datasize - (CRC_SIZE + redundant);
|
||||||
envptr = dataptr + CRC_SIZE + redundant;
|
envptr = dataptr + CRC_SIZE + redundant;
|
||||||
@ -158,24 +172,28 @@ int main(int argc, char **argv)
|
|||||||
memset(envptr, padbyte, envsize);
|
memset(envptr, padbyte, envsize);
|
||||||
|
|
||||||
/* Open the input file ... */
|
/* Open the input file ... */
|
||||||
if (optind >= argc) {
|
if (optind >= argc || strcmp(argv[optind], "-") == 0) {
|
||||||
fprintf(stderr, "Please specify an input filename\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
txt_filename = argv[optind];
|
|
||||||
if (strcmp(txt_filename, "-") == 0) {
|
|
||||||
int readbytes = 0;
|
int readbytes = 0;
|
||||||
int readlen = sizeof(*envptr) * 2048;
|
int readlen = sizeof(*envptr) * 4096;
|
||||||
txt_fd = STDIN_FILENO;
|
txt_fd = STDIN_FILENO;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
filebuf = realloc(filebuf, readlen);
|
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);
|
readbytes = read(txt_fd, filebuf + filesize, readlen);
|
||||||
|
if (errno) {
|
||||||
|
fprintf(stderr, "Error while reading stdin: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
filesize += readbytes;
|
filesize += readbytes;
|
||||||
} while (readbytes == readlen);
|
} while (readbytes == readlen);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
txt_filename = argv[optind];
|
||||||
txt_fd = open(txt_filename, O_RDONLY);
|
txt_fd = open(txt_filename, O_RDONLY);
|
||||||
if (txt_fd == -1) {
|
if (txt_fd == -1) {
|
||||||
fprintf(stderr, "Can't open \"%s\": %s\n",
|
fprintf(stderr, "Can't open \"%s\": %s\n",
|
||||||
@ -185,28 +203,36 @@ int main(int argc, char **argv)
|
|||||||
/* ... and check it */
|
/* ... and check it */
|
||||||
ret = fstat(txt_fd, &txt_file_stat);
|
ret = fstat(txt_fd, &txt_file_stat);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
fprintf(stderr, "Can't stat() on \"%s\": "
|
fprintf(stderr, "Can't stat() on \"%s\": %s\n",
|
||||||
"%s\n", txt_filename, strerror(errno));
|
txt_filename, strerror(errno));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
filesize = txt_file_stat.st_size;
|
filesize = txt_file_stat.st_size;
|
||||||
/* Read the raw input file and transform it */
|
|
||||||
|
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);
|
filebuf = malloc(sizeof(*envptr) * filesize);
|
||||||
ret = read(txt_fd, filebuf, sizeof(*envptr) * filesize);
|
ret = read(txt_fd, filebuf, sizeof(*envptr) * filesize);
|
||||||
if (ret != sizeof(*envptr) * filesize) {
|
if (ret != sizeof(*envptr) * filesize) {
|
||||||
fprintf(stderr, "Can't read the whole input file\n");
|
fprintf(stderr, "Can't read the whole input file (%ld bytes): %s\n",
|
||||||
|
sizeof(*envptr) * filesize,
|
||||||
|
strerror(errno));
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ret = close(txt_fd);
|
ret = close(txt_fd);
|
||||||
}
|
}
|
||||||
/*
|
/* The +1 is for the additionnal ending \0. See below. */
|
||||||
* The right test to do is "=>" (not ">") because of the additional
|
if (filesize + 1 > envsize) {
|
||||||
* ending \0. See below.
|
fprintf(stderr, "The input file is larger than the environment partition size\n");
|
||||||
*/
|
|
||||||
if (filesize >= envsize) {
|
|
||||||
fprintf(stderr, "The input file is larger than the "
|
|
||||||
"environment partition size\n");
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,14 +258,6 @@ int main(int argc, char **argv)
|
|||||||
/* End of a variable */
|
/* End of a variable */
|
||||||
envptr[ep++] = '\0';
|
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 {
|
} else {
|
||||||
envptr[ep++] = filebuf[fp];
|
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
|
* check the env size again to make sure we have room for two \0
|
||||||
*/
|
*/
|
||||||
if (ep >= envsize) {
|
if (ep >= envsize) {
|
||||||
fprintf(stderr, "The environment file is too large for "
|
fprintf(stderr, "The environment file is too large for the target environment storage\n");
|
||||||
"the target environment storage\n");
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
envptr[ep] = '\0';
|
envptr[ep] = '\0';
|
||||||
@ -268,14 +285,21 @@ int main(int argc, char **argv)
|
|||||||
crc = crc32(0, envptr, envsize);
|
crc = crc32(0, envptr, envsize);
|
||||||
targetendian_crc = bigendian ? cpu_to_be32(crc) : cpu_to_le32(crc);
|
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_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) {
|
if (bin_fd == -1) {
|
||||||
fprintf(stderr, "Can't open output file \"%s\": %s\n",
|
fprintf(stderr, "Can't open output file \"%s\": %s\n",
|
||||||
bin_filename, strerror(errno));
|
bin_filename, strerror(errno));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (write(bin_fd, dataptr, sizeof(*dataptr) * datasize) !=
|
if (write(bin_fd, dataptr, sizeof(*dataptr) * datasize) !=
|
||||||
sizeof(*dataptr) * datasize) {
|
sizeof(*dataptr) * datasize) {
|
||||||
|
Loading…
Reference in New Issue
Block a user