Compare commits

..

No commits in common. "49535cb998d9bec44b078f0af7d8299f9a3184d1" and "2365171e8e07cd5f9569586ba605fe48efd68d08" have entirely different histories.

515 changed files with 70 additions and 110473 deletions

108
Makefile
View File

@ -1,111 +1,44 @@
CC = clang
SRC_DIR := src SRC_DIR := src
SRC := $(wildcard $(SRC_DIR)/*.c) SRC := $(SRC_DIR)/main.c
BUILD_DIR := build BUILD_DIR := build
ASSETS := assets ASSETS := assets
TARGET := $(BUILD_DIR)/hello TARGET := $(BUILD_DIR)/hello
INCLUDE := /usr/include/
CTOOLS := $(SRC_DIR)/ctools CTOOLS := $(SRC_DIR)/ctools
LIBFT_DIR := $(CTOOLS)/libft LIBFT_DIR := $(CTOOLS)/libft
LIBFT := $(LIBFT_DIR)/lib/libft.a LIBFT := $(LIBFT_DIR)/lib/libft.a
LIB := $(LIBFT) $(LIBGPIOD) LIB := $(LIBFT)
TOOLCHAIN_DIR := $(HOME)/.local/toolchains CFLAGS := -Wall -Wextra -Werror --target=arm-linux-gnueabihf
TOOLCHAIN := $(TOOLCHAIN_DIR)/aarch64-linux-musl-cross
TOOLCHAIN_BIN := $(TOOLCHAIN)/bin
MUSL_LD := $(TOOLCHAIN_BIN)/aarch64-linux-musl-ld
CC := $(TOOLCHAIN_BIN)/aarch64-linux-musl-gcc
LIBGPIOD_INCLUDE := $(TOOLCHAIN)/include DOCKER_CMD := /bin/sh -c 'hello "host.docker.internal" "8000"'
LIBGPIOD := $(TOOLCHAIN)/lib/libgpiod.a
CFLAGS := -Wall -Wextra -Werror -I$(LIBGPIOD_INCLUDE)
DOCKER_CMD := /bin/sh #-c 'hello "host.docker.internal" "8000"'
MINIROOTFS := $(ASSETS)/minirootfs.tar.gz MINIROOTFS := $(ASSETS)/minirootfs.tar.gz
ALPINE := alpine/
LINKER_FLAGS := -L$(TOOLCHAIN)/lib -lgpiod
ALPINE := alpine
ALPINE_KERNEL := alpine/boot/vmlinuz-rpi
ALPINE_INITFRAM_FS := alpine/boot/initramfs-rpi
ALPINE_BIN := $(ALPINE)/bin ALPINE_BIN := $(ALPINE)/bin
ALPINE_TAR := $(ASSETS)/alpine-rpi-aarch64.gz
ALPINE_HEADLESS := $(ASSETS)/headless.apkovl.tar.gz
ALPINE_CUSTOM_IMG := $(BUILD_DIR)/alpine-custom.img get: $(ALPINE) $(ASSETS)
wget https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/armhf/alpine-minirootfs-3.22.1-armhf.tar.gz -O $(MINIROOTFS)
tar xvf $(MINIROOTFS) -C $^
PLATFORM := arm64 all: $(SRC) $(BUILD_DIR) $(LIB)
QEMU_VM := qemu-system-aarch64 $(CC) $(CFLAGS) -o $(TARGET) -static $(SRC) $(LIB)
QEMU_IMG := qemu-img cp $(TARGET) $(ALPINE_BIN)
tar czf $(MINIROOTFS) -C alpine ./
SSH_AUTH_KEYS := $(ALPINE)/authorized_keys docker import --platform linux/arm/v7 $(MINIROOTFS) alpine-custom:latest
all: $(TARGET)
$(TARGET): $(SRC) $(BUILD_DIR) $(LIB) $(LIBGPIOD)
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LIB) $(LIBGPIOD)
get: $(ASSETS) $(ALPINE_TAR) $(ALPINE_HEADLESS)
rm -rf $(ALPINE)/*
tar xvf $(ALPINE_TAR) -C $(ALPINE)
cp $(ALPINE_HEADLESS) $(ALPINE)
sync: $(TARGET)
rsync -avz root@pi:/media/mmcblk0p1/ ./image
rsync -avz ./build/* root@pi:/root/build/
img: get $(ALPINE) $(BUILD_DIR)
$(QEMU_IMG) create -f raw $(ALPINE_CUSTOM_IMG) 512M
mformat -i $(ALPINE_CUSTOM_IMG) -F ::
mcopy -i $(ALPINE_CUSTOM_IMG) -s $(ALPINE)/* ::
$(SSH_AUTH_KEYS):
cp ~/.ssh/authorized_keys $(ALPINE)
bootable: $(ALPINE) $(WPA_CONFIG) get
tar czf $(MINIROOTFS) -C $(ALPINE) ./
$(ALPINE_HEADLESS):
wget https://github.com/macmpi/alpine-linux-headless-bootstrap/raw/98728731299f262eab270941c522138d6c5cea73/headless.apkovl.tar.gz -O $(ALPINE_HEADLESS)
$(LIBGPIOD): $(TOOLCHAIN)
rm -f $(LIBGPIOD)
git clone https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git && \
cd libgpiod && \
export ac_cv_func_malloc_0_nonnull=yes && \
export ac_cv_func_realloc_0_nonnull=yes && \
./autogen.sh && \
./configure --host=aarch64-linux-musl \
--prefix=$(TOOLCHAIN) \
--enable-tools=no \
--enable-bindings-cxx=no \
--disable-shared \
--enable-static && \
make && make install && \
cd .. && \
rm -rf libgpiod
$(TOOLCHAIN): | $(TOOLCHAIN_DIR) run: all
wget https://musl.cc/aarch64-linux-musl-cross.tgz docker run --add-host=host.docker.internal:host-gateway --platform linux/arm/v7 -it alpine-custom $(DOCKER_CMD)
tar xvf aarch64-linux-musl-cross.tgz -C $(TOOLCHAIN_DIR)
rm aarch64-linux-musl-cross.tgz
$(TOOLCHAIN_DIR):
mkdir -p $@
$(ALPINE_TAR):
wget https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/aarch64/alpine-rpi-3.22.1-aarch64.tar.gz -O $(ALPINE_TAR)
$(LIB): $(LIB):
make aarch64 -C $(LIBFT_DIR) make -C $(LIBFT_DIR)
$(BUILD_DIR): $(BUILD_DIR):
mkdir -p $@ mkdir -p $@
@ -117,7 +50,4 @@ $(ASSETS):
mkdir -p $@ mkdir -p $@
clean: clean:
rm -rf $(BUILD_DIR) $(ALPINE) $(ASSETS) rm -rf $(BUILD_DIR)
make fclean -C $(LIBFT_DIR)
.PHONY: sync

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More