C Programming for Embedded - Build Errors

Post here on these publications

Postby shadders » Sun Jul 12, 2009 12:00 am

Hi,

I have implemented the latest Yagarto software on my PC (4.3.3), and for the string_tx example i am getting build errors. This is due to the sprintf procedure use - printf works ok.

In reading the yagarto_newlib.txt file it states that you may get these build errors due to undefined references.

The reference i obtain is _sbrk_r

The text states that the interface functions for the newlib need to be provided - but i am not sure how and where these interfaces need to be provided.

The texts that are suggested to be read are rather detailed, so being new to this area of GNU programming tools i do not know where would be the most appropriate place to start :

1. Write another header file with the interface in
2. Recompile the newlib since the text file states that the syscalls have been disabled.
3. Or another option ??

Any help gratefully received since the yagarto does not have a forum.

Thanks.

Regards,

Richard.
shadders
 
Posts: 53
Joined: Thu Jan 02, 2014 10:37 am

Postby shadders » Sun Jul 12, 2009 12:00 am

Hi Elektor,

I have examined the web site :

http://www.yagarto.de

and selected the link syscalls.c about half way down the page :

http://www.yagarto.de/download/yagarto/syscalls.c

I have then copied this file into the project directory and #include "syscalls.c" in the main.c file and the project now compiles.

Can you ask Warwick Smith if this is an acceptable approach ?., and if this will work without consequences ?. Thanks.

Regards,

Richard.'
shadders
 
Posts: 53
Joined: Thu Jan 02, 2014 10:37 am

Postby warwick » Mon Jul 13, 2009 12:00 am

Hi Richard

The reason for the problem that you are experiencing is that the newlib library that comes with YAGARTO has changed since the C programming book was published.

The approach that you have taken will work, but it is not good practice to #include c source files in the top of a c source file as you would normally do with header files.

A better approach is to copy the syscalls.c file into the project, as you have already done. To compile and link this file with the project, you must add it to your make file.

Edit the make file in 3 places:

1) Change the version number from 4.3.2 to 4.3.3:
# Paths to standard and maths library files - assumes default YAGARTO installation
LIBGCC=C:/"Program Files"/yagarto/lib/gcc/arm-elf/4.3.3/libgcc.a

2) Add syscalls.o to the list of object files to be linked:
#----------------------------------------------------------------------------------
# TODO: Add all the object files generated for you project to the framework
#objects listed below
#----------------------------------------------------------------------------------
OBJS=startup.o \
main.o \
syscalls.o

3) Add the lines to compile syscalls.c:
#----------------------------------------------------------------------------------
# TODO: Add your object file compilation instructions
#----------------------------------------------------------------------------------

main.o: main.c
$(CC) -c $(CCFLAGS) main.c -o main.o

syscalls.o: syscalls.c
$(CC) -c $(CCFLAGS) syscalls.c -o syscalls.o

startup.o: startup.s
$(AS) $(ASFLAGS) startup.s -o startup.o


OR

If your syscalls.c is in the Drivers directory:

syscalls.o: Drivers/syscalls.c
$(CC) -c $(CCFLAGS) Drivers/syscalls.c -o syscalls.o

I have attached the modified make files from the string_tx program (chapter 10) and the formats program (chapter 11).

I hope that this helps.

Regards,
Warwick
warwick
 
Posts: 11
Joined: Thu Jan 02, 2014 10:39 am

Postby shadders » Mon Jul 13, 2009 12:00 am

Hi Warwick,

Thanks for the prompt reply. Not tried this yet, but will implement shortly.

Will try both approaches since i am new to this area and need more experience.

I think it is a great book - will help me alot in my next project - program in C rather than assembly language.

Thanks again for the reply.

Regards,

Richard.
shadders
 
Posts: 53
Joined: Thu Jan 02, 2014 10:37 am

Postby warwick » Wed Nov 04, 2009 12:00 am

The software example programs and templates for the book "C Programming for Embedded Microcontrollers" have been updated to work with the YAGARTO toolchain version 4.4.2 on 2 November 2009.

The updated examples will also prevent the link errors from occurring when using functions such as sprintf().

The updated files are available here:
http://www.elektor.com/Uploads/Files/Product/ExtrasCprogramming.zip

OR

From www.elektor.com, under "Products", click "Books"
Click the "Microcontrollers" tab
Click "C Programming for Embedded Microcontrollers"
Download "ExtrasCprogramming.zip" (link to the right of the page)

Enjoy!
Warwick
warwick
 
Posts: 11
Joined: Thu Jan 02, 2014 10:39 am

Postby malkowki » Wed Jul 04, 2012 12:00 am

Hello Warwick,

