Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Makefiles for use outside of wixel-sdk


#1

Hi

As i want to compile and manage my applications outside of the wixel-sdk I have created to makefiles that can be used. They are based on the makefiles provided in the SDK.
Only tested on a Linux host…

One is to be placed on your top level and is called Makefile.common, the other is to be placed in your application directory (one copy per application), and is called Makefile.

For some reason you can’t add Makefiles as attachements, so here they are…

Any comments are welcome!

br
Mattias

Makefile

[code]APP_SRC = main.c
APP_LIBS = dma.lib radio_mac.lib radio_queue.lib radio_registers.lib random.lib usb.lib usb_cdc_acm.lib wixel.lib gpio.lib adc.lib

WIXEL = 11-2A-8A-25

include …/Makefile.common[/code]

Makefile.common

[code]# ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####

Based on Wixel SDK Makefile

CC := sdcc # # C compiler: creates object files (.rel) from C files (.c)
AS := sdas8051 # # Assembler: creates object files (.rel) from assembly files (.s)
AR := sdcclib # # Librarian: creates .lib
LD := sdld # # Linker: creates .hex files from .rel/.lib files)
PACKIHX := packihx # makes .hex files smaller

WARNING := --disable-warning 110

##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####

WIXEL_UTILS = /proj/Private/Wixel/wixel_linux
WIXEL_SDK = /proj/Private/Wixel/wixel-sdk/libraries

C_FLAGS = --debug --std-sdcc99 --Werror -Wp,-MD,$(@:%.rel=%.d),-MT,$@,-MP -I $(WIXEL_SDK)/include -Wa,-p --model-medium
AS_FLAGS = -p
PPC_FLAGS = -Wp,-o,$@
LD_FLAGS = --debug --model-medium --code-loc 0x0400 --code-size 0x7400 --iram-size 0x0100 --xram-loc 0xF000 --xram-size 0xF00 -L $(WIXEL_SDK)/lib

C_FLAGS += --debug

LD_FLAGS += --debug

APP_RELS := $(patsubst %, .repository/%,$(patsubst %.s,%.rel, $(patsubst %.c,%.rel, $(APP_SRC))))
APP_LIBS := $(foreach lib, $(APP_LIBS), $(WIXEL_SDK)/lib/$(lib))

MODULES

RELs += $(APP_RELS)
HEXs += $(APP).hex

FILES TYPES

.c : This is a file that contains source code in the C language.

.h : Header file in the C language (part of the source code).

.s : Assembly language source code.

.rel : This is an Object file, the result of compiling a .s or .c file.

.lib : This is a library (a collection of several object files).

.hex : This is a complete program that can be loaded onto a Wixel.

The lists of all .rel/lib/hex files compiled by this Makefile are in the

following variables: $(RELs) $(LIBs) $(HEXs)

These files are generated when compiling a .c file.

Ds := $(RELs:%.rel=%.d) # .d : dependency information
CDBs := $(RELs:%.rel=%.cdb) # .cdb : debugging information
ADBs := $(RELs:%.rel=%.adb) # .adb : debugging information
ASMs := $(RELs:%.rel=%.asm) # .asm : assembly generated by compiler

These files are generated when compiling a .s or .c file.

SYMs := $(RELs:%.rel=%.sym) # .sym : symbol table
LSTs := $(RELs:%.rel=%.lst) # .lst : listing without absolute addresses
RSTs := $(RELs:%.rel=%.rst) # .rst : listing with absolute addresses

These files are generated when linking:

MEMs := $(HEXs:%.hex=%.mem) # .mem : summary of memory usage
MAPs := $(HEXs:%.hex=%.map) # .map : list of all addresses and memory sections
LKs := $(HEXs:%.hex=%.lk) # .lk : args used by the linker
LNKs := $(HEXs:%.hex=%.lnk) # .lnk : args used by the linker (prior to SDCC 3.1.0)
CDBs := $(HEXs:%.hex=%.cdb) # .cdb : debugging information
OMFs := $(HEXs:%.hex=%) $(HEXs:%.hex=%.omf) # .omf : had no extension prior to SDCC 3.1.0

These files can be generated from a .hex and .cdb file.

WXLs := $(HEXs:%.hex=%.wxl) # .wxl : Wixel application
WXLs += $(HEXs:%.hex=%.wxl.tmp)

TARGETS

TARGETS += $(RELs) $(HEXs)

APP = .repository/application

all: $(TARGETS) $(APP)

.PHONY: clean
clean:
-@rm -f ~
-@rm -f .repository/

IMPLICIT RULES

.repository/%.rel: %.c
$(CC) $(C_FLAGS) -c $< -o $@

.repository/%.rel: %.s
$(AS) -glos $(AS_FLAGS) $<

%.lib:
@true

rm -f $@

$(AR) $@ $^

.repository/%.wxl: .repository/%.hex
@echo Packaging $@
@echo Pololu Wixel Application - www.pololu.com> $@.tmp
@echo 1.0>> $@.tmp
@echo ====== license>> $@.tmp
@cat $(WIXEL_SDK)/…/LICENSE.txt >> $@.tmp
@echo ====== cdb>> $@.tmp
@grep param $(<:%.hex=%.cdb) >> $@.tmp || echo “(This app has no params.)”
@echo ====== hex>> $@.tmp
@$(PACKIHX) $< >> $@.tmp
@sed -f $(WIXEL_SDK)/dos_newlines.sed $@.tmp > $@
@rm $@.tmp

.repository/%.hex: $(APP_RELS) $(APP_LIBS)
$(CC) $(LD_FLAGS) -o $(@:%.hex=%.ihx) $(WIXEL_SDK)/xpage/xpage.rel $^
@mv -f $(@:%.hex=%.ihx) $@

.PHONY : $(APP)
$(APP) : $(APP).wxl

.PHONY : ,list
,list:
$(WIXEL_UTILS)/wixelcmd list

.PHONY : ,load
,load : $(APP).wxl
$(WIXEL_UTILS)/wixelcmd write $< -d $(WIXEL) || true

.PHONY : ,open
,open_$(APP) : $(APP).wxl
$(WIXEL_UTILS)/wixelconfig $<

-include $(Ds)
[/code]


Wixel Apps
#2

Hello, Mattias.

Thanks for sharing your Makefiles to build Wixel apps outside of the Wixel SDK! We have added a link to your post to the list of Wixel apps on our forum.

- Amanda