DBUG program hangs when erasing sector

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DBUG program hangs when erasing sector

1,310 Views
wmunlai
Contributor I
Hi,
i downloaded the Freescale DBUG source code (v4a.1a.1b) and got it compiled using GNU compiler.
I then ran the program on my MCF5235 evaluation board. Everything runs properly until I
tried to execute the command line "set client 192.168.1.2" which hangs the board. I did
some tracing and found that it hangs in
amd_flash_sector_erase(int n)
{
   volatile AMD_FLASH_CELL status;
   
   pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA);
   pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55);
   pFlash[0x555] = AMD_FLASH_CMD_DATA(0x80);
   pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA);
   pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55);
   pFlash[SADDR(n)] = AMD_FLASH_CMD_DATA(0x30); <-- hangs at this line
   
   do
 {
       status = pFlash[SADDR(n)];
  
 }while ((status & AMD_FLASH_CMD_DATA(0x80)) != AMD_FLASH_CMD_DATA(0x80));
       
   /*
    * Place device in read mode
    */
   pFlash[0] = AMD_FLASH_CMD_DATA(0xAA);
   pFlash[0] = AMD_FLASH_CMD_DATA(0x55);
   pFlash[0] = AMD_FLASH_CMD_DATA(0xF0);
 
}

My linker file is:
/* vim:set ts=4 sw=4 et syn=c: */
MEMORY
{
   flash  (RWX) : ORIGIN = 0xffe00000, LENGTH = 0x001FFFFF
   vector_rom         (RWX) : ORIGIN = 0xffe00000, LENGTH = 0x00004000
   
   sdram  (RWX) : ORIGIN = 0x00000000, LENGTH = 0x00FFFFFF
   sram  (RWX) : ORIGIN = 0x20000000, LENGTH = 0x0000FFFF 
   vector_ram (RWX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
   data_ram (RWX) : ORIGIN = 0x00000400, LENGTH = 0x0001FC00
   user_space (RWX) : ORIGIN = 0x00020000, LENGTH = 0x00FFC000
}
SECTIONS
{
   .sdram : { } > sdram
   .vector_ram : { } > vector_ram
   .data_ram : { } > data_ram
   .user_space : { } > user_space
   .sram : { } > sram
   .ext_sram : { } > ext_sram
   .ipsbar : { } > ipsbar
   .flash : { } > flash
   .ext_flash : { } > ext_flash
   .vector_rom : { } > vector_rom
   .dbug : { } > dbug
   .text :
   {
       __VECTORS_ROM = .;
       __VECTORS_ROM_START = ABSOLUTE(.);
  obj/m523xevb/gnu/cpu/coldfire/mcf5xxx/vectors.o(.text)
       __VECTORS_ROM_END = ABSOLUTE(.);
       __VECTORS_SIZE = __VECTORS_ROM_END - __VECTORS_ROM_START;
       /* Parameters stored in flash need to be at 0x4000 offset */
       . = ALIGN(0x4000);
       __PARAMS = .;
       __PARAMS_ROM_START = ABSOLUTE(.);
  obj/m523xevb/gnu/board/m523xevb/src/params.o(.rodata)
       . = ALIGN(0x4);
       __PARAMS_ROM_END = ABSOLUTE(.);
       __PARAMS_SIZE = __PARAMS_ROM_END - __PARAMS_ROM_START;
       /* Rest of the code starts at offset 0x6000 */
       . = ALIGN(0x6000);
  obj/m523xevb/gnu/board/m523xevb/src/uClinux_and_SBCTools/delay.o(.text)
       *(.rela.got)
       *(.text)
   } > flash = 0
   .rodata :
   {
       . = ALIGN(0x4);
       *(.rodata)
       *(.rodata.str1.1)
       __DATA_ROM = .;
   } > flash
   .data : AT( __DATA_ROM )
   {
       . = ALIGN(0x4);
       __DATA_RAM = .;
       *(.data)
       *(.code_relocation)
       *(.got.plt)
       *(.got)
       . = ALIGN(0x4);
       __CTOR_LIST__ = .;
       LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
       *(.ctors)
       LONG(0)
       __CTOR_END__ = .;
       __DTOR_LIST__ = .;
       LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
       *(.dtors)
       LONG(0)
       __DTOR_END__ = .;
       __DATA_END = .;
   } > data_ram
       
   .bss :
   {
       __BSS_START = .;
       *(.bss)
       *(COMMON)
       __BSS_END = .;
       __HEAP_START = .;
       . = . + 0x10000;
       __HEAP_END = .;
       
       __PARAMS_START = .;
       . = . + __PARAMS_SIZE;
       __PARAMS_END = .;
       
       __SP_END = .;
       . = . + 0xC00;
       ___SP_INIT = .;
   } > data_ram
}
__IPSBAR       = 0x40000000;
___IPSBAR               = __IPSBAR;
__VECTOR_RAM            = ADDR(.vector_ram);
__SDRAM                 = ADDR(.sdram);
__SDRAM_SIZE            = 0x00FFFFFF;
__FLASH                 = ADDR(.flash);
__FLASH_SIZE            = 0x00200000;
__DBUG_ADDRESS          = ADDR(.vector_rom);
__DBUG_CODE_SIZE        = 0x0003FC00;
__DBUG_SIZE             = 0x00040000;
__USER_SPACE            = ADDR(.user_space);
__USER_SPACE_SIZE       = 0x00FC0000;
/* Is this linked to run in ROM? */
___Running_in_ROM       = 0x1;
/* declariations added to satisfy M5208EVB_dBUG */
__SRAM    = ADDR(.sram);
__SRAM_SIZE  = 0xFFFF;
___SRAM    = __SRAM;
___SRAM_SIZE  = __SRAM_SIZE;
__EXT_SRAM   = 0x30000000;
__EXT_SRAM_SIZE     = (512 * 1024);
___EXT_SRAM   = __EXT_SRAM;
___EXT_SRAM_SIZE = __EXT_SRAM_SIZE;
 
   
Hope that I could get some advice. Thanks.
rgds,
Mun Lai
Labels (1)
0 Kudos
1 Reply

371 Views
wmunlai
Contributor I
Hi,
I have solved the problem. When your code runs in flash, you cannot erase any flash sectors, even if that sector is different from your code sector. Hence, I moved my flash-related functions to RAM.
0 Kudos