--- 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);\r
- \r
- /* Enable PIO to access the LEDs */\r
-- AT91C_BASE_PIOB->PIO_PER = AT91C_PIO_PB2;\r
-- AT91C_BASE_PIOB->PIO_OER = AT91C_PIO_PB2;\r
-- AT91C_BASE_PIOB->PIO_CODR = AT91C_PIO_PB2;\r
-+ AT91C_BASE_PIOC->PIO_PER = AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15;\r
-+ AT91C_BASE_PIOC->PIO_OER = AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15;\r
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15;\r
-+ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC8 | AT91C_PIO_PC14;\r
- \r
- // AT91F_DBGU_Printk("\n\rAT91F_LowLevelInit(): Debug channel initialized\n\r");\r
- }\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 @@
- //*----------------------------------------------------------------------------\r
- #include <AT91RM9200.h>\r
- #include <lib_AT91RM9200.h>\r
-+#include <AT91C_MCI_Device.h>\r
- \r
- #include "com.h"\r
- #include "main.h"\r
+ //*----------------------------------------------------------------------------
+ #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 *);\r
- extern "C" void AT91F_ST_ASM_Handler(void);\r
- extern "C" void Jump(unsigned int addr);\r
--extern int mci_main(void);\r
-+extern int AT91F_MCI_Init(void);\r
-+#define TRUE 1\r
-+#define FALSE 0\r
-+\r
-+/* from trxhdr.h */\r
-+\r
-+#define TRX_MAGIC 0x30524448 /* "HDR0" */\r
-+#define TRX_VERSION 1\r
-+\r
-+struct trx_header {\r
-+ unsigned int magic;\r
-+ unsigned int len;\r
-+ unsigned int crc32;\r
-+ unsigned int flag_version;\r
-+ unsigned int offsets[3];\r
-+};\r
- \r
- //const char *menu_separ = "*----------------------------------------*\n\r";\r
- \r
- const char *menu_dataflash = {\r
-- "1: DL DF [ad]\n\r"\r
-- "2: RD DF [ad]\n\r"\r
-- "3: CP SD\n\r"\r
-- "4: U-BOOT\n\r"\r
-- "5: RM BL in DF\n\r"\r
-+ "1: Download DF [addr]\n\r"\r
-+ "2: Read DF [addr]\n\r"\r
-+ "3: Copy SD-Card\n\r"\r
-+ "4: Start U-BOOT\n\r"\r
-+ "5: Clear bootloder\n\r"\r
- };\r
- \r
- //* Globales variables \r
+ 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 @@
- //*-----------------------------------------------------------------------------\r
- void AT91F_DisplayMenu(void)\r
- {\r
-- printf("\n\rFDL SD-Card LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);\r
--// printf(menu_separ); \r
-- AT91F_DataflashPrintInfo();\r
--// printf(menu_separ); \r
- printf(menu_dataflash); \r
--// printf(menu_separ); \r
- } \r
- \r
-+void AT91F_DisplayIntro(void)\r
-+{\r
-+ printf("\n\rFDL LOADER %s %s %s\n\r", AT91C_VERSION, __DATE__, __TIME__);\r
-+ AT91F_DataflashPrintInfo();\r
-+}\r
-+\r
- //*-----------------------------------------------------------------------------\r
- //* Function Name : AsciiToHex()\r
- //* Object : ascii to hexa conversion\r
+ //*-----------------------------------------------------------------------------
+ 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();\r
- }\r
- \r
--/*void LedCode(void)\r
-+/*\r
-+void LedCode(void)\r
- {\r
- int *pRegister;\r
- pRegister = (int *)0xFFFFF800; // Enable port C peripheral reg\r
-- *pRegister = 0x3c00;\r
-+ *pRegister = (AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15);\r
- pRegister = (int *)0xFFFFF810; // Output Enable reg\r
-- *pRegister = 0x3c00;\r
-+ *pRegister = (AT91C_PIO_PC7 | AT91C_PIO_PC8 | AT91C_PIO_PC14 | AT91C_PIO_PC15);\r
- pRegister = (int *)0xFFFFF830; // Set data\r
-- *pRegister = 0x1400;\r
-+ *pRegister = AT91C_PIO_PC7 | AT91C_PIO_PC15;\r
- pRegister = (int *)0xFFFFF834; // Clear bits\r
-- *pRegister = 0x2800;\r
-+ *pRegister = AT91C_PIO_PC8 | AT91C_PIO_PC14;\r
- }\r
- */\r
- \r
-+\r
- void AT91F_StartUboot(unsigned int dummy, void *pvoid)\r
- {\r
-- //printf("Load U-BOOT from dataflash[%x] to SDRAM[%x]\n\r", AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_ADDR);\r
- read_dataflash(AT91C_UBOOT_DATAFLASH_ADDR, AT91C_UBOOT_SIZE, (char *)(AT91C_UBOOT_ADDR));\r
- //printf("Set PLLA to 180Mhz and Master clock to 60Mhz and start U-BOOT\n\r");\r
- //* Reset registers\r
+ 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);\r
- }\r
- \r
-+#define AT91C_MCI_TIMEOUT 1000000\r
-+\r
-+extern AT91S_MciDevice MCI_Device;\r
-+\r
-+extern void AT91F_MCIDeviceWaitReady(unsigned int);\r
-+extern int AT91F_MCI_ReadBlockSwab(AT91PS_MciDevice, int, unsigned int *, int);\r
-+\r
-+\r
-+int Program_From_MCI(void)\r
-+{\r
-+ int i;\r
-+ unsigned int Max_Read_DataBlock_Length;\r
-+ int block = 0;\r
-+ int buffer = AT91C_DOWNLOAD_BASE_ADDRESS;\r
-+ int bufpos = AT91C_DOWNLOAD_BASE_ADDRESS;\r
-+ int NbPage = 0;\r
-+ struct trx_header *p;\r
-+ unsigned int data;\r
-+\r
-+ p = (struct trx_header *)bufpos;\r
-+\r
-+ Max_Read_DataBlock_Length = MCI_Device.pMCI_DeviceFeatures->Max_Read_DataBlock_Length;\r
-+\r
-+ AT91F_MCIDeviceWaitReady(AT91C_MCI_TIMEOUT);\r
-+\r
-+ AT91F_MCI_ReadBlockSwab(&MCI_Device, block*Max_Read_DataBlock_Length, (unsigned int *)bufpos, Max_Read_DataBlock_Length);\r
-+\r
-+ if (p->magic != TRX_MAGIC)\r
-+ return FALSE;\r
-+\r
-+ printf("Read SD-Card\n\r");\r
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15 | AT91C_PIO_PC8 | AT91C_PIO_PC14;\r
-+ for (i=0; i<(p->len/512); i++) {\r
-+ AT91F_MCI_ReadBlockSwab(&MCI_Device, block*Max_Read_DataBlock_Length, (unsigned int *)bufpos, Max_Read_DataBlock_Length);\r
-+ block++;\r
-+ bufpos += Max_Read_DataBlock_Length;\r
-+ }\r
-+\r
-+ NbPage = 0;\r
-+ i = dataflash_info[0].Device.pages_number;\r
-+ while(i >>= 1)\r
-+ NbPage++;\r
-+ i = ((p->offsets[1] - p->offsets[0])/ 512) + 1 + (NbPage << 13) + (dataflash_info[0].Device.pages_size << 17);\r
-+ *(int *)(buffer + p->offsets[0] + AT91C_OFFSET_VECT6) = i;\r
-+\r
-+ printf("Write romboot\n\r");\r
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15 | AT91C_PIO_PC14;\r
-+ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC8;\r
-+ write_dataflash(0xc0000000, buffer + p->offsets[0], p->offsets[1] - p->offsets[0]);\r
-+ printf("Write u-boot\n\r");\r
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC7 | AT91C_PIO_PC15;\r
-+ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC8 | AT91C_PIO_PC14;\r
-+ write_dataflash(0xc0008000, buffer + p->offsets[1], p->offsets[2] - p->offsets[1]);\r
-+ printf("Write knl/root\n\r");\r
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC8 | AT91C_PIO_PC15;\r
-+ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC7 | AT91C_PIO_PC14;\r
-+ write_dataflash(0xc0042000, buffer + p->offsets[2], p->len - p->offsets[2]);\r
-+ AT91C_BASE_PIOC->PIO_CODR = AT91C_PIO_PC8 | AT91C_PIO_PC14;\r
-+ AT91C_BASE_PIOC->PIO_SODR = AT91C_PIO_PC7 | AT91C_PIO_PC15;\r
-+ return TRUE;\r
-+ }\r
- \r
- //*----------------------------------------------------------------------------\r
- //* Function Name : main\r
+ 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;\r
- volatile int device;\r
- int NbPage;\r
-+ int mci_present;\r
- \r
- stdin = fopen(0, at91_dbgu_getc);\r
- stdout = fopen(at91_dbgu_putc, 0);\r
+ 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 @@
- \r
- // DataFlash on SPI Configuration\r
- AT91F_DataflashInit ();\r
-+ AT91F_DisplayIntro();\r
-+ mci_present = AT91F_MCI_Init();\r
-+\r
-+#ifdef PRODTEST\r
-+ if (mci_present) {\r
-+ Program_From_MCI();\r
-+ AT91F_StartUboot(0, (void *)0);\r
-+ }\r
-+#endif\r
- \r
- // start tempo to start Uboot in a delay of 1 sec if no key pressed\r
- svcUbootTempo.Start(&svcUbootTempo, 1000, 0, AT91F_StartUboot, (void *)0);\r
+
+ // 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 @@
- \r
- // stop tempo\r
- svcUbootTempo.Stop(&svcUbootTempo);\r
-- \r
-+\r
- while(1) {\r
- while(command == 0) {\r
- AddressToDownload = AT91C_DOWNLOAD_BASE_ADDRESS;\r
+
+ // stop tempo
+ svcUbootTempo.Stop(&svcUbootTempo);
+-
++
+ while(1) {
+ while(command == 0) {
+ AddressToDownload = AT91C_DOWNLOAD_BASE_ADDRESS;
@@ -444,7 +533,8 @@
- #endif\r
- \r
- case '3':\r
-- mci_main();\r
-+ if (mci_present)\r
-+ Program_From_MCI();\r
- command=0;\r
- break;\r
- \r
+ #endif
+
+ case '3':
+- mci_main();
++ if (mci_present)
++ Program_From_MCI();
+ command=0;
+ break;
+
@@ -461,7 +551,6 @@
- *i = 0;\r
- }\r
- write_dataflash(0xc0000000, 0x20000000, 0x4000);\r
-- printf("BL CLR\r\n");\r
- command = 0;\r
- break;\r
- \r
+ *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 @@
- \r
- #define AT91C_OFFSET_VECT6 0x14 //* Offset for ARM vector 6\r
- \r
--#define AT91C_VERSION "VER 1.02"\r
-+#define AT91C_VERSION "VER 1.03"\r
- // Global variables and functions definition\r
- extern unsigned int GetTickCount(void);\r
- #endif\r
+
+ #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