This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to build code when code split between ROM/RAM

For the 8051 code space, if I have some code in ROM and some in RAM and I am using bank switching, how should I build my code? My specific question is with regards to RAM updates. I would want to be able to update the code in RAM and yet have the same ROM code.

What process should I follow for compilation, linking, data segments management etc? Do I need to create libraries? Any pointers will be helpful. thanks!

  • The 8051 architecture (and, therefore, the C51 tools) neither knows nor cares about RAM or ROM or any other memory technology - all it sees is CODE space and the various data spaces.

    You need to explain how you intend to achieve updatable code in RAM for people to be able to explain what tool configuration(s) might be necessary...

  • Right. First thought we have is to have banked code with for example, Bank0/Bank1 in ROM and commonBank in RAM. The commonBank will have function pointer table for functions that will be "designed to be patchable" in addition to all the usual code that are supposed to be there in commonBank. There will be some hardware hooks to download commonBank code into RAM before 8051 starts out of reset. The patch mechanism has two intended purposes 1.) to prototype new features and 2.) to fix any critical bugs.

  • Sounds like a bad idea. Get an ARM chip. Prototype by running everything in RAM while testing.

    Create the real application using a small boot loader and two application areas. Let the boot loader start the application in the second application area. Download a new application to the second application area. If checksum is ok, reboot and have the boot loader clear the first application and start the second.

    Patching to fix bugs is likely to produce 10 times more bugs than it can be used to solve. Your solution is like selecting expensive light bulbs with multiple filaments, and hardware that measures the current when powering the first filament and automatically switch to the second filament if the first one fails. Way easier to just get two lamps. Overengineering is a great way to crash and burn in spectacular ways.