APMIPS Toolchain Guide
Please let me know about any bugs austind(at)berkeley
To begin using the APMIPS toolchain you must first ssh into icom1.eecs.berkeley.edu , from the lab computers in 125 Cory, open Cygwin and type the following at the bash prompt(Note: this guide assumes bash or a bashlike shell)
ssh cs150-xx@icom1.eecs.berkeley.edu
Next run
cp -r ~cs150/install/build-template helloworld
This will copy the template build files from the cs150 home directory to a new folder named helloworld , in this folder you will find some important files needed to make a working build for the APMIPS processor.
start.s : the C main function kickoff stub, read the comments
isr.s : an interrupt handler stub, again read the comments
template.ld
Makefile
To quickly get started, edit the TARGET in the Makefile , then simply create a new .c or .s file, and add it to the appropriate CSRCS or ASSRCS variable in the Makefile . You should be able to compile by typing
make
If everything goes well there will be two files name $(TARGET).text.hex and $(TARGET).data.hex , these are the hex files for your instruction and data memories formatted and padded to XST's picky standards.
This file is used to map the binary to a scheme that matches our memory map. It fixes up address to point to the right place, and groups together object files for us
. = 0x00400000;
This sets the current address in the binary file to be 0x00400000 , the beginning of my instruction memory. The next piece
.text :
{
start.o(.text)
isr.o(.text)
*(.text)
}
This says to start the text section with the text from the object file assembled from start.s (our stack pointer setup, and main jump) and follow that with the text from the isr.o file generated from isr.s . Since start.s . has 3 instructions in it, the isr is placed at 0x0040000C . If you would like to force an address from the isr you can do something like this
.text :
{
start.o(.text)
}
. = 0x00400180;
.text :
{
isr.o(.text)
*(.text)
}
The next bit sets up the data memory, starting at 0x10010000 , the scripts instructs the linker to grab the relevant sections from the object files and combine them together
. = 0x10010000;
.data :
{
*(.rodata)
*(.data)
*(.bss)
}
The first line of interest in this file is
TARGET=template
This lets you set the TARGET variable, which determines the name of the final binary as well as the name of the linker script used to link the final binary, $(TARGET).ld
CSRCS=main.c
This line lets you specify the C files to build as a part of your project
ASSRCS=start.s isr.s
This line lets you specify the assembly files to build as a part of your project
TOOLCHAINPATH=~cs150/install
This line sets the location of the toolchain
ASFLAGS=
CFLAGS=-std=c99 -O3 -I$(TOOLCHAINPATH)/include
LDFLAGS=-static -T$(TARGET).ld -nostdlib -L$(TOOLCHAINPATH)/lib -lcs150
These lines specify the flags passed to the various tools. As you can see libcs150 is always linked in. If you are not using any of libcs150 I suggest you remove the -lcs150 . Overall this Makefile will automatically build all the files specified in the CSRCS and ASSRCS variables, and link them together in the manner specified by the $(TARGET).ld file. It then runs this binary through verilog2hex program that converts the binary into a format that XST can understand.
$(CAT) $(TARGET).ver | $(VERILOG2HEX) $(TARGET) 16 16
If you have a different number of bits of address for your instruction or data memory, change this line.
$(CAT) $(TARGET).ver | $(VERILOG2HEX) $(TARGET) N M
Where N are bits of instruction memory address and M are bits of data memory address.
verify: $(TARGET).elf
$(TOOLCHAINPATH)/apmipsverify $(TARGET).elf
All this make target does is run a filter over the output of mips-objdump you will need to manually inspect it for instructions that make it through the filter. Any instructions that show up in the listing are unimplemented, and will most likely break the processor. To verify the binary run
make verify
mkdir apmips-build
cd apmips-build
wget http://inst.eecs.berkeley.edu/~cs150/fa10/Project/apmipstoolchain.sh
chmod +x apmipstoolchain.sh
PREFIX=`pwd` ./apmipstoolchain.sh setup
|