Hello NXP community,
I've recently purchased a newer version of LPC1758FBD80 (AZC39200 11 SSD2347C) to replace my older LPC1758FBD80 (SKB283.1 10 ZSD1810A).
I am encountering two issues:
Error while calling macro execUserFlashInit Failed to load flash loader: FlashNXPLPC512K_Cortex.flash Could not start CPU core. (ErrorCode: -2)The same IAR setup works perfectly on my older LPC1758FBD80.
I already tried with the latest version of IAR ARM toolchain, it still fails with the same error.
Questions:
I would appreciate any guidance or recommendations on how to migrate applications from an old LPC1758FBD80 to a more recent one.
Thank you
Solved! Go to Solution.
Thank you @diego_charles for your reply.
I checked the ISP pin, but I still wasn’t able to boot my application.
However, because I was suspecting that the IAR flash loaders wasn't working anymore, I unchecked the “Use flash loader(s)” option under Project → Options → Debugger → Download, and was then able to successfully debug my new LPC1758 from my J-Link probe.
During debugging, I found that the MCU was stuck in the Chip_SetupXtalClocking() function (in sysinit_17xx_40xx.c file), because the SYSCTL_OSCSTAT bit of the SCS register was stuck low.
After examining my external oscillator, I noticed that it was producing a stable voltage level instead of oscillating. I think something went wrong during the chip replacement, which might have damaged my external oscillator.
As a temporary fix, I switched to using the internal RC oscillator, and my application boots successfully !
I will certainly contact IAR to obtain an updated version of the flash loader for the LPC1758, but I can move forward for now.
Thank you for your support !
Hi,
I think that IAR has not updated their LPC17xx.mac file to work with the latest LPC1758 version, since the following error is raised :
C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm/config/flashloader/NXP/LPC17xx.mac(40,17): Error: Operation error.
However I’m not sure what needs to be changed to make it work.
Can anyone help me with this?
__var FLASHCFG;
__var MEMMAP;
__var CLKSRCSEL;
__var SCS;
__var CCLKSEL;
__var PLL0CON;
execUserFlashInit()
{
// Save registers contents
FLASHCFG = __readMemory32(0x400FC000, "Memory");
MEMMAP = __readMemory32(0x400FC040, "Memory");
CLKSRCSEL = __readMemory32(0x400FC10C, "Memory");
SCS = __readMemory32(0x400FC1A0, "Memory");
CCLKSEL = __readMemory32(0x400FC104, "Memory");
PLL0CON = __readMemory32(0x400FC080, "Memory");
// Disable the PLL.
__writeMemory32(0x00000000, 0x400FC080, "Memory"); // PLL0CON = 0
// Qualify the PLL change.
__writeMemory32(0x000000AA, 0x400FC08C, "Memory"); // PLL0FEED = 0xAA
__writeMemory32(0x00000055, 0x400FC08C, "Memory"); // PLL0FEED = 0x55
__writeMemory32(0x00000000, 0x400FC104, "Memory"); // CCLKSEL=0
// Enable main clock
__writeMemory32(0x00000020, 0x400FC1A0, "Memory"); // SCS.OSCEN = 1
__delay(1); //Reading status is unstable
// Wait on OSCSTAT bit, set when oscillator is ready.
//while(!(__readMemory32(0x400FC1A0, "Memory") & 0x40))
// Switch to main clock instead of internal RC for stable JTAG auto-speed
__writeMemory32(0x00000001, 0x400FC10C, "Memory"); // CLKSRCSEL = 1
// Make sure that the flash memory system is correctly setup.
__writeMemory32(0x3A , 0x400FC000, "Memory"); // FLASHCFG = 0x3A;
// If the MAM values was wrong, a dummy read is necessary to get the flash memory in sync.
__writeMemory32(0x00000001, 0x400FC040, "Memory"); // MEMMAP = 1
__readMemory32(0x00000000, "Memory");
}
execUserFlashExit()
{
// Restore modified registers
__writeMemory32(CLKSRCSEL, 0x400FC10C, "Memory");
__writeMemory32(PLL0CON, 0x400FC080, "Memory");
// Qualify the PLL change.
__writeMemory32(0x000000AA, 0x400FC08C, "Memory");
__writeMemory32(0x00000055, 0x400FC08C, "Memory");
__writeMemory32(CCLKSEL, 0x400FC104, "Memory");
__writeMemory32(SCS, 0x400FC1A0, "Memory");
if (SCS & 0x20)
{
__delay(1); //Reading status is unstable
// Wait on OSCSTAT bit, set when oscillator is ready.
//while(!(__readMemory32(0x400FC1A0, "Memory") & 0x40));
}
__writeMemory32(FLASHCFG, 0x400FC000, "Memory");
__writeMemory32(MEMMAP, 0x400FC040, "Memory");
// Dummy read to get the flash memory in sync
__readMemory32(0x00000000, "Memory");
}
Hi @Tay33
Thank you for reaching out! I understand that you are migrating from the second device revision to the third device revision.
The latest revision corrects some erratas from the previous revision. According to Table 2. Functional problems table But we do not have another errata version available that explains further the changes.
As I have been checking there is no new software released for this revision, and we do not guidelines to update the flashloader for IAR.
You mentioned failure to boot the even after programming with J-Link. Can you check the ISP pin? What is the measured voltage of this pin when using the lastest revision?
Best regards,
Diego
Thank you @diego_charles for your reply.
I checked the ISP pin, but I still wasn’t able to boot my application.
However, because I was suspecting that the IAR flash loaders wasn't working anymore, I unchecked the “Use flash loader(s)” option under Project → Options → Debugger → Download, and was then able to successfully debug my new LPC1758 from my J-Link probe.
During debugging, I found that the MCU was stuck in the Chip_SetupXtalClocking() function (in sysinit_17xx_40xx.c file), because the SYSCTL_OSCSTAT bit of the SCS register was stuck low.
After examining my external oscillator, I noticed that it was producing a stable voltage level instead of oscillating. I think something went wrong during the chip replacement, which might have damaged my external oscillator.
As a temporary fix, I switched to using the internal RC oscillator, and my application boots successfully !
I will certainly contact IAR to obtain an updated version of the flash loader for the LPC1758, but I can move forward for now.
Thank you for your support !
Hi @Tay33
This is very good to hear! Thank you for sharing your findings and outcome, it may help others a well!
Diego