Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 24, 2024, 11:41:43 11:41


Login with username, password and session length


Pages: [1]
Print
Author Topic: cpik PIC 18 C compiler preliminary test  (Read 5828 times)
0 Members and 1 Guest are viewing this topic.
danielausparis
Inactive

Offline Offline

Posts: 3

Thank You
-Given: 4
-Receive: 1


« on: June 25, 2012, 07:48:12 19:48 »

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:

Code:
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:

Code:
##############################################################################
#
#     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 Cheesy

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.
« Last Edit: June 25, 2012, 10:20:08 22:20 by danielausparis » Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #1 on: June 25, 2012, 08:58:18 20:58 »

nICE tutorial, but I believe that CC5x you are using is outdated, since 2009.

Hi-Tech PICC is not heavy, bloated or even complex software. It is available for Linux, why don't you try it, it is available on the forum. I don't think it takes as much space as 350MB! I agree that CC5x is an excellent compiler and used to produce smaller hex, but I think that PICC recent versions are much better than the version you are sticking to now...

Logged
danielausparis
Inactive

Offline Offline

Posts: 3

Thank You
-Given: 4
-Receive: 1


« Reply #2 on: June 25, 2012, 09:25:30 21:25 »


Dear Metal,

I'm fine with outdated software when it's small, simple, blazingly fast and produces clean, super-compact code Cheesy

I'm not ok with new software when it's HUGE, slow as a snail, and with average results. This is just poor software engineering.

My PICC (on an office machine) is current, and it's really 350 mB  Shocked

Code:

du -b /opt/hitech/picc-18/
[...]
351317607       /opt/hitech/picc-18/


Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC