Flash programming for bootloader

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

Flash programming for bootloader

9,005 Views
marchè
Contributor I
I have a big problem!
I use Metrowerks codewarrior for HCS12.
I'm developing the bootloader.
I hae to remap the RAM over the bootloader so I can use the interrupt within the boot. But the RAM is 12K and when I'm not able to program the flash under the RAM!
For example the RAM is from $D000 to $FFFF, how can I program the address $E000 if the RAM has an higher priority than Flash?
 
Thanks.... 
Labels (1)
0 Kudos
Reply
7 Replies

1,247 Views
marchè
Contributor I
Thank you very much!!!
I made a mistake in the calculation of the Flash address.
I decided to place the boot in RAM without remapping it e so I don't use interrupts.
In fact my boot has to lunch the application within itself.
I can't perform an hardware reser after the Flash programming.
So I have a question for you: Can I remap twice the RAM without an HW reset?
For example using the watchdog reset, or jumping to the reset vector address.
 
0 Kudos
Reply

1,247 Views
mke_et
Contributor IV
Actually, when you issue commands to the flash, more than one page 'disappears'. That means even if aren't actually programming the boot code, you can be one page down, the boot area is unavailable. However, other pages can be programmed fine. On the 128K part, I can programm the pages at 38-3B without worry, but if I try to program 3C through 3F I have to be careful.

And one thing you have to be careful about is interrupts. You vector table can 'go away'. Oops!!

Now, since you can only do some operations 'once' after a reset, you might want to consider doing your bootloader code with NO interrupts, expecially if you can't execute a reset after programming. It's neat to drop SRAM up top and just move your bootloader image to it as well as you vector table, and then execute from RAM. But then you have to hard reset when done to get back to how you may operate the platform live. On the other hand, you could do it with no ints, although that can be tedious.

Or... if you're willing to give up a flash area at C000 and use it as paged flash only, I suppose you could have your default runtime map of the system be SRAM up top, and have your boot code set up the system that way after setting up the RAM with a vector table in RAM. But then you're talking some serious management of resource issues...
0 Kudos
Reply

1,247 Views
imajeff
Contributor III


mke_et wrote:
Actually, when you issue commands to the flash, more than one page 'disappears'. That means even if aren't actually programming the boot code, you can be one page down, the boot area is unavailable. However, other pages can be programmed fine. On the 128K part, I can programm the pages at 38-3B without worry

More specifically, it helps to read the docs about Flash "blocks", their size, and how to write.

Each block is 4 pages (16K X 4 = 64K). Block 0 the last 4 PPAGEs. The block being programmed cannot be accessed, therefore your code must be in RAM or a different block of ROM.

Sure that means you can write some Flash while executing from other Flash as long as the device has more than 64K Flash. It's just not practical with most bootloaders because they want to be able to write to as much Flash as possible to be versatile. That's why copying actual write routine to RAM (or maybe external mem) is better. I'm sure march� already knows this stuff though.
0 Kudos
Reply

1,247 Views
imajeff
Contributor III
Instead of remapping RAM to the bootloader addr, I'd prefer to make some relocatable bootloader code. I copy it to RAM addr, then jump there to program flash. You really don't have to stay in RAM the whole time, unless to improve pgm speed. The only time you need to jump to ram is for the actual programming pulses.
0 Kudos
Reply

1,247 Views
marchè
Contributor I
The chip is the MC9S12A256BCFU and I load the application by the BDM MULTILINK CABLE.
I'm programming in C.
Maybe I can't access to the 3F page for this reason (for the datapage handling).
Could it be possible?
Have I to use the assembler in programming flash memory?
0 Kudos
Reply

1,247 Views
Gizzzmo
Contributor I
Hi march,

I'm interested in what you are developping because i've some problems doing quite the same. What is the exactly your target chip ? Is your bootloader loaded in RAM by the LRAE ?

Thx
0 Kudos
Reply

1,247 Views
mke_et
Contributor IV
Map the flash as a 'page' somewhere else? Unless I'm making a serious mistake, just map 3F (the page normally resident at C000-FFFF) just like any other page down low to program it while you operate from RAM.

Message Edited by mke_et on 2006-06-06 03:44 PM

0 Kudos
Reply