I was reading a book called "Insiders guide to the Phillips ARM7 based microcontrollers". There it says "The easiest way to program the Flash is by the built in bootloader which allows the code to be downloaded via UART 0 into RAM and then programmed into FLASH". In Flash magic when we dump the .hex file via the PC's COMM port to the LPC1778 UART 0 port, does the .hex file go into the RAM and then does the bootloader inside place the code into the flash? If so,the onchip RAM is 64K in size and the flash size is 512k in size. What if the .hex file size i want to dump is greater than the size of the RAM?
In general, firmware images are not transferred over the UART verbatim; instead you communicate with a bootloader that provides in-system programming (ISP) functionality.
Section 37 of the LPC1778 user manual discusses the ISP commands and functionality.
A tool like Flash Magic sends commands to the bootloader to reprogram the chip incrementally. The particular algorithm will vary, but it probably looks something like:
- Transfer a sector's worth of data to the LPC1778's buffer in RAM.
- Erase the next flash sector to be reprogrammed.
- Copy the buffer from RAM to flash
- Compute the checksum of the newly written flash sector
- Compute the checksum of the data in RAM to verify
- Repeat until the entire firmware image has been written.
Accordingly, the amount of RAM available doesn't limit the bootloader's ability to reprogram the flash, though having more RAM available can speed up the process by reducing the amount of data transferred back and forth between the bootloader and the PC.