Skip to content

Commit

Permalink
Merge pull request #307 from firesim/linux6.6
Browse files Browse the repository at this point in the history
Bump to kernel 6.6 with latest buildroot
  • Loading branch information
abejgonzalez authored Jul 16, 2024
2 parents 2913311 + 9da1676 commit cf7cac5
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ jobs:
steps:
- name: Run tests (- spike tests)
run: |
env
unset LD_LIBRARY_PATH
cd ${{ env.REMOTE_WORK_DIR }}
eval "$(conda shell.bash hook)"
conda activate $PWD/.conda-env
Expand Down
8 changes: 4 additions & 4 deletions boards/chipyard/base-workloads/br-base/buildroot-config
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ BR2_PACKAGE_PROVIDES_TOOLCHAIN_EXTERNAL="toolchain-external-custom"
BR2_TOOLCHAIN_EXTERNAL_PREFIX="$(ARCH)-unknown-linux-gnu"
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARCH_SUPPORTS=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-unknown-linux-gnu"
BR2_TOOLCHAIN_EXTERNAL_GCC_12=y
# BR2_TOOLCHAIN_EXTERNAL_GCC_12 is not set
# BR2_TOOLCHAIN_EXTERNAL_GCC_11 is not set
# BR2_TOOLCHAIN_EXTERNAL_GCC_10 is not set
# BR2_TOOLCHAIN_EXTERNAL_GCC_9 is not set
Expand All @@ -117,7 +117,7 @@ BR2_TOOLCHAIN_EXTERNAL_GCC_12=y
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_13 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_12 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_11 is not set
BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_10=y
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_10 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_9 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_8 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_7 is not set
Expand Down Expand Up @@ -178,8 +178,8 @@ BR2_TOOLCHAIN_EXTERNAL_HAS_SSP_STRONG=y
# BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
# BR2_TOOLCHAIN_EXTERNAL_DLANG is not set
# BR2_TOOLCHAIN_EXTERNAL_FORTRAN is not set
# BR2_TOOLCHAIN_EXTERNAL_OPENMP is not set
BR2_TOOLCHAIN_EXTERNAL_FORTRAN=y
BR2_TOOLCHAIN_EXTERNAL_OPENMP=y
# BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY is not set
BR2_PACKAGE_HOST_GDB_ARCH_SUPPORTS=y

Expand Down
16 changes: 16 additions & 0 deletions boards/default/distros/br/br.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ def configure(self, env):
mergeScript = br_dir / 'merge_config.sh'
wlutil.run([mergeScript] + kFrags, cwd=(br_dir / 'buildroot'), env=env)

# Fakeroot needs to be set to 1.31 to compile with sysroot 2.17
fakerootVersion = 1.31
fakerootSite = "https://snapshot.debian.org/archive/debian/20240401T084438Z/pool/main/f/fakeroot"
fakerootTarFile = f"fakeroot_{fakerootVersion}.orig.tar.gz"
fakerootTar = br_dir / fakerootTarFile
fakerootDir = br_dir / f"fakeroot-{fakerootVersion}"

urllib.request.urlretrieve(fakerootSite + "/" + fakerootTarFile, fakerootTar)
wlutil.run(["tar", "-xzvf", str(fakerootTar)], cwd=br_dir, env=env)

# create a local.mk for buildroot
# Do this to override builtin buildroot package sourcecodes as needed
localMk = br_dir / 'buildroot' / 'local.mk'
with open(localMk, 'w') as f:
f.write(f"FAKEROOT_OVERRIDE_SRCDIR = {str(fakerootDir)}")

