summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhcg <hcg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-04-04 14:33:52 +0000
committerhcg <hcg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-04-04 14:33:52 +0000
commitc3831d028457ff1c106fa9a89e3b07712255d838 (patch)
treee8e9381e46fc6e4c50b98f819446338e6bf3e4a6
parent7b54053908fcad636059945ea8b978578d631885 (diff)
Cleanups on romboot and u-boot.
Conditionally apply ldd and ldconfig support on at91 platform git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6862 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--target/linux/at91-2.6/image/romboot/Makefile2
-rw-r--r--target/linux/at91-2.6/image/romboot/patches/000-fixenv.patch100
-rw-r--r--target/linux/at91-2.6/image/romboot/patches/002-Add-SD-Card.patch726
-rw-r--r--target/linux/at91-2.6/image/romboot/patches/003-SD-reflash.patch456
-rw-r--r--target/linux/at91-2.6/image/romboot/patches/004-code-cleanup.patch423
-rw-r--r--target/linux/at91-2.6/image/u-boot/patches/010-irda-patch-remove.patch13
-rw-r--r--toolchain/uClibc/Makefile2
7 files changed, 1081 insertions, 641 deletions
diff --git a/target/linux/at91-2.6/image/romboot/Makefile b/target/linux/at91-2.6/image/romboot/Makefile
index aa679aba7..586a4813b 100644
--- a/target/linux/at91-2.6/image/romboot/Makefile
+++ b/target/linux/at91-2.6/image/romboot/Makefile
@@ -19,6 +19,8 @@ PKG_SOURCE_URL:=http://www.teest.com/at91
PKG_MD5SUM:=
PKG_CAT:=zcat
+CRLF_WORKAROUND=1
+
include $(INCLUDE_DIR)/package.mk
define Build/InstallDev
diff --git a/target/linux/at91-2.6/image/romboot/patches/000-fixenv.patch b/target/linux/at91-2.6/image/romboot/patches/000-fixenv.patch
index 5a08d57be..7c2857285 100644
--- a/target/linux/at91-2.6/image/romboot/patches/000-fixenv.patch
+++ b/target/linux/at91-2.6/image/romboot/patches/000-fixenv.patch
@@ -2,56 +2,56 @@ diff -uNr romboot/main.cpp romboot.new/main.cpp
--- romboot/main.cpp 2004-07-16 17:10:04.000000000 +0200
+++ romboot.new/main.cpp 2006-03-03 02:27:37.000000000 +0100
@@ -23,12 +23,12 @@
- #define AT91C_UBOOT_DATAFLASH_ADDR 0xC0008000
-
- // crystal= 18.432MHz
--//#define AT91C_PLLA_VALUE 0x2026BE04 // -> 179.712MHz
--//#define AT91C_PLLA_MCK 0x0000202
-+#define AT91C_PLLA_VALUE 0x2026BE04 // -> 179.712MHz
-+#define AT91C_PLLA_MCK 0x0000202
-
- // crystal= 20.000MHz
--#define AT91C_PLLA_VALUE 0x2023BE04 // -> 180MHz
--#define AT91C_PLLA_MCK 0x0000202
-+//#define AT91C_PLLA_VALUE 0x2023BE04 // -> 180MHz
-+//#define AT91C_PLLA_MCK 0x0000202
-
- #define DELAY_MAIN_FREQ 1000
- #define DISP_LINE_LEN 16
+ #define AT91C_UBOOT_DATAFLASH_ADDR 0xC0008000
+
+ // crystal= 18.432MHz
+-//#define AT91C_PLLA_VALUE 0x2026BE04 // -> 179.712MHz
+-//#define AT91C_PLLA_MCK 0x0000202
++#define AT91C_PLLA_VALUE 0x2026BE04 // -> 179.712MHz
++#define AT91C_PLLA_MCK 0x0000202
+
+ // crystal= 20.000MHz
+-#define AT91C_PLLA_VALUE 0x2023BE04 // -> 180MHz
+-#define AT91C_PLLA_MCK 0x0000202
++//#define AT91C_PLLA_VALUE 0x2023BE04 // -> 180MHz
++//#define AT91C_PLLA_MCK 0x0000202
+
+ #define DELAY_MAIN_FREQ 1000
+ #define DISP_LINE_LEN 16
@@ -151,7 +151,7 @@
- //*-----------------------------------------------------------------------------
- void AT91F_DisplayMenu(void)
- {
-- printf("\n\rATMEL LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
-+ printf("\n\rFDL LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
- printf(menu_separ);
- AT91F_DataflashPrintInfo();
- printf(menu_separ);
+ //*-----------------------------------------------------------------------------
+ void AT91F_DisplayMenu(void)
+ {
+- printf("\n\rATMEL LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
++ printf("\n\rFDL LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
+ printf(menu_separ);
+ AT91F_DataflashPrintInfo();
+ printf(menu_separ);
@@ -306,6 +306,19 @@
- AT91F_SetPLL();
- }
-
-+void LedCode(void)
-+{
-+ int *pRegister;
-+ pRegister = (int *)0xFFFFF800; // Enable port C peripheral reg
-+ *pRegister = 0x3c00;
-+ pRegister = (int *)0xFFFFF810; // Output Enable reg
-+ *pRegister = 0x3c00;
-+ pRegister = (int *)0xFFFFF830; // Set data
-+ *pRegister = 0x1400;
-+ pRegister = (int *)0xFFFFF834; // Clear bits
-+ *pRegister = 0x2800;
-+}
-+
- void AT91F_StartUboot(unsigned int dummy, void *pvoid)
- {
- printf("Load U-BOOT from dataflash[%x] to SDRAM[%x]\n\r", AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_ADDR);
+ AT91F_SetPLL();
+ }
+
++void LedCode(void)
++{
++ int *pRegister;
++ pRegister = (int *)0xFFFFF800; // Enable port C peripheral reg
++ *pRegister = 0x3c00;
++ pRegister = (int *)0xFFFFF810; // Output Enable reg
++ *pRegister = 0x3c00;
++ pRegister = (int *)0xFFFFF830; // Set data
++ *pRegister = 0x1400;
++ pRegister = (int *)0xFFFFF834; // Clear bits
++ *pRegister = 0x2800;
++}
++
+ void AT91F_StartUboot(unsigned int dummy, void *pvoid)
+ {
+ printf("Load U-BOOT from dataflash[%x] to SDRAM[%x]\n\r", AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_ADDR);
@@ -313,6 +326,7 @@
- printf("Set PLLA to 180Mhz and Master clock to 60Mhz and start U-BOOT\n\r");
- //* Reset registers
- AT91F_ResetRegisters();
-+ LedCode();
- Jump(AT91C_UBOOT_ADDR);
- while(1);
- }
+ printf("Set PLLA to 180Mhz and Master clock to 60Mhz and start U-BOOT\n\r");
+ //* Reset registers
+ AT91F_ResetRegisters();
++ LedCode();
+ Jump(AT91C_UBOOT_ADDR);
+ while(1);
+ }
diff --git a/target/linux/at91-2.6/image/romboot/patches/002-Add-SD-Card.patch b/target/linux/at91-2.6/image/romboot/patches/002-Add-SD-Card.patch
index e3e10545a..8ed0db914 100644
--- a/target/linux/at91-2.6/image/romboot/patches/002-Add-SD-Card.patch
+++ b/target/linux/at91-2.6/image/romboot/patches/002-Add-SD-Card.patch
@@ -503,387 +503,387 @@ diff -urN romboot.old/init.cpp romboot/init.cpp
--- romboot.old/init.cpp 2004-07-06 13:01:55.000000000 +0200
+++ romboot/init.cpp 2007-03-21 12:43:39.000000000 +0100
@@ -35,7 +35,7 @@
- //*----------------------------------------------------------------------------
- void AT91F_SpuriousHandler()
- {
-- AT91F_DBGU_Printk("-F- Spurious Interrupt detected\n\r");
-+ AT91F_DBGU_Printk("ISI");
- while (1);
- }
-
+ //*----------------------------------------------------------------------------
+ void AT91F_SpuriousHandler()
+ {
+- AT91F_DBGU_Printk("-F- Spurious Interrupt detected\n\r");
++ AT91F_DBGU_Printk("ISI");
+ while (1);
+ }
+
@@ -46,7 +46,7 @@
- //*----------------------------------------------------------------------------
- void AT91F_DataAbort()
- {
-- AT91F_DBGU_Printk("-F- Data Abort detected\n\r");
-+ AT91F_DBGU_Printk("IDA");
- while (1);
- }
-
+ //*----------------------------------------------------------------------------
+ void AT91F_DataAbort()
+ {
+- AT91F_DBGU_Printk("-F- Data Abort detected\n\r");
++ AT91F_DBGU_Printk("IDA");
+ while (1);
+ }
+
@@ -56,7 +56,7 @@
- //*----------------------------------------------------------------------------
- void AT91F_FetchAbort()
- {
-- AT91F_DBGU_Printk("-F- Prefetch Abort detected\n\r");
-+ AT91F_DBGU_Printk("IPA");
- while (1);
- }
-
+ //*----------------------------------------------------------------------------
+ void AT91F_FetchAbort()
+ {
+- AT91F_DBGU_Printk("-F- Prefetch Abort detected\n\r");
++ AT91F_DBGU_Printk("IPA");
+ while (1);
+ }
+
@@ -66,7 +66,7 @@
- //*----------------------------------------------------------------------------
- void AT91F_Undef()
- {
-- AT91F_DBGU_Printk("-F- Undef detected\n\r");
-+ AT91F_DBGU_Printk("IUD");
- while (1);
- }
-
+ //*----------------------------------------------------------------------------
+ void AT91F_Undef()
+ {
+- AT91F_DBGU_Printk("-F- Undef detected\n\r");
++ AT91F_DBGU_Printk("IUD");
+ while (1);
+ }
+
@@ -76,7 +76,7 @@
- //*----------------------------------------------------------------------------
- void AT91F_UndefHandler()
- {
-- AT91F_DBGU_Printk("-F- Undef detected\n\r");
-+ AT91F_DBGU_Printk("IUD");
- while (1);
- }
-
+ //*----------------------------------------------------------------------------
+ void AT91F_UndefHandler()
+ {
+- AT91F_DBGU_Printk("-F- Undef detected\n\r");
++ AT91F_DBGU_Printk("IUD");
+ while (1);
+ }
+
diff -urN romboot.old/main.cpp romboot/main.cpp
--- romboot.old/main.cpp 2007-03-19 12:44:03.000000000 +0100
+++ romboot/main.cpp 2007-03-21 19:23:41.000000000 +0100
@@ -33,18 +33,22 @@
- #define DELAY_MAIN_FREQ 1000
- #define DISP_LINE_LEN 16
-
-+#define COMPACT 1
-+
- //* prototypes
- extern void AT91F_DBGU_Printk(char *);
- extern "C" void AT91F_ST_ASM_Handler(void);
- extern "C" void Jump(unsigned int addr);
-+extern int mci_main(void);
-
--const char *menu_separ = "*----------------------------------------*\n\r";
-+//const char *menu_separ = "*----------------------------------------*\n\r";
-
- const char *menu_dataflash = {
-- "1: Download Dataflash [addr]\n\r"
-- "2: Read Dataflash [addr]\n\r"
-- "3: Start U-BOOT\n\r"
-- "4: Clear bootloader section in Dataflash\n\r"
-+ "1: DL DF [ad]\n\r"
-+ "2: RD DF [ad]\n\r"
-+ "3: CP SD\n\r"
-+ "4: U-BOOT\n\r"
-+ "5: RM BL in DF\n\r"
- };
-
- //* Globales variables
+ #define DELAY_MAIN_FREQ 1000
+ #define DISP_LINE_LEN 16
+
++#define COMPACT 1
++
+ //* prototypes
+ extern void AT91F_DBGU_Printk(char *);
+ extern "C" void AT91F_ST_ASM_Handler(void);
+ extern "C" void Jump(unsigned int addr);
++extern int mci_main(void);
+
+-const char *menu_separ = "*----------------------------------------*\n\r";
++//const char *menu_separ = "*----------------------------------------*\n\r";
+
+ const char *menu_dataflash = {
+- "1: Download Dataflash [addr]\n\r"
+- "2: Read Dataflash [addr]\n\r"
+- "3: Start U-BOOT\n\r"
+- "4: Clear bootloader section in Dataflash\n\r"
++ "1: DL DF [ad]\n\r"
++ "2: RD DF [ad]\n\r"
++ "3: CP SD\n\r"
++ "4: U-BOOT\n\r"
++ "5: RM BL in DF\n\r"
+ };
+
+ //* Globales variables
@@ -151,12 +155,12 @@
- //*-----------------------------------------------------------------------------
- void AT91F_DisplayMenu(void)
- {
-- printf("\n\rFDL LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
-- printf(menu_separ);
-+ printf("\n\rFDL SD-Card LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
-+// printf(menu_separ);
- AT91F_DataflashPrintInfo();
-- printf(menu_separ);
-+// printf(menu_separ);
- printf(menu_dataflash);
-- printf(menu_separ);
-+// printf(menu_separ);
- }
-
- //*-----------------------------------------------------------------------------
+ //*-----------------------------------------------------------------------------
+ void AT91F_DisplayMenu(void)
+ {
+- printf("\n\rFDL LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
+- printf(menu_separ);
++ printf("\n\rFDL SD-Card LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
++// printf(menu_separ);
+ AT91F_DataflashPrintInfo();
+- printf(menu_separ);
++// printf(menu_separ);
+ printf(menu_dataflash);
+- printf(menu_separ);
++// printf(menu_separ);
+ }
+
+ //*-----------------------------------------------------------------------------
@@ -194,6 +198,7 @@
- }
-
-
-+#ifndef COMPACT
- //*-----------------------------------------------------------------------------
- //* Function Name : AT91F_MemoryDisplay()
- //* Object : Display the content of the dataflash
+ }
+
+
++#ifndef COMPACT
+ //*-----------------------------------------------------------------------------
+ //* Function Name : AT91F_MemoryDisplay()
+ //* Object : Display the content of the dataflash
@@ -244,7 +249,7 @@
- } while (nbytes > 0);
- return 0;
- }
--
-+#endif
-
- //*--------------------------------------------------------------------------------------
- //* Function Name : AT91F_SetPLL
+ } while (nbytes > 0);
+ return 0;
+ }
+-
++#endif
+
+ //*--------------------------------------------------------------------------------------
+ //* Function Name : AT91F_SetPLL
@@ -306,7 +311,7 @@
- AT91F_SetPLL();
- }
-
--void LedCode(void)
-+/*void LedCode(void)
- {
- int *pRegister;
- pRegister = (int *)0xFFFFF800; // Enable port C peripheral reg
+ AT91F_SetPLL();
+ }
+
+-void LedCode(void)
++/*void LedCode(void)
+ {
+ int *pRegister;
+ pRegister = (int *)0xFFFFF800; // Enable port C peripheral reg
@@ -318,15 +323,16 @@
- pRegister = (int *)0xFFFFF834; // Clear bits
- *pRegister = 0x2800;
- }
-+*/
-
- void AT91F_StartUboot(unsigned int dummy, void *pvoid)
- {
-- printf("Load U-BOOT from dataflash[%x] to SDRAM[%x]\n\r", AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_ADDR);
-+ //printf("Load U-BOOT from dataflash[%x] to SDRAM[%x]\n\r", AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_ADDR);
- read_dataflash(AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_SIZE, (char *)(AT91C_UBOOT_ADDR));
-- printf("Set PLLA to 180Mhz and Master clock to 60Mhz and start U-BOOT\n\r");
-+ //printf("Set PLLA to 180Mhz and Master clock to 60Mhz and start U-BOOT\n\r");
- //* Reset registers
- AT91F_ResetRegisters();
-- LedCode();
-+// LedCode();
- Jump(AT91C_UBOOT_ADDR);
- while(1);
- }
+ pRegister = (int *)0xFFFFF834; // Clear bits
+ *pRegister = 0x2800;
+ }
++*/
+
+ void AT91F_StartUboot(unsigned int dummy, void *pvoid)
+ {
+- printf("Load U-BOOT from dataflash[%x] to SDRAM[%x]\n\r", AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_ADDR);
++ //printf("Load U-BOOT from dataflash[%x] to SDRAM[%x]\n\r", AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_ADDR);
+ read_dataflash(AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_SIZE, (char *)(AT91C_UBOOT_ADDR));
+- printf("Set PLLA to 180Mhz and Master clock to 60Mhz and start U-BOOT\n\r");
++ //printf("Set PLLA to 180Mhz and Master clock to 60Mhz and start U-BOOT\n\r");
+ //* Reset registers
+ AT91F_ResetRegisters();
+- LedCode();
++// LedCode();
+ Jump(AT91C_UBOOT_ADDR);
+ while(1);
+ }
@@ -385,120 +391,124 @@
- // start tempo to start Uboot in a delay of 1 sec if no key pressed
- svcUbootTempo.Start(&svcUbootTempo, 1000, 0, AT91F_StartUboot, (void *)0);
-
-- printf("press any key to enter bootloader\n\r");
-+ printf("press key\n\r");
- getc();
-
- // stop tempo
- svcUbootTempo.Stop(&svcUbootTempo);
-
-- while(1)
-- {
-- while(command == 0)
-- {
-- AddressToDownload = AT91C_DOWNLOAD_BASE_ADDRESS;
-- SizeToDownload = AT91C_DOWNLOAD_MAX_SIZE;
-- DeviceAddress = 0;
-+ while(1) {
-+ while(command == 0) {
-+ AddressToDownload = AT91C_DOWNLOAD_BASE_ADDRESS;
-+ SizeToDownload = AT91C_DOWNLOAD_MAX_SIZE;
-+ DeviceAddress = 0;
-
-- AT91F_DisplayMenu();
-- message[0] = 0;
-- message[2] = 0;
-- AT91F_ReadLine("Enter: ", message);
-+ AT91F_DisplayMenu();
-+ message[0] = 0;
-+ message[2] = 0;
-+ AT91F_ReadLine("Enter: ", message);
-
-- command = message[0];
-- if(command == '1' || command == '2')
-- if(AsciiToHex(&message[2], &DeviceAddress) == 0)
-- command = 0;
--
-- switch(command)
-- {
-- case '1':
-- printf("Download Dataflash [0x%x]\n\r", DeviceAddress);
--
-- switch(DeviceAddress & 0xFF000000)
-- {
-- case CFG_DATAFLASH_LOGIC_ADDR_CS0:
-- device = 0;
-- break;
-+ command = message[0];
-+ if(command == '1' || command == '2')
-+ if(AsciiToHex(&message[2], &DeviceAddress) == 0)
-+ command = 0;
-+
-+ switch(command) {
-+ case '1':
-+ printf("DL DF [0x%x]\n\r", DeviceAddress);
-+
-+ switch(DeviceAddress & 0xFF000000) {
-+ case CFG_DATAFLASH_LOGIC_ADDR_CS0:
-+ device = 0;
-+ break;
-
-- case CFG_DATAFLASH_LOGIC_ADDR_CS3:
-- device = 1;
-- break;
-+ case CFG_DATAFLASH_LOGIC_ADDR_CS3:
-+ device = 1;
-+ break;
-
-- default:
-- command = 0;
-- break;
-- }
-- break;
--
-- case '2':
-- do
-- {
-- AT91F_MemoryDisplay(DeviceAddress, 4, 64);
-- AT91F_ReadLine ((char *)0, message);
-- DeviceAddress += 0x100;
-+ default:
-+ command = 0;
-+ break;
-+ }
-+ break;
-+
-+#ifndef COMPACT
-+ case '2':
-+ do {
-+ AT91F_MemoryDisplay(DeviceAddress, 4, 64);
-+ AT91F_ReadLine ((char *)0, message);
-+ DeviceAddress += 0x100;
-+ } while(message[0] == '\0');
-+ command = 0;
-+ break;
-+#endif
-+
-+ case '3':
-+ mci_main();
-+ command=0;
-+ break;
-+
-+ case '4':
-+ AT91F_StartUboot(0, (void *)0);
-+ command = 0;
-+ break;
-+
-+ case '5':
-+ {
-+ int *i;
-+
-+ for(i = (int *)0x20000000; i < (int *)0x20004000; i++)
-+ *i = 0;
-+ }
-+ write_dataflash(0xc0000000, 0x20000000, 0x4000);
-+ printf("BL CLR\r\n");
-+ command = 0;
-+ break;
-+
-+ default:
-+ command = 0;
-+ break;
-+ } // switch(command)
-+ } // while(command == 0)
-+
-+ xmodemPipe.Read(&xmodemPipe, (char *)AddressToDownload, SizeToDownload, XmodemProtocol, 0);
-+ while(XmodemComplete !=1);
-+ SizeToDownload = (unsigned int)(svcXmodem.pData) - (unsigned int)AddressToDownload;
-+
-+ // Modification of vector 6
-+ NbPage = 0;
-+ i = dataflash_info[device].Device.pages_number;
-+ while(i >>= 1)
-+ NbPage++;
-+ i = (SizeToDownload / 512) + 1 + (NbPage << 13) + (dataflash_info[device].Device.pages_size << 17);
-+ *(int *)(AddressToDownload + AT91C_OFFSET_VECT6) = i;
-+
-+// printf("\n\rModification of Arm Vector 6 :%x\n\r", i);
-+
-+ printf("\n\rWR %d in DF [0x%x]\n\r",SizeToDownload, DeviceAddress);
-+ crc1 = 0;
-+ pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc1);
-+
-+ // write the dataflash
-+ write_dataflash (DeviceAddress, AddressToDownload, SizeToDownload);
-+ // clear the buffer before read
-+ for(i=0; i < SizeToDownload; i++)
-+ *(unsigned char *)(AddressToDownload + i) = 0;
-+
-+ //* Read dataflash page in TestBuffer
-+ read_dataflash (DeviceAddress, SizeToDownload, (char *)(AddressToDownload));
-+
-+ printf("Vfy DF: ");
-+ crc2 = 0;
-+
-+ pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc2);
-+ if (crc1 != crc2)
-+ printf("Fail\r\n");
-+ else
-+ printf("OK\r\n");
-+
-+ command = 0;
-+ XmodemComplete = 0;
-+ AT91F_WaitKeyPressed();
- }
-- while(message[0] == '\0');
-- command = 0;
-- break;
--
-- case '3':
-- AT91F_StartUboot(0, (void *)0);
-- command = 0;
-- break;
-- case '4':
-- {
-- int *i;
-- for(i = (int *)0x20000000; i < (int *)0x20004000; i++)
-- *i = 0;
-- }
-- write_dataflash(0xc0000000, 0x20000000, 0x4000);
-- printf("Bootsection cleared\r\n");
-- command = 0;
-- break;
-- default:
-- command = 0;
-- break;
-- }
- }
--
-- xmodemPipe.Read(&xmodemPipe, (char *)AddressToDownload, SizeToDownload, XmodemProtocol, 0);
-- while(XmodemComplete !=1);
-- SizeToDownload = (unsigned int)(svcXmodem.pData) - (unsigned int)AddressToDownload;
--
-- // Modification of vector 6
-- NbPage = 0;
-- i = dataflash_info[device].Device.pages_number;
-- while(i >>= 1)
-- NbPage++;
-- i = (SizeToDownload / 512) + 1 + (NbPage << 13) + (dataflash_info[device].Device.pages_size << 17);
-- *(int *)(AddressToDownload + AT91C_OFFSET_VECT6) = i;
--
-- printf("\n\rModification of Arm Vector 6 :%x\n\r", i);
--
-- printf("\n\rWrite %d bytes in DataFlash [0x%x]\n\r",SizeToDownload, DeviceAddress);
-- crc1 = 0;
-- pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc1);
--
-- // write the dataflash
-- write_dataflash (DeviceAddress, AddressToDownload, SizeToDownload);
-- // clear the buffer before read
-- for(i=0; i < SizeToDownload; i++)
-- *(unsigned char *)(AddressToDownload + i) = 0;
--
-- //* Read dataflash page in TestBuffer
-- read_dataflash (DeviceAddress, SizeToDownload, (char *)(AddressToDownload));
--
-- printf("Verify Dataflash: ");
-- crc2 = 0;
--
-- pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc2);
-- if (crc1 != crc2)
-- printf("Failed\r\n");
-- else
-- printf("OK\r\n");
--
-- command = 0;
-- XmodemComplete = 0;
-- AT91F_WaitKeyPressed();
-- }
--}
+ // start tempo to start Uboot in a delay of 1 sec if no key pressed
+ svcUbootTempo.Start(&svcUbootTempo, 1000, 0, AT91F_StartUboot, (void *)0);
+
+- printf("press any key to enter bootloader\n\r");
++ printf("press key\n\r");
+ getc();
+
+ // stop tempo
+ svcUbootTempo.Stop(&svcUbootTempo);
+
+- while(1)
+- {
+- while(command == 0)
+- {
+- AddressToDownload = AT91C_DOWNLOAD_BASE_ADDRESS;
+- SizeToDownload = AT91C_DOWNLOAD_MAX_SIZE;
+- DeviceAddress = 0;
++ while(1) {
++ while(command == 0) {
++ AddressToDownload = AT91C_DOWNLOAD_BASE_ADDRESS;
++ SizeToDownload = AT91C_DOWNLOAD_MAX_SIZE;
++ DeviceAddress = 0;
+
+- AT91F_DisplayMenu();
+- message[0] = 0;
+- message[2] = 0;
+- AT91F_ReadLine("Enter: ", message);
++ AT91F_DisplayMenu();
++ message[0] = 0;
++ message[2] = 0;
++ AT91F_ReadLine("Enter: ", message);
+
+- command = message[0];
+- if(command == '1' || command == '2')
+- if(AsciiToHex(&message[2], &DeviceAddress) == 0)
+- command = 0;
+-
+- switch(command)
+- {
+- case '1':
+- printf("Download Dataflash [0x%x]\n\r", DeviceAddress);
+-
+- switch(DeviceAddress & 0xFF000000)
+- {
+- case CFG_DATAFLASH_LOGIC_ADDR_CS0:
+- device = 0;
+- break;
++ command = message[0];
++ if(command == '1' || command == '2')
++ if(AsciiToHex(&message[2], &DeviceAddress) == 0)
++ command = 0;
++
++ switch(command) {
++ case '1':
++ printf("DL DF [0x%x]\n\r", DeviceAddress);
++
++ switch(DeviceAddress & 0xFF000000) {
++ case CFG_DATAFLASH_LOGIC_ADDR_CS0:
++ device = 0;
++ break;
+
+- case CFG_DATAFLASH_LOGIC_ADDR_CS3:
+- device = 1;
+- break;
++ case CFG_DATAFLASH_LOGIC_ADDR_CS3:
++ device = 1;
++ break;
+
+- default:
+- command = 0;
+- break;
+- }
+- break;
+-
+- case '2':
+- do
+- {
+- AT91F_MemoryDisplay(DeviceAddress, 4, 64);
+- AT91F_ReadLine ((char *)0, message);
+- DeviceAddress += 0x100;
++ default:
++ command = 0;
++ break;
++ }
++ break;
++
++#ifndef COMPACT
++ case '2':
++ do {
++ AT91F_MemoryDisplay(DeviceAddress, 4, 64);
++ AT91F_ReadLine ((char *)0, message);
++ DeviceAddress += 0x100;
++ } while(message[0] == '\0');
++ command = 0;
++ break;
++#endif
++
++ case '3':
++ mci_main();
++ command=0;
++ break;
++
++ case '4':
++ AT91F_StartUboot(0, (void *)0);
++ command = 0;
++ break;
++
++ case '5':
++ {
++ int *i;
++
++ for(i = (int *)0x20000000; i < (int *)0x20004000; i++)
++ *i = 0;
++ }
++ write_dataflash(0xc0000000, 0x20000000, 0x4000);
++ printf("BL CLR\r\n");
++ command = 0;
++ break;
++
++ default:
++ command = 0;
++ break;
++ } // switch(command)
++ } // while(command == 0)
++
++ xmodemPipe.Read(&xmodemPipe, (char *)AddressToDownload, SizeToDownload, XmodemProtocol, 0);
++ while(XmodemComplete !=1);
++ SizeToDownload = (unsigned int)(svcXmodem.pData) - (unsigned int)AddressToDownload;
++
++ // Modification of vector 6
++ NbPage = 0;
++ i = dataflash_info[device].Device.pages_number;
++ while(i >>= 1)
++ NbPage++;
++ i = (SizeToDownload / 512) + 1 + (NbPage << 13) + (dataflash_info[device].Device.pages_size << 17);
++ *(int *)(AddressToDownload + AT91C_OFFSET_VECT6) = i;
++
++// printf("\n\rModification of Arm Vector 6 :%x\n\r", i);
++
++ printf("\n\rWR %d in DF [0x%x]\n\r",SizeToDownload, DeviceAddress);
++ crc1 = 0;
++ pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc1);
++
++ // write the dataflash
++ write_dataflash (DeviceAddress, AddressToDownload, SizeToDownload);
++ // clear the buffer before read
++ for(i=0; i < SizeToDownload; i++)
++ *(unsigned char *)(AddressToDownload + i) = 0;
++
++ //* Read dataflash page in TestBuffer
++ read_dataflash (DeviceAddress, SizeToDownload, (char *)(AddressToDownload));
++
++ printf("Vfy DF: ");
++ crc2 = 0;
++
++ pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc2);
++ if (crc1 != crc2)
++ printf("Fail\r\n");
++ else
++ printf("OK\r\n");
++
++ command = 0;
++ XmodemComplete = 0;
++ AT91F_WaitKeyPressed();
+ }
+- while(message[0] == '\0');
+- command = 0;
+- break;
+-
+- case '3':
+- AT91F_StartUboot(0, (void *)0);
+- command = 0;
+- break;
+- case '4':
+- {
+- int *i;
+- for(i = (int *)0x20000000; i < (int *)0x20004000; i++)
+- *i = 0;
+- }
+- write_dataflash(0xc0000000, 0x20000000, 0x4000);
+- printf("Bootsection cleared\r\n");
+- command = 0;
+- break;
+- default:
+- command = 0;
+- break;
+- }
+ }
+-
+- xmodemPipe.Read(&xmodemPipe, (char *)AddressToDownload, SizeToDownload, XmodemProtocol, 0);
+- while(XmodemComplete !=1);
+- SizeToDownload = (unsigned int)(svcXmodem.pData) - (unsigned int)AddressToDownload;
+-
+- // Modification of vector 6
+- NbPage = 0;
+- i = dataflash_info[device].Device.pages_number;
+- while(i >>= 1)
+- NbPage++;
+- i = (SizeToDownload / 512) + 1 + (NbPage << 13) + (dataflash_info[device].Device.pages_size << 17);
+- *(int *)(AddressToDownload + AT91C_OFFSET_VECT6) = i;
+-
+- printf("\n\rModification of Arm Vector 6 :%x\n\r", i);
+-
+- printf("\n\rWrite %d bytes in DataFlash [0x%x]\n\r",SizeToDownload, DeviceAddress);
+- crc1 = 0;
+- pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc1);
+-
+- // write the dataflash
+- write_dataflash (DeviceAddress, AddressToDownload, SizeToDownload);
+- // clear the buffer before read
+- for(i=0; i < SizeToDownload; i++)
+- *(unsigned char *)(AddressToDownload + i) = 0;
+-
+- //* Read dataflash page in TestBuffer
+- read_dataflash (DeviceAddress, SizeToDownload, (char *)(AddressToDownload));
+-
+- printf("Verify Dataflash: ");
+- crc2 = 0;
+-
+- pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc2);
+- if (crc1 != crc2)
+- printf("Failed\r\n");
+- else
+- printf("OK\r\n");
+-
+- command = 0;
+- XmodemComplete = 0;
+- AT91F_WaitKeyPressed();
+- }
+-}
diff -urN romboot.old/main.h romboot/main.h
--- romboot.old/main.h 2004-07-03 17:41:14.000000000 +0200
+++ romboot/main.h 2007-03-21 21:48:52.000000000 +0100
@@ -27,7 +27,7 @@
-
- #define AT91C_OFFSET_VECT6 0x14 //* Offset for ARM vector 6
-
--#define AT91C_VERSION "VER 1.01"
-+#define AT91C_VERSION "VER 1.02"
- // Global variables and functions definition
- extern unsigned int GetTickCount(void);
- #endif
+
+ #define AT91C_OFFSET_VECT6 0x14 //* Offset for ARM vector 6
+
+-#define AT91C_VERSION "VER 1.01"
++#define AT91C_VERSION "VER 1.02"
+ // Global variables and functions definition
+ extern unsigned int GetTickCount(void);
+ #endif
diff -urN romboot.old/Makefile romboot/Makefile
--- romboot.old/Makefile 2007-03-19 12:44:03.000000000 +0100
+++ romboot/Makefile 2007-03-21 12:29:11.000000000 +0100
diff --git a/target/linux/at91-2.6/image/romboot/patches/003-SD-reflash.patch b/target/linux/at91-2.6/image/romboot/patches/003-SD-reflash.patch
index e0b5e0733..b0d5baf03 100644
--- a/target/linux/at91-2.6/image/romboot/patches/003-SD-reflash.patch
+++ b/target/linux/at91-2.6/image/romboot/patches/003-SD-reflash.patch
@@ -2,251 +2,251 @@ diff -urN romboot.old/init.cpp romboot/init.cpp
--- romboot.old/init.cpp 2007-03-24 13:34:19.000000000 +0100
+++ romboot/init.cpp 2007-03-24 12:23:19.000000000 +0100
@@ -207,9 +207,10 @@
- AT91F_US_EnableRx((AT91PS_USART)AT91C_BASE_DBGU);
-
- /* Enable PIO to access the LEDs */
-- AT91C_BASE_PIOB->PIO_PER = AT91C_PIO_PB2;
-- AT91C_BASE_PIOB->PIO_OER = AT91C_PIO_PB2;
-- AT91C_BASE_PIOB->PIO_CODR = AT91C_PIO_PB2;
-+ AT91C_BASE_PIOC->PIO_PER = AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15;
-+ AT91C_BASE_PIOC->PIO_OER = AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15;
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15;
-+ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC8 | AT91C_PIO_PC14;
-
- // AT91F_DBGU_Printk("\n\rAT91F_LowLevelInit(): Debug channel initialized\n\r");
- }
+ AT91F_US_EnableRx((AT91PS_USART)AT91C_BASE_DBGU);
+
+ /* Enable PIO to access the LEDs */
+- AT91C_BASE_PIOB->PIO_PER = AT91C_PIO_PB2;
+- AT91C_BASE_PIOB->PIO_OER = AT91C_PIO_PB2;
+- AT91C_BASE_PIOB->PIO_CODR = AT91C_PIO_PB2;
++ AT91C_BASE_PIOC->PIO_PER = AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15;
++ AT91C_BASE_PIOC->PIO_OER = AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15;
++ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15;
++ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC8 | AT91C_PIO_PC14;
+
+ // AT91F_DBGU_Printk("\n\rAT91F_LowLevelInit(): Debug channel initialized\n\r");
+ }
diff -urN romboot.old/main.cpp romboot/main.cpp
--- romboot.old/main.cpp 2007-03-24 13:34:19.000000000 +0100
+++ romboot/main.cpp 2007-03-24 12:28:55.000000000 +0100
@@ -13,6 +13,7 @@
- //*----------------------------------------------------------------------------
- #include <AT91RM9200.h>
- #include <lib_AT91RM9200.h>
-+#include <AT91C_MCI_Device.h>
-
- #include "com.h"
- #include "main.h"
+ //*----------------------------------------------------------------------------
+ #include <AT91RM9200.h>
+ #include <lib_AT91RM9200.h>
++#include <AT91C_MCI_Device.h>
+
+ #include "com.h"
+ #include "main.h"
@@ -39,16 +40,31 @@
- extern void AT91F_DBGU_Printk(char *);
- extern "C" void AT91F_ST_ASM_Handler(void);
- extern "C" void Jump(unsigned int addr);
--extern int mci_main(void);
-+extern int AT91F_MCI_Init(void);
-+#define TRUE 1
-+#define FALSE 0
-+
-+/* from trxhdr.h */
-+
-+#define TRX_MAGIC 0x30524448 /* "HDR0" */
-+#define TRX_VERSION 1
-+
-+struct trx_header {
-+ unsigned int magic;
-+ unsigned int len;
-+ unsigned int crc32;
-+ unsigned int flag_version;
-+ unsigned int offsets[3];
-+};
-
- //const char *menu_separ = "*----------------------------------------*\n\r";
-
- const char *menu_dataflash = {
-- "1: DL DF [ad]\n\r"
-- "2: RD DF [ad]\n\r"
-- "3: CP SD\n\r"
-- "4: U-BOOT\n\r"
-- "5: RM BL in DF\n\r"
-+ "1: Download DF [addr]\n\r"
-+ "2: Read DF [addr]\n\r"
-+ "3: Copy SD-Card\n\r"
-+ "4: Start U-BOOT\n\r"
-+ "5: Clear bootloder\n\r"
- };
-
- //* Globales variables
+ extern void AT91F_DBGU_Printk(char *);
+ extern "C" void AT91F_ST_ASM_Handler(void);
+ extern "C" void Jump(unsigned int addr);
+-extern int mci_main(void);
++extern int AT91F_MCI_Init(void);
++#define TRUE 1
++#define FALSE 0
++
++/* from trxhdr.h */
++
++#define TRX_MAGIC 0x30524448 /* "HDR0" */
++#define TRX_VERSION 1
++
++struct trx_header {
++ unsigned int magic;
++ unsigned int len;
++ unsigned int crc32;
++ unsigned int flag_version;
++ unsigned int offsets[3];
++};
+
+ //const char *menu_separ = "*----------------------------------------*\n\r";
+
+ const char *menu_dataflash = {
+- "1: DL DF [ad]\n\r"
+- "2: RD DF [ad]\n\r"
+- "3: CP SD\n\r"
+- "4: U-BOOT\n\r"
+- "5: RM BL in DF\n\r"
++ "1: Download DF [addr]\n\r"
++ "2: Read DF [addr]\n\r"
++ "3: Copy SD-Card\n\r"
++ "4: Start U-BOOT\n\r"
++ "5: Clear bootloder\n\r"
+ };
+
+ //* Globales variables
@@ -155,14 +171,15 @@
- //*-----------------------------------------------------------------------------
- void AT91F_DisplayMenu(void)
- {
-- printf("\n\rFDL SD-Card LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
--// printf(menu_separ);
-- AT91F_DataflashPrintInfo();
--// printf(menu_separ);
- printf(menu_dataflash);
--// printf(menu_separ);
- }
-
-+void AT91F_DisplayIntro(void)
-+{
-+ printf("\n\rFDL LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
-+ AT91F_DataflashPrintInfo();
-+}
-+
- //*-----------------------------------------------------------------------------
- //* Function Name : AsciiToHex()
- //* Object : ascii to hexa conversion
+ //*-----------------------------------------------------------------------------
+ void AT91F_DisplayMenu(void)
+ {
+- printf("\n\rFDL SD-Card LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
+-// printf(menu_separ);
+- AT91F_DataflashPrintInfo();
+-// printf(menu_separ);
+ printf(menu_dataflash);
+-// printf(menu_separ);
+ }
+
++void AT91F_DisplayIntro(void)
++{
++ printf("\n\rFDL LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);
++ AT91F_DataflashPrintInfo();
++}
++
+ //*-----------------------------------------------------------------------------
+ //* Function Name : AsciiToHex()
+ //* Object : ascii to hexa conversion
@@ -311,23 +328,24 @@
- AT91F_SetPLL();
- }
-
--/*void LedCode(void)
-+/*
-+void LedCode(void)
- {
- int *pRegister;
- pRegister = (int *)0xFFFFF800; // Enable port C peripheral reg
-- *pRegister = 0x3c00;
-+ *pRegister = (AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15);
- pRegister = (int *)0xFFFFF810; // Output Enable reg
-- *pRegister = 0x3c00;
-+ *pRegister = (AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15);
- pRegister = (int *)0xFFFFF830; // Set data
-- *pRegister = 0x1400;
-+ *pRegister = AT91C_PIO_PC7 | AT91C_PIO_PC15;
- pRegister = (int *)0xFFFFF834; // Clear bits
-- *pRegister = 0x2800;
-+ *pRegister = AT91C_PIO_PC8 | AT91C_PIO_PC14;
- }
- */
-
-+
- void AT91F_StartUboot(unsigned int dummy, void *pvoid)
- {
-- //printf("Load U-BOOT from dataflash[%x] to SDRAM[%x]\n\r", AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_ADDR);
- read_dataflash(AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_SIZE, (char *)(AT91C_UBOOT_ADDR));
- //printf("Set PLLA to 180Mhz and Master clock to 60Mhz and start U-BOOT\n\r");
- //* Reset registers
+ AT91F_SetPLL();
+ }
+
+-/*void LedCode(void)
++/*
++void LedCode(void)
+ {
+ int *pRegister;
+ pRegister = (int *)0xFFFFF800; // Enable port C peripheral reg
+- *pRegister = 0x3c00;
++ *pRegister = (AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15);
+ pRegister = (int *)0xFFFFF810; // Output Enable reg
+- *pRegister = 0x3c00;
++ *pRegister = (AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15);
+ pRegister = (int *)0xFFFFF830; // Set data
+- *pRegister = 0x1400;
++ *pRegister = AT91C_PIO_PC7 | AT91C_PIO_PC15;
+ pRegister = (int *)0xFFFFF834; // Clear bits
+- *pRegister = 0x2800;
++ *pRegister = AT91C_PIO_PC8 | AT91C_PIO_PC14;
+ }
+ */
+
++
+ void AT91F_StartUboot(unsigned int dummy, void *pvoid)
+ {
+- //printf("Load U-BOOT from dataflash[%x] to SDRAM[%x]\n\r", AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_ADDR);
+ read_dataflash(AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_SIZE, (char *)(AT91C_UBOOT_ADDR));
+ //printf("Set PLLA to 180Mhz and Master clock to 60Mhz and start U-BOOT\n\r");
+ //* Reset registers
@@ -337,6 +355,67 @@
- while(1);
- }
-
-+#define AT91C_MCI_TIMEOUT 1000000
-+
-+extern AT91S_MciDevice MCI_Device;
-+
-+extern void AT91F_MCIDeviceWaitReady(unsigned int);
-+extern int AT91F_MCI_ReadBlockSwab(AT91PS_MciDevice, int, unsigned int *, int);
-+
-+
-+int Program_From_MCI(void)
-+{
-+ int i;
-+ unsigned int Max_Read_DataBlock_Length;
-+ int block = 0;
-+ int buffer = AT91C_DOWNLOAD_BASE_ADDRESS;
-+ int bufpos = AT91C_DOWNLOAD_BASE_ADDRESS;
-+ int NbPage = 0;
-+ struct trx_header *p;
-+ unsigned int data;
-+
-+ p = (struct trx_header *)bufpos;
-+
-+ Max_Read_DataBlock_Length = MCI_Device.pMCI_DeviceFeatures->Max_Read_DataBlock_Length;
-+
-+ AT91F_MCIDeviceWaitReady(AT91C_MCI_TIMEOUT);
-+
-+ AT91F_MCI_ReadBlockSwab(&MCI_Device, block*Max_Read_DataBlock_Length, (unsigned int *)bufpos, Max_Read_DataBlock_Length);
-+
-+ if (p->magic != TRX_MAGIC)
-+ return FALSE;
-+
-+ printf("Read SD-Card\n\r");
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15 | AT91C_PIO_PC8 | AT91C_PIO_PC14;
-+ for (i=0; i<(p->len/512); i++) {
-+ AT91F_MCI_ReadBlockSwab(&MCI_Device, block*Max_Read_DataBlock_Length, (unsigned int *)bufpos, Max_Read_DataBlock_Length);
-+ block++;
-+ bufpos += Max_Read_DataBlock_Length;
-+ }
-+
-+ NbPage = 0;
-+ i = dataflash_info[0].Device.pages_number;
-+ while(i >>= 1)
-+ NbPage++;
-+ i = ((p->offsets[1] - p->offsets[0])/ 512) + 1 + (NbPage << 13) + (dataflash_info[0].Device.pages_size << 17);
-+ *(int *)(buffer + p->offsets[0] + AT91C_OFFSET_VECT6) = i;
-+
-+ printf("Write romboot\n\r");
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15 | AT91C_PIO_PC14;
-+ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC8;
-+ write_dataflash(0xc0000000, buffer + p->offsets[0], p->offsets[1] - p->offsets[0]);
-+ printf("Write u-boot\n\r");
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15;
-+ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC8 | AT91C_PIO_PC14;
-+ write_dataflash(0xc0008000, buffer + p->offsets[1], p->offsets[2] - p->offsets[1]);
-+ printf("Write knl/root\n\r");
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC8 | AT91C_PIO_PC15;
-+ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC7 | AT91C_PIO_PC14;
-+ write_dataflash(0xc0042000, buffer + p->offsets[2], p->len - p->offsets[2]);
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC8 | AT91C_PIO_PC14;
-+ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC7 | AT91C_PIO_PC15;
-+ return TRUE;
-+ }
-
- //*----------------------------------------------------------------------------
- //* Function Name : main
+ while(1);
+ }
+
++#define AT91C_MCI_TIMEOUT 1000000
++
++extern AT91S_MciDevice MCI_Device;
++
++extern void AT91F_MCIDeviceWaitReady(unsigned int);
++extern int AT91F_MCI_ReadBlockSwab(AT91PS_MciDevice, int, unsigned int *, int);
++
++
++int Program_From_MCI(void)
++{
++ int i;
++ unsigned int Max_Read_DataBlock_Length;
++ int block = 0;
++ int buffer = AT91C_DOWNLOAD_BASE_ADDRESS;
++ int bufpos = AT91C_DOWNLOAD_BASE_ADDRESS;
++ int NbPage = 0;
++ struct trx_header *p;
++ unsigned int data;
++
++ p = (struct trx_header *)bufpos;
++
++ Max_Read_DataBlock_Length = MCI_Device.pMCI_DeviceFeatures->Max_Read_DataBlock_Length;
++
++ AT91F_MCIDeviceWaitReady(AT91C_MCI_TIMEOUT);
++
++ AT91F_MCI_ReadBlockSwab(&MCI_Device, block*Max_Read_DataBlock_Length, (unsigned int *)bufpos, Max_Read_DataBlock_Length);
++
++ if (p->magic != TRX_MAGIC)
++ return FALSE;
++
++ printf("Read SD-Card\n\r");
++ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15 | AT91C_PIO_PC8 | AT91C_PIO_PC14;
++ for (i=0; i<(p->len/512); i++) {
++ AT91F_MCI_ReadBlockSwab(&MCI_Device, block*Max_Read_DataBlock_Length, (unsigned int *)bufpos, Max_Read_DataBlock_Length);
++ block++;
++ bufpos += Max_Read_DataBlock_Length;
++ }
++
++ NbPage = 0;
++ i = dataflash_info[0].Device.pages_number;
++ while(i >>= 1)
++ NbPage++;
++ i = ((p->offsets[1] - p->offsets[0])/ 512) + 1 + (NbPage << 13) + (dataflash_info[0].Device.pages_size << 17);
++ *(int *)(buffer + p->offsets[0] + AT91C_OFFSET_VECT6) = i;
++
++ printf("Write romboot\n\r");
++ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15 | AT91C_PIO_PC14;
++ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC8;
++ write_dataflash(0xc0000000, buffer + p->offsets[0], p->offsets[1] - p->offsets[0]);
++ printf("Write u-boot\n\r");
++ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15;
++ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC8 | AT91C_PIO_PC14;
++ write_dataflash(0xc0008000, buffer + p->offsets[1], p->offsets[2] - p->offsets[1]);
++ printf("Write knl/root\n\r");
++ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC8 | AT91C_PIO_PC15;
++ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC7 | AT91C_PIO_PC14;
++ write_dataflash(0xc0042000, buffer + p->offsets[2], p->len - p->offsets[2]);
++ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC8 | AT91C_PIO_PC14;
++ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC7 | AT91C_PIO_PC15;
++ return TRUE;
++ }
+
+ //*----------------------------------------------------------------------------
+ //* Function Name : main
@@ -357,6 +436,7 @@
- unsigned int crc1 = 0, crc2 = 0;
- volatile int device;
- int NbPage;
-+ int mci_present;
-
- stdin = fopen(0, at91_dbgu_getc);
- stdout = fopen(at91_dbgu_putc, 0);
+ unsigned int crc1 = 0, crc2 = 0;
+ volatile int device;
+ int NbPage;
++ int mci_present;
+
+ stdin = fopen(0, at91_dbgu_getc);
+ stdout = fopen(at91_dbgu_putc, 0);
@@ -387,6 +467,15 @@
-
- // DataFlash on SPI Configuration
- AT91F_DataflashInit ();
-+ AT91F_DisplayIntro();
-+ mci_present = AT91F_MCI_Init();
-+
-+#ifdef PRODTEST
-+ if (mci_present) {
-+ Program_From_MCI();
-+ AT91F_StartUboot(0, (void *)0);
-+ }
-+#endif
-
- // start tempo to start Uboot in a delay of 1 sec if no key pressed
- svcUbootTempo.Start(&svcUbootTempo, 1000, 0, AT91F_StartUboot, (void *)0);
+
+ // DataFlash on SPI Configuration
+ AT91F_DataflashInit ();
++ AT91F_DisplayIntro();
++ mci_present = AT91F_MCI_Init();
++
++#ifdef PRODTEST
++ if (mci_present) {
++ Program_From_MCI();
++ AT91F_StartUboot(0, (void *)0);
++ }
++#endif
+
+ // start tempo to start Uboot in a delay of 1 sec if no key pressed
+ svcUbootTempo.Start(&svcUbootTempo, 1000, 0, AT91F_StartUboot, (void *)0);
@@ -396,7 +485,7 @@
-
- // stop tempo
- svcUbootTempo.Stop(&svcUbootTempo);
--
-+
- while(1) {
- while(command == 0) {
- AddressToDownload = AT91C_DOWNLOAD_BASE_ADDRESS;
+
+ // stop tempo
+ svcUbootTempo.Stop(&svcUbootTempo);
+-
++
+ while(1) {
+ while(command == 0) {
+ AddressToDownload = AT91C_DOWNLOAD_BASE_ADDRESS;
@@ -444,7 +533,8 @@
- #endif
-
- case '3':
-- mci_main();
-+ if (mci_present)
-+ Program_From_MCI();
- command=0;
- break;
-
+ #endif
+
+ case '3':
+- mci_main();
++ if (mci_present)
++ Program_From_MCI();
+ command=0;
+ break;
+
@@ -461,7 +551,6 @@
- *i = 0;
- }
- write_dataflash(0xc0000000, 0x20000000, 0x4000);
-- printf("BL CLR\r\n");
- command = 0;
- break;
-
+ *i = 0;
+ }
+ write_dataflash(0xc0000000, 0x20000000, 0x4000);
+- printf("BL CLR\r\n");
+ command = 0;
+ break;
+
diff -urN romboot.old/main.h romboot/main.h
--- romboot.old/main.h 2007-03-24 13:34:19.000000000 +0100
+++ romboot/main.h 2007-03-23 19:06:52.000000000 +0100
@@ -27,7 +27,7 @@
-
- #define AT91C_OFFSET_VECT6 0x14 //* Offset for ARM vector 6
-
--#define AT91C_VERSION "VER 1.02"
-+#define AT91C_VERSION "VER 1.03"
- // Global variables and functions definition
- extern unsigned int GetTickCount(void);
- #endif
+
+ #define AT91C_OFFSET_VECT6 0x14 //* Offset for ARM vector 6
+
+-#define AT91C_VERSION "VER 1.02"
++#define AT91C_VERSION "VER 1.03"
+ // Global variables and functions definition
+ extern unsigned int GetTickCount(void);
+ #endif
diff -urN romboot.old/Makefile romboot/Makefile
--- romboot.old/Makefile 2007-03-24 13:34:19.000000000 +0100
+++ romboot/Makefile 2007-03-24 10:45:38.000000000 +0100
diff --git a/target/linux/at91-2.6/image/romboot/patches/004-code-cleanup.patch b/target/linux/at91-2.6/image/romboot/patches/004-code-cleanup.patch
new file mode 100644
index 000000000..1a0f9c559
--- /dev/null
+++ b/target/linux/at91-2.6/image/romboot/patches/004-code-cleanup.patch
@@ -0,0 +1,423 @@
+diff -urN romboot.old/com.cpp romboot/com.cpp
+--- romboot.old/com.cpp 2004-07-04 21:37:05.000000000 +0200
++++ romboot/com.cpp 2007-04-04 04:30:12.000000000 +0200
+@@ -27,7 +27,7 @@
+ //*-----------------------------------------------------------------------------
+ void AT91F_ClrScr(void)
+ {
+- puts(CLRSCREEN);
++ putstr(CLRSCREEN);
+ }
+
+
+@@ -47,12 +47,12 @@
+
+ if (*(--p) == '\t') { /* will retype the whole line */
+ while (*colp > plen) {
+- puts(erase_seq);
++ putstr(erase_seq);
+ (*colp)--;
+ }
+ for (s=buffer; s<p; ++s) {
+ if (*s == '\t') {
+- puts(tab_seq+((*colp) & 07));
++ putstr(tab_seq+((*colp) & 07));
+ *colp += 8 - ((*colp) & 07);
+ } else {
+ ++(*colp);
+@@ -60,7 +60,7 @@
+ }
+ }
+ } else {
+- puts(erase_seq);
++ putstr(erase_seq);
+ (*colp)--;
+ }
+ (*np)--;
+@@ -85,7 +85,7 @@
+
+ /* print prompt */
+ if(prompt)
+- puts(prompt);
++ putstr(prompt);
+ col = plen;
+
+ for (;;)
+@@ -97,7 +97,7 @@
+ case '\r': /* Enter */
+ case '\n':
+ *p = '\0';
+- puts ("\r\n");
++ putstr ("\r\n");
+ return (p - console_buffer);
+
+ case 0x03: /* ^C - break */
+@@ -107,7 +107,7 @@
+ case 0x15: /* ^U - erase line */
+ while (col > plen)
+ {
+- puts(erase_seq);
++ putstr(erase_seq);
+ --col;
+ }
+ p = console_buffer;
+@@ -152,7 +152,7 @@
+ void AT91F_WaitKeyPressed(void)
+ {
+ int c;
+- puts("Hit a Key!");
++ putstr("Hit a Key!");
+ c = getc();
+ }
+
+diff -urN romboot.old/main.cpp romboot/main.cpp
+--- romboot.old/main.cpp 2007-04-03 12:12:33.000000000 +0200
++++ romboot/main.cpp 2007-04-04 05:56:39.000000000 +0200
+@@ -382,8 +382,10 @@
+
+ AT91F_MCI_ReadBlockSwab(&MCI_Device, block*Max_Read_DataBlock_Length, (unsigned int *)bufpos, Max_Read_DataBlock_Length);
+
+- if (p->magic != TRX_MAGIC)
++ if (p->magic != TRX_MAGIC) {
++ printf("Invalid Image 0x%08x\n\r");
+ return FALSE;
++ }
+
+ printf("Read SD-Card\n\r");
+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15 | AT91C_PIO_PC8 | AT91C_PIO_PC14;
+@@ -438,9 +440,6 @@
+ int NbPage;
+ int mci_present;
+
+- stdin = fopen(0, at91_dbgu_getc);
+- stdout = fopen(at91_dbgu_putc, 0);
+-
+ pAT91 = AT91C_ROM_BOOT_ADDRESS;
+
+ // Tempo Initialisation
+@@ -472,16 +471,18 @@
+
+ #ifdef PRODTEST
+ if (mci_present) {
+- Program_From_MCI();
+- AT91F_StartUboot(0, (void *)0);
++ if (Program_From_MCI())
++ AT91F_StartUboot(0, (void *)0);
+ }
+ #endif
+
+ // start tempo to start Uboot in a delay of 1 sec if no key pressed
+ svcUbootTempo.Start(&svcUbootTempo, 1000, 0, AT91F_StartUboot, (void *)0);
+
++#ifndef PRODTEST
+ printf("press key\n\r");
+ getc();
++#endif
+
+ // stop tempo
+ svcUbootTempo.Stop(&svcUbootTempo);
+@@ -601,3 +602,10 @@
+ AT91F_WaitKeyPressed();
+ }
+ }
++
++
++int puts(const char *str)
++{
++ putstr(str);
++ return 0;
++}
+diff -urN romboot.old/stdio.cpp romboot/stdio.cpp
+--- romboot.old/stdio.cpp 2004-07-04 22:36:10.000000000 +0200
++++ romboot/stdio.cpp 2007-04-04 04:29:25.000000000 +0200
+@@ -1,117 +1,32 @@
+ #include "stdio.h"
+
+ extern int at91_dbgu_putc(int ch);
++extern int at91_dbgu_getc();
+
+-FILE *stdout = (FILE *)0;
+-FILE *stdin = (FILE *)0;
+-
+-FILE __filedesc[FILEDESCS];
+-
+-FILE *fopen(int (*put)(int), int (*get)())
+-{
+- static int init = 1;
+-
+- if(init != 0)
+- {
+- for(int i = 0; i < FILEDESCS; i++)
+- {
+- __filedesc[i].active = false;
+- __filedesc[i].put = 0;
+- __filedesc[i].get = 0;
+- }
+-
+- init = 0;
+- }
+-
+- for(int i = 0; i < FILEDESCS; i++)
+- {
+- if(!__filedesc[i].active)
+- {
+- __filedesc[i].put = put;
+- __filedesc[i].get = get;
+-
+- __filedesc[i].active = true;
+-
+- return &__filedesc[i];
+- }
+- }
+-
+- return (FILE *)0;
+-}
+-
+-int fclose(FILE *fp)
++int putstr(const char *str)
+ {
+- for(int i = 0; i < FILEDESCS; i++)
+- if(&__filedesc[i] == fp || fp->active)
+- {
+- fp->active = false;
+-
+- fp->put = 0;
+- fp->get = 0;
+-
+- return 0;
+- }
+-
+- return -1;
+-}
+-
+-int fputs(const char *str, FILE *fp)
+-{
+- if(fp == (FILE *)0)
+- return -1;
+-
+- if(fp->put == (void *)0)
+- return -1;
+-
+- while(*str != 0)
+- {
+- fp->put(*str);
+- str++;
+- }
++ while (*str != 0)
++ {
++ putc(*str);
++ str++;
++ }
+ return 0;
+ }
+
+-int fputc(int c, FILE *fp)
+-{
+- if(fp == (FILE *)0)
+- return -1;
+-
+- if(fp->put == (void *)0)
+- return -1;
+-
+- return fp->put(c);
+-}
+-
+-int fgetc(FILE *fp)
+-{
+- if(fp == (FILE *)0)
+- return -1;
+-
+- if(fp->get == (void *)0)
+- return -1;
+-
+- return fp->get();
+-}
+-
+-
+-int puts(const char *str)
++int putchar(int c)
+ {
+- return fputs(str, stdout);
++ return putc(c);
+ }
+
+ int putc(int c)
+ {
+- return fputc(c, stdout);
+-}
+-
+-int putchar(int c)
+-{
+- return fputc(c, stdout);
++ at91_dbgu_putc(c);
++ return 0;
+ }
+
+ int getc()
+ {
+- return fgetc(stdin);
++ return at91_dbgu_getc();
+ }
+
+ int strlen(const char *str)
+@@ -139,7 +54,7 @@
+ __res; \
+ })
+
+-int number(FILE *fp, int num, int base, int size, int precision, int type)
++int number(int num, int base, int size, int precision, int type)
+ {
+ char c, sign, tmp[66];
+ const char *digits="0123456789abcdef";
+@@ -173,28 +88,28 @@
+
+ if(!(type&(ZEROPAD+LEFT)))
+ while(size-->0)
+- fputc(' ', fp);
++ putc(' ');
+
+ if(sign)
+- fputc(sign, fp);
++ putc(sign);
+
+ if (!(type & LEFT))
+ while (size-- > 0)
+- fputc(c, fp);
++ putc(c);
+
+ while (i < precision--)
+- fputc('0', fp);
++ putc('0');
+
+ while (i-- > 0)
+- fputc(tmp[i], fp);
++ putc(tmp[i]);
+
+ while (size-- > 0)
+- fputc(' ', fp);;
++ putc(' ');;
+
+ return 1;
+ }
+
+-int vfprintf(FILE *fp, const char *fmt, va_list va)
++int vprintf(const char *fmt, va_list va)
+ {
+ char *s;
+
+@@ -231,33 +146,33 @@
+ case 's' :
+ s = va_arg(va, char *);
+ if(!s)
+- fputs("<NULL>", fp);
++ putstr("<NULL>");
+ else
+- fputs(s, fp);
++ putstr(s);
+ done = true;
+ break;
+ case 'c' :
+- fputc(va_arg(va, int), fp);
++ putc(va_arg(va, int));
+ done = true;
+ break;
+ case 'd' :
+- number(fp, va_arg(va, int), 10, 0, precision, type);
++ number(va_arg(va, int), 10, 0, precision, type);
+ done = true;
+ break;
+ case 'x' :
+- number(fp, va_arg(va, int), 16, 0, precision, type);
++ number(va_arg(va, int), 16, 0, precision, type);
+ done = true;
+ break;
+ case 'X' :
+- number(fp, va_arg(va, int), 16, 0, precision, type | LARGE);
++ number(va_arg(va, int), 16, 0, precision, type | LARGE);
+ done = true;
+ break;
+ case '%' :
+- fputc(*fmt, fp);
++ putc(*fmt);
+ done = true;
+ default:
+- fputc('%', fp);
+- fputc(*fmt, fp);
++ putc('%');
++ putc(*fmt);
+ done = true;
+ break;
+ }
+@@ -265,7 +180,7 @@
+ while(!done);
+ }
+ else
+- fputc(*fmt, fp);
++ putc(*fmt);
+
+ fmt++;
+ }
+@@ -274,25 +189,13 @@
+ return 0;
+ }
+
+-int fprintf(FILE *fp, const char *fmt, ...)
+-{
+- va_list ap;
+- int i;
+-
+- va_start(ap, fmt);
+- i = fprintf(fp, fmt, ap);
+- va_end(ap);
+-
+- return i;
+-}
+-
+ int printf(const char *fmt, ...)
+ {
+ va_list ap;
+ int i;
+
+ va_start(ap, fmt);
+- i = vfprintf(stdout, fmt, ap);
++ i = vprintf(fmt, ap);
+ va_end(ap);
+
+ return i;
+diff -urN romboot.old/stdio.h romboot/stdio.h
+--- romboot.old/stdio.h 2004-07-04 22:04:27.000000000 +0200
++++ romboot/stdio.h 2007-04-04 04:29:48.000000000 +0200
+@@ -1,31 +1,12 @@
+ #include <stdarg.h>
+
+-struct FILE
+-{
+- bool active;
+- int (*put)(int); /* function to write one char to device */
+- int (*get)(); /* function to read one char from device */
+-};
+-
+-#define FILEDESCS 8
+-
+-FILE *fopen(int (*put)(int), int (*get)());
+-int fclose(FILE *fp);
+-
+-int puts(const char *str);
++int putstr(const char *str);
+ int putc(int c);
+ int putchar(int c);
+ int getc();
+
+-int fputs(const char *str, FILE *fp);
+-int fputc(int c, FILE *fp);
+-int fgetc(FILE *fp);
+ int strlen(const char *str);
+
+-int fprintf(FILE *fp, const char *fmt, ...);
+-int vfprintf(FILE *fp, const char *fmt, va_list ap);
++int vprintf(const char *fmt, va_list ap);
+
+ int printf(const char *fmt, ...);
+-
+-extern FILE *stdout;
+-extern FILE *stdin;
diff --git a/target/linux/at91-2.6/image/u-boot/patches/010-irda-patch-remove.patch b/target/linux/at91-2.6/image/u-boot/patches/010-irda-patch-remove.patch
new file mode 100644
index 000000000..2f23f5b38
--- /dev/null
+++ b/target/linux/at91-2.6/image/u-boot/patches/010-irda-patch-remove.patch
@@ -0,0 +1,13 @@
+--- u-boot-1.1.4.old/board/vlink/vlink.c 2007-04-03 11:42:39.000000000 +0200
++++ u-boot-1.1.4/board/vlink/vlink.c 2007-04-03 11:48:33.000000000 +0200
+@@ -40,10 +40,6 @@
+ /* Enable Ctrlc */
+ console_init_f ();
+
+- /* Correct IRDA resistor problem */
+- /* Set PA23_TXD in Output */
+- (AT91PS_PIO) AT91C_BASE_PIOA->PIO_OER = AT91C_PA23_TXD2;
+-
+ /* memory and cpu-speed are setup before relocation */
+ /* so we do _nothing_ here */
+
diff --git a/toolchain/uClibc/Makefile b/toolchain/uClibc/Makefile
index 2f95b0c44..93a994ebb 100644
--- a/toolchain/uClibc/Makefile
+++ b/toolchain/uClibc/Makefile
@@ -93,12 +93,14 @@ define Build/Install
RUNTIME_PREFIX=/ \
install_dev
echo $(PKG_VERSION) > $(STAGING_DIR)/uclibc_version
+ifneq ($(CONFIG_LINUX_2_6_AT91),y)
echo $(PKG_VERSION)$(PKG_EXTRAVERSION) > $(STAGING_DIR)/uclibc_extra_version
$(MAKE) -C $(PKG_BUILD_DIR) \
PREFIX=$(STAGING_DIR)/ \
DEVEL_PREFIX=/ \
RUNTIME_PREFIX=/ \
utils
+endif
endef
define Build/Clean