Dear all,
Being an old Unix fan, I have a taste for "small is beautiful", agile, smart and flexible development tools. I hate bloated, over-built, heavy, complex software like pest! As an example, for my PIC16 projects I am very satisfied with a combination of the fantastic
CC5X (see elsewhere in the forum for a cured version) running under wine, together with
gpasm for final assembly and the marvelous
sublime editor. All of them run like a charm on my mighty eeePC 901 under ArchLinux.
I had quite a difficulty when starting to build a comparable toolchain for the PIC18. To me, available professional tools like Hi-Tech picc-18 are out of the question. Why should I spend more than 350 mB of my limited disk space just for a simple C compiler? And alternatives are difficult to locate. CC8E, the PIC18 brother of CC5X, works but is limited (a full version is not available to my knowledge). Also, I found a few bugs in it after some tests. An interesting project is SDCC (Small Device C Compiler), however its PIC backend apparently still struggles with some bugs.
However I discovered yet another alternative, new to me: the CPIK PIC 18 C compiler. It is a full-fledged (near) ANSI compiler developed by a small but active team. Download is here:
http://pikdev.free.fr/. Installation takes only a few seconds after downloading and expanding the archive:
tar zxf cpik-0.7.1-1.tar.gz
cd cpik-0.7.1
g++ -o cpik-0.7.1 *.cpp
su #be root now
mv cpik-0.7.1 /usr/bin
ln -s /usr/bin/cpik-0.7.1 /usr/bin/cpik
mkdir /usr/share/cpik
cp -R 0.7.1/ /usr/share/cpik
Total size is 15 mB (the compiler itself is only 1 mB).
This compiler comes with a well-written, detailed documentation and a few tutorials. A small number of libraries for peripherals are included as well. Of course I did some LED blinking but first a suitable Makefile is needed:
##############################################################################
#
# generic Makefile for CPIK with gputils
# Daniel 2012
#
# designed for GNU make
#
#
##############################################################################
##############################################################################
# project-specific settings, configure for each project
##############################################################################
# target PIC processor (syntax: 16f84):
PROC = 18f2550
# source files:
SOURCES = blink.c
# burnable target:
PROG = blink.hex
##############################################################################
# installation-dependant settings, configure once for your host
##############################################################################
# nothing to do
##############################################################################
# general settings & rules - DO NOT MODIFY
##############################################################################
# list of object files:
OBJS = $(SOURCES:.c=.slb)
# final asm after link before hex
ASM = $(PROG:.hex=.asm)
# compiler used to compile source files.
CC = cpik
# asssembler used to produce object files.
AS = gpasm
# the linker.
LD = cpik
# Compiler flags go here.
CFLAGS = -p$(PROC) -I /usr/share/cpik/0.7.1/include/device
# Assembler flags:
ASFLAGS = -L -w 2
# Linker flags go here.
LDFLAGS = -p p$(PROC)
# top-level rule to compile everything.
all: $(PROG)
# rule for assembling the asm file and getting the hex
$(PROG): $(ASM)
$(AS) $(ASFLAGS) -o $(PROG) $(ASM)
# link rule getting the asm file
$(ASM): $(OBJS)
$(LD) $(LDFLAGS) -o $(ASM) $(OBJS)
# meta-rule for compiling any C source file.into .slb
%.slb: %.c
$(CC) $(CFLAGS) $<
# make clean & tidy
clean:
$(RM) *.asm *.c.c *.lst *.hex *.cod *.slb
burn: $(PROG)
pk2cmd -P -M -F $(PROG)
I used the LED blinking program provided with the compiler, no need to reproduce it here. The code looks sound and compact. Generally this compiler follows a straightforward stack machine strategy without too much optimizing machinery.
Of course my LED blinks
At this stage I would still like to validate this tool with a bigger project. Also, some code size benchmarks would be interesting. All in all, I think that the CPIK project is very interesting, filling a real gap in PIC software tooling. I hope that others in the community will find this compiler appealing and enlarge its user base.
I'll come back as soon as I'll have more testing results.