Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Assembly file(.S) compilation fails.(Ported assembly file from ARMCC syntax to GNU syntax. Throwing error while compilation.)
Assembly file(.S) compilation fails. [message #1828707] Wed, 17 June 2020 06:59 Go to next message
Utsav kumar is currently offline Utsav kumarFriend
Messages: 5
Registered: June 2020
Junior Member
Environment: GNU arm toolchain for ARM7 in Eclipse photon.
Requirement: Porting from keil ARMCC to GNU arm toolchain in eclipse.

Compiled and build properly. When I added an assembly file .S(attached), facing compilation errors (Pasted below).
I tried to solve for two days, unfortunately, it didn't work.
Can someone please help.

Thanks.

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

12:18:39 Build Failed. 9 errors, 0 warnings. (took 764ms)
  • Attachment: iap_blue.S
    (Size: 0.57KB, Downloaded 74 times)
Re: Assembly file(.S) compilation fails. [message #1828714 is a reply to message #1828707] Wed, 17 June 2020 12:21 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Maybe this will help
https://www.avrfreaks.net/forum/how-include-s-file
Re: Assembly file(.S) compilation fails. [message #1828747 is a reply to message #1828714] Thu, 18 June 2020 05:10 Go to previous messageGo to next message
Utsav kumar is currently offline Utsav kumarFriend
Messages: 5
Registered: June 2020
Junior Member
Thank you David.

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:
Checked C/C++ General --> File types which lists .S as assembly file. I changed .s to .S , 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 command line, it builds successfully without any error. That means there was some issue with eclipse project configuration.

Then I referred the link shared by David which says "You don't want to do include that. You have already included it in the project. That alone will get the file to be recognized properly and assembled."
This solved the mistake2.

Thank you.
Re: Assembly file(.S) compilation fails. [message #1828795 is a reply to message #1828707] Thu, 18 June 2020 17:33 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
I got curious and made an Eclipse CDT project of your code.

The only thing slightly wrong was the attempt to redefine the section .text.

For calling IAP, you do not need assembly code, but the GCC embedded assembly can be used pretty easily.

In the attached zip, there are a testing main program to call the modules, your module and three competing versions written in GCC code:
blue1.c is your module ported to GCC embedded C,
blue2.c is the simplest way to call IAP, with minimal code (3 words).

In all the previous pieces of code, there is a potential gotcha: If the IAP ROM code does the return with some other instruction than bx, the code does not return to 32 bit ARM mode on return and goes totally lost.

blue3.c is a GCC embedded assembly piece with guranteed return from Thumb mode.

The zip file contains the complete Eclipse CDT project in own directory 'blue' to run a makefile compilation of the test packet, and assembly listings of the compilations.
  • Attachment: blue.zip
    (Size: 23.71KB, Downloaded 95 times)


--

Tauno Voipio
Re: Assembly file(.S) compilation fails. [message #1828820 is a reply to message #1828795] Fri, 19 June 2020 08:40 Go to previous messageGo to next message
Utsav kumar is currently offline Utsav kumarFriend
Messages: 5
Registered: June 2020
Junior Member
Thank you, Tauno. That was beautiful work.

I am new to GNU ARM toolchain and as mentioned before, I am working on porting of my project code to eclipse with GCC from Keil using ARMCC.
Can you help me in understanding the mistake I am doing while porting the startup file (MappedToKeil.S ) ?

Keil source: Build success and execute in the target as per the logic implemented in the code.
DMGlass.sct - scatter file
LPC2400.s - startup file

Port in Eclipse: Build success but don't execute in the target as per the logic implemented.
MappedToKeil.S - startup file
LPC2468_ls.ld - linker script file.

New in Eclipse: Build success and execute in the target as per the logic implemented in the code.
LPC2468_startup.c - startup file
LPC2468_ls.ld - linker script file.
  • Attachment: Files.zip
    (Size: 21.50KB, Downloaded 77 times)
Re: Assembly file(.S) compilation fails. [message #1828835 is a reply to message #1828820] Fri, 19 June 2020 14:26 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
Will take a look - it takes some time.

--

Tauno Voipio
Re: Assembly file(.S) compilation fails. [message #1829583 is a reply to message #1828820] Tue, 07 July 2020 10:06 Go to previous message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
Hello Utsar,

Sorry, it took longer than I thought. My computer went on strike, and it took some time to get a new one up and running with all the software. I was lucky in having kept good backups, but a new operating system version took its time.

Please find attached a zip file containing what I succeeded in cooking up from your code. I changed the start-up from assembler to C, to make it easier to maintain.

I guess that the problems you have are from the LPC2468 start-up ROM code by NXP. There must be a checksum word in the fifth slot of the exception vector at offsets 20 to 23 (0x14 to 0x17). The word must be set up so that the 32 bit sum of the first 8 fullwords (byte offsets from 0 to 0x1f) is zero.

For further discussion, we should find a less public discussion channel, as it will be off-topic for this forum.
  • Attachment: blue.zip
    (Size: 163.58KB, Downloaded 78 times)


--

Tauno Voipio
Previous Topic:2020-06 ??
Next Topic:Error "Symbol 'pair' could not be resolved" when using typedef
Goto Forum:
  


Current Time: Fri Apr 26 13:54:44 GMT 2024

Powered by FUDForum. Page generated in 0.03072 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top