creating Flash programming algorithm

本文介绍如何使用µVision为不受支持的设备创建闪存编程算法。通过创建新的µVision项目并配置特定的编译器及链接器设置,可以为特定的闪存ROM设备定制编程算法。文中详细说明了创建过程中的关键步骤,并提供了测试算法的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.keil.com/support/man/docs/ulink2/ulink2_su_newalgorithms.htm


Creating New Algorithms

µVision allows creating Flash programming algorithms forunsupported 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 programmingalgorithm:

  1. Create a sub-folder in \KEIL\ARM\FLASH.
  2. Copy the content from \KEIL\ARM\FLASH\_Template to this new folder.
  3. Rename the project file NewDevice.uvproj to represent the new Flash ROM device name, for example 29F400.uvproj.
  4. 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.

  5. 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.
  6. Adapt the programming algorithms in the file FlashPrg.c (see below).
  7. Adapt the device parameters in the file FlashDev.c (see below).
  8. 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 FlashAlgorithm Functions Init,UnInit, EraseSector, and ProgramPage.Optionally, and in dependency of the device features, or to speed-upexecution, the functions EraseChip, BlankCheck, andVerify can be implemented.

The file provides a #define STACK_SIZE n. Defaultvalue for n is 64. Refer ARM:setting flashloader stack size with STACK_SIZE define not workingfor details.

Note

  • Interrupts can be used, but we do not recommend using them.
  • Debugging information can be output, but will not be picked up by the debugger. For example: LEDs or UARTs can be used from the code to provide debug information (needs to be interpreted by the user).

FlashDev.c

The file FlashDev.c contains parameterdefinitions for:

  1. 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.
  2. 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 aproject that shows how to test a new Flash Programming Algorithm onbehalf of an STM32 device.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值