#!/bin/bash # The PIC32MZ bare-metal fixture (the EC and the EF), built with LLVM as # ../baremetal is: a whole-chip ELF with its own reset code and configuration words. # build.sh set -euo pipefail D=$(cd "$(dirname "$0")" && pwd) O=${1:-$D/out} mkdir -p "$O" CC=/opt/homebrew/opt/llvm/bin/clang LD=/opt/homebrew/bin/ld.lld FLAGS="--target=mipsel-none-elf -march=mips32r2 -mabi=32 -mno-abicalls -fno-pic -G0 -msoft-float -O2 -ffreestanding -fno-builtin -Wall -Werror" $CC $FLAGS -c "$D/start.S" -o "$O/mz-start.o" $CC $FLAGS -c "$D/main.c" -o "$O/mz-main.o" $LD -T "$D/link.ld" -nostdlib --no-pie -z max-page-size=16 "$O/mz-start.o" "$O/mz-main.o" -o "$O/pic32-mz.elf" /opt/homebrew/opt/llvm/bin/llvm-objdump -h "$O/pic32-mz.elf" | grep -E "reset|config|vectors|text|data|bss" shasum -a 256 "$O/pic32-mz.elf"