This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LM3S2B93 Flash Download Problem

I am trying to program the Luminary Micro LM3S2B93 in a newly designed board. I am using Keil IDE & Keil ULINK2 JTAG for flash downloading. The erase command works fine ("Full Chip Erase Done" message is displayed). But when I try to program the Flash, it fails with the following message popping up - "ULINK - Cortex-M Error: Flash Timeout. Reset the Target and try again"... I tried to play around with the setting in the utilities section, but the problem remains...
Rgds,
Sudarshan

Parents
  • This is a Keil issue, not a device problem.

    The ULINK flash programming algorithm for the newer Stellaris devices was never properly updated by Keil. It does not take advantage of the write buffer, which speeds up the flash programming. The legacy method of programming the flash (one word at a time) like the earlier class devices is much slower than on the previous devices since it is a new flash, in a new technology (ie.. why the write buffer was added). This is why you are getting the flash timeout error. There is also a bit that needs to be cleared in order to properly program devices that are completely erased, otherwise it will fail to verify properly. This has been reported to Keil.

    There is a simple way for the user to fix the flash algorithm such that it works in the legacy mode. Keil will have to provide the proper flash algorithms that take full advantage of the write buffer, but for now this should get you going.

    1) Open up the flash programming algorithm project file for the Stellaris devices with 256 KB of Flash in the path: C:\Keil\ARM\Flash\LM3S_256\LM3S_256.Uv2

    2) In FlashPrg.c, modify Init () to look like the following (bold type has been added):

    /*
    * Initialize Flash Programming Functions
    * Parameter: adr: Device Base Address
    * clk: Clock Frequency (Hz)
    * fnc: Function Code (1 - Erase, 2 - Program, 3 - Verify)
    * Return Value: 0 - OK, 1 - Failed
    */

    int Init (unsigned long adr, unsigned long clk, unsigned long fnc) {

    // Set the Number of Clocks per microsecond for the Flash Controller
    // Approximate division by 1000000 (no Library Code)
    HWREG(FLASH_USECRL) = ((1074*(clk >> 10)) >> 20) - 1; // clk / 1000000 - 1;

    // Clear the BA bit in RMCTL by writing a 1 to this location.
    HWREG(0x400FE0F0) = 0x00000001;

    return (0);
    }

    3) In FlashDev.c, change the Program Page Timeout from 200ms to 500ms. So it should look something like (bold type modified):

    struct FlashDevice const FlashDevice = {
    FLASH_DRV_VERS, // Driver Version, do not modify!
    "LM3Sxxx 256kB Flash", // Device Name
    ONCHIP, // Device Type
    0x00000000, // Device Start Address
    0x00040000, // Device Size in Bytes (256kB)
    1024, // Programming Page Size
    0, // Reserved, must be 0
    0xFF, // Initial Content of Erased Memory
    500, // Program Page Timeout 500 mSec
    500, // Erase Sector Timeout 500 mSec
    // Specify Size and Address of Sectors
    0x0400, 0x000000, // Sector Size 1kB (256 Sectors)
    SECTOR_END
    };

    4) Recompile/link the project. This will automatically copy the output LM3S_256.FLM to the correct location.

    5) Repeat this for the other flash programming algorithms for Stellaris ( C:\Keil\ARM\Flash\LM3S_nnn\LM3S_nnn.Uv2)

    For all of our customers that have had the Flash Timeout error using the Keil ULINK2 and a Tempest class device (LM3S9B92, LM3S9B95, LM3S9B96, etc) this has resolved the issue.

    Regards,
    Dan Nakoneczny
    Texas Instruments Inc.

Reply
  • This is a Keil issue, not a device problem.

    The ULINK flash programming algorithm for the newer Stellaris devices was never properly updated by Keil. It does not take advantage of the write buffer, which speeds up the flash programming. The legacy method of programming the flash (one word at a time) like the earlier class devices is much slower than on the previous devices since it is a new flash, in a new technology (ie.. why the write buffer was added). This is why you are getting the flash timeout error. There is also a bit that needs to be cleared in order to properly program devices that are completely erased, otherwise it will fail to verify properly. This has been reported to Keil.

    There is a simple way for the user to fix the flash algorithm such that it works in the legacy mode. Keil will have to provide the proper flash algorithms that take full advantage of the write buffer, but for now this should get you going.

    1) Open up the flash programming algorithm project file for the Stellaris devices with 256 KB of Flash in the path: C:\Keil\ARM\Flash\LM3S_256\LM3S_256.Uv2

    2) In FlashPrg.c, modify Init () to look like the following (bold type has been added):

    /*
    * Initialize Flash Programming Functions
    * Parameter: adr: Device Base Address
    * clk: Clock Frequency (Hz)
    * fnc: Function Code (1 - Erase, 2 - Program, 3 - Verify)
    * Return Value: 0 - OK, 1 - Failed
    */

    int Init (unsigned long adr, unsigned long clk, unsigned long fnc) {

    // Set the Number of Clocks per microsecond for the Flash Controller
    // Approximate division by 1000000 (no Library Code)
    HWREG(FLASH_USECRL) = ((1074*(clk >> 10)) >> 20) - 1; // clk / 1000000 - 1;

    // Clear the BA bit in RMCTL by writing a 1 to this location.
    HWREG(0x400FE0F0) = 0x00000001;

    return (0);
    }

    3) In FlashDev.c, change the Program Page Timeout from 200ms to 500ms. So it should look something like (bold type modified):

    struct FlashDevice const FlashDevice = {
    FLASH_DRV_VERS, // Driver Version, do not modify!
    "LM3Sxxx 256kB Flash", // Device Name
    ONCHIP, // Device Type
    0x00000000, // Device Start Address
    0x00040000, // Device Size in Bytes (256kB)
    1024, // Programming Page Size
    0, // Reserved, must be 0
    0xFF, // Initial Content of Erased Memory
    500, // Program Page Timeout 500 mSec
    500, // Erase Sector Timeout 500 mSec
    // Specify Size and Address of Sectors
    0x0400, 0x000000, // Sector Size 1kB (256 Sectors)
    SECTOR_END
    };

    4) Recompile/link the project. This will automatically copy the output LM3S_256.FLM to the correct location.

    5) Repeat this for the other flash programming algorithms for Stellaris ( C:\Keil\ARM\Flash\LM3S_nnn\LM3S_nnn.Uv2)

    For all of our customers that have had the Flash Timeout error using the Keil ULINK2 and a Tempest class device (LM3S9B92, LM3S9B95, LM3S9B96, etc) this has resolved the issue.

    Regards,
    Dan Nakoneczny
    Texas Instruments Inc.

Children