# Build a base image in the requested format and return an absolute path to that image
def buildBaseImage(self, task, changed):
"""Ensures that the image file specified by baseConfig() exists and is up to date.
Expand Down
2 changes: 1 addition & 1 deletion boards/default/distros/br/buildroot
Submodule buildroot updated 6861 files
2 changes: 1 addition & 1 deletion boards/default/linux
Submodule linux updated from e3e5d2 to 67bc45
8 changes: 4 additions & 4 deletions boards/firechip/base-workloads/br-base/buildroot-config
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ BR2_PACKAGE_PROVIDES_TOOLCHAIN_EXTERNAL="toolchain-external-custom"
BR2_TOOLCHAIN_EXTERNAL_PREFIX="$(ARCH)-unknown-linux-gnu"
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARCH_SUPPORTS=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-unknown-linux-gnu"
BR2_TOOLCHAIN_EXTERNAL_GCC_12=y
# BR2_TOOLCHAIN_EXTERNAL_GCC_12 is not set
# BR2_TOOLCHAIN_EXTERNAL_GCC_11 is not set
# BR2_TOOLCHAIN_EXTERNAL_GCC_10 is not set
# BR2_TOOLCHAIN_EXTERNAL_GCC_9 is not set
Expand All @@ -116,7 +116,7 @@ BR2_TOOLCHAIN_EXTERNAL_GCC_12=y
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_13 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_12 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_11 is not set
BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_10=y
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_10 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_9 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_8 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_7 is not set
Expand Down Expand Up @@ -177,8 +177,8 @@ BR2_TOOLCHAIN_EXTERNAL_HAS_SSP_STRONG=y
# BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
# BR2_TOOLCHAIN_EXTERNAL_DLANG is not set
# BR2_TOOLCHAIN_EXTERNAL_FORTRAN is not set
# BR2_TOOLCHAIN_EXTERNAL_OPENMP is not set
BR2_TOOLCHAIN_EXTERNAL_FORTRAN=y
BR2_TOOLCHAIN_EXTERNAL_OPENMP=y
# BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY is not set
BR2_PACKAGE_HOST_GDB_ARCH_SUPPORTS=y

Expand Down
7 changes: 4 additions & 3 deletions wlutil/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ def makeModules(cfg):
["modules_prepare", '-j' + str(wlutil.getOpt('jlevel'))],
cwd=linCfg['source'])

makeCmd = "make LINUXSRC=" + str(linCfg['source'])
# MODPOST errors are warnings, since we built the extmods without building the kernel first
makeCmd = "make KBUILD_MODPOST_WARN=1 LINUXSRC=" + str(linCfg['source'])

for driverDir in linCfg['modules'].values():
wlutil.checkSubmodule(driverDir)
Expand Down Expand Up @@ -552,8 +553,8 @@ def makeBin(config, nodisk=False):
initramfsPath = ""
if nodisk:
initramfsIncludes += [wlutil.getOpt('initramfs-dir') / "nodisk"]
with wlutil.mountImg(config['img'], wlutil.getOpt('mnt-dir')):
initramfsIncludes = [wlutil.getOpt('mnt-dir')] + initramfsIncludes
with wlutil.mountImg(config['img'], wlutil.getOpt('mount-dir')):
initramfsIncludes = [wlutil.getOpt('mount-dir')] + initramfsIncludes
# This must be done while in the mountImg context
initramfsPath = makeInitramfs(initramfsIncludes, cpioDir, includeDevNodes=True)
else:
Expand Down
3 changes: 3 additions & 0 deletions wlutil/default-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ log-dir : '../logs'
# SW-simulation outputs
res-dir : '../runOutput'

# mount working directory
mount-dir : "../disk-mount"

# Location of the FireSim repository. Used by the 'install' command. Null
# indicates that no FireSim installation is available.
firesim-dir : null
Expand Down
50 changes: 27 additions & 23 deletions wlutil/wlutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,34 @@ def cleanPaths(opts, baseDir=pathlib.Path('.')):
relative to baseDir."""

# These options represent pathlib paths
# (path, needsStrict)
# mount-dir will be created by marshal, so this path may not exist
pathOpts = [
'board-dir',
'image-dir',
'linux-dir',
'firesim-dir',
'opensbi-dir',
'log-dir',
'res-dir',
'workload-dirs'
('board-dir', True),
('image-dir', True),
('linux-dir', True),
('firesim-dir', True),
('opensbi-dir', True),
('log-dir', True),
('res-dir', True),
('mount-dir', False),
('workload-dirs', True)
]

def clean(path):
return (baseDir / pathlib.Path(path)).resolve(strict=True)
def clean(path, needsStrict):
return (baseDir / pathlib.Path(path)).resolve(strict=needsStrict)

for opt in pathOpts:
for (opt, needsStrict) in pathOpts:
if opt in opts and opts[opt] is not None:
try:
if isinstance(opts[opt], str):
# Scalar path
opts[opt] = clean(opts[opt])
opts[opt] = clean(opts[opt], needsStrict)
else:
# List of paths
cleanedPaths = []
for p in opts[opt]:
cleanedPaths.append(clean(p))
cleanedPaths.append(clean(p, needsStrict))
opts[opt] = cleanedPaths
except Exception as e:
raise ConfigurationOptionError(opt, "Invalid path: " + str(e))
Expand All @@ -161,6 +164,7 @@ def clean(path):
'image-dir',
'firesim-dir',
'log-dir',
'mount-dir',
'res-dir',
'jlevel', # int or str from user, converted to '-jN' after loading
'rootfs-margin', # int or str from user, converted to int bytes after loading
Expand Down Expand Up @@ -188,9 +192,6 @@ def clean(path):
# Storage for generated/temporary outputs
'gen-dir',

