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
yf800930
Associate II
Posted on May 17, 2011 at 12:04

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6iB&d=%2Fa%2F0X0000000btm%2F73TashDHrmLHgZjiAusCDSZP1UJ2SMK.fxxJphQmG1s&asPdf=false
erics
Associate II
Posted on May 17, 2011 at 12:04

mulls,

I really appreciate your and Phaze's conversation about IAP, as it has helped me out greatly. I am currently trying to make an application on the 3200 board that supports IAP. My main application will also require code banking.

So my questions are:

(1) What did your final memory map look like in PSDsoft Express (i.e. which files did you load where?). It looks to me like you loaded your IAP file into CSBOOT0, but then I get confused about which pages you put what, and how you had the pages configured with the fs0-7.

(2) Would it be possible for you to show me how the final code in your startup.a51 file looked like? I understand if you are unable to, but it would really help me out to see a working example.

(3) the statusbyte gets defined as 0xFFFF, doesn't that mean that it should run the main app when it is 0xFFFF? do all the constants get defined in the main app?

I am very new to this MCU, and actually to the everything in this topic as well... I am a student working an internship. Thank you a lot for all the information that you have already posted!!

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

elsevers,

I would be glad to show you my IAP implementation. I'll even give you some of the files if you would like (proprietary info removed of course). I find it easier to learn by example. Take your time figuring out the uPSD though, I found it to be pretty confusing at first. Unforturnately I'm busted for time today, but I can chit-chat with you tomarrow 8:00am - 5:00pm eastern USA. I'll try to answer some of your questions in the morning, but if you don't see anything by noon, post a reply here, and I'll get a notice-email.

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

From ST's website, download sample apps from not only the DK3200, but from the other Dev Kits as well. Some of the other chips have very similar functionality(and code) as the DK3200, plus some of the examples are better suited for IAP, I2C, and other things.

Some of the file extensions are probably unknown to your PC, like .map & .arp. Many of the files generated by PSDexpress are simply text files with different extensions, open them w/ notepad.

I have removed all proprietary information from all of these documents. The removed info does not pertain to IAP anyway.

iap_main.c - Useful IAP usage in my IAP program.

main_system_control.c - The MAIN program's subroutine which handles IAP usage.

MAIN_NOTES.TXT - helpful info relating to the project.

STARTUP.A51 - bootloader used by both IAP & MAIN programs (Some ST samples describe this).

L51_BANK.A51 - Needing for code banking(paging). There is an ST sample using this too.

These files....

main_app.arp

main_app.map

main_app.sum

... are produced by PSDexpress. They show the general mapping and equations for my IAP implementation.

Remember even with all of this information, it is going to be difficult to follow my mapping until you have gained extensive experience with the DK3200, the uPSD3234A, and PSDexpress.

Take some time to absorb all this stuff. Let me know when you have questions. Later. 8-)

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

Let me try attaching that again....

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

Mulls,

Thank you!!!! I am going to do exactly as you suggested: take some time and sift through everything.

I will let you know what comes of it. Thanks a lot for your help! 8-)

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

Okay, so I am working through your code and i have a couple questions regarding the paging.

**(1)**Your main_app.arp file shows:

FS0 [00000 - 07FFF] 0000 7FFF C:\DUMMY\MAIN.H01

FS1 [08000 - 0FFFF] 8000 FFFF C:\DUMMY\MAIN.H01

FS2 [10000 - 17FFF] 8000 FFFF C:\DUMMY\MAIN.H02

...

Did you mean to have Main.h00 as the FS0 instead of main.h01? or are both fs0 and fs1 supposed be Main.h00? I think this ties in with my next question,

**(2)**I noticed that in the Startu32.a51 file you have the following:

MAIN_APP_STARTUP_PAGE EQU 01H ;refer to PSDsoft mapping

IAP_APP_STARTUP_PAGE EQU 00H ;refer to PSDsoft mapping

Shouldn't the main_app_startup_page be equal to 00H?

**(3)** In PSDsoft, my rs0 value is set for 2000 to 3FFF, I noticed that ST's RS232 sample project has the same setting. This allows for 8kb of xdata. When I try to change it to match your settings I get a warning saying ''In 'Chip Select Equations' tab under 'Design Assistant' The following signal(s) exceed the maximum chip select size. Do you want to continue? rs0.'' Is this something to be concerned about? is 8kb alright as far as the programming is concerned?

So far I have been able to get the IAP application to load, but when it tries to reboot into the main app, it seems to not be able to find it and I get a blank screen. so i assume that it is related to the above questions.

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

The mapping that I used is as complicated as it gets, so I applogize in advance if its takes a couple tries to explain it correctly.

