Changing the Flash origin address from 0x00000000 to 0x00001000.. What I am I doing wrong here!!

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the Flash origin address from 0x00000000 to 0x00001000.. What I am I doing wrong here!!

1,960 Views
JimMcP
Contributor I
When I change the origin of the flash section from 0x00000000
to 0x00001000. I get an Exception vector name : Address Error.

It is like the  vector table is not starting at 0x00001000. But it
is I look at the Map file.

There is something I am missing here...???? If I set the origin to
0x00000000  in the flash section of the LCF file it works. What am
I doing wrong here??


//////////////////////// Mcf52223.s

/********************************************************************
 *
 * This is the main entry point upon hard reset.  The memory map is
 * setup based on linker file definitions, then the higher level
 * system initialization routine is called.  Finally, we jump to the
 * "main" process.
 */
asm_startmeup:
_asm_startmeup:

  move.w    #0x2700, sr

  /* Save off reset values of D0 and D1 */

//// Get the Exception vector name: Address error here !!!!!!!
  move.l  d0,d6
  move.l  d1,d7
   
  
  /* Initialize RAMBAR1: locate SRAM and validate it */
  move.l  #__SRAM,d0
  add.l   #0x21,d0   
  movec   d0,RAMBAR1

  /* Locate Stack Pointer */
  move.l  #__SP_INIT,sp

  /* Initialize IPSBAR */
  move.l  #__IPSBAR,d0
  add.l   #0x1,d0
  move.l  d0,0x40000000
  
  /* Initialize FLASHBAR */
  move.l  #__FLASH,d0
  cmp.l   #0x00000000,d0
  bne     change_flashbar
  add.l   #0x21,d0
  movec   d0,RAMBAR0

_continue_startup:

  /* Locate Stack Pointer */
  move.l  #__SP_INIT,sp

  /* Initialize the system */
  ///jsr     board_sysinit

  jsr Start_It_Up
  
  jsr board_sysinit
  

  /* Save off intial D0 and D1 to RAM */
  move.l  d6,d0_reset
  move.l  d7,d1_reset
  
 /* Jump to the main process */
  jsr     main


// LCF File for MCF52223

#/*
# * File:       flash.lcf
# * Purpose:    Linker file for the MCF52223
# *
# * Notes:      Project running in internal Flash
# *
# */

// Flash starting out on at address 0x00000000. THIS WORKS..
#MEMORY
#{
#     flash (RX) : ORIGIN = 0x00000000,  LENGTH = 0x0003FF80
#     
#     params  (RX) : ORIGIN = 0x0003FF80,  LENGTH = 0x00000080 //128 bytes
#   
#     vectorram (RW) : ORIGIN = 0x20000000,  LENGTH = 0x00000400
#     ram     (RW) : ORIGIN = 0x20000400,  LENGTH = 0x00007C00
#}
//////////////////////////////////



// Flash starting out on at address 0x00001000. Problems here...
// vector table starts at 0x00001000
MEMORY
{
   flash (RX) : ORIGIN = 0x00001000,  LENGTH = 0x0003EF80
   
   params  (RX) : ORIGIN = 0x0003FF80,  LENGTH = 0x00000080 //128 bytes
  
   vectorram (RW) : ORIGIN = 0x20000000,  LENGTH = 0x00000400
   ram     (RW) : ORIGIN = 0x20000400,  LENGTH = 0x00007C00
}


SECTIONS
{
  ___IPSBAR           = 0x40000000;

  ___SRAM             = 0x20000000;
  ___SRAM_SIZE        = (32 * 1024);

  ___FLASH            = ADDR(flash);
    ___FLASH_SIZE       = (255 * 1024) + (7*128);

  ___RWFLASH            = ADDR(params);
  ___RWFLASH_SIZE       = (1 * 128); //(1 * 256);

  ___VECTOR_RAM       = ___SRAM;
  
  
 
 .flash :
  {
     vectors.s (.text)
     *(.text)
      *(.rodata)                    #The .rodata section contains any read-only data.
       .              = ALIGN(0x10);
      ___DATA_ROM     = .;
  } > flash

  .params :
  {   
  } > params
 
  # The .bss section contains data that's modifiable by your code, but not initialised,
  # or initialised to zero.

  #.data_bss : AT(___DATA_ROM)
  .ram : AT(___DATA_ROM)
  {

     ___DATA_RAM     = .;

      #******************
      mcfserial.c (.relocate_code)
      mcfserial.c (.relocate_const)
      mcfserial.c (.relocate_data)
      cfm_flash.c (.relocate_code)
      cfm_flash.c (.relocate_const)
      cfm_flash.c (.relocate_data)
      #******************
      *(.sdata)              # The .data section contains data that's modifiable by your code
      *(.data)
      
      
      ___DATA_END     = .;
      ___BSS_START    = .;
      *(.sbss)
      *(SCOMMON)
      *(.bss)
      *(COMMON)
      ___BSS_END      = .;
      .               = ALIGN(0x10);
      ___HEAP_START   = .;
      ___HEAP_END     = .;
      
      ___PARAMS_START = .;
      .                = . + ___RWFLASH_SIZE;
      ___PARAMS_END   = .;
      
      ___SP_END       = .;
     ___SP_INIT      = .;
  

  } > ram
}

