I am using LPC1788 micro-controller with Keil4, when i create a project Keil adds a file called "startup_LPC177x_8x.s". In this file at one stage a IMPORT command is trying to import SystemInit, but when i compile, i get an error as follow:
compiling main.c...
main.c(6): warning: #1-D: last line of file ends without a newline
linking...
project_1.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_lpc177x_8x.o).
Target not created
the piece of code is as follow:
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
I have included the header file "lpc177x_8x.h" in my project.
Please guide me friends ...i am new to Keil...thanks a lot.
It is an IMPORT symbol in this file - that is it defined elsewhere.
It will probably be in a file named system_LPC177x_8x.c or similar; it may need customisation for your project to set the PLL and initialise external memory interfaces, and other clock dependent features.
It is normally included in your project automatically if you ask for start-up files to be included when you create the project; otherwise it will be in the CMSIS target specific support folder in the Keil ARM-MDK installation, in this case I would guess: CMSIS\CM3\DeviceSupport\NXP\LPC17xx\ or similar, the exact directory structure has changed between CMSIS versions.
depends on where you installed Keil.
here is the address in my computer:
D:\Program Files\keil\ARM\INC\NXP\LPC17xx
(here contains the header files you use)
D:\Program Files\keil\ARM\Startup\NXP\LPC17xx
(here contains startup files you use, the SystemInit function is defined here in the system_LPC13xx.c)
Related
I am getting this error when using atomthreads in cosmic c for stm8L151c6 micro controller.
clnk - symbol _archFirstThreadRestore not defined (Debug\atomkernel.o)
Ifound out that _archFirstThreadRestore is defined inside a assembler file named atomports_asm_cosmic.s linker cannot find those routines in the assembler file. How can I make linker to add the assembler file to the c code where those functions are used.
Yes got it.
I got it worked.
The problem was I have to add assembler files to the project source files. Which I didn't do.
I am using IAR linker and I need to define exported symbols of start/end address of my defined blocks in linker file:
Example:
I defined my block like this:
define block AppFlash with fixed order, alignment = 32
{
block App_1,
block App_2,
block App_3,
};
And now I need to get the start address of the blocks, by using __section_begin("App_1"), etc.
The problem that I have is that I only am able to retrieve this info at runtime, but not at startup, and I have assembler files that need some start address references of the linker for vector table configuring...
Explanation:
C code Files:
result = __section_begin("App_1") -> Runs fine, info retrieved is the expected
Assembler files:
EXTERN MAINSTACK_START -->> I cant make a define with the __Section_begin function in the same way
Is there any way to define a exported symbol with the start address of a block in IAR linker file?
I know it's possible with regions, but I dont know how to do this with blocks.
In assembler you can use the operators SFB, SFE, and SIZEOF to get the start, end, and length of a block. They are used as in the example below. Note that the block you want to find must be declared before the operators are used.
;; Forward declaration of section App_1
SECTION App_1:DATA:NOALLOC:NOROOT(0)
PUBLIC begin, beginsym
PUBLIC end, endsym
PUBLIC size, sizesym
SECTION `.text`:CODE:NOROOT(2)
THUMB
begin: LDR R0, =SFB(App_1)
BX LR
end: LDR R0, =SFE(App_1)
BX LR
size: LDR R0, =SIZEOF(App_1)
BX LR
SECTION `.data`:DATA:NOROOT(2)
DATA
beginsym:
DC32 SFB(App_1)
endsym:
DC32 SFE(App_1)
sizesym:
DC32 SIZEOF(App_1)
END
I using the PCLint-Check 9.0L for a Project and got the current Error Message during a Lint-Check on all Lint-Object-Files(*.lob) of the Project:
W:\DevWA\src\Platforms_h\TSPlatforms.h Error 14: Symbol 'TS_IntDisableAsm(void)' previously defined (line 90, file W:\DevWA\src\Platforms_h\TSPlatforms.h, module TSPlatforms.c)
The PCLInt Help manual explains here:
Symbol 'Symbol' previously defined (Location) -- The named object has been defined a second time.
But there exists only the following definition on the whole Project inside the TSPlatforms.h at Line 90:
#define TS_IntDisable() TS_IntDisableAsm()
__asm TS_IntStatusType TS_IntDisableAsm(void)
{
.set noreorder
! "r3"
mfmsr r3
wrteei 0
.set reorder
}
The TSPlatforms.h is included several times in different C-Files of my project, but the code is of course wrapped in a redefinition protection:
#if (!defined TSPLATFORMS_H)
#define TSPLATFORMS_H
...
#endif
Has anyone a hint for me to identify the error?
Thanks!
HJ
My guess: the code TS_IntDisableAsm() is intended to be inlined. PCLint is not aware of that and thinks it is defined in multiple .c files and that there will be a conflict when everything will be linked together.
Adding a static keyword in front of your declaration should help.
I'm using IAR toolchain to compile few source files and then link generated .o files.
However, I'm running into linking errors like below:
Error[Li005]: no definition for "main" [referenced from cmain.o(rt7M_tl.a)]
Error[Lc036]: no block or place matches the
pattern "ro code section .intvec in vector_table_M.o(rt7M_tl.a)"
As I understand, ILINK linker is trying to link object files as an executable image and in the process adding dependencies from standard libraries[ i.e looking for main() and interrupt vector table ].
What I'm looking for :
How to configure linker to not to add these system-library dependencies like main/start/interrupt-vector-table etc. ?
How to configure linker to output a non-executable image from bunch of object files - if that at all is possible ?
You can think of this non-executable image sort of configuration-table image which will be put in persistent memory to be read/write by main application image.
If you tell the linker that you don't have an entry point with the command line option '--no_entry' you will get rid of the reference to main and the .intvec data.
However you do need to tell the linker what it should keep.
--keep and/or __root can help you with that.
I am facing a trivial prblem.
I am doing an ldr r0, _buff
in arm assembly, where _buff is defined in a c file. _buff is not static.
How should I define external linkage in assembly file (similar to extern in C)
is it required or is there anything which I am missing.
You don't need to. If the symbol can't be found in the source file, it'll be assumed to be defined elsewhere.
It's not necessary to do that. If *_buff* has been defined as global in the C file, you can compile and build the files together:
arm-none-gnuaebi-gcc -o output assembly.s cfile.c
You can also compile them separately, it's also going to work. But _buff does not exist, you will get a link error.