I am using LPC1788 controller but its 512KB flash memory is not enough. But I have enough external flash memory and accessible by the file system but not accessible in the compilation of the project. I wonder if it is possible create a library that will load from the file system into RAM in order to run. Best regards,
Leonardo F. Farah
I finally finished writing the flash programming algorithm. Use the algorithm along with an .ini file that initializes the microcontroller registers to enable and configure external memory controller.
The ini file:
//*********************************************************************************************
/***********************************************************************/ /* FLASH.INI: Flash Initialization File */ /***********************************************************************/
//*** Use Configuration Wizard in Context Menu ***
FUNC void Setup (void) { int x, y, z;
_WDWORD(0x4002C138, 0x000000B1); // PINSEL_ConfigPin(2,14,1) _WDWORD(0x4002C13C, 0x000000B1); // PINSEL_ConfigPin(2,15,1)
y = 0x4002C180; z = 0x4002C200; for (x = 0; x < 32; x++) { _WDWORD(y, 0x000000B1); // PINSEL_ConfigPin(3,0,1) _WDWORD(z, 0x000000B1); // PINSEL_ConfigPin(4,0,1) y += 4; z += 4; }
_WDWORD(0x4002C280, 0x000000B1); // PINSEL_ConfigPin(5,0,1) _WDWORD(0x4002C284, 0x000000B1); // PINSEL_ConfigPin(5,1,1)
_WDWORD(0x400FC100, 0x00000001); // LPC_SC->EMCCLKSEL = 1
_WDWORD(0x400FC0C4, 0x04288FDE); // LPC_SC->PCONP = 0x04288FDE
_WDWORD(0x2009C000, 0x00000001); // LPC_EMC->Control = 1
_WDWORD(0x2009C200, 0x00000081); // LPC_EMC->StaticConfig0 = 0x81
_WDWORD(0x2009C204, 0x00000002); // LPC_EMC->StaticWaitWen0 = 2 _WDWORD(0x2009C208, 0x00000002); // LPC_EMC->StaticWaitOen0 = 2 _WDWORD(0x2009C20C, 0x0000001F); // LPC_EMC->StaticWaitRd0 = 0x1F _WDWORD(0x2009C210, 0x0000001F); // LPC_EMC->StaticWaitPage0 = 0x1F _WDWORD(0x2009C214, 0x0000001F); // LPC_EMC->StaticWaitWr0 = 0x1F _WDWORD(0x2009C218, 0x0000000F); // LPC_EMC->StaticWaitTurn0 = 0xF }
Setup(); // Setup for Flash
The firmware recording goes smoothly but I can not do debug. The following messages appear:
ULINK - Cortex-M Error Cannot access target. Shutting down debug session.
uVision Error: Could not load file 'D:\Projects\NOR Flash Teste.axf'. Debugger aborted !
This error happens with code:
const unsigned long teste __attribute__ ((at(0x80000000))) = 0x11223344;
and I dont´t define the area 0x80000000 with size 0x400000 in Target->Read/Only Memory Areas. After this error the debugger loses communication with microcontroller and I need to make a mass erase with bootloader.
If I define the area 0x80000000 with size 0x400000 in Target->Read/Only Memory Areas the compilator allocate part of program for the area and messages appear:
ULINK - Cortex-M Error Memory Mismatch! Address: 0x80000000 Value = 0x00 Expected = 0x1F
In both cases the flash memory was correct flashed. In the second case it seems that the debuguer can not see the flash memory, as if the ini file did not work in debug. I configured ini file for both the debug and for flashing so do not understand what's going on.
I finally made the debug to work. I had to turn off the " load application at startup" and do a Load %L in end of the .ini file. However, the IDE does not set breakpoints in external flash address ( 0x80000000 ) what I 'm trying to understand .
I finally made the debug to work. I had to turn off the " load application at startup" and do a Load %L in end of the .ini file. However, the IDE does not set breakpoints in external flash address ( 0x80000000 ). Apparently hardware breakpoints are limited to the first 1G memory from what I read in other forums.