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

How to propagate a value from C to a SPACE directive with armasm

Hi all,

I would like to ask help to some expert in armasm.

In my startup.s file I have the following code which reserves 0x400 bytes of RAM to the stack.

; this is the original startup.s file
Stack_Size      EQU     0x00000400

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp

Well, I would like to be able to initialise Stack_Size with a value which I have in a cfg.h file or with a const value which I have in a cfg.c file

// this is cfg.h file
#define STACK_SIZE  0x00000400
// this is cfg.c file
#include "cfg.h"
extern const int Stack_Size = STACK_SIZE;

The problem is that I dont know how to export the variable from C and import it into assembly.

I tried to use IMPORT, as in the following, but it does not work.

; this is the modified startup.s

                IMPORT Stack_Size
;Stack_Size      EQU     0x00000400
;               EXPORT  Stack_Size

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp

Any suggestion?

Thanks in advance, Marco.

Parents
  • Hello Marcus,

    I haven't given up yet, and now when I have a little bit of I am determined to get this thing to work (having the preprocessor parse my scatter file). I am trying this:

    #! armcc -E
    
    #include "boot_firmware.h"
    

    in order to include a definition that the scatter file needs. But then the preprocessor reports

    C:\DOCUME~1\tm\LOCALS~1\Temp\p14c8-2(2): error:  #5: cannot open source input file "boot_firmware.h": No such file or directory
    

    using the -I directive does not seem to help. How do I tell the preprocessor where to look for the file? The compiler settings already use -I option to get to the relative path "..\..\Bootloaders\src", but if that one is used in the scatter file itself, I get this error message:

    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(103): error: L6226E: Missing base address for region typedef.
    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(103): error: L6292E: Ignoring unknown attribute 'enum' specified for region typedef.
    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6226E: Missing base address for region e_target_internal_flash.
    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6292E: Ignoring unknown attribute '=' specified for region e_target_internal_flash.
    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6228E: Expected '{', found ',...'.
    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6228E: Expected '}', found 'EOF'.
    

    Any thoughts...?

    Thanks in advance!

Reply
  • Hello Marcus,

    I haven't given up yet, and now when I have a little bit of I am determined to get this thing to work (having the preprocessor parse my scatter file). I am trying this:

    #! armcc -E
    
    #include "boot_firmware.h"
    

    in order to include a definition that the scatter file needs. But then the preprocessor reports

    C:\DOCUME~1\tm\LOCALS~1\Temp\p14c8-2(2): error:  #5: cannot open source input file "boot_firmware.h": No such file or directory
    

    using the -I directive does not seem to help. How do I tell the preprocessor where to look for the file? The compiler settings already use -I option to get to the relative path "..\..\Bootloaders\src", but if that one is used in the scatter file itself, I get this error message:

    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(103): error: L6226E: Missing base address for region typedef.
    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(103): error: L6292E: Ignoring unknown attribute 'enum' specified for region typedef.
    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6226E: Missing base address for region e_target_internal_flash.
    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6292E: Ignoring unknown attribute '=' specified for region e_target_internal_flash.
    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6228E: Expected '{', found ',...'.
    C:\DOCUME~1\tm\LOCALS~1\Temp\p200-3(105): error: L6228E: Expected '}', found 'EOF'.
    

    Any thoughts...?

    Thanks in advance!

Children