Is there a lib for Spifi-routines(Init;Read;Write) in lpcxpresso?

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

Is there a lib for Spifi-routines(Init;Read;Write) in lpcxpresso?

844 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Meyer on Tue Sep 17 06:52:15 MST 2013
Hi lpcXpresso-team,

I would like to read and write data from Spifi-Flash, while the code is running from the internal ram. There is a lib in Lpcopen, but i can´t integrate this lib in lpcxpresso. I have found on the internet a libspifi_drv_M4.a but without success. Is there anybody who implements these lib in lpcxpresso or got access without the lib ? I would be very happy if I did not have to do everything on foot.

Plz help me

Thx
0 Kudos
12 Replies

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Meyer on Fri Sep 20 05:40:19 MST 2013
Hey i got it ;)

Those who can read clearly have an advantage.

*** The project uses the 256 KB erase command, but pretends that it only needs to store 4 KB. That of course is not correct for a standard application. Please make sure to get the appropriate 64 KB uniform sector part with the 4 KB parameter sectors in order to use this example code in a real application.

Thx for ur help ;)
0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Meyer on Fri Sep 20 02:36:32 MST 2013
Hi noahk,

AtCLR is defined in core_cm4.h. I have run the program without debugger but without success...

I uploaded the project. take a look and plz help me :)

meyer
0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Meyer on Fri Sep 20 02:19:23 MST 2013
Hi Mc,

here is my lpcxpresso project. 1. File is Boardlib for hitex eval board and my firmware. At the beginning of the program comes a menu and u have to send option  '4' over uart .

Then u jump in state7 and there comes the spifi_function.

2. File are the linkerscripts I used.

plz let me know if u find something ;)

Thx
0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mc on Thu Sep 19 18:52:12 MST 2013
Hi Meyer,
Please post your full code here or send it to us. We will have a look
0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by noahk on Thu Sep 19 14:38:40 MST 2013
Hi Meyer,

I have heard that some headers don't define the ATCLR bit. Please make sure to keep that line as it affects jumping back to SPIFI for execution.

Disable before jumping out of SPIFI:
SCnSCB->ACTLR &= ~2; // disable Cortex write buffer to avoid exceptions when switching back to SPIFI for execution

and then re-enable after:
SCnSCB->ACTLR |= 2; // reenable Cortex write buffer

If it isn't this, then perhaps IAR is looking ahead and crashing for that reason. Perhaps burn the program and run it without the debugger open. Use some GPIO to blink some LEDs to see if it is working.

The SPIFI gives bus errors if the memory space is accessed when not in memory mode, so prefetching from that area for disassembly debugging could be causing issues. Also it is important to not have the SPIFI register space open as reading from SPIFIDAT will cause a bus error when there is no data to read.

Please send me your project, and I can try to run it.

Also please see a blog post I created for SPIFI:
http://lpcware.com/content/blog/introduction-spifi

Noah
0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Meyer on Thu Sep 19 06:11:09 MST 2013
Hi noahk,

I am using the Hitex Eval Board Lpc4350 with exactly this Spansion S25FL129P. Memory Region is correct ,register base address is 0x40003000.

In my opinion it should be run. When I run the entire code from the ram, then I can read and write out of flash as I'm funny.

I guess the problem is switching back to spifi for execution. Cause when debugging i saw the new value written in flash but after that i got error

fffffffe: Unable to retrieve disassembly data from backend. No source available
100000004: Unable to retrieve disassembly data from backend.


if you have the same board, I can send my project.

If anyone has an idea; bring it on ;)

Thx
0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by noahk on Wed Sep 18 16:46:01 MST 2013
Hi Meyer,

What board / chip are you using? What SPI Flash do you have? This code was written for the LPC4350 with the Spansion S25FL129P.

If you have a different chip then you must change some of the memory offsets. For example the 0x14000000 in main.c refers to the LPC43xx memory region for SPIFI memory. If you are on another chip you must modify the offset to reflect the base of the SPIFI memory range. You would also need to change 0x40003000 in spifi_functions.c to reflect the SPIFI register space. Also change the includes to reflect the correct core and chip in spifi_functions.c.

If you have a different SPI Flash then you must modify the code in spifi_functions.c. The code is tailored to the Spansion S25FL129P. It is written this way to clearly demonstrate usage of the registers on the SPIFI.

Let me know what chip and flash you are using, and I can try to give you additional guidance.
Noah
0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Meyer on Wed Sep 18 06:57:02 MST 2013
I put the functions into Ram with __attribute__ ((__section__(".data.ramfunc")))

.data.ramfunc  0x10080004      0x4b4 ./spifi_functions.o
                0x10080004                spifi_setup
                0x10080104                spifi_update_const

errors are gone.. But now I hang in the while loop.

while(*(volatile int*)&test_word != 0xfacedead);

I guess it is cause of test_word. It is put to ( 0x10084b48 test_word) and it should be placed into flash?
0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Meyer on Wed Sep 18 02:07:26 MST 2013
Hi noahk,

thx for your reply ;)

I take a look at this example and I don´t get it to run. I guess it isn´t a lpcxpresso project that is why I put the spifi_functions.c into my running project. In the map file :  .data.LPC_SPIFI
                0x10080000        0x4 ./spifi_functions.o
                0x10080000                LPC_SPIFI
.data.quad     0x10080004        0x1 ./spifi_functions.o
                0x10080004                quad

the whole spifi_functions.c is put in IRAM. I guess it is right but I don´t know where u do that.  Ok it doesn´t matter.

In the main I set the volatile variable go to 1.

In function spifi_setup() CRASH!

Failed to execute MI command:
          -data-disassemble -s 335545108 -e 335545212 -- 1
          Error message from debugger back end:
          Cannot access memory at address 0x14000326

That is while wait for reset to complete..

after that:
fffffffe:   Unable to retrieve disassembly data from backend. No source available
100000004:   Unable to retrieve disassembly data from backend.
here is gone

Is it your startup file, which i do not use?

Plz help me


0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by noahk on Tue Sep 17 07:53:04 MST 2013
Hi Meyer,

You might want to take a look at this example:
http://www.lpcware.com/content/forum/spifi-errata-and-part-version-information#comment-1023028

The example goes through the process of executing from SPIFI and then switching over to SRAM to reprogram the SPIFI. Finally it jumps back to SPIFI for execution.

There is also SPIFI documentation included in the user manuals. The SPIFI documentation for the LPC18xx is at:
http://www.nxp.com/documents/user_manual/UM10430.pdf
Chapter 19: LPC18xx SPI Flash Interface (SPIFI)

Let me know if this works for you or if you have any questions,
Noah
0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Meyer on Tue Sep 17 07:23:38 MST 2013
No this does not help

I am able to run the code from spifi flash. But i need routines to init read and write the spifi flash when my code is running in ram or other flash. In lpcopen/software/spifilib is a lib with these routines. But i can´t use them in lpcxpresso, cause of standard gnu toolchain expected .a as lib. So again my question:

Is there anybody who has access to spifi flash in his application ? or is there anybody who compilied the lib for lpcxpresso?
0 Kudos

727 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by whitecoe on Tue Sep 17 07:06:57 MST 2013
In the first place, you could look at the SPIFI projects in the Examples\Flashdriver subdirectory of your LPCXpresso install.

HTH!
0 Kudos