summaryrefslogtreecommitdiff
path: root/package/uboot-ifxmips/patches/100-ifx.patch
blob: 01a5884dba2f2b7b5f6e7bc379a2628ed2f10e4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
Index: u-boot-1.1.5/Makefile
===================================================================
--- u-boot-1.1.5.orig/Makefile	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/Makefile	2009-10-04 23:06:03.000000000 +0200
@@ -24,7 +24,7 @@
 VERSION = 1
 PATCHLEVEL = 1
 SUBLEVEL = 5
-EXTRAVERSION =
+EXTRAVERSION = -IFX-LXDB
 U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 VERSION_FILE = $(obj)include/version_autogenerated.h
 
@@ -44,6 +44,25 @@
 # Deal with colliding definitions from tcsh etc.
 VENDOR=
 
+# Default algorithm form compressing u-boot.bin
+ifndef COMPRESS
+COMPRESS=none
+COMPRESS_FILE=$(obj)u-boot.img
+else
+ifeq ($(COMPRESS),lzma)
+COMPRESS_FILE=$(obj)u-boot.limg
+endif
+ifeq ($(COMPRESS),bz2)
+COMPRESS_FILE=$(obj)u-boot.bzimg
+endif
+ifeq ($(COMPRESS),gzip)
+COMPRESS_FILE=$(obj)u-boot.zimg
+endif
+ifeq ($(COMPRESS),none)
+COMPRESS_FILE=$(obj)u-boot.img
+endif
+endif
+
 #########################################################################
 #
 # U-boot build supports producing a object files to the separate external
@@ -164,6 +183,11 @@
 # U-Boot objects....order is important (i.e. start must be first)
 
 OBJS  = cpu/$(CPU)/start.o
+OBJS_BOOTSTRAP  = cpu/$(CPU)/start_bootstrap.o
+
+cpu/$(CPU)/start_bootstrap.S: cpu/$(CPU)/start.S
+	ln -s start.S cpu/$(CPU)/start_bootstrap.S
+
 ifeq ($(CPU),i386)
 OBJS += cpu/$(CPU)/start16.o
 OBJS += cpu/$(CPU)/reset.o
@@ -183,6 +207,7 @@
 endif
 
 OBJS := $(addprefix $(obj),$(OBJS))
+OBJS_BOOTSTRAP := $(addprefix $(obj),$(OBJS_BOOTSTRAP))
 
 LIBS  = lib_generic/libgeneric.a
 LIBS += board/$(BOARDDIR)/lib$(BOARD).a
@@ -206,15 +231,24 @@
 LIBS += $(BOARDLIBS)
 
 LIBS := $(addprefix $(obj),$(LIBS))
+
+LIBS_BOOTSTRAP  = lib_bootstrap/libbootstrap.a
+LIBS_BOOTSTRAP+= board/$(BOARDDIR)/lib$(BOARD).a
+#LIBS_BOOTSTRAP+= board/ifx/libifx.a
+LIBS_BOOTSTRAP+= cpu/$(CPU)/lib$(CPU).a
+
+LIBS_BOOTSTRAP := $(addprefix $(obj),$(LIBS_BOOTSTRAP))
+
 .PHONY : $(LIBS)
+.PHONY : $(obj)lib_bootstrap/libbootstrap.a
 
 # Add GCC lib
 PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
 
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
+	  #examples
 SUBDIRS	= tools \
-	  examples \
 	  post \
 	  post/cpu
 .PHONY : $(SUBDIRS)
@@ -226,14 +260,75 @@
 
 __OBJS := $(subst $(obj),,$(OBJS))
 __LIBS := $(subst $(obj),,$(LIBS))
+__LIBS_BOOTSTRAP := $(subst $(obj),,$(LIBS_BOOTSTRAP))
+
+#__HEAD_OBJS := $(subst $(obj),,$(HEAD_OBJS))
+#__HEAD_LIBS := $(subst $(obj),,$(HEAD_LIBS))
 
 #########################################################################
 #########################################################################
 
 ALL = $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND)
+#IFX_ALL = $(obj)u-boot.ifx $(obj)head.srec $(obj)head.bin $(obj)head $(obj)head.map $(COMPRESS_FILE) $(obj)u-boot.srec
+IFX_ALL = $(obj)u-boot.srec $(obj)u-boot.ifx $(obj)u-boot.lzimg $(obj)System.map $(obj)bootstrap.bin $(obj)System_bootstrap.map
+IFX_BOOTSTRAP = $(obj)bootstrap.bin
 
 all:		$(ALL)
 
+ifx_all:	$(IFX_ALL)
+
+ifx_bootstrap:	$(IFX_BOOTSTRAP)
+
+$(obj)u-boot.ifx: $(obj)bootstrap.bin $(obj)u-boot.lzimg
+		@cat $(obj)bootstrap.bin > $(obj)u-boot.ifx
+		@cat $(obj)u-boot.lzimg >> $(obj)u-boot.ifx
+
+$(obj)u-boot.lzimg: $(obj)u-boot.bin $(obj)System.map
+		@lzma e $(obj)u-boot.bin $(obj)u-boot.lzma
+		$(obj)tools/mkimage -A mips -T firmware -C lzma \
+		-a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
+		-e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
+		-n 'u-boot image' -d $(obj)u-boot.lzma $@
+
+$(obj)ld_uboot.img: $(obj)u-boot.ifx $(obj)u-boot.lzimg $(obj)bootstrap.bin
+		@  cp -f $(obj)u-boot.ifx $(obj)u-boot.bin
+		@ ./mkbootimg.incaip2 $(obj)ld_uboot.img < ld_uboot.conf
+
+$(obj)u-boot.zimg:	$(obj)u-boot.bin $(obj)System.map
+		gzip $(obj)u-boot.bin
+		$(obj)tools/mkimage -A $(ARCH) -T firmware -C gzip \
+		-a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
+		-e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
+		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
+			 sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
+		-d u-boot.gz $@
+
+$(obj)u-boot.bzimg:	$(obj)u-boot.bin $(obj)System.map
+		bzip $(obj)u-boot.bin
+		$(obj)tools/mkimage -A $(ARCH) -T firmware -C bzip2 \
+		-a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
+		-e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
+		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
+			sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
+		-d u-boot.bz2 $@
+
+$(obj)u-boot.limg:	$(obj)u-boot.bin $(obj)System.map
+		@lzma e $(obj)u-boot.bin $(obj)u-boot.lzma
+		$(obj)tools/mkimage -A $(ARCH) -T firmware -C lzma \
+		-a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
+		-e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
+		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
+			sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
+		-d u-boot.lzma $@
+
+$(obj)u-boot.img:	$(obj)u-boot.bin $(obj)System.map
+		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
+		-a 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
+		-e 0x$(shell grep "T _start" $(obj)System.map | awk '{ printf "%s", $$1 }') \
+		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
+			sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
+		-d u-boot.bin $@
+
 $(obj)u-boot.hex:	$(obj)u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
 
@@ -243,28 +338,33 @@
 $(obj)u-boot.bin:	$(obj)u-boot
 		$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
 
-$(obj)u-boot.img:	$(obj)u-boot.bin
-		./tools/mkimage -A $(ARCH) -T firmware -C none \
-		-a $(TEXT_BASE) -e 0 \
-		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
-			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
-		-d $< $@
-
 $(obj)u-boot.dis:	$(obj)u-boot
 		$(OBJDUMP) -d $< > $@
 
-$(obj)u-boot:		depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
+$(obj)u-boot:	depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
 		UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
 		cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
 			--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
 			-Map u-boot.map -o u-boot
 
