Appendix A: LED error patterns

Long flashes

Short flashes

Error

0

3

Generic failure to boot

0

4

start*.elf not found

0

7

Kernel image not found

0

8

SDRAM failure

0

9

Insufficient SDRAM

0

10

In HALT state

2

1

Partition not FAT

2

2

Failed to read from partition

2

3

Extended partition not FAT

2

4

File signature/hash mismatch

3

1

SPI EEPROM error

3

2

SPI EEPROM write-protected

3

3

I2C error

3

4

Secure boot config invalid

4

4

Unsupported board type

4

5

Fatal firmware error

4

6

Power failure type A

4

7

Power failure type B

Appendix B: The kOS Makefile

#### KYOSPI/64 MAKE OF GREAT SUCCESS

## VARIABLES
#  B -      build dir
#  D -      disk (SD) image
#  H -      header file / include dir
#  I -      output image (place this on µSD card)
#  L -      linker script
#  M -      map file
#  P -      path to sources
#  S -      assembler listing
#  T -      toolchain
B ?=                build
D ?=                $(B)/sd.img
# i shake my first at the tyranny that doesn't let me name this
# kyospi64.img.
H ?=                inc
I ?=                $(B)/kernel8.img
L ?=                pi4.ld
M ?=                $(B)/kernel8.map
P ?=                src
S ?=                $(B)/kernel8.list
T ?=                arm-none-eabi

ELF :=              $(B)/kyospi64.elf

AS :=               $(T)-as
CC :=               $(T)-gcc
CXX :=              $(T)-g++
LD :=               $(T)-ld
OC :=               $(T)-objcopy
OD :=               $(T)-objdump

BUILD_FLAGS := -O2 -Wall -Werror -ffreestanding -march=armv8-a+crc  \
               -mfloat-abi=hard -mfpu=crypto-neon-fp-armv8          \
               -nostartfiles -nostdinc -nostdlib                    \
               -Wno-unused-command-line-argument -I$(H)
LDFLAGS :=  -nostdlib --no-undefined
CFLAGS :=   $(BUILD_FLAGS)
CXXFLAGS := -std=c++17 $(BUILD_FLAGS)

SRCXX :=    $(wildcard $(P)/*.cc)
SRCCC :=    $(wildcard $(P)/*.c)
OBJS :=     $(patsubst $(P)/%.S,$(B)/%.o,$(wildcard $(P)/*.S))
OBJS +=     $(patsubst $(P)/%.cc,$(B)/%.o,$(SRCXX))
OBJS +=     $(patsubst $(P)/%.c,$(B)/%.o,$(SRCCC))

PODMAN ?=   podman # can also be docker if you hate yourself
PIMAGE ?=   git.wntrmute.dev/kyle/armdev:latest


all:        $(I)

$(S):       $(ELF)
        $(OD) -d $(ELF) > $@

$(I):       $(ELF)
        $(OC) $(ELF) -O binary $@

$(ELF):     $(OBJS) $(L)
        $(LD) -o $@ $(LDFLAGS) $(OBJS) -Map $(M) -T $(L)

$(B)/%.o: $(P)/%.S $(B)
        $(CC) -o $@ $(BUILD_FLAGS) -c -I $(P) $<

$(B)/%.o: $(P)/%.cc $(B)
        $(CXX) -o $@ -c $(CXXFLAGS) -I $(P) $<

$(B)/%.o: $(P)/%.c $(B)
        $(CC) -o $@ -c $(CFLAGS) -I $(P) $<

$(B):
        mkdir $@

$(D): $(B)
        dd if=/dev/zero of=$@ bs=128k count=8192

print-%: ; @echo '$(subst ','\'',$*=$($*))'

clean :
        -rm -rf $(B) $(I) $(S) $(M) $(D)

emulate: $(I) $(D)
        qemu-system-aarch64                                         \
                -M raspi3b                                          \
                -cpu cortex-a53                                     \
                -m 1G                                               \
                -smp 4                                              \
                -kernel $(I)                                        \
                -serial telnet:localhost:4321,server,nowait         \
                -monitor telnet:localhost:4322,server,nowait        \
                -device usb-net,netdev=net0                         \
                -nographic                                          \
                -drive format=raw,file=$(D),if=sd,media=disk

emulate-vga: $(I) $(D)
        qemu-system-aarch64                                         \
                -M raspi3b                                          \
                -cpu cortex-a53                                     \
                -m 1G                                               \
                -smp 4                                              \
                -device VGA,id=vga2                                 \
                -kernel $(I)                                        \
                -serial telnet:localhost:4321,server,nowait         \
                -monitor telnet:localhost:4322,server,nowait        \
                -device usb-net,netdev=net0                         \
                -drive format=raw,file=$(D),if=sd,media=disk

devbox-build:
        $(PODMAN) build -t $(PIMAGE) -f Containerfile

devbox-run:
        $(PODMAN) run -i -t -v $(PWD):/build $(PIMAGE)

.PHONY: all clean