We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have an (external) 512 Kbyte flash using the Harvard model, and an Atmel 89C51 processor. I understand the code must move the boot loader code from flash to RAM for execution. (This assumption based on recent articles in Embedded Systems Programming and Circuit Cellar.) I assume this means a separate RAM chip must be installed in the program (ie, not data) space. Is this correct? Any references or articles on this topic with respect to 8051 family? Thanks.
The 8051 is a harvard architecture, this means the program address space overlaps the data address space but the two spaces are unique. You have code address starting from 0x000 - 0xFFFF and data address starting from 0x0000 - 0xFFFF. For code fetches, the CPU uses PSEN and ALE to fetch the next byte from FLASH or PROM. For data read/writes the CPU uses /RD or /WR with ALE to access your SRAM. You can execute out of RAM only if you override the CPU's architecture by allowing PSEN to enable RAM output drivers. I've never had to do this. Note if you do this you cut your address space in half, one shared block of 64K. 8051's execute in place, there is no copy-down to RAM like you have with traditional Von Neumann CPU's (MIPS, PowerPC, ARM). Just program your FLASH starting at 0x0000 with a jump to your first program instruction. - Mark
Typically, the initialization code and boot loader are permanently located in the 89C5x internal flash. The external flash is then mapped into banks above the internal code address space. Since the boot loader itself will not be field upgradeable, this code should be tight, general purpose, and well tested. The external flash should be programmed in accordance with JEDEC standard 21-C section 3.5, which can be found at: http://www.jedec.org Remember that during programming the external flash must be mapped into the data memory space, so that you can write and verify it. We sometimes temporarily disable some RAM or memory mapped I/O using a flash programing mode control bit (one of the 89C5x I/O ports) to make room in the data space for the flash. I suppose you could use RAM instead of internal flash to run your boot loader, but this requires that the flash be pre-programmed when the board is manufactured. As Mark pointed out, the RAM, like the flash, will have to be mapped into both the code and data address spaces.