From aa717685e3e0aa5ea1153ff4aeab2553b4f2ea68 Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Wed, 20 Apr 2022 12:39:40 -0500 Subject: [PATCH] Use our own toolchain instead of the one in the image Now that we are adding our own target we can compile our own toolchain instead of using the stock one. This does mean that there isn't really a purpose to using the alpine cc65 image though --- .gitlab-ci.yml | 18 +++++++++++++++--- .gitmodules | 3 +++ sw/Makefile | 8 ++++++-- sw/bootloader/Makefile | 2 +- sw/cc65 | 1 + sw/kernel/Makefile | 4 ++-- sw/kernel/boot.s | 5 +++-- sw/kernel/exec.c | 2 +- sw/kernel/link.ld | 8 ++++++-- 9 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 .gitmodules create mode 160000 sw/cc65 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e23d983..896d1bb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,20 +3,32 @@ default: - docker stages: + - build_toolchain - build_sw - build_hw - test +build-cc65: + stage: build_toolchain + image: gcc + script: + - cd sw + - make toolchain + build-kernel: stage: build_sw - image: a2geek/cc65-pipeline + image: gcc script: - cd sw/kernel - make + artifacts: + paths: + - sw/cc65/bin + - sw/cc65/lib build-bootloader: stage: build_sw - image: a2geek/cc65-pipeline + image: gcc script: - cd sw/bootloader - make @@ -53,7 +65,7 @@ test_bb_spi: test-sw: stage: test - image: a2geek/cc65-pipeline + image: gcc script: - cd sw/kernel - make test diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..21b2181 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "sw/cc65"] + path = sw/cc65 + url = https://git.byronlathi.com/bslathi19/cc65 diff --git a/sw/Makefile b/sw/Makefile index ee3f485..c379713 100644 --- a/sw/Makefile +++ b/sw/Makefile @@ -1,11 +1,14 @@ .PHONY: all install bootloader kernel clean -all: bootloader kernel +all: toolchain bootloader kernel install: all sh script/format_disk.sh sh script/copy_files.sh +toolchain: + @$(MAKE) -j4 -C cc65 + bootloader: @$(MAKE) -C bootloader @@ -15,4 +18,5 @@ kernel: clean: @$(MAKE) -C bootloader --no-print-directory $@ - @$(MAKE) -C kernel --no-print-directory $@ \ No newline at end of file + @$(MAKE) -C kernel --no-print-directory $@ + @$(MAKE) -C cc65 --no-print-directory $@ \ No newline at end of file diff --git a/sw/bootloader/Makefile b/sw/bootloader/Makefile index bd08961..6f3db2c 100644 --- a/sw/bootloader/Makefile +++ b/sw/bootloader/Makefile @@ -1,4 +1,4 @@ -CC=cl65 +CC=../cc65/bin/cl65 CFLAGS=-T -t none -I. --cpu "65C02" test: CFLAGS=-T -t sim65c02 -I. LDFLAGS=-C link.ld -m $(NAME).map diff --git a/sw/cc65 b/sw/cc65 new file mode 160000 index 0000000..23a984f --- /dev/null +++ b/sw/cc65 @@ -0,0 +1 @@ +Subproject commit 23a984f0ddd00712bb29bc0568e2e14cca637ed8 diff --git a/sw/kernel/Makefile b/sw/kernel/Makefile index bd2124e..5c6da0e 100644 --- a/sw/kernel/Makefile +++ b/sw/kernel/Makefile @@ -1,5 +1,5 @@ -CC=cl65 -CFLAGS=-T -t none -I. --cpu "65C02" +CC=../cc65/bin/cl65 +CFLAGS=-T -t super6502 -I. --cpu "65C02" test: CFLAGS=-T -t sim65c02 -I. LDFLAGS=-C link.ld -m $(NAME).map SIM=sim65 diff --git a/sw/kernel/boot.s b/sw/kernel/boot.s index 8cb6a79..a30963b 100644 --- a/sw/kernel/boot.s +++ b/sw/kernel/boot.s @@ -29,9 +29,10 @@ _init: LDX #$FF ; Initialize stack pointer to $01FF ; --------------------------------------------------------------------------- ; Set cc65 argument stack pointer - LDA #<(__SDRAM_START__ + __SDRAM_SIZE__) + ;LDA #<(__SDRAM_START__ + __SDRAM_SIZE__) + lda #<($200 + $7cf0) STA sp - LDA #>(__SDRAM_START__ + __SDRAM_SIZE__) + LDA #>($200 + $7cf0) STA sp+1 ; --------------------------------------------------------------------------- diff --git a/sw/kernel/exec.c b/sw/kernel/exec.c index 0824eb6..cbf1ccb 100644 --- a/sw/kernel/exec.c +++ b/sw/kernel/exec.c @@ -52,7 +52,7 @@ void exec(char* filename) { ret = 0; - ret = (*exec)(); + //ret = (*exec)(); cprintf("ret: %x\n", ret); diff --git a/sw/kernel/link.ld b/sw/kernel/link.ld index 1fd8d3f..806c93f 100644 --- a/sw/kernel/link.ld +++ b/sw/kernel/link.ld @@ -2,12 +2,16 @@ MEMORY { ZP: start = $0, size = $100, type = rw, define = yes; SDRAM: start = $200, size = $7cf0, type = rw, define = yes; - ROM: start = $D000, size = $3000, file = %O; + ROM: start = $C000, size = $4000, type = rw, define = yes; +} + +FILES { + %O: format = o65; } SEGMENTS { ZEROPAGE: load = ZP, type = zp, define = yes; - DATA: load = ROM, type = rw, define = yes, run = SDRAM; + DATA: load = SDRAM, type = rw, define = yes; BSS: load = SDRAM, type = bss, define = yes; HEAP: load = SDRAM, type = bss, optional = yes; STARTUP: load = ROM, type = ro;