Files in my Keil project are mapped to various pages(banks), but the main() routine (and a few others) are mapped 'common' (no banking). FYI: Interrupt service routines must be mapped common to all banks for obvious reasons. When banking is used, keil produces .H## files instead of the standard .hex file.

For example:

If main() is common to all banks starting at 0x0000

function1() uses bank 0 at 0x8000

function2() uses bank 1 at 0x8000

This will create hex files .H00 & .H01 which will be identical from 0x0000 to 0x7FFF, but .H00 will contain function1() at address 0x8000 and .H01 will contain function2() at 0x8000. This is because main is common to both banks. A hex file is created for each bank, even though main() is common to both of them, resulting in both files containing the same program from 0x0000 to 0x7FFF.

For reasons i will discuss later, there is nothing mapped to bank 0 in my main program, so there is no .H00 created. The remaining banks .H01-.H07 all contain routines used by my program. 0x0000 to 0x7FFF are the same in every .H## file.

The main_app.arp statements can be described in words like this...

FS0 [00000 - 07FFF] 0000 7FFF C:\DUMMY\MAIN.H01

FS1 [08000 - 0FFFF] 8000 FFFF C:\DUMMY\MAIN.H01

In the file ''MAIN.H01'', place the code which falls in the addresses between 0x0000-0x7FFF, into the uPSD flash sector called FS0 which has a physical address of 0x00000-0x07FFF.

Then, In the file ''MAIN.H01'', place the code which falls in the addresses between 0x8000-0xFFFF, into the uPSD flash sector called FS1 which has a physical address of 0x08000-0x0FFFF.

I guess I could use any of the .H## files for FS0 since they all contain the same code from 0x0000 to 0x7FFF.

On to the next issue...

Refer to main_app.map:

Label Page Bit start end Mem comments

fs0 0byyyyyyyy 0x0000 0x7FFF F // & !pdn & !_psen

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

In the Page Bit field you can see that when psen(program storage enable) is false, that means that the primary flash sectors FS# are now mapped to data space, and secondary flash csboot is now in program space. Also when psen is false, fs0 mapps to 0x8000-0xFFFF of page0. This means that csboot is in program space from 0x0000-0x7FFFF, and all of primary flash FS# is mapped to data space using page0-7 to choose each sector.

This is how the IAP application (running in csboot) re-flashes my entire primary flash sectors with whatever code I want. When the IAP has completed re-flashing primary flash, I then map primary flash (FS#) to program space, and map csboot to nowhere(undefined). Now that primary flash is in program space, change the page to any other page than 0, like 1, which mapps FS0 common to all pages(except 1) to 0x0000-0x7FFFF, and all other sectors FS1-FS7 are mapped to pages 1-7 0x8000-0xFFFF respectively.

You now have the ability to run and/or reprogram an entire 224K of program.

Once I completed testing with the DK3200 using the uPSD334A w/ 8K SRAM, I upgraded to the uPSD3254A w/32K SRAM. Thats the problem you're having. PSDexpress knows how much RAM the 3234A has, so when you tell it to use more, it craps out on you. Just stick with 8K for now, it doesnt impact the IAP development anyway.

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

At first, like you I was using their sample WinApp to communicate with their sample IAP program. I also found that file size bug when I opened hex files which are banked. After reading the winapp source code it is clear that they are not looking for the sector change intel-hex record within the hex files. Hence, the program reads banked hex files incorrectly. Note: read up on Intel-Hex format files and the record structure within them. It's pretty simple, but the ability to read them is very useful when debugging.

Remember, both the winapp and the IAP demo program are for example only. They have bugs and sould not be exactly duplicated.

My IAP program uses the same flash writing functions that are provided with the IAP demo. However, the rest of the IAP demo's functionality was gutted to better suit my needs. The IAP demo is a good example of page changing, and the changing of primary and secondary flash sectors into program/data space. Get familiar with it and the win app as they are good learning tools. It will be difficult to use the IAP demo program as a test subject for your application because the bootloader(assembly), IAP program, your main program, and the PSDsoft express must all be built around the same mapping.

I have got a bunch of test projects which I built when I was in your position. They progressively test each aspect of the DK3200 individually: Banking, IAP, Serial, I2C, RTC, Power, etc. I can send them to you as a winzip file attached in an email but I wont post them here for obvious reasons. Let me know if you want them, and If yes, post an email address that I can send the winzip file to.

Mulls out -

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

IT WORKS!!! :-]! Well at least the MCU part of it does.

I am using the sample windows IAP RS232 Demo application to load the hex files onto the MCU from the PC. The one that ST publishes on their site for both the DK3200 and DK3300 boards. It seems to have issues in reading Keil's banked files. The problem is that it thinks that the file is 1,300kb long when in reality it is around 7 KB. Are you using their sample pc application or did you write your own?

Thank you so much for your help!