fix uboot-ifxmips compile on mac os x
[openwrt/svn-archive/archive.git] / package / uboot-ifxmips / patches / 100-ifx.patch
1 --- a/Makefile
2 +++ b/Makefile
3 @@ -24,7 +24,7 @@
4 VERSION = 1
5 PATCHLEVEL = 1
6 SUBLEVEL = 5
7 -EXTRAVERSION =
8 +EXTRAVERSION = -IFX-LXDB
9 U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
10 VERSION_FILE = $(obj)include/version_autogenerated.h
11
12 @@ -44,6 +44,25 @@
13 # Deal with colliding definitions from tcsh etc.
14 VENDOR=
15
16 +# Default algorithm form compressing u-boot.bin
17 +ifndef COMPRESS
18 +COMPRESS=none
19 +COMPRESS_FILE=$(obj)u-boot.img
20 +else
21 +ifeq ($(COMPRESS),lzma)
22 +COMPRESS_FILE=$(obj)u-boot.limg
23 +endif
24 +ifeq ($(COMPRESS),bz2)
25 +COMPRESS_FILE=$(obj)u-boot.bzimg
26 +endif
27 +ifeq ($(COMPRESS),gzip)
28 +COMPRESS_FILE=$(obj)u-boot.zimg
29 +endif
30 +ifeq ($(COMPRESS),none)
31 +COMPRESS_FILE=$(obj)u-boot.img
32 +endif
33 +endif
34 +
35 #########################################################################
36 #
37 # U-boot build supports producing a object files to the separate external
38 @@ -155,6 +174,11 @@
39 endif
40 endif
41
42 +
43 +
44 +
45 +
46 +
47 export CROSS_COMPILE
48
49 # load other configuration
50 @@ -163,7 +187,9 @@
51 #########################################################################
52 # U-Boot objects....order is important (i.e. start must be first)
53
54 -OBJS = cpu/$(CPU)/start.o
55 +OBJS = cpu/$(CPU)/$(BOARDDIR)/start.o
56 +OBJS_BOOTSTRAP = cpu/$(CPU)/$(BOARDDIR)/start_bootstrap.o
57 +
58 ifeq ($(CPU),i386)
59 OBJS += cpu/$(CPU)/start16.o
60 OBJS += cpu/$(CPU)/reset.o
61 @@ -186,11 +212,11 @@
62
63 LIBS = lib_generic/libgeneric.a
64 LIBS += board/$(BOARDDIR)/lib$(BOARD).a
65 -LIBS += cpu/$(CPU)/lib$(CPU).a
66 +LIBS += cpu/$(CPU)/$(BOARDDIR)/lib$(CPU).a
67 ifdef SOC
68 LIBS += cpu/$(CPU)/$(SOC)/lib$(SOC).a
69 endif
70 -LIBS += lib_$(ARCH)/lib$(ARCH).a
71 +LIBS += lib_$(ARCH)/$(BOARDIR)/lib$(ARCH).a
72 LIBS += fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a \
73 fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a
74 LIBS += net/libnet.a
75 @@ -198,27 +224,54 @@
76 LIBS += rtc/librtc.a
77 LIBS += dtt/libdtt.a
78 LIBS += drivers/libdrivers.a
79 -LIBS += drivers/nand/libnand.a
80 -LIBS += drivers/nand_legacy/libnand_legacy.a
81 +#LIBS += drivers/nand_$(BOARDDIR)/libnand.a
82 +#LIBS += drivers/nand_legacy/libnand_legacy.a
83 LIBS += drivers/sk98lin/libsk98lin.a
84 LIBS += post/libpost.a post/cpu/libcpu.a
85 LIBS += common/libcommon.a
86 LIBS += $(BOARDLIBS)
87
88 LIBS := $(addprefix $(obj),$(LIBS))
89 +
90 +
91 +LIBS_BOOTSTRAP = lib_bootstrap/libbootstrap.a
92 +LIBS_BOOTSTRAP+= board/$(BOARDDIR)/lib$(BOARD).a
93 +#LIBS_BOOTSTRAP+= board/ifx/libifx.a
94 +LIBS_BOOTSTRAP+= cpu/$(CPU)/$(BOARDDIR)/lib$(CPU).a
95 +
96 +#HEAD_OBJS = cpu/$(CPU)/$(BOARDDIR)/start.o lib_$(ARCH)/board.o
97 +
98 +#HEAD_LIBS = board/$(BOARDDIR)/lib$(BOARD).a
99 +#HEAD_LIBS += cpu/$(CPU)/$(BOARDDIR)/lib$(CPU).a
100 +#HEAD_LIBS += lib_$(ARCH)/lib$(ARCH).a
101 +#HEAD_LIBS += lib_generic/libgeneric.a
102 +#HEAD_LIBS += common/console.o
103 +#HEAD_LIBS += common/devices.o
104 +#HEAD_LIBS += common/cmd_bootm.o
105 +
106 +#.PHONY : $(LIBS) $(HEAD_LIBS)
107 .PHONY : $(LIBS)
108 +.PHONY : $(LIBS_BOOTSTRAP)
109
110 # Add GCC lib
111 PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
112
113 # The "tools" are needed early, so put this first
114 # Don't include stuff already done in $(LIBS)
115 + #examples
116 SUBDIRS = tools \
117 - examples \
118 post \
119 post/cpu
120 .PHONY : $(SUBDIRS)
121
122 +# HEAD_SUBDIRS = tools
123 +#HEAD_SUBDIRS = lib_generic \
124 +# cpu/$(CPU) \
125 +# board/$(BOARDDIR) \
126 +# common \
127 +# lib_$(ARCH)
128 +#.PHONY : $(HEAD_SUBDIRS)
129 +
130 ifeq ($(CONFIG_NAND_U_BOOT),y)
131 NAND_SPL = nand_spl
132 U_BOOT_NAND = $(obj)u-boot-nand.bin
133 @@ -227,13 +280,76 @@
134 __OBJS := $(subst $(obj),,$(OBJS))
135 __LIBS := $(subst $(obj),,$(LIBS))
136
137 +#__HEAD_OBJS := $(subst $(obj),,$(HEAD_OBJS))
138 +#__HEAD_LIBS := $(subst $(obj),,$(HEAD_LIBS))
139 +
140 #########################################################################
141 #########################################################################
142
143 ALL = $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND)
144 +#IFX_ALL = $(obj)u-boot.ifx $(obj)head.srec $(obj)head.bin $(obj)head $(obj)head.map $(COMPRESS_FILE) $(obj)u-boot.srec
145 +IFX_ALL = $(obj)u-boot.srec $(obj)u-boot.ifx $(obj)u-boot.lzimg $(obj)System.map $(obj)bootstrap.bin
146
147 all: $(ALL)
148
149 +ifx_all: $(IFX_ALL)
150 +
151 +
152 +$(obj)u-boot.ifx: $(obj)System.map $(obj)bootstrap.bin $(obj)u-boot.lzimg
153 + @cat $(obj)bootstrap.bin > $(obj)u-boot.ifx
154 + @cat $(obj)u-boot.lzimg >> $(obj)u-boot.ifx
155 +
156 +$(obj)u-boot.lzimg: $(obj)u-boot.bin System.map
157 +# @lzma -f -z --best -v $(obj)u-boot.bin
158 + @lzma e $(obj)u-boot.bin $(obj)u-boot.bin.lzma
159 + @./tools/mkimage -A mips -T firmware -C lzma \
160 + -a 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
161 + -e 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
162 + -n 'u-boot image' -d $(obj)u-boot.bin.lzma $@
163 +
164 +$(obj)ld_uboot.img: $(obj)u-boot.ifx $(obj)u-boot.lzimg $(obj)System.map $(obj)bootstrap.bin
165 + @ cp -f $(obj)u-boot.ifx $(obj)u-boot.bin
166 + @ ./mkbootimg.incaip2 $(obj)ld_uboot.img < ld_uboot.conf
167 +
168 +
169 +
170 +
171 +$(obj)u-boot.zimg: $(obj)u-boot.bin $(obj)System.map
172 + gzip $(obj)u-boot.bin
173 + ./tools/mkimage -A $(ARCH) -T firmware -C gzip \
174 + -a 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
175 + -e 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
176 + -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
177 + sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
178 + -d u-boot.gz $@
179 +
180 +$(obj)u-boot.bzimg: $(obj)u-boot.bin $(obj)System.map
181 + bzip $(obj)u-boot.bin
182 + ./tools/mkimage -A $(ARCH) -T firmware -C bzip2 \
183 + -a 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
184 + -e 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
185 + -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
186 + sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
187 + -d u-boot.bz2 $@
188 +
189 +$(obj)u-boot.limg: $(obj)u-boot.bin $(obj)System.map
190 +# @lzma -f -z --best -v $(obj)u-boot.bin
191 + @lzma e $(obj)u-boot.bin $(obj)u-boot.bin.lzma
192 + ./tools/mkimage -A $(ARCH) -T firmware -C lzma \
193 + -a 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
194 + -e 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
195 + -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
196 + sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
197 + -d u-boot.bin.lzma $@
198 +
199 +$(obj)u-boot.img: $(obj)u-boot.bin $(obj)System.map
200 + ./tools/mkimage -A $(ARCH) -T firmware -C none \
201 + -a 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
202 + -e 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
203 + -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
204 + sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
205 + -d u-boot.bin $@
206 +
207 $(obj)u-boot.hex: $(obj)u-boot
208 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
209
210 @@ -243,28 +359,36 @@
211 $(obj)u-boot.bin: $(obj)u-boot
212 $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
213
214 -$(obj)u-boot.img: $(obj)u-boot.bin
215 - ./tools/mkimage -A $(ARCH) -T firmware -C none \
216 - -a $(TEXT_BASE) -e 0 \
217 - -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
218 - sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
219 - -d $< $@
220 -
221 $(obj)u-boot.dis: $(obj)u-boot
222 $(OBJDUMP) -d $< > $@
223
224 -$(obj)u-boot: depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
225 +$(obj)u-boot: depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
226 UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
227 cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
228 --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
229 -Map u-boot.map -o u-boot
230
231 +
232 +
233 +$(obj)bootstrap.bin: $(obj)bootstrap
234 + $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
235 +
236 +$(obj)bootstrap : depend version $(SUBDIRS) $(OBJS_BOOTSTRAP) $(LIBS_BOOTSTRAP) $(LDSCRIPT_BOOTSTRAP)
237 + UNDEF_SYM=`$(OBJDUMP) -x $(LIBS_BOOTSTRAP) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
238 + $(LD) $(LDFLAGS_BOOTSTRAP) $$UNDEF_SYM $(OBJS_BOOTSTRAP) \
239 + --start-group $(LIBS_BOOTSTRAP) --end-group $(PLATFORM_LIBS) \
240 + -Map bootstrap.map -o bootstrap
241 +
242 $(OBJS):
243 - $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
244 + $(MAKE) -C cpu/$(CPU)/$(BOARDDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
245
246 $(LIBS):
247 $(MAKE) -C $(dir $(subst $(obj),,$@))
248
249 +
250 +$(LIBS_BOOTSTRAP):
251 + $(MAKE) -C `dirname $@`
252 +
253 $(SUBDIRS):
254 $(MAKE) -C $@ all
255
256 @@ -295,14 +419,14 @@
257
258 tags ctags:
259 ctags -w -o $(OBJTREE)/ctags `find $(SUBDIRS) include \
260 - lib_generic board/$(BOARDDIR) cpu/$(CPU) lib_$(ARCH) \
261 + lib_generic board/$(BOARDDIR) cpu/$(CPU)/$(BOARDDIR) lib_$(ARCH) \
262 fs/cramfs fs/fat fs/fdos fs/jffs2 \
263 net disk rtc dtt drivers drivers/sk98lin common \
264 \( -name CVS -prune \) -o \( -name '*.[ch]' -print \)`
265
266 etags:
267 etags -a -o $(OBJTREE)/etags `find $(SUBDIRS) include \
268 - lib_generic board/$(BOARDDIR) cpu/$(CPU) lib_$(ARCH) \
269 + lib_generic board/$(BOARDDIR) cpu/$(CPU)/$(BOARDDIR) lib_$(ARCH) \
270 fs/cramfs fs/fat fs/fdos fs/jffs2 \
271 net disk rtc dtt drivers drivers/sk98lin common \
272 \( -name CVS -prune \) -o \( -name '*.[ch]' -print \)`
273 @@ -2032,7 +2156,20 @@
274 # MIPS
275 #========================================================================
276 #########################################################################
277 -## MIPS32 4Kc
278 +## Infineon MIPS generic u-boot config
279 +#########################################################################
280 +danube_config: unconfig
281 + @$(MKCONFIG) $(@:_config=) mips mips danube
282 +
283 +amazon_config: unconfig
284 + @$(MKCONFIG) $(@:_config=) mips mips amazon
285 +
286 +
287 +incaip2_config: unconfig
288 + @$(MKCONFIG) $(@:_config=) mips mips incaip2
289 +
290 +#########################################################################
291 +## MIPS32 4kc
292 #########################################################################
293
294 xtract_incaip = $(subst _100MHz,,$(subst _133MHz,,$(subst _150MHz,,$(subst _config,,$1))))
295 @@ -2246,6 +2383,8 @@
296 rm -f $(obj)include/bmp_logo.h
297 find nand_spl -lname "*" -print | xargs rm -f
298 rm -f nand_spl/u-boot-spl nand_spl/u-boot-spl.map
299 + rm -f lib_bootstrap/*.o
300 + rm -f lib_bootstrap/*.a
301
302 clobber: clean
303 find $(OBJTREE) -type f \( -name .depend \
304 @@ -2254,7 +2393,7 @@
305 | xargs -0 rm -f
306 rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS $(obj)include/version_autogenerated.h
307 rm -fr $(obj)*.*~
308 - rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
309 + rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL) $(IFX_ALL)
310 rm -f $(obj)tools/crc32.c $(obj)tools/environment.c $(obj)tools/env/crc32.c
311 rm -f $(obj)tools/inca-swap-bytes $(obj)cpu/mpc824x/bedbug_603e.c
312 rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
313 --- /dev/null
314 +++ b/build_danube.sh
315 @@ -0,0 +1,28 @@
316 +#!/bin/sh
317 +IFX_CONFIG_FLASH_SIZE=8
318 +IFX_CONFIG_MEMORY_SIZE=30
319 +CONFIG_RAM_TEXT_BASE=0xA0400000
320 +
321 +#prepare_headers()
322 +#{
323 +# cp -f include/flash_$1.h \
324 +# include/flash.h
325 +# cp -f include/net_$1.h \
326 +# include/net.h
327 +# cp -f include/asm-mips/cacheops_$1.h \
328 +# include/asm-mips/cacheops.h
329 +# cp -f include/asm-mips/mipsregs_$1.h \
330 +# include/asm-mips/mipsregs.h
331 +#}
332 +#prepare_headers "danube"
333 +UBOOT_COMPRESS=lzma
334 +UBOOT_CFLAGS="-DCONFIG_IFX_MIPS -DCONFIG_LZMA -DIFX_CONFIG_MEMORY_SIZE=${IFX_CONFIG_MEMORY_SIZE} -DIFX_CONFIG_FLASH_SIZE=${IFX_CONFIG_FLASH_SIZE}"
335 +
336 +rm -f .config_ok
337 +
338 +make CROSS_COMPILE="mips-linux-uclibc-" CROSS_COMPILE_UCLIBC=1 COMPRESS=${UBOOT_COMPRESS} PLATFORM_CPU=mips32r2 IFX_CFLAGS="${UBOOT_CFLAGS}" UBOOT_RAM_TEXT_BASE=${CONFIG_RAM_TEXT_BASE} CPU_TYPE=${IFX_CONFIG_CPU} danube_config distclean
339 +
340 +CROSS_COMPILE="mips-linux-uclibc-" CROSS_COMPILE_UCLIBC=1 COMPRESS=${UBOOT_COMPRESS} PLATFORM_CPU=mips32r2 IFX_CFLAGS="${UBOOT_CFLAGS}" make UBOOT_RAM_TEXT_BASE=${CONFIG_RAM_TEXT_BASE} CPU_TYPE=${IFX_CONFIG_CPU} danube_config
341 + echo -n > .config_ok
342 +
343 +CROSS_COMPILE="mips-linux-uclibc-" CROSS_COMPILE_UCLIBC=1 COMPRESS=${UBOOT_COMPRESS} PLATFORM_CPU=mips32r2 IFX_CFLAGS="${UBOOT_CFLAGS}" make UBOOT_RAM_TEXT_BASE=${CONFIG_RAM_TEXT_BASE} BOOTSTRAP_PRINTF_STATUS=$2 CPU_TYPE=${IFX_CONFIG_CPU} ifx_all
344 --- a/common/Makefile
345 +++ b/common/Makefile
346 @@ -46,7 +46,7 @@
347 env_nand.o env_dataflash.o env_flash.o env_eeprom.o \
348 env_nvram.o env_nowhere.o \
349 exports.o \
350 - flash.o fpga.o ft_build.o \
351 + flash_$(BOARD).o fpga.o ft_build.o \
352 hush.o kgdb.o lcd.o lists.o lynxkdi.o \
353 memsize.o miiphybb.o miiphyutil.o \
354 s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o spartan3.o \
355 @@ -60,7 +60,7 @@
356
357 all: $(LIB) $(AOBJS)
358
359 -$(LIB): $(obj).depend $(OBJS)
360 +$(LIB): $(OBJS)
361 $(AR) $(ARFLAGS) $@ $(OBJS)
362
363 $(obj)environment.o: $(src)environment.c $(obj)../tools/envcrc
364 --- a/common/cmd_bootm.c
365 +++ b/common/cmd_bootm.c
366 @@ -31,6 +31,7 @@
367 #include <malloc.h>
368 #include <zlib.h>
369 #include <bzlib.h>
370 +#include <LzmaWrapper.h>
371 #include <environment.h>
372 #include <asm/byteorder.h>
373
374 @@ -79,6 +80,8 @@
375 # define CHUNKSZ (64 * 1024)
376 #endif
377
378 +#ifndef CFG_HEAD_CODE
379 +
380 int gunzip (void *, int, unsigned char *, unsigned long *);
381
382 static void *zalloc(void *, unsigned, unsigned);
383 @@ -341,6 +344,7 @@
384 #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
385 }
386 break;
387 +#ifndef CONFIG_REMOVE_GZIP
388 case IH_COMP_GZIP:
389 printf (" Uncompressing %s ... ", name);
390 if (gunzip ((void *)ntohl(hdr->ih_load), unc_len,
391 @@ -350,6 +354,7 @@
392 do_reset (cmdtp, flag, argc, argv);
393 }
394 break;
395 +#endif /* CONFIG_REMOVE_GZIP */
396 #ifdef CONFIG_BZIP2
397 case IH_COMP_BZIP2:
398 printf (" Uncompressing %s ... ", name);
399 @@ -369,6 +374,18 @@
400 }
401 break;
402 #endif /* CONFIG_BZIP2 */
403 +#ifdef CONFIG_LZMA
404 + case IH_COMP_LZMA:
405 + printf (" Uncompressing %s ... ", name);
406 + i = lzma_inflate ((unsigned char *)data, len, (unsigned char*)ntohl(hdr->ih_load), &unc_len);
407 + if (i != LZMA_RESULT_OK) {
408 + printf ("LZMA ERROR %d - must RESET board to recover\n", i);
409 + SHOW_BOOT_PROGRESS (-6);
410 + udelay(100000);
411 + do_reset (cmdtp, flag, argc, argv);
412 + }
413 + break;
414 +#endif /* CONFIG_LZMA */
415 default:
416 if (iflag)
417 enable_interrupts();
418 @@ -1176,6 +1193,8 @@
419 );
420 #endif /* CFG_CMD_IMLS */
421
422 +#endif /* ! CFG_HEAD_CODE */
423 +
424 void
425 print_image_hdr (image_header_t *hdr)
426 {
427 @@ -1270,12 +1289,15 @@
428 case IH_COMP_NONE: comp = "uncompressed"; break;
429 case IH_COMP_GZIP: comp = "gzip compressed"; break;
430 case IH_COMP_BZIP2: comp = "bzip2 compressed"; break;
431 + case IH_COMP_LZMA: comp = "lzma compressed"; break;
432 default: comp = "unknown compression"; break;
433 }
434
435 printf ("%s %s %s (%s)", arch, os, type, comp);
436 }
437
438 +#ifndef CFG_HEAD_CODE
439 +
440 #define ZALLOC_ALIGNMENT 16
441
442 static void *zalloc(void *x, unsigned items, unsigned size)
443 @@ -1427,3 +1449,5 @@
444 }
445
446 #endif /* CONFIG_LYNXKDI */
447 +
448 +#endif /* ! CFG_HEAD_CODE */
449 --- a/common/cmd_flash.c
450 +++ b/common/cmd_flash.c
451 @@ -196,9 +196,17 @@
452 }
453
454 static int
455 -flash_fill_sect_ranges (ulong addr_first, ulong addr_last,
456 - int *s_first, int *s_last,
457 - int *s_count )
458 +flash_fill_sect_ranges(
459 + ulong *addr_first_sect_start,
460 + ulong addr_first,
461 + ulong *addr_last_sect_end,
462 + ulong addr_last,
463 + int *s_first,
464 + int *s_last,
465 + int *bPartialStart,
466 + int *bPartialEnd,
467 + int *s_count,
468 + unsigned int bPartialErase)
469 {
470 flash_info_t *info;
471 ulong bank;
472 @@ -211,9 +219,7 @@
473 s_last [bank] = -1; /* last sector to erase */
474 }
475
476 - for (bank=0,info=&flash_info[0];
477 - (bank < CFG_MAX_FLASH_BANKS) && (addr_first <= addr_last);
478 - ++bank, ++info) {
479 + for (bank=0, info=&flash_info[0]; (bank < CFG_MAX_FLASH_BANKS) && (addr_first <= addr_last); ++bank, ++info) {
480 ulong b_end;
481 int sect;
482 short s_end;
483 @@ -225,7 +231,6 @@
484 b_end = info->start[0] + info->size - 1; /* bank end addr */
485 s_end = info->sector_count - 1; /* last sector */
486
487 -
488 for (sect=0; sect < info->sector_count; ++sect) {
489 ulong end; /* last address in current sect */
490
491 @@ -238,11 +243,21 @@
492
493 if (addr_first == info->start[sect]) {
494 s_first[bank] = sect;
495 + } else if (addr_first > info->start[sect] && addr_first <= end && bPartialErase) {
496 + *addr_first_sect_start = info->start[sect];
497 + s_first[bank] = sect;
498 + *bPartialStart = 1;
499 }
500 +
501 if (addr_last == end) {
502 s_last[bank] = sect;
503 + } else if (addr_last >= info->start[sect] && addr_last < end && bPartialErase) {
504 + *addr_last_sect_end = end;
505 + s_last[bank] = sect;
506 + *bPartialEnd = 1;
507 }
508 }
509 +
510 if (s_first[bank] >= 0) {
511 if (s_last[bank] < 0) {
512 if (addr_last > b_end) {
513 @@ -316,6 +331,8 @@
514 struct part_info *part;
515 u8 dev_type, dev_num, pnum;
516 #endif
517 + unsigned int bPartialErase = 0;
518 +
519 int rcode = 0;
520
521 if (argc < 2) {
522 @@ -368,8 +385,8 @@
523 }
524 }
525 #endif
526 -
527 - if (argc != 3) {
528 +
529 + if (argc != 4) {
530 printf ("Usage:\n%s\n", cmdtp->usage);
531 return 1;
532 }
533 @@ -397,11 +414,117 @@
534 return 1;
535 }
536
537 - rcode = flash_sect_erase(addr_first, addr_last);
538 + printf ("Erase Flash from 0x%08lx to 0x%08lx\n", addr_first, addr_last);
539 + if(argc == 4) {
540 + bPartialErase = simple_strtoul(argv[3], NULL, 10);
541 + }
542 +
543 + rcode = flash_sect_erase(addr_first, addr_last, bPartialErase);
544 return rcode;
545 }
546
547 -int flash_sect_erase (ulong addr_first, ulong addr_last)
548 +int flerase_Partial(
549 + ulong addr_first_sect_start,
550 + ulong addr_first,
551 + ulong addr_last_sect_end,
552 + ulong addr_last,
553 + flash_info_t *info,
554 + int first_sect,
555 + int last_sect,
556 + int bFirstPartial,
557 + int bLastPartial) {
558 + unsigned int firstMemLen = 0;
559 + unsigned int lastMemLen = 0;
560 + unsigned int sectMemLen = 0;
561 + uchar *pSavedFirstMem = NULL;
562 + uchar *pSavedLastMem = NULL;
563 + uchar *pSavedSectMem = NULL;
564 + int bSectPartial = 0;
565 + int rt_code = 0;
566 +
567 + 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);
568 +
569 + if (bFirstPartial && bLastPartial && (first_sect == last_sect))
570 + {
571 + ulong b_end = info->start[0] + info->size - 1;
572 + ulong end = (first_sect == (info->sector_count - 1)) ? b_end : info->start[first_sect + 1] - 1;
573 + sectMemLen = end - info->start[first_sect] + 1;
574 + pSavedSectMem = (uchar *)calloc(sectMemLen, sizeof(char));
575 + if (pSavedSectMem == NULL)
576 + {
577 + debug("calloc %u FAILED\n", sectMemLen);
578 + rt_code = 1;
579 + goto ret;
580 + }
581 + memset(pSavedSectMem, 0xff, sectMemLen);
582 + bSectPartial = 1;
583 + memcpy(pSavedSectMem, (uchar *)addr_first_sect_start, addr_first - addr_first_sect_start);
584 + memcpy(pSavedSectMem + (addr_last - info->start[first_sect]) + 1, addr_last + 1, end - addr_last);
585 + }
586 + else
587 + {
588 + if (bFirstPartial){
589 + firstMemLen = addr_first - addr_first_sect_start + 1;
590 + pSavedFirstMem = (uchar *)calloc(firstMemLen,sizeof(char));
591 + memcpy(pSavedFirstMem,(uchar *)addr_first_sect_start,firstMemLen - 1);
592 + }
593 + if (bLastPartial){
594 + lastMemLen = addr_last_sect_end - addr_last + 1;
595 + pSavedLastMem = (uchar *)calloc(lastMemLen,sizeof(char));
596 + memcpy(pSavedLastMem,(uchar *)addr_last + 1,lastMemLen - 1);
597 + }
598 + }
599 +
600 + if (bFirstPartial){
601 + if(flash_erase (info, first_sect, first_sect)) {
602 + printf("%s ... Couldn't erase sector %d\n", __FUNCTION__, first_sect);
603 + rt_code = 1;
604 + goto ret;
605 + }
606 + debug("%s ... erase sector %d done!\n", __FUNCTION__, first_sect);
607 + }
608 +
609 + if (bLastPartial && first_sect != last_sect){
610 + if(flash_erase (info, last_sect, last_sect)) {
611 + printf("%s ... Couldn't erase sector %d\n", __FUNCTION__, last_sect);
612 + rt_code = 1;
613 + goto ret;
614 + }
615 + debug("%s ... erase sector %d done!\n", __FUNCTION__, last_sect);
616 + }
617 +
618 + if (bFirstPartial && bLastPartial && (first_sect == last_sect))
619 + {
620 + flash_write(pSavedSectMem, (uchar *)addr_first_sect_start, sectMemLen);
621 + debug("flash_write from 0x%08x with len %u\n", addr_first_sect_start, sectMemLen);
622 + }
623 + else
624 + {
625 + if (bFirstPartial){
626 + if(flash_write(pSavedFirstMem,(uchar *)addr_first_sect_start,firstMemLen - 1)) {
627 + printf("%s ... Couldn't write at 0x%08lx length %d\n", __FUNCTION__, addr_first_sect_start,firstMemLen - 1);
628 + rt_code = 1;
629 + goto ret;
630 + }
631 + }
632 + if (bLastPartial){
633 + if(flash_write(pSavedLastMem,(uchar *)addr_last + 1,lastMemLen - 1)) {
634 + printf("%s ... Couldn't write at 0x%08lx length %d\n", __FUNCTION__, addr_last, lastMemLen - 1);
635 + rt_code = 1;
636 + }
637 + }
638 + }
639 +ret:
640 + if (bFirstPartial)
641 + free(pSavedFirstMem);
642 + if (bLastPartial)
643 + free(pSavedLastMem);
644 + if (bSectPartial)
645 + free(pSavedSectMem);
646 + return rt_code;
647 +}
648 +
649 +int flash_sect_erase (ulong addr_first, ulong addr_last, unsigned int bPartialErase)
650 {
651 flash_info_t *info;
652 ulong bank;
653 @@ -413,27 +536,66 @@
654 int erased = 0;
655 int planned;
656 int rcode = 0;
657 -
658 - rcode = flash_fill_sect_ranges (addr_first, addr_last,
659 - s_first, s_last, &planned );
660 + int bPartialStart = 0; // Start sector has to be erased partially
661 + int bPartialEnd = 0; // End sector has to be erased partially
662 + ulong addr_first_sect_start = 0;// Sector start address of location addr_start
663 + ulong addr_last_sect_end = 0; // Sector end address of location addr_last
664 +
665 + rcode = flash_fill_sect_ranges (
666 + &addr_first_sect_start,
667 + addr_first,
668 + &addr_last_sect_end,
669 + addr_last,
670 + s_first,
671 + s_last,
672 + &bPartialStart,
673 + &bPartialEnd,
674 + &planned,
675 + bPartialErase );
676
677 if (planned && (rcode == 0)) {
678 - for (bank=0,info=&flash_info[0];
679 - (bank < CFG_MAX_FLASH_BANKS) && (rcode == 0);
680 - ++bank, ++info) {
681 + for (bank=0, info=&flash_info[0]; (bank < CFG_MAX_FLASH_BANKS) && (rcode == 0); ++bank, ++info) {
682 + ulong b_end = info->start[0] + info->size - 1; /* bank end addr */
683 if (s_first[bank]>=0) {
684 - erased += s_last[bank] - s_first[bank] + 1;
685 - debug ("Erase Flash from 0x%08lx to 0x%08lx "
686 - "in Bank # %ld ",
687 - info->start[s_first[bank]],
688 - (s_last[bank] == info->sector_count) ?
689 - info->start[0] + info->size - 1:
690 - info->start[s_last[bank]+1] - 1,
691 - bank+1);
692 - rcode = flash_erase (info, s_first[bank], s_last[bank]);
693 + if(bPartialErase) {
694 + rcode = flerase_Partial(
695 + addr_first_sect_start,
696 + addr_first,
697 + addr_last_sect_end,
698 + addr_last,
699 + info,
700 + s_first[bank],
701 + s_last[bank],
702 + bPartialStart,
703 + bPartialEnd);
704 + }
705 +
706 + //Erase full sectores
707 + if (bPartialStart)
708 + s_first[bank] += 1;
709 + if (bPartialEnd)
710 + s_last[bank] -= 1;
711 + if (s_last[bank] >= s_first[bank]) {
712 + erased += s_last[bank] - s_first[bank] + 1;
713 + debug ("Erase Flash from 0x%08lx to 0x%08lx in Bank # %ld ",
714 + info->start[s_first[bank]],
715 + (s_last[bank] == info->sector_count) ?
716 + info->start[0] + info->size - 1:
717 + info->start[s_last[bank]+1] - 1,
718 + bank + 1);
719 + rcode = flash_erase (info, s_first[bank], s_last[bank]);
720 + }
721 }
722 }
723 - printf ("Erased %d sectors\n", erased);
724 +
725 + if (erased && !bPartialErase) {
726 + printf ("Erased %d sectors\n", erased);
727 + } else if (bPartialErase){
728 + printf ("Partial erased from 0x%08lx to 0x%08lx\n", addr_first, addr_last);
729 + } else {
730 + printf ("Error: start and/or end address not on sector boundary\n");
731 + rcode = 1;
732 + }
733 } else if (rcode == 0) {
734 puts ("Error: start and/or end address"
735 " not on sector boundary\n");
736 @@ -629,8 +791,22 @@
737 int protected, i;
738 int planned;
739 int rcode;
740 -
741 - rcode = flash_fill_sect_ranges( addr_first, addr_last, s_first, s_last, &planned );
742 + int bPartialStart = 0; // Start sector has to be erased partially
743 + int bPartialEnd = 0; // End sector has to be erased partially
744 + ulong addr_first_sect_start = 0;// Sector start address of location addr_start
745 + ulong addr_last_sect_end = 0; // Sector end address of location addr_last
746 +
747 + rcode = flash_fill_sect_ranges (
748 + &addr_first_sect_start,
749 + addr_first,
750 + &addr_last_sect_end,
751 + addr_last,
752 + s_first,
753 + s_last,
754 + &bPartialStart,
755 + &bPartialEnd,
756 + &planned,
757 + 1 );
758
759 protected = 0;
760
761 @@ -690,7 +866,7 @@
762 );
763
764 U_BOOT_CMD(
765 - erase, 3, 1, do_flerase,
766 + erase, 4, 1, do_flerase,
767 "erase - erase FLASH memory\n",
768 "start end\n"
769 " - erase FLASH from addr 'start' to addr 'end'\n"
770 --- a/common/cmd_nvedit.c
771 +++ b/common/cmd_nvedit.c
772 @@ -540,8 +540,19 @@
773 extern char * env_name_spec;
774
775 printf ("Saving Environment to %s...\n", env_name_spec);
776 -
777 +#if 1
778 + if(saveenv() == 0) {
779 +#ifdef UBOOT_ENV_COPY
780 + saveenv_copy();
781 +#else
782 + ;
783 +#endif //UBOOT_ENV_COPY
784 + } else
785 + return 1;
786 + return 0;
787 +#else
788 return (saveenv() ? 1 : 0);
789 +#endif
790 }
791
792
793 --- a/common/console.c
794 +++ b/common/console.c
795 @@ -324,7 +324,7 @@
796 #endif
797
798 /** U-Boot INIT FUNCTIONS *************************************************/
799 -
800 +#ifndef CFG_HEAD_CODE
801 int console_assign (int file, char *devname)
802 {
803 int flag, i;
804 @@ -357,7 +357,7 @@
805
806 return -1;
807 }
808 -
809 +#endif //CFG_HEAD_CODE
810 /* Called before relocation - use serial functions */
811 int console_init_f (void)
812 {
813 @@ -392,6 +392,7 @@
814 }
815 #endif /* CFG_CONSOLE_IS_IN_ENV || CONFIG_SPLASH_SCREEN */
816
817 +#ifndef CFG_HEAD_CODE
818 #ifdef CFG_CONSOLE_IS_IN_ENV
819 /* Called after the relocation - use desired console functions */
820 int console_init_r (void)
821 @@ -570,3 +571,4 @@
822 }
823
824 #endif /* CFG_CONSOLE_IS_IN_ENV */
825 +#endif //CFG_HEAD_CODE
826 --- a/common/devices.c
827 +++ b/common/devices.c
828 @@ -39,6 +39,7 @@
829 list_t devlist = 0;
830 device_t *stdio_devices[] = { NULL, NULL, NULL };
831 char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
832 +#ifndef CFG_HEAD_CODE
833
834 #if defined(CONFIG_SPLASH_SCREEN) && !defined(CFG_DEVICE_NULLDEV)
835 #define CFG_DEVICE_NULLDEV 1
836 @@ -214,3 +215,5 @@
837
838 return 0;
839 }
840 +#endif //CFG_HEAD_CODE
841 +
842 --- a/common/env_common.c
843 +++ b/common/env_common.c
844 @@ -219,7 +219,9 @@
845 * We must allocate a buffer for the environment
846 */
847 env_ptr = (env_t *)malloc (CFG_ENV_SIZE);
848 - DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
849 + if(!env_ptr)
850 + DEBUGF ("malloc env_ptr error!!\n");
851 + DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__, __LINE__, env_ptr);
852 #endif
853
854 /*
855 @@ -227,6 +229,10 @@
856 */
857 env_get_char = env_get_char_memory;
858
859 + //leejack
860 + DEBUGF ("%s[%d] gd->env_valid=%d\n", __FUNCTION__, __LINE__, gd->env_valid);
861 + DEBUGF ("%s[%d] CFG_ENV_SIZE=%d\n", __FUNCTION__, __LINE__, CFG_ENV_SIZE);
862 +
863 if (gd->env_valid == 0) {
864 #if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE) /* Environment not changable */
865 puts ("Using default environment\n\n");
866 @@ -242,18 +248,17 @@
867 }
868
869 memset (env_ptr, 0, sizeof(env_t));
870 - memcpy (env_ptr->data,
871 - default_environment,
872 - sizeof(default_environment));
873 + memcpy (env_ptr->data, default_environment, sizeof(default_environment));
874 +
875 #ifdef CFG_REDUNDAND_ENVIRONMENT
876 env_ptr->flags = 0xFF;
877 #endif
878 env_crc_update ();
879 gd->env_valid = 1;
880 - }
881 - else {
882 + } else {
883 env_relocate_spec ();
884 }
885 +
886 gd->env_addr = (ulong)&(env_ptr->data);
887
888 #ifdef CONFIG_AMIGAONEG3SE
889 --- a/common/env_flash.c
890 +++ b/common/env_flash.c
891 @@ -66,7 +66,6 @@
892 #endif
893
894 #else /* ! ENV_IS_EMBEDDED */
895 -
896 env_t *env_ptr = (env_t *)CFG_ENV_ADDR;
897 #ifdef CMD_SAVEENV
898 static env_t *flash_addr = (env_t *)CFG_ENV_ADDR;
899 @@ -201,6 +200,7 @@
900 debug (" %08lX ... %08lX ...",
901 (ulong)&(flash_addr_new->data),
902 sizeof(env_ptr->data)+(ulong)&(flash_addr_new->data));
903 +
904 if ((rc = flash_write((char *)env_ptr->data,
905 (ulong)&(flash_addr_new->data),
906 sizeof(env_ptr->data))) ||
907 @@ -256,7 +256,6 @@
908 #endif /* CMD_SAVEENV */
909
910 #else /* ! CFG_ENV_ADDR_REDUND */
911 -
912 int env_init(void)
913 {
914 #ifdef CONFIG_OMAP2420H4
915 @@ -280,8 +279,55 @@
916
917 #ifdef CMD_SAVEENV
918
919 +#ifdef UBOOT_ENV_COPY
920 +int saveenv_copy(void) {
921 + uchar *env_buffer = (char *)env_ptr;
922 + char *kernel_addr;
923 + char *rootfs_addr;
924 + char *rootfs_size;
925 + ulong start_addr,end_addr,rootfs_end_addr;
926 + ulong flash_start;
927 +
928 + kernel_addr = getenv("f_kernel_addr");
929 + end_addr = simple_strtoul(kernel_addr,NULL,16) - 1;
930 + start_addr = end_addr - CFG_ENV_SIZE - sizeof(UBOOTCONFIG_COPY_HEADER) + 1;
931 +
932 + rootfs_addr = getenv("f_rootfs_addr");
933 + rootfs_size = getenv("f_rootfs_size");
934 + rootfs_end_addr = simple_strtoul(rootfs_addr,NULL,16) + simple_strtoul(rootfs_size,NULL,16);
935 +
936 + if(rootfs_end_addr >= start_addr)
937 + {
938 + 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);
939 + return 1;
940 + }
941 +
942 + debug ("Protect off %08lX ... %08lX\n", (ulong)rootfs_end_addr, end_addr);
943 + if (flash_sect_protect (0, rootfs_end_addr, end_addr))
944 + return 1;
945 +
946 + //delete the old environment copy, if found
947 + flash_start = rootfs_end_addr;
948 + while(flash_start + sizeof(UBOOTCONFIG_COPY_HEADER) + ENV_SIZE < end_addr)
949 + {
950 + if(strncmp((char *)flash_start,UBOOTCONFIG_COPY_HEADER,sizeof(UBOOTCONFIG_COPY_HEADER)) == 0)
951 + {
952 + flash_sect_erase(flash_start,flash_start + sizeof(UBOOTCONFIG_COPY_HEADER),1);
953 + }
954 + flash_start += 1;
955 + }
956 + flash_sect_erase(start_addr,end_addr,1);
957 + flash_write(UBOOTCONFIG_COPY_HEADER,start_addr,sizeof(UBOOTCONFIG_COPY_HEADER));
958 + flash_write(env_buffer,start_addr + sizeof(UBOOTCONFIG_COPY_HEADER), CFG_ENV_SIZE);
959 + flash_sect_protect (1, rootfs_end_addr, end_addr);
960 + printf("saved copy of the env at 0x%08lx\n",start_addr);
961 + return 0;
962 +}
963 +#endif //UBOOT_ENV_COPY
964 +
965 int saveenv(void)
966 {
967 +#define debug printf
968 int len, rc;
969 ulong end_addr;
970 ulong flash_sect_addr;
971 @@ -331,7 +377,7 @@
972 return 1;
973
974 puts ("Erasing Flash...");
975 - if (flash_sect_erase (flash_sect_addr, end_addr))
976 + if (flash_sect_erase (flash_sect_addr, end_addr, 1))
977 return 1;
978
979 puts ("Writing to Flash... ");
980 --- a/common/hush.c
981 +++ b/common/hush.c
982 @@ -3167,9 +3167,11 @@
983 int code = 0;
984 #endif
985 do {
986 + printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
987 ctx.type = flag;
988 initialize_context(&ctx);
989 update_ifs_map();
990 + printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
991 if (!(flag & FLAG_PARSE_SEMICOLON) || (flag & FLAG_REPARSING)) mapset((uchar *)";$&|", 0);
992 inp->promptmode=1;
993 rcode = parse_stream(&temp, &ctx, inp, '\n');
994 @@ -3180,9 +3182,12 @@
995 syntax();
996 #ifdef __U_BOOT__
997 flag_repeat = 0;
998 +printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
999 #endif
1000 + printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
1001 }
1002 if (rcode != 1 && ctx.old_flag == 0) {
1003 + printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
1004 done_word(&temp, &ctx);
1005 done_pipe(&ctx,PIPE_SEQ);
1006 #ifndef __U_BOOT__
1007 @@ -3202,6 +3207,7 @@
1008 if (code == -1)
1009 flag_repeat = 0;
1010 #endif
1011 + printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
1012 } else {
1013 if (ctx.old_flag != 0) {
1014 free(ctx.stack);
1015 @@ -3215,6 +3221,7 @@
1016 temp.quote = 0;
1017 inp->p = NULL;
1018 free_pipe_list(ctx.list_head,0);
1019 + printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
1020 }
1021 b_free(&temp);
1022 } while (rcode != -1 && !(flag & FLAG_EXIT_FROM_LOOP)); /* loop on syntax errors, return on EOF */
1023 @@ -3235,9 +3242,12 @@
1024 #ifdef __U_BOOT__
1025 char *p = NULL;
1026 int rcode;
1027 + printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
1028 if ( !s || !*s)
1029 return 1;
1030 + printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
1031 if (!(p = strchr(s, '\n')) || *++p) {
1032 + printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
1033 p = xmalloc(strlen(s) + 2);
1034 strcpy(p, s);
1035 strcat(p, "\n");
1036 @@ -3247,6 +3257,7 @@
1037 return rcode;
1038 } else {
1039 #endif
1040 + printf("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
1041 setup_string_in_str(&input, s);
1042 return parse_stream_outer(&input, flag);
1043 #ifdef __U_BOOT__
1044 --- a/config.mk
1045 +++ b/config.mk
1046 @@ -77,7 +77,7 @@
1047 sinclude $(TOPDIR)/$(ARCH)_config.mk # include architecture dependend rules
1048 endif
1049 ifdef CPU
1050 -sinclude $(TOPDIR)/cpu/$(CPU)/config.mk # include CPU specific rules
1051 +sinclude $(TOPDIR)/cpu/$(CPU)/$(BOARD)/config.mk # include CPU specific rules
1052 endif
1053 ifdef SOC
1054 sinclude $(TOPDIR)/cpu/$(CPU)/$(SOC)/config.mk # include SoC specific rules
1055 @@ -130,7 +130,8 @@
1056 ARFLAGS = crv
1057 RELFLAGS= $(PLATFORM_RELFLAGS)
1058 DBGFLAGS= -g # -DDEBUG
1059 -OPTFLAGS= -Os #-fomit-frame-pointer
1060 +OPTFLAGS= -Os
1061 +#-O2 #-fomit-frame-pointer
1062 ifndef LDSCRIPT
1063 #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
1064 ifeq ($(CONFIG_NAND_U_BOOT),y)
1065 @@ -139,12 +140,15 @@
1066 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
1067 endif
1068 endif
1069 +
1070 +LDSCRIPT_BOOTSTRAP := $(TOPDIR)/board/$(BOARDDIR)/u-boot-bootstrap.lds
1071 +
1072 OBJCFLAGS += --gap-fill=0xff
1073
1074 gccincdir := $(shell $(CC) -print-file-name=include)
1075
1076 CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
1077 - -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \
1078 + -D__KERNEL__ -DUBOOT_RAM_TEXT_BASE=$(UBOOT_RAM_TEXT_BASE) \
1079
1080 ifneq ($(OBJTREE),$(SRCTREE))
1081 CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
1082 @@ -180,7 +184,10 @@
1083
1084 AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
1085
1086 -LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
1087 +LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(UBOOT_RAM_TEXT_BASE) $(PLATFORM_LDFLAGS)
1088 +LDFLAGS_BOOTSTRAP += -Bstatic -T $(LDSCRIPT_BOOTSTRAP) -Ttext $(BOOTSTRAP_TEXT_BASE) $(PLATFORM_LDFLAGS)
1089 +
1090 +#HEAD_LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(HEAD_FLASH_TEXT_BASE) $(PLATFORM_LDFLAGS)
1091
1092 # Location of a usable BFD library, where we define "usable" as
1093 # "built for ${HOST}, supports ${TARGET}". Sensible values are
1094 @@ -211,10 +218,17 @@
1095
1096 #########################################################################
1097
1098 +AFLAGS := $(AFLAGS) $(IFX_CFLAGS)
1099 +CFLAGS := $(CFLAGS) $(IFX_CFLAGS)
1100 +CPPFLAGS := $(CPPFLAGS) $(IFX_CFLAGS)
1101 +
1102 +#########################################################################
1103 +
1104 export CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
1105 AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
1106 MAKE
1107 -export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
1108 +#export UBOOT_RAM_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
1109 +export UBOOT_RAM_TEXT_BASE BOOTSTRAP_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
1110
1111 #########################################################################
1112
1113 --- a/drivers/Makefile
1114 +++ b/drivers/Makefile
1115 @@ -50,14 +50,14 @@
1116 videomodes.o w83c553f.o \
1117 ks8695eth.o \
1118 pxa_pcmcia.o mpc8xx_pcmcia.o tqm8xx_pcmcia.o \
1119 - rpx_pcmcia.o
1120 + rpx_pcmcia.o ifx_sw.o
1121
1122 SRCS := $(COBJS:.o=.c)
1123 OBJS := $(addprefix $(obj),$(COBJS))
1124
1125 all: $(LIB)
1126
1127 -$(LIB): $(obj).depend $(OBJS)
1128 +$(LIB): $(OBJS)
1129 $(AR) $(ARFLAGS) $@ $(OBJS)
1130
1131 #########################################################################
1132 --- a/include/asm-mips/mipsregs.h
1133 +++ b/include/asm-mips/mipsregs.h
1134 @@ -48,6 +48,7 @@
1135 #define CP0_CAUSE $13
1136 #define CP0_EPC $14
1137 #define CP0_PRID $15
1138 +#define CP0_EBASE $15,1
1139 #define CP0_CONFIG $16
1140 #define CP0_LLADDR $17
1141 #define CP0_WATCHLO $18
1142 @@ -330,11 +331,32 @@
1143 # define KSU_USER 0x00000010
1144 # define KSU_SUPERVISOR 0x00000008
1145 # define KSU_KERNEL 0x00000000
1146 +#ifdef CONFIG_DANUBE /* MIPS 24KE */
1147 +/* bits 5 & 6 & 7: reserved */
1148 +/* bits 8~15: IM0~7 */
1149 +/* bits 16: reserved */
1150 +#define ST0_CEE 0x00020000
1151 +/* bits 18: always 0 */
1152 +#define ST0_NMI 0x00080000
1153 +#define ST0_SR 0x00100000
1154 +#define ST0_TS 0x00200000
1155 +#define ST0_BEV 0x00400000
1156 +/* bits 23: reserved */
1157 +#define ST0_MX 0x01000000
1158 +#define ST0_RE 0x02000000
1159 +#define ST0_FR 0x04000000
1160 +#define ST0_RP 0x08000000
1161 +#define ST0_CU0 0x10000000
1162 +#define ST0_CU1 0x20000000
1163 +#define ST0_CU2 0x40000000
1164 +#define ST0_CU3 0x80000000
1165 +#else
1166 #define ST0_UX 0x00000020
1167 #define ST0_SX 0x00000040
1168 #define ST0_KX 0x00000080
1169 #define ST0_DE 0x00010000
1170 #define ST0_CE 0x00020000
1171 +#endif
1172
1173 /*
1174 * Bitfields in the R[23]000 cp0 status register.
1175 @@ -471,6 +493,14 @@
1176 #define CAUSEF_BD (1 << 31)
1177
1178 /*
1179 + * Bits in the coprocessor 0 EBase register
1180 + */
1181 +#define EBASEB_CPUNUM 0
1182 +#define EBASEF_CPUNUM (0x3ff << EBASEB_CPUNUM)
1183 +#define EBASEB_EXPBASE 12
1184 +#define EBASEF_EXPBASE (0x3ffff << EBASEB_EXPBASE)
1185 +
1186 +/*
1187 * Bits in the coprozessor 0 config register.
1188 */
1189 #define CONF_CM_CACHABLE_NO_WA 0
1190 @@ -544,4 +574,10 @@
1191 #define CEB_KERNEL 2 /* Count events in kernel mode EXL = ERL = 0 */
1192 #define CEB_EXL 1 /* Count events with EXL = 1, ERL = 0 */
1193
1194 +/*
1195 + * Bits in ErrCtl register
1196 + */
1197 +#define ECCB_WST 29
1198 +#define ECCF_WST (0x1 << ECCB_WST)
1199 +
1200 #endif /* _ASM_MIPSREGS_H */
1201 --- a/include/cmd_confdefs.h
1202 +++ b/include/cmd_confdefs.h
1203 @@ -94,6 +94,7 @@
1204 #define CFG_CMD_EXT2 0x1000000000000000ULL /* EXT2 Support */
1205 #define CFG_CMD_SNTP 0x2000000000000000ULL /* SNTP support */
1206 #define CFG_CMD_DISPLAY 0x4000000000000000ULL /* Display support */
1207 +#define CFG_CMD_DHRYSTONE 0x8000000000000000ULL /* Dhrystone benchmark support */
1208
1209 #define CFG_CMD_ALL 0xFFFFFFFFFFFFFFFFULL /* ALL commands */
1210
1211 @@ -141,6 +142,7 @@
1212 CFG_CMD_SPI | \
1213 CFG_CMD_UNIVERSE | \
1214 CFG_CMD_USB | \
1215 + CFG_CMD_DHRYSTONE | \
1216 CFG_CMD_VFD )
1217
1218 /* Default configuration
1219 --- /dev/null
1220 +++ b/include/config.h
1221 @@ -0,0 +1,2 @@
1222 +/* Automatically generated - do not edit */
1223 +#include <configs/danube.h>
1224 --- /dev/null
1225 +++ b/include/config.mk
1226 @@ -0,0 +1,3 @@
1227 +ARCH = mips
1228 +CPU = mips
1229 +BOARD = danube
1230 --- a/include/flash.h
1231 +++ b/include/flash.h
1232 @@ -79,7 +79,7 @@
1233 extern unsigned long flash_init (void);
1234 extern void flash_print_info (flash_info_t *);
1235 extern int flash_erase (flash_info_t *, int, int);
1236 -extern int flash_sect_erase (ulong addr_first, ulong addr_last);
1237 +extern int flash_sect_erase (ulong addr_first, ulong addr_last, unsigned int bPartialErase);
1238 extern int flash_sect_protect (int flag, ulong addr_first, ulong addr_last);
1239
1240 /* common/flash.c */
1241 @@ -299,6 +299,10 @@
1242 #define TOSH_ID_FVT160 0xC2 /* TC58FVT160 ID (16 M, top ) */
1243 #define TOSH_ID_FVB160 0x43 /* TC58FVT160 ID (16 M, bottom ) */
1244
1245 +#define MX_ID_29LV320AB 0x22A822A8 /* MXIC MX29LV320AB ID (32 M, bottom ) joelin */
1246 +#define MX_ID_29LV160BB 0x22492249 /* MXIC MX29LV160BB ID (16 M, bottom ) joelin */
1247 +#define MX_ID_29LV640BB 0x22cb22cb /* MXIC MX29LV640BB ID (64 M, bottom ) joelin */
1248 +
1249 /*-----------------------------------------------------------------------
1250 * Internal FLASH identification codes
1251 *
1252 @@ -422,6 +426,10 @@
1253 #define FLASH_S29GL064M 0x00F0 /* Spansion S29GL064M-R6 */
1254 #define FLASH_S29GL128N 0x00F1 /* Spansion S29GL128N */
1255
1256 +#define FLASH_29LV320AB 0x00B0 /* MXIC MX29LV320AB( 32M = 4M x 16 ) joelin 10/07/2004*/
1257 +#define FLASH_29LV160BB 0x00B1 /* MXIC MX29LV160BB( 16M = 2M x 16 ) joelin 11/22/2004*/
1258 +#define FLASH_29LV640BB 0x00B2 /* MXIC MX29LV640BB( 64M = 8M x 16 ) liupeng*/
1259 +
1260 #define FLASH_UNKNOWN 0xFFFF /* unknown flash type */
1261
1262
1263 --- a/include/image.h
1264 +++ b/include/image.h
1265 @@ -132,6 +132,7 @@
1266 #define IH_COMP_NONE 0 /* No Compression Used */
1267 #define IH_COMP_GZIP 1 /* gzip Compression Used */
1268 #define IH_COMP_BZIP2 2 /* bzip2 Compression Used */
1269 +#define IH_COMP_LZMA 3 /* lzma Compression Used */
1270
1271 #define IH_MAGIC 0x27051956 /* Image Magic Number */
1272 #define IH_NMLEN 32 /* Image Name Length */
1273 --- /dev/null
1274 +++ b/include/syscall.h
1275 @@ -0,0 +1,42 @@
1276 +#ifndef __MON_SYS_CALL_H__
1277 +#define __MON_SYS_CALL_H__
1278 +
1279 +#ifndef __ASSEMBLY__
1280 +
1281 +#include <common.h>
1282 +
1283 +/* These are declarations of system calls available in C code */
1284 +int mon_getc(void);
1285 +int mon_tstc(void);
1286 +void mon_putc(const char);
1287 +void mon_puts(const char*);
1288 +void mon_printf(const char* fmt, ...);
1289 +void mon_install_hdlr(int, interrupt_handler_t*, void*);
1290 +void mon_free_hdlr(int);
1291 +void *mon_malloc(size_t);
1292 +void mon_free(void*);
1293 +void mon_udelay(unsigned long);
1294 +unsigned long mon_get_timer(unsigned long);
1295 +
1296 +#endif /* ifndef __ASSEMBLY__ */
1297 +
1298 +#define NR_SYSCALLS 11 /* number of syscalls */
1299 +
1300 +
1301 +/*
1302 + * Make sure these functions are in the same order as they
1303 + * appear in the "examples/syscall.S" file !!!
1304 + */
1305 +#define SYSCALL_GETC 0
1306 +#define SYSCALL_TSTC 1
1307 +#define SYSCALL_PUTC 2
1308 +#define SYSCALL_PUTS 3
1309 +#define SYSCALL_PRINTF 4
1310 +#define SYSCALL_INSTALL_HDLR 5
1311 +#define SYSCALL_FREE_HDLR 6
1312 +#define SYSCALL_MALLOC 7
1313 +#define SYSCALL_FREE 8
1314 +#define SYSCALL_UDELAY 9
1315 +#define SYSCALL_GET_TIMER 10
1316 +
1317 +#endif
1318 --- /dev/null
1319 +++ b/include/version_autogenerated.h
1320 @@ -0,0 +1 @@
1321 +#define U_BOOT_VERSION "U-Boot 1.1.5-IFX-LXDB-g71af1545"
1322 --- /dev/null
1323 +++ b/ld_uboot.conf
1324 @@ -0,0 +1,8 @@
1325 +TAG_DWNLD()
1326 +{
1327 + 0xA0B00000 "u-boot.bin" /* Download u-boot image */
1328 +};
1329 +TAG_START()
1330 +{
1331 + 0xA0B00000
1332 +}; /* Start u-boot image */
1333 --- a/lib_generic/Makefile
1334 +++ b/lib_generic/Makefile
1335 @@ -28,7 +28,7 @@
1336 COBJS = bzlib.o bzlib_crctable.o bzlib_decompress.o \
1337 bzlib_randtable.o bzlib_huffman.o \
1338 crc32.o ctype.o display_options.o ldiv.o \
1339 - string.o vsprintf.o zlib.o
1340 + string.o vsprintf.o zlib.o LzmaDecode.o LzmaWrapper.o
1341
1342 SRCS := $(COBJS:.o=.c)
1343 OBJS := $(addprefix $(obj),$(COBJS))
1344 --- a/lib_mips/board.c
1345 +++ b/lib_mips/board.c
1346 @@ -29,6 +29,25 @@
1347 #include <net.h>
1348 #include <environment.h>
1349
1350 +#ifdef CFG_HEAD_CODE
1351 +#undef CONFIG_MICROBZIP2
1352 +
1353 +#ifdef CONFIG_BZIP2
1354 +#include <bzlib.h>
1355 +#endif
1356 +
1357 +#ifdef CONFIG_MICROBZIP2
1358 +#include <micro_bzlib.h>
1359 +#endif
1360 +
1361 +#ifdef CONFIG_LZMA
1362 +#include <LzmaWrapper.h>
1363 +#endif
1364 +
1365 +#include <image.h>
1366 +#include "head.h"
1367 +#endif //CFG_HEAD_CODE
1368 +
1369 DECLARE_GLOBAL_DATA_PTR;
1370
1371 #if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
1372 @@ -39,8 +58,6 @@
1373 #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
1374 #endif
1375
1376 -#undef DEBUG
1377 -
1378 extern int timer_init(void);
1379
1380 extern int incaip_set_cpuclk(void);
1381 @@ -79,6 +96,25 @@
1382 mem_malloc_end - mem_malloc_start);
1383 }
1384
1385 +#ifdef CFG_HEAD_CODE
1386 +void *malloc(unsigned int size) {
1387 + if(size < (mem_malloc_end - mem_malloc_start)) {
1388 + mem_malloc_start += size;
1389 + //printf("malloc : size required = 0x%08lx and pointer = 0x%08lx\n",size,mem_malloc_start - size);
1390 + return (void *)(mem_malloc_start - size);
1391 + }
1392 + return NULL;
1393 +}
1394 +
1395 +void *realloc(void *src,unsigned int size) {
1396 + return NULL;
1397 +}
1398 +
1399 +void free(void *src) {
1400 + return;
1401 +}
1402 +#endif //CFG_HEAD_CODE
1403 +
1404 void *sbrk (ptrdiff_t increment)
1405 {
1406 ulong old = mem_malloc_brk;
1407 @@ -99,7 +135,11 @@
1408 #else
1409 int board_type = 0; /* use dummy arg */
1410 #endif
1411 +#ifdef CONFIG_USE_DDR_RAM
1412 + puts ("DDR-DRAM: ");
1413 +#else
1414 puts ("DRAM: ");
1415 +#endif
1416
1417 if ((gd->ram_size = initdram (board_type)) > 0) {
1418 print_size (gd->ram_size, "\n");
1419 @@ -116,26 +156,29 @@
1420 return (0);
1421 }
1422
1423 +#ifndef CFG_HEAD_CODE
1424 static void display_flash_config(ulong size)
1425 {
1426 puts ("Flash: ");
1427 print_size (size, "\n");
1428 }
1429 -
1430 +#endif
1431
1432 static int init_baudrate (void)
1433 {
1434 +#ifndef CFG_HEAD_CODE
1435 char tmp[64]; /* long enough for environment variables */
1436 int i = getenv_r ("baudrate", tmp, sizeof (tmp));
1437
1438 gd->baudrate = (i > 0)
1439 ? (int) simple_strtoul (tmp, NULL, 10)
1440 : CONFIG_BAUDRATE;
1441 -
1442 +#else //CFG_HEAD_CODE
1443 + gd->baudrate = CONFIG_BAUDRATE;
1444 +#endif //CFG_HEAD_CODE
1445 return (0);
1446 }
1447
1448 -
1449 /*
1450 * Breath some life into the board...
1451 *
1452 @@ -160,7 +203,9 @@
1453
1454 init_fnc_t *init_sequence[] = {
1455 timer_init,
1456 +#ifndef CFG_HEAD_CODE
1457 env_init, /* initialize environment */
1458 +#endif //CFG_HEAD_CODE
1459 #ifdef CONFIG_INCA_IP
1460 incaip_set_cpuclk, /* set cpu clock according to environment variable */
1461 #endif
1462 @@ -179,7 +224,11 @@
1463 gd_t gd_data, *id;
1464 bd_t *bd;
1465 init_fnc_t **init_fnc_ptr;
1466 +#ifdef CFG_HEAD_CODE
1467 + ulong addr, addr_sp, len = (ulong)&uboot_end - CFG_HEAD_BASE;
1468 +#else //CFG_HEAD_CODE
1469 ulong addr, addr_sp, len = (ulong)&uboot_end - CFG_MONITOR_BASE;
1470 +#endif //CFG_HEAD_CODE
1471 ulong *s;
1472 #ifdef CONFIG_PURPLE
1473 void copy_code (ulong);
1474 @@ -278,7 +327,8 @@
1475 #ifdef CONFIG_PURPLE
1476 copy_code(addr);
1477 #endif
1478 -
1479 +
1480 + puts("\n relocate_code start");
1481 relocate_code (addr_sp, id, addr);
1482
1483 /* NOTREACHED - relocate_code() does not return */
1484 @@ -292,7 +342,93 @@
1485 *
1486 ************************************************************************
1487 */
1488 +#ifdef CFG_HEAD_CODE
1489 +
1490 +extern void print_image_hdr (image_header_t *hdr);
1491 +extern void jump_unconditional (ulong addr);
1492 +
1493 +void board_init_r (gd_t *id, ulong dest_addr) {
1494 + int i;
1495 + ulong addr;
1496 + ulong data, len, checksum;
1497 + ulong *len_ptr;
1498 + image_header_t header;
1499 + image_header_t *hdr = &header;
1500 + unsigned int destLen;
1501
1502 + puts("\n relocate code finish.\n");
1503 +
1504 + /* initialize malloc() area */
1505 + mem_malloc_init();
1506 +
1507 + addr = CFG_HEAD_BASE + CFG_UBOOT_OFFSET;
1508 + memmove (&header, (char *)addr, sizeof(image_header_t));
1509 +
1510 + if (ntohl(hdr->ih_magic) != IH_MAGIC) {
1511 + printf ("Bad Magic Number at address 0x%08lx\n",addr);
1512 + return;
1513 + }
1514 +
1515 + data = (ulong)&header;
1516 + len = sizeof(image_header_t);
1517 +
1518 + checksum = ntohl(hdr->ih_hcrc);
1519 + hdr->ih_hcrc = 0;
1520 + if (crc32 (0, (char *)data, len) != checksum) {
1521 + printf ("Bad Header Checksum\n");
1522 + return;
1523 + }
1524 +
1525 + print_image_hdr (hdr);
1526 +
1527 + data = addr + sizeof(image_header_t);
1528 + len = ntohl(hdr->ih_size);
1529 + len_ptr = (ulong *)data;
1530 +
1531 + debug ("Disabling all the interrupts\n");
1532 + disable_interrupts();
1533 +
1534 + debug (" Uncompressing UBoot Image ... \n" );
1535 + /*
1536 + * If we've got less than 4 MB of malloc() space,
1537 + * use slower decompression algorithm which requires
1538 + * at most 2300 KB of memory.
1539 + */
1540 + destLen = 0x0;
1541 +
1542 +#ifdef CONFIG_BZIP2
1543 + i = BZ2_bzBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
1544 + 0x400000, (char *)data, len,
1545 + CFG_MALLOC_LEN < (4096 * 1024), 0);
1546 + if (i != BZ_OK) {
1547 + printf ("BUNZIP2 ERROR %d - must RESET board to recover\n", i);
1548 + return;
1549 + }
1550 +#elif CONFIG_MICROBZIP2
1551 + i = micro_bzBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
1552 + &destLen, (char *)data, len,
1553 + CFG_MALLOC_LEN < (4096 * 1024), 0);
1554 + if (i != RETVAL_OK) {
1555 + printf ("MICRO_BUNZIP2 ERROR %d - must RESET board to recover\n", i);
1556 + return;
1557 + }
1558 +#elif CONFIG_LZMA
1559 + i = lzma_inflate ((char *)data, len, (char*)ntohl(hdr->ih_load), &destLen);
1560 + if (i != LZMA_RESULT_OK) {
1561 + printf ("LZMA ERROR %d - must RESET board to recover\n", i);
1562 + return;
1563 + }
1564 +#else
1565 + printf ("NONE Compressing u-boot body!!\n");
1566 + memmove ((void *)ntohl(hdr->ih_load), (uchar *)data, len);
1567 + destLen = len;
1568 +#endif
1569 + debug (" Uncompression completed successfully with destLen %d.\n ",destLen );
1570 + debug ("Head: Jumping to u-boot in the ram at 0x%08lx\n", CFG_MONITOR_BASE);
1571 +
1572 + jump_unconditional(CFG_MONITOR_BASE);
1573 +}
1574 +#else //CFG_HEAD_CODE
1575 void board_init_r (gd_t *id, ulong dest_addr)
1576 {
1577 cmd_tbl_t *cmdtp;
1578 @@ -305,6 +441,8 @@
1579 bd_t *bd;
1580 int i;
1581
1582 + puts("\n relocate code finish.\n");
1583 +
1584 gd = id;
1585 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
1586
1587 @@ -321,10 +459,10 @@
1588 ulong addr;
1589
1590 addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
1591 -#if 0
1592 - printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
1593 +
1594 + debug ("Command \"%s\": 0x%08lx => 0x%08lx\n",
1595 cmdtp->name, (ulong) (cmdtp->cmd), addr);
1596 -#endif
1597 +
1598 cmdtp->cmd =
1599 (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
1600
1601 @@ -424,6 +562,7 @@
1602
1603 /* NOTREACHED - no way out of command loop except booting */
1604 }
1605 +#endif //CFG_HEAD_CODE
1606
1607 void hang (void)
1608 {
1609 --- /dev/null
1610 +++ b/lib_mips/head.h
1611 @@ -0,0 +1,3 @@
1612 +
1613 +//#define CFG_HEAD_LEN 0x00006000
1614 +#define CFG_UBOOT_OFFSET CFG_HEAD_LEN
1615 --- a/lib_mips/time.c
1616 +++ b/lib_mips/time.c
1617 @@ -80,6 +80,17 @@
1618 /*NOP*/;
1619 }
1620
1621 +void mdelay (unsigned long msec)
1622 +{
1623 + int i,j;
1624 + for(i=0;i<msec;i++)
1625 + {
1626 + udelay(1000);
1627 +
1628 + }
1629 +
1630 +}
1631 +
1632 /*
1633 * This function is derived from PowerPC code (read timebase as long long).
1634 * On MIPS it just returns the timer value.
1635 --- a/net/eth.c
1636 +++ b/net/eth.c
1637 @@ -25,6 +25,9 @@
1638 #include <command.h>
1639 #include <net.h>
1640 #include <miiphy.h>
1641 +#if defined(CONFIG_IFX_MIPS)
1642 +# include "ifx_eth.c"
1643 +#endif
1644
1645 #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI)
1646
1647 @@ -54,6 +57,9 @@
1648 extern int skge_initialize(bd_t*);
1649 extern int tsec_initialize(bd_t*, int, char *);
1650 extern int npe_initialize(bd_t *);
1651 +#if defined(CONFIG_IFX_MIPS)
1652 + IFX_ETH_INITIALIZE_EXTERN
1653 +#endif
1654
1655 static struct eth_device *eth_devices, *eth_current;
1656
1657 @@ -235,7 +241,9 @@
1658 #if defined(CONFIG_RTL8169)
1659 rtl8169_initialize(bis);
1660 #endif
1661 -
1662 +#if defined(CONFIG_IFX_MIPS)
1663 + IFX_ETH_INITIALIZE(bis)
1664 +#endif
1665 if (!eth_devices) {
1666 puts ("No ethernet found.\n");
1667 } else {
1668 --- a/tools/Makefile
1669 +++ b/tools/Makefile
1670 @@ -23,7 +23,7 @@
1671
1672 BIN_FILES = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
1673
1674 -OBJ_LINKS = environment.o crc32.o
1675 +OBJ_LINKS = environment_$(BOARDDIR).o crc32_$(BOARDDIR).o
1676 OBJ_FILES = img2srec.o mkimage.o envcrc.o gen_eth_addr.o bmp_logo.o
1677
1678 ifeq ($(ARCH),mips)
1679 @@ -117,7 +117,7 @@
1680 CPPFLAGS = -idirafter $(SRCTREE)/include \
1681 -idirafter $(OBJTREE)/include2 \
1682 -idirafter $(OBJTREE)/include \
1683 - -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
1684 + -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC $(IFX_CFLAGS)
1685 CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
1686 AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
1687 CC = $(HOSTCC)
1688 @@ -126,14 +126,14 @@
1689
1690 all: $(obj).depend $(BINS) $(LOGO_H) subdirs
1691
1692 -$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)environment.o
1693 +$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32_$(BOARDDIR).o $(obj)environment_$(BOARDDIR).o
1694 $(CC) $(CFLAGS) -o $@ $^
1695
1696 $(obj)img2srec$(SFX): $(obj)img2srec.o
1697 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
1698 $(STRIP) $@
1699
1700 -$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o
1701 +$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32_$(BOARDDIR).o
1702 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
1703 $(STRIP) $@
1704
1705 @@ -160,7 +160,7 @@
1706 $(obj)envcrc.o: $(src)envcrc.c
1707 $(CC) -g $(CFLAGS) -c -o $@ $<
1708
1709 -$(obj)crc32.o: $(obj)crc32.c
1710 +$(obj)crc32_$(BOARDDIR).o: $(obj)crc32_$(BOARDDIR).c
1711 $(CC) -g $(CFLAGS) -c -o $@ $<
1712
1713 $(obj)mkimage.o: $(src)mkimage.c
1714 @@ -192,16 +192,16 @@
1715 done
1716 endif
1717
1718 -$(obj)environment.c:
1719 - @rm -f $(obj)environment.c
1720 - ln -s $(src)../common/environment.c $(obj)environment.c
1721 +$(obj)environment_$(BOARDDIR).c:
1722 + @rm -f $(obj)environment_$(BOARDDIR).c
1723 + ln -s $(src)../common/environment_$(BOARDDIR).c $(obj)environment_$(BOARDDIR).c
1724
1725 -$(obj)environment.o: $(obj)environment.c
1726 +$(obj)environment_$(BOARDDIR).o: $(obj)environment_$(BOARDDIR).c
1727 $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<
1728
1729 -$(obj)crc32.c:
1730 - @rm -f $(obj)crc32.c
1731 - ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
1732 +$(obj)crc32_$(BOARDDIR).c:
1733 + @rm -f $(obj)crc32_$(BOARDDIR).c
1734 + ln -s $(src)../lib_generic/crc32_$(BOARDDIR).c $(obj)crc32_$(BOARDDIR).c
1735
1736 $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
1737 $(obj)./bmp_logo $(LOGO_BMP) >$@
1738 --- a/tools/mkimage.c
1739 +++ b/tools/mkimage.c
1740 @@ -28,6 +28,7 @@
1741 #ifndef __WIN32__
1742 #include <netinet/in.h> /* for host / network byte order conversions */
1743 #endif
1744 +#include <sys/types.h>
1745 #include <sys/mman.h>
1746 #include <sys/stat.h>
1747 #include <time.h>
1748 @@ -138,6 +139,7 @@
1749 { IH_COMP_NONE, "none", "uncompressed", },
1750 { IH_COMP_BZIP2, "bzip2", "bzip2 compressed", },
1751 { IH_COMP_GZIP, "gzip", "gzip compressed", },
1752 + { IH_COMP_LZMA, "lzma", "lzma compressed", },
1753 { -1, "", "", },
1754 };
1755
1756 @@ -445,7 +447,7 @@
1757 }
1758
1759 /* We're a bit of paranoid */
1760 -#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
1761 +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
1762 (void) fdatasync (ifd);
1763 #else
1764 (void) fsync (ifd);
1765 @@ -495,7 +497,7 @@
1766 (void) munmap((void *)ptr, sbuf.st_size);
1767
1768 /* We're a bit of paranoid */
1769 -#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
1770 +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
1771 (void) fdatasync (ifd);
1772 #else
1773 (void) fsync (ifd);