Creating New Algorithms
µVision allows creating Flash programming algorithms for unsupported devices. The algorithm source code is implemented as a µVision project with special compiler and linker settings.
Follow these steps to create a new Flash programming algorithm:
Create a sub-folder in \KEIL\ARM\FLASH.
Copy the content from \KEIL\ARM\FLASH\_Template to this new folder.
Rename the project file NewDevice.uvproj to represent the new Flash ROM device name, for example 29F400.uvproj.
Open the project with µVision. From the toolbar, use the drop-down Select Target to define the processor architecture:
Cortex-M fits for Cortex-M0, M1, M3, and M4 processor-based devices.
ARM7/ARM9 fits for ARM7 and ARM9 processor-based devices.
The configuration assumes a little-endian microcontroller. In case of a big-endian microcontroller, select the correct processor core with Project - Options for Target - Device.
Open the dialog Project - Options for Target - Output and change the content of the field Name of Executable to represent the device, for example 29F400.
Adapt the programming algorithms in the file FlashPrg.c (see below).
Adapt the device parameters in the file FlashDev.c (see below).
Use Project - Build Target to generate the new Flash programming algorithm. The output file, *.FLX - for ARM7/ARM9 devices, or *.FLM - for Cortex-M devices, is copied to the folder \KEIL\ARM\FLASH and is now available in the dialog Add Flash Programming Algorithm.
Note
Flash programming algorithms use Read-Only Position Independent and Read-Write Position Independent program code. These options are set in the dialogs Project - Options for Target - C/C++ and Project - Options for Target - Asm.
The dialog Project - Options for Target - Linker defines the linker scatter file Target.lin. The error L6305 is disabled with --diag_suppress L6305.
FlashPrg.c
The file FlashPrg.c contains the mandatory Flash Algorithm Functions Init, UnInit, EraseSector, and ProgramPage. Optionally, and in dependency of the device features, or to speed-up execution, the functions EraseChip, BlankCheck, and Verify can be implemented.
FlashDev.c
The file FlashDev.c contains parameter definitions for:
the mandatory Flash Programming Functions Init, UnInit, EraseSector, and ProgramPage. Depending on the device, the optional Flash Programming Functions EraseChip, BlankCheck, and Verify might need programming.
the FlashDevice structure.
struct FlashDevice const FlashDevice = {
FLASH_DRV_VERS, // Driver Version, do not modify!
"STM32Fxxx High-density Flash", // Device Name (512kB/384kB/256kB)
ONCHIP, // Device Type
0x08000000, // Device Start Address
0x00080000, // Device Size in Bytes (512kB)
1024, // Programming Page Size
0, // Reserved, must be 0
0xFF, // Initial Content of Erased Memory
100, // Program Page Timeout 100 mSec
500, // Erase Sector Timeout 500 mSec
// Specify Size and Address of Sectors
0x0800, 0x000000, // Sector Size 2kB (256 Sectors)
SECTOR_END
};
Testing Algorithms
The \KEIL\ARM\FLASH\_Template\Test\ folder contains a project that shows how to test a new Flash Programming Algorithm on behalf of an STM32 device. |