From 54ef7d52f9a8aa317a03a5b24eaa3d26ec504e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 22 Jan 2019 00:00:00 +0000 Subject: [PATCH] gem5: initramfs works, obviously :-) --- README.adoc | 16 +++++++++++----- common.py | 22 ++++++++++++++-------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/README.adoc b/README.adoc index 652a2d0..50181f0 100644 --- a/README.adoc +++ b/README.adoc @@ -2654,7 +2654,7 @@ It is also possible to compress that image with other options. + Buildroot forces that option when `BR2_TARGET_ROOTFS_CPIO=y` is given -https://unix.stackexchange.com/questions/89923/how-does-linux-load-the-initrd-image asks how the mechanism works in more detail. +TODO: how does the bootloader inform the kernel where to find initrd? https://unix.stackexchange.com/questions/89923/how-does-linux-load-the-initrd-image === initrd in desktop distros @@ -2674,8 +2674,6 @@ Related: https://stackoverflow.com/questions/6405083/initrd-and-booting-the-linu === initramfs -TODO: broken when we started building the Linux manually with `./build-linux` instead of Buildroot. Was working before, see e.g. 56738a1c70e50bf7b6d5fbe02372c5d277a8286f. - initramfs is just like <>, but you also glue the image directly to the kernel image itself using the kernel's build system. Try it out with: @@ -2719,9 +2717,17 @@ http://nairobi-embedded.org/initramfs_tutorial.html shows a full manual setup. TODO we were not able to get it working yet: https://stackoverflow.com/questions/49261801/how-to-boot-the-linux-kernel-with-initrd-or-initramfs-with-gem5 -This would require gem5 to load the CPIO into memory, just like QEMU, which it does not seem to support. It should not be hard to implement however. +This would require gem5 to load the CPIO into memory, just like QEMU. Grepping `initrd` shows some ARM hits under: -initramfs might just work however, TODO test it out. +.... +src/arch/arm/linux/atag.hh +.... + +but they are commented out. + +Initramfs just works however, since gem5 does not need to do anything special there, it just dumps the kernel into memory as usual, it just happens to transparently contain a CPIO disk image attached. + +We just have to pass a dummy disk image as of gem5 7fa4c946386e7207ad5859e8ade0bbfc14000d91 since the scripts don't handle a missing `--disk-image` well, much like is currently done for <>. == Device tree diff --git a/common.py b/common.py index 11efe18..5136116 100644 --- a/common.py +++ b/common.py @@ -257,6 +257,9 @@ Use the given directory as the Linux source tree. self.add_argument( '--initramfs', default=False, + help='''\ +See: https://github.com/cirosantilli/linux-kernel-module-cheat#initramfs +''' ) self.add_argument( '--initrd', @@ -642,14 +645,7 @@ Valid emulators: {} env['qcow2_file'] = env['buildroot_qcow2_file'] # Image - if not env['_args_given']['baremetal']: - if env['emulator'] == 'gem5': - env['image'] = env['vmlinux'] - env['disk_image'] = env['rootfs_raw_file'] - else: - env['image'] = env['linux_image'] - env['disk_image'] = env['qcow2_file'] - else: + if env['_args_given']['baremetal']: env['disk_image'] = env['gem5_fake_iso'] if env['baremetal'] == 'all': path = env['baremetal'] @@ -670,6 +666,16 @@ Valid emulators: {} env['source_path'] = source_path break env['image'] = path + else: + if env['emulator'] == 'gem5': + env['image'] = env['vmlinux'] + if env['ramfs']: + env['disk_image'] = env['gem5_fake_iso'] + else: + env['disk_image'] = env['rootfs_raw_file'] + else: + env['image'] = env['linux_image'] + env['disk_image'] = env['qcow2_file'] def add_argument(self, *args, **kwargs): '''