Flash Memory (Boot Loader) (Compact 7)
3/12/2014
The BLCOMMON library provides an infrastructure for downloading the run-time image into flash memory, although you may need to modify some of the functions that the BLCOMMON functions call to work with your hardware. The header file that defines the flash memory interface is Public\Common\OAK\Inc\blcommon.h. The flash memory functions are typically located in Platform\<BSP Name>\Src\Bootloader\Eboot and linked into oal_flash.lib or directly into the boot loader executable (such as eboot.exe).
The following table lists the flash memory functions. For more information, see Boot Loader Flash Functions.
Purpose | Function name | Typical file name |
---|---|---|
Determines if an address lies in flash memory |
flash.c |
|
Remaps a flash memory address to a RAM address |
flash.c |
|
Erases flash memory |
OEMStartEraseFlash, OEMContinueEraseFlash, OEMFinishEraseFlash |
flash.c |
Writes to flash memory |
flash.c |
The following figure shows an example of the function call sequence when you download a run-time image into flash memory.
Below is a description of the process of downloading the OS image into flash memory, as shown in the figure.
- The BootloaderMain function calls the DownloadImage function, which in turn calls the DownloadBin function when the run-time image is in .bin format (or a similar function if the image is in .nb0 format). All three functions are implemented by the BLCOMMON library and therefore you do not need to modify them. The DownloadBin function calls several BSP functions, as described below.
- The DownloadBin function calls the OEMReadData function to read the run-time image’s starting address and length. The OEMReadData function typically calls a hardware-specific function to perform the read operation.
- The DownloadBin function then calls the OEMIsFlashAddr function to check if the run-time image will be downloaded into flash memory.
- If the image is destined for flash memory, the DownloadBin function then calls the OEMStartErase function so that the flash memory will be erased as the image is downloaded. The OEMStartErase function typically calls a hardware-specific function to start erasing the flash memory.
- The DownloadBin function then calls OEMReadData function to copy the records of the BIN image to flash memory.
- As it reads the data of the .bin image, the DownloadBin function calls the OEMMapMemAddr function to map the flash memory addresses to a temporary location in RAM, which allows the run-time image to be downloaded while the slower flash memory erase operation takes place.
- The DownloadBin function calls OEMContinueEraseFlash to continue erasing the flash memory as it copies the data records of the .bin image into it.
- After all of the data records have been copied into flash memory, the DownloadBin function calls the OEMFinishEraseFlash function, which typically calls a hardware-specific function to finish the flash memory erasure.