Problem with write/erase operation on AM29lv160DB external FLASH (coldfire 5235)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem with write/erase operation on AM29lv160DB external FLASH (coldfire 5235)

3,481 次查看
AgC
Contributor I
hello,

In my project (based on MCF5235), I must store datas in my flash(AM29LV160DB).

My problem is that I can't access at my Flash with a write command. Every time I begin my write sequence "*((uint16 *)(EXT_FLASH_ADDRESS + 0x0555)) = 0x00AA;" an exception occurs ("Attempted write to write-protected space")

I saw in this forum that the Coldfire doesn't support a write or erase in Flash operation when the code runs in it, so, as I saw on many topics, I "copy" my write code in my RAM.

Is there a problem with protected sector?
Does someone see what is wrong?

Thanks a lot for your implication,
Regards
AgC

Here is my code:

My link file:

Code:
MEMORY {ext_nvsram (RWX) : ORIGIN = 0x10000000, LENGTH = 0x00080000vector_ram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x500sram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00010000user (RWX) : ORIGIN = 0x20000500, LENGTH = 0x0000FB00ext_sram (RWX) : ORIGIN = 0x30000000, LENGTH = 0x00080000ipsbar (RWX) : ORIGIN = 0x40000000, LENGTH = 0x01ext_flash (RWX) : ORIGIN = 0xFFE00000, LENGTH = 0x00200000}SECTIONS {.vector_ram : {} > vector_ram.ipsbar : {} > ipsbar.sram : {} > sram.ext_sram : {} > ext_sram.ext_nvsram : {} > ext_nvsram.ext_flash : {} > ext_flash.user : {} > user.boot_flash :{obj-CPU_A/vectors.o (.text)*(.text)*(.rodata)*(.rodata.str1.1)} > ext_flashMy code file:enum TFlashStatus Flash_write_word(ULWORD address, UWORD data){*((uint16 *)(EXT_FLASH_ADDRESS + 0x0555)) = 0x00AA;*((uint16 *)(EXT_FLASH_ADDRESS + 0x02AA)) = 0x0055;*((uint16 *)(EXT_FLASH_ADDRESS + 0x0555)) = 0x00A0;*((uint16 *)(EXT_FLASH_ADDRESS + address)) = data;return FLASH_SUCCESS; }void runEnd(void){} // leave this immediately after runInRamenum TFlashStatus Flash_Set_Word(ULWORD address, UWORD data){enum TFlashStatus status;char buf[200];enum TFlashStatus (*ramCopy)(ULWORD, UWORD) = (enum TFlashStatus(*)(ULWORD,UWORD))buf;/* Ecriture du mot de données */memcpy(buf, (void*)Flash_write_word, (char*)runEnd - (char*)Flash_write_word);status = ramCopy(address, data);return status;}

 
(Alban formatted code)

Message Edited by Alban on 2006-09-14 10:55 AM

标签 (1)
0 项奖励
回复
3 回复数

1,076 次查看
stzari
Contributor III
Hi AgC

did you check whether the Chip Select is maybe configured for Read Only accesses (WP bit in CSMRx register) ?

HTH
Stamatis
0 项奖励
回复

1,076 次查看
francois_boucha
Contributor III
I'm a bit in the same waters.   Right now I can read the Flash (Am29LV160D) correctly but it seems the external Flash (I want to write to it) is write protected by the ship itself, not by the debbuger memory file.

Here my memory map:

//         Memory Map:
//         ----------------------------------------------------------------------
range      0x00000000 0x0007FFFF 4 Read         // 512 Kbytes Internal Flash
reserved   0x00080000 0x1FFFFFFF
range      0x20000000 0x2000FFFF 4 ReadWrite    // 64 Kbytes Internal SRAM
reserved   0x20010000 0x2FFFFFFF
reserved   0x30000000 0x3FFFFFFF                // External SRAM (not fitted)
//         $IPSBAR_BASE         $IPSBAR_BASE + 0x1FFFFF // Memory Mapped Registers
reserved   $IPSBAR_BASE + 0x200000     0xEFFFFFFF
range      0xF0000000 0xF0FFFFFF 4 ReadWrite    // 16 Mbyte SDRAM
reserved   0xF1000000 0xFFDFFFFF
range      0xFFE00000 0xFFEFFFFF 4 read               // debugger/monitor firmware
range       0xFFF00000 0xFFFFFFFF 2 ReadWrite    //

I want to write at 0xFFF00000  to 0xFFFFFFFF.    The Flash memory organisation is 16 bits x 1M

My ship select initialization routine :

    /*
     * ChipSelect 0 - External Flash
     */
    MCF_CS0_CSAR = MCF_CS_CSAR_BA(0xffe00000);
    MCF_CS0_CSCR = (0
        | MCF_CS_CSCR_WS(6)
        | MCF_CS_CSCR_AA
        | MCF_CS_CSCR_PS_16);
    MCF_CS0_CSMR = MCF_CS_CSMR_BAM_2M | MCF_CS_CSMR_V;


Any clues?

Francois
0 项奖励
回复

1,076 次查看
J2MEJediMaster
Specialist I
Try looking at the following Freescale FAQ on Flash programming. It provides some general rules about programming Flash memory. More to the point, further down in the FAQ is a list of application notes on flash programming. The app notes were chosen to cover a wide range of Freescale processors, and in most cases, provide example code. There's even one that coveres using the Codewarrior debugger to bit-bang external memory to confirm that the processor is properly interfaced to the processor. HTH.

---Tom
0 项奖励
回复