// ////////////////////////////////////vector.s

/*
 * File:    vectors.s
 * Purpose: ColdFire Interrupt Vector Table
 * Note:    Applications can change the interrupt routine
 *          for each vector at runtime using the mcf5xxx_set_vector()
 *          routine.
 */

#ifdef  _UNDERSCORE_
#define __SP_INIT               ___SP_INIT
#define asm_startmeup           _asm_startmeup
#define asm_exception_handler   _asm_exception_handler
#define __PC_INIT               ___PC_INIT
#endif

  .global VECTOR_TABLE
  .global _VECTOR_TABLE
   .global start
  .global _start

  .extern __SP_INIT
  .extern ___PC_INIT
  .extern asm_startmeup
  .extern asm_exception_handler
  .text

/********************************************************************
 *
 * Exception Vector Table
 */
VECTOR_TABLE:
_VECTOR_TABLE:
INITSP:     .long   __SP_INIT               /* Initial SP           */
INITPC:     .long   asm_startmeup          /* Initial PC           */
vector002:  .long   asm_exception_handler   /* Access Error         */
vector003:  .long   asm_exception_handler   /* Address Error        */
vector004:  .long   asm_exception_handler   /* Illegal Instruction  */
vector005:  .long   asm_exception_handler   /* Reserved             */
vector006:  .long   asm_exception_handler   /* Reserved             */
vector007:  .long   asm_exception_handler   /* Reserved             */
vector008:  .long   asm_exception_handler   /* Privilege Violation  */
vector009:  .long   asm_exception_handler   /* Trace                */
vector010:  .long   asm_exception_handler   /* Unimplemented A-Line */
vector011:  .long   asm_exception_handler   /* Unimplemented F-Line */
vector012:  .long   asm_exception_handler   /* Debug Interrupt      */
vector013:  .long   asm_exception_handler   /* Reserved             */
vector014:  .long   asm_exception_handler   /* Format Error         */
vector015:  .long   asm_exception_handler   /* Unitialized Int.     */
vector016:  .long   asm_exception_handler   /* Reserved             */
vector017:  .long   asm_exception_handler   /* Reserved             */
vector018:  .long   asm_exception_handler   /* Reserved             */
vector019:  .long   asm_exception_handler   /* Reserved             */
vector020:  .long   asm_exception_handler   /* Reserved             */
vector021:  .long   asm_exception_handler   /* Reserved             */
vector022:  .long   asm_exception_handler   /* Reserved             */
vector023:  .long   asm_exception_handler   /* Reserved             */
vector024:  .long   asm_exception_handler   /* Spurious Interrupt   */
vector025:  .long   asm_exception_handler   /* Autovector Level 1   */
vector026:  .long   asm_exception_handler   /* Autovector Level 2   */
vector027:  .long   asm_exception_handler   /* Autovector Level 3   */
vector028:  .long   asm_exception_handler   /* Autovector Level 4   */
vector029:  .long   asm_exception_handler   /* Autovector Level 5   */
vector030:  .long   asm_exception_handler   /* Autovector Level 6   */
vector031:  .long   asm_exception_handler   /* Autovector Level 7   */
vector032:  .long   asm_exception_handler   /* TRAP #0              */
vector033:  .long   asm_exception_handler   /* TRAP #1              */
vector034:  .long   asm_exception_handler   /* TRAP #2              */
vector035:  .long   asm_exception_handler   /* TRAP #3              */
vector036:  .long   asm_exception_handler   /* TRAP #4              */
vector037:  .long   asm_exception_handler   /* TRAP #5              */
vector038:  .long   asm_exception_handler   /* TRAP #6              */
vector039:  .long   asm_exception_handler   /* TRAP #7              */
vector040:  .long   asm_exception_handler   /* TRAP #8              */
vector041:  .long   asm_exception_handler   /* TRAP #9              */
vector042:  .long   asm_exception_handler   /* TRAP #10             */
vector043:  .long   asm_exception_handler   /* TRAP #11             */
vector044:  .long   asm_exception_handler   /* TRAP #12             */
vector045:  .long   asm_exception_handler   /* TRAP #13             */
vector046:  .long   asm_exception_handler   /* TRAP #14             */
vector047:  .long   asm_exception_handler   /* TRAP #15             */
vector048:  .long   asm_exception_handler   /* Reserved             */
vector049:  .long   asm_exception_handler   /* Reserved             */
vector050:  .long   asm_exception_handler   /* Reserved             */
vector051:  .long   asm_exception_handler   /* Reserved             */
vector052:  .long   asm_exception_handler   /* Reserved             */
vector053:  .long   asm_exception_handler   /* Reserved             */
vector054:  .long   asm_exception_handler   /* Reserved             */
vector055:  .long   asm_exception_handler   /* Reserved             */
vector056:  .long   asm_exception_handler   /* Reserved             */
vector057:  .long   asm_exception_handler   /* Reserved             */
vector058:  .long   asm_exception_handler   /* Reserved             */
vector059:  .long   asm_exception_handler   /* Reserved             */
vector060:  .long   asm_exception_handler   /* Reserved             */
vector061:  .long   asm_exception_handler   /* Reserved             */
vector062:  .long   asm_exception_handler   /* Reserved             */
vector063:  .long   asm_exception_handler   /* Reserved             */
vector064:  .long   asm_exception_handler
vector065:  .long   asm_exception_handler

