Skip to main content
sven23
Associate
February 7, 2016
Question

ASM error when using an array containing struct elements

  • February 7, 2016
  • 9 replies
  • 1868 views
Posted on February 07, 2016 at 19:55

Hello,

I have an array, that should contain structures for the input and output pins as follows:

typedef
struct
inputStruct
{
uint16_t pin;
GPIO_TypeDef *port;
}input_t;
struct
inputStruct inputPins[20];
void
initPins(
void
)
{
uint8_t counter = 0;
inputPins[0].pin = GPIO_Pin_0;
inputPins[0].port = GPIOA;
inputPins[1].pin = GPIO_Pin_1;
inputPins[1].port = GPIOA;
. 
//some more pin definitions here
inputPins[20].pin = GPIO_Pin_4;
inputPins[20].port = GPIOB;
for
(counter = 0; counter < 20; counter++)
{
initInput(inputPins[counter]);
}
}
void
initInput(input_t channel)
{
GPIO_InitTypeDef GPIO_InitStructure;
uint32_t clockSystem;
if
(channel.port == GPIOA)
clockSystem = RCC_AHBPeriph_GPIOA;
else
if
(channel.port == GPIOB)
clockSystem = RCC_AHBPeriph_GPIOB;
else
if
(channel.port == GPIOC)
clockSystem = RCC_AHBPeriph_GPIOC;
RCC_AHBPeriphClockCmd(clockSystem, ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Pin = channel.pin;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_Init(channel.port, &GPIO_InitStructure);
}

When compiling, I get the following error messages:

Info: Internal Builder is used for build
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -std=c11 -DNUCLEO_L152RE -DSTM32L1 -DSTM32L152RETx -DSTM32 -DDEBUG -DUSE_STDPERIPH_DRIVER -DSTM32L1XX_XL -I/home/sven/workspace/micaFirmware/inc -I/home/sven/workspace/micaFirmware/CMSIS/device -I/home/sven/workspace/micaFirmware/CMSIS/core -I/home/sven/workspace/micaFirmware/StdPeriph_Driver/inc -I/home/sven/workspace/micaFirmware/Utilities -O0 -g3 -Wall -fmessage-length=0 -ffunction-sections -c -o src/syscalls.o ../src/syscalls.c 
../src/syscalls.c:63:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'asm'
register char * stack_ptr asm(''sp'');
^
../src/syscalls.c: In function '_sbrk':
../src/syscalls.c:116:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'asm'
extern char end asm(''end'');
^
../src/syscalls.c:116:18: warning: implicit declaration of function 'asm' [-Wimplicit-function-declaration]
../src/syscalls.c:121:15: error: 'end' undeclared (first use in this function)
heap_end = &end;
^
../src/syscalls.c:121:15: note: each undeclared identifier is reported only once for each function it appears in
../src/syscalls.c:124:24: error: 'stack_ptr' undeclared (first use in this function)
if (heap_end + incr > stack_ptr)
^

Is there just a library missing or what's going on here? Thanks EDIT: I use System Workbench for STM32
    This topic has been closed for replies.

    9 replies

    Radosław
    Associate II
    February 7, 2016
    Posted on February 07, 2016 at 20:03

    This error are from syscalls, not from your code.  This code is generated?

    sven23
    sven23Author
    Associate
    February 7, 2016
    Posted on February 07, 2016 at 20:15

    Hi,

    I use the standard Library without any code generator and created an empty Ac6 STM32 MCU Project.

    Radosław
    Associate II
    February 7, 2016
    Posted on February 07, 2016 at 20:19

    So it's look like the linker file and syscalls are not complementary to each other.

    You will use printf or dynamic allocation?

    sven23
    sven23Author
    Associate
    February 7, 2016
    Posted on February 07, 2016 at 20:22

    No I will use a custom USART library that is working in another project. Dynamic allocation won't be used either.

    Radosław
    Associate II
    February 7, 2016
    Posted on February 07, 2016 at 20:36

    So syscalls are not neccesary, delete this file. Check compilation.

    sven23
    sven23Author
    Associate
    February 7, 2016
    Posted on February 07, 2016 at 20:45

    Wow that was easy. Thank you. No errors any more.

    Radosław
    Associate II
    February 7, 2016
    Posted on February 07, 2016 at 20:48

    Yes it is easy, but not with ST solutions. For future when you wonna use standard io or dynamic alocations, linker file must coresponds with syscalls.

    Radosław
    Associate II
    February 7, 2016
    Posted on February 07, 2016 at 21:00

    Function parameter as structure not pointer??

    For input pins you can use bitband. will be much more portable. And your configuration is very not optimal.

    sven23
    sven23Author
    Associate
    February 7, 2016
    Posted on February 07, 2016 at 21:15

    Yeah should be pointers to work. Didn't notice that, debugging would possibly have shown me the bug.

    Oh never heard of bit banding before. Nobody told us in study such thing exists but looks good on the first view. I might use it in future codes. Thanks.