summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS2
-rw-r--r--README46
-rw-r--r--board/esd/plu405/plu405.c8
-rw-r--r--board/esd/vom405/vom405.c35
-rw-r--r--board/freescale/mpc8260ads/mpc8260ads.c13
-rw-r--r--board/ids8247/ids8247.c16
-rw-r--r--board/keymile/mgcoge/mgcoge.c8
-rw-r--r--board/muas3001/muas3001.c16
-rw-r--r--common/Makefile1
-rw-r--r--common/cmd_bootm.c4
-rw-r--r--common/cmd_cache.c4
-rw-r--r--common/cmd_date.c6
-rw-r--r--common/cmd_i2c.c8
-rw-r--r--common/cmd_irq.c9
-rw-r--r--common/cmd_license.c4
-rw-r--r--common/cmd_mgdisk.c4
-rw-r--r--common/cmd_misc.c11
-rw-r--r--cpu/mpc8260/cpu.c1
-rw-r--r--doc/uImage.FIT/kernel.its3
-rw-r--r--doc/uImage.FIT/kernel_fdt.its3
-rw-r--r--doc/uImage.FIT/multi.its3
-rw-r--r--doc/uImage.FIT/update3.its3
-rw-r--r--doc/uImage.FIT/update_uboot.its3
-rw-r--r--drivers/mtd/spi/Makefile1
-rw-r--r--drivers/mtd/spi/spi_flash.c5
-rw-r--r--drivers/mtd/spi/spi_flash_internal.h1
-rw-r--r--drivers/mtd/spi/stmicro.c3
-rw-r--r--drivers/mtd/spi/winbond.c332
-rw-r--r--drivers/rtc/m41t11.c14
-rw-r--r--drivers/rtc/mc13783-rtc.c2
-rw-r--r--drivers/spi/atmel_dataflash_spi.c18
-rw-r--r--examples/standalone/Makefile8
-rw-r--r--examples/standalone/nios2.lds133
-rw-r--r--examples/standalone/smc91111_eeprom.c12
-rw-r--r--fs/ext2/ext2fs.c20
-rw-r--r--include/configs/MPC8536DS.h7
-rw-r--r--include/configs/MPC8541CDS.h7
-rw-r--r--include/configs/MPC8544DS.h7
-rw-r--r--include/configs/MPC8548CDS.h7
-rw-r--r--include/configs/MPC8555CDS.h7
-rw-r--r--include/configs/MPC8568MDS.h7
-rw-r--r--include/configs/MPC8569MDS.h7
-rw-r--r--include/configs/MPC8572DS.h7
-rw-r--r--include/configs/P2020DS.h7
-rw-r--r--include/configs/PLU405.h3
-rw-r--r--include/configs/mimc200.h2
-rw-r--r--include/image.h2
-rw-r--r--include/sja1000.h (renamed from examples/standalone/nios.lds)71
-rw-r--r--include/spi_flash.h1
-rw-r--r--lib_generic/Makefile1
-rw-r--r--lib_generic/circbuf.c (renamed from common/circbuf.c)0
-rw-r--r--lib_generic/lzma/LzmaTools.c9
-rw-r--r--lib_nios/config.mk2
-rw-r--r--lib_nios2/board.c2
-rw-r--r--lib_nios2/bootm.c5
-rw-r--r--lib_nios2/config.mk2
-rw-r--r--lib_ppc/Makefile2
-rw-r--r--lib_ppc/kgdb.c5
-rwxr-xr-xmkconfig5
-rw-r--r--net/net.c32
-rw-r--r--tools/.gitignore1
-rw-r--r--tools/fit_image.c34
-rw-r--r--tools/img2srec.c164
-rw-r--r--tools/mingw_support.c157
-rw-r--r--tools/mingw_support.h2
-rw-r--r--tools/mkimage.c58
66 files changed, 817 insertions, 566 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 8a61f5b2b7f..9734b1d0958 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -279,7 +279,7 @@ Nye Liu <nyet@zumanetworks.com>
ZUMA MPC7xx_74xx
-Jon Loeliger <jdl@freescale.com>
+Kumar Gala <kumar.gala@freescale.com>
MPC8540ADS MPC8540
MPC8560ADS MPC8560
diff --git a/README b/README
index 2c776876e23..8047c778887 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
#
-# (C) Copyright 2000 - 2008
+# (C) Copyright 2000 - 2009
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# 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:
====================
+- api Machine/arch independent API for external apps
- board Board dependent files
- common Misc architecture independent functions
- cpu CPU specific files
@@ -178,8 +179,8 @@ Directory Hierarchy:
- disk Code for disk drive partition handling
- doc Documentation (don't expect too much)
- drivers Commonly used device drivers
-- dtt Digital Thermometer and Thermostat drivers
- examples Example code for standalone applications, etc.
+- fs Filesystem code (cramfs, ext2, jffs2, etc.)
- include Header Files
- lib_arm Files generic to ARM architecture
- lib_avr32 Files generic to AVR32 architecture
@@ -187,9 +188,12 @@ Directory Hierarchy:
- lib_generic Files generic to all architectures
- lib_i386 Files generic to i386 architecture
- lib_m68k Files generic to m68k architecture
+- lib_microblaze Files generic to microblaze architecture
- lib_mips Files generic to MIPS architecture
- lib_nios Files generic to NIOS architecture
+- lib_nios2 Files generic to NIOS2 architecture
- lib_ppc Files generic to PowerPC architecture
+- lib_sh Files generic to SH architecture
- lib_sparc Files generic to SPARC architecture
- libfdt Library files to support flattened device trees
- net Networking code
@@ -1889,25 +1893,6 @@ The following options need to be configured:
example, some LED's) on your board. At the moment,
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:
Arg Where When
@@ -2061,6 +2046,25 @@ FIT uImage format:
-150 common/cmd_nand.c Incorrect FIT image format
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:
--------------
diff --git a/board/esd/plu405/plu405.c b/board/esd/plu405/plu405.c
index 1841cda0bb8..fcffdf67c01 100644
--- a/board/esd/plu405/plu405.c
+++ b/board/esd/plu405/plu405.c
@@ -26,6 +26,7 @@
#include <asm/io.h>
#include <command.h>
#include <malloc.h>
+#include <sja1000.h>
#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 + 3, 0); /* write LCR */
+ /*
+ * Init magnetic couplers
+ */
+ if (!getenv("noinitcoupler")) {
+ init_coupler(CAN0_BA);
+ init_coupler(CAN1_BA);
+ }
return 0;
}
diff --git a/board/esd/vom405/vom405.c b/board/esd/vom405/vom405.c
index fb480226599..de350369c10 100644
--- a/board/esd/vom405/vom405.c
+++ b/board/esd/vom405/vom405.c
@@ -26,11 +26,40 @@
#include <asm/io.h>
#include <command.h>
#include <malloc.h>
+#include <sja1000.h>
DECLARE_GLOBAL_DATA_PTR;
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)
{
/*
@@ -77,6 +106,12 @@ int misc_init_r (void)
gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
gd->bd->bi_flashoffset = 0;
+ /*
+ * Init magnetic coupler
+ */
+ if (!getenv("noinitcoupler"))
+ init_coupler(CAN_BA);
+
return (0);
}
diff --git a/board/freescale/mpc8260ads/mpc8260ads.c b/board/freescale/mpc8260ads/mpc8260ads.c
index 49a88bbdd14..be55626104b 100644
--- a/board/freescale/mpc8260ads/mpc8260ads.c
+++ b/board/freescale/mpc8260ads/mpc8260ads.c
@@ -550,24 +550,11 @@ void pci_init_board(void)
#endif
#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)
{
ft_cpu_setup(blob, bd);
#ifdef CONFIG_PCI
ft_pci_setup(blob, bd);
#endif
- ft_blob_update(blob, bd);
}
#endif
diff --git a/board/ids8247/ids8247.c b/board/ids8247/ids8247.c
index 79fe9da5baf..d621833cc11 100644
--- a/board/ids8247/ids8247.c
+++ b/board/ids8247/ids8247.c
@@ -400,24 +400,8 @@ int board_nand_init(struct nand_chip *nand)
#endif /* CONFIG_CMD_NAND */
#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)
{
ft_cpu_setup( blob, bd);
- ft_blob_update(blob, bd);
}
#endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */
diff --git a/board/keymile/mgcoge/mgcoge.c b/board/keymile/mgcoge/mgcoge.c
index b16a01ccc5b..932a80547f1 100644
--- a/board/keymile/mgcoge/mgcoge.c
+++ b/board/keymile/mgcoge/mgcoge.c
@@ -312,11 +312,10 @@ int hush_init_var (void)
#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)
{
- ulong memory_data[2] = {0};
ulong *flash_data = NULL;
ulong flash_reg[6] = {0};
flash_info_t *info;
@@ -324,11 +323,6 @@ void ft_blob_update (void *blob, bd_t *bd)
int size;
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",
(void *)&flash_data);
diff --git a/board/muas3001/muas3001.c b/board/muas3001/muas3001.c
index 36caed813dd..e0a7f32fd9d 100644
--- a/board/muas3001/muas3001.c
+++ b/board/muas3001/muas3001.c
@@ -308,25 +308,9 @@ int board_early_init_r (void)
void ft_blob_update (void *blob, bd_t *bd)
{
int ret, nodeoffset = 0;
- ulong memory_data[2] = {0};
ulong flash_data[4] = {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 */
flash_data[2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
flash_data[3] = cpu_to_be32 (CONFIG_SYS_FLASH_SIZE);
diff --git a/common/Makefile b/common/Makefile
index ec025eddd20..778418086c4 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -29,7 +29,6 @@ AOBJS =
# core
COBJS-y += main.o
-COBJS-y += circbuf.o
COBJS-y += console.o
COBJS-y += command.o
COBJS-y += dlmalloc.o
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index aa85fafab73..e0cb8695de9 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -133,7 +133,7 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
static boot_os_fn do_bootm_integrity;
#endif
-boot_os_fn * boot_os[] = {
+static boot_os_fn *boot_os[] = {
#ifdef CONFIG_BOOTM_LINUX
[IH_OS_LINUX] = do_bootm_linux,
#endif
@@ -546,7 +546,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
break;
#endif
-#ifdef CONFIG_OF_LIBFDT
+#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_SYS_BOOTMAPSZ)
case BOOTM_STATE_FDT:
{
ulong bootmap_base = getenv_bootm_low();
diff --git a/common/cmd_cache.c b/common/cmd_cache.c
index 0dfa3363bdd..12022584196 100644
--- a/common/cmd_cache.c
+++ b/common/cmd_cache.c
@@ -27,8 +27,6 @@
#include <common.h>
#include <command.h>
-#if defined(CONFIG_CMD_CACHE)
-
static int on_off (const char *);
int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -108,5 +106,3 @@ U_BOOT_CMD(
"[on, off]\n"
" - enable or disable data (writethrough) cache"
);
-
-#endif
diff --git a/common/cmd_date.c b/common/cmd_date.c
index 9f50f8956e5..3141a3968ae 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -71,9 +71,9 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/* and write to RTC */
rcode = rtc_set (&tm);
if(rcode)
- puts("## Set date failled\n");
+ puts("## Set date failed\n");
} else {
- puts("## Get date failled\n");
+ puts("## Get date failed\n");
}
}
/* FALL TROUGH */
@@ -81,7 +81,7 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
rcode = rtc_get (&tm);
if (rcode) {
- puts("## Get date failled\n");
+ puts("## Get date failed\n");
break;
}
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 8f0fc9e1d73..8d6feda2721 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -326,14 +326,6 @@ int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
#if !defined(CONFIG_SYS_I2C_FRAM)
udelay(11000);
#endif
-
-#if 0
- for (timeout = 0; timeout < 10; timeout++) {
- udelay(2000);
- if (i2c_probe(chip) == 0)
- break;
- }
-#endif
}
return (0);
diff --git a/common/cmd_irq.c b/common/cmd_irq.c
index 4604a5a31ef..2c7e6bbf0c2 100644
--- a/common/cmd_irq.c
+++ b/common/cmd_irq.c
@@ -47,3 +47,12 @@ U_BOOT_CMD(
"enable or disable interrupts",
"[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",
+ ""
+);
diff --git a/common/cmd_license.c b/common/cmd_license.c
index 141215b3a58..c6f272ad34a 100644
--- a/common/cmd_license.c
+++ b/common/cmd_license.c
@@ -23,8 +23,6 @@
#include <common.h>
-#if defined(CONFIG_CMD_LICENSE)
-
/* COPYING is currently 15951 bytes in size */
#define LICENSE_MAX 20480
@@ -56,5 +54,3 @@ U_BOOT_CMD(license, 1, 1, do_license,
"print GPL license text",
""
);
-
-#endif /* CONFIG_CMD_LICENSE */
diff --git a/common/cmd_mgdisk.c b/common/cmd_mgdisk.c
index aadc3356362..3ba62f618c0 100644
--- a/common/cmd_mgdisk.c
+++ b/common/cmd_mgdisk.c
@@ -24,8 +24,6 @@
#include <common.h>
#include <command.h>
-#if defined (CONFIG_CMD_MG_DISK)
-
#include <mg_disk.h>
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 write : mgd writesec [from] [sector] [counts]"
);
-
-#endif
diff --git a/common/cmd_misc.c b/common/cmd_misc.c
index b97537ecd00..b0ced2f3b88 100644
--- a/common/cmd_misc.c
+++ b/common/cmd_misc.c
@@ -49,17 +49,6 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
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(
sleep , 2, 1, do_sleep,
"delay execution for some time",
diff --git a/cpu/mpc8260/cpu.c b/cpu/mpc8260/cpu.c
index 17e62487226..aedbf297ab7 100644
--- a/cpu/mpc8260/cpu.c
+++ b/cpu/mpc8260/cpu.c
@@ -318,6 +318,7 @@ void ft_cpu_setup (void *blob, bd_t *bd)
"timebase-frequency", OF_TBCLK, 1);
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
"clock-frequency", bd->bi_intfreq, 1);
+ fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
}
#endif /* CONFIG_OF_LIBFDT */
diff --git a/doc/uImage.FIT/kernel.its b/doc/uImage.FIT/kernel.its
index d1a59391152..ef3ab8f726a 100644
--- a/doc/uImage.FIT/kernel.its
+++ b/doc/uImage.FIT/kernel.its
@@ -1,6 +1,9 @@
/*
* Simple U-boot uImage source file containing a single kernel
*/
+
+/dts-v1/;
+
/ {
description = "Simple image with single Linux kernel";
#address-cells = <1>;
diff --git a/doc/uImage.FIT/kernel_fdt.its b/doc/uImage.FIT/kernel_fdt.its
index fd6dee25713..7e940d2af91 100644
--- a/doc/uImage.FIT/kernel_fdt.its
+++ b/doc/uImage.FIT/kernel_fdt.its
@@ -1,6 +1,9 @@
/*
* 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";
#address-cells = <1>;
diff --git a/doc/uImage.FIT/multi.its b/doc/uImage.FIT/multi.its
index 1d8c2dbf905..a120da038f5 100644
--- a/doc/uImage.FIT/multi.its
+++ b/doc/uImage.FIT/multi.its
@@ -1,6 +1,9 @@
/*
* U-boot uImage source file with multiple kernels, ramdisks and FDT blobs
*/
+
+/dts-v1/;
+
/ {
description = "Various kernels, ramdisks and FDT blobs";
#address-cells = <1>;
diff --git a/doc/uImage.FIT/update3.its b/doc/uImage.FIT/update3.its
index 285cf73b4df..a6eaef691e2 100644
--- a/doc/uImage.FIT/update3.its
+++ b/doc/uImage.FIT/update3.its
@@ -1,6 +1,9 @@
/*
* Example Automatic software update file.
*/
+
+/dts-v1/;
+
/ {
description = "Automatic software updates: kernel, ramdisk, FDT";
#address-cells = <1>;
diff --git a/doc/uImage.FIT/update_uboot.its b/doc/uImage.FIT/update_uboot.its
index e0d27eacc99..846723e2d62 100644
--- a/doc/uImage.FIT/update_uboot.its
+++ b/doc/uImage.FIT/update_uboot.its
@@ -2,6 +2,9 @@
* Automatic software update for U-Boot
* Make sure the flashing addresses ('load' prop) is correct for your board!
*/
+
+/dts-v1/;
+
/ {
description = "Automatic U-Boot update";
#address-cells = <1>;
diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile
index e3e0292808c..4f11b363137 100644
--- a/drivers/mtd/spi/Makefile
+++ b/drivers/mtd/spi/Makefile
@@ -31,6 +31,7 @@ COBJS-$(CONFIG_SPI_FLASH_MACRONIX) += macronix.o
COBJS-$(CONFIG_SPI_FLASH_SPANSION) += spansion.o
COBJS-$(CONFIG_SPI_FLASH_SST) += sst.o
COBJS-$(CONFIG_SPI_FLASH_STMICRO) += stmicro.o
+COBJS-$(CONFIG_SPI_FLASH_WINBOND) += winbond.o
COBJS-$(CONFIG_SPI_M95XXX) += eeprom_m95xxx.o
COBJS := $(COBJS-y)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 25346a4a110..612f819dc29 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -140,6 +140,11 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
flash = spi_flash_probe_macronix(spi, idcode);
break;
#endif
+#ifdef CONFIG_SPI_FLASH_WINBOND
+ case 0xef:
+ flash = spi_flash_probe_winbond(spi, idcode);
+ break;
+#endif
#ifdef CONFIG_SPI_FLASH_STMICRO
case 0x20:
flash = spi_flash_probe_stmicro(spi, idcode);
diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h
index 0612383c693..08546fbb038 100644
--- a/drivers/mtd/spi/spi_flash_internal.h
+++ b/drivers/mtd/spi/spi_flash_internal.h
@@ -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_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_winbond(struct spi_slave *spi, u8 *idcode);
diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c
index 9b910c13fd8..ae0d0471f21 100644
--- a/drivers/mtd/spi/stmicro.c
+++ b/drivers/mtd/spi/stmicro.c
@@ -281,7 +281,8 @@ int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len)
ret = 0;
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);
if (ret < 0) {
diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c
new file mode 100644
index 00000000000..b8da9231931
--- /dev/null
+++ b/drivers/mtd/spi/winbond.c
@@ -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;
+}
diff --git a/drivers/rtc/m41t11.c b/drivers/rtc/m41t11.c
index e0c27e18509..bb134875b3d 100644
--- a/drivers/rtc/m41t11.c
+++ b/drivers/rtc/m41t11.c
@@ -181,18 +181,4 @@ void rtc_reset (void)
val = val & 0x3F;/*turn off freq test keep calibration*/
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
diff --git a/drivers/rtc/mc13783-rtc.c b/drivers/rtc/mc13783-rtc.c
index 05db2f1d474..416f50d01f9 100644
--- a/drivers/rtc/mc13783-rtc.c
+++ b/drivers/rtc/mc13783-rtc.c
@@ -109,7 +109,7 @@ int rtc_set(struct rtc_time *rtc)
spi_release_bus(slave);
- return -1;
+ return 0;
}
void rtc_reset(void)
diff --git a/drivers/spi/atmel_dataflash_spi.c b/drivers/spi/atmel_dataflash_spi.c
index 614965c3674..3a648e61902 100644
--- a/drivers/spi/atmel_dataflash_spi.c
+++ b/drivers/spi/atmel_dataflash_spi.c
@@ -30,7 +30,8 @@
#include <dataflash.h>
#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 */
void AT91F_SpiInit(void)
@@ -57,7 +58,14 @@ void AT91F_SpiInit(void)
((get_mck_clk_rate() / AT91_SPI_CLK) << 8),
AT91_BASE_SPI + AT91_SPI_CSR(1));
#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
/* Configure CS3 */
writel(AT91_SPI_NCPHA |
@@ -99,6 +107,12 @@ void AT91F_SpiEnable(int cs)
writel(mode | ((AT91_SPI_PCS1_DATAFLASH_CARD<<16) & AT91_SPI_PCS),
AT91_BASE_SPI + AT91_SPI_MR);
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:
mode = readl(AT91_BASE_SPI + AT91_SPI_MR);
mode &= 0xFFF0FFFF;
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index 5e2f2bcaeb4..6ea3b93db10 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -38,7 +38,13 @@ ELF-mpc8260 += mem_to_mem_idma2intr
ELF-ppc += sched
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))
BIN = $(addsuffix .bin,$(ELF))
diff --git a/examples/standalone/nios2.lds b/examples/standalone/nios2.lds
deleted file mode 100644
index a3e5ea8e336..00000000000
--- a/examples/standalone/nios2.lds
+++ /dev/null
@@ -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) }
-}
diff --git a/examples/standalone/smc91111_eeprom.c b/examples/standalone/smc91111_eeprom.c
index 89afc871fa7..428ea7bd2fa 100644
--- a/examples/standalone/smc91111_eeprom.c
+++ b/examples/standalone/smc91111_eeprom.c
@@ -33,8 +33,6 @@
struct eth_device { unsigned long iobase; };
#include "../drivers/net/smc91111.h"
-#ifdef CONFIG_SMC91111
-
#ifndef SMC91111_EEPROM_INIT
# define SMC91111_EEPROM_INIT()
#endif
@@ -391,13 +389,3 @@ void dump_reg (struct eth_device *dev)
printf ("\n");
}
}
-
-#else
-
-int smc91111_eeprom (int argc, char *argv[])
-{
- printf("Not supported for this board\n");
- return 1;
-}
-
-#endif
diff --git a/fs/ext2/ext2fs.c b/fs/ext2/ext2fs.c
index d54f60b30b9..4b391d60a8f 100644
--- a/fs/ext2/ext2fs.c
+++ b/fs/ext2/ext2fs.c
@@ -178,6 +178,7 @@ int indir1_blkno = -1;
uint32_t *indir2_block = NULL;
int indir2_size = 0;
int indir2_blkno = -1;
+static unsigned int inode_size;
static int ext2fs_blockgroup
@@ -212,7 +213,7 @@ static int ext2fs_read_inode
unsigned int blkoff;
#ifdef DEBUG
- printf ("ext2fs read inode %d\n", ino);
+ printf ("ext2fs read inode %d, inode_size %d\n", ino, inode_size);
#endif
/* It is easier to calculate if the first inode is 0. */
ino--;
@@ -222,16 +223,12 @@ static int ext2fs_read_inode
return (0);
}
- inodes_per_block = EXT2_BLOCK_SIZE(data) / __le16_to_cpu(sblock->inode_size);
-
-#ifdef DEBUG
- printf ("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff);
-#endif
+ inodes_per_block = EXT2_BLOCK_SIZE(data) / inode_size;
blkno = __le32_to_cpu (blkgrp.inode_table_id) +
(ino % __le32_to_cpu (sblock->inodes_per_group))
/ inodes_per_block;
- blkoff = (ino % inodes_per_block) * __le16_to_cpu (sblock->inode_size);
+ blkoff = (ino % inodes_per_block) * inode_size;
#ifdef DEBUG
printf ("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff);
#endif
@@ -863,6 +860,15 @@ int ext2fs_mount (unsigned part_length) {
if (__le16_to_cpu (data->sblock.magic) != EXT2_MAGIC) {
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.ino = 2;
data->diropen.inode_read = 1;
diff --git a/include/configs/MPC8536DS.h b/include/configs/MPC8536DS.h
index a8472754622..46d6e9d39c9 100644
--- a/include/configs/MPC8536DS.h
+++ b/include/configs/MPC8536DS.h
@@ -70,13 +70,6 @@
#define CONFIG_TSEC_ENET /* tsec ethernet support */
#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__
extern unsigned long get_board_sys_clk(unsigned long dummy);
extern unsigned long get_board_ddr_clk(unsigned long dummy);
diff --git a/include/configs/MPC8541CDS.h b/include/configs/MPC8541CDS.h
index a8f206f5386..f41fe300dd2 100644
--- a/include/configs/MPC8541CDS.h
+++ b/include/configs/MPC8541CDS.h
@@ -46,13 +46,6 @@
#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__
extern unsigned long get_clock_freq(void);
#endif
diff --git a/include/configs/MPC8544DS.h b/include/configs/MPC8544DS.h
index 0caf4560360..b7d355315d9 100644
--- a/include/configs/MPC8544DS.h
+++ b/include/configs/MPC8544DS.h
@@ -50,13 +50,6 @@
#define CONFIG_ENV_OVERWRITE
#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__
extern unsigned long get_board_sys_clk(unsigned long dummy);
#endif
diff --git a/include/configs/MPC8548CDS.h b/include/configs/MPC8548CDS.h
index e69ba901edc..53de56dbc32 100644
--- a/include/configs/MPC8548CDS.h
+++ b/include/configs/MPC8548CDS.h
@@ -52,13 +52,6 @@
#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__
extern unsigned long get_clock_freq(void);
#endif
diff --git a/include/configs/MPC8555CDS.h b/include/configs/MPC8555CDS.h
index 94952dc9909..abbfd4707c0 100644
--- a/include/configs/MPC8555CDS.h
+++ b/include/configs/MPC8555CDS.h
@@ -46,13 +46,6 @@
#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__
extern unsigned long get_clock_freq(void);
#endif
diff --git a/include/configs/MPC8568MDS.h b/include/configs/MPC8568MDS.h
index 7b8c6c772b4..426b93378f4 100644
--- a/include/configs/MPC8568MDS.h
+++ b/include/configs/MPC8568MDS.h
@@ -44,13 +44,6 @@
#define CONFIG_ENV_OVERWRITE
#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__
extern unsigned long get_clock_freq(void);
#endif /*Replace a call to get_clock_freq (after it is implemented)*/
diff --git a/include/configs/MPC8569MDS.h b/include/configs/MPC8569MDS.h
index 17ea3bb14ed..b87f375281b 100644
--- a/include/configs/MPC8569MDS.h
+++ b/include/configs/MPC8569MDS.h
@@ -44,13 +44,6 @@
#define CONFIG_ENV_OVERWRITE
#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__
extern unsigned long get_clock_freq(void);
#endif
diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h
index 000f8f62d62..0e7745c46ed 100644
--- a/include/configs/MPC8572DS.h
+++ b/include/configs/MPC8572DS.h
@@ -53,13 +53,6 @@
#define CONFIG_TSEC_ENET /* tsec ethernet support */
#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__
extern unsigned long get_board_sys_clk(unsigned long dummy);
extern unsigned long get_board_ddr_clk(unsigned long dummy);
diff --git a/include/configs/P2020DS.h b/include/configs/P2020DS.h
index b48c1999f8f..9574fcaa1fd 100644
--- a/include/configs/P2020DS.h
+++ b/include/configs/P2020DS.h
@@ -54,13 +54,6 @@
#define CONFIG_TSEC_ENET /* tsec ethernet support */
#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__
extern unsigned long calculate_board_sys_clk(unsigned long dummy);
extern unsigned long calculate_board_ddr_clk(unsigned long dummy);
diff --git a/include/configs/PLU405.h b/include/configs/PLU405.h
index 85e4611aa1c..5f5f1c76af3 100644
--- a/include/configs/PLU405.h
+++ b/include/configs/PLU405.h
@@ -298,7 +298,8 @@
/*
* 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 DUART1_BA 0xF0000408 /* DUART Base Address */
#define RTC_BA 0xF0000500 /* RTC Base Address */
diff --git a/include/configs/mimc200.h b/include/configs/mimc200.h
index 8f71664f325..36488b32cd2 100644
--- a/include/configs/mimc200.h
+++ b/include/configs/mimc200.h
@@ -74,7 +74,7 @@
#define CONFIG_BAUDRATE 115200
#define CONFIG_BOOTARGS \
- "root=/dev/mtdblock1 rootfstype=jffs2 console=ttyS1"
+ "root=/dev/mtdblock1 rootfstype=jffs2 fbmem=512k console=ttyS1"
#define CONFIG_BOOTCOMMAND \
"fsload boot/uImage; bootm"
diff --git a/include/image.h b/include/image.h
index cc38eae39a4..d2e78fe2983 100644
--- a/include/image.h
+++ b/include/image.h
@@ -220,12 +220,10 @@ typedef struct bootm_headers {
const char *fit_uname_rd; /* init ramdisk subimage node unit name */
int fit_noffset_rd; /* init ramdisk subimage node offset */
-#if defined(CONFIG_PPC)
void *fit_hdr_fdt; /* FDT blob FIT image header */
const char *fit_uname_fdt; /* FDT blob subimage node unit name */
int fit_noffset_fdt;/* FDT blob subimage node offset */
#endif
-#endif
#ifndef USE_HOSTCC
image_info_t os; /* os image info */
diff --git a/examples/standalone/nios.lds b/include/sja1000.h
index 4c1080b868c..59e35afa0dc 100644
--- a/examples/standalone/nios.lds
+++ b/include/sja1000.h
@@ -1,6 +1,7 @@
/*
- * (C) Copyright 2003, Psyent Corporation <www.psyent.com>
- * Scott McNutt <smcnutt@psyent.com>
+ * Copyright 2009, Matthias Fuchs <matthias.fuchs@esd.eu>
+ *
+ * SJA1000 register layout for basic CAN mode
*
* See file CREDITS for list of people who contributed to this
* project.
@@ -21,41 +22,39 @@
* MA 02111-1307 USA
*/
+#ifndef _SJA1000_H_
+#define _SJA1000_H_
-OUTPUT_FORMAT("elf32-nios")
-OUTPUT_ARCH(nios)
-ENTRY(_start)
-
-SECTIONS
-{
- .text :
- {
- *(.text)
- }
- __text_end = .;
+/*
+ * SJA1000 register layout in basic can mode
+ */
+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;
+};
- . = ALIGN(4);
- .rodata :
- {
- *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
- }
- __rodata_end = .;
+/* control register */
+#define CR_RR 0x01
- . = ALIGN(4);
- .data :
- {
- *(.data)
- }
- . = ALIGN(4);
- __data_end = .;
+/* output control register */
+#define OC_MODE0 0x01
+#define OC_MODE1 0x02
+#define OC_POL0 0x04
+#define OC_TN0 0x08
+#define OC_TP0 0x10
+#define OC_POL1 0x20
+#define OC_TN1 0x40
+#define OC_TP1 0x80
- __bss_start = .;
- . = ALIGN(4);
- .bss (NOLOAD) :
- {
- *(.bss)
- }
- . = ALIGN(4);
- __bss_end = .;
- _end = .;
-}
+#endif
diff --git a/include/spi_flash.h b/include/spi_flash.h
index de4f174ad52..1f8ba2987ef 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -24,6 +24,7 @@
#define _SPI_FLASH_H_
#include <spi.h>
+#include <linux/types.h>
struct spi_flash_region {
unsigned int count;
diff --git a/lib_generic/Makefile b/lib_generic/Makefile
index 7291fa3963f..bfaf3468ef6 100644
--- a/lib_generic/Makefile
+++ b/lib_generic/Makefile
@@ -31,6 +31,7 @@ COBJS-$(CONFIG_BZIP2) += bzlib_crctable.o
COBJS-$(CONFIG_BZIP2) += bzlib_decompress.o
COBJS-$(CONFIG_BZIP2) += bzlib_randtable.o
COBJS-$(CONFIG_BZIP2) += bzlib_huffman.o
+COBJS-$(CONFIG_USB_TTY) += circbuf.o
COBJS-y += crc16.o
COBJS-y += crc32.o
COBJS-y += ctype.o
diff --git a/common/circbuf.c b/lib_generic/circbuf.c
index 2332c63717d..2332c63717d 100644
--- a/common/circbuf.c
+++ b/lib_generic/circbuf.c
diff --git a/lib_generic/lzma/LzmaTools.c b/lib_generic/lzma/LzmaTools.c
index 408b577f17a..8860bfbf3da 100644
--- a/lib_generic/lzma/LzmaTools.c
+++ b/lib_generic/lzma/LzmaTools.c
@@ -97,11 +97,14 @@ int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
} else if (outSizeHigh != 0 || (UInt32)(SizeT)outSize != outSize) {
/*
* 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");
- return SZ_ERROR_DATA;
+ if (outSizeHigh != (SizeT)-1 || outSize != (SizeT)-1) {
+ debug ("LZMA: 64bit support not enabled.\n");
+ return SZ_ERROR_DATA;
+ }
}
debug ("LZMA: Uncompresed size............ 0x%lx\n", outSizeFull);
diff --git a/lib_nios/config.mk b/lib_nios/config.mk
index d48aa6dfd4e..e1b9f07bb30 100644
--- a/lib_nios/config.mk
+++ b/lib_nios/config.mk
@@ -24,6 +24,6 @@
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
diff --git a/lib_nios2/board.c b/lib_nios2/board.c
index 008f04f9562..41d3297190b 100644
--- a/lib_nios2/board.c
+++ b/lib_nios2/board.c
@@ -83,8 +83,6 @@ void board_init (void)
{
bd_t *bd;
init_fnc_t **init_fnc_ptr;
- char *s, *e;
- int i;
/* Pointer is writable since we allocated a register for it.
* Nios treats CONFIG_SYS_GBL_DATA_OFFSET as an address.
diff --git a/lib_nios2/bootm.c b/lib_nios2/bootm.c
index 53fd5691ad7..675bfac63a5 100644
--- a/lib_nios2/bootm.c
+++ b/lib_nios2/bootm.c
@@ -24,6 +24,7 @@
#include <common.h>
#include <command.h>
#include <asm/byteorder.h>
+#include <asm/cache.h>
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))
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
* needs to be called ;-)
*/
diff --git a/lib_nios2/config.mk b/lib_nios2/config.mk
index 34ee6977d93..be406392803 100644
--- a/lib_nios2/config.mk
+++ b/lib_nios2/config.mk
@@ -24,7 +24,7 @@
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 += -ffixed-r15 -G0
diff --git a/lib_ppc/Makefile b/lib_ppc/Makefile
index 399b41e31e0..60a76253b26 100644
--- a/lib_ppc/Makefile
+++ b/lib_ppc/Makefile
@@ -35,7 +35,7 @@ COBJS-y += bootm.o
COBJS-y += cache.o
COBJS-y += extable.o
COBJS-y += interrupts.o
-COBJS-y += kgdb.o
+COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
COBJS-y += time.o
SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
diff --git a/lib_ppc/kgdb.c b/lib_ppc/kgdb.c
index 78c2f0c4758..d3eb1f35a9f 100644
--- a/lib_ppc/kgdb.c
+++ b/lib_ppc/kgdb.c
@@ -1,8 +1,5 @@
#include <common.h>
#include <command.h>
-
-#if defined(CONFIG_CMD_KGDB)
-
#include <kgdb.h>
#include <asm/signal.h>
#include <asm/processor.h>
@@ -322,5 +319,3 @@ kgdb_breakpoint(int argc, char *argv[])
breakinst: .long 0x7d821008\n\
");
}
-
-#endif
diff --git a/mkconfig b/mkconfig
index bdc9d91d171..27d9f2bac7c 100755
--- a/mkconfig
+++ b/mkconfig
@@ -27,6 +27,11 @@ done
[ $# -lt 4 ] && 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..."
#
diff --git a/net/net.c b/net/net.c
index cab4b2dd885..fd13cd93f44 100644
--- a/net/net.c
+++ b/net/net.c
@@ -197,6 +197,8 @@ volatile uchar *NetTxPacket = 0; /* THE transmit packet */
static int net_check_prereq (proto_t protocol);
+static int NetTryCount;
+
/**********************************************************************/
IPaddr_t NetArpWaitPacketIP;
@@ -320,6 +322,7 @@ NetLoop(proto_t protocol)
NetArpWaitReplyIP = 0;
NetArpWaitTxPacket = NULL;
NetTxPacket = NULL;
+ NetTryCount = 1;
if (!NetTxPacket) {
int i;
@@ -558,17 +561,30 @@ startAgainHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
void NetStartAgain (void)
{
char *nretry;
- int noretry = 0, once = 0;
+ int retry_forever = 0;
+ unsigned long retrycnt = 0;
+
+ nretry = getenv("netretry");
+ if (nretry) {
+ if (!strcmp(nretry, "yes"))
+ retry_forever = 1;
+ else if (!strcmp(nretry, "no"))
+ retrycnt = 0;
+ else if (!strcmp(nretry, "once"))
+ retrycnt = 1;
+ else
+ retrycnt = simple_strtoul(nretry, NULL, 0);
+ } else
+ retry_forever = 1;
- if ((nretry = getenv ("netretry")) != NULL) {
- noretry = (strcmp (nretry, "no") == 0);
- once = (strcmp (nretry, "once") == 0);
- }
- if (noretry) {
- eth_halt ();
+ if ((!retry_forever) && (NetTryCount >= retrycnt)) {
+ eth_halt();
NetState = NETLOOP_FAIL;
return;
}
+
+ NetTryCount++;
+
#ifndef CONFIG_NET_MULTI
NetSetTimeout (10000UL, startAgainTimeout);
NetSetHandler (startAgainHandler);
@@ -580,7 +596,7 @@ void NetStartAgain (void)
eth_init (gd->bd);
if (NetRestartWrap) {
NetRestartWrap = 0;
- if (NetDevExists && !once) {
+ if (NetDevExists) {
NetSetTimeout (10000UL, startAgainTimeout);
NetSetHandler (startAgainHandler);
} else {
diff --git a/tools/.gitignore b/tools/.gitignore
index 03f54ef1221..cb067a40710 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -8,3 +8,4 @@
/ncp
/ubsha1
/inca-swap-bytes
+/*.exe
diff --git a/tools/fit_image.c b/tools/fit_image.c
index d1e612fece3..ef9ffeeec59 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -155,38 +155,6 @@ static int fit_handle_file (struct mkimage_params *params)
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)
{
return ((params->dflag && (params->fflag || params->lflag)) ||
@@ -202,7 +170,7 @@ static struct image_type_params fitimage_params = {
.print_header = fit_print_contents,
.check_image_type = fit_check_image_types,
.fflag_handle = fit_handle_file,
- .set_header = fit_set_header,
+ .set_header = NULL, /* FIT images use DTB header */
.check_params = fit_check_params,
};
diff --git a/tools/img2srec.c b/tools/img2srec.c
index f10379fe42b..ec769640239 100644
--- a/tools/img2srec.c
+++ b/tools/img2srec.c
@@ -53,6 +53,7 @@
|*************************************************************************/
#include "os_support.h"
+#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@@ -63,63 +64,22 @@
#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
|*************************************************************************/
-static char* ExtractHex (DWORD* value, char* getPtr)
+static char* ExtractHex (uint32_t* value, char* getPtr)
{
- DWORD num;
- DWORD digit;
- BYTE c;
+ uint32_t num;
+ uint32_t digit;
+ uint8_t c;
while (*getPtr == ' ') getPtr++;
num = 0;
for (;;) {
c = *getPtr;
- if ((c >= '0') && (c <= '9')) digit = (DWORD)(c - '0');
- else if ((c >= 'A') && (c <= 'F')) digit = (DWORD)(c - 'A' + 10);
- else if ((c >= 'a') && (c <= 'f')) digit = (DWORD)(c - 'a' + 10);
+ if ((c >= '0') && (c <= '9')) digit = (uint32_t)(c - '0');
+ else if ((c >= 'A') && (c <= 'F')) digit = (uint32_t)(c - 'A' + 10);
+ else if ((c >= 'a') && (c <= 'f')) digit = (uint32_t)(c - 'a' + 10);
else break;
num <<= 4;
num += digit;
@@ -129,17 +89,17 @@ static char* ExtractHex (DWORD* value, char* getPtr)
return getPtr;
} /* ExtractHex */
-static char* ExtractDecimal (DWORD* value, char* getPtr)
+static char* ExtractDecimal (uint32_t* value, char* getPtr)
{
- DWORD num;
- DWORD digit;
- BYTE c;
+ uint32_t num;
+ uint32_t digit;
+ uint8_t c;
while (*getPtr == ' ') getPtr++;
num = 0;
for (;;) {
c = *getPtr;
- if ((c >= '0') && (c <= '9')) digit = (DWORD)(c - '0');
+ if ((c >= '0') && (c <= '9')) digit = (uint32_t)(c - '0');
else break;
num *= 10;
num += digit;
@@ -150,13 +110,13 @@ static char* ExtractDecimal (DWORD* value, char* getPtr)
} /* 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++;
if (*getPtr == '-') {
- neg = TRUE;
+ neg = true;
getPtr++;
} /* if */
if ((*getPtr == '0') && ((*(getPtr+1) == 'x') || (*(getPtr+1) == 'X'))) {
@@ -170,38 +130,38 @@ static void ExtractNumber (DWORD* value, char* getPtr)
} /* ExtractNumber */
-static BYTE* ExtractWord(WORD* value, BYTE* buffer)
+static uint8_t* ExtractWord(uint16_t* value, uint8_t* buffer)
{
- WORD x;
- x = (WORD)*buffer++;
- x = (x<<8) + (WORD)*buffer++;
+ uint16_t x;
+ x = (uint16_t)*buffer++;
+ x = (x<<8) + (uint16_t)*buffer++;
*value = x;
return buffer;
} /* ExtractWord */
-static BYTE* ExtractLong(DWORD* value, BYTE* buffer)
+static uint8_t* ExtractLong(uint32_t* value, uint8_t* buffer)
{
- DWORD x;
- x = (DWORD)*buffer++;
- x = (x<<8) + (DWORD)*buffer++;
- x = (x<<8) + (DWORD)*buffer++;
- x = (x<<8) + (DWORD)*buffer++;
+ uint32_t x;
+ x = (uint32_t)*buffer++;
+ x = (x<<8) + (uint32_t)*buffer++;
+ x = (x<<8) + (uint32_t)*buffer++;
+ x = (x<<8) + (uint32_t)*buffer++;
*value = x;
return buffer;
} /* 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++;
return buffer;
} /* 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";
@@ -214,13 +174,13 @@ static char* WriteHex(char* pa, BYTE value, WORD* pCheckSum)
}
-static char* BuildSRecord(char* pa, WORD sType, DWORD addr,
- const BYTE* data, int nCount)
+static char* BuildSRecord(char* pa, uint16_t sType, uint32_t addr,
+ const uint8_t* data, int nCount)
{
- WORD addrLen;
- WORD sRLen;
- WORD checkSum;
- WORD i;
+ uint16_t addrLen;
+ uint16_t sRLen;
+ uint16_t checkSum;
+ uint16_t i;
switch (sType) {
case 0:
@@ -244,11 +204,11 @@ static char* BuildSRecord(char* pa, WORD sType, DWORD addr,
*pa++ = (char)(sType + '0');
sRLen = addrLen + nCount + 1;
checkSum = 0;
- pa = WriteHex(pa, (BYTE)sRLen, &checkSum);
+ pa = WriteHex(pa, (uint8_t)sRLen, &checkSum);
/* Write address field */
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 */
/* Write code/data fields */
@@ -258,25 +218,25 @@ static char* BuildSRecord(char* pa, WORD sType, DWORD addr,
/* Write checksum field */
checkSum = ~checkSum;
- pa = WriteHex(pa, (BYTE)checkSum, &checkSum);
+ pa = WriteHex(pa, (uint8_t)checkSum, &checkSum);
*pa++ = '\0';
return pa;
}
-static void ConvertELF(char* fileName, DWORD loadOffset)
+static void ConvertELF(char* fileName, uint32_t loadOffset)
{
FILE* file;
int i;
int rxCount;
- BYTE rxBlock[1024];
- DWORD loadSize;
- DWORD firstAddr;
- DWORD loadAddr;
- DWORD loadDiff = 0;
+ uint8_t rxBlock[1024];
+ uint32_t loadSize;
+ uint32_t firstAddr;
+ uint32_t loadAddr;
+ uint32_t loadDiff = 0;
Elf32_Ehdr elfHeader;
Elf32_Shdr sectHeader[32];
- BYTE* getPtr;
+ uint8_t* getPtr;
char srecLine[128];
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 = ExtractWord(&elfHeader.e_type, getPtr);
getPtr = ExtractWord(&elfHeader.e_machine, getPtr);
- getPtr = ExtractLong((DWORD *)&elfHeader.e_version, getPtr);
- getPtr = ExtractLong((DWORD *)&elfHeader.e_entry, getPtr);
- getPtr = ExtractLong((DWORD *)&elfHeader.e_phoff, getPtr);
- getPtr = ExtractLong((DWORD *)&elfHeader.e_shoff, getPtr);
- getPtr = ExtractLong((DWORD *)&elfHeader.e_flags, getPtr);
+ getPtr = ExtractLong((uint32_t *)&elfHeader.e_version, getPtr);
+ getPtr = ExtractLong((uint32_t *)&elfHeader.e_entry, getPtr);
+ getPtr = ExtractLong((uint32_t *)&elfHeader.e_phoff, getPtr);
+ getPtr = ExtractLong((uint32_t *)&elfHeader.e_shoff, getPtr);
+ getPtr = ExtractLong((uint32_t *)&elfHeader.e_flags, getPtr);
getPtr = ExtractWord(&elfHeader.e_ehsize, getPtr);
getPtr = ExtractWord(&elfHeader.e_phentsize, 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);
for (i = 0; i < elfHeader.e_shnum; i++) {
rxCount = fread(rxBlock, 1, sizeof sectHeader[0], file);
- getPtr = ExtractLong((DWORD *)&sectHeader[i].sh_name, rxBlock);
- getPtr = ExtractLong((DWORD *)&sectHeader[i].sh_type, getPtr);
- getPtr = ExtractLong((DWORD *)&sectHeader[i].sh_flags, getPtr);
- getPtr = ExtractLong((DWORD *)&sectHeader[i].sh_addr, getPtr);
- getPtr = ExtractLong((DWORD *)&sectHeader[i].sh_offset, getPtr);
- getPtr = ExtractLong((DWORD *)&sectHeader[i].sh_size, getPtr);
- getPtr = ExtractLong((DWORD *)&sectHeader[i].sh_link, getPtr);
- getPtr = ExtractLong((DWORD *)&sectHeader[i].sh_info, getPtr);
- getPtr = ExtractLong((DWORD *)&sectHeader[i].sh_addralign, getPtr);
- getPtr = ExtractLong((DWORD *)&sectHeader[i].sh_entsize, getPtr);
+ getPtr = ExtractLong((uint32_t *)&sectHeader[i].sh_name, rxBlock);
+ getPtr = ExtractLong((uint32_t *)&sectHeader[i].sh_type, getPtr);
+ getPtr = ExtractLong((uint32_t *)&sectHeader[i].sh_flags, getPtr);
+ getPtr = ExtractLong((uint32_t *)&sectHeader[i].sh_addr, getPtr);
+ getPtr = ExtractLong((uint32_t *)&sectHeader[i].sh_offset, getPtr);
+ getPtr = ExtractLong((uint32_t *)&sectHeader[i].sh_size, getPtr);
+ getPtr = ExtractLong((uint32_t *)&sectHeader[i].sh_link, getPtr);
+ getPtr = ExtractLong((uint32_t *)&sectHeader[i].sh_info, getPtr);
+ getPtr = ExtractLong((uint32_t *)&sectHeader[i].sh_addralign, getPtr);
+ getPtr = ExtractLong((uint32_t *)&sectHeader[i].sh_entsize, getPtr);
if (rxCount != sizeof sectHeader[0]) {
fclose(file);
fprintf (stderr, "*** illegal file format\n");
@@ -342,7 +302,7 @@ static void ConvertELF(char* fileName, DWORD loadOffset)
++hdr_name;
}
/* 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);
/* write data records */
@@ -395,7 +355,7 @@ static void ConvertELF(char* fileName, DWORD loadOffset)
int main( int argc, char *argv[ ])
{
- DWORD offset;
+ uint32_t offset;
if (argc == 2) {
ConvertELF(argv[1], 0);
diff --git a/tools/mingw_support.c b/tools/mingw_support.c
index 67cd6e115f4..63797108bb8 100644
--- a/tools/mingw_support.c
+++ b/tools/mingw_support.c
@@ -24,7 +24,9 @@
#include "mingw_support.h"
#include <stdio.h>
#include <stdint.h>
+#include <string.h>
#include <errno.h>
+#include <assert.h>
#include <io.h>
int fsync(int fd)
@@ -77,3 +79,158 @@ int munmap(void *addr, size_t len)
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);
+}
diff --git a/tools/mingw_support.h b/tools/mingw_support.h
index 9e45e64911b..27936746bda 100644
--- a/tools/mingw_support.h
+++ b/tools/mingw_support.h
@@ -44,5 +44,7 @@ typedef ULONG ulong;
int fsync(int fd);
void *mmap(void *, size_t, int, int, int, int);
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_ */
diff --git a/tools/mkimage.c b/tools/mkimage.c
index ab6ea32ad05..6826eae7710 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -229,8 +229,15 @@ main (int argc, char **argv)
case 'f':
if (--argc <= 0)
usage ();
+ params.type = IH_TYPE_FLATDT;
params.datafile = *++argv;
params.fflag = 1;
+
+ /*
+ * The flattened image tree (FIT) format
+ * requires a flattened device tree image type
+ */
+ params.type = IH_TYPE_FLATDT;
goto NXTARG;
case 'n':
if (--argc <= 0)
@@ -292,23 +299,35 @@ NXTARG: ;
params.imagefile = *argv;
- if (!params.fflag){
- if (params.lflag) {
- ifd = open (params.imagefile, O_RDONLY|O_BINARY);
- } else {
- ifd = open (params.imagefile,
- O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666);
- }
+ 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(&params);
- if (ifd < 0) {
- fprintf (stderr, "%s: Can't open %s: %s\n",
- params.cmdname, params.imagefile,
- strerror(errno));
- exit (EXIT_FAILURE);
- }
+ if (retval != EXIT_SUCCESS)
+ exit (retval);
}
- 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
*/
@@ -346,17 +365,6 @@ NXTARG: ;
(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(&params);
-
- exit (retval);
}
/*