..................
.................
vector253:  .long   asm_exception_handler
vector254:  .long   asm_exception_handler
vector255:  .long   asm_exception_handler

/*
 * CFM Flash Configuration Field
 */
KEY_UPPER:  .long   0x00000000
KEY_LOWER:  .long   0x00000000
CFMPROT:    .long   0x00000000
CFMSACC:    .long   0x00000000
CFMDACC:    .long   0x00000000
CFMSEC:     .long   0x00000000

/********************************************************************/

start:
_start:
  move.w  #0x2700,sr
  jmp     _asm_startmeup

  .end

//////////////////////////////////////

Labels (1)
0 Kudos
3 Replies

241 Views
Napoletano
Contributor I
By moving the Vector table, you are also moving the Flash Controller iniatialisation:
KEY_UPPER:  .long   0x00000000
KEY_LOWER:  .long   0x00000000
CFMPROT:    .long   0x00000000
CFMSACC:    .long   0x00000000
CFMDACC:    .long   0x00000000
CFMSEC:     .long   0x00000000

Have a look at Table 15-1. CFM Configuration Field in the prozessor manual.
 
I guess that you now have the CFMDACC Register set to 0xFFFFFFFF this means data access only,  this is why you get an exception on the first adress fetch in your code.

Regards Daniel


0 Kudos

241 Views
JimMcP
Contributor I
Yes, I already figured that out.

To fix it :

// LCF file  added under SECTIONS

   ___PC_INIT            = ADDR(vectorflash) + 0x418;

// In the vector.s file

#define __PC_INIT               ___PC_INIT
........
   .extern __PC_INIT
.........


VECTOR_TABLE:
_VECTOR_TABLE:
INITSP:     .long   __SP_INIT               /* Initial SP           */
INITPC:     .long   __PC_INIT                    /* Change here*/
.........
////////////////////////////////////////////////////////////////////////////////////////////

I appreciate your reply....



0 Kudos

241 Views
SKumar
Contributor I
Hi,
 
         Try with this, I am not sure it will work...        
        My First impression is You are doing Wrong calculation for params.It should be ( ORIGIN + LEN )
 
 
         Changes are indicated by ===>>
 
//////////////////////// Mcf52223.s

/********************************************************************
 *
 * This is the main entry point upon hard reset.  The memory map is
 * setup based on linker file definitions, then the higher level
 * system initialization routine is called.  Finally, we jump to the
 * "main" process.
 */
asm_startmeup:
_asm_startmeup:

  move.w    #0x2700, sr

  /* Save off reset values of D0 and D1 */

//// Get the Exception vector name: Address error here !!!!!!!
  move.l  d0,d6
  move.l  d1,d7
   
  
  /* Initialize RAMBAR1: locate SRAM and validate it */
  move.l  #__SRAM,d0
  add.l   #0x21,d0   
  movec   d0,RAMBAR1

  /* Locate Stack Pointer */
  move.l  #__SP_INIT,sp

  /* Initialize IPSBAR */
  move.l  #__IPSBAR,d0
  add.l   #0x1,d0
  move.l  d0,0x40000000
  
  /* Initialize FLASHBAR */
  move.l  #__FLASH,d0
===>>  //cmp.l   #0x00000000,d0  
  cmp.l   #0x00001000,d0

  bne     change_flashbar
  add.l   #0x21,d0
  movec   d0,RAMBAR0

_continue_startup:

  /* Locate Stack Pointer */
  move.l  #__SP_INIT,sp

  /* Initialize the system */
  ///jsr     board_sysinit

  jsr Start_It_Up
  
  jsr board_sysinit
  

  /* Save off intial D0 and D1 to RAM */
  move.l  d6,d0_reset
  move.l  d7,d1_reset
  
 /* Jump to the main process */
  jsr     main
 
 

// Flash starting out on at address 0x00001000. Problems here...
// vector table starts at 0x00001000
MEMORY
{
   flash (RX) : ORIGIN = 0x00001000,  LENGTH = 0x0003EF80
   
===>>   //params  (RX) : ORIGIN = 0x0003FF80,  LENGTH = 0x00000080 //128 bytes 
  params (RX) : ORIGIN = 0x00040F80  /*( 1000 + 3EF80 )*/  LENGTH = 0x00000080
  
  
   vectorram (RW) : ORIGIN = 0x20000000,  LENGTH = 0x00000400
   ram     (RW) : ORIGIN = 0x20000400,  LENGTH = 0x00007C00
}
 
 
Regards,
Kumar
0 Kudos