We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I had a look to the Keil\ARM\Flash\AT91SAM7_64 and it looks this code was design to never run.
1. The example finishes with error 2. ProgramPage should be at least in RAM 3. *Flash++ = *((unsigned long *)buf); -> buf should be aligned before get Data abort exception.
Did someone has some working example with Keil AT91SAM7xx and data flash?
Hi Robert,
Thanks for fast feed back. Please try next:
1. Make a new project int main(void){} 2. Add the flash files to the project. 3. Try to flash 1 page from main.
Operation finish with data aborts exception after: AT91C_BASE_MC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_START_PROG | (AT91C_MC_PAGEN & (page << 8));
The same problem it's described in several forums: www.embeddedrelated.com/.../1385.php
And it happens also with Keil.
If you have some sources which it works please publish it because so far the flashing new pages look like a big problem.
Best regards
As answered: The code you have is expected to be downloaded into RAM through the JTAG interface when you download applications to the unit.
The code is _not_ intended for inclusion in your own applications.
So, if you want to copy the code for use in your own application, then you must create a project where the code will be run in an identical way as when downloaded run using the JTAG interface.
You must make sure that the code runs from RAM - either by manually copying the code, or getting the linker to see it basically as initialized RAM, and decompressing/copying the function to a suitable address in RAM.
And _you_ have to make sure that the function is supplied with aligned data blocks.
When you take sample code intended for one problem, and want to use it for a completely different problem, then it is up to you to figure out the needed changes.
One more: The key flash algorithms are not intended to be run from any main() - but you could possibly modify them for that use.
I believe that you have probably missed something. I have just tried it out on AT91SAM7256 (256kB Flash) and it works as expected.
A simple demonstration of using ULINK's Flash algorithms in an application:
1. Create a new project and select AT91SAM7S64 (automatically copies the startup code) 2. Add the FlashPrg.c from ARM\Flash\AT91SAM7_64 folder (comment out the include for FlashOs.h) 3. Add the following main.c:
extern int Init (unsigned long adr, unsigned long clk, unsigned long fnc); extern int ProgramPage (unsigned long adr, unsigned long sz, unsigned char *buf); unsigned char __align(4) buf[128]; // Buffer properly aligned int main (void) { int i; for (i = 0; i < 128; i++) buf[i] = i; // Init Buffer i = Init (0x00100000, 18432000, 0); // Init Flash i = ProgramPage(0x00108000, 128, buf); // Program one Page while (1); }
4. Change Memory assignment for FlashPrg.c (right mouse click) to IRAM1 so that algorithms are copied to and executed from RAM. 5. Build the application and Flash it 6. Debug the application which runs correctly and programs one page at address 0x00108000 (can be verified in the debugger)
An alternative is also to make the whole project for RAM which is then loaded and executed by the debugger.
Hi Per,
Thanks for you reply. It clarifies a lot of things. Can you deliver some tutorial sources where flash it's possible from application? So far I found a lot of complaining all over the sites and no real examples/solution for this problem (it looks not so easy to make). No sources deliver from Keil and so far I spend 2 days of debugging and the results are so far not very positive.
Thanks Robert. I'll try it and give you a feed back.
I'm not sure I understand you, but if you are trying to do IAP you can look at http://www.st.com, STR9 samples.
So far the example it's working and looks this is the correct way to flash the data. Thank you very much for fast response and very very good support. I'll try to integrate now in main program. If I get some other problems please allow me to continue this subject.