Automation
(Last updated: Saturday February 24, 2007)
Using C18, C-Stamp and the Bol-Bot via Linux
Currently this page was quickly thrown together and is not really really representative of what is needed to be done. I'll get everything posted in the next month or two.
I
am currently waiting on this robot: the BOL-BOT Full Kit -
Serial and USB Connectors - This is the robot I recently
picked up.
The purpose of this page is to explain what you need to do to compile and download your C code to the A-WIT BOL-BOT Kit.
Here are some of the things you'll need:
- Linux - a recent version is a good idea
- Wine
- make
- Microchips' C18 C compiler (C18)
- A-WIT's C library (Code_Module_Library)
Please don't ask me for the C18 or Code_Module_Library software as I won't send it to you. Both packages can be found on the CD that accompanied the Bol-Bot kit.
Both packages were installed using Wine.
Here's my Makefile for compiling a rather simple C program. I'll post the more elaborate one for compiling Bol-Bot code at a later date. This makefile is here for informational purposes until I get the other one built. At the moment I may be on special assignment and I don't know when I'll be back.
#************** Example Makefile *********************** # # 2009/04/04 ncherry@linuxha.com # # The OBJFILES variable is filled with .o targets using the wildcard # command and patsubst. The $(wildcard *.c) will retrieve any .c # file in the current directory and store it in a variable. The patsubstr # functions is used to convert a file from one format to another. In # this case each .c file is converted into a .o extension and then # stored into OBJFILES. This variable is then used to compile each .c file. # The rule %.o: %.c rebuilds any .o file if the cooresponding .c file has # changed. # # In the compile line you will see two variables $@ and $<. # $@ will match the target and the $< will match the dependency. So, for # example, $< will contain main.c whenever $@ contains main.o. # Note: makefiles are counterintuitive in that the rules don't run in the order # listed in the file, but instead run whenever they are matched. # Also be careful with tabs and spaces. Rules need a tab (not spaces) # before each action. #RENAME AS NEEDED PROJECT=main #del for windows, rm for unix #RM := del /F RM := rm -f # Run under wine so use a DOS path LIB_PATH="c:\mcc18\lib" #LINKER = mplink #CC = mcc18 CC = wine mcc18 -p=18f4550 LINKER = wine mplink LINK = $(LINKER) "18f4550.lkr" $(OBJFILES) /l $(LIB_PATH) /m $(PROJECT).map /o $(PROJECT).hex PICFLAG = "-p=18F8520" CFLAGS = -i"C\:PROGRA~1\mcc18\h" -nw=2066 DEFINES = -D_FRC_BOARD -D_PRIORY_CAMERA #optimization parameters (default = full optimization) OPT_ENABLE_ALL= OPT_DEBUG=-Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- OPT=$(OPT_ENABLE_ALL) # ---------------------------------------------------------------------------- #make a list of object files that match all C files OBJFILES := $(patsubst %.c,%.o,$(wildcard *.c)) COMPILE=$(CC) $(PICFLAG) $< -fo=$@ $(CFLAGS) $(DEFINES) $(OPT) all: $(PROJECT).hex #re-link if any object file changed $(PROJECT).hex: $(OBJFILES) $(LINK) # $(LINKER) "18f4550.lkr" $(OBJFILES) /l $(LIB_PATH) /m $(PROJECT).map /o $(PROJECT).hex # $(LINKER) "18f8520user.lkr" $(OBJFILES) "FRC_library.lib" /l $(LIB_PATH) /m $(PROJECT).map /o $(PROJECT).hex # Recompile a file if it's c-file changes, # OR recompile everything if ANY header file changes %.o: %.c *.h echo $(COMPILE) $(COMPILE) #delete all the build files so you can start from scratch. .PHONY: clean test clean: -$(RM) $(OBJFILES) -$(RM) $(PROJECT).hex -$(RM) $(PROJECT).map -$(RM) $(PROJECT).lst -$(RM) $(PROJECT).cod rm -f *~ core foo test: @/bin/echo @wine cmd <SET.BAT @/bin/echo -e "\n\n$(COMPILE)\n$(LINK)\n"
The entire file (w/ 18f4550.lkr, main.c, Makefile, and SET.BAT) is here (the test file). One little secret I found was to get wine to run batch files I needed to redirect it into a command (cmd) shell and finish it with an exit (see SET.BAT in the test file).