- // 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
- \r
-- printf("press any key to enter bootloader\n\r");\r
-+ printf("press key\n\r");\r
- getc();\r
- \r
- // stop tempo\r
- svcUbootTempo.Stop(&svcUbootTempo);\r
- \r
-- while(1)\r
-- {\r
-- while(command == 0)\r
-- {\r
-- AddressToDownload = AT91C_DOWNLOAD_BASE_ADDRESS;\r
-- SizeToDownload = AT91C_DOWNLOAD_MAX_SIZE;\r
-- DeviceAddress = 0;\r
-+ while(1) {\r
-+ while(command == 0) {\r
-+ AddressToDownload = AT91C_DOWNLOAD_BASE_ADDRESS;\r
-+ SizeToDownload = AT91C_DOWNLOAD_MAX_SIZE;\r
-+ DeviceAddress = 0;\r
- \r
-- AT91F_DisplayMenu();\r
-- message[0] = 0;\r
-- message[2] = 0;\r
-- AT91F_ReadLine("Enter: ", message);\r
-+ AT91F_DisplayMenu();\r
-+ message[0] = 0;\r
-+ message[2] = 0;\r
-+ AT91F_ReadLine("Enter: ", message);\r
- \r
-- command = message[0];\r
-- if(command == '1' || command == '2')\r
-- if(AsciiToHex(&message[2], &DeviceAddress) == 0)\r
-- command = 0;\r
--\r
-- switch(command)\r
-- {\r
-- case '1': \r
-- printf("Download Dataflash [0x%x]\n\r", DeviceAddress);\r
-- \r
-- switch(DeviceAddress & 0xFF000000)\r
-- {\r
-- case CFG_DATAFLASH_LOGIC_ADDR_CS0:\r
-- device = 0;\r
-- break;\r
-+ command = message[0];\r
-+ if(command == '1' || command == '2')\r
-+ if(AsciiToHex(&message[2], &DeviceAddress) == 0)\r
-+ command = 0;\r
-+\r
-+ switch(command) {\r
-+ case '1': \r
-+ printf("DL DF [0x%x]\n\r", DeviceAddress);\r
-+\r
-+ switch(DeviceAddress & 0xFF000000) {\r
-+ case CFG_DATAFLASH_LOGIC_ADDR_CS0:\r
-+ device = 0;\r
-+ break;\r
- \r
-- case CFG_DATAFLASH_LOGIC_ADDR_CS3:\r
-- device = 1;\r
-- break;\r
-+ case CFG_DATAFLASH_LOGIC_ADDR_CS3:\r
-+ device = 1;\r
-+ break;\r
- \r
-- default:\r
-- command = 0;\r
-- break;\r
-- }\r
-- break;\r
-- \r
-- case '2':\r
-- do \r
-- {\r
-- AT91F_MemoryDisplay(DeviceAddress, 4, 64);\r
-- AT91F_ReadLine ((char *)0, message);\r
-- DeviceAddress += 0x100;\r
-+ default:\r
-+ command = 0;\r
-+ break;\r
-+ }\r
-+ break;\r
-+\r
-+#ifndef COMPACT\r
-+ case '2':\r
-+ do {\r
-+ AT91F_MemoryDisplay(DeviceAddress, 4, 64);\r
-+ AT91F_ReadLine ((char *)0, message);\r
-+ DeviceAddress += 0x100;\r
-+ } while(message[0] == '\0');\r
-+ command = 0;\r
-+ break;\r
-+#endif\r
-+ \r
-+ case '3':\r
-+ mci_main();\r
-+ command=0;\r
-+ break;\r
-+\r
-+ case '4':\r
-+ AT91F_StartUboot(0, (void *)0);\r
-+ command = 0;\r
-+ break;\r
-+\r
-+ case '5':\r
-+ {\r
-+ int *i;\r
-+ \r
-+ for(i = (int *)0x20000000; i < (int *)0x20004000; i++)\r
-+ *i = 0;\r
-+ }\r
-+ write_dataflash(0xc0000000, 0x20000000, 0x4000);\r
-+ printf("BL CLR\r\n");\r
-+ command = 0;\r
-+ break;\r
-+ \r
-+ default:\r
-+ command = 0;\r
-+ break;\r
-+ } // switch(command)\r
-+ } // while(command == 0)\r
-+ \r
-+ xmodemPipe.Read(&xmodemPipe, (char *)AddressToDownload, SizeToDownload, XmodemProtocol, 0); \r
-+ while(XmodemComplete !=1);\r
-+ SizeToDownload = (unsigned int)(svcXmodem.pData) - (unsigned int)AddressToDownload; \r
-+ \r
-+ // Modification of vector 6\r
-+ NbPage = 0;\r
-+ i = dataflash_info[device].Device.pages_number;\r
-+ while(i >>= 1)\r
-+ NbPage++;\r
-+ i = (SizeToDownload / 512) + 1 + (NbPage << 13) + (dataflash_info[device].Device.pages_size << 17);\r
-+ *(int *)(AddressToDownload + AT91C_OFFSET_VECT6) = i;\r
-+ \r
-+// printf("\n\rModification of Arm Vector 6 :%x\n\r", i);\r
-+\r
-+ printf("\n\rWR %d in DF [0x%x]\n\r",SizeToDownload, DeviceAddress);\r
-+ crc1 = 0;\r
-+ pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc1);\r
-+\r
-+ // write the dataflash\r
-+ write_dataflash (DeviceAddress, AddressToDownload, SizeToDownload);\r
-+ // clear the buffer before read\r
-+ for(i=0; i < SizeToDownload; i++)\r
-+ *(unsigned char *)(AddressToDownload + i) = 0;\r
-+ \r
-+ //* Read dataflash page in TestBuffer\r
-+ read_dataflash (DeviceAddress, SizeToDownload, (char *)(AddressToDownload));\r
-+\r
-+ printf("Vfy DF: "); \r
-+ crc2 = 0;\r
-+\r
-+ pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc2);\r
-+ if (crc1 != crc2)\r
-+ printf("Fail\r\n"); \r
-+ else\r
-+ printf("OK\r\n"); \r
-+ \r
-+ command = 0;\r
-+ XmodemComplete = 0;\r
-+ AT91F_WaitKeyPressed();\r
- }\r
-- while(message[0] == '\0');\r
-- command = 0;\r
-- break;\r
-- \r
-- case '3':\r
-- AT91F_StartUboot(0, (void *)0);\r
-- command = 0;\r
-- break;\r
-- case '4':\r
-- {\r
-- int *i;\r
-- for(i = (int *)0x20000000; i < (int *)0x20004000; i++)\r
-- *i = 0;\r
-- }\r
-- write_dataflash(0xc0000000, 0x20000000, 0x4000);\r
-- printf("Bootsection cleared\r\n");\r
-- command = 0;\r
-- break;\r
-- default:\r
-- command = 0;\r
-- break;\r
-- }\r
- }\r
-- \r
-- xmodemPipe.Read(&xmodemPipe, (char *)AddressToDownload, SizeToDownload, XmodemProtocol, 0); \r
-- while(XmodemComplete !=1);\r
-- SizeToDownload = (unsigned int)(svcXmodem.pData) - (unsigned int)AddressToDownload; \r
-- \r
-- // Modification of vector 6\r
-- NbPage = 0;\r
-- i = dataflash_info[device].Device.pages_number;\r
-- while(i >>= 1)\r
-- NbPage++;\r
-- i = (SizeToDownload / 512) + 1 + (NbPage << 13) + (dataflash_info[device].Device.pages_size << 17);\r
-- *(int *)(AddressToDownload + AT91C_OFFSET_VECT6) = i;\r
-- \r
-- printf("\n\rModification of Arm Vector 6 :%x\n\r", i);\r
-- \r
-- printf("\n\rWrite %d bytes in DataFlash [0x%x]\n\r",SizeToDownload, DeviceAddress);\r
-- crc1 = 0;\r
-- pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc1);\r
-- \r
-- // write the dataflash\r
-- write_dataflash (DeviceAddress, AddressToDownload, SizeToDownload);\r
-- // clear the buffer before read\r
-- for(i=0; i < SizeToDownload; i++)\r
-- *(unsigned char *)(AddressToDownload + i) = 0;\r
-- \r
-- //* Read dataflash page in TestBuffer\r
-- read_dataflash (DeviceAddress, SizeToDownload, (char *)(AddressToDownload));\r
-- \r
-- printf("Verify Dataflash: "); \r
-- crc2 = 0;\r
-- \r
-- pAT91->CRC32((const unsigned char *)AddressToDownload, SizeToDownload , &crc2);\r
-- if (crc1 != crc2)\r
-- printf("Failed\r\n"); \r
-- else\r
-- printf("OK\r\n"); \r
-- \r
-- command = 0;\r
-- XmodemComplete = 0;\r
-- AT91F_WaitKeyPressed();\r
-- }\r
--}\r
+ // 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();
+- }
+-}