Compare commits
No commits in common. "main" and "arm" have entirely different histories.
@ -1,11 +1,11 @@
|
|||||||
# minimal-linux
|
# minimal-linux
|
||||||
|
|
||||||
A minimal linux distro with busybox. Kernel loads up in Qemu but doesn't "init" into shell properly yet.
|
A minimal linux distro cross compiled for ARM with busybox. This works fine but doing the exact same thing with x86_64 doesn't work in the main branch? Don't know whats happening but I presume the startup process is much more complicated for x86_64
|
||||||
|
|
||||||
## build from scratch
|
## build from scratch
|
||||||
|
|
||||||
Just do: `./build.sh`
|
`./manual-linux.sh`
|
||||||
|
|
||||||
### test with QEMU
|
### test with QEMU
|
||||||
|
|
||||||
`./start-vm.sh`
|
`./start-qemu-terminal.sh`
|
||||||
|
BIN
initramfs.cpio
BIN
initramfs.cpio
Binary file not shown.
Binary file not shown.
@ -1,15 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Script create the simplest linux distro ever
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
OUTDIR=/minimal-linux
|
OUTDIR=/tmp/aeld
|
||||||
KERNEL_REPO=git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
|
KERNEL_REPO=git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
|
||||||
KERNEL_VERSION=v6.1.14
|
KERNEL_VERSION=v6.1.14
|
||||||
BUSYBOX_VERSION=1_33_1
|
BUSYBOX_VERSION=1_33_1
|
||||||
|
# FINDER_APP_DIR=$(realpath $(dirname $0))
|
||||||
#ARCH=arm64
|
ARCH=arm64
|
||||||
#CROSS_COMPILE=aarch64-none-linux-gnu-
|
CROSS_COMPILE=aarch64-none-linux-gnu-
|
||||||
ARCH=x86_64
|
|
||||||
CROSS_COMPILE=
|
|
||||||
|
|
||||||
if [ $# -lt 1 ]
|
if [ $# -lt 1 ]
|
||||||
then
|
then
|
||||||
@ -35,13 +36,26 @@ if [ ! -e ${OUTDIR}/linux-stable/arch/${ARCH}/boot/Image ]; then
|
|||||||
#make ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE" menuconfig
|
#make ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE" menuconfig
|
||||||
#make ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE" config
|
#make ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE" config
|
||||||
# use default config
|
# use default config
|
||||||
make ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE" defconfig
|
# make ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE" defconfig
|
||||||
make ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE"
|
# make ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE"
|
||||||
|
# (deepclean) the kernal Biuld tree - remove any existing configuration
|
||||||
|
make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} mrproper
|
||||||
|
# configure our virt device we simulate in qemu
|
||||||
|
echo "(configure our virt)"
|
||||||
|
make ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} defconfig
|
||||||
|
# biuld a kernel image for booting with qemu
|
||||||
|
echo "biuld a kernel image for booting with qemu"
|
||||||
|
make -j4 ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} all
|
||||||
|
# build any kernel modules
|
||||||
|
echo "build any kernel modules"
|
||||||
|
make ARCH=arm64 CROSS_COMPILE=${CROSS_COMPILE} modules
|
||||||
|
# build the device tree
|
||||||
|
make ARCH=arm64 CROSS_COMPILE=${CROSS_COMPILE} dtbs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Adding the Image in outdir"
|
echo "Adding the Image in outdir"
|
||||||
|
|
||||||
cp ${OUTDIR}/linux-stable/arch/x86/boot/bzImage ${OUTDIR}
|
cp ${OUTDIR}/linux-stable/arch/${ARCH}/boot/Image ${OUTDIR}
|
||||||
|
|
||||||
echo "Creating the staging directory for the root filesystem"
|
echo "Creating the staging directory for the root filesystem"
|
||||||
cd "$OUTDIR"
|
cd "$OUTDIR"
|
||||||
@ -96,18 +110,33 @@ ${CROSS_COMPILE}readelf -a ${OUTDIR}/rootfs/bin/busybox | grep "program interpre
|
|||||||
${CROSS_COMPILE}readelf -a ${OUTDIR}/rootfs/bin/busybox | grep "Shared library"
|
${CROSS_COMPILE}readelf -a ${OUTDIR}/rootfs/bin/busybox | grep "Shared library"
|
||||||
|
|
||||||
# TODO: Add library dependencies to rootfs
|
# TODO: Add library dependencies to rootfs
|
||||||
SYSROOT=$(${CROSS_COMPILE}gcc -print-sysroot)
|
CROSS_COMPILE_PATH=$(${CROSS_COMPILE}gcc --print-sysroot)
|
||||||
echo "SYSROOT is : $SYSROOT"
|
cp "${CROSS_COMPILE_PATH}"/lib/ld-linux-aarch64.so.1 "${OUTDIR}"/rootfs/lib
|
||||||
cp -a ${SYSROOT}/lib64/ld-linux-x86-64.so.2 ${OUTDIR}/rootfs/lib
|
cp "${CROSS_COMPILE_PATH}"/lib64/libm.so.6 "${OUTDIR}"/rootfs/lib64
|
||||||
echo "cp 1 result $#"
|
cp "${CROSS_COMPILE_PATH}"/lib64/libresolv.so.2 "${OUTDIR}"/rootfs/lib64
|
||||||
cp -r ${SYSROOT}/lib64/ ${OUTDIR}/rootfs/lib64
|
cp "${CROSS_COMPILE_PATH}"/lib64/libc.so.6 "${OUTDIR}"/rootfs/lib64
|
||||||
echo "cp 2 result $#"
|
|
||||||
|
|
||||||
# TODO: Make device nodes
|
# TODO: Make device nodes
|
||||||
cd ${OUTDIR}/rootfs
|
cd "$OUTDIR/rootfs"
|
||||||
sudo mknod -m 666 dev/null c 1 3
|
sudo mknod -m 666 dev/null c 1 3
|
||||||
sudo mknod -m 600 dev/console c 5 1
|
sudo mknod -m 600 dev/console c 5 1
|
||||||
ls -l dev
|
|
||||||
|
# TODO: Copy scripts and executables to a directory
|
||||||
|
# on the target rootfs
|
||||||
|
|
||||||
|
# embedded apps and ohter installs can go here?
|
||||||
|
|
||||||
|
# cd "$FINDER_APP_DIR"
|
||||||
|
# make clean
|
||||||
|
# make ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE"
|
||||||
|
|
||||||
|
# cp writer ${OUTDIR}/rootfs/home
|
||||||
|
# cp finder.sh ${OUTDIR}/rootfs/home
|
||||||
|
# cp finder-test.sh ${OUTDIR}/rootfs/home
|
||||||
|
# cp writer.sh ${OUTDIR}/rootfs/home
|
||||||
|
# mkdir ${OUTDIR}/rootfs/home/conf
|
||||||
|
# cp -r conf/. ${OUTDIR}/rootfs/home/conf
|
||||||
|
# cp autorun-qemu.sh ${OUTDIR}/rootfs/home
|
||||||
|
|
||||||
# TODO: Chown the root directory
|
# TODO: Chown the root directory
|
||||||
cd "$OUTDIR/rootfs"
|
cd "$OUTDIR/rootfs"
|
||||||
@ -116,4 +145,4 @@ sudo chown -R root:root *
|
|||||||
# TODO: Create initramfs.cpio.gz
|
# TODO: Create initramfs.cpio.gz
|
||||||
find . | cpio -H newc -ov --owner root:root > ${OUTDIR}/initramfs.cpio
|
find . | cpio -H newc -ov --owner root:root > ${OUTDIR}/initramfs.cpio
|
||||||
cd "$OUTDIR"
|
cd "$OUTDIR"
|
||||||
gzip -f initramfs.cpio
|
gzip -f initramfs.cpio
|
@ -1,16 +1,17 @@
|
|||||||
# !/bin/bash
|
# !/bin/bash
|
||||||
# Script to test build using qemu x86 emulator.
|
# Script to open qemu terminal.
|
||||||
|
# Author: Siddhant Jajoo.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
OUTDIR=$1
|
OUTDIR=$1
|
||||||
|
|
||||||
if [ -z "${OUTDIR}" ]; then
|
if [ -z "${OUTDIR}" ]; then
|
||||||
OUTDIR=/minimal-linux
|
OUTDIR=/tmp/aeld
|
||||||
echo "No outdir specified, using ${OUTDIR}"
|
echo "No outdir specified, using ${OUTDIR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
KERNEL_IMAGE=${OUTDIR}/linux-stable/arch/x86/boot/bzImage
|
KERNEL_IMAGE=${OUTDIR}/Image
|
||||||
INITRD_IMAGE=${OUTDIR}/initramfs.cpio.gz
|
INITRD_IMAGE=${OUTDIR}/initramfs.cpio.gz
|
||||||
|
|
||||||
if [ ! -e ${KERNEL_IMAGE} ]; then
|
if [ ! -e ${KERNEL_IMAGE} ]; then
|
||||||
@ -25,13 +26,7 @@ fi
|
|||||||
|
|
||||||
echo "Booting the kernel"
|
echo "Booting the kernel"
|
||||||
# See trick at https://superuser.com/a/1412150 to route serial port output to file
|
# See trick at https://superuser.com/a/1412150 to route serial port output to file
|
||||||
qemu-system-x86_64 \
|
qemu-system-aarch64 -m 256M -M virt -cpu cortex-a53 -nographic -smp 1 -kernel ${KERNEL_IMAGE} \
|
||||||
-m 256M \
|
|
||||||
-M pc \
|
|
||||||
-cpu qemu64 \
|
|
||||||
-nographic \
|
|
||||||
-smp 1 \
|
|
||||||
-kernel ${KERNEL_IMAGE} \
|
|
||||||
-chardev stdio,id=char0,mux=on,logfile=${OUTDIR}/serial.log,signal=off \
|
-chardev stdio,id=char0,mux=on,logfile=${OUTDIR}/serial.log,signal=off \
|
||||||
-serial chardev:char0 -mon chardev=char0 \
|
-serial chardev:char0 -mon chardev=char0\
|
||||||
-append "rdinit=/home/autorun-qemu.sh console=ttyAMA0" -initrd ${INITRD_IMAGE}
|
-append "rdinit=/bin/sh" -initrd ${INITRD_IMAGE}
|
Loading…
x
Reference in New Issue
Block a user