# Empty directory used for mounting images
'mnt-dir',

# Path to basic template for user-specified commands (the "command:" option)
'command-script',

Expand Down Expand Up @@ -328,7 +329,6 @@ def deriveOpts(self):
self['busybox-dir'] = self['wlutil-dir'] / 'busybox'
self['initramfs-dir'] = self['wlutil-dir'] / "initramfs"
self['gen-dir'] = self['wlutil-dir'] / "generated"
self['mnt-dir'] = self['root-dir'] / "disk-mount"
self['command-script'] = self['gen-dir'] / "_command.sh"
self['run-name'] = ""
self['rootfs-margin'] = humanfriendly.parse_size(str(self['rootfs-margin']))
Expand Down Expand Up @@ -411,7 +411,7 @@ def initialize():
global ctx
ctx = marshalCtx()

ctx['mnt-dir'].mkdir(parents=True, exist_ok=True)
ctx['mount-dir'].mkdir(parents=True, exist_ok=True)

# Directories that must be initialized for disk-based initramfs
initramfs_disk_dirs = ["bin", 'dev', 'etc', 'proc', 'root', 'sbin', 'sys', 'usr/bin', 'usr/sbin', 'mnt/root']
Expand Down Expand Up @@ -620,6 +620,10 @@ def mountImg(imgPath, mntPath):
finally:
run_with_retries(sudoCmd + [fsimUnmountCmd, mntPath])
else:
# guestmount does not support NFS filesystems
fstype = sp.run(["df", mntPath, "--output=fstype"], capture_output=True, text=True).stdout.strip().splitlines()[-1]
assert "nfs" not in fstype, f"Guestmount does not support {fstype} filesystems, change mount-dir to a non-NFS filesystem"

pidPath = './guestmount.pid'
run(['guestmount', '--pid-file', pidPath, '-o', f'uid={uid}', '-o', f'gid={gid}', '-a', imgPath, '-m', '/dev/sda', mntPath])
try:
Expand Down Expand Up @@ -694,12 +698,12 @@ def copyImgFiles(img, files, direction):
"""
log = logging.getLogger()
assert direction in ['in', 'out'], f"direction={direction} must be either 'in' or 'out'"
with mountImg(img, getOpt('mnt-dir')):
with mountImg(img, getOpt('mount-dir')):
for f in files:
cpSrcMaybeRelPath = f.src if direction == 'in' else f.src.relative_to('/')
cpDstMaybeRelPath = f.dst.relative_to('/') if direction == 'in' else f.dst
cpSrcResPath = cpSrcMaybeRelPath if direction == 'in' else getOpt('mnt-dir') / cpSrcMaybeRelPath
cpDstResPath = getOpt('mnt-dir') / cpDstMaybeRelPath if direction == 'in' else cpDstMaybeRelPath
cpSrcResPath = cpSrcMaybeRelPath if direction == 'in' else getOpt('mount-dir') / cpSrcMaybeRelPath
cpDstResPath = getOpt('mount-dir') / cpDstMaybeRelPath if direction == 'in' else cpDstMaybeRelPath

# modify perms for dirs to always be able to copy in/out
oldPerms = {} # store old permissions
Expand All @@ -708,9 +712,9 @@ def copyImgFiles(img, files, direction):

# irrespective if the mountpoint is src/dst, modify all dirs up to mountpoint (including the src/dst dir)
withinMountRelPath = cpDstMaybeRelPath if direction == 'in' else cpSrcMaybeRelPath
withinMountPath = getOpt('mnt-dir') / withinMountRelPath
withinMountPath = getOpt('mount-dir') / withinMountRelPath
parents = withinMountRelPath.parents if withinMountRelPath.parents else '.'
dirsToModify.extend([getOpt('mnt-dir') / e for e in reversed(parents)])
dirsToModify.extend([getOpt('mount-dir') / e for e in reversed(parents)])
dirsToModify.extend([withinMountPath] if withinMountPath.is_dir() else [])
# also ensure that if copying a directory into a mountpoint, that directory can be written in the mountpoint
dirsToModify.extend([cpDstResPath / cpSrcResPath.name] if direction == 'in' and cpSrcResPath.is_dir() else [])
Expand Down

0 comments on commit cf7cac5

Please sign in to comment.