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