Close

Software Build Toolchain

A project log for 68K CPU with Frame Buffer on FPGA

Working with AMR's build and improvements to the TG68 FPGA project

land-boards.comland-boards.com 09/07/2020 at 16:200 Comments

Assembler

C Compiler

Build environment

Example Software

Makefile for Rectangles code

ARCH    = 68000
BASE    = /opt/m68k-elf/bin/m68k-elf
CC      = $(BASE)-gcc
LD      = $(BASE)-gcc
AS      = $(BASE)-as
CP      = $(BASE)-objcopy
DUMP    = $(BASE)-objdump
VASM    = ../../../vasm/vasmm68k_mot

# we use crt0.s from here
STARTUP_DIR = ../../Firmware_Common
COMMON_DIR = ../../Firmware_Common

BUILD_DIR=m68k_obj

STARTUP_SRC = $(STARTUP_DIR)/startup_app.s  $(STARTUP_DIR)/premain.s
STARTUP_OBJ = $(patsubst $(STARTUP_DIR)/%.s,$(BUILD_DIR)/%.o,$(STARTUP_SRC))

COMMON_SRC = vga.c uart.c interrupts.c
COMMON_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(COMMON_SRC))

MAIN_PRJ = Rectangles
MAIN_C_SRC = rectangles.c
MAIN_C_OBJ = $(patsubst %.c,$(BUILD_DIR)/%.o,$(MAIN_C_SRC))

MAIN_S_SRC = draw.s
MAIN_S_OBJ = $(patsubst %.s,$(BUILD_DIR)/%.o,$(MAIN_S_SRC))

MAIN_OBJ = $(COMMON_OBJ) $(MAIN_C_OBJ) $(MAIN_S_OBJ)

LINKMAP  = $(STARTUP_DIR)/ldscript_app.ld


# Commandline options for each tool.

CFLAGS  = -m$(ARCH) -I. -c -O6 -DDISABLE_UART_RX -I$(COMMON_DIR)

LFLAGS  = -m$(ARCH) -nostartfiles -Wl,--relax -O6


# Our target.
all: $(BUILD_DIR) $(MAIN_PRJ).sre $(MAIN_PRJ).rpt

clean:
    rm -f $(BUILD_DIR)/*.o *.elf *.sre *.rpt *.map *.lst *.srec *~ */*.o *.bin


# Convert ELF binary to bin file.
%.sre: %.elf
    $(CP) -O srec $< $@

%.rpt: %.elf
    echo >$@ -n "End of code:\t"
    $(DUMP) -x $< | grep >>$@ _romend
    echo >>$@ -n "Start of BSS:\t"
    $(DUMP) -x $< | grep  >>$@ __bss_start__
    echo >>$@ -n "End of BSS:\t"
    $(DUMP) -x $< | grep >>$@ __bss_end__
    cat $@

# Link - this produces an ELF binary.

$(MAIN_PRJ).elf: $(STARTUP_OBJ) $(MAIN_OBJ)
    $(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)

$(BUILD_DIR)/%.o: %.c Makefile
    $(CC) $(CFLAGS)  -o $@ -c $<

$(BUILD_DIR)/%.o: $(COMMON_DIR)/%.c Makefile
    $(CC) $(CFLAGS)  -o $@ -c $<

$(BUILD_DIR)/%.o: %.s
    $(VASM) -Felf -o $@ $<

$(BUILD_DIR)/%.o: $(STARTUP_DIR)/%.s
    $(VASM) -Felf -o $@ $<

$(BUILD_DIR):
    mkdir $(BUILD_DIR)

Discussions