2008-12-26 02:44 PM
Need some help creating an IAP app
#iap #bootloader #upsd32532011-05-17 03:04 AM
it is working now,
i am a student of wuhan university of technology, the Poople's Republic of China, è°¢è°¢ä½ çš„èµ„æ–™ thanks for your paper,2011-05-17 03:04 AM
My SRAM seems to reset to 0's on watchdog reset. Should I be using idata instead of xdata to store my bootloader key_string ???
2011-05-17 03:04 AM
moon,
can you attach your FULL Startup.a51 ???2011-05-17 03:04 AM
I dunno about using that map picture kinda thingy, but I can just describe what I do (or at least the basic idea):
Page 0: boot flash from 0x0000 - 0x7FFF in code space fs0 from 0x8000 - 0xFFFF in data page 1: fs0 from 0x0000 - 0x7FFF in code space fs1 from 0x8000 - 0xFFFF in code space So... on page 1, I have 64k of contiguous main flash which contains my application, and thus I can have a 64kB app without paging (rather than a 32kb).2011-05-17 03:04 AM
mulls14,
Your SRAM certainly should NOT reset to 0 after a watchdog reset (unless it's not really SRAM). Are you sure you're not just looking at it after all of Keil's initialization code has run and cleared it out? Keep in mind that there's an ''invisible'' assembly file that gets linked into your project called something like INIT.A51 which runs through and initializes static variables and the like before transferring control over to main().2011-05-17 03:04 AM
phaze,
OHHH! Your map makes more sense now. I was assuming that your bootloader was located in secondary flash (csboot - common to all pages), and that your 64k main app was split between fs0 and fs1. I was going to ask how the hell you avoid using paging, but now I get it. On a good note, I've managed to make my current version work. My bootloader is located in csboot0, and main app in fs0. I've had much difficulties w/ startup.a51. I cannot seem to use a string for my key2check because I have little knowlege of the assembler's rules. So Im simply checking one byte. I realize that this is risky for a release version, but for now, it'll work fine. The SRAM reset issue was due the fact that I copied my startup.a51 template from another uPSD example which delcared XDATASTART & XDATALENGTH = 0x2000. As you mensioned, the startup init code 'IF XDATALENGTH <> 0'... was reseting my SRAM. I have corrected this issue. Obviously, since my app now works, I have managed to locate both apps using ?C_C51STARTUP(0x0500). But I had issues locating statusbytes. It seems that the strings within my app (which are also considered constant code space) always preceed my statusbytes. EXAMPLE of main.c: const code unsigned int statusbytes = (0xFFFF) void main(void) { printf(''AAA'') //'A'=65=0x41 } By reading the .hex file, my const code space is as follows :1005F000414141FFFF.... Notice how the string preceeds the statusbytes. So, if I alter my code, i run a high risk of moving my status byte location. No need to respond to this issue. I just wanted to let ya know (FYI). I think that in our full implementation, instead of statusbytes, we are going to use a checksum over the entire main application to validate it. This is due to the fact that our device will be subject to a very rugged environment, physically and electrically, which could posibly corrupt flash. I am currently testing using the uPSD3234A w/ 8Kb SRAM. We are going to use the PSD w/ 32Kb SRAM for our product. However, we need to extend this memory to 64K. Have you any experience adding external RAM to these devices? If so, can you suggest a good chip select pin? Are there any address bus contensions that I must be aware of? Thanks again for all of your help.2011-05-17 03:04 AM
phaze,
I think I read your last message wrong. You said... Page 0: boot flash from 0x0000 - 0x7FFF in code space fs0 from 0x8000 - 0xFFFF in data page 1: fs0 from 0x0000 - 0x7FFF in code space fs1 from 0x8000 - 0xFFFF in code space This is so your IAP application can re-program your entire 64K main application, both fs0 and fs1. Correct? I thought that secondary flash(csboot) 0x0000-0x7FFF was common to all pages, and primary flash(fs0-7) 0x8000-0xFFFF is selectable using the page register. How do you acquire this mapping scheme???2011-05-17 03:04 AM
phaze,
Ok! This map your referring to can be acquired by changing the flash sector equations in PSDexpress. Remember, I'm a dumb newbie. In page0, the bootloader only has access to fs0 in data space. How do you reprogram fs1 data space located in page1???2011-05-17 03:04 AM
mulls,
I'll just answer your last few questions in one shot. Basically, I'm able to accomplish reprogramming the app because I have an insanely complicated page layout (with much more than what I showed you). That was just to give you the idea about how I could have a 64kB app without paging. Another example (that shows how you could reprogram) would be to have pages 0 - 7 all with csboot in the lower 32kB in code space and fs0-fs7 in the upper 32kB in data space respectively (ie. page 0 has fs0 up there, page 1 has fs1 up there, etc.). You could then have page 8 have fs0 in the lower 32kb of code space and fs1 in the upper 32kB of code space. Finally, if you wanted a MASSIVE app, you could locate only your common code to fs0, keep it in the lower 32kb space and in fact map fs1 - fs7 into the upper 32kB from pages 8 - whatever. (ie. page 8 has fs0, fs1. page 9 has fs0, fs2. page 10 has fs0,fs3, etc.). The difficulty in this is that you don't have enough product terms available in PDSSoft express to pull it off without monkey around with individual address bits. So, I have fs0 mapped in the top end on page 0, and then for all other page values, I have it mapped from 0 - 7FFF, but I have an additional term at the end that says (pgr4) or whatever so that it really only maps it in the upper pages. If you read that last bit and your head exploded, I understand. It's probably not necessary for what you're trying to do. As far as the check code of one byte being good enough for now, that depends on your criteria. If we assume everything's random at powerup, that means you can expect to startup incorrectly once out of every 255 times or so. I guess that's not too bad. Finally, there's a very simple way to get the statusbytes where you want them. That is NOT to define them in main. Make a TOTALLY SEPARATE C file names STATUS.C. Put only ONE line in that file: const code unsigned int statusbytes = 0xFFFF; Then tell the linker to locate ?CO?STATUS at whatever address you want. This will make it immune to changes anywhere else in the file as the linker will just link other things around it. Otherwise, you're right... there's no guarantee that it will stay there.2011-05-17 03:04 AM
phaze,
Your assistance has been GREATLY appreciated! I seem to have graduated from uPSD IAP school as I have successfully implemented my ideal mapping structure, thanks to you. Here's what I've done: IAP application: ----------------- csboot(0-3) in code space 0x0000-7FFF fs(0-7) in data space 0x8000-FFFF ?C_C51STARTUP(0x0500) IAP routine must change page register to reprogram all 8 primary flash sectors. MAIN application: ------------------- csboot(0-3) not mapped fs0 in code space 0x0000-0x7FFF (common) ?C_C51STARTUP(0x0500) fs1 in code space 0x8000-0xFFFF (page 1) fs2 in code space 0x8000-0xFFFF (page 2) fs3 in code space 0x8000-0xFFFF (page 3) fs4 in code space 0x8000-0xFFFF (page 4) fs5 in code space 0x8000-0xFFFF (page 5) fs6 in code space 0x8000-0xFFFF (page 6) fs7 in code space 0x8000-0xFFFF (page 7) The use of page 0 has inherantly been lost, but for cleanliness, maybe I should make fs0 = upper 32k if page==0, lower 32k if page <> 0. Anyway, thanks again for all of your help!