Compiling code using the command line (instead of an Integrated Development Environment like DevC++) generally requires typing line entry with a large number of 'switches' (parameters entered after the command to tell it what to do). We may have to repeat this for several files, and in a particular order, if we want the program to work. To make the whole process easier, you can use a 'makefile'.
A makefile is like an old DOS batch file, but is read by make.exe, rather than the operating system. The makefile contains all the switches and decisions you would have to make manually, so using it saves a lot of time if you are going to compile your code more than once. Makefiles can do things like create 'dependencies', such as "if file X has been altered, then check the state of file Y to make sure it is up-to-date as well". Phil's code contains a number of switches (like -m68hcs12) and dependencies (these are the tabbed lines), and should not need many changes in most cases.
Here's a listing of Phil's Makefile:
#******************************************************************* #* Makefile for MSII #* #* COPYRIGHT: Philip L Johnson 2004 #* This header must appear on all derivatives of this file. #* #******************************************************************* CC = /usr/local/m6812-elf/bin/m6812-elf-gcc OBJCOPY = /usr/local/m6812-elf/bin/m6812-elf-objcopy OBJDUMP = /usr/local/m6812-elf/bin/m6812-elf-objdump CFLAGS = -g -Os -Wall -fomit-frame-pointer -m68hcs12 -mshort -msoft-reg-count=32 -mauto-incdec -DGCC_BUILD LDFLAGS = -Wl,-defsym,vectors_addr=0xff80,-m,m68hc12elfb CSRCS=main.c ASRCS=vectors.s msii_flash_gcc.s OBJS=$(CSRCS:.c=.o) AOBJS= $(ASRCS:.s=.o) all: msii.dmp msii.elf msii.s19 $(AOBJS): %.o: %.s $(CC) $(CFLAGS) -c $< $(OBJS): %.o: %.c cltfactor.inc egofactor.inc matfactor.inc hcs12def.h flash.h $(CC) $(CFLAGS) -c $< msii.elf: $(OBJS) $(AOBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o msii.elf $(OBJS) $(AOBJS) msii.s19: msii.elf $(OBJCOPY) --output-target=srec --only-section=.text \ --only-section=.rodata --only-section=.vectors --only-section=.eeprom \ msii.elf msii.s19 msii.dmp: msii.elf $(OBJDUMP) -Ssdp msii.elf > msii.dmp .PHONY: clean clean: $(RM) -f msii.elf $(RM) -f msii.s19 $(RM) -f msii.dmp $(RM) -f $(OBJS) $(AOBJS) |
For more on makefiles, click this link.
Note that you can change your 'environment variables' so that you don't have to type the path command every time you open a command prompt. You do this by right clicking on 'My Computer' and selecting 'Environment Variables' button under 'Advanced'. Find "Path=..." in the system variables, click it and add c:\cygwin\usr\local\m6812-elf\bin;C:\cygwin\bin\; to the end of whatever is already there.If you use Windows95/98/Me, you may need to open the 'autoexec.bat' file in the 'c:\' directory and edit the 'Path=" statement there to include c:\cygwin\usr\local\m6812-elf\bin;C:\cygwin\bin\; (add these to the end, don't delete anything that might be there), then reboot.
Typing 'make+<enter>' runs the make.exe file in the C:\cygwin\bin directory, but acts on the makefile in the current directory (which you navigated to above). The compiled .s19 file will be located in the folder where the source files are located (i.e., the current directory). It will be called msii.s19, but you can change the name by editing the Makefile or simply by renaming the msii.s19 file after compiling.The MegaSquirt-II Code Downloader
You can also run the code downloader for MegaSquirt-II .s19 files independently of DevC++, either in a GUI version or from the command line.
You can find the downloader installer (that transfers the file over the serial port to MegaSquirt-II, sort of like download.exe for Megasquirt) and source zip at www.not2fast.com/megasquirt/ms2dl/. It requires that your processor have the serial monitor installed, and will not work with blank processors (much like the bootloader code in MegaSquirt). It is known to work with code generated by both CodeWarrior and GCC.
The scripts and other support files for using Inno Setup to create the installer can be found in gms2dl_installer.zip. (If you get Inno Setup, also install the QuickStart Pack.)
The installer itself is in ms2dl200_setup.exe.
To use the downloader,