Keil Logo

Converting FlashPrg.c

ULINK Flash programming algorithms can be converted to be used by RL-FlashFS.

The following example describes the conversion for the Am29x800BT Flash device:

  1. Copy the file FlashPrg.c from the folder \Keil\ARM\Flash\AM29F160DB to a subfolder of \Keil\ARM\RL\FlashFS\Flash.
  2. Rename this file to FS_FlashPrg.c
  3. Change the include header file from:
    #include "..\FlashOS.H"        // FlashOS Structures
    to the RL-FlashFS definition header.
    #include <File_Config.h>
  4. Add the Flash driver control block definition:
    /* Embedded Flash Driver Interface functions */
    static BOOL Init        (U32 adr, U32 clk);
    static BOOL UnInit      (void);
    static BOOL ProgramPage (U32 adr, U32 sz, U8 *buf);
    static BOOL EraseSector (U32 adr);
    static BOOL EraseChip   (void);         /* Optional function if supported    */
    /* Embedded Flash Device Driver Control Block */
    EFS_DRV fl0_drv = {
      NULL,                                 /* =NULL, use FFS internal ReadData  */
  5. Rename the functions and replace the function headers:
    • Init()
      int Init (unsigned long adr, unsigned long clk, unsigned long fnc) {
      static BOOL Init (U32 adr, U32 clk)  {
    • UnInit()
      int UnInit (unsigned long fnc)  {
      static BOOL UnInit (void)  {
      The fnc parameter is not used by the Flash driver.
    • EraseChip()
      int EraseChip (void) {
      static BOOL EraseChip (void) {
    • EraseSector()
      int EraseSector (unsigned long adr) {
      static BOOL EraseSector (U32 adr) {
    • ProgramPage()
      int ProgramPage (unsigned long adr, unsigned long sz, unsigned char *buf) {
      static BOOL ProgramPage (U32 adr, U32 sz, U8 *buf) {
  6. Modify the return values for all functions to: __TRUE on success and __FALSE on failure.
  7. Update the function ProgramPage() function to allow unaligned buffer access. Add the attribute __packed if buf is not accessing a byte..
    /* 'buf' might be unaligned. */
    M16(adr) = *(__packed U16 *)buf;
  8. Keep local functions that are needed, for example: Polling.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.