X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fsvn-archive%2Farchive.git;a=blobdiff_plain;f=target%2Flinux%2Fat91-2.6%2Fimage%2Fromboot%2Fpatches%2F003-SD-reflash.patch;h=b0d5baf03fdd3c8c523f4080c7df590d6df7ee00;hp=e0b5e07332c22ee429355905bc8676fdac02282a;hb=cd097a8e89bbd2b54f31a5672af163e29047e795;hpb=b8182f35237e05d32a8b7f451a562ac1dc1bb349;ds=sidebyside 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 e0b5e07332..b0d5baf03f 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 - #include -+#include - - #include "com.h" - #include "main.h" + //*---------------------------------------------------------------------------- + #include + #include ++#include + + #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