8 +EXTRAVERSION = -IFX-LXDB
9 U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
10 VERSION_FILE = $(obj)include/version_autogenerated.h
13 # Deal with colliding definitions from tcsh etc.
16 +# Default algorithm form compressing u-boot.bin
19 +COMPRESS_FILE=$(obj)u-boot.img
21 +ifeq ($(COMPRESS),lzma)
22 +COMPRESS_FILE=$(obj)u-boot.limg
24 +ifeq ($(COMPRESS),bz2)
25 +COMPRESS_FILE=$(obj)u-boot.bzimg
27 +ifeq ($(COMPRESS),gzip)
28 +COMPRESS_FILE=$(obj)u-boot.zimg
30 +ifeq ($(COMPRESS),none)
31 +COMPRESS_FILE=$(obj)u-boot.img
35 #########################################################################
37 # U-boot build supports producing a object files to the separate external
39 # U-Boot objects....order is important (i.e. start must be first)
41 OBJS = cpu/$(CPU)/start.o
42 +OBJS_BOOTSTRAP = cpu/$(CPU)/start_bootstrap.o
44 +cpu/$(CPU)/start_bootstrap.S: cpu/$(CPU)/start.S
45 + ln -s start.S cpu/$(CPU)/start_bootstrap.S
48 OBJS += cpu/$(CPU)/start16.o
49 OBJS += cpu/$(CPU)/reset.o
53 OBJS := $(addprefix $(obj),$(OBJS))
54 +OBJS_BOOTSTRAP := $(addprefix $(obj),$(OBJS_BOOTSTRAP))
56 LIBS = lib_generic/libgeneric.a
57 LIBS += board/$(BOARDDIR)/lib$(BOARD).a
61 LIBS := $(addprefix $(obj),$(LIBS))
63 +LIBS_BOOTSTRAP = lib_bootstrap/libbootstrap.a
64 +LIBS_BOOTSTRAP+= board/$(BOARDDIR)/lib$(BOARD).a
65 +#LIBS_BOOTSTRAP+= board/ifx/libifx.a
66 +LIBS_BOOTSTRAP+= cpu/$(CPU)/lib$(CPU).a
68 +LIBS_BOOTSTRAP := $(addprefix $(obj),$(LIBS_BOOTSTRAP))
71 +.PHONY : $(obj)lib_bootstrap/libbootstrap.a
74 PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
76 # The "tools" are needed early, so put this first
77 # Don't include stuff already done in $(LIBS)
86 __OBJS := $(subst $(obj),,$(OBJS))
87 __LIBS := $(subst $(obj),,$(LIBS))
88 +__LIBS_BOOTSTRAP := $(subst $(obj),,$(LIBS_BOOTSTRAP))
90 +#__HEAD_OBJS := $(subst $(obj),,$(HEAD_OBJS))
91 +#__HEAD_LIBS := $(subst $(obj),,$(HEAD_LIBS))
93 #########################################################################
94 #########################################################################
96 ALL = $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND)
97 +#IFX_ALL = $(obj)u-boot.ifx $(obj)head.srec $(obj)head.bin $(obj)head $(obj)head.map $(COMPRESS_FILE) $(obj)u-boot.srec
98 +IFX_ALL = $(obj)u-boot.srec $(obj)u-boot.ifx $(obj)u-boot.lzimg $(obj)System.map $(obj)bootstrap.bin $(obj)System_bootstrap.map
99 +IFX_BOOTSTRAP = $(obj)bootstrap.bin
105 +ifx_bootstrap: $(IFX_BOOTSTRAP)
107 +$(obj)u-boot.ifx: $(obj)bootstrap.bin $(obj)u-boot.lzimg
108 + @cat $(obj)bootstrap.bin > $(obj)u-boot.ifx
109 + @cat $(obj)u-boot.lzimg >> $(obj)u-boot.ifx
111 +$(obj)u-boot.lzimg: $(obj)u-boot.bin $(obj)System.map
112 + @lzma e $(obj)u-boot.bin $(obj)u-boot.lzma
113 + $(obj)tools/mkimage -A mips -T firmware -C lzma \
114 + -a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
115 + -e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
116 + -n 'u-boot image' -d $(obj)u-boot.lzma $@
118 +$(obj)ld_uboot.img: $(obj)u-boot.ifx $(obj)u-boot.lzimg $(obj)bootstrap.bin
119 + @ cp -f $(obj)u-boot.ifx $(obj)u-boot.bin
120 + @ ./mkbootimg.incaip2 $(obj)ld_uboot.img < ld_uboot.conf
122 +$(obj)u-boot.zimg: $(obj)u-boot.bin $(obj)System.map
123 + gzip $(obj)u-boot.bin
124 + $(obj)tools/mkimage -A $(ARCH) -T firmware -C gzip \
125 + -a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
126 + -e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
127 + -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
128 + sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
131 +$(obj)u-boot.bzimg: $(obj)u-boot.bin $(obj)System.map
132 + bzip $(obj)u-boot.bin
133 + $(obj)tools/mkimage -A $(ARCH) -T firmware -C bzip2 \
134 + -a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
135 + -e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
136 + -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
137 + sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
140 +$(obj)u-boot.limg: $(obj)u-boot.bin $(obj)System.map
141 + @lzma e $(obj)u-boot.bin $(obj)u-boot.lzma
142 + $(obj)tools/mkimage -A $(ARCH) -T firmware -C lzma \
143 + -a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
144 + -e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
145 + -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
146 + sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
149 +$(obj)u-boot.img: $(obj)u-boot.bin $(obj)System.map
150 + $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
151 + -a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
152 + -e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
153 + -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
154 + sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
157 $(obj)u-boot.hex: $(obj)u-boot
158 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
160 @@ -243,28 +338,33 @@
161 $(obj)u-boot.bin: $(obj)u-boot
162 $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
164 -$(obj)u-boot.img: $(obj)u-boot.bin
165 - ./tools/mkimage -A $(ARCH) -T firmware -C none \
166 - -a $(TEXT_BASE) -e 0 \
167 - -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
168 - sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
171 $(obj)u-boot.dis: $(obj)u-boot
172 $(OBJDUMP) -d $< > $@
174 -$(obj)u-boot: depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
175 +$(obj)u-boot: depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
176 UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
177 cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
178 --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
179 -Map u-boot.map -o u-boot
181 +$(obj)bootstrap.bin: $(obj)bootstrap
182 + $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
184 +$(obj)bootstrap : depend version $(SUBDIRS) $(OBJS_BOOTSTRAP) $(LIBS_BOOTSTRAP) $(LDSCRIPT_BOOTSTRAP)
185 + UNDEF_SYM=`$(OBJDUMP) -x $(LIBS_BOOTSTRAP) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
186 + $(LD) $(LDFLAGS_BOOTSTRAP) $$UNDEF_SYM $(OBJS_BOOTSTRAP) \
187 + --start-group $(__LIBS_BOOTSTRAP) --end-group $(PLATFORM_LIBS) \
188 + -Map bootstrap.map -o bootstrap
191 $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
194 $(MAKE) -C $(dir $(subst $(obj),,$@))
196 +$(obj)lib_bootstrap/libbootstrap.a:
197 + $(MAKE) -C $(dir $(subst $(obj),,$@))
203 $(obj)System.map: $(obj)u-boot
205 grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
206 - sort > $(obj)System.map
209 +$(obj)System_bootstrap.map: $(obj)bootstrap
211 + grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
214 #########################################################################
216 @@ -2032,7 +2137,20 @@
218 #========================================================================
219 #########################################################################
221 +## Infineon MIPS generic u-boot config
222 +#########################################################################
223 +danube_config: unconfig
224 + @$(MKCONFIG) $(@:_config=) mips mips danube ifx danube
226 +amazon_config: unconfig
227 + @$(MKCONFIG) $(@:_config=) mips mips amazon
230 +incaip2_config: unconfig
231 + @$(MKCONFIG) $(@:_config=) mips mips incaip2
233 +#########################################################################
235 #########################################################################
237 xtract_incaip = $(subst _100MHz,,$(subst _133MHz,,$(subst _150MHz,,$(subst _config,,$1))))
238 @@ -2254,7 +2372,7 @@
240 rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS $(obj)include/version_autogenerated.h
242 - rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
243 + rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL) $(IFX_ALL)
244 rm -f $(obj)tools/crc32.c $(obj)tools/environment.c $(obj)tools/env/crc32.c
245 rm -f $(obj)tools/inca-swap-bytes $(obj)cpu/mpc824x/bedbug_603e.c
246 rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
247 --- a/common/cmd_bootm.c
248 +++ b/common/cmd_bootm.c
253 +#include <LzmaWrapper.h>
254 #include <environment.h>
255 #include <asm/byteorder.h>
258 # define CHUNKSZ (64 * 1024)
261 +#ifndef CFG_HEAD_CODE
263 int gunzip (void *, int, unsigned char *, unsigned long *);
265 static void *zalloc(void *, unsigned, unsigned);
267 #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
270 +#ifndef CONFIG_REMOVE_GZIP
272 printf (" Uncompressing %s ... ", name);
273 if (gunzip ((void *)ntohl(hdr->ih_load), unc_len,
275 do_reset (cmdtp, flag, argc, argv);
278 +#endif /* CONFIG_REMOVE_GZIP */
281 printf (" Uncompressing %s ... ", name);
285 #endif /* CONFIG_BZIP2 */
288 + printf (" Uncompressing %s ... ", name);
289 + i = lzma_inflate ((unsigned char *)data, len, (unsigned char*)ntohl(hdr->ih_load), &unc_len);
290 + if (i != LZMA_RESULT_OK) {
291 + printf ("LZMA ERROR %d - must RESET board to recover\n", i);
292 + SHOW_BOOT_PROGRESS (-6);
294 + do_reset (cmdtp, flag, argc, argv);
297 +#endif /* CONFIG_LZMA */
301 @@ -1176,6 +1193,8 @@
303 #endif /* CFG_CMD_IMLS */
305 +#endif /* ! CFG_HEAD_CODE */
308 print_image_hdr (image_header_t *hdr)
310 @@ -1270,12 +1289,15 @@
311 case IH_COMP_NONE: comp = "uncompressed"; break;
312 case IH_COMP_GZIP: comp = "gzip compressed"; break;
313 case IH_COMP_BZIP2: comp = "bzip2 compressed"; break;
314 + case IH_COMP_LZMA: comp = "lzma compressed"; break;
315 default: comp = "unknown compression"; break;
318 printf ("%s %s %s (%s)", arch, os, type, comp);
321 +#ifndef CFG_HEAD_CODE
323 #define ZALLOC_ALIGNMENT 16
325 static void *zalloc(void *x, unsigned items, unsigned size)
326 @@ -1427,3 +1449,5 @@
329 #endif /* CONFIG_LYNXKDI */
331 +#endif /* ! CFG_HEAD_CODE */
332 --- a/common/cmd_flash.c
333 +++ b/common/cmd_flash.c
338 -flash_fill_sect_ranges (ulong addr_first, ulong addr_last,
339 - int *s_first, int *s_last,
341 +flash_fill_sect_ranges(
342 + ulong *addr_first_sect_start,
344 + ulong *addr_last_sect_end,
348 + int *bPartialStart,
351 + unsigned int bPartialErase)
356 s_last [bank] = -1; /* last sector to erase */
359 - for (bank=0,info=&flash_info[0];
360 - (bank < CFG_MAX_FLASH_BANKS) && (addr_first <= addr_last);
362 + for (bank=0, info=&flash_info[0]; (bank < CFG_MAX_FLASH_BANKS) && (addr_first <= addr_last); ++bank, ++info) {
367 b_end = info->start[0] + info->size - 1; /* bank end addr */
368 s_end = info->sector_count - 1; /* last sector */
371 for (sect=0; sect < info->sector_count; ++sect) {
372 ulong end; /* last address in current sect */
374 @@ -238,11 +243,21 @@
376 if (addr_first == info->start[sect]) {
377 s_first[bank] = sect;
378 + } else if (addr_first > info->start[sect] && addr_first <= end && bPartialErase) {
379 + *addr_first_sect_start = info->start[sect];
380 + s_first[bank] = sect;
381 + *bPartialStart = 1;
384 if (addr_last == end) {
386 + } else if (addr_last >= info->start[sect] && addr_last < end && bPartialErase) {
387 + *addr_last_sect_end = end;
388 + s_last[bank] = sect;
393 if (s_first[bank] >= 0) {
394 if (s_last[bank] < 0) {
395 if (addr_last > b_end) {
397 struct part_info *part;
398 u8 dev_type, dev_num, pnum;
400 + unsigned int bPartialErase = 0;
411 printf ("Usage:\n%s\n", cmdtp->usage);
414 @@ -397,11 +414,117 @@
418 - rcode = flash_sect_erase(addr_first, addr_last);
419 + printf ("Erase Flash from 0x%08lx to 0x%08lx\n", addr_first, addr_last);
421 + bPartialErase = simple_strtoul(argv[3], NULL, 10);
424 + rcode = flash_sect_erase(addr_first, addr_last, bPartialErase);
428 -int flash_sect_erase (ulong addr_first, ulong addr_last)
429 +int flerase_Partial(
430 + ulong addr_first_sect_start,
432 + ulong addr_last_sect_end,
434 + flash_info_t *info,
438 + int bLastPartial) {
439 + unsigned int firstMemLen = 0;
440 + unsigned int lastMemLen = 0;
441 + unsigned int sectMemLen = 0;
442 + uchar *pSavedFirstMem = NULL;
443 + uchar *pSavedLastMem = NULL;
444 + uchar *pSavedSectMem = NULL;
445 + int bSectPartial = 0;
448 + debug("%s ... 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%p, %d, %d, %d, %d\n", __FUNCTION__, addr_first_sect_start, addr_first, addr_last_sect_end, addr_last, info, first_sect, last_sect, bFirstPartial, bLastPartial);
450 + if (bFirstPartial && bLastPartial && (first_sect == last_sect))
452 + ulong b_end = info->start[0] + info->size - 1;
453 + ulong end = (first_sect == (info->sector_count - 1)) ? b_end : info->start[first_sect + 1] - 1;
454 + sectMemLen = end - info->start[first_sect] + 1;
455 + pSavedSectMem = (uchar *)calloc(sectMemLen, sizeof(char));
456 + if (pSavedSectMem == NULL)
458 + debug("calloc %u FAILED\n", sectMemLen);
462 + memset(pSavedSectMem, 0xff, sectMemLen);
464 + memcpy(pSavedSectMem, (uchar *)addr_first_sect_start, addr_first - addr_first_sect_start);
465 + memcpy(pSavedSectMem + (addr_last - info->start[first_sect]) + 1, addr_last + 1, end - addr_last);
469 + if (bFirstPartial){
470 + firstMemLen = addr_first - addr_first_sect_start + 1;
471 + pSavedFirstMem = (uchar *)calloc(firstMemLen,sizeof(char));
472 + memcpy(pSavedFirstMem,(uchar *)addr_first_sect_start,firstMemLen - 1);
475 + lastMemLen = addr_last_sect_end - addr_last + 1;
476 + pSavedLastMem = (uchar *)calloc(lastMemLen,sizeof(char));
477 + memcpy(pSavedLastMem,(uchar *)addr_last + 1,lastMemLen - 1);
481 + if (bFirstPartial){
482 + if(flash_erase (info, first_sect, first_sect)) {
483 + printf("%s ... Couldn't erase sector %d\n", __FUNCTION__, first_sect);
487 + debug("%s ... erase sector %d done!\n", __FUNCTION__, first_sect);
490 + if (bLastPartial && first_sect != last_sect){
491 + if(flash_erase (info, last_sect, last_sect)) {
492 + printf("%s ... Couldn't erase sector %d\n", __FUNCTION__, last_sect);
496 + debug("%s ... erase sector %d done!\n", __FUNCTION__, last_sect);
499 + if (bFirstPartial && bLastPartial && (first_sect == last_sect))
501 + flash_write(pSavedSectMem, (uchar *)addr_first_sect_start, sectMemLen);
502 + debug("flash_write from 0x%08x with len %u\n", addr_first_sect_start, sectMemLen);
506 + if (bFirstPartial){
507 + if(flash_write(pSavedFirstMem,(uchar *)addr_first_sect_start,firstMemLen - 1)) {
508 + printf("%s ... Couldn't write at 0x%08lx length %d\n", __FUNCTION__, addr_first_sect_start,firstMemLen - 1);
514 + if(flash_write(pSavedLastMem,(uchar *)addr_last + 1,lastMemLen - 1)) {
515 + printf("%s ... Couldn't write at 0x%08lx length %d\n", __FUNCTION__, addr_last, lastMemLen - 1);
522 + free(pSavedFirstMem);
524 + free(pSavedLastMem);
526 + free(pSavedSectMem);
530 +int flash_sect_erase (ulong addr_first, ulong addr_last, unsigned int bPartialErase)
534 @@ -413,27 +536,66 @@
539 - rcode = flash_fill_sect_ranges (addr_first, addr_last,
540 - s_first, s_last, &planned );
541 + int bPartialStart = 0; // Start sector has to be erased partially
542 + int bPartialEnd = 0; // End sector has to be erased partially
543 + ulong addr_first_sect_start = 0;// Sector start address of location addr_start
544 + ulong addr_last_sect_end = 0; // Sector end address of location addr_last
546 + rcode = flash_fill_sect_ranges (
547 + &addr_first_sect_start,
549 + &addr_last_sect_end,
558 if (planned && (rcode == 0)) {
559 - for (bank=0,info=&flash_info[0];
560 - (bank < CFG_MAX_FLASH_BANKS) && (rcode == 0);
562 + for (bank=0, info=&flash_info[0]; (bank < CFG_MAX_FLASH_BANKS) && (rcode == 0); ++bank, ++info) {
563 + ulong b_end = info->start[0] + info->size - 1; /* bank end addr */
564 if (s_first[bank]>=0) {
565 - erased += s_last[bank] - s_first[bank] + 1;
566 - debug ("Erase Flash from 0x%08lx to 0x%08lx "
568 - info->start[s_first[bank]],
569 - (s_last[bank] == info->sector_count) ?
570 - info->start[0] + info->size - 1:
571 - info->start[s_last[bank]+1] - 1,
573 - rcode = flash_erase (info, s_first[bank], s_last[bank]);
574 + if(bPartialErase) {
575 + rcode = flerase_Partial(
576 + addr_first_sect_start,
578 + addr_last_sect_end,
587 + //Erase full sectores
589 + s_first[bank] += 1;
592 + if (s_last[bank] >= s_first[bank]) {
593 + erased += s_last[bank] - s_first[bank] + 1;
594 + debug ("Erase Flash from 0x%08lx to 0x%08lx in Bank # %ld ",
595 + info->start[s_first[bank]],
596 + (s_last[bank] == info->sector_count) ?
597 + info->start[0] + info->size - 1:
598 + info->start[s_last[bank]+1] - 1,
600 + rcode = flash_erase (info, s_first[bank], s_last[bank]);
604 - printf ("Erased %d sectors\n", erased);
606 + if (erased && !bPartialErase) {
607 + printf ("Erased %d sectors\n", erased);
608 + } else if (bPartialErase){
609 + printf ("Partial erased from 0x%08lx to 0x%08lx\n", addr_first, addr_last);
611 + printf ("Error: start and/or end address not on sector boundary\n");
614 } else if (rcode == 0) {
615 puts ("Error: start and/or end address"
616 " not on sector boundary\n");
622 - rcode = flash_fill_sect_ranges( addr_first, addr_last, s_first, s_last, &planned );
623 + int bPartialStart = 0; // Start sector has to be erased partially
624 + int bPartialEnd = 0; // End sector has to be erased partially
625 + ulong addr_first_sect_start = 0;// Sector start address of location addr_start
626 + ulong addr_last_sect_end = 0; // Sector end address of location addr_last
628 + rcode = flash_fill_sect_ranges (
629 + &addr_first_sect_start,
631 + &addr_last_sect_end,
646 - erase, 3, 1, do_flerase,
647 + erase, 4, 1, do_flerase,
648 "erase - erase FLASH memory\n",
650 " - erase FLASH from addr 'start' to addr 'end'\n"
651 --- a/common/cmd_nvedit.c
652 +++ b/common/cmd_nvedit.c
654 extern char * env_name_spec;
656 printf ("Saving Environment to %s...\n", env_name_spec);
659 + if(saveenv() == 0) {
660 +#ifdef UBOOT_ENV_COPY
664 +#endif //UBOOT_ENV_COPY
669 return (saveenv() ? 1 : 0);
674 --- a/common/console.c
675 +++ b/common/console.c
679 /** U-Boot INIT FUNCTIONS *************************************************/
681 +#ifndef CFG_HEAD_CODE
682 int console_assign (int file, char *devname)
690 +#endif //CFG_HEAD_CODE
691 /* Called before relocation - use serial functions */
692 int console_init_f (void)
696 #endif /* CFG_CONSOLE_IS_IN_ENV || CONFIG_SPLASH_SCREEN */
698 +#ifndef CFG_HEAD_CODE
699 #ifdef CFG_CONSOLE_IS_IN_ENV
700 /* Called after the relocation - use desired console functions */
701 int console_init_r (void)
705 #endif /* CFG_CONSOLE_IS_IN_ENV */
706 +#endif //CFG_HEAD_CODE
707 --- a/common/devices.c
708 +++ b/common/devices.c
711 device_t *stdio_devices[] = { NULL, NULL, NULL };
712 char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
713 +#ifndef CFG_HEAD_CODE
715 #if defined(CONFIG_SPLASH_SCREEN) && !defined(CFG_DEVICE_NULLDEV)
716 #define CFG_DEVICE_NULLDEV 1
721 +#endif //CFG_HEAD_CODE
723 --- a/common/env_common.c
724 +++ b/common/env_common.c
726 * We must allocate a buffer for the environment
728 env_ptr = (env_t *)malloc (CFG_ENV_SIZE);
729 - DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
731 + DEBUGF ("malloc env_ptr error!!\n");
732 + DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__, __LINE__, env_ptr);
738 env_get_char = env_get_char_memory;
741 + DEBUGF ("%s[%d] gd->env_valid=%d\n", __FUNCTION__, __LINE__, gd->env_valid);
742 + DEBUGF ("%s[%d] CFG_ENV_SIZE=%d\n", __FUNCTION__, __LINE__, CFG_ENV_SIZE);
744 if (gd->env_valid == 0) {
745 #if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE) /* Environment not changable */
746 puts ("Using default environment\n\n");
747 @@ -242,18 +248,17 @@
750 memset (env_ptr, 0, sizeof(env_t));
751 - memcpy (env_ptr->data,
752 - default_environment,
753 - sizeof(default_environment));
754 + memcpy (env_ptr->data, default_environment, sizeof(default_environment));
756 #ifdef CFG_REDUNDAND_ENVIRONMENT
757 env_ptr->flags = 0xFF;
764 env_relocate_spec ();
767 gd->env_addr = (ulong)&(env_ptr->data);
769 #ifdef CONFIG_AMIGAONEG3SE
770 --- a/common/env_flash.c
771 +++ b/common/env_flash.c
775 #else /* ! ENV_IS_EMBEDDED */
777 env_t *env_ptr = (env_t *)CFG_ENV_ADDR;
779 static env_t *flash_addr = (env_t *)CFG_ENV_ADDR;
781 debug (" %08lX ... %08lX ...",
782 (ulong)&(flash_addr_new->data),
783 sizeof(env_ptr->data)+(ulong)&(flash_addr_new->data));
785 if ((rc = flash_write((char *)env_ptr->data,
786 (ulong)&(flash_addr_new->data),
787 sizeof(env_ptr->data))) ||
789 #endif /* CMD_SAVEENV */
791 #else /* ! CFG_ENV_ADDR_REDUND */
795 #ifdef CONFIG_OMAP2420H4
800 +#ifdef UBOOT_ENV_COPY
801 +int saveenv_copy(void) {
802 + uchar *env_buffer = (char *)env_ptr;
806 + ulong start_addr,end_addr,rootfs_end_addr;
809 + kernel_addr = getenv("f_kernel_addr");
810 + end_addr = simple_strtoul(kernel_addr,NULL,16) - 1;
811 + start_addr = end_addr - CFG_ENV_SIZE - sizeof(UBOOTCONFIG_COPY_HEADER) + 1;
813 + rootfs_addr = getenv("f_rootfs_addr");
814 + rootfs_size = getenv("f_rootfs_size");
815 + rootfs_end_addr = simple_strtoul(rootfs_addr,NULL,16) + simple_strtoul(rootfs_size,NULL,16);
817 + if(rootfs_end_addr >= start_addr)
819 + printf("Can not copy the environment at 0x%08lx as no space left.\nf_kernel_addr = 0x%08lx while rootfs_end_addr = 0x%08lx\n",start_addr,end_addr,rootfs_end_addr);
823 + debug ("Protect off %08lX ... %08lX\n", (ulong)rootfs_end_addr, end_addr);
824 + if (flash_sect_protect (0, rootfs_end_addr, end_addr))
827 + //delete the old environment copy, if found
828 + flash_start = rootfs_end_addr;
829 + while(flash_start + sizeof(UBOOTCONFIG_COPY_HEADER) + ENV_SIZE < end_addr)
831 + if(strncmp((char *)flash_start,UBOOTCONFIG_COPY_HEADER,sizeof(UBOOTCONFIG_COPY_HEADER)) == 0)
833 + flash_sect_erase(flash_start,flash_start + sizeof(UBOOTCONFIG_COPY_HEADER),1);
837 + flash_sect_erase(start_addr,end_addr,1);
838 + flash_write(UBOOTCONFIG_COPY_HEADER,start_addr,sizeof(UBOOTCONFIG_COPY_HEADER));
839 + flash_write(env_buffer,start_addr + sizeof(UBOOTCONFIG_COPY_HEADER), CFG_ENV_SIZE);
840 + flash_sect_protect (1, rootfs_end_addr, end_addr);
841 + printf("saved copy of the env at 0x%08lx\n",start_addr);
844 +#endif //UBOOT_ENV_COPY
852 puts ("Erasing Flash...");
853 - if (flash_sect_erase (flash_sect_addr, end_addr))
854 + if (flash_sect_erase (flash_sect_addr, end_addr, 1))
857 puts ("Writing to Flash... ");
861 OBJDUMP = $(CROSS_COMPILE)objdump
862 RANLIB = $(CROSS_COMPILE)RANLIB
864 +ifneq (,$(findstring s,$(MAKEFLAGS)))
869 RELFLAGS= $(PLATFORM_RELFLAGS)
870 DBGFLAGS= -g # -DDEBUG
871 OPTFLAGS= -Os #-fomit-frame-pointer
872 @@ -139,12 +143,15 @@
873 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
877 +LDSCRIPT_BOOTSTRAP := $(TOPDIR)/board/$(BOARDDIR)/u-boot-bootstrap.lds
879 OBJCFLAGS += --gap-fill=0xff
881 gccincdir := $(shell $(CC) -print-file-name=include)
883 CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
884 - -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \
885 + -D__KERNEL__ -DUBOOT_RAM_TEXT_BASE=$(UBOOT_RAM_TEXT_BASE) \
887 ifneq ($(OBJTREE),$(SRCTREE))
888 CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
891 AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
893 -LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
894 +LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(UBOOT_RAM_TEXT_BASE) $(PLATFORM_LDFLAGS)
895 +LDFLAGS_BOOTSTRAP += -Bstatic -T $(LDSCRIPT_BOOTSTRAP) -Ttext $(BOOTSTRAP_TEXT_BASE) $(PLATFORM_LDFLAGS)
897 # Location of a usable BFD library, where we define "usable" as
898 # "built for ${HOST}, supports ${TARGET}". Sensible values are
899 @@ -214,12 +222,19 @@
900 export CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
901 AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
903 -export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
904 +export UBOOT_RAM_TEXT_BASE BOOTSTRAP_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
906 #########################################################################
910 +%_bootstrap.s: %_bootstrap.S
911 + $(CPP) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -o $@ $<
912 +%_bootstrap.o: %_bootstrap.S
913 + $(CC) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
914 +%_bootstrap.o: %_bootstrap.c
915 + $(CC) $(CFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
918 $(CPP) $(AFLAGS) -o $@ $<
920 @@ -229,12 +244,20 @@
924 +$(obj)%_bootstrap.s: %_bootstrap.S
925 + $(CPP) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -o $@ $<
926 +$(obj)%_bootstrap.o: %_bootstrap.S
927 + $(CC) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
928 +$(obj)%_bootstrap.o: %_bootstrap.c
929 + $(CC) $(CFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
932 $(CPP) $(AFLAGS) -o $@ $<
934 $(CC) $(AFLAGS) -c -o $@ $<
936 $(CC) $(CFLAGS) -c -o $@ $<
940 #########################################################################
941 --- a/drivers/Makefile
942 +++ b/drivers/Makefile
944 videomodes.o w83c553f.o \
946 pxa_pcmcia.o mpc8xx_pcmcia.o tqm8xx_pcmcia.o \
948 + rpx_pcmcia.o ifx_sw.o
950 SRCS := $(COBJS:.o=.c)
951 OBJS := $(addprefix $(obj),$(COBJS))
952 --- a/include/asm-mips/mipsregs.h
953 +++ b/include/asm-mips/mipsregs.h
955 #define CP0_CAUSE $13
958 +#define CP0_EBASE $15,1
959 #define CP0_CONFIG $16
960 #define CP0_LLADDR $17
961 #define CP0_WATCHLO $18
962 @@ -330,11 +331,32 @@
963 # define KSU_USER 0x00000010
964 # define KSU_SUPERVISOR 0x00000008
965 # define KSU_KERNEL 0x00000000
966 +#ifdef CONFIG_DANUBE /* MIPS 24KE */
967 +/* bits 5 & 6 & 7: reserved */
968 +/* bits 8~15: IM0~7 */
969 +/* bits 16: reserved */
970 +#define ST0_CEE 0x00020000
971 +/* bits 18: always 0 */
972 +#define ST0_NMI 0x00080000
973 +#define ST0_SR 0x00100000
974 +#define ST0_TS 0x00200000
975 +#define ST0_BEV 0x00400000
976 +/* bits 23: reserved */
977 +#define ST0_MX 0x01000000
978 +#define ST0_RE 0x02000000
979 +#define ST0_FR 0x04000000
980 +#define ST0_RP 0x08000000
981 +#define ST0_CU0 0x10000000
982 +#define ST0_CU1 0x20000000
983 +#define ST0_CU2 0x40000000
984 +#define ST0_CU3 0x80000000
986 #define ST0_UX 0x00000020
987 #define ST0_SX 0x00000040
988 #define ST0_KX 0x00000080
989 #define ST0_DE 0x00010000
990 #define ST0_CE 0x00020000
994 * Bitfields in the R[23]000 cp0 status register.
996 #define CAUSEF_BD (1 << 31)
999 + * Bits in the coprocessor 0 EBase register
1001 +#define EBASEB_CPUNUM 0
1002 +#define EBASEF_CPUNUM (0x3ff << EBASEB_CPUNUM)
1003 +#define EBASEB_EXPBASE 12
1004 +#define EBASEF_EXPBASE (0x3ffff << EBASEB_EXPBASE)
1007 * Bits in the coprozessor 0 config register.
1009 #define CONF_CM_CACHABLE_NO_WA 0
1010 @@ -544,4 +574,10 @@
1011 #define CEB_KERNEL 2 /* Count events in kernel mode EXL = ERL = 0 */
1012 #define CEB_EXL 1 /* Count events with EXL = 1, ERL = 0 */
1015 + * Bits in ErrCtl register
1017 +#define ECCB_WST 29
1018 +#define ECCF_WST (0x1 << ECCB_WST)
1020 #endif /* _ASM_MIPSREGS_H */
1021 --- a/include/cmd_confdefs.h
1022 +++ b/include/cmd_confdefs.h
1024 #define CFG_CMD_EXT2 0x1000000000000000ULL /* EXT2 Support */
1025 #define CFG_CMD_SNTP 0x2000000000000000ULL /* SNTP support */
1026 #define CFG_CMD_DISPLAY 0x4000000000000000ULL /* Display support */
1027 +#define CFG_CMD_DHRYSTONE 0x8000000000000000ULL /* Dhrystone benchmark support */
1029 #define CFG_CMD_ALL 0xFFFFFFFFFFFFFFFFULL /* ALL commands */
1033 CFG_CMD_UNIVERSE | \
1035 + CFG_CMD_DHRYSTONE | \
1038 /* Default configuration
1040 +++ b/include/config.h
1042 +/* Automatically generated - do not edit */
1043 +#include <configs/danube.h>
1045 +++ b/include/config.mk
1052 --- a/include/flash.h
1053 +++ b/include/flash.h
1055 extern unsigned long flash_init (void);
1056 extern void flash_print_info (flash_info_t *);
1057 extern int flash_erase (flash_info_t *, int, int);
1058 -extern int flash_sect_erase (ulong addr_first, ulong addr_last);
1059 +extern int flash_sect_erase (ulong addr_first, ulong addr_last, unsigned int bPartialErase);
1060 extern int flash_sect_protect (int flag, ulong addr_first, ulong addr_last);
1062 /* common/flash.c */
1063 @@ -299,6 +299,10 @@
1064 #define TOSH_ID_FVT160 0xC2 /* TC58FVT160 ID (16 M, top ) */
1065 #define TOSH_ID_FVB160 0x43 /* TC58FVT160 ID (16 M, bottom ) */
1067 +#define MX_ID_29LV320AB 0x22A822A8 /* MXIC MX29LV320AB ID (32 M, bottom ) joelin */
1068 +#define MX_ID_29LV160BB 0x22492249 /* MXIC MX29LV160BB ID (16 M, bottom ) joelin */
1069 +#define MX_ID_29LV640BB 0x22cb22cb /* MXIC MX29LV640BB ID (64 M, bottom ) joelin */
1071 /*-----------------------------------------------------------------------
1072 * Internal FLASH identification codes
1074 @@ -422,6 +426,10 @@
1075 #define FLASH_S29GL064M 0x00F0 /* Spansion S29GL064M-R6 */
1076 #define FLASH_S29GL128N 0x00F1 /* Spansion S29GL128N */
1078 +#define FLASH_29LV320AB 0x00B0 /* MXIC MX29LV320AB( 32M = 4M x 16 ) joelin 10/07/2004*/
1079 +#define FLASH_29LV160BB 0x00B1 /* MXIC MX29LV160BB( 16M = 2M x 16 ) joelin 11/22/2004*/
1080 +#define FLASH_29LV640BB 0x00B2 /* MXIC MX29LV640BB( 64M = 8M x 16 ) liupeng*/
1082 #define FLASH_UNKNOWN 0xFFFF /* unknown flash type */
1085 --- a/include/image.h
1086 +++ b/include/image.h
1088 #define IH_COMP_NONE 0 /* No Compression Used */
1089 #define IH_COMP_GZIP 1 /* gzip Compression Used */
1090 #define IH_COMP_BZIP2 2 /* bzip2 Compression Used */
1091 +#define IH_COMP_LZMA 3 /* lzma Compression Used */
1093 #define IH_MAGIC 0x27051956 /* Image Magic Number */
1094 #define IH_NMLEN 32 /* Image Name Length */
1096 +++ b/include/syscall.h
1098 +#ifndef __MON_SYS_CALL_H__
1099 +#define __MON_SYS_CALL_H__
1101 +#ifndef __ASSEMBLY__
1103 +#include <common.h>
1105 +/* These are declarations of system calls available in C code */
1106 +int mon_getc(void);
1107 +int mon_tstc(void);
1108 +void mon_putc(const char);
1109 +void mon_puts(const char*);
1110 +void mon_printf(const char* fmt, ...);
1111 +void mon_install_hdlr(int, interrupt_handler_t*, void*);
1112 +void mon_free_hdlr(int);
1113 +void *mon_malloc(size_t);
1114 +void mon_free(void*);
1115 +void mon_udelay(unsigned long);
1116 +unsigned long mon_get_timer(unsigned long);
1118 +#endif /* ifndef __ASSEMBLY__ */
1120 +#define NR_SYSCALLS 11 /* number of syscalls */
1124 + * Make sure these functions are in the same order as they
1125 + * appear in the "examples/syscall.S" file !!!
1127 +#define SYSCALL_GETC 0
1128 +#define SYSCALL_TSTC 1
1129 +#define SYSCALL_PUTC 2
1130 +#define SYSCALL_PUTS 3
1131 +#define SYSCALL_PRINTF 4
1132 +#define SYSCALL_INSTALL_HDLR 5
1133 +#define SYSCALL_FREE_HDLR 6
1134 +#define SYSCALL_MALLOC 7
1135 +#define SYSCALL_FREE 8
1136 +#define SYSCALL_UDELAY 9
1137 +#define SYSCALL_GET_TIMER 10
1145 + 0xA0B00000 "u-boot.bin" /* Download u-boot image */
1150 +}; /* Start u-boot image */
1151 --- a/lib_generic/Makefile
1152 +++ b/lib_generic/Makefile
1154 COBJS = bzlib.o bzlib_crctable.o bzlib_decompress.o \
1155 bzlib_randtable.o bzlib_huffman.o \
1156 crc32.o ctype.o display_options.o ldiv.o \
1157 - string.o vsprintf.o zlib.o
1158 + string.o vsprintf.o zlib.o LzmaDecode.o LzmaWrapper.o
1160 SRCS := $(COBJS:.o=.c)
1161 OBJS := $(addprefix $(obj),$(COBJS))
1162 --- a/lib_mips/board.c
1163 +++ b/lib_mips/board.c
1166 #include <environment.h>
1168 +#ifdef CFG_BOOTSTRAP_CODE
1169 +//#include <asm/danube.h>
1170 +#undef CONFIG_MICROBZIP2
1172 +#ifdef CONFIG_BZIP2
1176 +#ifdef CONFIG_MICROBZIP2
1177 +#include <micro_bzlib.h>
1181 +#include <LzmaWrapper.h>
1183 +#endif //CFG_BOOTSTRAP_CODE
1185 DECLARE_GLOBAL_DATA_PTR;
1187 -#if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
1188 +#if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < BOOTSTRAP_CFG_MONITOR_BASE) || \
1189 + (CFG_ENV_ADDR >= (BOOTSTRAP_CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
1190 + defined(CFG_ENV_IS_IN_NVRAM) && defined(CFG_BOOTSTRAP_CODE)
1191 +#define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE)
1192 +#elif ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
1193 (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
1194 defined(CFG_ENV_IS_IN_NVRAM)
1195 #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE)
1197 #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
1202 extern int timer_init(void);
1204 extern int incaip_set_cpuclk(void);
1206 +#ifdef CFG_BOOTSTRAP_CODE
1207 +extern ulong uboot_end_data_bootstrap;
1208 +extern ulong uboot_end_bootstrap;
1209 +#else //CFG_BOOTSTRAP_CODE
1210 extern ulong uboot_end_data;
1211 extern ulong uboot_end;
1212 +#endif //CFG_BOOTSTRAP_CODE
1214 ulong monitor_flash_len;
1216 -const char version_string[] =
1217 - U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
1218 +const char version_string[] = U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
1220 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1221 static char *failed = "*** failed ***\n";
1225 * Begin and End of memory area for malloc(), and current "brk"
1227 static ulong mem_malloc_end;
1228 static ulong mem_malloc_brk;
1232 * The Malloc area is immediately below the monitor copy in DRAM
1234 -static void mem_malloc_init (void)
1236 +#ifdef CFG_BOOTSTRAP_CODE
1237 +static void mem_malloc_init (ulong dest_addr) {
1238 +#else //CFG_BOOTSTRAP_CODE
1239 +static void mem_malloc_init (void) {
1240 ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
1242 +#endif //CFG_BOOTSTRAP_CODE
1243 mem_malloc_end = dest_addr;
1244 mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
1245 mem_malloc_brk = mem_malloc_start;
1247 mem_malloc_end - mem_malloc_start);
1250 +#ifdef CFG_BOOTSTRAP_CODE
1251 +void *malloc(unsigned int size) {
1252 + if(size < (mem_malloc_end - mem_malloc_start)) {
1253 + mem_malloc_start += size;
1254 + debug ("malloc : size required = 0x%08lx and pointer = 0x%08lx\n",size,mem_malloc_start - size);
1255 + return (void *)(mem_malloc_start - size);
1260 +void *realloc(void *src,unsigned int size) {
1264 +void free(void *src) {
1267 +#endif //CFG_BOOTSTRAP_CODE
1269 void *sbrk (ptrdiff_t increment)
1271 ulong old = mem_malloc_brk;
1272 @@ -99,42 +143,58 @@
1274 int board_type = 0; /* use dummy arg */
1278 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1279 +#ifdef CONFIG_USE_DDR_RAM
1280 + puts ("DDR-DRAM: ");
1284 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1285 if ((gd->ram_size = initdram (board_type)) > 0) {
1286 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1287 print_size (gd->ram_size, "\n");
1288 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1291 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1293 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1297 +#if !defined(CFG_BOOTSTRAP_CODE) || defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF)
1298 static int display_banner(void)
1301 printf ("\n\n%s\n\n", version_string);
1306 +#ifndef CFG_BOOTSTRAP_CODE
1307 static void display_flash_config(ulong size)
1310 print_size (size, "\n");
1312 +#endif //CFG_BOOTSTRAP_CODE
1315 +#if !defined(CFG_BOOTSTRAP_CODE) || defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF)
1316 static int init_baudrate (void)
1318 +#ifndef CFG_BOOTSTRAP_CODE
1319 char tmp[64]; /* long enough for environment variables */
1320 int i = getenv_r ("baudrate", tmp, sizeof (tmp));
1322 gd->baudrate = (i > 0)
1323 ? (int) simple_strtoul (tmp, NULL, 10)
1326 +#else //CFG_BOOTSTRAP_CODE
1327 + gd->baudrate = CONFIG_BAUDRATE;
1328 +#endif //CFG_BOOTSTRAP_CODE
1335 * Breath some life into the board...
1336 @@ -159,27 +219,49 @@
1337 typedef int (init_fnc_t) (void);
1339 init_fnc_t *init_sequence[] = {
1340 +#ifdef CFG_BOOTSTRAP_CODE
1343 + //env_init, /* initialize environment */
1344 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1345 + init_baudrate, /* initialze baudrate settings */
1346 + serial_init, /* serial communications setup */
1348 + display_banner, /* say that we are here */
1350 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1353 +#else /********** CFG_BOOTSTRAP_CODE **********/
1355 - env_init, /* initialize environment */
1356 -#ifdef CONFIG_INCA_IP
1357 - incaip_set_cpuclk, /* set cpu clock according to environment variable */
1359 init_baudrate, /* initialze baudrate settings */
1360 serial_init, /* serial communications setup */
1362 display_banner, /* say that we are here */
1365 + env_init, /* initialize environment */
1367 +#endif //CFG_BOOTSTRAP_CODE
1370 +#ifdef CFG_BOOTSTRAP_CODE
1371 +extern void bootstrap_relocate_code(ulong addr_sp, gd_t *id, ulong addr);
1373 +void bootstrap_board_init_f(ulong bootflag)
1375 void board_init_f(ulong bootflag)
1380 init_fnc_t **init_fnc_ptr;
1381 - ulong addr, addr_sp, len = (ulong)&uboot_end - CFG_MONITOR_BASE;
1382 +#ifdef CFG_BOOTSTRAP_CODE
1383 + ulong addr, addr_sp, len = (ulong)&uboot_end_bootstrap - BOOTSTRAP_CFG_MONITOR_BASE;
1384 + ulong lzmaImageaddr = 0;
1385 +#else //CFG_BOOTSTRAP_CODE
1386 + ulong addr, addr_sp, len = CFG_MONITOR_LEN;
1387 +#endif //CFG_BOOTSTRAP_CODE
1389 #ifdef CONFIG_PURPLE
1390 void copy_code (ulong);
1391 @@ -219,13 +301,12 @@
1393 addr &= ~(16 * 1024 - 1);
1395 - debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
1396 + debug ("Reserving %d Bytes for U-Boot at: %08lx\n", len, addr);
1398 /* Reserve memory for malloc() arena.
1400 addr_sp = addr - TOTAL_MALLOC_LEN;
1401 - debug ("Reserving %dk for malloc() at: %08lx\n",
1402 - TOTAL_MALLOC_LEN >> 10, addr_sp);
1403 + debug ("Reserving %d Bytes for malloc() at: %08lx\n", TOTAL_MALLOC_LEN, addr_sp);
1406 * (permanently) allocate a Board Info struct
1407 @@ -234,20 +315,17 @@
1408 addr_sp -= sizeof(bd_t);
1409 bd = (bd_t *)addr_sp;
1411 - debug ("Reserving %d Bytes for Board Info at: %08lx\n",
1412 - sizeof(bd_t), addr_sp);
1413 + debug ("Reserving %d Bytes for Board Info at: %08lx\n", sizeof(bd_t), addr_sp);
1415 addr_sp -= sizeof(gd_t);
1416 id = (gd_t *)addr_sp;
1417 - debug ("Reserving %d Bytes for Global Data at: %08lx\n",
1418 - sizeof (gd_t), addr_sp);
1419 + debug ("Reserving %d Bytes for Global Data at: %08lx\n", sizeof (gd_t), addr_sp);
1421 /* Reserve memory for boot params.
1423 addr_sp -= CFG_BOOTPARAMS_LEN;
1424 bd->bi_boot_params = addr_sp;
1425 - debug ("Reserving %dk for boot params() at: %08lx\n",
1426 - CFG_BOOTPARAMS_LEN >> 10, addr_sp);
1427 + debug ("Reserving %dk for boot params() at: %08lx\n", CFG_BOOTPARAMS_LEN >> 10, addr_sp);
1430 * Finally, we set up a new (bigger) stack.
1431 @@ -279,7 +357,16 @@
1435 +#ifdef CFG_BOOTSTRAP_CODE
1436 + lzmaImageaddr = (ulong)&uboot_end_data_bootstrap;
1437 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1438 + puts("\n BOOTSTRAP: relocate_code start");
1439 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1440 + bootstrap_relocate_code (addr_sp, id, addr);
1441 +#else //CFG_BOOTSTRAP_CODE
1442 + puts("\n relocate_code start");
1443 relocate_code (addr_sp, id, addr);
1444 +#endif //CFG_BOOTSTRAP_CODE
1446 /* NOTREACHED - relocate_code() does not return */
1448 @@ -292,7 +379,110 @@
1450 ************************************************************************
1452 +#ifdef CFG_BOOTSTRAP_CODE
1453 +void bootstrap_board_init_r (gd_t *id, ulong dest_addr) {
1456 + ulong data, len, checksum;
1458 + image_header_t header;
1459 + image_header_t *hdr = &header;
1460 + unsigned int destLen;
1463 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1464 + puts("\n BOOTSTRAP: relocate_code finish.\n");
1465 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1467 + /* initialize malloc() area */
1468 + mem_malloc_init(dest_addr);
1470 + addr = (char *)(BOOTSTRAP_CFG_MONITOR_BASE + ((ulong)&uboot_end_data_bootstrap - dest_addr));
1471 + memmove (&header, (char *)addr, sizeof(image_header_t));
1473 + if (ntohl(hdr->ih_magic) != IH_MAGIC) {
1474 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1475 + printf ("Bad Magic Number at address 0x%08lx\n",addr);
1476 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1480 + data = (ulong)&header;
1481 + len = sizeof(image_header_t);
1483 + checksum = ntohl(hdr->ih_hcrc);
1485 + if (crc32 (0, (unsigned char *)data, len) != checksum) {
1486 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1487 + printf ("Bad Header Checksum\n");
1488 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1492 + data = addr + sizeof(image_header_t);
1493 + len = ntohl(hdr->ih_size);
1494 + len_ptr = (ulong *)data;
1496 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1497 + debug ("Disabling all the interrupts\n");
1498 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1499 + disable_interrupts();
1501 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1502 + debug (" Uncompressing UBoot Image ... \n" );
1503 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1505 + * If we've got less than 4 MB of malloc() space,
1506 + * use slower decompression algorithm which requires
1507 + * at most 2300 KB of memory.
1511 +#ifdef CONFIG_BZIP2
1512 + i = BZ2_bzBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
1513 + 0x400000, (char *)data, len,
1514 + CFG_MALLOC_LEN < (4096 * 1024), 0);
1516 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1517 + printf ("BUNZIP2 ERROR %d - must RESET board to recover\n", i);
1518 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1521 +#elif CONFIG_MICROBZIP2
1522 + i = micro_bzBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
1523 + &destLen, (char *)data, len,
1524 + CFG_MALLOC_LEN < (4096 * 1024), 0);
1525 + if (i != RETVAL_OK) {
1526 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1527 + printf ("MICRO_BUNZIP2 ERROR %d - must RESET board to recover\n", i);
1528 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1532 + i = lzma_inflate ((unsigned char *)data, len, (unsigned char*)ntohl(hdr->ih_load), &destLen);
1533 + if (i != LZMA_RESULT_OK) {
1534 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1535 + printf ("LZMA ERROR %d - must RESET board to recover\n", i);
1536 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1540 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1541 + printf ("NONE Compressing u-boot body!!\n");
1542 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1543 + memmove ((void *)ntohl(hdr->ih_load), (uchar *)data, len);
1546 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1547 + debug (" Uncompression completed successfully with destLen %d.\n ",destLen );
1548 + debug ("Head: Jumping to u-boot in the ram at 0x%08lx\n", CFG_MONITOR_BASE);
1549 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1551 + fn = ntohl(hdr->ih_load);
1555 +#else //CFG_BOOTSTRAP_CODE
1556 void board_init_r (gd_t *id, ulong dest_addr)
1563 + puts("\n relocate_code finish.\n");
1566 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
1568 @@ -321,12 +513,10 @@
1571 addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
1573 - printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
1574 - cmdtp->name, (ulong) (cmdtp->cmd), addr);
1577 - (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
1579 + debug ("Command \"%s\": 0x%08lx => 0x%08lx\n", cmdtp->name, (ulong) (cmdtp->cmd), addr);
1581 + cmdtp->cmd = (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
1583 addr = (ulong)(cmdtp->name) + gd->reloc_off;
1584 cmdtp->name = (char *)addr;
1585 @@ -363,7 +553,13 @@
1586 /* initialize malloc() area */
1589 +#if (CONFIG_COMMANDS & CFG_CMD_NAND)
1590 + nand_init(); /* go init the NAND */
1594 + spi_init_f(); /* go init the SPI flash */
1596 /* relocate environment function pointers etc. */
1599 @@ -424,9 +620,12 @@
1601 /* NOTREACHED - no way out of command loop except booting */
1603 +#endif //CFG_BOOTSTRAP_CODE
1607 +#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
1608 puts ("### ERROR ### Please RESET the board ###\n");
1609 +#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
1612 --- a/lib_mips/time.c
1613 +++ b/lib_mips/time.c
1618 +#ifndef CFG_BOOTSTRAP_CODE
1619 +void mdelay (unsigned long msec)
1622 + for(i=0;i<msec;i++)
1632 * This function is derived from PowerPC code (read timebase as long long).
1633 * On MIPS it just returns the timer value.
1637 #include <command.h>
1640 +#if defined(CONFIG_IFX_MIPS)
1641 +# include "ifx_eth.c"
1644 #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI)
1647 extern int skge_initialize(bd_t*);
1648 extern int tsec_initialize(bd_t*, int, char *);
1649 extern int npe_initialize(bd_t *);
1650 +#if defined(CONFIG_IFX_MIPS)
1651 + IFX_ETH_INITIALIZE_EXTERN
1654 static struct eth_device *eth_devices, *eth_current;
1657 #if defined(CONFIG_RTL8169)
1658 rtl8169_initialize(bis);
1661 +#if defined(CONFIG_IFX_MIPS)
1662 + IFX_ETH_INITIALIZE(bis)
1665 puts ("No ethernet found.\n");
1667 --- a/tools/mkimage.c
1668 +++ b/tools/mkimage.c
1671 #include <netinet/in.h> /* for host / network byte order conversions */
1673 +#include <sys/types.h>
1674 #include <sys/mman.h>
1675 #include <sys/stat.h>
1678 { IH_COMP_NONE, "none", "uncompressed", },
1679 { IH_COMP_BZIP2, "bzip2", "bzip2 compressed", },
1680 { IH_COMP_GZIP, "gzip", "gzip compressed", },
1681 + { IH_COMP_LZMA, "lzma", "lzma compressed", },
1688 /* We're a bit of paranoid */
1689 -#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
1690 +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
1691 (void) fdatasync (ifd);
1695 (void) munmap((void *)ptr, sbuf.st_size);
1697 /* We're a bit of paranoid */
1698 -#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
1699 +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
1700 (void) fdatasync (ifd);
1703 --- a/cpu/mips/cache.S
1704 +++ b/cpu/mips/cache.S
1706 #include <asm/mipsregs.h>
1707 #include <asm/addrspace.h>
1708 #include <asm/cacheops.h>
1710 +#if defined(CONFIG_IFX_MIPS)
1711 +# include "danube/ifx_cache.S"
1714 /* 16KB is the maximum size of instruction and data caches on
1719 mtc0 zero, CP0_TAGLO
1720 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_EXTRA_INVALID_TAG)
1721 + IFX_CACHE_EXTRA_INVALID_TAG
1725 * The caches are probably in an indeterminate state,
1728 icacheopn(a0,a1,a2,a3,121,(Index_Store_Tag_I,Fill))
1730 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_EXTRA_OPERATION)
1731 + IFX_CACHE_EXTRA_OPERATION
1733 /* To support Orion/R4600, we initialise the data cache in 3 passes.
1737 move a3, t5 # dcacheLineSize
1739 icacheop(a0,a1,a2,a3,Index_Store_Tag_D)
1743 .end mips_cache_reset
1744 --- a/cpu/mips/config.mk
1745 +++ b/cpu/mips/config.mk
1747 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1751 -$(CROSS_COMPILE)as --version|grep "GNU assembler"|awk '{print $$3}'|awk -F . '{print $$2}')
1752 -MIPSFLAGS=$(shell \
1753 -if [ "$v" -lt "14" ]; then \
1754 - echo "-mcpu=4kc"; \
1756 - echo "-march=4kc -mtune=4kc"; \
1759 +ifndef PLATFORM_CPU
1760 +PLATFORM_CPU = mips32
1763 +MIPSFLAGS +=$(call cc-option,-march=$(PLATFORM_CPU) -mtune=$(PLATFORM_CPU),-mcpu=$(PLATFORM_CPU))
1765 +ifeq ($(CROSS_COMPILE_UCLIBC),1)
1766 +ifneq (,$(findstring mipsel,$(CROSS_COMIPLE)))
1772 ifneq (,$(findstring 4KCle,$(CROSS_COMPILE)))
1779 MIPSFLAGS += $(ENDIANNESS) -mabicalls
1781 --- a/cpu/mips/cpu.c
1782 +++ b/cpu/mips/cpu.c
1786 #include <command.h>
1787 -#include <asm/inca-ip.h>
1788 +#if defined(CONFIG_INCA_IP)
1789 +# include <asm/inca-ip.h>
1790 +#elif defined(CONFIG_IFX_MIPS)
1791 +# include <asm/danube.h>
1792 +# include "danube/ifx_cpu.c"
1794 #include <asm/mipsregs.h>
1796 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1798 void (*f)(void) = (void *) 0xbfc00000;
1801 +#elif defined(CONFIG_IFX_MIPS)
1804 fprintf(stderr, "*** reset failed ***\n");
1806 --- a/cpu/mips/incaip_clock.c
1807 +++ b/cpu/mips/incaip_clock.c
1812 -#include <asm/inca-ip.h>
1814 +#ifdef CONFIG_INCA_IP
1815 +#include <asm/inca-ip.h>
1817 /*******************************************************************************
1824 +#endif /* CONFIG_INCA_IP */
1825 --- a/cpu/mips/start.S
1826 +++ b/cpu/mips/start.S
1828 #include <version.h>
1829 #include <asm/regdef.h>
1830 #include <asm/mipsregs.h>
1832 +#if defined(CONFIG_IFX_MIPS)
1833 +# include "danube/ifx_start.S"
1836 #define RVECENT(f,n) \
1843 +#ifdef CFG_BOOTSTRAP_CODE
1844 + .globl _start_bootstrap
1849 +#ifdef CFG_BOOTSTRAP_CODE
1854 RVECENT(reset,0) /* U-boot entry point */
1855 RVECENT(reset,1) /* software reboot */
1856 -#if defined(CONFIG_INCA_IP)
1857 +#if defined(CONFIG_INCA_IP) || defined(CONFIG_INCA_IP2)
1858 .word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
1859 .word 0x00000000 /* phase of the flash */
1860 +#elif defined(CONFIG_IFX_MIPS) && defined(IFX_EBU_BOOTCFG_DWORD)
1861 + IFX_EBU_BOOTCFG_DWORD
1862 #elif defined(CONFIG_PURPLE)
1863 .word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
1864 .word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
1866 * 128 * 8 == 1024 == 0x400
1867 * so this is address R_VEC+0x400 == 0xbfc00400
1869 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_MORE_RESERVED_VECTORS)
1870 + IFX_MORE_RESERVED_VECTORS
1872 #ifdef CONFIG_PURPLE
1875 @@ -205,8 +219,12 @@
1878 #endif /* CONFIG_PURPLE */
1879 +#endif /* CONFIG_IFX_MIPS */
1882 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_RESET_PRECHECK)
1883 + IFX_RESET_PRECHECK
1886 /* Clear watch registers.
1888 @@ -226,6 +244,10 @@
1889 /* CAUSE register */
1890 mtc0 zero, CP0_CAUSE
1892 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU_EXTRA_INIT)
1893 + IFX_CPU_EXTRA_INIT
1897 mtc0 zero, CP0_COUNT
1898 mtc0 zero, CP0_COMPARE
1899 @@ -252,12 +274,26 @@
1903 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_SKIP_LOWLEVEL_INIT)
1904 + IFX_SKIP_LOWLEVEL_INIT
1906 +#ifdef CFG_BOOTSTRAP_CODE
1907 /* Initialize any external memory.
1909 la t9, lowlevel_init
1913 +lowlevel_init_done:
1915 + beq s0, zero, init_cache_0
1918 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_CPU1_INIT)
1923 /* Initialize caches...
1925 la t9, mips_cache_reset
1926 @@ -266,7 +302,11 @@
1928 /* ... and enable them.
1930 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_OPER_MODE)
1931 + IFX_CACHE_OPER_MODE
1933 li t0, CONF_CM_CACHABLE_NONCOHERENT
1938 @@ -280,13 +320,38 @@
1939 li t0, CFG_SDRAM_BASE + CFG_INIT_SP_OFFSET
1942 +#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_BOOT_CLEAR)
1946 +#ifdef CFG_BOOTSTRAP_CODE
1947 + la t9, bootstrap_board_init_f
1954 +#ifdef CFG_BOOTSTRAP_CODE
1956 + * void jump_unconditional (addr)
1957 + * This function simply jumps to the location pointed by a0.
1958 + * a0 = target_location
1961 + .globl jump_unconditional
1962 + .ent jump_unconditional
1963 +jump_unconditional:
1967 + .end jump_unconditional
1972 * void relocate_code (addr_sp, gd, addr_moni)
1973 + * void bootstrap_relocate_code (addr_sp, gd, addr_moni)
1975 * This "function" does not return, instead it continues in RAM
1976 * after relocating the monitor code.
1977 @@ -295,12 +360,22 @@
1979 * a2 = destination address
1981 +#ifdef CFG_BOOTSTRAP_CODE
1982 + .globl bootstrap_relocate_code
1983 + .ent bootstrap_relocate_code
1984 +bootstrap_relocate_code:
1986 .globl relocate_code
1990 move sp, a0 /* Set new stack pointer */
1992 +#ifdef CFG_BOOTSTRAP_CODE
1993 + li t0, BOOTSTRAP_CFG_MONITOR_BASE
1995 li t0, CFG_MONITOR_BASE
1998 lw t2, -12(t3) /* t2 <-- uboot_end_data */
2000 @@ -311,7 +386,11 @@
2001 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
2004 +#ifdef CFG_BOOTSTRAP_CODE
2005 + sub gp, BOOTSTRAP_CFG_MONITOR_BASE
2007 sub gp, CFG_MONITOR_BASE
2009 add gp, a2 /* gp now adjusted */
2010 sub t6, gp, t6 /* t6 <-- relocation offset */
2012 @@ -337,12 +416,21 @@
2014 /* Jump to where we've relocated ourselves.
2016 +#ifdef CFG_BOOTSTRAP_CODE
2017 + addi t0, a2, in_ram - _start_bootstrap
2019 addi t0, a2, in_ram - _start
2024 +#ifdef CFG_BOOTSTRAP_CODE
2025 + .word uboot_end_data_bootstrap
2026 + .word uboot_end_bootstrap
2028 .word uboot_end_data
2031 .word num_got_entries
2034 @@ -374,12 +462,19 @@
2035 sw zero, 0(t1) /* delay slot */
2038 +#ifdef CFG_BOOTSTRAP_CODE
2039 + la t9, bootstrap_board_init_r
2044 move a1, a2 /* delay slot */
2046 +#ifdef CFG_BOOTSTRAP_CODE
2047 + .end bootstrap_relocate_code
2053 /* Exception handlers.
2055 @@ -388,3 +483,20 @@
2061 +#ifdef CFG_BOOTSTRAP_CODE
2064 +#endif /* CFG_BOOTSTRAP_CODE */
2068 + /* Additional handlers.
2070 +#if defined(CONFIG_IFX_MIPS)
2071 +#if defined(IFX_MIPS_HANDLER_1)
2072 +ifx_mips_handler_1:
2073 + IFX_MIPS_HANDLER_1