Skip to content

resources: add scripts to make and extract arm kernel #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/ubuntu-generic-diskimages/files/arm/gem5_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ mount -t sysfs /sys /sys
cmdline=$(cat /proc/cmdline)
no_systemd=false

# Load gem5_bridge driver
## Default parameters (ARM64)
gem5_bridge_baseaddr=0x10010000
gem5_bridge_rangesize=0x10000
## Try to read overloads from kernel arguments
if [[ $cmdline =~ gem5_bridge_baseaddr=([[:alnum:]]+) ]]; then
gem5_bridge_baseaddr=${BASH_REMATCH[1]}
fi
if [[ $cmdline =~ gem5_bridge_rangesize=([[:alnum:]]+) ]]; then
gem5_bridge_rangesize=${BASH_REMATCH[1]}
fi
## Insert driver
modprobe gem5_bridge \
gem5_bridge_baseaddr=$gem5_bridge_baseaddr \
gem5_bridge_rangesize=$gem5_bridge_rangesize


# gem5-bridge exit signifying that kernel is booted
# This will cause the simulation to exit. Note that this will
# cause qemu to fail.
Expand Down
2 changes: 1 addition & 1 deletion src/ubuntu-generic-diskimages/http/arm-24-04/user-data
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ autoinstall:
type: format
id: format-0
- device: disk-vda
size: 4257218560
size: 40726691840
wipe: superblock
flag: ''
number: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ source "qemu" "initialize" {
"<wait>"
]
cpus = "4"
disk_size = "4600"
disk_size = "42000"
format = "raw"
headless = "true"
http_directory = local.iso_data[var.ubuntu_version].http_directory
Expand Down Expand Up @@ -139,4 +139,9 @@ build {
environment_vars = ["ISA=arm64"]
expect_disconnect = true
}
provisioner "file" {
source = "/home/gem5/my-arm-kernel/linux-6.8.0/vmlinux"
destination = "./arm-disk-image-24-04/vmlinux"
direction = "download"
}
}
38 changes: 30 additions & 8 deletions src/ubuntu-generic-diskimages/scripts/post-installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,26 @@ apt-get install -y build-essential
echo "Installing serial service for autologin after systemd"
mv /home/gem5/[email protected] /lib/systemd/system/

# Make sure the headers are installed to extract the kernel that DKMS
# packages will be built against.
sudo apt -y install "linux-headers-$(uname -r)" "linux-modules-extra-$(uname -r)"

echo "Extracting linux kernel $(uname -r) to /home/gem5/vmlinux-x86-ubuntu"
sudo bash -c "/usr/src/linux-headers-$(uname -r)/scripts/extract-vmlinux /boot/vmlinuz-$(uname -r) > /home/gem5/vmlinux-x86-ubuntu"
apt-get update
apt-get install -y fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge
# Fixing the sources.list file to include deb-src: https://askubuntu.com/questions/1512042/ubuntu-24-04-getting-error-you-must-put-some-deb-src-uris-in-your-sources-list
sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources

apt update

apt-get -y build-dep linux
apt-get -y install git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev
apt-get -y install libssl-dev
apt -y install flex bison
apt -y install zstd

mkdir my-arm-kernel
cd my-arm-kernel
apt source linux-image-unsigned-$(uname -r)
cd linux-6.8.0
cp /boot/config-$(uname -r) .config
make olddefconfig
make -j$(nproc)

echo "Installing the gem5 init script in /sbin"
mv /home/gem5/gem5_init.sh /sbin
Expand All @@ -47,21 +61,29 @@ if [ -z "$ISA" ]; then
fi

# Just get the files we need
git clone https://github.com/gem5/gem5.git --depth=1 --filter=blob:none --no-checkout --sparse --single-branch --branch=stable
git clone https://github.com/nkrim/gem5.git --depth=1 --filter=blob:none --no-checkout --sparse --single-branch --branch=gem5-bridge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is just a placeholder, but don't forget to fix this.

pushd gem5
# Checkout just the files we need
git sparse-checkout add util/m5
git sparse-checkout add util/gem5_bridge
git sparse-checkout add include
git checkout
# Install the headers globally so that other benchmarks can use them
cp -r include/gem5 /usr/local/include/\
cp -r include/gem5 /usr/local/include/

# Build the library and binary
pushd util/m5
scons build/${ISA}/out/m5
cp build/${ISA}/out/m5 /usr/local/bin/
cp build/${ISA}/out/libm5.a /usr/local/lib/
popd # util/m5

# Build and insert the gem5-bridge driver
pushd util/gem5_bridge
make build install
depmod --quick
popd

popd # gem5

# rename the m5 binary to gem5-bridge
Expand Down