- Note:
- We describe the development environment for linux and possibly other unices here. It is also possible to use cygwin for win32.
The development consists of 3 main steps:
- write your code, compile and link
- convert resulting object yourapp.elf into yourapp.trb - Turbo application object format
- upload yourapp.trb with the prog_apps utility.
For development and building of Turbo applications you need the following tools:
- gcc - GNU project C compiler configured for AVR architecture
- binutils - GNU project set of utilities for linking and object code manipulation configured for AVR architecture; application specific format --turbo support patch by BLADOX
- turbo-devel - package containing Turbo Adapter specific libc and headers
- turbo-prog-utils - package containing Turbo Programmer headers and linker scripts
As for gcc you can use the vanilla gcc from any GNU mirror, binutils have to be patched to provide turbo specific binary application format.
The binutils and turbo-devel packages can be found on http://www.bladox.com/.
Untar and ./configure --target=avr
make
make install
installs all the AVR binutils into /usr/local/.
Untar and ./configure --target=avr --enable-languages=c
make
make install
installs all the AVR gcc into /usr/local/.
Untar the package somewhere (and use this path in Makefiles).
Untar the package somewhere (and use this path in Makefiles).
- Example of Makefile
ifndef TPROG_DIR
TPROG_DIR = ../../../
endif
ifndef TURBO_DIR
TURBO_DIR := ../../../../../turbo-devel
endif
TURBO_TAG = #--turbo-manifest "Version: 2.0.0 Vendor: BLADOX" #--turbo-verbose
INCDIR = -I$(TPROG_DIR)/include -I.
LIBDIR = $(TURBO_DIR)/lib
CC = avr-gcc
LD = avr-ld
RM = rm -f
TRG = YOUR_TARGETNAME
SRC = YOUR_SOURCE1.c YOUR_SOURCE2.c ... YOUR_SOURCEn.c
LIB =
CFLAGS = -std=gnu99 -mmcu=atmega128 -mno-tablejump -Wimplicit-function-declaration -Os -fno-builtin
LDFLAGS = -L$(LIBDIR) -T $(TPROG_DIR)/lib/turbo.lds -d -r --emit-relocs -R $(TPROG_DIR)/lib/public_calls $(LIB) -lm -lc `avr-gcc -print-libgcc-file-name`
OBJ = $(SRC:.c=.o)
all: $(TRG).trb
include $(SRC:.c=.d)
%.o : %.c
$(CC) -c $(CFLAGS) $(INCDIR) $< -o $@
%.d: %.c
$(CC) -M $(CFLAGS) $(INCDIR) $< | sed 's/$*.o/& $@/g' >$@
$(TRG).elf: $(OBJ)
$(LD) -o $@ $(OBJ) $(LDFLAGS)
$(TRG).trb: $(TRG).elf
avr-objdump $(TURBO_TAG) --turbo $(TRG).elf
dis: $(TRG).elf
avr-objdump -D --architecture=avr:5 $(TRG).elf >$(TRG).dis
indent:
for X in $(SRC); do \
indent -npsl -sob -bad -bli0 -cli2 $$X; \
done
install: all
cp $(TRG).trb ../../../modules
clean:
$(RM) *.o
$(RM) *.d
$(RM) *~
$(RM) $(TRG).dis
$(RM) $(TRG).elf
$(RM) $(TRG).trb
Meaning of CFLAGS:
- -fno-builtin - to avoid usage of compiler internal strlen, etc.
- -std=gnu99 - to avoid some warnings
- -Wimplicit-function-declaration - it is really good to avoid implicit function declaration (code may be worse)
- -Os - optimize for size. For us size is more important than anything else.
- -mmcu=atmega128 - desired target
- -mno-tablejump - do not use tablejumps, they cause only problems
Meaning of LDFLAGS:
- -Tdata 0x800000 - starting address of the data section
- -T /lib/turbo.lds - use linker script turbo.lds
- -R /lib/public_calls - read symbol names and their addresses from .../public_calls
- --emit-relocs - leave relocations sections in fully linked executable
- -d - assign space to commons symbols even if -r
- -r - generate relocatable output
trb and elf are created, dis when "make dis"
Assume that you have built your application and the result is helloworld.trb file. To upload the object use the prog_apps utility.
prog_apps -u helloworld.trb
Copyright © 2004 BLADOX
| Turbo Programmer version 2.0
|