Skip to contentSkip to conversation

print problem on ARM, toolchain 3.4.3

U-Boot-Users Shakthi Kannan 2 participants 4 messages Nov 14, 2005

lore
Share & tools
lore
#0 lore raw

Greetings!

This is a followup on use of printf with u-boot-1.1.2 with cross-toolchains 2.95.3 and Codesourcery's 3.4.3 on ARM.

http://sourceforge.net/mailarchive/message.php?msg_id=13329626

I am now trying to write a standalone code to be run with u-boot. This is the simple foo.c file:

/*
* foo.c
*
*/

#include <common.h>
#include <exports.h>

int main (int argc, char *argv[])

{
	/* Print the ABI version */
	app_startup(argv); 
	putc ('c'); 
	return (0);
}

The Makefile for cross-compilation:

# Makefile
# Tools

CROSS =
/usr/local/arm/3.4.3/bin/arm-none-linux-gnueabi-
CC = $(CROSS)gcc
AS = $(CROSS)as
LD = $(CROSS)ld
OBJCOPY = $(CROSS)objcopy

TARGET = foo
BASE = 0x04000000

CFLAGS = -fno-strict-aliasing -fno-common -ffixed-r8
-msoft-float -D__KERNEL__ -fno-builtin -ffreestanding -nostdinc -isystem /usr/local/arm/3.4.3/bin/../lib/gcc/arm-non-linux-gnueabi/3.4.3/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv4 -Wall -Wstrict-prototypes

INCLUDE = -I/home/shaks/docs/monitor/u-boot/u-boot-1.1.2/include -I/usr -I$(LIBSTUB_INCLUDE)

LIBSTUB_INCLUDE =
/usr/local/arm/3.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/3.4.3/include
LDFLAGS = -Ttext $(BASE) -e main

all:

	$(CC) $(CFLAGS) $(INCLUDE) -c $(TARGET).c -o
$(TARGET).o
	$(LD) $(LDFLAGS) $(TARGET).o -o $(TARGET) 

objcopy:

	$(OBJCOPY) -O binary $(TARGET) $(TARGET).bin

2>/dev/null

clean:

	rm -f *~ *.o *.bin $(TARGET)

On running make clean; make, I get this output:

/usr/local/arm/3.4.3/bin/arm-none-linux-gnueabi-gcc -fno-strict-aliasing -fno-common -ffixed-r8
-msoft-float -D__KERNEL__ -fno-builtin -ffreestanding -nostdinc -isystem /usr/local/arm/3.4.3/bin/../lib/gcc/arm-non-linux-gnueabi/3.4.3/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv4 -Wall -Wstrict-prototypes -I/home/shaks/docs/monitor/u-boot/u-boot-1.1.2/include
-I/usr -I/usr/local/arm/3.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/3.4.3/include -c foo.c -o foo.o

/usr/local/arm/3.4.3/bin/arm-none-linux-gnueabi-ld -Ttext 0x04000000 -e main foo.o -o foo foo.c:1: warning: target CPU does not support interworking
foo.o: In function `main':
foo.c:(.text+0x1c): undefined reference to `app_startup'
foo.c:(.text+0x24): undefined reference to `putc'
make: *** [all] Error 1

foo.o gets created. putc is declard in common.h, but, where is the actual definition? I'd appreciate any input from folks who have done similar style of firmware development with u-boot.

Thanks,

SK

--
Shakthi Kannan, MS
Software Engineer, Specsoft (Hexaware Technologies)
[E]: shakthimaan at yahoo.com [M]: (91) 98407-87007
[W]: http://www.shakthimaan.com [L]: Chennai, India

__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

#1 lore raw
Quoted 4 lines · In message <[email protected]> you wrote:

This is a followup on use of printf with u-boot-1.1.2 with cross-toolchains 2.95.3 and Codesourcery's 3.4.3 on ARM.

Let me remember that working toolchains have NO problems with all this. In other works, this is not an U-Boot problem per se.

Quoted 1 line

The Makefile for cross-compilation:

Please check exactly what the U-Boot Makefiles are doing. Then fix your Makefile.

Quoted 1 line

On running make clean; make, I get this output:

....

Quoted 3 lines

/usr/local/arm/3.4.3/bin/arm-none-linux-gnueabi-ld -Ttext 0x04000000 -e main foo.o -o foo
foo.c:1: warning: target CPU does not support interworking

Fix your toolchain problems.

Quoted 11 lines

foo.o: In function `main':
foo.c:(.text+0x1c): undefined reference to `app_startup'
foo.c:(.text+0x24): undefined reference to `putc'
make: *** [all] Error 1

