mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-14 12:56:00 +01:00
Merge branch 'master' into next
Conflicts: board/esd/plu405/plu405.c drivers/rtc/ftrtc010.c Signed-off-by: Wolfgang Denk <wd@denx.de>
This commit is contained in:
commit
2a49bf3149
@ -279,7 +279,7 @@ Nye Liu <nyet@zumanetworks.com>
|
|||||||
|
|
||||||
ZUMA MPC7xx_74xx
|
ZUMA MPC7xx_74xx
|
||||||
|
|
||||||
Jon Loeliger <jdl@freescale.com>
|
Kumar Gala <kumar.gala@freescale.com>
|
||||||
|
|
||||||
MPC8540ADS MPC8540
|
MPC8540ADS MPC8540
|
||||||
MPC8560ADS MPC8560
|
MPC8560ADS MPC8560
|
||||||
|
46
README
46
README
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# (C) Copyright 2000 - 2008
|
# (C) Copyright 2000 - 2009
|
||||||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||||
#
|
#
|
||||||
# See file CREDITS for list of people who contributed to this
|
# See file CREDITS for list of people who contributed to this
|
||||||
@ -138,6 +138,7 @@ U-Boot will always have a patchlevel of "0".
|
|||||||
Directory Hierarchy:
|
Directory Hierarchy:
|
||||||
====================
|
====================
|
||||||
|
|
||||||
|
- api Machine/arch independent API for external apps
|
||||||
- board Board dependent files
|
- board Board dependent files
|
||||||
- common Misc architecture independent functions
|
- common Misc architecture independent functions
|
||||||
- cpu CPU specific files
|
- cpu CPU specific files
|
||||||
@ -178,8 +179,8 @@ Directory Hierarchy:
|
|||||||
- disk Code for disk drive partition handling
|
- disk Code for disk drive partition handling
|
||||||
- doc Documentation (don't expect too much)
|
- doc Documentation (don't expect too much)
|
||||||
- drivers Commonly used device drivers
|
- drivers Commonly used device drivers
|
||||||
- dtt Digital Thermometer and Thermostat drivers
|
|
||||||
- examples Example code for standalone applications, etc.
|
- examples Example code for standalone applications, etc.
|
||||||
|
- fs Filesystem code (cramfs, ext2, jffs2, etc.)
|
||||||
- include Header Files
|
- include Header Files
|
||||||
- lib_arm Files generic to ARM architecture
|
- lib_arm Files generic to ARM architecture
|
||||||
- lib_avr32 Files generic to AVR32 architecture
|
- lib_avr32 Files generic to AVR32 architecture
|
||||||
@ -187,9 +188,12 @@ Directory Hierarchy:
|
|||||||
- lib_generic Files generic to all architectures
|
- lib_generic Files generic to all architectures
|
||||||
- lib_i386 Files generic to i386 architecture
|
- lib_i386 Files generic to i386 architecture
|
||||||
- lib_m68k Files generic to m68k architecture
|
- lib_m68k Files generic to m68k architecture
|
||||||
|
- lib_microblaze Files generic to microblaze architecture
|
||||||
- lib_mips Files generic to MIPS architecture
|
- lib_mips Files generic to MIPS architecture
|
||||||
- lib_nios Files generic to NIOS architecture
|
- lib_nios Files generic to NIOS architecture
|
||||||
|
- lib_nios2 Files generic to NIOS2 architecture
|
||||||
- lib_ppc Files generic to PowerPC architecture
|
- lib_ppc Files generic to PowerPC architecture
|
||||||
|
- lib_sh Files generic to SH architecture
|
||||||
- lib_sparc Files generic to SPARC architecture
|
- lib_sparc Files generic to SPARC architecture
|
||||||
- libfdt Library files to support flattened device trees
|
- libfdt Library files to support flattened device trees
|
||||||
- net Networking code
|
- net Networking code
|
||||||
@ -1889,25 +1893,6 @@ The following options need to be configured:
|
|||||||
example, some LED's) on your board. At the moment,
|
example, some LED's) on your board. At the moment,
|
||||||
the following checkpoints are implemented:
|
the following checkpoints are implemented:
|
||||||
|
|
||||||
- Automatic software updates via TFTP server
|
|
||||||
CONFIG_UPDATE_TFTP
|
|
||||||
CONFIG_UPDATE_TFTP_CNT_MAX
|
|
||||||
CONFIG_UPDATE_TFTP_MSEC_MAX
|
|
||||||
|
|
||||||
These options enable and control the auto-update feature;
|
|
||||||
for a more detailed description refer to doc/README.update.
|
|
||||||
|
|
||||||
- MTD Support (mtdparts command, UBI support)
|
|
||||||
CONFIG_MTD_DEVICE
|
|
||||||
|
|
||||||
Adds the MTD device infrastructure from the Linux kernel.
|
|
||||||
Needed for mtdparts command support.
|
|
||||||
|
|
||||||
CONFIG_MTD_PARTITIONS
|
|
||||||
|
|
||||||
Adds the MTD partitioning infrastructure from the Linux
|
|
||||||
kernel. Needed for UBI support.
|
|
||||||
|
|
||||||
Legacy uImage format:
|
Legacy uImage format:
|
||||||
|
|
||||||
Arg Where When
|
Arg Where When
|
||||||
@ -2061,6 +2046,25 @@ FIT uImage format:
|
|||||||
-150 common/cmd_nand.c Incorrect FIT image format
|
-150 common/cmd_nand.c Incorrect FIT image format
|
||||||
151 common/cmd_nand.c FIT image format OK
|
151 common/cmd_nand.c FIT image format OK
|
||||||
|
|
||||||
|
- Automatic software updates via TFTP server
|
||||||
|
CONFIG_UPDATE_TFTP
|
||||||
|
CONFIG_UPDATE_TFTP_CNT_MAX
|
||||||
|
CONFIG_UPDATE_TFTP_MSEC_MAX
|
||||||
|
|
||||||
|
These options enable and control the auto-update feature;
|
||||||
|
for a more detailed description refer to doc/README.update.
|
||||||
|
|
||||||
|
- MTD Support (mtdparts command, UBI support)
|
||||||
|
CONFIG_MTD_DEVICE
|
||||||
|
|
||||||
|
Adds the MTD device infrastructure from the Linux kernel.
|
||||||
|
Needed for mtdparts command support.
|
||||||
|
|
||||||
|
CONFIG_MTD_PARTITIONS
|
||||||
|
|
||||||
|
Adds the MTD partitioning infrastructure from the Linux
|
||||||
|
kernel. Needed for UBI support.
|
||||||
|
|
||||||
|
|
||||||
Modem Support:
|
Modem Support:
|
||||||
--------------
|
--------------
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <sja1000.h>
|
||||||
|
|
||||||
#undef FPGA_DEBUG
|
#undef FPGA_DEBUG
|
||||||
|
|
||||||
@ -198,6 +199,13 @@ int misc_init_r(void)
|
|||||||
out_8((void *)DUART1_BA + 1, fctr); /* write FCTR */
|
out_8((void *)DUART1_BA + 1, fctr); /* write FCTR */
|
||||||
out_8((void *)DUART1_BA + 3, 0); /* write LCR */
|
out_8((void *)DUART1_BA + 3, 0); /* write LCR */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Init magnetic couplers
|
||||||
|
*/
|
||||||
|
if (!getenv("noinitcoupler")) {
|
||||||
|
init_coupler(CAN0_BA);
|
||||||
|
init_coupler(CAN1_BA);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +26,40 @@
|
|||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <sja1000.h>
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
extern void lxt971_no_sleep(void);
|
extern void lxt971_no_sleep(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* generate a short spike on the CAN tx line
|
||||||
|
* to bring the couplers in sync
|
||||||
|
*/
|
||||||
|
void init_coupler(u32 addr)
|
||||||
|
{
|
||||||
|
struct sja1000_basic_s *ctrl = (struct sja1000_basic_s *)addr;
|
||||||
|
|
||||||
|
/* reset */
|
||||||
|
out_8(&ctrl->cr, CR_RR);
|
||||||
|
|
||||||
|
/* dominant */
|
||||||
|
out_8(&ctrl->btr0, 0x00); /* btr setup is required */
|
||||||
|
out_8(&ctrl->btr1, 0x14); /* we use 1Mbit/s */
|
||||||
|
out_8(&ctrl->oc, OC_TP1 | OC_TN1 | OC_POL1 |
|
||||||
|
OC_TP0 | OC_TN0 | OC_POL0 | OC_MODE1);
|
||||||
|
out_8(&ctrl->cr, 0x00);
|
||||||
|
|
||||||
|
/* delay */
|
||||||
|
in_8(&ctrl->cr);
|
||||||
|
in_8(&ctrl->cr);
|
||||||
|
in_8(&ctrl->cr);
|
||||||
|
in_8(&ctrl->cr);
|
||||||
|
|
||||||
|
/* reset */
|
||||||
|
out_8(&ctrl->cr, CR_RR);
|
||||||
|
}
|
||||||
|
|
||||||
int board_early_init_f (void)
|
int board_early_init_f (void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -77,6 +106,12 @@ int misc_init_r (void)
|
|||||||
gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
|
gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
|
||||||
gd->bd->bi_flashoffset = 0;
|
gd->bd->bi_flashoffset = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Init magnetic coupler
|
||||||
|
*/
|
||||||
|
if (!getenv("noinitcoupler"))
|
||||||
|
init_coupler(CAN_BA);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,24 +550,11 @@ void pci_init_board(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
|
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
|
||||||
void ft_blob_update(void *blob, bd_t *bd)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
|
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
printf("ft_blob_update(): cannot set /memory/reg "
|
|
||||||
"property err:%s\n", fdt_strerror(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ft_board_setup(void *blob, bd_t *bd)
|
void ft_board_setup(void *blob, bd_t *bd)
|
||||||
{
|
{
|
||||||
ft_cpu_setup(blob, bd);
|
ft_cpu_setup(blob, bd);
|
||||||
#ifdef CONFIG_PCI
|
#ifdef CONFIG_PCI
|
||||||
ft_pci_setup(blob, bd);
|
ft_pci_setup(blob, bd);
|
||||||
#endif
|
#endif
|
||||||
ft_blob_update(blob, bd);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -400,24 +400,8 @@ int board_nand_init(struct nand_chip *nand)
|
|||||||
#endif /* CONFIG_CMD_NAND */
|
#endif /* CONFIG_CMD_NAND */
|
||||||
|
|
||||||
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
|
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
|
||||||
/*
|
|
||||||
* update "memory" property in the blob
|
|
||||||
*/
|
|
||||||
void ft_blob_update(void *blob, bd_t *bd)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
|
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
printf("ft_blob_update(): cannot set /memory/reg "
|
|
||||||
"property err:%s\n", fdt_strerror(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ft_board_setup(void *blob, bd_t *bd)
|
void ft_board_setup(void *blob, bd_t *bd)
|
||||||
{
|
{
|
||||||
ft_cpu_setup( blob, bd);
|
ft_cpu_setup( blob, bd);
|
||||||
ft_blob_update(blob, bd);
|
|
||||||
}
|
}
|
||||||
#endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */
|
#endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */
|
||||||
|
@ -312,11 +312,10 @@ int hush_init_var (void)
|
|||||||
|
|
||||||
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
|
#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
|
||||||
/*
|
/*
|
||||||
* update "memory" property in the blob
|
* update "flash" property in the blob
|
||||||
*/
|
*/
|
||||||
void ft_blob_update (void *blob, bd_t *bd)
|
void ft_blob_update (void *blob, bd_t *bd)
|
||||||
{
|
{
|
||||||
ulong memory_data[2] = {0};
|
|
||||||
ulong *flash_data = NULL;
|
ulong *flash_data = NULL;
|
||||||
ulong flash_reg[6] = {0};
|
ulong flash_reg[6] = {0};
|
||||||
flash_info_t *info;
|
flash_info_t *info;
|
||||||
@ -324,11 +323,6 @@ void ft_blob_update (void *blob, bd_t *bd)
|
|||||||
int size;
|
int size;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
memory_data[0] = cpu_to_be32 (bd->bi_memstart);
|
|
||||||
memory_data[1] = cpu_to_be32 (bd->bi_memsize);
|
|
||||||
fdt_set_node_and_value (blob, "/memory", "reg", memory_data,
|
|
||||||
sizeof (memory_data));
|
|
||||||
|
|
||||||
len = fdt_get_node_and_value (blob, "/localbus", "ranges",
|
len = fdt_get_node_and_value (blob, "/localbus", "ranges",
|
||||||
(void *)&flash_data);
|
(void *)&flash_data);
|
||||||
|
|
||||||
|
@ -308,25 +308,9 @@ int board_early_init_r (void)
|
|||||||
void ft_blob_update (void *blob, bd_t *bd)
|
void ft_blob_update (void *blob, bd_t *bd)
|
||||||
{
|
{
|
||||||
int ret, nodeoffset = 0;
|
int ret, nodeoffset = 0;
|
||||||
ulong memory_data[2] = {0};
|
|
||||||
ulong flash_data[4] = {0};
|
ulong flash_data[4] = {0};
|
||||||
ulong speed = 0;
|
ulong speed = 0;
|
||||||
|
|
||||||
memory_data[0] = cpu_to_be32 (bd->bi_memstart);
|
|
||||||
memory_data[1] = cpu_to_be32 (bd->bi_memsize);
|
|
||||||
|
|
||||||
nodeoffset = fdt_path_offset (blob, "/memory");
|
|
||||||
if (nodeoffset >= 0) {
|
|
||||||
ret = fdt_setprop (blob, nodeoffset, "reg", memory_data,
|
|
||||||
sizeof(memory_data));
|
|
||||||
if (ret < 0)
|
|
||||||
printf ("ft_blob_update): cannot set /memory/reg "
|
|
||||||
"property err:%s\n", fdt_strerror (ret));
|
|
||||||
} else {
|
|
||||||
/* memory node is required in dts */
|
|
||||||
printf ("ft_blob_update(): cannot find /memory node "
|
|
||||||
"err:%s\n", fdt_strerror(nodeoffset));
|
|
||||||
}
|
|
||||||
/* update Flash addr, size */
|
/* update Flash addr, size */
|
||||||
flash_data[2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
|
flash_data[2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
|
||||||
flash_data[3] = cpu_to_be32 (CONFIG_SYS_FLASH_SIZE);
|
flash_data[3] = cpu_to_be32 (CONFIG_SYS_FLASH_SIZE);
|
||||||
|
@ -29,7 +29,6 @@ AOBJS =
|
|||||||
|
|
||||||
# core
|
# core
|
||||||
COBJS-y += main.o
|
COBJS-y += main.o
|
||||||
COBJS-y += circbuf.o
|
|
||||||
COBJS-y += console.o
|
COBJS-y += console.o
|
||||||
COBJS-y += command.o
|
COBJS-y += command.o
|
||||||
COBJS-y += dlmalloc.o
|
COBJS-y += dlmalloc.o
|
||||||
|
@ -133,7 +133,7 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
|||||||
static boot_os_fn do_bootm_integrity;
|
static boot_os_fn do_bootm_integrity;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
boot_os_fn * boot_os[] = {
|
static boot_os_fn *boot_os[] = {
|
||||||
#ifdef CONFIG_BOOTM_LINUX
|
#ifdef CONFIG_BOOTM_LINUX
|
||||||
[IH_OS_LINUX] = do_bootm_linux,
|
[IH_OS_LINUX] = do_bootm_linux,
|
||||||
#endif
|
#endif
|
||||||
@ -546,7 +546,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_OF_LIBFDT
|
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_SYS_BOOTMAPSZ)
|
||||||
case BOOTM_STATE_FDT:
|
case BOOTM_STATE_FDT:
|
||||||
{
|
{
|
||||||
ulong bootmap_base = getenv_bootm_low();
|
ulong bootmap_base = getenv_bootm_low();
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_CACHE)
|
|
||||||
|
|
||||||
static int on_off (const char *);
|
static int on_off (const char *);
|
||||||
|
|
||||||
int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
@ -108,5 +106,3 @@ U_BOOT_CMD(
|
|||||||
"[on, off]\n"
|
"[on, off]\n"
|
||||||
" - enable or disable data (writethrough) cache"
|
" - enable or disable data (writethrough) cache"
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -71,9 +71,9 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||||||
/* and write to RTC */
|
/* and write to RTC */
|
||||||
rcode = rtc_set (&tm);
|
rcode = rtc_set (&tm);
|
||||||
if(rcode)
|
if(rcode)
|
||||||
puts("## Set date failled\n");
|
puts("## Set date failed\n");
|
||||||
} else {
|
} else {
|
||||||
puts("## Get date failled\n");
|
puts("## Get date failed\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* FALL TROUGH */
|
/* FALL TROUGH */
|
||||||
@ -81,7 +81,7 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||||||
rcode = rtc_get (&tm);
|
rcode = rtc_get (&tm);
|
||||||
|
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
puts("## Get date failled\n");
|
puts("## Get date failed\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,14 +326,6 @@ int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||||||
#if !defined(CONFIG_SYS_I2C_FRAM)
|
#if !defined(CONFIG_SYS_I2C_FRAM)
|
||||||
udelay(11000);
|
udelay(11000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
|
||||||
for (timeout = 0; timeout < 10; timeout++) {
|
|
||||||
udelay(2000);
|
|
||||||
if (i2c_probe(chip) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -47,3 +47,12 @@ U_BOOT_CMD(
|
|||||||
"enable or disable interrupts",
|
"enable or disable interrupts",
|
||||||
"[on, off]"
|
"[on, off]"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/* Implemented in $(CPU)/interrupts.c */
|
||||||
|
int do_irqinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||||
|
|
||||||
|
U_BOOT_CMD(
|
||||||
|
irqinfo, 1, 1, do_irqinfo,
|
||||||
|
"print information about IRQs",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_LICENSE)
|
|
||||||
|
|
||||||
/* COPYING is currently 15951 bytes in size */
|
/* COPYING is currently 15951 bytes in size */
|
||||||
#define LICENSE_MAX 20480
|
#define LICENSE_MAX 20480
|
||||||
|
|
||||||
@ -56,5 +54,3 @@ U_BOOT_CMD(license, 1, 1, do_license,
|
|||||||
"print GPL license text",
|
"print GPL license text",
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif /* CONFIG_CMD_LICENSE */
|
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
|
||||||
#if defined (CONFIG_CMD_MG_DISK)
|
|
||||||
|
|
||||||
#include <mg_disk.h>
|
#include <mg_disk.h>
|
||||||
|
|
||||||
int do_mg_disk_cmd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
int do_mg_disk_cmd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||||
@ -72,5 +70,3 @@ U_BOOT_CMD(
|
|||||||
" - sector read : mgd readsec [sector] [to] [counts]\n"
|
" - sector read : mgd readsec [sector] [to] [counts]\n"
|
||||||
" - sector write : mgd writesec [from] [sector] [counts]"
|
" - sector write : mgd writesec [from] [sector] [counts]"
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -49,17 +49,6 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implemented in $(CPU)/interrupts.c */
|
|
||||||
#if defined(CONFIG_CMD_IRQ)
|
|
||||||
int do_irqinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
|
||||||
|
|
||||||
U_BOOT_CMD(
|
|
||||||
irqinfo, 1, 1, do_irqinfo,
|
|
||||||
"print information about IRQs",
|
|
||||||
""
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
U_BOOT_CMD(
|
U_BOOT_CMD(
|
||||||
sleep , 2, 1, do_sleep,
|
sleep , 2, 1, do_sleep,
|
||||||
"delay execution for some time",
|
"delay execution for some time",
|
||||||
|
@ -318,6 +318,7 @@ void ft_cpu_setup (void *blob, bd_t *bd)
|
|||||||
"timebase-frequency", OF_TBCLK, 1);
|
"timebase-frequency", OF_TBCLK, 1);
|
||||||
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
||||||
"clock-frequency", bd->bi_intfreq, 1);
|
"clock-frequency", bd->bi_intfreq, 1);
|
||||||
|
fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_OF_LIBFDT */
|
#endif /* CONFIG_OF_LIBFDT */
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Simple U-boot uImage source file containing a single kernel
|
* Simple U-boot uImage source file containing a single kernel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
description = "Simple image with single Linux kernel";
|
description = "Simple image with single Linux kernel";
|
||||||
#address-cells = <1>;
|
#address-cells = <1>;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Simple U-boot uImage source file containing a single kernel and FDT blob
|
* Simple U-boot uImage source file containing a single kernel and FDT blob
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
description = "Simple image with single Linux kernel and FDT blob";
|
description = "Simple image with single Linux kernel and FDT blob";
|
||||||
#address-cells = <1>;
|
#address-cells = <1>;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* U-boot uImage source file with multiple kernels, ramdisks and FDT blobs
|
* U-boot uImage source file with multiple kernels, ramdisks and FDT blobs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
description = "Various kernels, ramdisks and FDT blobs";
|
description = "Various kernels, ramdisks and FDT blobs";
|
||||||
#address-cells = <1>;
|
#address-cells = <1>;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Example Automatic software update file.
|
* Example Automatic software update file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
description = "Automatic software updates: kernel, ramdisk, FDT";
|
description = "Automatic software updates: kernel, ramdisk, FDT";
|
||||||
#address-cells = <1>;
|
#address-cells = <1>;
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
* Automatic software update for U-Boot
|
* Automatic software update for U-Boot
|
||||||
* Make sure the flashing addresses ('load' prop) is correct for your board!
|
* Make sure the flashing addresses ('load' prop) is correct for your board!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
description = "Automatic U-Boot update";
|
description = "Automatic U-Boot update";
|
||||||
#address-cells = <1>;
|
#address-cells = <1>;
|
||||||
|
@ -31,6 +31,7 @@ COBJS-$(CONFIG_SPI_FLASH_MACRONIX) += macronix.o
|
|||||||
COBJS-$(CONFIG_SPI_FLASH_SPANSION) += spansion.o
|
COBJS-$(CONFIG_SPI_FLASH_SPANSION) += spansion.o
|
||||||
COBJS-$(CONFIG_SPI_FLASH_SST) += sst.o
|
COBJS-$(CONFIG_SPI_FLASH_SST) += sst.o
|
||||||
COBJS-$(CONFIG_SPI_FLASH_STMICRO) += stmicro.o
|
COBJS-$(CONFIG_SPI_FLASH_STMICRO) += stmicro.o
|
||||||
|
COBJS-$(CONFIG_SPI_FLASH_WINBOND) += winbond.o
|
||||||
COBJS-$(CONFIG_SPI_M95XXX) += eeprom_m95xxx.o
|
COBJS-$(CONFIG_SPI_M95XXX) += eeprom_m95xxx.o
|
||||||
|
|
||||||
COBJS := $(COBJS-y)
|
COBJS := $(COBJS-y)
|
||||||
|
@ -140,6 +140,11 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
|
|||||||
flash = spi_flash_probe_macronix(spi, idcode);
|
flash = spi_flash_probe_macronix(spi, idcode);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_SPI_FLASH_WINBOND
|
||||||
|
case 0xef:
|
||||||
|
flash = spi_flash_probe_winbond(spi, idcode);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_SPI_FLASH_STMICRO
|
#ifdef CONFIG_SPI_FLASH_STMICRO
|
||||||
case 0x20:
|
case 0x20:
|
||||||
flash = spi_flash_probe_stmicro(spi, idcode);
|
flash = spi_flash_probe_stmicro(spi, idcode);
|
||||||
|
@ -49,3 +49,4 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode);
|
|||||||
struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode);
|
struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode);
|
||||||
struct spi_flash *spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode);
|
struct spi_flash *spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode);
|
||||||
struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode);
|
struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode);
|
||||||
|
struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode);
|
||||||
|
@ -281,7 +281,8 @@ int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
for (actual = 0; actual < len; actual++) {
|
for (actual = 0; actual < len; actual++) {
|
||||||
cmd[1] = (offset / sector_size) + actual;
|
cmd[1] = offset >> 16;
|
||||||
|
offset += sector_size;
|
||||||
|
|
||||||
ret = spi_flash_cmd(flash->spi, CMD_M25PXX_WREN, NULL, 0);
|
ret = spi_flash_cmd(flash->spi, CMD_M25PXX_WREN, NULL, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
332
drivers/mtd/spi/winbond.c
Normal file
332
drivers/mtd/spi/winbond.c
Normal file
@ -0,0 +1,332 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008, Network Appliance Inc.
|
||||||
|
* Author: Jason McMullan <mcmullan <at> netapp.com>
|
||||||
|
* Licensed under the GPL-2 or later.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <spi_flash.h>
|
||||||
|
|
||||||
|
#include "spi_flash_internal.h"
|
||||||
|
|
||||||
|
/* M25Pxx-specific commands */
|
||||||
|
#define CMD_W25_WREN 0x06 /* Write Enable */
|
||||||
|
#define CMD_W25_WRDI 0x04 /* Write Disable */
|
||||||
|
#define CMD_W25_RDSR 0x05 /* Read Status Register */
|
||||||
|
#define CMD_W25_WRSR 0x01 /* Write Status Register */
|
||||||
|
#define CMD_W25_READ 0x03 /* Read Data Bytes */
|
||||||
|
#define CMD_W25_FAST_READ 0x0b /* Read Data Bytes at Higher Speed */
|
||||||
|
#define CMD_W25_PP 0x02 /* Page Program */
|
||||||
|
#define CMD_W25_SE 0x20 /* Sector (4K) Erase */
|
||||||
|
#define CMD_W25_BE 0xd8 /* Block (64K) Erase */
|
||||||
|
#define CMD_W25_CE 0xc7 /* Chip Erase */
|
||||||
|
#define CMD_W25_DP 0xb9 /* Deep Power-down */
|
||||||
|
#define CMD_W25_RES 0xab /* Release from DP, and Read Signature */
|
||||||
|
|
||||||
|
#define WINBOND_ID_W25X16 0x3015
|
||||||
|
#define WINBOND_ID_W25X32 0x3016
|
||||||
|
#define WINBOND_ID_W25X64 0x3017
|
||||||
|
|
||||||
|
#define WINBOND_SR_WIP (1 << 0) /* Write-in-Progress */
|
||||||
|
|
||||||
|
struct winbond_spi_flash_params {
|
||||||
|
uint16_t id;
|
||||||
|
/* Log2 of page size in power-of-two mode */
|
||||||
|
uint8_t l2_page_size;
|
||||||
|
uint16_t pages_per_sector;
|
||||||
|
uint16_t sectors_per_block;
|
||||||
|
uint8_t nr_blocks;
|
||||||
|
const char *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* spi_flash needs to be first so upper layers can free() it */
|
||||||
|
struct winbond_spi_flash {
|
||||||
|
struct spi_flash flash;
|
||||||
|
const struct winbond_spi_flash_params *params;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline struct winbond_spi_flash *
|
||||||
|
to_winbond_spi_flash(struct spi_flash *flash)
|
||||||
|
{
|
||||||
|
return container_of(flash, struct winbond_spi_flash, flash);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
|
||||||
|
{
|
||||||
|
.id = WINBOND_ID_W25X16,
|
||||||
|
.l2_page_size = 8,
|
||||||
|
.pages_per_sector = 16,
|
||||||
|
.sectors_per_block = 16,
|
||||||
|
.nr_blocks = 32,
|
||||||
|
.name = "W25X16",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.id = WINBOND_ID_W25X32,
|
||||||
|
.l2_page_size = 8,
|
||||||
|
.pages_per_sector = 16,
|
||||||
|
.sectors_per_block = 16,
|
||||||
|
.nr_blocks = 64,
|
||||||
|
.name = "W25X32",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.id = WINBOND_ID_W25X64,
|
||||||
|
.l2_page_size = 8,
|
||||||
|
.pages_per_sector = 16,
|
||||||
|
.sectors_per_block = 16,
|
||||||
|
.nr_blocks = 128,
|
||||||
|
.name = "W25X64",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static int winbond_wait_ready(struct spi_flash *flash, unsigned long timeout)
|
||||||
|
{
|
||||||
|
struct spi_slave *spi = flash->spi;
|
||||||
|
unsigned long timebase;
|
||||||
|
int ret;
|
||||||
|
u8 status;
|
||||||
|
u8 cmd[4] = { CMD_W25_RDSR, 0xff, 0xff, 0xff };
|
||||||
|
|
||||||
|
ret = spi_xfer(spi, 32, &cmd[0], NULL, SPI_XFER_BEGIN);
|
||||||
|
if (ret) {
|
||||||
|
debug("SF: Failed to send command %02x: %d\n", cmd, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
timebase = get_timer(0);
|
||||||
|
do {
|
||||||
|
ret = spi_xfer(spi, 8, NULL, &status, 0);
|
||||||
|
if (ret) {
|
||||||
|
debug("SF: Failed to get status for cmd %02x: %d\n", cmd, ret);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((status & WINBOND_SR_WIP) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
} while (get_timer(timebase) < timeout);
|
||||||
|
|
||||||
|
spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END);
|
||||||
|
|
||||||
|
if ((status & WINBOND_SR_WIP) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
debug("SF: Timed out on command %02x: %d\n", cmd, ret);
|
||||||
|
/* Timed out */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assemble the address part of a command for Winbond devices in
|
||||||
|
* non-power-of-two page size mode.
|
||||||
|
*/
|
||||||
|
static void winbond_build_address(struct winbond_spi_flash *stm, u8 *cmd, u32 offset)
|
||||||
|
{
|
||||||
|
unsigned long page_addr;
|
||||||
|
unsigned long byte_addr;
|
||||||
|
unsigned long page_size;
|
||||||
|
unsigned int page_shift;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The "extra" space per page is the power-of-two page size
|
||||||
|
* divided by 32.
|
||||||
|
*/
|
||||||
|
page_shift = stm->params->l2_page_size;
|
||||||
|
page_size = (1 << page_shift);
|
||||||
|
page_addr = offset / page_size;
|
||||||
|
byte_addr = offset % page_size;
|
||||||
|
|
||||||
|
cmd[0] = page_addr >> (16 - page_shift);
|
||||||
|
cmd[1] = page_addr << (page_shift - 8) | (byte_addr >> 8);
|
||||||
|
cmd[2] = byte_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int winbond_read_fast(struct spi_flash *flash,
|
||||||
|
u32 offset, size_t len, void *buf)
|
||||||
|
{
|
||||||
|
struct winbond_spi_flash *stm = to_winbond_spi_flash(flash);
|
||||||
|
u8 cmd[5];
|
||||||
|
|
||||||
|
cmd[0] = CMD_READ_ARRAY_FAST;
|
||||||
|
winbond_build_address(stm, cmd + 1, offset);
|
||||||
|
cmd[4] = 0x00;
|
||||||
|
|
||||||
|
return spi_flash_read_common(flash, cmd, sizeof(cmd), buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int winbond_write(struct spi_flash *flash,
|
||||||
|
u32 offset, size_t len, const void *buf)
|
||||||
|
{
|
||||||
|
struct winbond_spi_flash *stm = to_winbond_spi_flash(flash);
|
||||||
|
unsigned long page_addr;
|
||||||
|
unsigned long byte_addr;
|
||||||
|
unsigned long page_size;
|
||||||
|
unsigned int page_shift;
|
||||||
|
size_t chunk_len;
|
||||||
|
size_t actual;
|
||||||
|
int ret;
|
||||||
|
u8 cmd[4];
|
||||||
|
|
||||||
|
page_shift = stm->params->l2_page_size;
|
||||||
|
page_size = (1 << page_shift);
|
||||||
|
page_addr = offset / page_size;
|
||||||
|
byte_addr = offset % page_size;
|
||||||
|
|
||||||
|
ret = spi_claim_bus(flash->spi);
|
||||||
|
if (ret) {
|
||||||
|
debug("SF: Unable to claim SPI bus\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (actual = 0; actual < len; actual += chunk_len) {
|
||||||
|
chunk_len = min(len - actual, page_size - byte_addr);
|
||||||
|
|
||||||
|
cmd[0] = CMD_W25_PP;
|
||||||
|
cmd[1] = page_addr >> (16 - page_shift);
|
||||||
|
cmd[2] = page_addr << (page_shift - 8) | (byte_addr >> 8);
|
||||||
|
cmd[3] = byte_addr;
|
||||||
|
debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %d\n",
|
||||||
|
buf + actual,
|
||||||
|
cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
|
||||||
|
|
||||||
|
ret = spi_flash_cmd(flash->spi, CMD_W25_WREN, NULL, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
debug("SF: Enabling Write failed\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = spi_flash_cmd_write(flash->spi, cmd, 4,
|
||||||
|
buf + actual, chunk_len);
|
||||||
|
if (ret < 0) {
|
||||||
|
debug("SF: Winbond Page Program failed\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = winbond_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
|
||||||
|
if (ret < 0) {
|
||||||
|
debug("SF: Winbond page programming timed out\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
page_addr++;
|
||||||
|
byte_addr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("SF: Winbond: Successfully programmed %u bytes @ 0x%x\n",
|
||||||
|
len, offset);
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
out:
|
||||||
|
spi_release_bus(flash->spi);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int winbond_erase(struct spi_flash *flash, u32 offset, size_t len)
|
||||||
|
{
|
||||||
|
struct winbond_spi_flash *stm = to_winbond_spi_flash(flash);
|
||||||
|
unsigned long sector_size;
|
||||||
|
unsigned int page_shift;
|
||||||
|
size_t actual;
|
||||||
|
int ret;
|
||||||
|
u8 cmd[4];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function currently uses sector erase only.
|
||||||
|
* probably speed things up by using bulk erase
|
||||||
|
* when possible.
|
||||||
|
*/
|
||||||
|
|
||||||
|
page_shift = stm->params->l2_page_size;
|
||||||
|
sector_size = (1 << page_shift) * stm->params->pages_per_sector;
|
||||||
|
|
||||||
|
if (offset % sector_size || len % sector_size) {
|
||||||
|
debug("SF: Erase offset/length not multiple of sector size\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
len /= sector_size;
|
||||||
|
cmd[0] = CMD_W25_SE;
|
||||||
|
|
||||||
|
ret = spi_claim_bus(flash->spi);
|
||||||
|
if (ret) {
|
||||||
|
debug("SF: Unable to claim SPI bus\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (actual = 0; actual < len; actual++) {
|
||||||
|
winbond_build_address(stm, &cmd[1], offset + actual * sector_size);
|
||||||
|
printf("Erase: %02x %02x %02x %02x\n",
|
||||||
|
cmd[0], cmd[1], cmd[2], cmd[3]);
|
||||||
|
|
||||||
|
ret = spi_flash_cmd(flash->spi, CMD_W25_WREN, NULL, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
debug("SF: Enabling Write failed\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = spi_flash_cmd_write(flash->spi, cmd, 4, NULL, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
debug("SF: Winbond sector erase failed\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = winbond_wait_ready(flash, SPI_FLASH_PAGE_ERASE_TIMEOUT);
|
||||||
|
if (ret < 0) {
|
||||||
|
debug("SF: Winbond sector erase timed out\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("SF: Winbond: Successfully erased %u bytes @ 0x%x\n",
|
||||||
|
len * sector_size, offset);
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
out:
|
||||||
|
spi_release_bus(flash->spi);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
|
||||||
|
{
|
||||||
|
const struct winbond_spi_flash_params *params;
|
||||||
|
unsigned long page_size;
|
||||||
|
struct winbond_spi_flash *stm;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) {
|
||||||
|
params = &winbond_spi_flash_table[i];
|
||||||
|
if (params->id == ((idcode[1] << 8) | idcode[2]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == ARRAY_SIZE(winbond_spi_flash_table)) {
|
||||||
|
debug("SF: Unsupported Winbond ID %02x%02x\n",
|
||||||
|
idcode[1], idcode[2]);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
stm = malloc(sizeof(struct winbond_spi_flash));
|
||||||
|
if (!stm) {
|
||||||
|
debug("SF: Failed to allocate memory\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
stm->params = params;
|
||||||
|
stm->flash.spi = spi;
|
||||||
|
stm->flash.name = params->name;
|
||||||
|
|
||||||
|
/* Assuming power-of-two page size initially. */
|
||||||
|
page_size = 1 << params->l2_page_size;
|
||||||
|
|
||||||
|
stm->flash.write = winbond_write;
|
||||||
|
stm->flash.erase = winbond_erase;
|
||||||
|
stm->flash.read = winbond_read_fast;
|
||||||
|
stm->flash.size = page_size * params->pages_per_sector
|
||||||
|
* params->sectors_per_block
|
||||||
|
* params->nr_blocks;
|
||||||
|
|
||||||
|
debug("SF: Detected %s with page size %u, total %u bytes\n",
|
||||||
|
params->name, page_size, stm->flash.size);
|
||||||
|
|
||||||
|
return &stm->flash;
|
||||||
|
}
|
@ -181,18 +181,4 @@ void rtc_reset (void)
|
|||||||
val = val & 0x3F;/*turn off freq test keep calibration*/
|
val = val & 0x3F;/*turn off freq test keep calibration*/
|
||||||
i2c_write(CONFIG_SYS_I2C_RTC_ADDR, RTC_CONTROL_ADDR, 1, &val, 1);
|
i2c_write(CONFIG_SYS_I2C_RTC_ADDR, RTC_CONTROL_ADDR, 1, &val, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rtc_store(int addr, unsigned char* data, int size)
|
|
||||||
{
|
|
||||||
/*don't let things wrap onto the time on a write*/
|
|
||||||
if( (addr+size) >= M41T11_STORAGE_SZ )
|
|
||||||
return 1;
|
|
||||||
return i2c_write( CONFIG_SYS_I2C_RTC_ADDR, REG_CNT+addr, 1, data, size );
|
|
||||||
}
|
|
||||||
|
|
||||||
int rtc_recall(int addr, unsigned char* data, int size)
|
|
||||||
{
|
|
||||||
return i2c_read( CONFIG_SYS_I2C_RTC_ADDR, REG_CNT+addr, 1, data, size );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -109,7 +109,7 @@ int rtc_set(struct rtc_time *rtc)
|
|||||||
|
|
||||||
spi_release_bus(slave);
|
spi_release_bus(slave);
|
||||||
|
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rtc_reset(void)
|
void rtc_reset(void)
|
||||||
|
@ -30,7 +30,8 @@
|
|||||||
#include <dataflash.h>
|
#include <dataflash.h>
|
||||||
|
|
||||||
#define AT91_SPI_PCS0_DATAFLASH_CARD 0xE /* Chip Select 0: NPCS0%1110 */
|
#define AT91_SPI_PCS0_DATAFLASH_CARD 0xE /* Chip Select 0: NPCS0%1110 */
|
||||||
#define AT91_SPI_PCS1_DATAFLASH_CARD 0xD /* Chip Select 0: NPCS0%1101 */
|
#define AT91_SPI_PCS1_DATAFLASH_CARD 0xD /* Chip Select 1: NPCS1%1101 */
|
||||||
|
#define AT91_SPI_PCS2_DATAFLASH_CARD 0xB /* Chip Select 2: NPCS2%1011 */
|
||||||
#define AT91_SPI_PCS3_DATAFLASH_CARD 0x7 /* Chip Select 3: NPCS3%0111 */
|
#define AT91_SPI_PCS3_DATAFLASH_CARD 0x7 /* Chip Select 3: NPCS3%0111 */
|
||||||
|
|
||||||
void AT91F_SpiInit(void)
|
void AT91F_SpiInit(void)
|
||||||
@ -57,7 +58,14 @@ void AT91F_SpiInit(void)
|
|||||||
((get_mck_clk_rate() / AT91_SPI_CLK) << 8),
|
((get_mck_clk_rate() / AT91_SPI_CLK) << 8),
|
||||||
AT91_BASE_SPI + AT91_SPI_CSR(1));
|
AT91_BASE_SPI + AT91_SPI_CSR(1));
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS2
|
||||||
|
/* Configure CS2 */
|
||||||
|
writel(AT91_SPI_NCPHA |
|
||||||
|
(AT91_SPI_DLYBS & DATAFLASH_TCSS) |
|
||||||
|
(AT91_SPI_DLYBCT & DATAFLASH_TCHS) |
|
||||||
|
((get_mck_clk_rate() / AT91_SPI_CLK) << 8),
|
||||||
|
AT91_BASE_SPI + AT91_SPI_CSR(2));
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS3
|
#ifdef CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS3
|
||||||
/* Configure CS3 */
|
/* Configure CS3 */
|
||||||
writel(AT91_SPI_NCPHA |
|
writel(AT91_SPI_NCPHA |
|
||||||
@ -99,6 +107,12 @@ void AT91F_SpiEnable(int cs)
|
|||||||
writel(mode | ((AT91_SPI_PCS1_DATAFLASH_CARD<<16) & AT91_SPI_PCS),
|
writel(mode | ((AT91_SPI_PCS1_DATAFLASH_CARD<<16) & AT91_SPI_PCS),
|
||||||
AT91_BASE_SPI + AT91_SPI_MR);
|
AT91_BASE_SPI + AT91_SPI_MR);
|
||||||
break;
|
break;
|
||||||
|
case 2: /* Configure SPI CS2 for Serial DataFlash AT45DBxx */
|
||||||
|
mode = readl(AT91_BASE_SPI + AT91_SPI_MR);
|
||||||
|
mode &= 0xFFF0FFFF;
|
||||||
|
writel(mode | ((AT91_SPI_PCS2_DATAFLASH_CARD<<16) & AT91_SPI_PCS),
|
||||||
|
AT91_BASE_SPI + AT91_SPI_MR);
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
mode = readl(AT91_BASE_SPI + AT91_SPI_MR);
|
mode = readl(AT91_BASE_SPI + AT91_SPI_MR);
|
||||||
mode &= 0xFFF0FFFF;
|
mode &= 0xFFF0FFFF;
|
||||||
|
@ -38,7 +38,13 @@ ELF-mpc8260 += mem_to_mem_idma2intr
|
|||||||
ELF-ppc += sched
|
ELF-ppc += sched
|
||||||
ELF-oxc += eepro100_eeprom
|
ELF-oxc += eepro100_eeprom
|
||||||
|
|
||||||
ELF := $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(BOARD)) $(ELF-$(CPU))
|
#
|
||||||
|
# Some versions of make do not handle trailing white spaces properly;
|
||||||
|
# leading to build failures. The problem was found with GNU Make 3.80.
|
||||||
|
# Using 'strip' as a workaround for the problem.
|
||||||
|
#
|
||||||
|
ELF := $(strip $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(BOARD)) $(ELF-$(CPU)))
|
||||||
|
|
||||||
SREC = $(addsuffix .srec,$(ELF))
|
SREC = $(addsuffix .srec,$(ELF))
|
||||||
BIN = $(addsuffix .bin,$(ELF))
|
BIN = $(addsuffix .bin,$(ELF))
|
||||||
|
|
||||||
|
@ -1,133 +0,0 @@
|
|||||||
/*
|
|
||||||
* (C) Copyright 2004, Psyent Corporation <www.psyent.com>
|
|
||||||
* Scott McNutt <smcnutt@psyent.com>
|
|
||||||
*
|
|
||||||
* See file CREDITS for list of people who contributed to this
|
|
||||||
* project.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
||||||
* MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
OUTPUT_FORMAT("elf32-littlenios2")
|
|
||||||
OUTPUT_ARCH(nios2)
|
|
||||||
ENTRY(_start)
|
|
||||||
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
.text :
|
|
||||||
{
|
|
||||||
*(.text)
|
|
||||||
*(.text.*)
|
|
||||||
*(.gnu.linkonce.t*)
|
|
||||||
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
|
|
||||||
*(.gnu.linkonce.r*)
|
|
||||||
}
|
|
||||||
. = ALIGN (4);
|
|
||||||
_etext = .;
|
|
||||||
PROVIDE (etext = .);
|
|
||||||
|
|
||||||
/* INIT DATA sections - "Small" data (see the gcc -G option)
|
|
||||||
* is always gp-relative. Here we make all init data sections
|
|
||||||
* adjacent to simplify the startup code -- and provide
|
|
||||||
* the global pointer for gp-relative access.
|
|
||||||
*/
|
|
||||||
_data = .;
|
|
||||||
.data :
|
|
||||||
{
|
|
||||||
*(.data)
|
|
||||||
*(.data.*)
|
|
||||||
*(.gnu.linkonce.d*)
|
|
||||||
}
|
|
||||||
|
|
||||||
. = ALIGN(16);
|
|
||||||
_gp = .; /* Global pointer addr */
|
|
||||||
PROVIDE (gp = .);
|
|
||||||
|
|
||||||
.sdata :
|
|
||||||
{
|
|
||||||
*(.sdata)
|
|
||||||
*(.sdata.*)
|
|
||||||
*(.gnu.linkonce.s.*)
|
|
||||||
}
|
|
||||||
. = ALIGN(4);
|
|
||||||
|
|
||||||
_edata = .;
|
|
||||||
PROVIDE (edata = .);
|
|
||||||
|
|
||||||
/* UNINIT DATA - Small uninitialized data is first so it's
|
|
||||||
* adjacent to sdata and can be referenced via gp. The normal
|
|
||||||
* bss follows. We keep it adjacent to simplify init code.
|
|
||||||
*/
|
|
||||||
__bss_start = .;
|
|
||||||
.sbss (NOLOAD) :
|
|
||||||
{
|
|
||||||
*(.sbss)
|
|
||||||
*(.sbss.*)
|
|
||||||
*(.gnu.linkonce.sb.*)
|
|
||||||
*(.scommon)
|
|
||||||
}
|
|
||||||
. = ALIGN(4);
|
|
||||||
.bss (NOLOAD) :
|
|
||||||
{
|
|
||||||
*(.bss)
|
|
||||||
*(.bss.*)
|
|
||||||
*(.dynbss)
|
|
||||||
*(COMMON)
|
|
||||||
*(.scommon)
|
|
||||||
}
|
|
||||||
. = ALIGN(4);
|
|
||||||
_end = .;
|
|
||||||
PROVIDE (end = .);
|
|
||||||
|
|
||||||
/* CMD TABLE - uboot command sections
|
|
||||||
*/
|
|
||||||
. = .;
|
|
||||||
__uboot_cmd_start = .;
|
|
||||||
.u_boot_cmd :
|
|
||||||
{
|
|
||||||
*(.u_boot_cmd)
|
|
||||||
}
|
|
||||||
. = ALIGN(4);
|
|
||||||
__u_boot_cmd_end = .;
|
|
||||||
|
|
||||||
/* DEBUG -- symbol table, string table, etc. etc.
|
|
||||||
*/
|
|
||||||
.stab 0 : { *(.stab) }
|
|
||||||
.stabstr 0 : { *(.stabstr) }
|
|
||||||
.stab.excl 0 : { *(.stab.excl) }
|
|
||||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
|
||||||
.stab.index 0 : { *(.stab.index) }
|
|
||||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
|
||||||
.comment 0 : { *(.comment) }
|
|
||||||
.debug 0 : { *(.debug) }
|
|
||||||
.line 0 : { *(.line) }
|
|
||||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
|
||||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
|
||||||
.debug_aranges 0 : { *(.debug_aranges) }
|
|
||||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
|
||||||
.debug_info 0 : { *(.debug_info) }
|
|
||||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
|
||||||
.debug_line 0 : { *(.debug_line) }
|
|
||||||
.debug_frame 0 : { *(.debug_frame) }
|
|
||||||
.debug_str 0 : { *(.debug_str) }
|
|
||||||
.debug_loc 0 : { *(.debug_loc) }
|
|
||||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
|
||||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
|
||||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
|
||||||
.debug_typenames 0 : { *(.debug_typenames) }
|
|
||||||
.debug_varnames 0 : { *(.debug_varnames) }
|
|
||||||
}
|
|
@ -33,8 +33,6 @@
|
|||||||
struct eth_device { unsigned long iobase; };
|
struct eth_device { unsigned long iobase; };
|
||||||
#include "../drivers/net/smc91111.h"
|
#include "../drivers/net/smc91111.h"
|
||||||
|
|
||||||
#ifdef CONFIG_SMC91111
|
|
||||||
|
|
||||||
#ifndef SMC91111_EEPROM_INIT
|
#ifndef SMC91111_EEPROM_INIT
|
||||||
# define SMC91111_EEPROM_INIT()
|
# define SMC91111_EEPROM_INIT()
|
||||||
#endif
|
#endif
|
||||||
@ -391,13 +389,3 @@ void dump_reg (struct eth_device *dev)
|
|||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int smc91111_eeprom (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
printf("Not supported for this board\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -178,6 +178,7 @@ int indir1_blkno = -1;
|
|||||||
uint32_t *indir2_block = NULL;
|
uint32_t *indir2_block = NULL;
|
||||||
int indir2_size = 0;
|
int indir2_size = 0;
|
||||||
int indir2_blkno = -1;
|
int indir2_blkno = -1;
|
||||||
|
static unsigned int inode_size;
|
||||||
|
|
||||||
|
|
||||||
static int ext2fs_blockgroup
|
static int ext2fs_blockgroup
|
||||||
@ -212,7 +213,7 @@ static int ext2fs_read_inode
|
|||||||
unsigned int blkoff;
|
unsigned int blkoff;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf ("ext2fs read inode %d\n", ino);
|
printf ("ext2fs read inode %d, inode_size %d\n", ino, inode_size);
|
||||||
#endif
|
#endif
|
||||||
/* It is easier to calculate if the first inode is 0. */
|
/* It is easier to calculate if the first inode is 0. */
|
||||||
ino--;
|
ino--;
|
||||||
@ -222,16 +223,12 @@ static int ext2fs_read_inode
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inodes_per_block = EXT2_BLOCK_SIZE(data) / __le16_to_cpu(sblock->inode_size);
|
inodes_per_block = EXT2_BLOCK_SIZE(data) / inode_size;
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
printf ("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
blkno = __le32_to_cpu (blkgrp.inode_table_id) +
|
blkno = __le32_to_cpu (blkgrp.inode_table_id) +
|
||||||
(ino % __le32_to_cpu (sblock->inodes_per_group))
|
(ino % __le32_to_cpu (sblock->inodes_per_group))
|
||||||
/ inodes_per_block;
|
/ inodes_per_block;
|
||||||
blkoff = (ino % inodes_per_block) * __le16_to_cpu (sblock->inode_size);
|
blkoff = (ino % inodes_per_block) * inode_size;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf ("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff);
|
printf ("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff);
|
||||||
#endif
|
#endif
|
||||||
@ -863,6 +860,15 @@ int ext2fs_mount (unsigned part_length) {
|
|||||||
if (__le16_to_cpu (data->sblock.magic) != EXT2_MAGIC) {
|
if (__le16_to_cpu (data->sblock.magic) != EXT2_MAGIC) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
if (__le32_to_cpu(data->sblock.revision_level == 0)) {
|
||||||
|
inode_size = 128;
|
||||||
|
} else {
|
||||||
|
inode_size = __le16_to_cpu(data->sblock.inode_size);
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("EXT2 rev %d, inode_size %d\n",
|
||||||
|
__le32_to_cpu(data->sblock.revision_level), inode_size);
|
||||||
|
#endif
|
||||||
data->diropen.data = data;
|
data->diropen.data = data;
|
||||||
data->diropen.ino = 2;
|
data->diropen.ino = 2;
|
||||||
data->diropen.inode_read = 1;
|
data->diropen.inode_read = 1;
|
||||||
|
@ -70,13 +70,6 @@
|
|||||||
#define CONFIG_TSEC_ENET /* tsec ethernet support */
|
#define CONFIG_TSEC_ENET /* tsec ethernet support */
|
||||||
#define CONFIG_ENV_OVERWRITE
|
#define CONFIG_ENV_OVERWRITE
|
||||||
|
|
||||||
/*
|
|
||||||
* When initializing flash, if we cannot find the manufacturer ID,
|
|
||||||
* assume this is the AMD flash associated with the CDS board.
|
|
||||||
* This allows booting from a promjet.
|
|
||||||
*/
|
|
||||||
#define CONFIG_ASSUME_AMD_FLASH
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
extern unsigned long get_board_sys_clk(unsigned long dummy);
|
extern unsigned long get_board_sys_clk(unsigned long dummy);
|
||||||
extern unsigned long get_board_ddr_clk(unsigned long dummy);
|
extern unsigned long get_board_ddr_clk(unsigned long dummy);
|
||||||
|
@ -46,13 +46,6 @@
|
|||||||
|
|
||||||
#define CONFIG_FSL_VIA
|
#define CONFIG_FSL_VIA
|
||||||
|
|
||||||
/*
|
|
||||||
* When initializing flash, if we cannot find the manufacturer ID,
|
|
||||||
* assume this is the AMD flash associated with the CDS board.
|
|
||||||
* This allows booting from a promjet.
|
|
||||||
*/
|
|
||||||
#define CONFIG_ASSUME_AMD_FLASH
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
extern unsigned long get_clock_freq(void);
|
extern unsigned long get_clock_freq(void);
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,13 +50,6 @@
|
|||||||
#define CONFIG_ENV_OVERWRITE
|
#define CONFIG_ENV_OVERWRITE
|
||||||
#define CONFIG_INTERRUPTS /* enable pci, srio, ddr interrupts */
|
#define CONFIG_INTERRUPTS /* enable pci, srio, ddr interrupts */
|
||||||
|
|
||||||
/*
|
|
||||||
* When initializing flash, if we cannot find the manufacturer ID,
|
|
||||||
* assume this is the AMD flash associated with the CDS board.
|
|
||||||
* This allows booting from a promjet.
|
|
||||||
*/
|
|
||||||
#define CONFIG_ASSUME_AMD_FLASH
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
extern unsigned long get_board_sys_clk(unsigned long dummy);
|
extern unsigned long get_board_sys_clk(unsigned long dummy);
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,13 +52,6 @@
|
|||||||
|
|
||||||
#define CONFIG_FSL_VIA
|
#define CONFIG_FSL_VIA
|
||||||
|
|
||||||
/*
|
|
||||||
* When initializing flash, if we cannot find the manufacturer ID,
|
|
||||||
* assume this is the AMD flash associated with the CDS board.
|
|
||||||
* This allows booting from a promjet.
|
|
||||||
*/
|
|
||||||
#define CONFIG_ASSUME_AMD_FLASH
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
extern unsigned long get_clock_freq(void);
|
extern unsigned long get_clock_freq(void);
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,13 +46,6 @@
|
|||||||
#define CONFIG_FSL_VIA
|
#define CONFIG_FSL_VIA
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* When initializing flash, if we cannot find the manufacturer ID,
|
|
||||||
* assume this is the AMD flash associated with the CDS board.
|
|
||||||
* This allows booting from a promjet.
|
|
||||||
*/
|
|
||||||
#define CONFIG_ASSUME_AMD_FLASH
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
extern unsigned long get_clock_freq(void);
|
extern unsigned long get_clock_freq(void);
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,13 +44,6 @@
|
|||||||
#define CONFIG_ENV_OVERWRITE
|
#define CONFIG_ENV_OVERWRITE
|
||||||
#define CONFIG_FSL_LAW 1 /* Use common FSL init code */
|
#define CONFIG_FSL_LAW 1 /* Use common FSL init code */
|
||||||
|
|
||||||
/*
|
|
||||||
* When initializing flash, if we cannot find the manufacturer ID,
|
|
||||||
* assume this is the AMD flash associated with the MDS board.
|
|
||||||
* This allows booting from a promjet.
|
|
||||||
*/
|
|
||||||
#define CONFIG_ASSUME_AMD_FLASH
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
extern unsigned long get_clock_freq(void);
|
extern unsigned long get_clock_freq(void);
|
||||||
#endif /*Replace a call to get_clock_freq (after it is implemented)*/
|
#endif /*Replace a call to get_clock_freq (after it is implemented)*/
|
||||||
|
@ -44,13 +44,6 @@
|
|||||||
#define CONFIG_ENV_OVERWRITE
|
#define CONFIG_ENV_OVERWRITE
|
||||||
#define CONFIG_FSL_LAW 1 /* Use common FSL init code */
|
#define CONFIG_FSL_LAW 1 /* Use common FSL init code */
|
||||||
|
|
||||||
/*
|
|
||||||
* When initializing flash, if we cannot find the manufacturer ID,
|
|
||||||
* assume this is the AMD flash associated with the MDS board.
|
|
||||||
* This allows booting from a promjet.
|
|
||||||
*/
|
|
||||||
#define CONFIG_ASSUME_AMD_FLASH
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
extern unsigned long get_clock_freq(void);
|
extern unsigned long get_clock_freq(void);
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,13 +53,6 @@
|
|||||||
#define CONFIG_TSEC_ENET /* tsec ethernet support */
|
#define CONFIG_TSEC_ENET /* tsec ethernet support */
|
||||||
#define CONFIG_ENV_OVERWRITE
|
#define CONFIG_ENV_OVERWRITE
|
||||||
|
|
||||||
/*
|
|
||||||
* When initializing flash, if we cannot find the manufacturer ID,
|
|
||||||
* assume this is the AMD flash associated with the CDS board.
|
|
||||||
* This allows booting from a promjet.
|
|
||||||
*/
|
|
||||||
#define CONFIG_ASSUME_AMD_FLASH
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
extern unsigned long get_board_sys_clk(unsigned long dummy);
|
extern unsigned long get_board_sys_clk(unsigned long dummy);
|
||||||
extern unsigned long get_board_ddr_clk(unsigned long dummy);
|
extern unsigned long get_board_ddr_clk(unsigned long dummy);
|
||||||
|
@ -54,13 +54,6 @@
|
|||||||
#define CONFIG_TSEC_ENET /* tsec ethernet support */
|
#define CONFIG_TSEC_ENET /* tsec ethernet support */
|
||||||
#define CONFIG_ENV_OVERWRITE
|
#define CONFIG_ENV_OVERWRITE
|
||||||
|
|
||||||
/*
|
|
||||||
* When initializing flash, if we cannot find the manufacturer ID,
|
|
||||||
* assume this is the AMD flash associated with the CDS board.
|
|
||||||
* This allows booting from a promjet.
|
|
||||||
*/
|
|
||||||
#define CONFIG_ASSUME_AMD_FLASH
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
extern unsigned long calculate_board_sys_clk(unsigned long dummy);
|
extern unsigned long calculate_board_sys_clk(unsigned long dummy);
|
||||||
extern unsigned long calculate_board_ddr_clk(unsigned long dummy);
|
extern unsigned long calculate_board_ddr_clk(unsigned long dummy);
|
||||||
|
@ -298,7 +298,8 @@
|
|||||||
/*
|
/*
|
||||||
* External Bus Controller (EBC) Setup
|
* External Bus Controller (EBC) Setup
|
||||||
*/
|
*/
|
||||||
#define CAN_BA 0xF0000000 /* CAN Base Address */
|
#define CAN0_BA 0xF0000000 /* CAN0 Base Address */
|
||||||
|
#define CAN1_BA 0xF0000100 /* CAN1 Base Address */
|
||||||
#define DUART0_BA 0xF0000400 /* DUART Base Address */
|
#define DUART0_BA 0xF0000400 /* DUART Base Address */
|
||||||
#define DUART1_BA 0xF0000408 /* DUART Base Address */
|
#define DUART1_BA 0xF0000408 /* DUART Base Address */
|
||||||
#define RTC_BA 0xF0000500 /* RTC Base Address */
|
#define RTC_BA 0xF0000500 /* RTC Base Address */
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
|
|
||||||
#define CONFIG_BAUDRATE 115200
|
#define CONFIG_BAUDRATE 115200
|
||||||
#define CONFIG_BOOTARGS \
|
#define CONFIG_BOOTARGS \
|
||||||
"root=/dev/mtdblock1 rootfstype=jffs2 console=ttyS1"
|
"root=/dev/mtdblock1 rootfstype=jffs2 fbmem=512k console=ttyS1"
|
||||||
#define CONFIG_BOOTCOMMAND \
|
#define CONFIG_BOOTCOMMAND \
|
||||||
"fsload boot/uImage; bootm"
|
"fsload boot/uImage; bootm"
|
||||||
|
|
||||||
|
@ -220,12 +220,10 @@ typedef struct bootm_headers {
|
|||||||
const char *fit_uname_rd; /* init ramdisk subimage node unit name */
|
const char *fit_uname_rd; /* init ramdisk subimage node unit name */
|
||||||
int fit_noffset_rd; /* init ramdisk subimage node offset */
|
int fit_noffset_rd; /* init ramdisk subimage node offset */
|
||||||
|
|
||||||
#if defined(CONFIG_PPC)
|
|
||||||
void *fit_hdr_fdt; /* FDT blob FIT image header */
|
void *fit_hdr_fdt; /* FDT blob FIT image header */
|
||||||
const char *fit_uname_fdt; /* FDT blob subimage node unit name */
|
const char *fit_uname_fdt; /* FDT blob subimage node unit name */
|
||||||
int fit_noffset_fdt;/* FDT blob subimage node offset */
|
int fit_noffset_fdt;/* FDT blob subimage node offset */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef USE_HOSTCC
|
#ifndef USE_HOSTCC
|
||||||
image_info_t os; /* os image info */
|
image_info_t os; /* os image info */
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* (C) Copyright 2003, Psyent Corporation <www.psyent.com>
|
* Copyright 2009, Matthias Fuchs <matthias.fuchs@esd.eu>
|
||||||
* Scott McNutt <smcnutt@psyent.com>
|
*
|
||||||
|
* SJA1000 register layout for basic CAN mode
|
||||||
*
|
*
|
||||||
* See file CREDITS for list of people who contributed to this
|
* See file CREDITS for list of people who contributed to this
|
||||||
* project.
|
* project.
|
||||||
@ -21,41 +22,39 @@
|
|||||||
* MA 02111-1307 USA
|
* MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _SJA1000_H_
|
||||||
|
#define _SJA1000_H_
|
||||||
|
|
||||||
OUTPUT_FORMAT("elf32-nios")
|
/*
|
||||||
OUTPUT_ARCH(nios)
|
* SJA1000 register layout in basic can mode
|
||||||
ENTRY(_start)
|
*/
|
||||||
|
struct sja1000_basic_s {
|
||||||
|
u8 cr;
|
||||||
|
u8 cmr;
|
||||||
|
u8 sr;
|
||||||
|
u8 ir;
|
||||||
|
u8 ac;
|
||||||
|
u8 am;
|
||||||
|
u8 btr0;
|
||||||
|
u8 btr1;
|
||||||
|
u8 oc;
|
||||||
|
u8 txb[10];
|
||||||
|
u8 rxb[10];
|
||||||
|
u8 unused;
|
||||||
|
u8 cdr;
|
||||||
|
};
|
||||||
|
|
||||||
SECTIONS
|
/* control register */
|
||||||
{
|
#define CR_RR 0x01
|
||||||
.text :
|
|
||||||
{
|
|
||||||
*(.text)
|
|
||||||
}
|
|
||||||
__text_end = .;
|
|
||||||
|
|
||||||
. = ALIGN(4);
|
/* output control register */
|
||||||
.rodata :
|
#define OC_MODE0 0x01
|
||||||
{
|
#define OC_MODE1 0x02
|
||||||
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
|
#define OC_POL0 0x04
|
||||||
}
|
#define OC_TN0 0x08
|
||||||
__rodata_end = .;
|
#define OC_TP0 0x10
|
||||||
|
#define OC_POL1 0x20
|
||||||
|
#define OC_TN1 0x40
|
||||||
|
#define OC_TP1 0x80
|
||||||
|
|
||||||
. = ALIGN(4);
|
#endif
|
||||||
.data :
|
|
||||||
{
|
|
||||||
*(.data)
|
|
||||||
}
|
|
||||||
. = ALIGN(4);
|
|
||||||
__data_end = .;
|
|
||||||
|
|
||||||
__bss_start = .;
|
|
||||||
. = ALIGN(4);
|
|
||||||
.bss (NOLOAD) :
|
|
||||||
{
|
|
||||||
*(.bss)
|
|
||||||
}
|
|
||||||
. = ALIGN(4);
|
|
||||||
__bss_end = .;
|
|
||||||
_end = .;
|
|
||||||
}
|
|
@ -24,6 +24,7 @@
|
|||||||
#define _SPI_FLASH_H_
|
#define _SPI_FLASH_H_
|
||||||
|
|
||||||
#include <spi.h>
|
#include <spi.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
|
||||||
struct spi_flash_region {
|
struct spi_flash_region {
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
@ -31,6 +31,7 @@ COBJS-$(CONFIG_BZIP2) += bzlib_crctable.o
|
|||||||
COBJS-$(CONFIG_BZIP2) += bzlib_decompress.o
|
COBJS-$(CONFIG_BZIP2) += bzlib_decompress.o
|
||||||
COBJS-$(CONFIG_BZIP2) += bzlib_randtable.o
|
COBJS-$(CONFIG_BZIP2) += bzlib_randtable.o
|
||||||
COBJS-$(CONFIG_BZIP2) += bzlib_huffman.o
|
COBJS-$(CONFIG_BZIP2) += bzlib_huffman.o
|
||||||
|
COBJS-$(CONFIG_USB_TTY) += circbuf.o
|
||||||
COBJS-y += crc16.o
|
COBJS-y += crc16.o
|
||||||
COBJS-y += crc32.o
|
COBJS-y += crc32.o
|
||||||
COBJS-y += ctype.o
|
COBJS-y += ctype.o
|
||||||
|
@ -97,11 +97,14 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
|
|||||||
} else if (outSizeHigh != 0 || (UInt32)(SizeT)outSize != outSize) {
|
} else if (outSizeHigh != 0 || (UInt32)(SizeT)outSize != outSize) {
|
||||||
/*
|
/*
|
||||||
* SizeT is a 32 bit uint => We cannot manage files larger than
|
* SizeT is a 32 bit uint => We cannot manage files larger than
|
||||||
* 4GB!
|
* 4GB! Assume however that all 0xf values is "unknown size" and
|
||||||
|
* not actually a file of 2^64 bits.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
debug ("LZMA: 64bit support not enabled.\n");
|
if (outSizeHigh != (SizeT)-1 || outSize != (SizeT)-1) {
|
||||||
return SZ_ERROR_DATA;
|
debug ("LZMA: 64bit support not enabled.\n");
|
||||||
|
return SZ_ERROR_DATA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug ("LZMA: Uncompresed size............ 0x%lx\n", outSizeFull);
|
debug ("LZMA: Uncompresed size............ 0x%lx\n", outSizeFull);
|
||||||
|
@ -24,6 +24,6 @@
|
|||||||
|
|
||||||
CROSS_COMPILE ?= nios-elf-
|
CROSS_COMPILE ?= nios-elf-
|
||||||
|
|
||||||
STANDALONE_LOAD_ADDR = 0x00800000 -L $(gcclibdir)/m32 -T nios.lds
|
STANDALONE_LOAD_ADDR = 0x00800000 -L $(gcclibdir)/m32
|
||||||
|
|
||||||
PLATFORM_CPPFLAGS += -m32 -DCONFIG_NIOS -D__NIOS__ -ffixed-g7 -gstabs
|
PLATFORM_CPPFLAGS += -m32 -DCONFIG_NIOS -D__NIOS__ -ffixed-g7 -gstabs
|
||||||
|
@ -83,8 +83,6 @@ void board_init (void)
|
|||||||
{
|
{
|
||||||
bd_t *bd;
|
bd_t *bd;
|
||||||
init_fnc_t **init_fnc_ptr;
|
init_fnc_t **init_fnc_ptr;
|
||||||
char *s, *e;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Pointer is writable since we allocated a register for it.
|
/* Pointer is writable since we allocated a register for it.
|
||||||
* Nios treats CONFIG_SYS_GBL_DATA_OFFSET as an address.
|
* Nios treats CONFIG_SYS_GBL_DATA_OFFSET as an address.
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <asm/byteorder.h>
|
#include <asm/byteorder.h>
|
||||||
|
#include <asm/cache.h>
|
||||||
|
|
||||||
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
|
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
|
||||||
{
|
{
|
||||||
@ -32,6 +33,10 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
|
|||||||
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
|
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
/* flushes data and instruction caches before calling the kernel */
|
||||||
|
flush_dcache (0,CONFIG_SYS_DCACHE_SIZE);
|
||||||
|
flush_icache (0,CONFIG_SYS_ICACHE_SIZE);
|
||||||
|
|
||||||
/* For now we assume the Microtronix linux ... which only
|
/* For now we assume the Microtronix linux ... which only
|
||||||
* needs to be called ;-)
|
* needs to be called ;-)
|
||||||
*/
|
*/
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
CROSS_COMPILE ?= nios2-elf-
|
CROSS_COMPILE ?= nios2-elf-
|
||||||
|
|
||||||
STANDALONE_LOAD_ADDR = 0x02000000 -L $(gcclibdir) -T nios2.lds
|
STANDALONE_LOAD_ADDR = 0x02000000 -L $(gcclibdir)
|
||||||
|
|
||||||
PLATFORM_CPPFLAGS += -DCONFIG_NIOS2 -D__NIOS2__
|
PLATFORM_CPPFLAGS += -DCONFIG_NIOS2 -D__NIOS2__
|
||||||
PLATFORM_CPPFLAGS += -ffixed-r15 -G0
|
PLATFORM_CPPFLAGS += -ffixed-r15 -G0
|
||||||
|
@ -35,7 +35,7 @@ COBJS-y += bootm.o
|
|||||||
COBJS-y += cache.o
|
COBJS-y += cache.o
|
||||||
COBJS-y += extable.o
|
COBJS-y += extable.o
|
||||||
COBJS-y += interrupts.o
|
COBJS-y += interrupts.o
|
||||||
COBJS-y += kgdb.o
|
COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
|
||||||
COBJS-y += time.o
|
COBJS-y += time.o
|
||||||
|
|
||||||
SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
|
SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_KGDB)
|
|
||||||
|
|
||||||
#include <kgdb.h>
|
#include <kgdb.h>
|
||||||
#include <asm/signal.h>
|
#include <asm/signal.h>
|
||||||
#include <asm/processor.h>
|
#include <asm/processor.h>
|
||||||
@ -322,5 +319,3 @@ kgdb_breakpoint(int argc, char *argv[])
|
|||||||
breakinst: .long 0x7d821008\n\
|
breakinst: .long 0x7d821008\n\
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
5
mkconfig
5
mkconfig
@ -27,6 +27,11 @@ done
|
|||||||
[ $# -lt 4 ] && exit 1
|
[ $# -lt 4 ] && exit 1
|
||||||
[ $# -gt 6 ] && exit 1
|
[ $# -gt 6 ] && exit 1
|
||||||
|
|
||||||
|
if [ "${ARCH}" -a "${ARCH}" != "$2" ]; then
|
||||||
|
echo "Failed: \$ARCH=${ARCH}, should be '$2' for ${BOARD_NAME}" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Configuring for ${BOARD_NAME} board..."
|
echo "Configuring for ${BOARD_NAME} board..."
|
||||||
|
|
||||||
#
|
#
|
||||||
|
32
net/net.c
32
net/net.c
@ -197,6 +197,8 @@ volatile uchar *NetTxPacket = 0; /* THE transmit packet */
|
|||||||
|
|
||||||
static int net_check_prereq (proto_t protocol);
|
static int net_check_prereq (proto_t protocol);
|
||||||
|
|
||||||
|
static int NetTryCount;
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
IPaddr_t NetArpWaitPacketIP;
|
IPaddr_t NetArpWaitPacketIP;
|
||||||
@ -320,6 +322,7 @@ NetLoop(proto_t protocol)
|
|||||||
NetArpWaitReplyIP = 0;
|
NetArpWaitReplyIP = 0;
|
||||||
NetArpWaitTxPacket = NULL;
|
NetArpWaitTxPacket = NULL;
|
||||||
NetTxPacket = NULL;
|
NetTxPacket = NULL;
|
||||||
|
NetTryCount = 1;
|
||||||
|
|
||||||
if (!NetTxPacket) {
|
if (!NetTxPacket) {
|
||||||
int i;
|
int i;
|
||||||
@ -558,17 +561,30 @@ startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
|
|||||||
void NetStartAgain (void)
|
void NetStartAgain (void)
|
||||||
{
|
{
|
||||||
char *nretry;
|
char *nretry;
|
||||||
int noretry = 0, once = 0;
|
int retry_forever = 0;
|
||||||
|
unsigned long retrycnt = 0;
|
||||||
|
|
||||||
if ((nretry = getenv ("netretry")) != NULL) {
|
nretry = getenv("netretry");
|
||||||
noretry = (strcmp (nretry, "no") == 0);
|
if (nretry) {
|
||||||
once = (strcmp (nretry, "once") == 0);
|
if (!strcmp(nretry, "yes"))
|
||||||
}
|
retry_forever = 1;
|
||||||
if (noretry) {
|
else if (!strcmp(nretry, "no"))
|
||||||
eth_halt ();
|
retrycnt = 0;
|
||||||
|
else if (!strcmp(nretry, "once"))
|
||||||
|
retrycnt = 1;
|
||||||
|
else
|
||||||
|
retrycnt = simple_strtoul(nretry, NULL, 0);
|
||||||
|
} else
|
||||||
|
retry_forever = 1;
|
||||||
|
|
||||||
|
if ((!retry_forever) && (NetTryCount >= retrycnt)) {
|
||||||
|
eth_halt();
|
||||||
NetState = NETLOOP_FAIL;
|
NetState = NETLOOP_FAIL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetTryCount++;
|
||||||
|
|
||||||
#ifndef CONFIG_NET_MULTI
|
#ifndef CONFIG_NET_MULTI
|
||||||
NetSetTimeout (10000UL, startAgainTimeout);
|
NetSetTimeout (10000UL, startAgainTimeout);
|
||||||
NetSetHandler (startAgainHandler);
|
NetSetHandler (startAgainHandler);
|
||||||
@ -580,7 +596,7 @@ void NetStartAgain (void)
|
|||||||
eth_init (gd->bd);
|
eth_init (gd->bd);
|
||||||
if (NetRestartWrap) {
|
if (NetRestartWrap) {
|
||||||
NetRestartWrap = 0;
|
NetRestartWrap = 0;
|
||||||
if (NetDevExists && !once) {
|
if (NetDevExists) {
|
||||||
NetSetTimeout (10000UL, startAgainTimeout);
|
NetSetTimeout (10000UL, startAgainTimeout);
|
||||||
NetSetHandler (startAgainHandler);
|
NetSetHandler (startAgainHandler);
|
||||||
} else {
|
} else {
|
||||||
|
1
tools/.gitignore
vendored
1
tools/.gitignore
vendored
@ -8,3 +8,4 @@
|
|||||||
/ncp
|
/ncp
|
||||||
/ubsha1
|
/ubsha1
|
||||||
/inca-swap-bytes
|
/inca-swap-bytes
|
||||||
|
/*.exe
|
||||||
|
@ -155,38 +155,6 @@ static int fit_handle_file (struct mkimage_params *params)
|
|||||||
return (EXIT_SUCCESS);
|
return (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fit_set_header (void *ptr, struct stat *sbuf, int ifd,
|
|
||||||
struct mkimage_params *params)
|
|
||||||
{
|
|
||||||
uint32_t checksum;
|
|
||||||
|
|
||||||
image_header_t * hdr = (image_header_t *)ptr;
|
|
||||||
|
|
||||||
checksum = crc32 (0,
|
|
||||||
(const unsigned char *)(ptr +
|
|
||||||
sizeof(image_header_t)),
|
|
||||||
sbuf->st_size - sizeof(image_header_t));
|
|
||||||
|
|
||||||
/* Build new header */
|
|
||||||
image_set_magic (hdr, IH_MAGIC);
|
|
||||||
image_set_time (hdr, sbuf->st_mtime);
|
|
||||||
image_set_size (hdr, sbuf->st_size - sizeof(image_header_t));
|
|
||||||
image_set_load (hdr, params->addr);
|
|
||||||
image_set_ep (hdr, params->ep);
|
|
||||||
image_set_dcrc (hdr, checksum);
|
|
||||||
image_set_os (hdr, params->os);
|
|
||||||
image_set_arch (hdr, params->arch);
|
|
||||||
image_set_type (hdr, params->type);
|
|
||||||
image_set_comp (hdr, params->comp);
|
|
||||||
|
|
||||||
image_set_name (hdr, params->imagename);
|
|
||||||
|
|
||||||
checksum = crc32 (0, (const unsigned char *)hdr,
|
|
||||||
sizeof(image_header_t));
|
|
||||||
|
|
||||||
image_set_hcrc (hdr, checksum);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int fit_check_params (struct mkimage_params *params)
|
static int fit_check_params (struct mkimage_params *params)
|
||||||
{
|
{
|
||||||
return ((params->dflag && (params->fflag || params->lflag)) ||
|
return ((params->dflag && (params->fflag || params->lflag)) ||
|
||||||
@ -202,7 +170,7 @@ static struct image_type_params fitimage_params = {
|
|||||||
.print_header = fit_print_contents,
|
.print_header = fit_print_contents,
|
||||||
.check_image_type = fit_check_image_types,
|
.check_image_type = fit_check_image_types,
|
||||||
.fflag_handle = fit_handle_file,
|
.fflag_handle = fit_handle_file,
|
||||||
.set_header = fit_set_header,
|
.set_header = NULL, /* FIT images use DTB header */
|
||||||
.check_params = fit_check_params,
|
.check_params = fit_check_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
164
tools/img2srec.c
164
tools/img2srec.c
@ -53,6 +53,7 @@
|
|||||||
|*************************************************************************/
|
|*************************************************************************/
|
||||||
|
|
||||||
#include "os_support.h"
|
#include "os_support.h"
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -62,64 +63,23 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
| DEFINES
|
|
||||||
|*************************************************************************/
|
|
||||||
|
|
||||||
#define FALSE 0
|
|
||||||
#define TRUE 1
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
| MACROS
|
|
||||||
|*************************************************************************/
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
| TYPEDEFS
|
|
||||||
|*************************************************************************/
|
|
||||||
|
|
||||||
typedef uint8_t CHAR;
|
|
||||||
typedef uint8_t BYTE;
|
|
||||||
typedef uint16_t WORD;
|
|
||||||
typedef uint32_t DWORD;
|
|
||||||
typedef int BOOL;
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
| LOCALS
|
|
||||||
|*************************************************************************/
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
| PROTOTYPES
|
|
||||||
|*************************************************************************/
|
|
||||||
|
|
||||||
static char *ExtractHex(DWORD *value, char *getPtr);
|
|
||||||
static char *ExtractDecimal(DWORD *value, char *getPtr);
|
|
||||||
static void ExtractNumber(DWORD *value, char *getPtr);
|
|
||||||
static BYTE *ExtractWord(WORD *value, BYTE *buffer);
|
|
||||||
static BYTE *ExtractLong(DWORD *value, BYTE *buffer);
|
|
||||||
static BYTE *ExtractBlock(WORD count, BYTE *data, BYTE *buffer);
|
|
||||||
static char *WriteHex(char *pa, BYTE value, WORD *pCheckSum);
|
|
||||||
static char *BuildSRecord(char *pa, WORD sType, DWORD addr,
|
|
||||||
const BYTE *data, int nCount);
|
|
||||||
static void ConvertELF(char *fileName, DWORD loadOffset);
|
|
||||||
int main(int argc, char *argv[]);
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
| FUNCTIONS
|
| FUNCTIONS
|
||||||
|*************************************************************************/
|
|*************************************************************************/
|
||||||
|
|
||||||
static char* ExtractHex (DWORD* value, char* getPtr)
|
static char* ExtractHex (uint32_t* value, char* getPtr)
|
||||||
{
|
{
|
||||||
DWORD num;
|
uint32_t num;
|
||||||
DWORD digit;
|
uint32_t digit;
|
||||||
BYTE c;
|
uint8_t c;
|
||||||
|
|
||||||
while (*getPtr == ' ') getPtr++;
|
while (*getPtr == ' ') getPtr++;
|
||||||
num = 0;
|
num = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = *getPtr;
|
c = *getPtr;
|
||||||
if ((c >= '0') && (c <= '9')) digit = (DWORD)(c - '0');
|
if ((c >= '0') && (c <= '9')) digit = (uint32_t)(c - '0');
|
||||||
else if ((c >= 'A') && (c <= 'F')) digit = (DWORD)(c - 'A' + 10);
|
else if ((c >= 'A') && (c <= 'F')) digit = (uint32_t)(c - 'A' + 10);
|
||||||
else if ((c >= 'a') && (c <= 'f')) digit = (DWORD)(c - 'a' + 10);
|
else if ((c >= 'a') && (c <= 'f')) digit = (uint32_t)(c - 'a' + 10);
|
||||||
else break;
|
else break;
|
||||||
num <<= 4;
|
num <<= 4;
|
||||||
num += digit;
|
num += digit;
|
||||||
@ -129,17 +89,17 @@ static char* ExtractHex (DWORD* value, char* getPtr)
|
|||||||
return getPtr;
|
return getPtr;
|
||||||
} /* ExtractHex */
|
} /* ExtractHex */
|
||||||
|
|
||||||
static char* ExtractDecimal (DWORD* value, char* getPtr)
|
static char* ExtractDecimal (uint32_t* value, char* getPtr)
|
||||||
{
|
{
|
||||||
DWORD num;
|
uint32_t num;
|
||||||
DWORD digit;
|
uint32_t digit;
|
||||||
BYTE c;
|
uint8_t c;
|
||||||
|
|
||||||
while (*getPtr == ' ') getPtr++;
|
while (*getPtr == ' ') getPtr++;
|
||||||
num = 0;
|
num = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = *getPtr;
|
c = *getPtr;
|
||||||
if ((c >= '0') && (c <= '9')) digit = (DWORD)(c - '0');
|
if ((c >= '0') && (c <= '9')) digit = (uint32_t)(c - '0');
|
||||||
else break;
|
else break;
|
||||||
num *= 10;
|
num *= 10;
|
||||||
num += digit;
|
num += digit;
|
||||||
@ -150,13 +110,13 @@ static char* ExtractDecimal (DWORD* value, char* getPtr)
|
|||||||
} /* ExtractDecimal */
|
} /* ExtractDecimal */
|
||||||
|
|
||||||
|
|
||||||
static void ExtractNumber (DWORD* value, char* getPtr)
|
static void ExtractNumber (uint32_t* value, char* getPtr)
|
||||||
{
|
{
|
||||||
BOOL neg = FALSE;;
|
bool neg = false;;
|
||||||
|
|
||||||
while (*getPtr == ' ') getPtr++;
|
while (*getPtr == ' ') getPtr++;
|
||||||
if (*getPtr == '-') {
|
if (*getPtr == '-') {
|
||||||
neg = TRUE;
|
neg = true;
|
||||||
getPtr++;
|
getPtr++;
|
||||||
} /* if */
|
} /* if */
|
||||||
if ((*getPtr == '0') && ((*(getPtr+1) == 'x') || (*(getPtr+1) == 'X'))) {
|
if ((*getPtr == '0') && ((*(getPtr+1) == 'x') || (*(getPtr+1) == 'X'))) {
|
||||||
@ -170,38 +130,38 @@ static void ExtractNumber (DWORD* value, char* getPtr)
|
|||||||
} /* ExtractNumber */
|
} /* ExtractNumber */
|
||||||
|
|
||||||
|
|
||||||
static BYTE* ExtractWord(WORD* value, BYTE* buffer)
|
static uint8_t* ExtractWord(uint16_t* value, uint8_t* buffer)
|
||||||
{
|
{
|
||||||
WORD x;
|
uint16_t x;
|
||||||
x = (WORD)*buffer++;
|
x = (uint16_t)*buffer++;
|
||||||
x = (x<<8) + (WORD)*buffer++;
|
x = (x<<8) + (uint16_t)*buffer++;
|
||||||
*value = x;
|
*value = x;
|
||||||
return buffer;
|
return buffer;
|
||||||
} /* ExtractWord */
|
} /* ExtractWord */
|
||||||
|
|
||||||
|
|
||||||
static BYTE* ExtractLong(DWORD* value, BYTE* buffer)
|
static uint8_t* ExtractLong(uint32_t* value, uint8_t* buffer)
|
||||||
{
|
{
|
||||||
DWORD x;
|
uint32_t x;
|
||||||
x = (DWORD)*buffer++;
|
x = (uint32_t)*buffer++;
|
||||||
x = (x<<8) + (DWORD)*buffer++;
|
x = (x<<8) + (uint32_t)*buffer++;
|
||||||
x = (x<<8) + (DWORD)*buffer++;
|
x = (x<<8) + (uint32_t)*buffer++;
|
||||||
x = (x<<8) + (DWORD)*buffer++;
|
x = (x<<8) + (uint32_t)*buffer++;
|
||||||
*value = x;
|
*value = x;
|
||||||
return buffer;
|
return buffer;
|
||||||
} /* ExtractLong */
|
} /* ExtractLong */
|
||||||
|
|
||||||
|
|
||||||
static BYTE* ExtractBlock(WORD count, BYTE* data, BYTE* buffer)
|
static uint8_t* ExtractBlock(uint16_t count, uint8_t* data, uint8_t* buffer)
|
||||||
{
|
{
|
||||||
while (count--) *data++ = *buffer++;
|
while (count--) *data++ = *buffer++;
|
||||||
return buffer;
|
return buffer;
|
||||||
} /* ExtractBlock */
|
} /* ExtractBlock */
|
||||||
|
|
||||||
|
|
||||||
static char* WriteHex(char* pa, BYTE value, WORD* pCheckSum)
|
static char* WriteHex(char* pa, uint8_t value, uint16_t* pCheckSum)
|
||||||
{
|
{
|
||||||
WORD temp;
|
uint16_t temp;
|
||||||
|
|
||||||
static char ByteToHex[] = "0123456789ABCDEF";
|
static char ByteToHex[] = "0123456789ABCDEF";
|
||||||
|
|
||||||
@ -214,13 +174,13 @@ static char* WriteHex(char* pa, BYTE value, WORD* pCheckSum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char* BuildSRecord(char* pa, WORD sType, DWORD addr,
|
static char* BuildSRecord(char* pa, uint16_t sType, uint32_t addr,
|
||||||
const BYTE* data, int nCount)
|
const uint8_t* data, int nCount)
|
||||||
{
|
{
|
||||||
WORD addrLen;
|
uint16_t addrLen;
|
||||||
WORD sRLen;
|
uint16_t sRLen;
|
||||||
WORD checkSum;
|
uint16_t checkSum;
|
||||||
WORD i;
|
uint16_t i;
|
||||||
|
|
||||||
switch (sType) {
|
switch (sType) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -244,11 +204,11 @@ static char* BuildSRecord(char* pa, WORD sType, DWORD addr,
|
|||||||
*pa++ = (char)(sType + '0');
|
*pa++ = (char)(sType + '0');
|
||||||
sRLen = addrLen + nCount + 1;
|
sRLen = addrLen + nCount + 1;
|
||||||
checkSum = 0;
|
checkSum = 0;
|
||||||
pa = WriteHex(pa, (BYTE)sRLen, &checkSum);
|
pa = WriteHex(pa, (uint8_t)sRLen, &checkSum);
|
||||||
|
|
||||||
/* Write address field */
|
/* Write address field */
|
||||||
for (i = 1; i <= addrLen; i++) {
|
for (i = 1; i <= addrLen; i++) {
|
||||||
pa = WriteHex(pa, (BYTE)(addr >> (8 * (addrLen - i))), &checkSum);
|
pa = WriteHex(pa, (uint8_t)(addr >> (8 * (addrLen - i))), &checkSum);
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
/* Write code/data fields */
|
/* Write code/data fields */
|
||||||
@ -258,25 +218,25 @@ static char* BuildSRecord(char* pa, WORD sType, DWORD addr,
|
|||||||
|
|
||||||
/* Write checksum field */
|
/* Write checksum field */
|
||||||
checkSum = ~checkSum;
|
checkSum = ~checkSum;
|
||||||
pa = WriteHex(pa, (BYTE)checkSum, &checkSum);
|
pa = WriteHex(pa, (uint8_t)checkSum, &checkSum);
|
||||||
*pa++ = '\0';
|
*pa++ = '\0';
|
||||||
return pa;
|
return pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ConvertELF(char* fileName, DWORD loadOffset)
|
static void ConvertELF(char* fileName, uint32_t loadOffset)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
int i;
|
int i;
|
||||||
int rxCount;
|
int rxCount;
|
||||||
BYTE rxBlock[1024];
|
uint8_t rxBlock[1024];
|
||||||
DWORD loadSize;
|
uint32_t loadSize;
|
||||||
DWORD firstAddr;
|
uint32_t firstAddr;
|
||||||
DWORD loadAddr;
|
uint32_t loadAddr;
|
||||||
DWORD loadDiff = 0;
|
uint32_t loadDiff = 0;
|
||||||
Elf32_Ehdr elfHeader;
|
Elf32_Ehdr elfHeader;
|
||||||
Elf32_Shdr sectHeader[32];
|
Elf32_Shdr sectHeader[32];
|
||||||
BYTE* getPtr;
|
uint8_t* getPtr;
|
||||||
char srecLine[128];
|
char srecLine[128];
|
||||||
char *hdr_name;
|
char *hdr_name;
|
||||||
|
|
||||||
@ -292,11 +252,11 @@ static void ConvertELF(char* fileName, DWORD loadOffset)
|
|||||||
getPtr = ExtractBlock(sizeof elfHeader.e_ident, elfHeader.e_ident, rxBlock);
|
getPtr = ExtractBlock(sizeof elfHeader.e_ident, elfHeader.e_ident, rxBlock);
|
||||||
getPtr = ExtractWord(&elfHeader.e_type, getPtr);
|
getPtr = ExtractWord(&elfHeader.e_type, getPtr);
|
||||||
getPtr = ExtractWord(&elfHeader.e_machine, getPtr);
|
getPtr = ExtractWord(&elfHeader.e_machine, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)&elfHeader.e_version, getPtr);
|
getPtr = ExtractLong((uint32_t *)&elfHeader.e_version, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)&elfHeader.e_entry, getPtr);
|
getPtr = ExtractLong((uint32_t *)&elfHeader.e_entry, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)&elfHeader.e_phoff, getPtr);
|
getPtr = ExtractLong((uint32_t *)&elfHeader.e_phoff, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)&elfHeader.e_shoff, getPtr);
|
getPtr = ExtractLong((uint32_t *)&elfHeader.e_shoff, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)&elfHeader.e_flags, getPtr);
|
getPtr = ExtractLong((uint32_t *)&elfHeader.e_flags, getPtr);
|
||||||
getPtr = ExtractWord(&elfHeader.e_ehsize, getPtr);
|
getPtr = ExtractWord(&elfHeader.e_ehsize, getPtr);
|
||||||
getPtr = ExtractWord(&elfHeader.e_phentsize, getPtr);
|
getPtr = ExtractWord(&elfHeader.e_phentsize, getPtr);
|
||||||
getPtr = ExtractWord(&elfHeader.e_phnum, getPtr);
|
getPtr = ExtractWord(&elfHeader.e_phnum, getPtr);
|
||||||
@ -319,16 +279,16 @@ static void ConvertELF(char* fileName, DWORD loadOffset)
|
|||||||
fseek(file, elfHeader.e_shoff, SEEK_SET);
|
fseek(file, elfHeader.e_shoff, SEEK_SET);
|
||||||
for (i = 0; i < elfHeader.e_shnum; i++) {
|
for (i = 0; i < elfHeader.e_shnum; i++) {
|
||||||
rxCount = fread(rxBlock, 1, sizeof sectHeader[0], file);
|
rxCount = fread(rxBlock, 1, sizeof sectHeader[0], file);
|
||||||
getPtr = ExtractLong((DWORD *)§Header[i].sh_name, rxBlock);
|
getPtr = ExtractLong((uint32_t *)§Header[i].sh_name, rxBlock);
|
||||||
getPtr = ExtractLong((DWORD *)§Header[i].sh_type, getPtr);
|
getPtr = ExtractLong((uint32_t *)§Header[i].sh_type, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)§Header[i].sh_flags, getPtr);
|
getPtr = ExtractLong((uint32_t *)§Header[i].sh_flags, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)§Header[i].sh_addr, getPtr);
|
getPtr = ExtractLong((uint32_t *)§Header[i].sh_addr, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)§Header[i].sh_offset, getPtr);
|
getPtr = ExtractLong((uint32_t *)§Header[i].sh_offset, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)§Header[i].sh_size, getPtr);
|
getPtr = ExtractLong((uint32_t *)§Header[i].sh_size, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)§Header[i].sh_link, getPtr);
|
getPtr = ExtractLong((uint32_t *)§Header[i].sh_link, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)§Header[i].sh_info, getPtr);
|
getPtr = ExtractLong((uint32_t *)§Header[i].sh_info, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)§Header[i].sh_addralign, getPtr);
|
getPtr = ExtractLong((uint32_t *)§Header[i].sh_addralign, getPtr);
|
||||||
getPtr = ExtractLong((DWORD *)§Header[i].sh_entsize, getPtr);
|
getPtr = ExtractLong((uint32_t *)§Header[i].sh_entsize, getPtr);
|
||||||
if (rxCount != sizeof sectHeader[0]) {
|
if (rxCount != sizeof sectHeader[0]) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
fprintf (stderr, "*** illegal file format\n");
|
fprintf (stderr, "*** illegal file format\n");
|
||||||
@ -342,7 +302,7 @@ static void ConvertELF(char* fileName, DWORD loadOffset)
|
|||||||
++hdr_name;
|
++hdr_name;
|
||||||
}
|
}
|
||||||
/* write start record */
|
/* write start record */
|
||||||
(void)BuildSRecord(srecLine, 0, 0, (BYTE *)hdr_name, strlen(hdr_name));
|
(void)BuildSRecord(srecLine, 0, 0, (uint8_t *)hdr_name, strlen(hdr_name));
|
||||||
printf("%s\r\n",srecLine);
|
printf("%s\r\n",srecLine);
|
||||||
|
|
||||||
/* write data records */
|
/* write data records */
|
||||||
@ -395,7 +355,7 @@ static void ConvertELF(char* fileName, DWORD loadOffset)
|
|||||||
|
|
||||||
int main( int argc, char *argv[ ])
|
int main( int argc, char *argv[ ])
|
||||||
{
|
{
|
||||||
DWORD offset;
|
uint32_t offset;
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
ConvertELF(argv[1], 0);
|
ConvertELF(argv[1], 0);
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
#include "mingw_support.h"
|
#include "mingw_support.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
int fsync(int fd)
|
int fsync(int fd)
|
||||||
@ -77,3 +79,158 @@ int munmap(void *addr, size_t len)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reentrant string tokenizer. Generic version.
|
||||||
|
Copyright (C) 1991,1996-1999,2001,2004,2007 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
/* Parse S into tokens separated by characters in DELIM.
|
||||||
|
If S is NULL, the saved pointer in SAVE_PTR is used as
|
||||||
|
the next starting point. For example:
|
||||||
|
char s[] = "-abc-=-def";
|
||||||
|
char *sp;
|
||||||
|
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
|
||||||
|
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
|
||||||
|
x = strtok_r(NULL, "=", &sp); // x = NULL
|
||||||
|
// s = "abc\0-def\0"
|
||||||
|
*/
|
||||||
|
char *strtok_r(char *s, const char *delim, char **save_ptr)
|
||||||
|
{
|
||||||
|
char *token;
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
s = *save_ptr;
|
||||||
|
|
||||||
|
/* Scan leading delimiters. */
|
||||||
|
s += strspn(s, delim);
|
||||||
|
if (*s == '\0') {
|
||||||
|
*save_ptr = s;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the end of the token. */
|
||||||
|
token = s;
|
||||||
|
s = strpbrk (token, delim);
|
||||||
|
if (s == NULL) {
|
||||||
|
/* This token finishes the string. */
|
||||||
|
*save_ptr = memchr(token, '\0', strlen(token));
|
||||||
|
} else {
|
||||||
|
/* Terminate the token and make *SAVE_PTR point past it. */
|
||||||
|
*s = '\0';
|
||||||
|
*save_ptr = s + 1;
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* getline.c -- Replacement for GNU C library function getline
|
||||||
|
|
||||||
|
Copyright (C) 1993, 1996, 2001, 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
/* Written by Jan Brittenson, bson@gnu.ai.mit.edu. */
|
||||||
|
|
||||||
|
/* Always add at least this many bytes when extending the buffer. */
|
||||||
|
#define MIN_CHUNK 64
|
||||||
|
|
||||||
|
/* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR
|
||||||
|
+ OFFSET (and null-terminate it). *LINEPTR is a pointer returned from
|
||||||
|
malloc (or NULL), pointing to *N characters of space. It is realloc'd
|
||||||
|
as necessary. Return the number of characters read (not including the
|
||||||
|
null terminator), or -1 on error or EOF.
|
||||||
|
NOTE: There is another getstr() function declared in <curses.h>. */
|
||||||
|
static int getstr(char **lineptr, size_t *n, FILE *stream,
|
||||||
|
char terminator, size_t offset)
|
||||||
|
{
|
||||||
|
int nchars_avail; /* Allocated but unused chars in *LINEPTR. */
|
||||||
|
char *read_pos; /* Where we're reading into *LINEPTR. */
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!lineptr || !n || !stream)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!*lineptr) {
|
||||||
|
*n = MIN_CHUNK;
|
||||||
|
*lineptr = malloc(*n);
|
||||||
|
if (!*lineptr)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
nchars_avail = *n - offset;
|
||||||
|
read_pos = *lineptr + offset;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
register int c = getc(stream);
|
||||||
|
|
||||||
|
/* We always want at least one char left in the buffer, since we
|
||||||
|
always (unless we get an error while reading the first char)
|
||||||
|
NUL-terminate the line buffer. */
|
||||||
|
|
||||||
|
assert(*n - nchars_avail == read_pos - *lineptr);
|
||||||
|
if (nchars_avail < 2) {
|
||||||
|
if (*n > MIN_CHUNK)
|
||||||
|
*n *= 2;
|
||||||
|
else
|
||||||
|
*n += MIN_CHUNK;
|
||||||
|
|
||||||
|
nchars_avail = *n + *lineptr - read_pos;
|
||||||
|
*lineptr = realloc(*lineptr, *n);
|
||||||
|
if (!*lineptr)
|
||||||
|
return -1;
|
||||||
|
read_pos = *n - nchars_avail + *lineptr;
|
||||||
|
assert(*n - nchars_avail == read_pos - *lineptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == EOF || ferror (stream)) {
|
||||||
|
/* Return partial line, if any. */
|
||||||
|
if (read_pos == *lineptr)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*read_pos++ = c;
|
||||||
|
nchars_avail--;
|
||||||
|
|
||||||
|
if (c == terminator)
|
||||||
|
/* Return the line. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Done - NUL terminate and return the number of chars read. */
|
||||||
|
*read_pos = '\0';
|
||||||
|
|
||||||
|
ret = read_pos - (*lineptr + offset);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getline (char **lineptr, size_t *n, FILE *stream)
|
||||||
|
{
|
||||||
|
return getstr(lineptr, n, stream, '\n', 0);
|
||||||
|
}
|
||||||
|
@ -44,5 +44,7 @@ typedef ULONG ulong;
|
|||||||
int fsync(int fd);
|
int fsync(int fd);
|
||||||
void *mmap(void *, size_t, int, int, int, int);
|
void *mmap(void *, size_t, int, int, int, int);
|
||||||
int munmap(void *, size_t);
|
int munmap(void *, size_t);
|
||||||
|
char *strtok_r(char *s, const char *delim, char **save_ptr);
|
||||||
|
int getline(char **lineptr, size_t *n, FILE *stream);
|
||||||
|
|
||||||
#endif /* __MINGW_SUPPORT_H_ */
|
#endif /* __MINGW_SUPPORT_H_ */
|
||||||
|
@ -229,8 +229,15 @@ main (int argc, char **argv)
|
|||||||
case 'f':
|
case 'f':
|
||||||
if (--argc <= 0)
|
if (--argc <= 0)
|
||||||
usage ();
|
usage ();
|
||||||
|
params.type = IH_TYPE_FLATDT;
|
||||||
params.datafile = *++argv;
|
params.datafile = *++argv;
|
||||||
params.fflag = 1;
|
params.fflag = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The flattened image tree (FIT) format
|
||||||
|
* requires a flattened device tree image type
|
||||||
|
*/
|
||||||
|
params.type = IH_TYPE_FLATDT;
|
||||||
goto NXTARG;
|
goto NXTARG;
|
||||||
case 'n':
|
case 'n':
|
||||||
if (--argc <= 0)
|
if (--argc <= 0)
|
||||||
@ -292,23 +299,35 @@ NXTARG: ;
|
|||||||
|
|
||||||
params.imagefile = *argv;
|
params.imagefile = *argv;
|
||||||
|
|
||||||
if (!params.fflag){
|
if (params.fflag){
|
||||||
if (params.lflag) {
|
if (tparams->fflag_handle)
|
||||||
ifd = open (params.imagefile, O_RDONLY|O_BINARY);
|
/*
|
||||||
} else {
|
* in some cases, some additional processing needs
|
||||||
ifd = open (params.imagefile,
|
* to be done if fflag is defined
|
||||||
O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666);
|
*
|
||||||
}
|
* For ex. fit_handle_file for Fit file support
|
||||||
|
*/
|
||||||
|
retval = tparams->fflag_handle(¶ms);
|
||||||
|
|
||||||
if (ifd < 0) {
|
if (retval != EXIT_SUCCESS)
|
||||||
fprintf (stderr, "%s: Can't open %s: %s\n",
|
exit (retval);
|
||||||
params.cmdname, params.imagefile,
|
|
||||||
strerror(errno));
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.lflag) {
|
if (params.lflag || params.fflag) {
|
||||||
|
ifd = open (params.imagefile, O_RDONLY|O_BINARY);
|
||||||
|
} else {
|
||||||
|
ifd = open (params.imagefile,
|
||||||
|
O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ifd < 0) {
|
||||||
|
fprintf (stderr, "%s: Can't open %s: %s\n",
|
||||||
|
params.cmdname, params.imagefile,
|
||||||
|
strerror(errno));
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.lflag || params.fflag) {
|
||||||
/*
|
/*
|
||||||
* list header information of existing image
|
* list header information of existing image
|
||||||
*/
|
*/
|
||||||
@ -345,17 +364,6 @@ NXTARG: ;
|
|||||||
(void) munmap((void *)ptr, sbuf.st_size);
|
(void) munmap((void *)ptr, sbuf.st_size);
|
||||||
(void) close (ifd);
|
(void) close (ifd);
|
||||||
|
|
||||||
exit (retval);
|
|
||||||
} else if (params.fflag) {
|
|
||||||
if (tparams->fflag_handle)
|
|
||||||
/*
|
|
||||||
* in some cases, some additional processing needs
|
|
||||||
* to be done if fflag is defined
|
|
||||||
*
|
|
||||||
* For ex. fit_handle_file for Fit file support
|
|
||||||
*/
|
|
||||||
retval = tparams->fflag_handle(¶ms);
|
|
||||||
|
|
||||||
exit (retval);
|
exit (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user