Mbed-os: Invalid character `#' in linker script (STM32F4 with ARM_GCC)

Created on 16 Mar 2017  路  14Comments  路  Source: ARMmbed/mbed-os

Description

  • Type: Bug
  • Priority: Minor
  • OS: Windows 10
  • IDE: EmBitz
    Tried to build STM32F4 project with ARM_GCC, but could not build because of linker error.

Bug

STM32F429xI.ld from line 13

#if !defined(MBED_APP_START)
  #define MBED_APP_START 0x08000000
#endif

#if !defined(MBED_APP_SIZE)
  #define MBED_APP_SIZE 2048k
#endif

/* Specify the memory areas */
MEMORY
{
    VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x400
    FLASH (rx)   : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400
    CCM (rwx)    : ORIGIN = 0x10000000, LENGTH = 64K
    RAM (rwx)    : ORIGIN = 0x20000000, LENGTH = 192k
}

Target
STM32F4

Toolchain:
GCC_ARM

Toolchain version:
arm-none-eabi 5.4.1

Expected behavior
Exported project compile and link without errors.

Actual behavior
STM32F429xI.ld:13: ignoring invalid character `#' in expression
STM32F429xI.ld:13: syntax error

Steps to reproduce
Create project for STM32F4. Export to offline IDE (ARM_GCC) and build.

closed_in_jira export mirrored tracking bug

All 14 comments

cc @bcostm @adustm @LMESTM @jeromecoutant

@c1728p9 @theotherjimmy I think you are already aware ?
I think this comes from PR #3749. Could you check this, please ?

@vargham in #3749 there is a suggestion of workaround for your issue.
Let us know if it works.
Kind regards

I use the EmBitz exporter. My workaround: I changed the linker script back to the previous version without ifdefs.

@c1728p9 @theotherjimmy I think you are already aware ?
I think this comes from PR #3749. Could you check this, please ?

Yes , this is intended. I did not earlier spot it's about macros in the linker script.

I use the EmBitz exporter. My workaround: I changed the linker script back to the previous version without ifdefs.

OK I now see what is the failure here. The linker scripts are now required to be preprocessed. Therefore EmBitz exporter should be updated to do this step.

This bug is then for the exporter, not the target. @vargham Does EmBitz support this ?

Note: arm-none-eabi 5.4.1 - we currently do not support 5.x (4.9.x), but should work .

Thank you Martin @0xc0170

Hello, so what is the solution. I got problem, as it is desribed above. I exported project from mbed Compiler into SW4STM32, but after build a received message:
path.../STM32F429xI.ld:13: ignoring invalid character # in expression
path.../STM32F429xI.ld:13: syntax error
Thanks in advance!

@theotherjimmy Is there anything we can do?

Launched today a SW4STM32 export with mbed online (on DISCO_L476VG) and still the same error with the #if/#define not recognized in the ld file.

From #3749 :

You are correct to point out this deficiency in the exporter. The problem is that it does not run the C preprocessor on the linker script before passing it to the linker.

Any idea when this preprocessing will be fixed. Or can you give some hints ?

Any idea when this preprocessing will be fixed. Or can you give some hints ?

I understand the pre-processing of linker scripts is already working. Could you please re-test and confirm?

@MarceloSalazar this issue is still open and correct as there have not been any updates to the ~SW4STM32~ EmBitz exporter.

ARM Internal Ref: IOTMORF-1835

Alternative Solution

@toyokomi @vargham I found a workaround based on succesfull earlier version of mbed-os. first comment out this part of code in STM32F446XE.ld

#if !defined(MBED_APP_START)
  #define MBED_APP_START 0x08000000
#endif

#if !defined(MBED_APP_SIZE)
  #define MBED_APP_SIZE 512K
#endif

And replace flash memory declaration

MEMORY
{
  FLASH (rx)   : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
  RAM (rwx)  : ORIGIN = 0x200001C4, LENGTH = 128k - 0x1C4
}

with new direct declaration:

MEMORY
{ 
  FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
  RAM (rwx)  : ORIGIN = 0x200001C4, LENGTH = 128k - 0x1C4
}

Make sure your memory map is correct because it may be different from my microcontroller.

@AchmadFathoni That's a nice workaround. Alternatively, you could run the C preprocessor on the file.

Any idea when this preprocessing will be fixed. Or can you give some hints ?
I understand the pre-processing of linker scripts is already working. Could you please re-test and confirm?

The preprocessing of GCC linker script is working. I compiled successfully the NUCLEO_F429ZI platform.

@AchmadFathoni, FYI the MBED_APP_START/SIZE labels are used for the bootloader feature.

I think this issue can be closed. Thanks.

ST_TO_BE_CLOSED

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbonghi picture rbonghi  路  3Comments

cesarvandevelde picture cesarvandevelde  路  4Comments

pilotak picture pilotak  路  3Comments

chrissnow picture chrissnow  路  4Comments

sarahmarshy picture sarahmarshy  路  4Comments