foo.o gets created. putc is declard in common.h, but, where is the actual definition? I'd appreciate any input from folks who have done similar style of firmware development with u-boot.

You fail to compile and link examples/stubs.c

It seems you also missed to readthe documentation (i. e. "doc/README.standalone").

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If all you have is a hammer, everything looks like a nail.
#2 lore raw

Hi Wolfgang Denk,

Thanks for your inputs. Appreciate it.

Quoted 3 lines · --- Wolfgang Denk

It seems you also missed to readthe documentation
(i. e.
"doc/README.standalone").

Oops. Sorry about that. Will have a look at it.

SK

--
Shakthi Kannan, MS
Software Engineer, Specsoft (Hexaware Technologies)
[E]: shakthimaan at yahoo.com [M]: (91) 98407-87007
[W]: http://www.shakthimaan.com [L]: Chennai, India

__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

#3 lore raw

Hi again,

I have got the build working. Here is a foo.c and a simple Makefile that runs with CodeSourcery's 3.4.3 toolchain:

/*
* foo.c
*/

#include <common.h>
#include <exports.h>

int main (int argc, char *argv[])

{
	app_startup(argv);
	printf ("Voila! Voila!");
	return (0);
}

The Makefile:

# Makefile
# Tools

CROSS =
/usr/local/arm/3.4.3/bin/arm-none-linux-gnueabi-
CC = $(CROSS)gcc
AS = $(CROSS)as
LD = $(CROSS)ld
OBJCOPY = $(CROSS)objcopy

TARGET = foo
BASE = 0x04000000

CFLAGS = -g -Os -fno-strict-aliasing -fno-common
-ffixed-r8 -msoft-float -D__KERNEL__ -fno-builtin -ffreestanding -nostdinc -isystem /usr/local/arm/3.4.3/bin/../lib/gcc/arm-non-linux-gnueabi/3.4.3/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv4 -Wall -Wstrict-prototypes

INCLUDE = -I/home/shaks/docs/monitor/u-boot/u-boot-1.1.2/include -I/usr/local/arm/3.4.3/lib/gcc/arm-none-linux-gnueabi/3.4.3/include

LIBSTUBS = /home/shaks/docs/monitor/u-boot/u-boot-1.1.2/examples/libstubs.a
LGCC =
-L/usr/local/arm/3.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/3.4.3 -lgcc -L/home/shaks/docs/monitor/u-boot/u-boot-1.1.2/examples -lstubs

LIBSTUB_INCLUDE =
/usr/local/arm/3.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/3.4.3/include
LDFLAGS = -g -Ttext $(BASE) -e main

all:

	$(CC) $(CFLAGS) $(INCLUDE) -c $(TARGET).c -o
$(TARGET).o
	$(LD) $(INCLUDE) $(LDFLAGS) $(TARGET).o -o $(TARGET)
$(LIBSTUBS) $(LGCC)
	$(OBJCOPY) -O binary $(TARGET) $(TARGET).bin

2>/dev/null

clean:

	rm -f *~ *.o *.bin $(TARGET)

Voila! Voila!

SK

--
Shakthi Kannan, MS
Software Engineer, Specsoft (Hexaware Technologies)
[E]: shakthimaan at yahoo.com [M]: (91) 98407-87007
[W]: http://www.shakthimaan.com [L]: Chennai, India

__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com