The Bootleg - oops, BootLoad Code.

A very quick summary...

This code may help those that want to set up a bootloader for a 8051 device. This particular code works for my setup which is something like:

DS87C520 micro
AM29C040 (512k) flash. The flash is plumbed so that it appears as 16 banks of 32k mapped into memory space at 32k - 64k. In this particular case, the first (2) 32k banks also appear in code space at 0 - 64k. This means that I can write with movx to the flash but also code fetch from it as well. 4 bank mapping bits exist, wired to the flash A15..18, and these appear in data space as "digout" (see code). They actually appear in a GAL16V8,  as does the other re-wiring above and some other chip selects.
GAL16V8 as above...

You'll no doubt be aware that while the flash is erasing, or writing a byte, it can't be read from. This means that the CPU must get it's opcodes from somewhere else. You can either use an 87xxx part, with internal eprom space, or plug a ram chip in and wire it somehow. The cpu still needs something to run when it comes out of reset, so I'm not sure how you'd setup the ram solution, hence my preference (amongst many other reasons) for the 87xxx solution.

This code compiles with the Hitech C compiler. Other compilers may require adjustments to be made here :(

This code hasn't been thoroughly tested as such. The bigger code, from which this has been extracted, was, but I know sometimes bad things happen. Don't burn this into a OTP device until you've tested it !!!  Here 'tis...

 

And now some Delphi...

Okay, now that's sorted out, you'll need a little program to download the hex file to the cpu.  Here's an extract from a Delphi program that does just that.  It's not all there, but you'll hook it into your favourite form easily enough.  You will need some serial handling code though.  I prefer TSerial2 (shareware) for simple jobs like this, and would strongly recommend TurboPower's Async Pro for serious work.  Look at the Delphi Deli for some serial handling code, much of which is freeware.  Download a Delphi (object pascal) snippet here.

Have fun. (HA!)

Contact scott@smartdata.com.au if you get really stuck :)


For more information, contact:  
info@smartdata.com.au  

or Phone: +61 7 3281 8841  
Fax: +61 7 3281 8114