From a441f9a988f65d2a5585c8c0d69f196cd9dcb8d1 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 9 May 2022 19:01:25 +0200 Subject: [PATCH] Create basic BR2_EXTERNAL, with a twist Initial defconfig is based on Buildroot qemu_x86_64_defconfig, with a Bootlin pre-built toolchain and a very basic qemu.sh script, generated by a local post-image.sh, for `make run`. Signed-off-by: Joachim Wiberg --- .gitignore | 6 ++++++ .gitmodules | 3 +++ Config.in | 0 Makefile | 30 ++++++++++++++++++++++++++++ board/common/post-image.sh | 16 +++++++++++++++ buildroot | 1 + configs/x86_defconfig | 41 ++++++++++++++++++++++++++++++++++++++ external.desc | 2 ++ external.mk | 0 patches/.empty | 0 10 files changed, 99 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Config.in create mode 100644 Makefile create mode 100755 board/common/post-image.sh create mode 160000 buildroot create mode 100644 configs/x86_defconfig create mode 100644 external.desc create mode 100644 external.mk create mode 100644 patches/.empty diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2aafd58e --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*~ +.gdb_history +/.ccache +/dl +/output* +/local.mk diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..e1d58ff5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "buildroot"] + path = buildroot + url = https://github.com/buildroot/buildroot.git diff --git a/Config.in b/Config.in new file mode 100644 index 00000000..e69de29b diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..dfa15477 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +export BR2_EXTERNAL := $(CURDIR) +export PATH := $(CURDIR)/bin:$(PATH) + +ARCH ?= $(shell uname -m) +O ?= $(CURDIR)/output + +config := $(O)/.config +bmake = $(MAKE) -C buildroot O=$(O) $1 + + +all: $(config) buildroot/Makefile + @+$(call bmake,$@) + +$(config): + @+$(call bmake,list-defconfigs) + @echo "ERROR: No configuration selected." + @echo "Please choose a configuration from the list above by running" + @echo "'make _defconfig' before building an image." + @exit 1 + +%: buildroot/Makefile + @+$(call bmake,$@) + +buildroot/Makefile: + @git submodule update --init + +run: + @echo "Starting Qemu :: Ctrl-a x -- exit | Ctrl-a c -- toggle console/monitor" + @(cd $(O)/images && ./qemu.sh) + diff --git a/board/common/post-image.sh b/board/common/post-image.sh new file mode 100755 index 00000000..ede26e99 --- /dev/null +++ b/board/common/post-image.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# shellcheck disable=SC1090 +. "$BR2_CONFIG" 2>/dev/null + +cat <<-EOF >"$BINARIES_DIR/qemu.sh" + #!/bin/sh + line=\$(stty -g) + stty raw + qemu-system-x86_64 -M pc -cpu kvm64 -enable-kvm -nographic \\ + -kernel bzImage -append "rootwait root=/dev/vda console=ttyS0" \\ + -drive file=rootfs.ext2,if=virtio,format=raw \\ + -net nic,model=virtio -net user + stty "\$line" +EOF +chmod +x "$BINARIES_DIR/qemu.sh" diff --git a/buildroot b/buildroot new file mode 160000 index 00000000..21ab3e72 --- /dev/null +++ b/buildroot @@ -0,0 +1 @@ +Subproject commit 21ab3e720c0acae2332454cf0ebdb992ac65b644 diff --git a/configs/x86_defconfig b/configs/x86_defconfig new file mode 100644 index 00000000..6bd6510d --- /dev/null +++ b/configs/x86_defconfig @@ -0,0 +1,41 @@ +# Architecture +BR2_x86_64=y +BR2_x86_corei7=y +BR2_DL_DIR="$(BR2_EXTERNAL_INFIX_PATH)/dl" +BR2_CCACHE=y +BR2_CCACHE_DIR="$(BR2_EXTERNAL_INFIX_PATH)/.ccache" +BR2_ENABLE_DEBUG=y +BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_INFIX_PATH)/patches" +BR2_TOOLCHAIN_EXTERNAL=y +BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_CORE_I7_UCLIBC_BLEEDING_EDGE=y + +# System +BR2_SYSTEM_DHCP="eth0" +BR2_TARGET_GENERIC_HOSTNAME="infix" +BR2_TARGET_GENERIC_ISSUE="Inf/IX by KernelKit" + +# Filesystem +BR2_TARGET_ROOTFS_EXT2=y +# BR2_TARGET_ROOTFS_TAR is not set + +# Image +BR2_ROOTFS_POST_BUILD_SCRIPT="board/qemu/x86_64/post-build.sh" + +# Image +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh $(BR2_EXTERNAL_INFIX_PATH)/board/common/post-image.sh" +BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)" + +# Linux headers same as kernel +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_15=y + +# Kernel +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.15.18" +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config" +BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y + +# host-qemu for gitlab testing +#BR2_PACKAGE_HOST_QEMU=y +#BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y diff --git a/external.desc b/external.desc new file mode 100644 index 00000000..af8d2e2d --- /dev/null +++ b/external.desc @@ -0,0 +1,2 @@ +name: INFIX +desc: Inf/IX by KernelKit diff --git a/external.mk b/external.mk new file mode 100644 index 00000000..e69de29b diff --git a/patches/.empty b/patches/.empty new file mode 100644 index 00000000..e69de29b