AW: Mess with library
"Mark Butcher" <[email protected]>
| Newsgroups | gmane.comp.hardware.motorola.microcontrollers.coldfire |
|---|---|
| Message-ID | <000601c85ebd$c21d9e50$7400a8c0@mjblp004> |
Hi Bob Printf() will need to send the output to an interface - one of the UARTs normally. The printf() code interfaces with the UART using the puts() call, which accepts the characters to be sent and transmits them to the UART. If you are getting a linker error due to this not being found you will need to use a hardware library which performs it (BSP or something). Since I don't use the same tools as you I can't say exactly which is required, but this may help you start looking in the right direction. Regards Mark Mark Butcher Bsc (Hons) MPhil MIEE M.J.Butcher Consulting Obere Bahnhofstr. 13, CH-5507 Mellingen, Switzerland www.mjbc.ch / www.uTasker.com 056 491 48 10 / 079 402 26 37 / Skype: M_J_Butcher -----Ursprüngliche Nachricht----- Von: [email protected] [mailto:[email protected]] Im Auftrag von Bob Brusa Gesendet: Donnerstag, 24. Januar 2008 17:14 An: [email protected] Betreff: [ColdFire] Mess with library Hi, I am using the toolchain uClinux (m68k-uclinux-tools-20061214.sh) on a Debian (etch) host. The Target is a COBRA5282-Board which operates under dBUG. The Board came with an example that blinks with the LEDs on the board. The program links with its own target-specific startfile crt0_ram and no libraries. It compiles, links and I can download (using NFS) and execute it. So far so good. Then I wanted to create another example - a simple HelloWorld-Programm. But I get an error. The output is shown below: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++ rwb@debi28:~/wso/helloworld$ make /usr/local/bin/m68k-elf-gcc -Wa,-as -m5307 -c crt0_ram.S 68K GAS /tmp/ccrsskya.s page 1 DEFINED SYMBOLS *ABS*:00000000 crt0_ram.S crt0_ram.S:39 .text:00000000 _start UNDEFINED SYMBOLS main /usr/local/bin/m68k-elf-gcc -g -m5307 -nostartfiles -c main.c /usr/local/bin/m68k-elf-ld -T COBRA5282-ram.ld -M -o helloworld.elf crt0_ram.o main.o > helloworld.map main.o: In function `main': /home/rwb/wso/helloworld/main.c:5: undefined reference to `puts' make: *** [helloworld.elf] Fehler 1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++ It seems, something is wrong with the standard library. Who can help? So far I have found nothing that explains the linking process in some details. Yes, I have the ld-doc, but it does not explain the basics (which I am sorry to say - I do not know yet). Regards Bob The source (main.c) is shown below: ----------------------------------------------- #include <stdio.h> int main(void) { printf("Hello World\n"); return 0; } ------------------------------------------------ The makefile, adapted from the led-example - is: ------------------------------------------------ GCC_EXEC_PREFIX = /usr/local/bin/m68k-elf- CC = $(GCC_EXEC_PREFIX)gcc AS = $(GCC_EXEC_PREFIX)as LD = $(GCC_EXEC_PREFIX)ld AR = $(GCC_EXEC_PREFIX)ar OBJCOPY = $(GCC_EXEC_PREFIX)objcopy PROGNAME = helloworld TARGET = $(PROGNAME).s19 OBJS = crt0_ram.o main.o CFLAGS += -g -m5307 # -g produces debugging options (native format) # -m5307 selects the processor. this options is also ok for the MCF5282. # the -as option for the assembler is nowhere documented ASFLAGS += -Wa,-as -m5307 $(PROGNAME).s19: $(PROGNAME).bin # objcopy converts the binary file to the srec format - .bin to .s19 $(OBJCOPY) --input-target=binary --output-target=srec $(PROGNAME).bin $(PROGNAME).s19 # and the .s19-file is copied to our network-folder cp ${PROGNAME}.s19 /tftpboot $(PROGNAME).bin: $(PROGNAME).elf # create a binary file using the standard .elf-file as input $(OBJCOPY) -O binary $(PROGNAME).elf $@ # and copy the .bin-file to our network-folder cp ${PROGNAME}.bin /tftpboot $(PROGNAME).elf: $(OBJS) # Link the o-files into memory as specified in the .ld-file (linker-script-file) $(LD) -T COBRA5282-ram.ld -M -o $(PROGNAME).elf $(OBJS) > $(PROGNAME).map .S.o: $(CC) $(ASFLAGS) -c $< .c.o: $(CC) $(CFLAGS) -nostartfiles -c $< #compile c-files, but no linking crt0_ram.o: crt0_ram.S all: $(TARGET) clean: rm $(PROGNAME) *.o *.bin *.s19 *.map *.elf *.gdb -f ------------------------------------------------------------------ and the loader script (COBRA5282-ram.ld) is: ------------------------------------------------------------------ MEMORY { ram : ORIGIN = 0x10000, LENGTH = 0x3e0000 } SECTIONS { .text : { _stext = . ; *(.text) _etext = ALIGN(0x4) ; } > ram .data BLOCK(0x4) : { _sdata = . ; __data_start = . ; *(.rodata) *(.data) _edata = ALIGN(0x4) ; } > ram .bss BLOCK(0x4) : { _sbss = . ; *(.bss) *(COMMON) _ebss = ALIGN(0x4) ; _end = ALIGN(0x4) ; } > ram __main = main; } ------------------------------------------------------------- -- Bob Brusa [email protected] Chapfwiesenstr. 14 ph: +4144 926 74 74 CH-8712 Stäfa fx: +4144 926 73 34 --- [email protected] Send a post to the list. [email protected] Join the list. [email protected] Join the list in digest mode. [email protected] Leave the list. --- [email protected] Send a post to the list. [email protected] Join the list. [email protected] Join the list in digest mode. [email protected] Leave the list.