//------------------------------------------------------------------------------ /// Applet code for initializing the external RAM. //------------------------------------------------------------------------------ int main(int argc, char **argv) { struct _Mailbox *pMailbox = (struct _Mailbox *) argv; unsigned int ramType = 0; unsigned int dataBusWidth = 0; unsigned int ddrModel = 0; unsigned int baseAddress = 0; unsigned int *ramAddr = (unsigned int *) EXTRAM_ADDR; unsigned int comType = 0; TRACE_CONFIGURE_ISP(DBGU_STANDARD, 115200, BOARD_MCK); // ---------------------------------------------------------- // INIT: // ---------------------------------------------------------- if (pMailbox->command == APPLET_CMD_INIT) { // Save info of communication link comType = pMailbox->argument.inputInit.comType; #if (TRACE_LEVEL==0) && (DYN_TRACES==0) if (comType == DBGU_COM_TYPE){ // Function TRACE_CONFIGURE_ISP wiil be bypass due to the 0 TRACE_LEVEL. We shall reconfigure the baut rate. DBGU_Configure(DBGU_STANDARD, 115200, BOARD_MCK); } #endif // Enable User Reset AT91C_BASE_RSTC->RSTC_RMR |= AT91C_RSTC_URSTEN | (0xA5<<24); ramType = pMailbox->argument.inputInit.ramType; dataBusWidth = pMailbox->argument.inputInit.dataBusWidth; ddrModel = pMailbox->argument.inputInit.ddrModel; baseAddress = pMailbox->argument.inputInit.baseAddress; #if (DYN_TRACES == 1) traceLevel = pMailbox->argument.inputInit.traceLevel; #endif TRACE_INFO("-- EXTRAM Applet %s --\n\r", SAM_BA_APPLETS_VERSION); TRACE_INFO("-- %s\n\r", BOARD_NAME); TRACE_INFO("-- Compiled: %s %s --\n\r", __DATE__, __TIME__); TRACE_INFO("INIT command:\n\r"); TRACE_INFO("\tCommunication link type : %d\n\r", pMailbox->argument.inputInit.comType); TRACE_INFO("\tData bus width : %d bits\n\r", dataBusWidth); if (ramType == TYPE_SDRAM) { TRACE_INFO("\tExternal RAM type : %s\n\r", "SDRAM"); } else { if (ramType == TYPE_DDRAM) { TRACE_INFO("\tExternal RAM type : %s\n\r", "DDRAM"); } else { TRACE_INFO("\tExternal RAM type : %s\n\r", "PSRAM"); } } #if defined(at91cap7) || defined(at91cap9) || defined(at91sam9m10) || defined(at91sam9g45) TRACE_INFO("\tInit EBI Vdd : %s\n\r", (pMailbox->argument.inputInit.VddMemSel)?"3.3V":"1.8V"); BOARD_ConfigureVddMemSel(pMailbox->argument.inputInit.VddMemSel); #endif //defined(at91cap9) if (pMailbox->argument.inputInit.ramType == TYPE_SDRAM) { // Configure SDRAM controller TRACE_INFO("\tInit SDRAM...\n\r"); #if defined(PINS_SDRAM) BOARD_ConfigureSdram(dataBusWidth); #endif } else if (pMailbox->argument.inputInit.ramType == TYPE_PSRAM) { TRACE_INFO("\tInit PSRAM...\n\r"); #if defined(at91sam3u) BOARD_ConfigurePsram(); #endif } else { // Configure DDRAM controller #if defined(at91sam9m10) || defined(at91sam9g45) TRACE_INFO("\tInit DDRAM ... (model : %d)\n\r", ddrModel); BOARD_ConfigureDdram(baseAddress, ddrModel, dataBusWidth); if (baseAddress != (unsigned int)AT91C_BASE_DDR2C) { ramAddr = (unsigned int *)EXTRAM_ADDR_2; } #elif defined(at91cap9dk) TRACE_INFO("\tInit DDRAM ... (model : %d)\n\r", ddrModel); BOARD_ConfigureDdram(ddrModel, dataBusWidth); #endif } // Test external RAM access if (ExtRAM_TestOk(ramAddr)) { pMailbox->status = APPLET_SUCCESS; } else { pMailbox->status = APPLET_FAIL; } pMailbox->argument.outputInit.bufferAddress = ((unsigned int) &end); pMailbox->argument.outputInit.bufferSize = 0; pMailbox->argument.outputInit.memorySize = EXTRAM_SIZE; TRACE_INFO("\tInit successful.\n\r"); } // Acknowledge the end of command TRACE_INFO("\tEnd of applet (command : %x --- status : %x)\n\r", pMailbox->command, pMailbox->status); // Notify the host application of the end of the command processing pMailbox->command = ~(pMailbox->command); // Send ACK character if (comType == DBGU_COM_TYPE) { DBGU_PutChar(0x6); } return 0; }
//------------------------------------------------------------------------------ /// Applet code for initializing the external RAM. //------------------------------------------------------------------------------ int main(int argc, char **argv) { struct _Mailbox *pMailbox = (struct _Mailbox *) argv; unsigned int ramType = 0; unsigned int bufferSize, bufferAddr, memoryOffset; unsigned int bytesToWrite; unsigned int tempBufferAddr; unsigned int dataBusWidth = 0; unsigned int ddrModel = 0; LowLevelInit(); TRACE_CONFIGURE_ISP(DBGU_STANDARD, 115200, BOARD_MCK); /* *AT91C_PMC_PCER = AT91C_ID_PIOA; *AT91C_PIOA_PDR = (1<<31); *AT91C_PIOA_OER = (1<<31); *AT91C_PIOA_BSR = (1<<31); *AT91C_PIOA_PER = (1<<0); *AT91C_PIOA_OER = (1<<0); *AT91C_PMC_PCKR = (1<<8); // select master clock *AT91C_PMC_SCER = (1<<8); // ENABLE PCK0*/ TRACE_INFO("Statup: PMC_MCKR %x MCK = %d command = %d\n\r", *AT91C_PMC_MCKR, BOARD_MCK, pMailbox->command); // ---------------------------------------------------------- // INIT: // ---------------------------------------------------------- if (pMailbox->command == APPLET_CMD_INIT) { // Initialize PMC // BOARD_RemapRam(); // Enable User Reset AT91C_BASE_RSTC->RSTC_RMR |= AT91C_RSTC_URSTEN | (0xA5<<24); ramType = pMailbox->argument.inputInit.ramType; dataBusWidth = pMailbox->argument.inputInit.dataBusWidth; ddrModel = pMailbox->argument.inputInit.ddrModel; //#if (DYN_TRACES == 1) // traceLevel = pMailbox->argument.inputInit.traceLevel; //#endif TRACE_INFO("-- EXTRAM ISP Applet %s --\n\r", SAM_BA_APPLETS_VERSION); TRACE_INFO("-- %s\n\r", BOARD_NAME); TRACE_INFO("-- Compiled: %s %s %s --\n\r", __DATE__, __TIME__, __GIT__); TRACE_INFO("INIT command:\n\r"); TRACE_INFO("\tCommunication link type : %d\n\r", pMailbox->argument.inputInit.comType); TRACE_INFO("\tData bus width : %d bits\n\r", dataBusWidth); if (ramType == TYPE_SDRAM) { TRACE_INFO("\tExternal RAM type : %s\n\r", "SDRAM"); } else { if (ramType == TYPE_DDRAM) { TRACE_INFO("\tExternal RAM type : %s\n\r", "DDRAM"); } else { TRACE_INFO("\tExternal RAM type : %s\n\r", "PSRAM"); } } #if defined(at91cap9) || defined(at91sam9m10) || defined(at91sam9g45) TRACE_INFO("\tInit EBI Vdd : %s\n\r", (pMailbox->argument.inputInit.VddMemSel)?"3.3V":"1.8V"); BOARD_ConfigureVddMemSel(pMailbox->argument.inputInit.VddMemSel); #endif //defined(at91cap9) if (pMailbox->argument.inputInit.ramType == TYPE_SDRAM) { // Configure SDRAM controller TRACE_INFO("\tInit SDRAM...\n\r"); #if defined(PINS_SDRAM) BOARD_ConfigureSdram(dataBusWidth); #endif } else if (pMailbox->argument.inputInit.ramType == TYPE_PSRAM) { TRACE_INFO("\tInit PSRAM...\n\r"); #if defined(at91sam3u4) BOARD_ConfigurePsram(); #endif } else { // Configure DDRAM controller #if defined(at91cap9dk) || defined(at91sam9m10) || defined(at91sam9g45) TRACE_INFO("\tInit DDRAM ... (model : %d)\n\r", ddrModel); BOARD_ConfigureVddMemSel(VDDMEMSEL_1V8); BOARD_ConfigureDdram(0, dataBusWidth); // ddramc_hw_init(); #endif } TRACE_INFO("\tInit successful.\n\r"); } // ---------------------------------------------------------- // LIST_BAD_BLOCK: (Check DDR) // ---------------------------------------------------------- else if (pMailbox->command == APPLET_CMD_LIST_BAD_BLOCKS) { // Test external RAM access if (ExtRAM_TestOk()) { pMailbox->status = APPLET_SUCCESS; } else { pMailbox->status = APPLET_FAIL; } pMailbox->argument.outputInit.bufferAddress = ((unsigned int) &end); pMailbox->argument.outputInit.bufferSize = 0; pMailbox->argument.outputInit.memorySize = EXTRAM_SIZE; } // ---------------------------------------------------------- // WRITE: // ---------------------------------------------------------- else if (pMailbox->command == APPLET_CMD_WRITE) { memoryOffset = pMailbox->argument.inputWrite.memoryOffset; bufferAddr = pMailbox->argument.inputWrite.bufferAddr; bytesToWrite = pMailbox->argument.inputWrite.bufferSize; tempBufferAddr = bufferAddr+memoryOffset; TRACE_INFO("WRITE arguments : offset 0x%x, run 0x%x, of 0x%x Bytes\n\r", memoryOffset, tempBufferAddr, bytesToWrite); pMailbox->argument.outputWrite.bytesWritten = 0; /* * We must define the following * - MACH_TYPE_xxx * - Setup the kernel tagged list (http://www.arm.linux.org.uk/developer/booting.php#4) * first 16KiB of RAM. * * we recommend to load at 32KiB into RAM */ //Fake the end of the applet because we will not be able to do anything after this step if (bytesToWrite < EXTRAM_SIZE) { pMailbox->status = APPLET_SUCCESS; } else { pMailbox->status = APPLET_FAIL; } pMailbox->command = ~(pMailbox->command); //Going to ((VFptr *)(EXTRAM_ADDR+memoryOffset))(); } exit : // Acknowledge the end of command TRACE_INFO("\tEnd of applet (command : %x --- status : %x)\n\r", pMailbox->command, pMailbox->status); // Notify the host application of the end of the command processing pMailbox->command = ~(pMailbox->command); return 0; }
/** * \brief Applet code for initializing the external RAM. */ int main(int argc, char **argv) { struct _Mailbox *pMailbox = (struct _Mailbox *) argv; uint32_t ramType = 0; uint32_t dataBusWidth = 0; uint32_t ddrModel = 0; uint32_t comType = 0; /* ---------------------------------------------------------- */ /* INIT: */ /* ---------------------------------------------------------- */ if (pMailbox->command == APPLET_CMD_INIT) { /* Save info of communication link */ comType = pMailbox->argument.inputInit.comType; /* Re-configurate UART (MCK maybe change in LowLevelInit()) */ UART_Configure(115200, BOARD_MCK); ramType = pMailbox->argument.inputInit.ramType; dataBusWidth = pMailbox->argument.inputInit.dataBusWidth; ddrModel = pMailbox->argument.inputInit.ddrModel; #if (DYN_TRACES == 1) dwTraceLevel = pMailbox->argument.inputInit.traceLevel; #endif TRACE_INFO("-- EXTRAM Applet %s --\n\r", SAM_BA_APPLETS_VERSION); TRACE_INFO("-- %s\n\r", BOARD_NAME); TRACE_INFO("INIT command:\n\r"); TRACE_INFO("\tCommunication link type : %d\n\r",(unsigned int)( pMailbox->argument.inputInit.comType)); TRACE_INFO("\tData bus width : %d bits\n\r", (unsigned int)dataBusWidth); if (ramType == TYPE_SDRAM) { TRACE_INFO("\tExternal RAM type : %s\n\r", "SDRAM"); } else { TRACE_INFO("\tUnknow External RAM type\n\r"); } if (pMailbox->argument.inputInit.ramType == TYPE_SDRAM) { /* Configure SDRAM controller */ TRACE_INFO("\tInit SDRAM...\n\r"); BOARD_ConfigureSdram(); } /* Test external RAM access */ if (ExtRAM_TestOk()) { pMailbox->status = APPLET_SUCCESS; TRACE_INFO("\tInit successful.\n\r"); } else { pMailbox->status = APPLET_FAIL; TRACE_INFO("\tInit failure.\n\r"); } pMailbox->argument.outputInit.bufferAddress = ((uint32_t) &end); pMailbox->argument.outputInit.bufferSize = 0; pMailbox->argument.outputInit.memorySize = EXTRAM_SIZE; } /* Acknowledge the end of command */ TRACE_INFO("\tEnd of applet (command : %x --- status : %x)\n\r", (unsigned int)(pMailbox->command), (unsigned int)(pMailbox->status)); /* Notify the host application of the end of the command processing */ pMailbox->command = ~(pMailbox->command); if (comType == DBGU_COM_TYPE) { UART_PutChar(0x6); } return 0; }