lib spifi bug

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lib spifi bug

507 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pierre on Sun Aug 03 09:01:04 MST 2014
Hello,

I have used lpcspifi (v0.06) to program the flash on my LPC4330 Xplorer board, and encountered a bug...

My program executes from flash.
cr_startup_lpc43xx.c starts by setting up the clock and calling a few initialization functions before coping all the executable into RAM.
So, I have set up the linker script to put this init code in flash.

Everything else is set to be loaded in RAM before execution (including all SPIFI related code of course).

However, the spifi code calls those :

Chip_Clock_SetDivider
Chip_Clock_GetClockInputHz

just after taking ownership of the flash... so of course, the CPU can't access those functions, and it crashes.

The fix is simple, I removed the call to Chip_Clock_GetClockInputHz (it is just a debug output), and made a copy of Chip_Clock_SetDivider, that I load in RAM along with the rest of the code.

Now it works. Actually, after fixing this, my flash programming code worked on the first try. The new libspifi interface is easier to use than the previous one...

So, cr_startup_xxxx.c needs Chip_Clock_SetDivider to be in flash, but libspifi needs it to be in RAM. A bit of a dilemma here.

cr_startup_xxxx.c could copy the executable in RAM before doing all initialization (hm...), or we need a RAM copy of Chip_Clock_SetDivider.

Labels (1)
0 Kudos
Reply
2 Replies

467 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by peufeu on Thu Aug 07 01:44:51 MST 2014
> I imagine the problem you are alluding to is down to the fact the the LPC43xx startup code
>  generated in LPCXpresso calls the SystemInit() function in LPCOpen projects before it
> does the data/bss initialisation.

Yes.

> Assuming you aren't using SDRAM, you may well be able to get away with just moving
> the SystemInit() call to later in the ResetHandler() function.

OK, will try that.

> If you need further assistance, it would be helpful if you could export and post your test project.

No need, the fix works. I was just posting to inform others of the issue.

0 Kudos
Reply

467 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Tue Aug 05 03:01:42 MST 2014
Without seeing your actual project - and the way you are moving code to RAM - it is hard to comment in detail.

But I imagine the problem you are alluding to is down to the fact the the LPC43xx startup code generated in LPCXpresso calls the
SystemInit() function in LPCOpen projects before it does the data/bss initialisation. This is done so that things don't break when external SDRAM is being used.

Assuming you aren't using SDRAM, you may well be able to get away with just moving the SystemInit() call to later in the ResetHandler() function.

If you need further assistance, it would be helpful if you could export and post your test project.

http://www.lpcware.com/content/faq/lpcxpresso/how-importexport-projects

or at least post your linker map file and linker scripts.

Regards,
LPCXpresso Support
0 Kudos
Reply