aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-02-23 11:42:19 -0700
committerChristian Cunningham <cc@localhost>2022-02-23 11:42:19 -0700
commit667ee7c7ba26b4c32133dad24031ba30b5db70b0 (patch)
tree2a8f994122f356770038ca753f1420129c62a6a5
parentb5021c723a5ee267982c4779bb1b1d644e4d2d5c (diff)
Makefile Modifications
-rw-r--r--Common.mk72
-rw-r--r--linker.ld5
-rwxr-xr-xtests/test1.bash4
3 files changed, 49 insertions, 32 deletions
diff --git a/Common.mk b/Common.mk
index 9852b2d..66e103c 100644
--- a/Common.mk
+++ b/Common.mk
@@ -1,11 +1,16 @@
C_SOURCES = $(wildcard src/*.c src/**/*.c)
-C_HEADERS = $(wildcard src/*.h src/**/*.h)
C_OBJECTS = ${C_SOURCES:.c=.co}
C_OBJECTD = ${subst src,obj,${C_OBJECTS}}
A_SOURCES = $(wildcard src/*.S src/**/*.S)
A_OBJECTS = ${A_SOURCES:.S=.ao}
A_OBJECTD = ${subst src,obj,${A_OBJECTS}}
+ATTACH_USB ?= 0
+AUTO ?= 0
+BSP ?= 2
+DEBUG ?= 0
+SILENT ?= 0
+
CROSS = arm-none-eabi
CC = ${CROSS}-gcc
AS = ${CROSS}-as
@@ -14,27 +19,45 @@ OBJDUMP = ${CROSS}-objdump
QEMU = qemu-system-arm
GDB = gdb-multiarch
CFLAGS = -mcpu=cortex-a7 -fpic -ffreestanding -std=gnu99 -O3 -Wall -Wextra -nostdlib -Iinclude -g
+CFLAGS += -DVERSION="\"0.1c\""
AFLAGS = -mcpu=cortex-a7 -Iinclude -g
QFLAGS = -M raspi2b -cpu cortex-a7 -m 1G
-#QFLAGS += -chardev stdio,id=char0,mux=on,logfile=serial.log,signal=off -serial chardev:char0 -mon chardev=char0
-QFLAGS += -chardev pipe,id=char0,mux=on,logfile=serial.log,path=guest -serial chardev:char0 -mon chardev=char0
-QFLAGS += -device usb-kbd
-ifneq ("$(wildcard ./sd.hda)","")
- QFLAGS += -drive file=sd.hda,if=sd,format=raw
+
+# Attach USB if requested
+ifneq ("$(ATTACH_USB)","0")
+ QFLAGS += -device usb-kbd
+ QFLAGS += -trace events=events
endif
-#QFLAGS += -trace events=events
-#QFLAGS += -nographic
-BSP ?= 2
+# Use Automation Pipe if requested
+ifneq ("$(AUTO)","0")
+ QFLAGS += -chardev pipe,id=char0,mux=on,logfile=serial.log,path=guest -serial chardev:char0 -mon chardev=char0
+else
+ QFLAGS += -chardev stdio,id=char0,mux=on,logfile=serial.log,signal=off -serial chardev:char0 -mon chardev=char0
+endif
+# Use Correct MMIO Address
ifeq ($(BSP),2)
BSP23 = 1
CFLAGS += -DBSP23
endif
-CFLAGS += -DVERSION="\"0.1b\""
+# Pause and wait for GDB if requested
+ifneq ($(DEBUG),0)
+ QFLAGS += -s -S
+endif
-.PHONY: clean run run-silent run-debug debug export tree disk test
+# Don't use screen if requested
+ifneq ("$(SILENT)","0")
+ QFLAGS += -nographic
+endif
+
+# Attach sd if exists
+ifneq ("$(wildcard ./sd.hda)","")
+ QFLAGS += -drive file=sd.hda,if=sd,format=raw
+endif
+
+.PHONY: clean debug disk dump run test tree
default: clean build/kernel7.img
@@ -42,22 +65,17 @@ build/kernel7.img: build/kernel.elf
@mkdir -p $(@D)
${OBJCOPY} $< -O binary $@
-build/kernel.list: build/kernel-g.elf
+build/kernel.list: build/kernel.elf
@mkdir -p $(@D)
${OBJDUMP} -D $< > $@
-build/kernel-g.elf: ${A_OBJECTD} ${C_OBJECTD}
- @mkdir -p $(@D)
- ${CC} -T linker.ld -o $@ ${CFLAGS} $^
+dump: build/kernel.list
build/kernel.elf: ${A_OBJECTD} ${C_OBJECTD}
@tput setaf 6 2> /dev/null || true; echo Linking Kernel; tput sgr0 2> /dev/null || true
@mkdir -p $(@D)
${CC} -T linker.ld -o $@ -ffreestanding -O3 -nostdlib $^
-export: build/kernel.elf sd.hda
- cp $^ /mnt/c/temp/
-
obj/%.co: src/%.c
@mkdir -p $(@D)
${CC} ${CFLAGS} -c $< -o $@
@@ -70,24 +88,18 @@ run: build/kernel.elf
@tput setaf 6 2> /dev/null || true; echo Starting QEMU; tput sgr0 2> /dev/null || true
@${QEMU} -kernel $< ${QFLAGS}
-run-silent: build/kernel.elf
- @tput setaf 6 2> /dev/null || true; echo Starting QEMU; tput sgr0 2> /dev/null || true
- @${QEMU} -kernel $< -nographic ${QFLAGS}
-
-run-debug: build/kernel-g.elf
- @echo Starting QEMU in Debug Mode
- @${QEMU} -kernel $< -s -S ${QFLAGS}
-
-debug: build/kernel-g.elf build/kernel.list
- ${GDB} $< -command=gdbinit
+debug: build/kernel.list
+ @tput setaf 6 2> /dev/null || true; echo Starting GDB; tput sgr0 2> /dev/null || true
+ @${GDB} $< -command=gdbinit
sd.hda:
- cp README.md sd.hda
- dd if=/dev/zero of=sd.hda count=1 bs=1 seek=16383
+ @cp README.md sd.hda
+ @dd if=/dev/zero of=sd.hda count=1 bs=1 seek=16383
disk: sd.hda
clean:
+ @tput setaf 6 2> /dev/null || true; echo Clearing Build; tput sgr0 2> /dev/null || true
rm -rf obj/* build/*
tree:
diff --git a/linker.ld b/linker.ld
index c97501c..3d84d1c 100644
--- a/linker.ld
+++ b/linker.ld
@@ -43,4 +43,9 @@ SECTIONS
. = ALIGN(4096); /* align to page size */
__bss_end = .;
__end = .;
+ /DISCARD/ : {
+ *(.ARM.attributes*)
+ *(.comment*)
+ *(.debug*)
+ }
}
diff --git a/tests/test1.bash b/tests/test1.bash
index d04af60..4fcebfd 100755
--- a/tests/test1.bash
+++ b/tests/test1.bash
@@ -1,9 +1,9 @@
#!/bin/bash
rm -f l.test1.log
-make run-silent &
+AUTO=1 SILENT=1 make run &
cat guest.out >> l.test1.log &
sleep 0.5
printf "ab" >> guest.in
-sleep 1
+sleep 2
printf "\001x" >> guest.in
sleep 0.5