Utsav
Utsav

Reputation: 1

Assembly file(.S) throw errors with GNU ARM toolchain in Eclipse Photon

I ported an assembly file from ARMCC syntax to GNU syntax, but it is throwing an error during compilation.

Environment: GNU ARM toolchain for ARM7 in Eclipse 4.8 (Photon).
Requirement: Porting from Keil ARMCC to GNU ARM toolchain in Eclipse.

It compiled and build properly. When I added an assembly file iap_blue.S(attached), I was facing compilation errors (pasted below).

//iap_blue.S
            .section .text,"x"
            .balign 4

.globl blue_execute
blue_execute:
        STMFD   SP!,{LR}               // Save Return Address
                ADD     R1,R0,#0x14            // R0 = &IAP.cmd, R1 = &IAP.stat
                ADR     LR,blue_exit           // Return Address
                LDR     R2,=0x7FFFFFF1         // IAP Entry (Thumb Mode)
                BX      R2                     // Execute IAP Command

blue_exit:
                LDMFD   SP!,{LR}               // Restore Return Address
                BX        LR                     // Return
                .end
12:18:38 **** Build of configuration Debug for project LEDblink ****
make all
Building file: ../LPC2468_startup.c
Invoking: GNU ARM Cross C Compiler
arm-none-eabi-gcc -mcpu=arm7tdmi-s -march=armv4t -marm -mthumb-interwork -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -include"E:\EclipseARM\workspace\LEDblink\iap_blue.S" -std=gnu11 -MMD -MP -MF"LPC2468_startup.d" -MT"LPC2468_startup.o" -c -o "LPC2468_startup.o" "../LPC2468_startup.c"
In file included from <command-line>:
E:\EclipseARM\workspace\LEDblink\iap_blue.S:1:13: error: expected identifier or '(' before '.' token
1 | .section .text,"x"
| ^
E:\EclipseARM\workspace\LEDblink\iap_blue.S:7:17: error: unknown type name 'ADD'
7 | ADD R1,R0,#0x14 // R0 = &IAP.cmd, R1 = &IAP.stat
| ^~~
E:\EclipseARM\workspace\LEDblink\iap_blue.S:7:31: error: stray '#' in program
7 | ADD R1,R0,#0x14 // R0 = &IAP.cmd, R1 = &IAP.stat
| ^
E:\EclipseARM\workspace\LEDblink\iap_blue.S:7:32: error: expected identifier or '(' before numeric constant
7 | ADD R1,R0,#0x14 // R0 = &IAP.cmd, R1 = &IAP.stat
| ^~~~
E:\EclipseARM\workspace\LEDblink\iap_blue.S:14:17: error: unknown type name 'BX'
14 | BX LR // Return
| ^~
E:\EclipseARM\workspace\LEDblink\iap_blue.S:15:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
15 | .end
| ^
In file included from c:\program files (x86)\gnu tools arm embedded\9 2019-q4-major\arm-none-eabi\include\stdint.h:14,
from c:\program files (x86)\gnu tools arm embedded\9 2019-q4-major\lib\gcc\arm-none-eabi\9.2.1\include\stdint.h:9,
from ../LPC2468_startup.c:1:
c:\program files (x86)\gnu tools arm embedded\9 2019-q4-major\arm-none-eabi\include\sys\_stdint.h:20:9: error: unknown type name '__int8_t'
20 | typedef __int8_t int8_t ;
| ^~~~~~~~
subdir.mk:31: recipe for target 'LPC2468_startup.o' failed
make: *** [LPC2468_startup.o] Error 1

Upvotes: 0

Views: 729

Answers (1)

Utsav
Utsav

Reputation: 1

The problem is solved.

I will like to elaborate on what was the mistake I was doing and how it is solved. This may be helpful for others.

Mistake 1:

I was using .s instead of .S for assembly file.

Mistake 2:

Included .S file in eclipse compiler include files as part of project settings.

Solution:

I checked C/C++ General → File types which lists .S as assembly file. I changed .s to .S, and mistake 1 is corrected.

Even though I was facing compilation errors which I have posted here, I was not sure whether there is some Eclipse-related issue or issue with my assembly file since I ported it to GNU syntax from ARMCC syntax.

I created my own make file and build the code using a command line. It builds successfully without any error. That means there was some issue with Eclipse project configuration.

Then, I realized you don't have include an assembly file in compiler settings if you have already included it in the project. That alone will get the file to be recognized properly and assembled. This solved mistake 2.

Upvotes: 0

Related Questions