Custom Linker Section, recognized in assembly

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

Custom Linker Section, recognized in assembly

Jump to solution
961 Views
Kerrie
Contributor I

We have a project using a mix of C and Assembly on the Coldfire V1, QE256 part.

 

Using the App Note AN4329, I was able to create a custome linker section in the lower half of the memory space

 

  .BooksRange :
  {
    __BOOKS_BASE = .;     #start address of the new books area
    .=ALIGN(512);
    *(.BooksRange)        #actual data matching pragma directives
    __BOOKS_END = .;
    .=ALIGN(512);
  } >> code_00020410

 

This isn't causing any errors that I can tell :smileyhappy:

 

but now I am stumped as how to get code into the BooksRange area, I tried the following but am getting

undefine macro or opcode when I insert this snippit into .asm file

 

    .BooksRange   month1: .byte 1,2,3,4,5
Labels (1)
0 Kudos
1 Solution
583 Views
CrasyCat
Specialist III

Hello

 

You need to place the section BootRange that you have created in one of the memory area inside of the linker command file.

 

I assume you gave to change the definition of the section .BootRange as follows:

 

.BooksRange :  {     *(BooksRange)    . = ALIGN (0x4);} >> code_00020410 

 

 

Additionally why are you using a an org after the section command in the assembly file?

Not sure I get the point here.

 

At which address do you expect the section BootRange to be allocated?

 

CrasyCat

View solution in original post

0 Kudos
3 Replies
583 Views
CrasyCat
Specialist III

Hello

 

As section .BooksRange  is not a predefined section you need to define it using .section directive.

 

Please look at the ColdFire_Assembler_MCU_Eclipse.pdf manual and check syntax of the .section directive.

 

CrasyCat

0 Kudos
583 Views
Kerrie
Contributor I

Thanks Crasy, you have definitly pointed me on the right path.  I no longer have compiler errors.  But I am getting this warning " BooksRange (BooksRange) is refrenced but not written check your linker command file and sure enough when I look into memory after program nothing is store in that memory location.

 

Here is the complete linker file

# Sample Linker Command File for CodeWarrior for ColdFire MCF51JE256# Memory rangesMEMORY {   code        (RX)  : ORIGIN = 0x00000414, LENGTH = 0x0001FFE8   code_00020410 (RX) : ORIGIN = 0x00020410, LENGTH = 0x0001FBF0   userram     (RWX) : ORIGIN = 0x00800000, LENGTH = 0x00008000}SECTIONS {# Heap and Stack sizes definition  ___heap_size     = 0x0400;  ___stack_size    = 0x0400;# MCF51JE256 Derivative Memory map definitions from linker command files:# ___RAM_ADDRESS, ___RAM_SIZE, ___FLASH_ADDRESS, ___FLASH_SIZE linker# symbols must be defined in the linker command file.# 32 Kbytes Internal SRAM   ___RAM_ADDRESS = 0x00800000;   ___RAM_SIZE    = 0x00008000;   # 256 KByte Internal Flash Memory   ___FLASH_ADDRESS  = 0x00000000;   ___FLASH_SIZE     = 0x00040000;  .userram        : {} > userram  .code      : {} > code  .code1     : {} > code_00020410   .text :  {    *(.text)    . = ALIGN (0x4);    *(.rodata)    . = ALIGN (0x4);    ___ROM_AT = .;    ___DATA_ROM = .; } >> code   .BooksRange :  {     *(.text)    . = ALIGN (0x4);} >> code_00020410    .usb_bdt :  {    .=ALIGN(512);    __BDT_BASE = .;    *(.usb_bdt)     __BDT_END = .;   } >> userram  .data : AT(___ROM_AT)  {    ___DATA_RAM = .;    . = ALIGN(0x4);    *(.exception)    . = ALIGN(0x4);    __exception_table_start__ = .;    EXCEPTION    __exception_table_end__ = .;    ___sinit__ = .;      STATICINIT    __START_DATA = .;    *(.data)    . = ALIGN (0x4);    __END_DATA = .;    __START_SDATA = .;    *(.sdata)    . = ALIGN (0x4);    __END_SDATA = .;    ___DATA_END = .;    __SDA_BASE = .;    . = ALIGN (0x4);  } >> userram  .bss :  {    ___BSS_START = .;    __START_SBSS = .;    *(.sbss)    . = ALIGN (0x4);    *(SCOMMON)    __END_SBSS = .;    __START_BSS = .;    *(.bss)    . = ALIGN (0x4);    *(COMMON)    __END_BSS = .;    ___BSS_END = .;    . = ALIGN(0x4);  } >> userram  .custom :  {    ___HEAP_START       = .;    ___heap_addr        = ___HEAP_START;    ___HEAP_END         = ___HEAP_START + ___heap_size;    ___SP_END             = ___HEAP_END;    ___SP_INIT          = ___SP_END + ___stack_size;    ___mem_limit        = ___HEAP_END;    ___stack_safety     = 16;    . = ALIGN (0x4);  } >> userram  __SP_INIT             = ___SP_INIT;  ___SP_AFTER_RESET     = __SP_INIT;  _romp_at = ___ROM_AT + SIZEOF(.data);  .romp : AT(_romp_at)  {    __S_romp = _romp_at;    WRITEW(___ROM_AT);    WRITEW(ADDR(.data));    WRITEW(SIZEOF(.data));    WRITEW(0);    WRITEW(0);    WRITEW(0);  }}

 

 

and here is the snippit of assembly code

 .section  BooksRange, text .org 0x0020500 testingloop: move.l #$0FF,D2  ;get current byte move.b #$03,D1 add.l D2,D1  ;D1 = D1+D2  subi.l #$01,D2  ;decrement the counter of length bne testingloop rts

 

 

0 Kudos
584 Views
CrasyCat
Specialist III

Hello

 

You need to place the section BootRange that you have created in one of the memory area inside of the linker command file.

 

I assume you gave to change the definition of the section .BootRange as follows:

 

.BooksRange :  {     *(BooksRange)    . = ALIGN (0x4);} >> code_00020410 

 

 

Additionally why are you using a an org after the section command in the assembly file?

Not sure I get the point here.

 

At which address do you expect the section BootRange to be allocated?

 

CrasyCat

0 Kudos