Skip to content
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

adding ubuntu support, fixing fedora linux config #288

Merged
merged 10 commits into from
Jan 19, 2024
Merged
Changes from 1 commit
Commits
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
Next Next commit
adding ubuntu support, fixing fedora linux config
Cloud User committed Sep 26, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
johanlundberg Johan Lundberg
commit 26ef85729f1c48abbd70ff053464f8ae8e83b45a
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ wlutil/_command.sh
*__pycache__
.doit.db*
marshal-config.yaml
boards/default/distros/ubuntu/rootfs.img*
.ropeproject
*~
*#
*#
14 changes: 14 additions & 0 deletions boards/default/distros/ubuntu/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
RAWURL=https://cdimage.ubuntu.com/releases/20.04.5/release/ubuntu-20.04.5-preinstalled-server-riscv64+unmatched.img.xz
COMPIMG=rootfs.img.xz
NEWIMG=rootfs.img

# Extract root partition without partition table
# NOTE: Offset must be adjusted for different base image
$(NEWIMG): $(COMPIMG)
xzcat -k $(COMPIMG) | dd of=$(NEWIMG) bs=512 skip=235554

$(COMPIMG):
curl $(RAWURL) -o $(COMPIMG)

clean:
rm -f $(COMPIMG) $(RAWIMG) $(NEWIMG)
1 change: 1 addition & 0 deletions boards/default/distros/ubuntu/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .ubuntu import * # NOQA
Binary file not shown.
1 change: 1 addition & 0 deletions boards/default/distros/ubuntu/overlay/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
etc/systemd/system/firesim.service
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Acquire::Changelogs::AlwaysOnline "true";
Acquire::http::User-Agent-Non-Interactive "true";
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
APT
{
NeverAutoRemove
{
"^firmware-linux.*";
"^linux-firmware$";
"^linux-image-[a-z0-9]*$";
"^linux-image-[a-z0-9]*-[a-z0-9]*$";
};

VersionedKernelPackages
{
# kernels
"linux-.*";
"kfreebsd-.*";
"gnumach-.*";
# (out-of-tree) modules
".*-modules";
".*-kernel";
};

Never-MarkAuto-Sections
{
"metapackages";
"contrib/metapackages";
"non-free/metapackages";
"restricted/metapackages";
"universe/metapackages";
"multiverse/metapackages";
};

Move-Autobit-Sections
{
"oldlibs";
"contrib/oldlibs";
"non-free/oldlibs";
"restricted/oldlibs";
"universe/oldlibs";
"multiverse/oldlibs";
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
APT::Update::Post-Invoke-Stats {
"[ ! -f /usr/lib/ubuntu-advantage/apt-esm-hook ] || /usr/lib/ubuntu-advantage/apt-esm-hook post-invoke-stats || true";
};

APT::Install::Post-Invoke-Success {
"[ ! -f /usr/lib/ubuntu-advantage/apt-esm-hook ] || /usr/lib/ubuntu-advantage/apt-esm-hook post-invoke-success || true";
};

APT::Install::Pre-Invoke {
"[ ! -f /usr/lib/ubuntu-advantage/apt-esm-hook ] || /usr/lib/ubuntu-advantage/apt-esm-hook pre-invoke || true";
};

AptCli::Hooks::Upgrade {
"[ ! -f /usr/lib/ubuntu-advantage/apt-esm-json-hook ] || /usr/lib/ubuntu-advantage/apt-esm-json-hook || true";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APT::Archives::MaxAge "30";
APT::Archives::MinAge "2";
APT::Archives::MaxSize "500";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// THIS FILE IS USED TO INFORM PACKAGEKIT
// THAT THE UPDATE-INFO MIGHT HAVE CHANGED

// Whenever dpkg is called we might have different updates
// i.e. if an user removes a package that had an update
DPkg::Post-Invoke {
"/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 4 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null";
};

// When Apt's cache is updated (i.e. apt-cache update)
APT::Update::Post-Invoke-Success {
"/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 4 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## This file is provided by command-not-found(1) to download
## Commands metadata files.

Acquire::IndexTargets {
# The deb822 metadata files
deb::CNF {
MetaKey "$(COMPONENT)/cnf/Commands-$(NATIVE_ARCHITECTURE)";
ShortDescription "Commands-$(NATIVE_ARCHITECTURE)";
Description "$(RELEASE)/$(COMPONENT) $(NATIVE_ARCHITECTURE) c-n-f Metadata";
};
};

# Refresh AppStream cache when APT's cache is updated (i.e. apt update)
APT::Update::Post-Invoke-Success {
"if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// Automatically upgrade packages from these (origin:archive) pairs
//
// Note that in Ubuntu security updates may pull in new dependencies
// from non-security sources (e.g. chromium). By allowing the release
// pocket these get automatically pulled in.
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}";
"${distro_id}:${distro_codename}-security";
// Extended Security Maintenance; doesn't necessarily exist for
// every release and this system may not have it installed, but if
// available, the policy for updates is such that unattended-upgrades
// should also install from here by default.
"${distro_id}ESMApps:${distro_codename}-apps-security";
"${distro_id}ESM:${distro_codename}-infra-security";
// "${distro_id}:${distro_codename}-updates";
// "${distro_id}:${distro_codename}-proposed";
// "${distro_id}:${distro_codename}-backports";
};

// Python regular expressions, matching packages to exclude from upgrading
Unattended-Upgrade::Package-Blacklist {
// The following matches all packages starting with linux-
// "linux-";

// Use $ to explicitely define the end of a package name. Without
// the $, "libc6" would match all of them.
// "libc6$";
// "libc6-dev$";
// "libc6-i686$";

// Special characters need escaping
// "libstdc\+\+6$";

// The following matches packages like xen-system-amd64, xen-utils-4.1,
// xenstore-utils and libxenstore3.0
// "(lib)?xen(store)?";

// For more information about Python regular expressions, see
// https://docs.python.org/3/howto/regex.html
};

// This option controls whether the development release of Ubuntu will be
// upgraded automatically. Valid values are "true", "false", and "auto".
Unattended-Upgrade::DevRelease "auto";

// This option allows you to control if on a unclean dpkg exit
// unattended-upgrades will automatically run
// dpkg --force-confold --configure -a
// The default is true, to ensure updates keep getting installed
//Unattended-Upgrade::AutoFixInterruptedDpkg "true";

// Split the upgrade into the smallest possible chunks so that
// they can be interrupted with SIGTERM. This makes the upgrade
// a bit slower but it has the benefit that shutdown while a upgrade
// is running is possible (with a small delay)
//Unattended-Upgrade::MinimalSteps "true";

// Install all updates when the machine is shutting down
// instead of doing it in the background while the machine is running.
// This will (obviously) make shutdown slower.
// Unattended-upgrades increases logind's InhibitDelayMaxSec to 30s.
// This allows more time for unattended-upgrades to shut down gracefully
// or even install a few packages in InstallOnShutdown mode, but is still a
// big step back from the 30 minutes allowed for InstallOnShutdown previously.
// Users enabling InstallOnShutdown mode are advised to increase
// InhibitDelayMaxSec even further, possibly to 30 minutes.
//Unattended-Upgrade::InstallOnShutdown "false";

// Send email to this address for problems or packages upgrades
// If empty or unset then no email is sent, make sure that you
// have a working mail setup on your system. A package that provides
// 'mailx' must be installed. E.g. "[email protected]"
//Unattended-Upgrade::Mail "";

// Set this value to one of:
// "always", "only-on-error" or "on-change"
// If this is not set, then any legacy MailOnlyOnError (boolean) value
// is used to chose between "only-on-error" and "on-change"
//Unattended-Upgrade::MailReport "on-change";

// Remove unused automatically installed kernel-related packages
// (kernel images, kernel headers and kernel version locked tools).
//Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";

// Do automatic removal of newly unused dependencies after the upgrade
//Unattended-Upgrade::Remove-New-Unused-Dependencies "true";

// Do automatic removal of unused packages after the upgrade
// (equivalent to apt-get autoremove)
//Unattended-Upgrade::Remove-Unused-Dependencies "false";

// Automatically reboot *WITHOUT CONFIRMATION* if
// the file /var/run/reboot-required is found after the upgrade
//Unattended-Upgrade::Automatic-Reboot "false";

// Automatically reboot even if there are users currently logged in
// when Unattended-Upgrade::Automatic-Reboot is set to true
//Unattended-Upgrade::Automatic-Reboot-WithUsers "true";

// If automatic reboot is enabled and needed, reboot at the specific
// time instead of immediately
// Default: "now"
//Unattended-Upgrade::Automatic-Reboot-Time "02:00";

// Use apt bandwidth limit feature, this example limits the download
// speed to 70kb/sec
//Acquire::http::Dl-Limit "70";

// Enable logging to syslog. Default is False
// Unattended-Upgrade::SyslogEnable "false";

// Specify syslog facility. Default is daemon
// Unattended-Upgrade::SyslogFacility "daemon";

// Download and install upgrades only on AC power
// (i.e. skip or gracefully stop updates on battery)
// Unattended-Upgrade::OnlyOnACPower "true";

// Download and install upgrades only on non-metered connection
// (i.e. skip or gracefully stop updates on a metered connection)
// Unattended-Upgrade::Skip-Updates-On-Metered-Connections "true";

// Verbose logging
// Unattended-Upgrade::Verbose "false";

// Print debugging information both in unattended-upgrades and
// in unattended-upgrade-shutdown
// Unattended-Upgrade::Debug "false";

// Allow package downgrade if Pin-Priority exceeds 1000
// Unattended-Upgrade::Allow-downgrade "false";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Pre-configure all packages with debconf before they are installed.
// If you don't like it, comment it out.
DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt || true";};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DPkg::Post-Invoke {"if [ -d /var/lib/update-notifier ]; then touch /var/lib/update-notifier/dpkg-run-stamp; fi; /usr/lib/update-notifier/update-motd-updates-available 2>/dev/null || true";};
APT::Update::Post-Invoke-Success {"/usr/lib/update-notifier/update-motd-updates-available 2>/dev/null || true";};
61 changes: 61 additions & 0 deletions boards/default/distros/ubuntu/overlay/etc/apt/sources.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
## or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://ports.ubuntu.com/ubuntu-ports focal main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://ports.ubuntu.com/ubuntu-ports focal universe
# deb-src http://ports.ubuntu.com/ubuntu-ports focal universe
deb http://ports.ubuntu.com/ubuntu-ports focal-updates universe
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://ports.ubuntu.com/ubuntu-ports focal multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports focal multiverse
deb http://ports.ubuntu.com/ubuntu-ports focal-updates multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://ports.ubuntu.com/ubuntu-ports focal-security main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports focal-security universe
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-security universe
deb http://ports.ubuntu.com/ubuntu-ports focal-security multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-security multiverse
deb https://apt.kitware.com/ubuntu focal main
# deb-src https://apt.kitware.com/ubuntu focal main
deb https://download.docker.com/linux/ubuntu focal stable
# deb-src https://download.docker.com/linux/ubuntu focal stable
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal main
# deb-src http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal main
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal main
# deb-src http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal main
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal main
# deb-src http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal main
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal main
# deb-src http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal main
61 changes: 61 additions & 0 deletions boards/default/distros/ubuntu/overlay/etc/apt/sources.list.save
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
## or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://ports.ubuntu.com/ubuntu-ports focal main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://ports.ubuntu.com/ubuntu-ports focal universe
# deb-src http://ports.ubuntu.com/ubuntu-ports focal universe
deb http://ports.ubuntu.com/ubuntu-ports focal-updates universe
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://ports.ubuntu.com/ubuntu-ports focal multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports focal multiverse
deb http://ports.ubuntu.com/ubuntu-ports focal-updates multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://ports.ubuntu.com/ubuntu-ports focal-security main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports focal-security universe
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-security universe
deb http://ports.ubuntu.com/ubuntu-ports focal-security multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports focal-security multiverse
deb https://apt.kitware.com/ubuntu focal main
# deb-src https://apt.kitware.com/ubuntu focal main
deb https://download.docker.com/linux/ubuntu focal stable
# deb-src https://download.docker.com/linux/ubuntu focal stable
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions boards/default/distros/ubuntu/overlay/etc/firesim/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file is auto-generated by the build system
firesim.sh
1 change: 1 addition & 0 deletions boards/default/distros/ubuntu/overlay/etc/fstab
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LABEL=_/ / ext4 defaults,noatime,x-systemd.device-timeout=300s,x-systemd.mount-timeout=300s 0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Unit]
Requires=multi-user.target
After=multi-user.target
AllowIsolate=yes
15 changes: 15 additions & 0 deletions boards/default/distros/ubuntu/resize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# Usage: ./resize.sh FEDORA_IMAGE NEW_SIZE_IN_BYTES

IMG=$1
NEWSZ=$(numfmt --from=iec $2)
REALSZ=$(du --apparent-size -b $IMG | cut -f1)

if [ $NEWSZ -le $REALSZ ]; then
echo "Target size smaller than current size (shrinking images not currently supported)"
exit
fi

truncate -s $NEWSZ $IMG
e2fsck -f $IMG
resize2fs $IMG
110 changes: 110 additions & 0 deletions boards/default/distros/ubuntu/ubuntu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import subprocess as sp
import shutil
import pathlib
import wlutil
import re

serviceTemplate = """[Unit]
Requires=multi-user.target
After=multi-user.target
Before=firesim.target
Wants=firesim.target
[Service]
ExecStart=/etc/firesim/{scriptName} {scriptArgs}
StandardOutput=journal+console"""

# Some common directories for this module (all absolute paths)
fed_dir = pathlib.Path(__file__).resolve().parent

# Temporary overlay used for applying init scripts
overlay = fed_dir / 'overlay'


# Fedora doesn't support any options
def hashOpts(opts):
return None


# Fedora doesn't support any options
def mergeOpts(base, new):
return base


def initOpts(cfg):
return


class Builder:
def __init__(self, opts):
return

def getWorkload(self):
return {
'name': 'ubuntu-base',
'isDistro': True,
'distro': {
'name': 'ubuntu',
'opts': {}
},
'workdir': fed_dir,
'builder': self,
'img': fed_dir / "rootfs.img"
}

def buildBaseImage(self, task, changed):
wlutil.run(['make', "rootfs.img"], cwd=fed_dir)

def fileDeps(self):
return []

# Return True if the base image is up to date, or False if it needs to be
# rebuilt.
def upToDate(self):
def checkMake():
retcode = sp.call('make -q rootfs.img', shell=True, cwd=fed_dir)
if retcode == 0:
return True
else:
return False
return [(checkMake, ())]

def generateBootScriptOverlay(self, script, args):
# How this works:
# The fedora repo has a pre-built overlay with all the systemd paths
# filled in and a custom boot target (firesim.target) that loads a
# custom service (firesim.service) that runs a script (/init.sh). We
# can change the default boot behavior by changing this script.
scriptDst = overlay / 'etc/firesim/firesim.sh'
if script is not None:
print("applying script: " + str(scriptDst))
shutil.copy(script, scriptDst)
else:
scriptDst.unlink()
# Create a blank init script because overlays won't let us delete stuff
# Alternatively: we could consider replacing the default.target
# symlink to disable the firesim target entirely
scriptDst.touch()

scriptDst.chmod(0o755)

# Create the service script
if args is None:
serviceScript = serviceTemplate.format(scriptName='firesim.sh', scriptArgs='')
else:
serviceScript = serviceTemplate.format(scriptName='firesim.sh', scriptArgs=' '.join(args))

with open(overlay / 'etc/systemd/system/firesim.service', 'w') as f:
f.write(serviceScript)

return overlay

def stripUart(self, lines):
stripped = []
pat = re.compile(r".*firesim.sh\[\d*\]: (.*\n)")
for line in lines:
match = pat.match(line)
if match:
stripped.append(match.group(1))

return stripped
2 changes: 1 addition & 1 deletion boards/firechip/base-workloads/fedora-base/linux-config
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ CONFIG_NR_CPUS=32
# CONFIG_PCI is not set
# CONFIG_POWER_SUPPLY is not set
# CONFIG_SCSI is not set
# CONFIG_SERIAL_SIFIVE is not set
CONFIG_SERIAL_SIFIVE=y
# CONFIG_SOC_SIFIVE is not set
# CONFIG_SPI is not set
# CONFIG_USB_SUPPORT is not set
21 changes: 21 additions & 0 deletions boards/firechip/base-workloads/ubuntu-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name" : "ubuntu-base",
"guest-init": "initRepos.sh",
"rootfs-size": "16GB",
"distro" : {
"name" : "ubuntu",
"opts" : {}
},
"overlay" : "overlay",
"linux" : {
"source" : "../../linux",
"config" : "linux-config",
"modules" : {
"icenet" : "../../drivers/icenet-driver",
"iceblk" : "../../drivers/iceblk-driver"
}
},
"firmware" : {
"opensbi-src" : "../../firmware/opensbi"
}
}
3 changes: 3 additions & 0 deletions boards/firechip/base-workloads/ubuntu-base/initRepos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
dnf makecache
poweroff
65 changes: 65 additions & 0 deletions boards/firechip/base-workloads/ubuntu-base/linux-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
CONFIG_AS_VERSION=23900
# CONFIG_ATA is not set
# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
CONFIG_CMDLINE="console=ttyS0 console=ttySIF0,3686400 earlycon"
CONFIG_DEBUG_SECTION_MISMATCH=y
CONFIG_DEFAULT_HOSTNAME="ucb"
# CONFIG_DRM is not set
CONFIG_EXT2_FS=y
# CONFIG_FB is not set
# CONFIG_HID_GENERIC is not set
# CONFIG_HWMON is not set
# CONFIG_I2C_ALGOBIT is not set
# CONFIG_I2C_COMPAT is not set
# CONFIG_I2C_HELPER_AUTO is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_INPUT_MOUSEDEV is not set
CONFIG_LD_VERSION=23900
# CONFIG_MMC is not set
CONFIG_NR_CPUS=32
# CONFIG_NVMEM_SYSFS is not set
# CONFIG_PCI is not set
# CONFIG_POWER_SUPPLY is not set
# CONFIG_SCSI is not set
CONFIG_SERIAL_SIFIVE=y
# CONFIG_SOC_SIFIVE is not set
# CONFIG_SPI is not set
# CONFIG_USB_SUPPORT is not set
# CONFIG_VHOST_MENU is not set
CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
CONFIG_ARCH_HAS_DMA_PREP_COHERENT=y
CONFIG_ARCH_HAS_SETUP_DMA_OPS=y
CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU=y
CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE=y
CONFIG_AS_HAS_INSN=y
CONFIG_CC_HAVE_STACKPROTECTOR_TLS=y
# CONFIG_CMDLINE_EXTEND is not set
# CONFIG_CMDLINE_FALLBACK is not set
CONFIG_CMDLINE_FORCE=y
CONFIG_DMA_COHERENT_POOL=y
CONFIG_DMA_DIRECT_REMAP=y
CONFIG_DMA_NONCOHERENT_MMAP=y
# CONFIG_EXT2_FS_XATTR is not set
CONFIG_FONT_AUTOSELECT=y
# CONFIG_I2C_ALGOPCA is not set
# CONFIG_I2C_ALGOPCF is not set
# CONFIG_I2C_SMBUS is not set
# CONFIG_INITRAMFS_COMPRESSION_BZIP2 is not set
# CONFIG_INITRAMFS_COMPRESSION_GZIP is not set
# CONFIG_INITRAMFS_COMPRESSION_LZ4 is not set
# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set
# CONFIG_INITRAMFS_COMPRESSION_LZO is not set
CONFIG_INITRAMFS_COMPRESSION_NONE=y
# CONFIG_INITRAMFS_COMPRESSION_XZ is not set
# CONFIG_INITRAMFS_COMPRESSION_ZSTD is not set
# CONFIG_INITRAMFS_FORCE is not set
CONFIG_INITRAMFS_ROOT_GID=0
CONFIG_INITRAMFS_ROOT_UID=0
CONFIG_RISCV_DMA_NONCOHERENT=y
CONFIG_RISCV_ISA_ZICBOM=y
CONFIG_RISCV_ROCC=y
CONFIG_STACKPROTECTOR_PER_TASK=y
CONFIG_TOOLCHAIN_HAS_ZICBOM=y
CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE=y
CONFIG_BLK_DEV_DM=y
CONFIG_DM_MULTIPATH=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
network:
ethernets:
zz-all-en:
dhcp4: true
match:
name: en*
optional: true
zz-all-eth:
dhcp4: true
match:
name: eth*
optional: true
version: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
network:
ethernets:
zz-all-en:
match:
name:
en*
addresses: [172.16.52.86/24]
dhcp4: false
gateway4: [172.16.1.1]
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
zz-all-eth:
match:
name:
eth*
addresses: [172.16.52.86/24]
dhcp4: false
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
version: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import yaml
import sys

with open(sys.argv[1], 'r') as file:
config = yaml.safe_load(file)

config["network"]["ethernets"]["ens33"]["addresses"] = ["172.16." + sys.argv[2] + "." + sys.argv[3] + "/24"]
config["network"]["ethernets"]["ens33"]["gateway4"] = ["172.16.1.1"]

with open(sys.argv[1], 'w') as file:
yaml.dump(config, file)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

#mac=$(ifconfig | grep -o "..:..:..:..:..:..")
mac=$(cat /sys/class/net/eth0/address)
macpref=$(echo $mac | cut -c 1-8 -)
echo "mac prefix:"
echo $macpref
case "$macpref" in
"00:12:6d")
echo "this looks like FireSim. starting network"
machigh=$(echo $mac | cut -c 13-14 -)
maclow=$(echo $mac | cut -c 16-17 -)
# python3 ip.py /etc/firesim/50-cloud-init-static.yaml $((16#$machigh)) $((16#$maclow))
cp /etc/firesim/50-cloud-init-static.yaml /etc/netplan/50-cloud-init.yaml
#echo IPADDR=172.16.$((16#$machigh)).$((16#$maclow)) >> /etc/sysconfig/network-scripts/ifcfg-eth0
;;
"52:54:00")
echo "this looks like not FireSim. exiting"
cp /etc/firesim/50-cloud-init-dhcp.yaml /etc/netplan/50-cloud-init.yaml
;;
esac
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
trying to do Ubuntu
26 changes: 26 additions & 0 deletions boards/firechip/base-workloads/ubuntu-base/overlay/etc/shadow
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
root:$6$soQup5SHA01WBVl8$Ky6UdkSnYBXuW7HEbz0YPWy1/TwU.5BTq.zxrwJbL/su81Q7hCDSOFvMawnYoroWxqqHglPDbm0pUT15E/jWo.:17869:0:99999:7:::
bin:*:17725:0:99999:7:::
daemon:*:17725:0:99999:7:::
adm:*:17725:0:99999:7:::
lp:*:17725:0:99999:7:::
sync:*:17725:0:99999:7:::
shutdown:*:17725:0:99999:7:::
halt:*:17725:0:99999:7:::
mail:*:17725:0:99999:7:::
operator:*:17725:0:99999:7:::
games:*:17725:0:99999:7:::
ftp:*:17725:0:99999:7:::
nobody:*:17725:0:99999:7:::
dbus:!!:17819::::::
systemd-coredump:!!:17819::::::
systemd-network:!!:17819::::::
systemd-resolve:!!:17819::::::
tss:!!:17819::::::
polkitd:!!:17819::::::
rpc:!!:17819:0:99999:7:::
geoclue:!!:17819::::::
kojibuilder:!!:17819::::::
rpcuser:!!:17819::::::
chrony:!!:17819::::::
sshd:!!:17819::::::
pesign:!!:17819::::::
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=FireSim NIC Bringup
After=local-fs.target
Wants=local-fs.target

Before=network-pre.target
Wants=network-pre.target

[Service]
Type=oneshot
ExecStart=/etc/firesim/start-firesim-network.sh

[Install]
WantedBy=network.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
After=systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes

# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by serial-getty@.service, not this
# unit.
ConditionPathExists=/dev/tty0

[Service]
# the VT is cleared by TTYVTDisallocate
ExecStart=-/sbin/agetty --noclear %I $TERM
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes

# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=

[Install]
WantedBy=getty.target
DefaultInstance=tty1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
After=systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
After=rc-local.service

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes

# IgnoreOnIsolate causes issues with sulogin, if someone isolates
# rescue.target or starts rescue.service from multi-user.target or
# graphical.target.
Conflicts=rescue.service
Before=rescue.service

# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by serial-getty@.service, not this
# unit.
ConditionPathExists=/dev/hvc0

[Service]
# the VT is cleared by TTYVTDisallocate
# The '-o' option value tells agetty to replace 'login' arguments with an
# option to preserve environment (-p), followed by '--' for safety, and then
# the entered username.
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear %I $TERM
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes

# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION

[Install]
WantedBy=getty.target
DefaultInstance=hvc0