cancel
Showing results for 
Search instead for 
Did you mean: 

Need some help creating an IAP app

jmullaney
Associate II
Posted on December 26, 2008 at 23:44

Need some help creating an IAP app

#iap #bootloader #upsd3253
108 REPLIES 108
erics
Associate II
Posted on May 17, 2011 at 12:04

That would be awesome if you wanted to send me those files! My email address is:

mailto:erics@forwardr.com

I am going to read up on the hex file format, as you suggested. Thanks again for your help! I am slowly coming along.

isabelbl
Associate II
Posted on May 17, 2011 at 12:04

Sorry, but I could not with the first one, I cannot see how is that memory map, my program is really big and I can put it all on the secondary memory, but I suppose I am not understanding well your indicatins, can you help me?

1. Create a memory map that has one page with secondary flash mapped in the lower 32kB of code memory and main flash mapped into the upper 32kB (or whatever) of data memory (with your RAM and the like in the lower 32kB of data memory). This map should have another page with main flash mapped into the lower 32kB of code memory and secondary flash not mapped anywhere.

2. Create a project for some compiler (I use Keil) to contain your IAP routines. Make sure to copy and include the STARTUP.A51 code from Keil if that's what you're using. In this project, write the various routines for programming the main flash, etc.

3. Create another project to contain your main application. Find an open block of fixed code memory and define some constants there that are all FF's, like so:

const unsigned int code statusbytes = 0xFFFF;

4. Modify the STARTUP.A51 file for BOTH projects to be IDENTICAL. This assembly code should, at startup, check the status bytes of the main application and if they're equal to some predetermined value (OTHER than FF), run the application. Otherwise, it should just run the IAP routines. The way the code runs the application is by changing the VM register to let it fetch code from EITHER main or secondary flash, THEN swapping to a page which places main flash in the space previously held by secondary flash. A final note is that you have to tell the linker to place this startup code (in Keil, the routine is C_C51STARTUP) at the EXACT same memory address. Just look at the memory map and pick someplace that looks convenient.

Notes:

- When you finish programming the main flash application, you should set the status bytes to whatever value you want to be your ''good'' indicator. For examples, I use 0xFE

- Your startup assembly code also needs to check if you're trying to switch into IAP mode. I do this by writing a long key sequence into RAM from the main application when IAP is initiated and then letting the watchdog reset the processor. I have my startup code check this BEFORE seeing if the application is valid, and if it's there I run the IAP routines. Make sure it's a long enough key sequence that random RAM contents at startup couldn't accidentally prevent you from running the application.

- When you start reprogramming flash, the very FIRST thing you should do is program your status bytes to 0x0000, that way if anything goes wrong, your startup code will know NOT to try and run a corrupted application.

There are some other nifty things you could do. With as much memory as the DK3200 has, it's possible to have multiple application images and have the startup code just run whichever one is valid. This way, you avoid ever having no application to run after a failed download.

Hopefully some of that will help. It took me quite a while to wrap my head around what's involved in doing all this manual paging.

jmullaney
Associate II
Posted on May 17, 2011 at 12:04

George,

Are you asking me a question? Or did your message land here by mistake?

isabelbl
Associate II
Posted on May 17, 2011 at 12:04

Sorry, it was not very clear but yes, it was a question.

jmullaney
Associate II
Posted on May 17, 2011 at 12:04

I don't know what you're asking me. Try to ask very specific questions, because describing the DK3200 usage can be complicated when speaking generally.

Are you planning to use the IAP capabilities of the uPSD3234A?

Or are you simply trying to put a large amount of code in secondary flash?

jmullaney
Associate II
Posted on May 17, 2011 at 12:04

George,

Please review the forum discussions between myself and elsevers. He was a newbie also, and I walked him through the IAP methods that I am using. In previous forum discussions I suggested to read the uPSD documents & source code thoroughly. Getting a handle on the IAP mapping and usage takes time and patience. The terminology used in uPSD development is tricky, so a good place to start is by tinkering with the sample programs provided with the DK3200. You will soon become familiar with the memory mapping and chip architecture terminology needed to understand the more advanced mapping required for IAP.

Walk before you run ;)

isabelbl
Associate II
Posted on May 17, 2011 at 12:04

Sorry again,

I am trying to make an IAP application and I saw this message in the forum. I thougt I could follow these steps to try and make my IAP program but I was not able to perform that memory map you told; first because I did not understand how it was, and second because in my program is too much code and I need the main memory and the secondary as code memory. So my question is how can I do it?

The memory map I have in this moments is like that:

fs0 0byyyyy000 0x8000 0xFFFF F // & !pdn

fs1 0byyyyy001 0x8000 0xFFFF F // & !pdn

fs2 0byyyyy010 0x8000 0xFFFF F // & !pdn

fs3 0byyyyy011 0x8000 0xFFFF F // & !pdn

fs4 0byyyyy100 0x8000 0xFFFF F // & !pdn

fs5 0byyyyy101 0x8000 0xFFFF F // & !pdn

fs6 0byyyyy110 0x8000 0xFFFF F // & !pdn

fs7 0byyyyy111 0x8000 0xFFFF F // & !pdn

csboot0 0byyyyyyyy 0x0000 0x1FFF F // & !pdn