+$(obj)bootstrap.bin:	$(obj)bootstrap
+		$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
+
+$(obj)bootstrap :		depend version $(SUBDIRS) $(OBJS_BOOTSTRAP) $(LIBS_BOOTSTRAP) $(LDSCRIPT_BOOTSTRAP)
+		UNDEF_SYM=`$(OBJDUMP) -x $(LIBS_BOOTSTRAP) |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
+		$(LD) $(LDFLAGS_BOOTSTRAP) $$UNDEF_SYM $(OBJS_BOOTSTRAP) \
+			--start-group $(__LIBS_BOOTSTRAP) --end-group $(PLATFORM_LIBS) \
+			-Map bootstrap.map -o bootstrap
+
 $(OBJS):
 		$(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
 
 $(LIBS):
 		$(MAKE) -C $(dir $(subst $(obj),,$@))
 
+$(obj)lib_bootstrap/libbootstrap.a:
+		$(MAKE) -C $(dir $(subst $(obj),,$@))
+
 $(SUBDIRS):
 		$(MAKE) -C $@ all
 
@@ -310,7 +410,12 @@
 $(obj)System.map:	$(obj)u-boot
 		@$(NM) $< | \
 		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
-		sort > $(obj)System.map
+		sort > $@
+
+$(obj)System_bootstrap.map:	$(obj)bootstrap
+		@$(NM) $< | \
+		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
+		sort > $@
 
 #########################################################################
 else
@@ -2032,7 +2137,20 @@
 # MIPS
 #========================================================================
 #########################################################################
-## MIPS32 4Kc
+## Infineon MIPS generic u-boot config
+#########################################################################
+danube_config:	unconfig
+	@$(MKCONFIG) $(@:_config=) mips mips danube ifx danube
+
+amazon_config:	unconfig
+	@$(MKCONFIG) $(@:_config=) mips mips amazon
+
+
+incaip2_config:	unconfig
+	@$(MKCONFIG) $(@:_config=) mips mips incaip2
+
+#########################################################################
+## MIPS32 4kc
 #########################################################################
 
 xtract_incaip = $(subst _100MHz,,$(subst _133MHz,,$(subst _150MHz,,$(subst _config,,$1))))
@@ -2254,7 +2372,7 @@
 		| xargs -0 rm -f
 	rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS $(obj)include/version_autogenerated.h
 	rm -fr $(obj)*.*~
-	rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
+	rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL) $(IFX_ALL)
 	rm -f $(obj)tools/crc32.c $(obj)tools/environment.c $(obj)tools/env/crc32.c
 	rm -f $(obj)tools/inca-swap-bytes $(obj)cpu/mpc824x/bedbug_603e.c
 	rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
Index: u-boot-1.1.5/common/cmd_bootm.c
===================================================================
--- u-boot-1.1.5.orig/common/cmd_bootm.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/common/cmd_bootm.c	2009-10-04 23:06:03.000000000 +0200
@@ -31,6 +31,7 @@
 #include <malloc.h>
 #include <zlib.h>
 #include <bzlib.h>
+#include <LzmaWrapper.h>
 #include <environment.h>
 #include <asm/byteorder.h>
 
@@ -79,6 +80,8 @@
 # define CHUNKSZ (64 * 1024)
 #endif
 
+#ifndef CFG_HEAD_CODE
+
 int  gunzip (void *, int, unsigned char *, unsigned long *);
 
 static void *zalloc(void *, unsigned, unsigned);
@@ -341,6 +344,7 @@
 #endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
 		}
 		break;
+#ifndef CONFIG_REMOVE_GZIP
 	case IH_COMP_GZIP:
 		printf ("   Uncompressing %s ... ", name);
 		if (gunzip ((void *)ntohl(hdr->ih_load), unc_len,
@@ -350,6 +354,7 @@
 			do_reset (cmdtp, flag, argc, argv);
 		}
 		break;
+#endif /* CONFIG_REMOVE_GZIP */
 #ifdef CONFIG_BZIP2
 	case IH_COMP_BZIP2:
 		printf ("   Uncompressing %s ... ", name);
@@ -369,6 +374,18 @@
 		}
 		break;
 #endif /* CONFIG_BZIP2 */
+#ifdef CONFIG_LZMA
+	case IH_COMP_LZMA:
+		printf ("   Uncompressing %s ... ", name);
+		i = lzma_inflate ((unsigned char *)data, len, (unsigned char*)ntohl(hdr->ih_load), &unc_len);
+		if (i != LZMA_RESULT_OK) {
+			printf ("LZMA ERROR %d - must RESET board to recover\n", i);
+			SHOW_BOOT_PROGRESS (-6);
+			udelay(100000);
+			do_reset (cmdtp, flag, argc, argv);
+		}
+		break;
+#endif /* CONFIG_LZMA */
 	default:
 		if (iflag)
 			enable_interrupts();
@@ -1176,6 +1193,8 @@
 );
 #endif	/* CFG_CMD_IMLS */
 
+#endif	/* ! CFG_HEAD_CODE */
+
 void
 print_image_hdr (image_header_t *hdr)
 {
@@ -1270,12 +1289,15 @@
 	case IH_COMP_NONE:	comp = "uncompressed";		break;
 	case IH_COMP_GZIP:	comp = "gzip compressed";	break;
 	case IH_COMP_BZIP2:	comp = "bzip2 compressed";	break;
+	case IH_COMP_LZMA:      comp = "lzma compressed";       break;
 	default:		comp = "unknown compression";	break;
 	}
 
 	printf ("%s %s %s (%s)", arch, os, type, comp);
 }
 
+#ifndef CFG_HEAD_CODE
+
 #define	ZALLOC_ALIGNMENT	16
 
 static void *zalloc(void *x, unsigned items, unsigned size)
@@ -1427,3 +1449,5 @@
 }
 
 #endif /* CONFIG_LYNXKDI */
+
+#endif /* ! CFG_HEAD_CODE */
Index: u-boot-1.1.5/common/cmd_flash.c
===================================================================
--- u-boot-1.1.5.orig/common/cmd_flash.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/common/cmd_flash.c	2009-10-04 23:06:03.000000000 +0200
@@ -196,9 +196,17 @@
 }
 
 static int
-flash_fill_sect_ranges (ulong addr_first, ulong addr_last,
-			int *s_first, int *s_last,
-			int *s_count )
+flash_fill_sect_ranges(
+	ulong *addr_first_sect_start,
+	ulong addr_first,
+	ulong *addr_last_sect_end,
+	ulong addr_last,
+	int *s_first,
+	int *s_last,
+	int *bPartialStart,
+	int *bPartialEnd,
+	int *s_count,
+	unsigned int bPartialErase)
 {
 	flash_info_t *info;
 	ulong bank;
@@ -211,9 +219,7 @@
 		s_last [bank] = -1;	/* last  sector to erase	*/
 	}
 
-	for (bank=0,info=&flash_info[0];
-	     (bank < CFG_MAX_FLASH_BANKS) && (addr_first <= addr_last);
-	     ++bank, ++info) {
+	for (bank=0, info=&flash_info[0]; (bank < CFG_MAX_FLASH_BANKS) && (addr_first <= addr_last); ++bank, ++info) {
 		ulong b_end;
 		int sect;
 		short s_end;
@@ -225,7 +231,6 @@
 		b_end = info->start[0] + info->size - 1;	/* bank end addr */
 		s_end = info->sector_count - 1;			/* last sector   */
 
-
 		for (sect=0; sect < info->sector_count; ++sect) {
 			ulong end;	/* last address in current sect	*/
 
@@ -238,11 +243,21 @@
 
 			if (addr_first == info->start[sect]) {
 				s_first[bank] = sect;
+			} else if (addr_first > info->start[sect] && addr_first <= end && bPartialErase) {
+				*addr_first_sect_start = info->start[sect];
+				s_first[bank] = sect;
+				*bPartialStart = 1;
 			}
+
 			if (addr_last  == end) {
 				s_last[bank]  = sect;
+			} else if (addr_last >= info->start[sect] && addr_last < end && bPartialErase) {
+				*addr_last_sect_end = end;
+				s_last[bank] = sect;
+				*bPartialEnd = 1;
 			}
 		}
+
 		if (s_first[bank] >= 0) {
 			if (s_last[bank] < 0) {
 				if (addr_last > b_end) {
@@ -316,6 +331,8 @@
 	struct part_info *part;
 	u8 dev_type, dev_num, pnum;
 #endif
+	unsigned int bPartialErase = 0;
+
 	int rcode = 0;
 
 	if (argc < 2) {
@@ -369,7 +386,7 @@
 	}
 #endif
 
-	if (argc != 3) {
+	if (argc != 4) {
 		printf ("Usage:\n%s\n", cmdtp->usage);
 		return 1;
 	}
@@ -397,11 +414,117 @@
 		return 1;
 	}
 
-	rcode = flash_sect_erase(addr_first, addr_last);
+	printf ("Erase Flash from 0x%08lx to 0x%08lx\n", addr_first, addr_last);
+	if(argc == 4) {
+		bPartialErase = simple_strtoul(argv[3], NULL, 10);
+	}
+
+	rcode = flash_sect_erase(addr_first, addr_last, bPartialErase);
 	return rcode;
 }
 
-int flash_sect_erase (ulong addr_first, ulong addr_last)
+int flerase_Partial(
+	ulong addr_first_sect_start,
+	ulong addr_first,
+	ulong addr_last_sect_end,
+	ulong addr_last,
+	flash_info_t *info,
+	int first_sect,
+	int last_sect,
+	int bFirstPartial,
+	int bLastPartial) {
+	unsigned int firstMemLen = 0;
+	unsigned int lastMemLen = 0;
+	unsigned int sectMemLen = 0;
+	uchar *pSavedFirstMem = NULL;
+	uchar *pSavedLastMem = NULL;
+	uchar *pSavedSectMem = NULL;
+	int bSectPartial = 0;
+	int rt_code = 0;
+
+	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);
+
+	if (bFirstPartial && bLastPartial && (first_sect == last_sect))
+	{
+		ulong b_end = info->start[0] + info->size - 1;
+		ulong end = (first_sect == (info->sector_count - 1)) ? b_end : info->start[first_sect + 1] - 1;
+		sectMemLen = end - info->start[first_sect] + 1;
+		pSavedSectMem = (uchar *)calloc(sectMemLen, sizeof(char));
+		if (pSavedSectMem == NULL)
+		{
+			debug("calloc %u FAILED\n", sectMemLen);
+			rt_code = 1;
+			goto ret;
+		}
+		memset(pSavedSectMem, 0xff, sectMemLen);
+		bSectPartial = 1;
+		memcpy(pSavedSectMem, (uchar *)addr_first_sect_start, addr_first - addr_first_sect_start);
+		memcpy(pSavedSectMem + (addr_last - info->start[first_sect]) + 1, addr_last + 1, end - addr_last);
+	}
+	else
+	{
+		if (bFirstPartial){
+			firstMemLen = addr_first - addr_first_sect_start + 1;
+			pSavedFirstMem = (uchar *)calloc(firstMemLen,sizeof(char));
+			memcpy(pSavedFirstMem,(uchar *)addr_first_sect_start,firstMemLen - 1);
+		}
+		if (bLastPartial){
+			lastMemLen = addr_last_sect_end - addr_last + 1;
+			pSavedLastMem = (uchar *)calloc(lastMemLen,sizeof(char));
+			memcpy(pSavedLastMem,(uchar *)addr_last + 1,lastMemLen - 1);
+		}
+	}
+
+	if (bFirstPartial){
+		if(flash_erase (info, first_sect, first_sect)) {
+			printf("%s ... Couldn't erase sector %d\n", __FUNCTION__, first_sect);
+			rt_code = 1;
+			goto ret;
+		}
+		debug("%s ... erase sector %d done!\n", __FUNCTION__, first_sect);
+	}
+
+	if (bLastPartial && first_sect != last_sect){
+		if(flash_erase (info, last_sect, last_sect)) {
+			printf("%s ... Couldn't erase sector %d\n", __FUNCTION__, last_sect);
+			rt_code = 1;
+			goto ret;
+		}
+		debug("%s ... erase sector %d done!\n", __FUNCTION__, last_sect);
+	}
+
+	if (bFirstPartial && bLastPartial && (first_sect == last_sect))
+	{
+		flash_write(pSavedSectMem, (uchar *)addr_first_sect_start, sectMemLen);
+		debug("flash_write from 0x%08x with len %u\n", addr_first_sect_start, sectMemLen);
+	}
+	else
+	{
+		if (bFirstPartial){
+			if(flash_write(pSavedFirstMem,(uchar *)addr_first_sect_start,firstMemLen - 1)) {
+				printf("%s ... Couldn't write at 0x%08lx length %d\n", __FUNCTION__, addr_first_sect_start,firstMemLen - 1);
+				rt_code = 1;
+				goto ret;
+			}
+		}
+		if (bLastPartial){
+			if(flash_write(pSavedLastMem,(uchar *)addr_last + 1,lastMemLen - 1)) {
+				printf("%s ... Couldn't write at 0x%08lx length %d\n", __FUNCTION__, addr_last, lastMemLen - 1);
+				rt_code = 1;
+			}
+		}
+	}
+ret:
+	if (bFirstPartial)
+		free(pSavedFirstMem);
+	if (bLastPartial)
+		free(pSavedLastMem);
+	if (bSectPartial)
+		free(pSavedSectMem);
+	return rt_code;
+}
+
+int flash_sect_erase (ulong addr_first, ulong addr_last, unsigned int bPartialErase)
 {
 	flash_info_t *info;
 	ulong bank;
@@ -413,27 +536,66 @@
 	int erased = 0;
 	int planned;
 	int rcode = 0;
-
-	rcode = flash_fill_sect_ranges (addr_first, addr_last,
-					s_first, s_last, &planned );
+	int bPartialStart = 0;		// Start sector has to be erased partially
+	int bPartialEnd = 0;		// End sector has to be erased partially
+	ulong addr_first_sect_start = 0;// Sector start address of location addr_start
+	ulong addr_last_sect_end = 0;	// Sector end address of location addr_last
+
+	rcode = flash_fill_sect_ranges (
+			&addr_first_sect_start,
+			addr_first,
+			&addr_last_sect_end,
+			addr_last,
+			s_first,
+			s_last,
+			&bPartialStart,
+			&bPartialEnd,
+			&planned,
+			bPartialErase );
 
 	if (planned && (rcode == 0)) {
-		for (bank=0,info=&flash_info[0];
-		     (bank < CFG_MAX_FLASH_BANKS) && (rcode == 0);
-		     ++bank, ++info) {
+		for (bank=0, info=&flash_info[0]; (bank < CFG_MAX_FLASH_BANKS) && (rcode == 0); ++bank, ++info) {
+			ulong b_end = info->start[0] + info->size - 1;	/* bank end addr */
 			if (s_first[bank]>=0) {
-				erased += s_last[bank] - s_first[bank] + 1;
-				debug ("Erase Flash from 0x%08lx to 0x%08lx "
-					"in Bank # %ld ",
-					info->start[s_first[bank]],
-					(s_last[bank] == info->sector_count) ?
-						info->start[0] + info->size - 1:
-						info->start[s_last[bank]+1] - 1,
-					bank+1);
-				rcode = flash_erase (info, s_first[bank], s_last[bank]);
+				if(bPartialErase) {
+					rcode = flerase_Partial(
+							addr_first_sect_start,
+							addr_first,
+							addr_last_sect_end,
+							addr_last,
+							info,
+							s_first[bank],
+							s_last[bank],
+							bPartialStart,
+							bPartialEnd);
+				}
+
+				//Erase full sectores
+				if (bPartialStart)
+					s_first[bank] += 1;
+				if (bPartialEnd)
+					s_last[bank] -= 1;
+				if (s_last[bank] >= s_first[bank]) {
+					erased += s_last[bank] - s_first[bank] + 1;
+					debug ("Erase Flash from 0x%08lx to 0x%08lx in Bank # %ld ",
+						info->start[s_first[bank]],
+						(s_last[bank] == info->sector_count) ?
+							info->start[0] + info->size - 1:
+							info->start[s_last[bank]+1] - 1,
+						bank + 1);
+					rcode = flash_erase (info, s_first[bank], s_last[bank]);
+				}
 			}
 		}
-		printf ("Erased %d sectors\n", erased);
+
+		if (erased && !bPartialErase) {
+			printf ("Erased %d sectors\n", erased);
+		} else if (bPartialErase){
+			printf ("Partial erased from 0x%08lx to 0x%08lx\n", addr_first, addr_last);
+		} else {
+			printf ("Error: start and/or end address not on sector boundary\n");
+			rcode = 1;
+		}
 	} else if (rcode == 0) {
 		puts ("Error: start and/or end address"
 			" not on sector boundary\n");
@@ -629,8 +791,22 @@
 	int protected, i;
 	int planned;
 	int rcode;
-
-	rcode = flash_fill_sect_ranges( addr_first, addr_last, s_first, s_last, &planned );
+	int bPartialStart = 0;		// Start sector has to be erased partially
+	int bPartialEnd = 0;		// End sector has to be erased partially
+	ulong addr_first_sect_start = 0;// Sector start address of location addr_start
+	ulong addr_last_sect_end = 0;	// Sector end address of location addr_last
+
+	rcode = flash_fill_sect_ranges (
+			&addr_first_sect_start,
+			addr_first,
+			&addr_last_sect_end,
+			addr_last,
+			s_first,
+			s_last,
+			&bPartialStart,
+			&bPartialEnd,
+			&planned,
+			1 );
 
 	protected = 0;
 
@@ -690,7 +866,7 @@
 );
 
 U_BOOT_CMD(
-	erase,   3,   1,  do_flerase,
+	erase,   4,   1,  do_flerase,
 	"erase   - erase FLASH memory\n",
 	"start end\n"
 	"    - erase FLASH from addr 'start' to addr 'end'\n"
Index: u-boot-1.1.5/common/cmd_nvedit.c
===================================================================
--- u-boot-1.1.5.orig/common/cmd_nvedit.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/common/cmd_nvedit.c	2009-10-04 23:06:03.000000000 +0200
@@ -540,8 +540,19 @@
 	extern char * env_name_spec;
 
 	printf ("Saving Environment to %s...\n", env_name_spec);
-
+#if 1
+	if(saveenv() == 0) {
+#ifdef UBOOT_ENV_COPY
+		saveenv_copy();
+#else
+		;
+#endif //UBOOT_ENV_COPY
+	} else
+		return 1;
+	return 0;
+#else
 	return (saveenv() ? 1 : 0);
+#endif
 }
 
 
Index: u-boot-1.1.5/common/console.c
===================================================================
--- u-boot-1.1.5.orig/common/console.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/common/console.c	2009-10-04 23:06:03.000000000 +0200
@@ -324,7 +324,7 @@
 #endif
 
 /** U-Boot INIT FUNCTIONS *************************************************/
-
+#ifndef CFG_HEAD_CODE
 int console_assign (int file, char *devname)
 {
 	int flag, i;
@@ -357,7 +357,7 @@
 
 	return -1;
 }
-
+#endif	//CFG_HEAD_CODE
 /* Called before relocation - use serial functions */
 int console_init_f (void)
 {
@@ -392,6 +392,7 @@
 }
 #endif /* CFG_CONSOLE_IS_IN_ENV || CONFIG_SPLASH_SCREEN */
 
+#ifndef CFG_HEAD_CODE
 #ifdef CFG_CONSOLE_IS_IN_ENV
 /* Called after the relocation - use desired console functions */
 int console_init_r (void)
@@ -570,3 +571,4 @@
 }
 
 #endif /* CFG_CONSOLE_IS_IN_ENV */
+#endif	//CFG_HEAD_CODE
Index: u-boot-1.1.5/common/devices.c
===================================================================
--- u-boot-1.1.5.orig/common/devices.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/common/devices.c	2009-10-04 23:06:03.000000000 +0200
@@ -39,6 +39,7 @@
 list_t devlist = 0;
 device_t *stdio_devices[] = { NULL, NULL, NULL };
 char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
+#ifndef CFG_HEAD_CODE
 
 #if defined(CONFIG_SPLASH_SCREEN) && !defined(CFG_DEVICE_NULLDEV)
 #define	CFG_DEVICE_NULLDEV	1
@@ -214,3 +215,5 @@
 
 	return 0;
 }
+#endif //CFG_HEAD_CODE
+
Index: u-boot-1.1.5/common/env_common.c
===================================================================
--- u-boot-1.1.5.orig/common/env_common.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/common/env_common.c	2009-10-04 23:06:03.000000000 +0200
@@ -219,7 +219,9 @@
 	 * We must allocate a buffer for the environment
 	 */
 	env_ptr = (env_t *)malloc (CFG_ENV_SIZE);
-	DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
+	if(!env_ptr)
+		DEBUGF ("malloc env_ptr error!!\n");
+	DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__, __LINE__, env_ptr);
 #endif
 
 	/*
@@ -227,6 +229,10 @@
 	 */
 	env_get_char = env_get_char_memory;
 
+	//leejack
+	DEBUGF ("%s[%d] gd->env_valid=%d\n", __FUNCTION__, __LINE__, gd->env_valid);
+	DEBUGF ("%s[%d] CFG_ENV_SIZE=%d\n", __FUNCTION__, __LINE__, CFG_ENV_SIZE);
+
 	if (gd->env_valid == 0) {
 #if defined(CONFIG_GTH)	|| defined(CFG_ENV_IS_NOWHERE)	/* Environment not changable */
 		puts ("Using default environment\n\n");
@@ -242,18 +248,17 @@
 		}
 
 		memset (env_ptr, 0, sizeof(env_t));
-		memcpy (env_ptr->data,
-			default_environment,
-			sizeof(default_environment));
+		memcpy (env_ptr->data, default_environment, sizeof(default_environment));
+
 #ifdef CFG_REDUNDAND_ENVIRONMENT
 		env_ptr->flags = 0xFF;
 #endif
 		env_crc_update ();
 		gd->env_valid = 1;
-	}
-	else {
+	} else {
 		env_relocate_spec ();
 	}
+
 	gd->env_addr = (ulong)&(env_ptr->data);
 
 #ifdef CONFIG_AMIGAONEG3SE
Index: u-boot-1.1.5/common/env_flash.c
===================================================================
--- u-boot-1.1.5.orig/common/env_flash.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/common/env_flash.c	2009-10-04 23:06:03.000000000 +0200
@@ -66,7 +66,6 @@
 #endif
 
 #else /* ! ENV_IS_EMBEDDED */
-
 env_t *env_ptr = (env_t *)CFG_ENV_ADDR;
 #ifdef CMD_SAVEENV
 static env_t *flash_addr = (env_t *)CFG_ENV_ADDR;
@@ -201,6 +200,7 @@
 	debug (" %08lX ... %08lX ...",
 		(ulong)&(flash_addr_new->data),
 		sizeof(env_ptr->data)+(ulong)&(flash_addr_new->data));
+
 	if ((rc = flash_write((char *)env_ptr->data,
 			(ulong)&(flash_addr_new->data),
 			sizeof(env_ptr->data))) ||
@@ -256,7 +256,6 @@
 #endif /* CMD_SAVEENV */
 
 #else /* ! CFG_ENV_ADDR_REDUND */
-
 int  env_init(void)
 {
 #ifdef CONFIG_OMAP2420H4
@@ -280,6 +279,52 @@
 
 #ifdef CMD_SAVEENV
 
+#ifdef UBOOT_ENV_COPY
+int saveenv_copy(void) {
+	uchar *env_buffer = (char *)env_ptr;
+	char *kernel_addr;
+	char *rootfs_addr;
+	char *rootfs_size;
+	ulong start_addr,end_addr,rootfs_end_addr;
+	ulong flash_start;
+
+	kernel_addr = getenv("f_kernel_addr");
+	end_addr = simple_strtoul(kernel_addr,NULL,16) - 1;
+	start_addr = end_addr - CFG_ENV_SIZE - sizeof(UBOOTCONFIG_COPY_HEADER) + 1;
+
+	rootfs_addr = getenv("f_rootfs_addr");
+	rootfs_size = getenv("f_rootfs_size");
+	rootfs_end_addr = simple_strtoul(rootfs_addr,NULL,16) + simple_strtoul(rootfs_size,NULL,16);
+
+	if(rootfs_end_addr >= start_addr)
+	{
+		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);
+		return 1;
+	}
+
+	debug ("Protect off %08lX ... %08lX\n", (ulong)rootfs_end_addr, end_addr);
+	if (flash_sect_protect (0, rootfs_end_addr, end_addr))
+		return 1;
+
+	//delete the old environment copy, if found
+	flash_start = rootfs_end_addr;
+	while(flash_start + sizeof(UBOOTCONFIG_COPY_HEADER) + ENV_SIZE < end_addr)
+	{
+		if(strncmp((char *)flash_start,UBOOTCONFIG_COPY_HEADER,sizeof(UBOOTCONFIG_COPY_HEADER)) == 0)
+		{
+			flash_sect_erase(flash_start,flash_start + sizeof(UBOOTCONFIG_COPY_HEADER),1);
+		}
+		flash_start += 1;
+	}
+	flash_sect_erase(start_addr,end_addr,1);
+	flash_write(UBOOTCONFIG_COPY_HEADER,start_addr,sizeof(UBOOTCONFIG_COPY_HEADER));
+	flash_write(env_buffer,start_addr + sizeof(UBOOTCONFIG_COPY_HEADER), CFG_ENV_SIZE);
+	flash_sect_protect (1, rootfs_end_addr, end_addr);
+	printf("saved copy of the env at 0x%08lx\n",start_addr);
+	return 0;
+}
+#endif	//UBOOT_ENV_COPY
+
 int saveenv(void)
 {
 	int	len, rc;
@@ -331,7 +376,7 @@
 		return 1;
 
 	puts ("Erasing Flash...");
-	if (flash_sect_erase (flash_sect_addr, end_addr))
+	if (flash_sect_erase (flash_sect_addr, end_addr, 1))
 		return 1;
 
 	puts ("Writing to Flash... ");
Index: u-boot-1.1.5/config.mk
===================================================================
--- u-boot-1.1.5.orig/config.mk	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/config.mk	2009-10-04 23:32:51.000000000 +0200
@@ -127,10 +127,15 @@
 OBJDUMP = $(CROSS_COMPILE)objdump
 RANLIB	= $(CROSS_COMPILE)RANLIB
 
+ifneq (,$(findstring s,$(MAKEFLAGS)))
+ARFLAGS = cr
+else
 ARFLAGS = crv
+endif
 RELFLAGS= $(PLATFORM_RELFLAGS)
 DBGFLAGS= -g # -DDEBUG
 OPTFLAGS= -Os #-fomit-frame-pointer
+OWRT_FLAGS?=
 ifndef LDSCRIPT
 #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
 ifeq ($(CONFIG_NAND_U_BOOT),y)
@@ -139,12 +144,15 @@
 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
 endif
 endif
+
+LDSCRIPT_BOOTSTRAP := $(TOPDIR)/board/$(BOARDDIR)/u-boot-bootstrap.lds
+
 OBJCFLAGS += --gap-fill=0xff
 
 gccincdir := $(shell $(CC) -print-file-name=include)
 
-CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)		\
-	-D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE)		\
+CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)	$(OWRT_FLAGS)	\
+	-D__KERNEL__ -DUBOOT_RAM_TEXT_BASE=$(UBOOT_RAM_TEXT_BASE)		\
 
 ifneq ($(OBJTREE),$(SRCTREE))
 CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
@@ -180,7 +188,8 @@
 
 AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
 
-LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
+LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(UBOOT_RAM_TEXT_BASE) $(PLATFORM_LDFLAGS)
+LDFLAGS_BOOTSTRAP += -Bstatic -T $(LDSCRIPT_BOOTSTRAP) -Ttext $(BOOTSTRAP_TEXT_BASE) $(PLATFORM_LDFLAGS)
 
 # Location of a usable BFD library, where we define "usable" as
 # "built for ${HOST}, supports ${TARGET}".  Sensible values are
@@ -214,12 +223,19 @@
 export	CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
 	AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
 	MAKE
-export	TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
+export	UBOOT_RAM_TEXT_BASE BOOTSTRAP_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
 
 #########################################################################
 
 ifndef REMOTE_BUILD
 
+%_bootstrap.s:	%_bootstrap.S
+	$(CPP) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -o $@ $<
+%_bootstrap.o:	%_bootstrap.S
+	$(CC) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
+%_bootstrap.o:	%_bootstrap.c
+	$(CC) $(CFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
+
 %.s:	%.S
 	$(CPP) $(AFLAGS) -o $@ $<
 %.o:	%.S
@@ -229,12 +245,20 @@
 
 else
 
+$(obj)%_bootstrap.s:	%_bootstrap.S
+	$(CPP) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -o $@ $<
+$(obj)%_bootstrap.o:	%_bootstrap.S
+	$(CC) $(AFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
+$(obj)%_bootstrap.o:	%_bootstrap.c
+	$(CC) $(CFLAGS) -DCFG_BOOTSTRAP_CODE -c -o $@ $<
+
 $(obj)%.s:	%.S
 	$(CPP) $(AFLAGS) -o $@ $<
 $(obj)%.o:	%.S
 	$(CC) $(AFLAGS) -c -o $@ $<
 $(obj)%.o:	%.c
 	$(CC) $(CFLAGS) -c -o $@ $<
+
 endif
 
 #########################################################################
Index: u-boot-1.1.5/drivers/Makefile
===================================================================
--- u-boot-1.1.5.orig/drivers/Makefile	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/drivers/Makefile	2009-10-04 23:06:03.000000000 +0200
@@ -50,7 +50,7 @@
 	  videomodes.o w83c553f.o \
 	  ks8695eth.o \
 	  pxa_pcmcia.o mpc8xx_pcmcia.o tqm8xx_pcmcia.o	\
-	  rpx_pcmcia.o
+	  rpx_pcmcia.o ifx_sw.o
 
 SRCS	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
Index: u-boot-1.1.5/include/asm-mips/mipsregs.h
===================================================================
--- u-boot-1.1.5.orig/include/asm-mips/mipsregs.h	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/include/asm-mips/mipsregs.h	2009-10-04 23:06:03.000000000 +0200
@@ -48,6 +48,7 @@
 #define CP0_CAUSE $13
 #define CP0_EPC $14
 #define CP0_PRID $15
+#define CP0_EBASE $15,1
 #define CP0_CONFIG $16
 #define CP0_LLADDR $17
 #define CP0_WATCHLO $18
@@ -330,11 +331,32 @@
 #  define KSU_USER		0x00000010
 #  define KSU_SUPERVISOR	0x00000008
 #  define KSU_KERNEL		0x00000000
+#ifdef CONFIG_DANUBE	/* MIPS 24KE */
+/* bits 5 & 6 & 7: reserved */
+/* bits 8~15: IM0~7 */
+/* bits 16: reserved */
+#define ST0_CEE			0x00020000
+/* bits 18: always 0 */
+#define ST0_NMI			0x00080000
+#define ST0_SR			0x00100000
+#define ST0_TS			0x00200000
+#define ST0_BEV			0x00400000
+/* bits 23: reserved */
+#define ST0_MX			0x01000000
+#define ST0_RE			0x02000000
+#define ST0_FR			0x04000000
+#define ST0_RP			0x08000000
+#define ST0_CU0			0x10000000
+#define ST0_CU1			0x20000000
+#define ST0_CU2			0x40000000
+#define ST0_CU3			0x80000000
+#else
 #define ST0_UX			0x00000020
 #define ST0_SX			0x00000040
 #define ST0_KX 			0x00000080
 #define ST0_DE			0x00010000
 #define ST0_CE			0x00020000
+#endif
 
 /*
  * Bitfields in the R[23]000 cp0 status register.
@@ -471,6 +493,14 @@
 #define  CAUSEF_BD		(1   << 31)
 
 /*
+ * Bits in the coprocessor 0 EBase register
+ */
+#define EBASEB_CPUNUM		0
+#define EBASEF_CPUNUM		(0x3ff << EBASEB_CPUNUM)
+#define EBASEB_EXPBASE		12
+#define EBASEF_EXPBASE		(0x3ffff << EBASEB_EXPBASE)
+
+/*
  * Bits in the coprozessor 0 config register.
  */
 #define CONF_CM_CACHABLE_NO_WA		0
@@ -544,4 +574,10 @@
 #define CEB_KERNEL	2	/* Count events in kernel mode EXL = ERL = 0 */
 #define CEB_EXL		1	/* Count events with EXL = 1, ERL = 0 */
 
+/*
+ * Bits in ErrCtl register
+ */
+#define ECCB_WST	29
+#define ECCF_WST	(0x1 << ECCB_WST)
+
 #endif /* _ASM_MIPSREGS_H */
Index: u-boot-1.1.5/include/cmd_confdefs.h
===================================================================
--- u-boot-1.1.5.orig/include/cmd_confdefs.h	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/include/cmd_confdefs.h	2009-10-04 23:06:03.000000000 +0200
@@ -94,6 +94,7 @@
 #define CFG_CMD_EXT2	0x1000000000000000ULL	/* EXT2 Support			*/
 #define CFG_CMD_SNTP	0x2000000000000000ULL	/* SNTP support			*/
 #define CFG_CMD_DISPLAY	0x4000000000000000ULL	/* Display support		*/
+#define CFG_CMD_DHRYSTONE	0x8000000000000000ULL	/* Dhrystone benchmark support		*/
 
 #define CFG_CMD_ALL	0xFFFFFFFFFFFFFFFFULL	/* ALL commands			*/
 
@@ -141,6 +142,7 @@
 			CFG_CMD_SPI	| \
 			CFG_CMD_UNIVERSE | \
 			CFG_CMD_USB	| \
+			CFG_CMD_DHRYSTONE | \
 			CFG_CMD_VFD	)
 
 /* Default configuration
Index: u-boot-1.1.5/include/config.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ u-boot-1.1.5/include/config.h	2009-10-04 23:06:04.000000000 +0200
@@ -0,0 +1,2 @@
+/* Automatically generated - do not edit */
+#include <configs/danube.h>
Index: u-boot-1.1.5/include/config.mk
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ u-boot-1.1.5/include/config.mk	2009-10-04 23:06:04.000000000 +0200
@@ -0,0 +1,5 @@
+ARCH   = mips
+CPU    = mips
+BOARD  = danube
+VENDOR = ifx
+SOC    = danube
Index: u-boot-1.1.5/include/flash.h
===================================================================
--- u-boot-1.1.5.orig/include/flash.h	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/include/flash.h	2009-10-04 23:06:03.000000000 +0200
@@ -79,7 +79,7 @@
 extern unsigned long flash_init (void);
 extern void flash_print_info (flash_info_t *);
 extern int flash_erase	(flash_info_t *, int, int);
-extern int flash_sect_erase (ulong addr_first, ulong addr_last);
+extern int flash_sect_erase (ulong addr_first, ulong addr_last, unsigned int bPartialErase);
 extern int flash_sect_protect (int flag, ulong addr_first, ulong addr_last);
 
 /* common/flash.c */
@@ -299,6 +299,10 @@
 #define TOSH_ID_FVT160	0xC2		/* TC58FVT160 ID (16 M, top )		*/
 #define TOSH_ID_FVB160	0x43		/* TC58FVT160 ID (16 M, bottom )	*/
 
+#define MX_ID_29LV320AB 0x22A822A8      /* MXIC  MX29LV320AB ID (32 M, bottom ) joelin       */
+#define MX_ID_29LV160BB 0x22492249      /* MXIC  MX29LV160BB ID (16 M, bottom ) joelin       */
+#define MX_ID_29LV640BB 0x22cb22cb      /* MXIC  MX29LV640BB ID (64 M, bottom ) joelin       */
+
 /*-----------------------------------------------------------------------
  * Internal FLASH identification codes
  *
@@ -422,6 +426,10 @@
 #define FLASH_S29GL064M 0x00F0		/* Spansion S29GL064M-R6		*/
 #define FLASH_S29GL128N 0x00F1		/* Spansion S29GL128N			*/
 
+#define FLASH_29LV320AB 0x00B0          /* MXIC MX29LV320AB( 32M = 4M x 16 ) joelin 10/07/2004*/
+#define FLASH_29LV160BB 0x00B1          /* MXIC MX29LV160BB( 16M = 2M x 16 ) joelin 11/22/2004*/
+#define FLASH_29LV640BB 0x00B2          /* MXIC MX29LV640BB( 64M = 8M x 16 ) liupeng*/
+
 #define FLASH_UNKNOWN	0xFFFF		/* unknown flash type			*/
 
 
Index: u-boot-1.1.5/include/image.h
===================================================================
--- u-boot-1.1.5.orig/include/image.h	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/include/image.h	2009-10-04 23:06:03.000000000 +0200
@@ -132,6 +132,7 @@
 #define IH_COMP_NONE		0	/*  No	 Compression Used	*/
 #define IH_COMP_GZIP		1	/* gzip	 Compression Used	*/
 #define IH_COMP_BZIP2		2	/* bzip2 Compression Used	*/
+#define IH_COMP_LZMA		3	/* lzma Compression Used	*/
 
 #define IH_MAGIC	0x27051956	/* Image Magic Number		*/
 #define IH_NMLEN		32	/* Image Name Length		*/
Index: u-boot-1.1.5/include/syscall.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ u-boot-1.1.5/include/syscall.h	2009-10-04 23:06:03.000000000 +0200
@@ -0,0 +1,42 @@
+#ifndef __MON_SYS_CALL_H__
+#define __MON_SYS_CALL_H__
+
+#ifndef __ASSEMBLY__
+
+#include <common.h>
+
+/* These are declarations of system calls available in C code */
+int  mon_getc(void);
+int  mon_tstc(void);
+void mon_putc(const char);
+void mon_puts(const char*);
+void mon_printf(const char* fmt, ...);
+void mon_install_hdlr(int, interrupt_handler_t*, void*);
+void mon_free_hdlr(int);
+void *mon_malloc(size_t);
+void mon_free(void*);
+void mon_udelay(unsigned long);
+unsigned long mon_get_timer(unsigned long);
+
+#endif    /* ifndef __ASSEMBLY__ */
+
+#define NR_SYSCALLS            11        /* number of syscalls */
+
+
+/*
+ * Make sure these functions are in the same order as they
+ * appear in the "examples/syscall.S" file !!!
+ */
+#define SYSCALL_GETC           0
+#define SYSCALL_TSTC           1
+#define SYSCALL_PUTC           2
+#define SYSCALL_PUTS           3
+#define SYSCALL_PRINTF         4
+#define SYSCALL_INSTALL_HDLR   5
+#define SYSCALL_FREE_HDLR      6
+#define SYSCALL_MALLOC         7
+#define SYSCALL_FREE           8
+#define SYSCALL_UDELAY         9
+#define SYSCALL_GET_TIMER     10
+
+#endif
Index: u-boot-1.1.5/ld_uboot.conf
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ u-boot-1.1.5/ld_uboot.conf	2009-10-04 23:06:03.000000000 +0200
@@ -0,0 +1,8 @@
+TAG_DWNLD()
+{
+   0xA0B00000 "u-boot.bin" /* Download u-boot image */
+};
+TAG_START()
+{
+   0xA0B00000
+}; /* Start u-boot image */
Index: u-boot-1.1.5/lib_generic/Makefile
===================================================================
--- u-boot-1.1.5.orig/lib_generic/Makefile	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/lib_generic/Makefile	2009-10-04 23:06:03.000000000 +0200
@@ -28,7 +28,7 @@
 COBJS	= bzlib.o bzlib_crctable.o bzlib_decompress.o \
 	  bzlib_randtable.o bzlib_huffman.o \
 	  crc32.o ctype.o display_options.o ldiv.o \
-	  string.o vsprintf.o zlib.o
+	  string.o vsprintf.o zlib.o LzmaDecode.o LzmaWrapper.o
 
 SRCS 	:= $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
Index: u-boot-1.1.5/lib_mips/board.c
===================================================================
--- u-boot-1.1.5.orig/lib_mips/board.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/lib_mips/board.c	2009-10-04 23:06:03.000000000 +0200
@@ -29,9 +29,30 @@
 #include <net.h>
 #include <environment.h>
 
+#ifdef CFG_BOOTSTRAP_CODE
+//#include <asm/danube.h>
+#undef CONFIG_MICROBZIP2
+
+#ifdef CONFIG_BZIP2
+#include <bzlib.h>
+#endif
+
+#ifdef CONFIG_MICROBZIP2
+#include <micro_bzlib.h>
+#endif
+
+#ifdef CONFIG_LZMA
+#include <LzmaWrapper.h>
+#endif
+#endif //CFG_BOOTSTRAP_CODE
+
 DECLARE_GLOBAL_DATA_PTR;
 
-#if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
+#if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < BOOTSTRAP_CFG_MONITOR_BASE) || \
+	(CFG_ENV_ADDR >= (BOOTSTRAP_CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
+    defined(CFG_ENV_IS_IN_NVRAM) && defined(CFG_BOOTSTRAP_CODE)
+#define	TOTAL_MALLOC_LEN	(CFG_MALLOC_LEN + CFG_ENV_SIZE)
+#elif ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
       (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
     defined(CFG_ENV_IS_IN_NVRAM)
 #define	TOTAL_MALLOC_LEN	(CFG_MALLOC_LEN + CFG_ENV_SIZE)
@@ -39,21 +60,24 @@
 #define	TOTAL_MALLOC_LEN	CFG_MALLOC_LEN
 #endif
 
-#undef DEBUG
-
 extern int timer_init(void);
-
 extern int incaip_set_cpuclk(void);
 
+#ifdef CFG_BOOTSTRAP_CODE
+extern ulong uboot_end_data_bootstrap;
+extern ulong uboot_end_bootstrap;
+#else //CFG_BOOTSTRAP_CODE
 extern ulong uboot_end_data;
 extern ulong uboot_end;
+#endif //CFG_BOOTSTRAP_CODE
 
 ulong monitor_flash_len;
 
-const char version_string[] =
-	U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
+const char version_string[] = U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
 
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
 static char *failed = "*** failed ***\n";
+#endif
 
 /*
  * Begin and End of memory area for malloc(), and current "brk"
@@ -62,14 +86,15 @@
 static ulong mem_malloc_end;
 static ulong mem_malloc_brk;
 
-
 /*
  * The Malloc area is immediately below the monitor copy in DRAM
  */
-static void mem_malloc_init (void)
-{
+#ifdef CFG_BOOTSTRAP_CODE
+static void mem_malloc_init (ulong dest_addr) {
+#else //CFG_BOOTSTRAP_CODE
+static void mem_malloc_init (void) {
 	ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
-
+#endif //CFG_BOOTSTRAP_CODE
 	mem_malloc_end = dest_addr;
 	mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
 	mem_malloc_brk = mem_malloc_start;
@@ -79,6 +104,25 @@
 		mem_malloc_end - mem_malloc_start);
 }
 
+#ifdef CFG_BOOTSTRAP_CODE
+void *malloc(unsigned int size) {
+	if(size < (mem_malloc_end - mem_malloc_start)) {
+		mem_malloc_start += size;
+		debug ("malloc : size required = 0x%08lx and pointer = 0x%08lx\n",size,mem_malloc_start - size);
+		return (void *)(mem_malloc_start - size);
+	}
+	return NULL;
+}
+
+void *realloc(void *src,unsigned int size) {
+	return NULL;
+}
+
+void free(void *src) {
+	return;
+}
+#endif //CFG_BOOTSTRAP_CODE
+
 void *sbrk (ptrdiff_t increment)
 {
 	ulong old = mem_malloc_brk;
@@ -99,42 +143,58 @@
 #else
 	int board_type = 0;	/* use dummy arg */
 #endif
-	puts ("DRAM:  ");
 
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+#ifdef CONFIG_USE_DDR_RAM
+	puts ("DDR-DRAM:  ");
+#else
+	puts ("DRAM:  ");
+#endif
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
 	if ((gd->ram_size = initdram (board_type)) > 0) {
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
 		print_size (gd->ram_size, "\n");
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
 		return (0);
 	}
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
 	puts (failed);
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
 	return (1);
 }
 
+#if !defined(CFG_BOOTSTRAP_CODE) || defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF)
 static int display_banner(void)
 {
-
 	printf ("\n\n%s\n\n", version_string);
 	return (0);
 }
+#endif
 
+#ifndef CFG_BOOTSTRAP_CODE
 static void display_flash_config(ulong size)
 {
 	puts ("Flash: ");
 	print_size (size, "\n");
 }
+#endif //CFG_BOOTSTRAP_CODE
 
-
+#if !defined(CFG_BOOTSTRAP_CODE) || defined(DEBUG_ENABLE_BOOTSTRAP_PRINTF)
 static int init_baudrate (void)
 {
+#ifndef CFG_BOOTSTRAP_CODE
 	char tmp[64];	/* long enough for environment variables */
 	int i = getenv_r ("baudrate", tmp, sizeof (tmp));
 
 	gd->baudrate = (i > 0)
 			? (int) simple_strtoul (tmp, NULL, 10)
 			: CONFIG_BAUDRATE;
-
+#else //CFG_BOOTSTRAP_CODE
+	gd->baudrate = CONFIG_BAUDRATE;
+#endif //CFG_BOOTSTRAP_CODE
 	return (0);
 }
-
+#endif
 
 /*
  * Breath some life into the board...
@@ -159,27 +219,49 @@
 typedef int (init_fnc_t) (void);
 
 init_fnc_t *init_sequence[] = {
+#ifdef CFG_BOOTSTRAP_CODE
+	//fuse_prg,
+	//timer_init,
+	//env_init,		/* initialize environment */
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	init_baudrate,		/* initialze baudrate settings */
+	serial_init,		/* serial communications setup */
+	console_init_f,
+	display_banner,		/* say that we are here */
+	checkboard,
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	init_func_ram,
+	NULL,
+#else /********** CFG_BOOTSTRAP_CODE **********/
 	timer_init,
-	env_init,		/* initialize environment */
-#ifdef CONFIG_INCA_IP
-	incaip_set_cpuclk,	/* set cpu clock according to environment variable */
-#endif
 	init_baudrate,		/* initialze baudrate settings */
 	serial_init,		/* serial communications setup */
 	console_init_f,
 	display_banner,		/* say that we are here */
 	checkboard,
 	init_func_ram,
+	env_init,               /* initialize environment */
 	NULL,
+#endif //CFG_BOOTSTRAP_CODE
 };
 
+#ifdef CFG_BOOTSTRAP_CODE
+extern void bootstrap_relocate_code(ulong addr_sp, gd_t *id, ulong addr);
 
+void bootstrap_board_init_f(ulong bootflag)
+#else
 void board_init_f(ulong bootflag)
+#endif
 {
 	gd_t gd_data, *id;
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
-	ulong addr, addr_sp, len = (ulong)&uboot_end - CFG_MONITOR_BASE;
+#ifdef CFG_BOOTSTRAP_CODE
+	ulong addr, addr_sp, len = (ulong)&uboot_end_bootstrap - BOOTSTRAP_CFG_MONITOR_BASE;
+	ulong lzmaImageaddr = 0;
+#else //CFG_BOOTSTRAP_CODE
+	ulong addr, addr_sp, len = CFG_MONITOR_LEN;
+#endif //CFG_BOOTSTRAP_CODE
 	ulong *s;
 #ifdef CONFIG_PURPLE
 	void copy_code (ulong);
@@ -219,13 +301,12 @@
 	addr -= len;
 	addr &= ~(16 * 1024 - 1);
 
-	debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
+	debug ("Reserving %d Bytes for U-Boot at: %08lx\n", len, addr);
 
 	 /* Reserve memory for malloc() arena.
 	 */
 	addr_sp = addr - TOTAL_MALLOC_LEN;
-	debug ("Reserving %dk for malloc() at: %08lx\n",
-			TOTAL_MALLOC_LEN >> 10, addr_sp);
+	debug ("Reserving %d Bytes for malloc() at: %08lx\n", TOTAL_MALLOC_LEN, addr_sp);
 
 	/*
 	 * (permanently) allocate a Board Info struct
@@ -234,20 +315,17 @@
 	addr_sp -= sizeof(bd_t);
 	bd = (bd_t *)addr_sp;
 	gd->bd = bd;
-	debug ("Reserving %d Bytes for Board Info at: %08lx\n",
-			sizeof(bd_t), addr_sp);
+	debug ("Reserving %d Bytes for Board Info at: %08lx\n",	sizeof(bd_t), addr_sp);
 
 	addr_sp -= sizeof(gd_t);
 	id = (gd_t *)addr_sp;
-	debug ("Reserving %d Bytes for Global Data at: %08lx\n",
-			sizeof (gd_t), addr_sp);
+	debug ("Reserving %d Bytes for Global Data at: %08lx\n", sizeof (gd_t), addr_sp);
 
  	/* Reserve memory for boot params.
 	 */
 	addr_sp -= CFG_BOOTPARAMS_LEN;
 	bd->bi_boot_params = addr_sp;
-	debug ("Reserving %dk for boot params() at: %08lx\n",
-			CFG_BOOTPARAMS_LEN >> 10, addr_sp);
+	debug ("Reserving %dk for boot params() at: %08lx\n", CFG_BOOTPARAMS_LEN >> 10, addr_sp);
 
 	/*
 	 * Finally, we set up a new (bigger) stack.
@@ -279,7 +357,16 @@
 	copy_code(addr);
 #endif
 
+#ifdef CFG_BOOTSTRAP_CODE
+	lzmaImageaddr = (ulong)&uboot_end_data_bootstrap;
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	puts("\n BOOTSTRAP: relocate_code start");
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	bootstrap_relocate_code (addr_sp, id, addr);
+#else //CFG_BOOTSTRAP_CODE
+	puts("\n relocate_code start");
 	relocate_code (addr_sp, id, addr);
+#endif //CFG_BOOTSTRAP_CODE
 
 	/* NOTREACHED - relocate_code() does not return */
 }
@@ -292,7 +379,110 @@
  *
  ************************************************************************
  */
+#ifdef CFG_BOOTSTRAP_CODE
+void bootstrap_board_init_r (gd_t *id, ulong dest_addr) {
+	int i;
+	ulong	addr;
+	ulong	data, len, checksum;
+	ulong  *len_ptr;
+	image_header_t header;
+	image_header_t *hdr = &header;
+	unsigned int destLen;
+	int (*fn)(void);
+
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	puts("\n BOOTSTRAP: relocate_code finish.\n");
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+
+	/* initialize malloc() area */
+	mem_malloc_init(dest_addr);
+
+	addr = (char *)(BOOTSTRAP_CFG_MONITOR_BASE + ((ulong)&uboot_end_data_bootstrap - dest_addr));
+	memmove (&header, (char *)addr, sizeof(image_header_t));
+
+	if (ntohl(hdr->ih_magic) != IH_MAGIC) {
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+		printf ("Bad Magic Number at address 0x%08lx\n",addr);
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+		return;
+	}
 
+	data = (ulong)&header;
+	len  = sizeof(image_header_t);
+
+	checksum = ntohl(hdr->ih_hcrc);
+	hdr->ih_hcrc = 0;
+	if (crc32 (0, (unsigned char *)data, len) != checksum) {
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+		printf ("Bad Header Checksum\n");
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+		return;
+	}
+
+	data = addr + sizeof(image_header_t);
+	len  = ntohl(hdr->ih_size);
+	len_ptr = (ulong *)data;
+
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	debug ("Disabling all the interrupts\n");
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	disable_interrupts();
+
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	debug ("   Uncompressing UBoot Image ... \n" );
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	/*
+	 * If we've got less than 4 MB of malloc() space,
+	 * use slower decompression algorithm which requires
+	 * at most 2300 KB of memory.
+	 */
+	destLen = 0x0;
+
+#ifdef CONFIG_BZIP2
+	i = BZ2_bzBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
+					0x400000, (char *)data, len,
+					CFG_MALLOC_LEN < (4096 * 1024), 0);
+	if (i != BZ_OK) {
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+			printf ("BUNZIP2 ERROR %d - must RESET board to recover\n", i);
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+			return;
+	}
+#elif CONFIG_MICROBZIP2
+	i = micro_bzBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
+					&destLen, (char *)data, len,
+					CFG_MALLOC_LEN < (4096 * 1024), 0);
+	if (i != RETVAL_OK) {
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+		printf ("MICRO_BUNZIP2 ERROR %d - must RESET board to recover\n", i);
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+		return;
+	}
+#elif CONFIG_LZMA
+	i = lzma_inflate ((unsigned char *)data, len, (unsigned char*)ntohl(hdr->ih_load), &destLen);
+	if (i != LZMA_RESULT_OK) {
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+		printf ("LZMA ERROR %d - must RESET board to recover\n", i);
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+		return;
+	}
+#else
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	printf ("NONE Compressing u-boot body!!\n");
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	memmove ((void *)ntohl(hdr->ih_load), (uchar *)data, len);
+	destLen = len;
+#endif
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
+	debug ("   Uncompression completed successfully with destLen %d.\n ",destLen );
+	debug ("Head: Jumping to u-boot in the ram at 0x%08lx\n", CFG_MONITOR_BASE);
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
+
+	fn = ntohl(hdr->ih_load);
+	(*fn)();
+	hang ();
+}
+#else //CFG_BOOTSTRAP_CODE
 void board_init_r (gd_t *id, ulong dest_addr)
 {
 	cmd_tbl_t *cmdtp;
@@ -305,6 +495,8 @@
 	bd_t *bd;
 	int i;
 
+	puts("\n relocate_code finish.\n");
+
 	gd = id;
 	gd->flags |= GD_FLG_RELOC;	/* tell others: relocation done */
 
@@ -321,12 +513,10 @@
 		ulong addr;
 
 		addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
-#if 0
-		printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
-				cmdtp->name, (ulong) (cmdtp->cmd), addr);
-#endif
-		cmdtp->cmd =
-			(int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
+
+		debug ("Command \"%s\": 0x%08lx => 0x%08lx\n", cmdtp->name, (ulong) (cmdtp->cmd), addr);
+
+		cmdtp->cmd = (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
 
 		addr = (ulong)(cmdtp->name) + gd->reloc_off;
 		cmdtp->name = (char *)addr;
@@ -363,7 +553,13 @@
 	/* initialize malloc() area */
 	mem_malloc_init();
 	malloc_bin_reloc();
+#if (CONFIG_COMMANDS & CFG_CMD_NAND)
+	nand_init();	/* go init the NAND */
+#endif
 
+#ifdef CONFIG_SPI
+	spi_init_f();            /* go init the SPI flash */
+#endif
 	/* relocate environment function pointers etc. */
 	env_relocate();
 
@@ -424,9 +620,12 @@
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
+#endif //CFG_BOOTSTRAP_CODE
 
 void hang (void)
 {
+#ifdef DEBUG_ENABLE_BOOTSTRAP_PRINTF
 	puts ("### ERROR ### Please RESET the board ###\n");
+#endif //DEBUG_ENABLE_BOOTSTRAP_PRINTF
 	for (;;);
 }
Index: u-boot-1.1.5/lib_mips/time.c
===================================================================
--- u-boot-1.1.5.orig/lib_mips/time.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/lib_mips/time.c	2009-10-04 23:06:03.000000000 +0200
@@ -80,6 +80,19 @@
 		/*NOP*/;
 }
 
+#ifndef CFG_BOOTSTRAP_CODE
+void mdelay (unsigned long msec)
+{
+       int i,j;
+       for(i=0;i<msec;i++)
+       {
+          udelay(1000);
+
+       }
+
+}
+#endif
+
 /*
  * This function is derived from PowerPC code (read timebase as long long).
  * On MIPS it just returns the timer value.
Index: u-boot-1.1.5/net/eth.c
===================================================================
--- u-boot-1.1.5.orig/net/eth.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/net/eth.c	2009-10-04 23:06:03.000000000 +0200
@@ -25,6 +25,9 @@
 #include <command.h>
 #include <net.h>
 #include <miiphy.h>
+#if defined(CONFIG_IFX_MIPS)
+#       include "ifx_eth.c"
+#endif
 
 #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI)
 
@@ -54,6 +57,9 @@
 extern int skge_initialize(bd_t*);
 extern int tsec_initialize(bd_t*, int, char *);
 extern int npe_initialize(bd_t *);
+#if defined(CONFIG_IFX_MIPS)
+	IFX_ETH_INITIALIZE_EXTERN
+#endif
 
 static struct eth_device *eth_devices, *eth_current;
 
@@ -235,7 +241,9 @@
 #if defined(CONFIG_RTL8169)
 	rtl8169_initialize(bis);
 #endif
-
+#if defined(CONFIG_IFX_MIPS)
+	IFX_ETH_INITIALIZE(bis)
+#endif
 	if (!eth_devices) {
 		puts ("No ethernet found.\n");
 	} else {
Index: u-boot-1.1.5/tools/mkimage.c
===================================================================
--- u-boot-1.1.5.orig/tools/mkimage.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/tools/mkimage.c	2009-10-04 23:06:03.000000000 +0200
@@ -28,6 +28,7 @@
 #ifndef __WIN32__
 #include <netinet/in.h>		/* for host / network byte order conversions	*/
 #endif
+#include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <time.h>
@@ -138,6 +139,7 @@
     {	IH_COMP_NONE,	"none",		"uncompressed",		},
     {	IH_COMP_BZIP2,	"bzip2",	"bzip2 compressed",	},
     {	IH_COMP_GZIP,	"gzip",		"gzip compressed",	},
+    {	IH_COMP_LZMA,	"lzma",		"lzma compressed",	},
     {	-1,		"",		"",			},
 };
 
@@ -445,7 +447,7 @@
 	}
 
 	/* We're a bit of paranoid */
-#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
+#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
 	(void) fdatasync (ifd);
 #else
 	(void) fsync (ifd);
@@ -495,7 +497,7 @@
 	(void) munmap((void *)ptr, sbuf.st_size);
 
 	/* We're a bit of paranoid */
-#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
+#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) && !defined(__APPLE__)
 	(void) fdatasync (ifd);
 #else
 	(void) fsync (ifd);
Index: u-boot-1.1.5/cpu/mips/cache.S
===================================================================
--- u-boot-1.1.5.orig/cpu/mips/cache.S	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/cpu/mips/cache.S	2009-10-04 23:06:03.000000000 +0200
@@ -29,7 +29,9 @@
 #include <asm/mipsregs.h>
 #include <asm/addrspace.h>
 #include <asm/cacheops.h>
-
+#if defined(CONFIG_IFX_MIPS)
+#	include "danube/ifx_cache.S"
+#endif
 
 	/* 16KB is the maximum size of instruction and data caches on
 	 * MIPS 4K.
@@ -155,6 +157,9 @@
 	 */
 
 	mtc0	zero, CP0_TAGLO
+#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_EXTRA_INVALID_TAG)
+	IFX_CACHE_EXTRA_INVALID_TAG
+#endif
 
    /*
     * The caches are probably in an indeterminate state,
@@ -171,6 +176,9 @@
 	move	a1, a2
 	icacheopn(a0,a1,a2,a3,121,(Index_Store_Tag_I,Fill))
 
+#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_EXTRA_OPERATION)
+	IFX_CACHE_EXTRA_OPERATION
+#else
 	/* To support Orion/R4600, we initialise the data cache in 3 passes.
 	 */
 
@@ -200,6 +208,7 @@
 	move	a3, t5		# dcacheLineSize
 	move	a1, a2
 	icacheop(a0,a1,a2,a3,Index_Store_Tag_D)
+#endif
 
 	j  ra
 	.end  mips_cache_reset
Index: u-boot-1.1.5/cpu/mips/config.mk
===================================================================
--- u-boot-1.1.5.orig/cpu/mips/config.mk	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/cpu/mips/config.mk	2009-10-04 23:06:03.000000000 +0200
@@ -20,20 +20,26 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
 #
-v=$(shell \
-$(CROSS_COMPILE)as --version|grep "GNU assembler"|awk '{print $$3}'|awk -F . '{print $$2}')
-MIPSFLAGS=$(shell \
-if [ "$v" -lt "14" ]; then \
-	echo "-mcpu=4kc"; \
-else \
-	echo "-march=4kc -mtune=4kc"; \
-fi)
 
+ifndef PLATFORM_CPU
+PLATFORM_CPU = mips32
+endif
+
+MIPSFLAGS +=$(call cc-option,-march=$(PLATFORM_CPU) -mtune=$(PLATFORM_CPU),-mcpu=$(PLATFORM_CPU))
+
+ifeq ($(CROSS_COMPILE_UCLIBC),1)
+ifneq (,$(findstring mipsel,$(CROSS_COMIPLE)))
+ENDIANNESS = -el
+else
+ENDIANNESS = -eb
+endif
+else
 ifneq (,$(findstring 4KCle,$(CROSS_COMPILE)))
 ENDIANNESS = -EL
 else
 ENDIANNESS = -EB
 endif
+endif
 
 MIPSFLAGS += $(ENDIANNESS) -mabicalls
 
Index: u-boot-1.1.5/cpu/mips/cpu.c
===================================================================
--- u-boot-1.1.5.orig/cpu/mips/cpu.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/cpu/mips/cpu.c	2009-10-04 23:06:03.000000000 +0200
@@ -23,7 +23,12 @@
 
 #include <common.h>
 #include <command.h>
-#include <asm/inca-ip.h>
+#if defined(CONFIG_INCA_IP)
+#	include <asm/inca-ip.h>
+#elif defined(CONFIG_IFX_MIPS)
+#	include <asm/danube.h>
+#	include "danube/ifx_cpu.c"
+#endif
 #include <asm/mipsregs.h>
 
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -34,6 +39,8 @@
 	void (*f)(void) = (void *) 0xbfc00000;
 
 	f();
+#elif defined(CONFIG_IFX_MIPS)
+	IFX_CPU_RESET;
 #endif
 	fprintf(stderr, "*** reset failed ***\n");
 	return 0;
Index: u-boot-1.1.5/cpu/mips/incaip_clock.c
===================================================================
--- u-boot-1.1.5.orig/cpu/mips/incaip_clock.c	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/cpu/mips/incaip_clock.c	2009-10-04 23:06:03.000000000 +0200
@@ -22,8 +22,9 @@
  */
 
 #include <common.h>
-#include <asm/inca-ip.h>
 
+#ifdef CONFIG_INCA_IP
+#include <asm/inca-ip.h>
 
 /*******************************************************************************
 *
@@ -114,3 +115,5 @@
 
 	return 0;
 }
+
+#endif /* CONFIG_INCA_IP */
Index: u-boot-1.1.5/cpu/mips/start.S
===================================================================
--- u-boot-1.1.5.orig/cpu/mips/start.S	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/cpu/mips/start.S	2009-10-04 23:06:03.000000000 +0200
@@ -27,7 +27,9 @@
 #include <version.h>
 #include <asm/regdef.h>
 #include <asm/mipsregs.h>
-
+#if defined(CONFIG_IFX_MIPS)
+#	include "danube/ifx_start.S"
+#endif
 
 #define RVECENT(f,n) \
    b f; nop
@@ -36,15 +38,24 @@
    li k0,bev
 
 	.set noreorder
-
+#ifdef CFG_BOOTSTRAP_CODE
+	.globl _start_bootstrap
+#else
 	.globl _start
+#endif
 	.text
+#ifdef CFG_BOOTSTRAP_CODE
+_start_bootstrap:
+#else
 _start:
+#endif
 	RVECENT(reset,0)	/* U-boot entry point */
 	RVECENT(reset,1)	/* software reboot */
-#if defined(CONFIG_INCA_IP)
+#if defined(CONFIG_INCA_IP) || defined(CONFIG_INCA_IP2)
 	.word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
 	.word 0x00000000           /* phase of the flash                    */
+#elif defined(CONFIG_IFX_MIPS) && defined(IFX_EBU_BOOTCFG_DWORD)
+	IFX_EBU_BOOTCFG_DWORD
 #elif defined(CONFIG_PURPLE)
 	.word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
 	.word INFINEON_EBU_BOOTCFG /* EBU init code, fetched during booting */
@@ -181,6 +192,9 @@
 	 * 128 * 8 == 1024 == 0x400
 	 * so this is address R_VEC+0x400 == 0xbfc00400
 	 */
+#if defined(CONFIG_IFX_MIPS) && defined(IFX_MORE_RESERVED_VECTORS)
+	IFX_MORE_RESERVED_VECTORS
+#else
 #ifdef CONFIG_PURPLE
 /* 0xbfc00400 */
 	.word	0xdc870000
@@ -205,8 +219,12 @@
 	.word	0x00000000
 	.word   0x00000000
 #endif /* CONFIG_PURPLE */
+#endif /* CONFIG_IFX_MIPS */
 	.align 4
 reset:
+#if defined(CONFIG_IFX_MIPS) && defined(IFX_RESET_PRECHECK)
+	IFX_RESET_PRECHECK
+#endif
 
 	/* Clear watch registers.
 	 */
@@ -226,6 +244,10 @@
 	/* CAUSE register */
 	mtc0	zero, CP0_CAUSE
 
+#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU_EXTRA_INIT)
+	IFX_CPU_EXTRA_INIT
+#endif
+
 	/* Init Timer */
 	mtc0	zero, CP0_COUNT
 	mtc0	zero, CP0_COMPARE
@@ -252,12 +274,26 @@
 	nop
 #endif
 
+#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_SKIP_LOWLEVEL_INIT)
+	IFX_SKIP_LOWLEVEL_INIT
+#endif
+#ifdef CFG_BOOTSTRAP_CODE
 	/* Initialize any external memory.
 	 */
 	la      t9, lowlevel_init
 	jalr    t9
 	nop
+#endif
+lowlevel_init_done:
+
+	beq	s0, zero, init_cache_0
+	nop
+
+#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_CPU1_INIT)
+        IFX_CPU1_INIT
+#endif
 
+init_cache_0:
 	/* Initialize caches...
 	 */
 	la      t9, mips_cache_reset
@@ -266,7 +302,11 @@
 
 	/* ... and enable them.
 	 */
+#if defined(CONFIG_IFX_MIPS) && defined(IFX_CACHE_OPER_MODE)
+	IFX_CACHE_OPER_MODE
+#else
 	li	t0, CONF_CM_CACHABLE_NONCOHERENT
+#endif
 	mtc0	t0, CP0_CONFIG
 
 
@@ -280,13 +320,38 @@
 	li	t0, CFG_SDRAM_BASE + CFG_INIT_SP_OFFSET
 	la	sp, 0(t0)
 
+#if defined(CONFIG_IFX_MIPS) && defined(IFX_CPU1_SUPPORT) && defined(IFX_BOOT_CLEAR)
+	IFX_BOOT_CLEAR
+#endif
+
+#ifdef CFG_BOOTSTRAP_CODE
+	la	t9, bootstrap_board_init_f
+#else
 	la	t9, board_init_f
+#endif
 	j	t9
 	nop
 
+#ifdef CFG_BOOTSTRAP_CODE
+/*
+ * void jump_unconditional (addr)
+ * This function simply jumps to the location pointed by a0.
+ * a0 = target_location
+ *
+ */
+	.globl  jump_unconditional
+	.ent    jump_unconditional
+jump_unconditional:
+	move t9, a0
+	j       t9
+	nop
+	.end    jump_unconditional
+
+#endif
 
 /*
  * void relocate_code (addr_sp, gd, addr_moni)
+ * void bootstrap_relocate_code (addr_sp, gd, addr_moni)
  *
  * This "function" does not return, instead it continues in RAM
  * after relocating the monitor code.
@@ -295,12 +360,22 @@
  * a1 = gd
  * a2 = destination address
  */
+#ifdef CFG_BOOTSTRAP_CODE
+	.globl	bootstrap_relocate_code
+	.ent	bootstrap_relocate_code
+bootstrap_relocate_code:
+#else
 	.globl	relocate_code
 	.ent	relocate_code
 relocate_code:
+#endif
 	move	sp, a0		/* Set new stack pointer		*/
 
+#ifdef CFG_BOOTSTRAP_CODE
+	li	t0, BOOTSTRAP_CFG_MONITOR_BASE
+#else
 	li	t0, CFG_MONITOR_BASE
+#endif
 	la	t3, in_ram
 	lw	t2, -12(t3)	/* t2 <-- uboot_end_data	*/
 	move	t1, a2
@@ -311,7 +386,11 @@
 	 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
 	 */
 	move	t6, gp
+#ifdef CFG_BOOTSTRAP_CODE
+	sub	gp, BOOTSTRAP_CFG_MONITOR_BASE
+#else
 	sub	gp, CFG_MONITOR_BASE
+#endif
 	add	gp, a2			/* gp now adjusted		*/
 	sub	t6, gp, t6		/* t6 <-- relocation offset	*/
 
@@ -337,12 +416,21 @@
 
 	/* Jump to where we've relocated ourselves.
 	 */
+#ifdef CFG_BOOTSTRAP_CODE
+	addi	t0, a2, in_ram - _start_bootstrap
+#else
 	addi	t0, a2, in_ram - _start
+#endif
 	j	t0
 	nop
 
+#ifdef CFG_BOOTSTRAP_CODE
+	.word	uboot_end_data_bootstrap
+	.word	uboot_end_bootstrap
+#else
 	.word	uboot_end_data
 	.word	uboot_end
+#endif
 	.word	num_got_entries
 
 in_ram:
@@ -374,12 +462,19 @@
 	sw	zero, 0(t1)	/* delay slot			*/
 
 	move	a0, a1
+#ifdef CFG_BOOTSTRAP_CODE
+	la	t9, bootstrap_board_init_r
+#else
 	la	t9, board_init_r
+#endif
 	j	t9
 	move	a1, a2		/* delay slot			*/
 
+#ifdef CFG_BOOTSTRAP_CODE
+	.end	bootstrap_relocate_code
+#else
 	.end	relocate_code
-
+#endif
 
 	/* Exception handlers.
 	 */
@@ -388,3 +483,20 @@
 
 romExcHandle:
 	b romExcHandle
+
+romEjtagHandle:
+#ifdef CFG_BOOTSTRAP_CODE
+	deret
+	nop
+#endif /* CFG_BOOTSTRAP_CODE */
+1:
+	b 1b
+
+	/* Additional handlers.
+	 */
+#if defined(CONFIG_IFX_MIPS)
+#if defined(IFX_MIPS_HANDLER_1)
+ifx_mips_handler_1:
+	IFX_MIPS_HANDLER_1
+#endif
+#endif
Index: u-boot-1.1.5/tools/Makefile
===================================================================
--- u-boot-1.1.5.orig/tools/Makefile	2006-10-20 17:54:33.000000000 +0200
+++ u-boot-1.1.5/tools/Makefile	2009-10-04 23:06:03.000000000 +0200
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-BIN_FILES	= img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
+BIN_FILES	= mkimage$(SFX)
 
 OBJ_LINKS	= environment.o crc32.o
 OBJ_FILES	= img2srec.o mkimage.o envcrc.o gen_eth_addr.o bmp_logo.o