[Sdcc-user] Can't link a simple example using PIC16 with SDCC : ASlink no definition of area errors
I'm currently trying to use SDCC to generate an Intel Hex file for a PIC16 device (pic18f452). I'm using a Makefile and multiple source files, to be compiled separately and linked at the end. This is my Makefile setup: CFLAGS=--std-c99 --use-non-free -mpic16 LDFLAGS=--out-fmt-ihx build/image.hex: build/main.rel build/lcd.rel sdcc -o build/image.hex $^ build/main.rel: main.c lcd.h sdcc $(CFLAGS) -c $< -o $@ build/lcd.rel: lcd.c lcd.h sdcc $(CFLAGS) -c $< -o $@ The source files are as simple as it gets: *lcd.h:* #ifndef _LCD_H_ #define _LCD_H_ void lcd_init(void); #endif *lcd.c:* #include #include "lcd.h" void lcd_init(void) { PORTEbits.RE1 = 0; PORTEbits.RE2 = 0; } *main.c:* #include #include "lcd.h" void main() { lcd_init(); while (1); } Running make gives me the following (warnings?) errors, from the linking stage: ASlink-Warning-No definition of area HOME ASlink-Warning-No definition of area XSEG ASlink-Warning-No definition of area PSEG And I don't get my output. If I concatenate all my code into one file and run sdcc on it, however, it works: $ cat lcd.h lcd.c main.c > *monster.c* $ sdcc --use-non-free -mpic16 monster.c message: Using default linker script "/usr/share/gputils/lkr/18f452_g.lkr". $ ls lcd.c lcd.h main.c Makefile monster.asm monster.c monster.cod *monster.hex* monster.lst monster.o Is there some other setup I should be doing, or flag I should be passing? I'm not really using any ASM code or defining my own areas, and expected it to work out-of-the-box with C. Are my assumptions wrong? Sorry for the long message, hope to hear soon Thanks in advance, Délisson J. G. Silva -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user
Re: [Sdcc-user] Can't link a simple example using PIC16 with SDCC : ASlink no definition of area errors
Sorry don't have time to look at this, but on this page you find my project complete with Makefile that should compile out of the box with SDCC so if you look at the Makefile it might help you. http://www.sparetimelabs.com/usbcdcacm/usbcdcacm.php Below is the relevant part from that Makefile. cheers Kusti # The source files that make up the project go here SRCS = main.c usbcdc.c printft.c # The libraries that are used go here LIBS = libc18f.lib libio18f4550.lib libm18f.lib libsdcc.lib # Where to find the compiler SDCC = /Users/nyholku/sdcc-3.2.0/bin/sdcc # Compiler flags go here SDCCFLAGS = -V -L /Users/nyholku/sdcc-3.2.0/share/sdcc/non-free/lib/pic16 -Wl,-m,-s18f4550.lkr -mpic16 -p18f4550 --disable-warning 85 --std-sdcc99 --obanksel=3 --use-non-free # Where to store the target/intermediate/temporary/object files OBJDIR = ../obj # Compile the C-files $(OBJDIR)/%.o: %.c $$(@D)/.f $(SDCC) -c $(SDCCFLAGS) $< -o $@ # Link the compiled files and libraries $(OBJDIR)/$(TARGET): $(addprefix $(OBJDIR)/, $(SRCS:.c=.o)) $(SDCC) $(SDCCFLAGS) -o $(OBJDIR)/$(TARGET) $(addprefix $(OBJDIR)/, $(SRCS:.c=.o)) $(LIBS) > -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot ___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user
Re: [Sdcc-user] Can't link a simple example using PIC16 with SDCC : ASlink no definition of area errors
On Fri, 16 Dec 2016, Délisson Gonçalves wrote: I'm currently trying to use SDCC to generate an Intel Hex file for a PIC16 device (pic18f452). I'm using a Makefile and multiple source files, to be compiled separately and linked at the end. This is my Makefile setup: CFLAGS=--std-c99 --use-non-free -mpic16 LDFLAGS=--out-fmt-ihx build/image.hex: build/main.rel build/lcd.rel sdcc -o build/image.hex $^ build/main.rel: main.c lcd.h sdcc $(CFLAGS) -c $< -o $@ build/lcd.rel: lcd.c lcd.h sdcc $(CFLAGS) -c $< -o $@ The source files are as simple as it gets: lcd.h: #ifndef _LCD_H_ #define _LCD_H_ void lcd_init(void); #endif lcd.c: #include #include "lcd.h" void lcd_init(void) { PORTEbits.RE1 = 0; PORTEbits.RE2 = 0; } main.c: #include #include "lcd.h" void main() { lcd_init(); while (1); } Running make gives me the following (warnings?) errors, from the linking stage: ASlink-Warning-No definition of area HOME ASlink-Warning-No definition of area XSEG ASlink-Warning-No definition of area PSEG And I don't get my output. If I concatenate all my code into one file and run sdcc on it, however, it works: $ cat lcd.h lcd.c main.c > monster.c $ sdcc --use-non-free -mpic16 monster.c message: Using default linker script "/usr/share/gputils/lkr/18f452_g.lkr". $ ls lcd.c lcd.h main.c Makefile monster.asm monster.c monster.cod monster.hex monster.lst monster.o Is there some other setup I should be doing, or flag I should be passing? I'm not really using any ASM code or defining my own areas, and expected it to work out-of-the-box with C. Are my assumptions wrong? Sorry for the long message, hope to hear soon Thanks in advance, Délisson J. G. Silva The compiler uses different assembler/linkers depending on the target microcontroller. You need to also include -mpic16 when linking so that sdcc knows to invoke gplink instead of aslink. This is why it was successful for monster.c but not when linking separately from compiling. Erik-- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot___ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user