csboot1 0byyyyyyyy 0x2000 0x3FFF F // & !pdn

csboot2 0byyyyyyyy 0x4000 0x5FFF F // & !pdn

csboot3 0byyyyyyyy 0x6000 0x7FFF F // & !pdn

rs0 0byyyyyyyy 0x2000 0x3FFF V // & !pdn

csiop 0byyyyyyyy 0x0200 0x02FF V // & !pdn

psel0 0byyyyyyyy 0x0300 0x03FF Peripheral // & !pdn

LCD_A0 // > 100 address ranges, no address range generated.

!CS_LCD

0byyyyyyyy 0x0300 0x03FF Peripheral // & LCD_RD

0byyyyyyyy 0x0300 0x03FF Peripheral // & LCD_WR

I do not understand very well, exactly how must me the memory map for an IAP program, and I do not understand either how works an IAP program, I mean, is the same program that works on my device but it has something that when I send some commands from a PC it starts the IAP program to load the code via serie or USB?

I am a newbie, and I could not find any information about IAP (application note or whatever) and I have to solve the problem myself but I do not know how to start.

Thank you very much.

Quote:

On 16-09-2005 at 17:08, Anonymous wrote:

I don't know what you're asking me. Try to ask very specific questions, because describing the DK3200 usage can be complicated when speaking generally.

Are you planning to use the IAP capabilities of the uPSD3234A?

Or are you simply trying to put a large amount of code in secondary flash?

nullnull

isabel_benitez
Associate II
Posted on May 17, 2011 at 12:04

Thanks all of you for your discussion, it has been a great help for me, but I am still really far to get everything work ok, the iap and my own application.

There are mainly three questions I need to understand to go further.

1- Can someone exactly where I must put the *.h00, *.h01, ..., *.h00 of my app and the *.hex of the iap? I mean in the psdsoft. My memory map is the one you attatched here with the rest of files of your application. I have tried several combinations and I can get some kind of living in my machine, but it doesn't work ok, the display is black, etc. But if I try to connect to the PC with the software from st, it seems to communicate properly.

2- There is something I don´t understand, how must my machine start to make it in a normal way without iap programming? And how must it starts when it needs to be programmed? I mean, is the pc who tells the uPSD that there is going to be a reprogrammation of its memory? If I turn on my machine, I told you before, but the most of the things doesn't work.

3 - And the last one, I was really happy with the information you wrote here, but suddenly I found out that the software for the pc st provides is not the good one, what I am going to do now?????? Is there anywhere one that works properly? I am the only person in the R&D department, and believe me, I have no time to develope the software.

Thank you again for your help here in the forum, and forget me if there is something that is not explain properly, my english is a bit poor.

jmullaney
Associate II
Posted on May 17, 2011 at 12:04

Icebell,

1- The files that i've provided probably won't work with your hardware. I'm using a different graphic LCD, and other stuff. You'll have to extract the IAP functionallity from my files and incorporate them into your pin-definitions for your HW. That might be why your LCD is black. Compare my PSD setup with that of the ST examples for your dev-kit. I've attached an image of the hex file mapping. I hope it helps.

2-The IAP and MAIN programs are totally isolated from each other. IAP lives in CSBOOT0-3, and MAIN lives in FS0-7. The only way to switch between them is to write data into SRAM, and then force a self-reboot. When the bootloader starts, it will examine the contents of SRAM, and decide which program to run: IAP or MAIN. So for example, if you want to start the IAP program, write something like ''BOOT_IN_IAP'' into some location in SRAM, and let the watch dog timer reboot. The IAP program can then communicate with your PC application, and reflash the 'MAIN' program. Then from IAP, write ''BOOT_IN_MAIN'' to the same SRAM location and cause another reboot. The bootloader will examine the SRAM data and start the MAIN app. If the MAIN program is running, you can use anything to cause a reboot into IAP, a keypress, a serial command, anything. My program has a menu item called ''Program Update''. When the user selects that menu item, I write data into SRAM, and force a reboot: simple as that. To reprogram the MAIN app, your IAP program must be able to communicate with the PC. Write a PC app to exchange data with you IAP application. The ST examples are great but they are just that, ''examples'', you should modify them to suit your needs.

3- The ST examples are great, but I also found out that I had to write my own reprogramming application. The .obj file created by PSD express contains your entire program: both IAP & MAIN programs. You must write a program to extract the necessary data from the .obj files and then transfer the data to your IAP program so it can rewrite the contents of FS0-7. I wrote the program for my company so unfortunately I'm not allowed to distribute it. But I'll try to answer any specific questions you may have.

Hope I could help.

isabel_benitez
Associate II
Posted on May 17, 2011 at 12:04

Here I am again,

I have started to taking a look to the software, it would be very helpfull if you could give some tips about where the program is not working properly, maybe you haven´t worked too much with it, and you have just made yours, but if you know, please, make me know.

In the last messagge I forgot to tell you that I put my own hex files on the psdsoft to make my machine works, the display didn´t work because when I turn it on, it stays in the iap communicating with the pc and there wasn´t anything that make it change to another part of the program, I will chage this too and I will tell you about it.

Thank you again for your attention and for the information you share here with all of us.

Icebell