when compiling the "string_tx "I have got the following message:
make.exe: *** [sram] Error 11
arm-none-eabi-gcc -nostartfiles -Wl,-Map,out.map,--cref -T RAM.ld -n -o string_tx.elf startup.o main.o syscalls.o

I am using the following libraries:
LIBGCC=C:/yagarto/lib/gcc/arm-none-eabi/4.6.0/libgcc.a
LIBC=C:/yagarto/arm-none-eabi/lib/libc.a
LIBM=C:/yagarto/arm-none-eabi/lib/libm.a

any idea what could be?
malkowki
 
Posts: 12
Joined: Thu Jan 02, 2014 10:39 am

Postby warwick » Wed Jul 04, 2012 12:00 am

Hi malkowki

I would need to see the full error message that you got. It is under the "Console" tab in Eclipse (at the bottom where the "Problems" tab is).

But your problem may be that you need to change the following in the make file because Yagarto GCC changed since the book was written:

Old:
AS=arm-elf-gcc
CC=arm-elf-gcc
LD=arm-elf-gcc
OBJCOPY=arm-elf-objcopy
OBJDUMP=arm-elf-objdump

Must change to:
AS=arm-none-eabi-gcc
CC=arm-none-eabi-gcc
LD=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
OBJDUMP=arm-none-eabi-objdump

In the above, "elf" is replaced with "none-eabi"

I hope that this helps.

Kind regards,
Warwick
warwick
 
Posts: 11
Joined: Thu Jan 02, 2014 10:39 am

Postby malkowki » Wed Jul 04, 2012 12:00 am

Hi Warwick,

This the make file I am using which has been modified earlier for previous exercises:
OUTFILE_SRAM=string_tx

TARGET=AT91SAM7S256

# Paths to standard and maths library files - assumes default YAGARTO installation
LIBGCC=C:/yagarto/lib/gcc/arm-none-eabi/4.6.0/libgcc.a
LIBC=C:/yagarto/arm-none-eabi/lib/libc.a
LIBM=C:/yagarto/arm-none-eabi/lib/libm.a

# no optimisation
OPTIM=-O0

AS=arm-none-eabi-gcc
CC=arm-none-eabi-gcc
LD=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
OBJDUMP=arm-none-eabi-objdump
CCFLAGS=-g -mcpu=arm7tdmi $(OPTIM) -Wall -D$(TARGET)
ASFLAGS=-D__ASSEMBLY__ -D$(TARGET) -g -mcpu=arm7tdmi -c $(OPTIM) -Wall

# Linker flags.
# -Wl,... : tell GCC to pass this to linker.
# -Map : create map file
# --cref : add cross reference to map file
LDFLAGS_R+=-nostartfiles -Wl,-Map,out.map,--cref
LDFLAGS_R+=-T RAM.ld


#----------------------------------------------------------------------------------
# TODO: Add all the object files generated for you project to the framework
#objects listed below
#----------------------------------------------------------------------------------
OBJS=startup.o \
main.o \
syscalls.o

rebuild: clean all

all: sram

sram: $(OBJS)
$(LD) $(LDFLAGS_R) -n -o $(OUTFILE_SRAM).elf $(OBJS)
$(OBJCOPY) --strip-debug --strip-unneeded $(OUTFILE_SRAM).elf -O binary $(OUTFILE_SRAM).bin

#----------------------------------------------------------------------------------
# TODO: Add your object file compilation instructions
#----------------------------------------------------------------------------------

main.o: main.c
$(CC) -c $(CCFLAGS) main.c -o main.o

syscalls.o: syscalls.c
$(CC) -c $(CCFLAGS) syscalls.c -o syscalls.o

startup.o: startup.s
$(AS) $(ASFLAGS) startup.s -o startup.o

clean:
rm -f *.o *.bin *.elf *.map

and I got the following message from the eclipse problem tab:

DescriptionResourcePathLocationType
make.exe: *** [sram] Error 11string_tx C/C++ Problem
malkowki
 
Posts: 12
Joined: Thu Jan 02, 2014 10:39 am

Postby warwick » Wed Jul 04, 2012 12:00 am

Hi malkowki

I need you to copy and paste the message from the "Console" tab to this forum so that I can see a proper description of the problem.

Next to the "Problems" tab is the "Tasks" tab and then the "Console" tab.

Warwick
warwick
 
Posts: 11
Joined: Thu Jan 02, 2014 10:39 am

Postby malkowki » Thu Jul 05, 2012 12:00 am

Hello Warwick,
Please find attached the error messages I have got
Attachments
string-tx-error.JPG
malkowki
 
Posts: 12
Joined: Thu Jan 02, 2014 10:39 am

Next

Return to Books | CDs | DVDs| Videos | Courses | Seminars | Webinars

Who is online

Users browsing this forum: No registered users and 1 guest