add not-os disk image builder and qemu #10
Loading…
Reference in New Issue
No description provided.
Delete Branch "fsagbuya/nix-servo:sdimage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
This patch aims to:
not-os
, built with minimal size using the sd-image builder of nixpkgs as reference.See: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/sd-card/sd-image.nix#L173-L256
postBootCommand
to resize partition on first boot to be added on a separate PR.Do we really need a 2GB output?
It's smarter to make a minimally-sized disk image and resize the partition on first boot like NixOS on Raspberry Pi does.
I also doubt FSBL+uboot+kernel+stage1 needs 200MB.
@ -235,0 +270,4 @@
cp ${not-os-cfg.build.uRamdisk}/initrd /mnt/uramdisk.image.gz
cp ${not-os-cfg.build.kernel}/dtbs/zynq-zc706.dtb /mnt/devicetree.dtb
cat ${rootfs} > /dev/vda2
fsck -f -y /dev/vda2
Not needed.
@ -235,0 +260,4 @@
1 : size=${toString (2048 * 200)}, type=c
2 : type=83
EOF
lsblk
Not needed.
@ -235,0 +239,4 @@
storePaths = [ not-os-cfg.build.toplevel ];
volumeLabel = "root";
};
in pkgs.vmTools.runInLinuxVM (pkgs.runCommand "disk_image" {
I don't think a VM is required to create a few filesystems and copy some files.
Where is this idea from?
The VM method is mainly from make-disk-image.nix and some examples in Github. This can be helpful to run disk formatting commands that require root privileges.
I suspect you can use e2fsprogs and mtools instead to modify the disk image directly without this little circus. Try it.
Also parted is more amenable to command line scripting than sfdisk. See the NixOS installation manual which gives you almost exactly the parted commands you need here.
Understood. Will do as suggested.
You may have to create raw filesystem images for each partition, and then dd them at the correct offsets into the final image with the partitions, unless those tools can deal with the partition tables already. Do your research.
@ -235,0 +271,4 @@
cp ${not-os-cfg.build.kernel}/dtbs/zynq-zc706.dtb /mnt/devicetree.dtb
cat ${rootfs} > /dev/vda2
fsck -f -y /dev/vda2
resize2fs /dev/vda2
Why?
What is that for? NixOS systems don't have a
/nix-path-registration
file and work fine.Does it boot?
In QEMU yes. Still need to test in the physical board.
flake: add not-os disk image builderto WIP: flake: add not-os disk image builderWIP: flake: add not-os disk image builderto WIP: add not-os disk image builder12e0f79931
to94c7cce5de
WIP: add not-os disk image builderto add not-os disk image builderadd not-os disk image builderto add not-os disk image builder and qemuUpdated. See new Description for the changes.
94c7cce5de
to0c349356f5
@ -250,1 +339,3 @@
zc706-not-os = not-os-configured.config.system.build.zynq_image;
zc706-not-os = not-os-cfg.build.zynq_image;
zc706-sd-image = sd-image;
zc706-qemu = not-os-qemu;
What is the difference with the QEMU launcher in zc706-not-os?
zc706-not-os now only builds dtb, kernel and initrd (qemu exluded) while the qemu launcher includes everything, also the sd-image.img for booting in root-fs. It would be cleaner to include these in the zc706-not-os though. However zc706-not-os builds on modules, wasn't able to find a way to include a package in it for now.
It's rather messy to change the not-os PR and update the hash here. Probably better to copy the patches to this repos.
@ -242,0 +250,4 @@
cp $base/sd-image.img /tmp/
chmod +w /tmp/sd-image.img
truncate -s 512m /tmp/sd-image.img
What is this about?
Just use QEMU copy-on-write overlays, duh.
@ -242,0 +254,4 @@
qemu-system-arm \
-M xilinx-zynq-a9 \
-serial /dev/null \
Needed? What does this do?
Got it from an example qemu command in https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/821854273/Running+Bare+Metal+Applications+on+QEMU. It seems when this is omitted, the qemu monitor hangs.
Please add code comment and link to source.
0c349356f5
toe718a865ec
@ -249,2 +335,3 @@
zc706-bootimage = bootimage { board = "zc706"; };
zc706-not-os = not-os-configured.config.system.build.zynq_image;
zc706-not-os = not-os-cfg.build.zynq_image;
zc706-sd-image = sd-image;
There's a blatant problem here since you pass board=zc706 to the functions above and then suddenly stop.
e718a865ec
to34a6d026fd
@ -242,0 +319,4 @@
faketime "1970-01-01 00:00:00" mkfs.vfat -n BOOT firmware_part.img
mkdir firmware
cp ${bootimage { board = "zc706"; }}/boot.bin firmware/
Please read your code again. The problem is only blatant at those lines of code at the end, but runs deeper.
@ -242,0 +247,4 @@
export PATH=${pkgs.qemu}/bin:$PATH
set -x
base=$(dirname $0)
qemu-img create -f qcow2 -b $base/sd-image.img -F raw /tmp/sd-overlay.qcow2 512M
Why -F raw?
And you can use mktemp.
-F raw is the detected backing format for the
img
fileI can read the man page and figure out what -F does. The point is I'm questioning the use of the raw format over the other options that QEMU offers.
Usage here is only for direct backing of the current
img
format, otherwise we can convert the raw image first toqcow2
(or other format recommended) then apply overlay to it.Okay. It's rather unclear from the command line that this applies only to the base SD image. Can you reorder the arguments to make it less confusing, or is this a fundamental issue with the CLI of qemu-img?
And I would avoid reconverting images since those copies are quite large and waste storage or memory.
Rearranged the arguments for clarity while maintaining their intended function.
34a6d026fd
toe00f47f5bb
e00f47f5bb
toc10d81fb3b
c10d81fb3b
tod14d965e81
@ -242,0 +274,4 @@
cd $out
cp -s ${not-os-cfg.build.kernel}/uImage .
cp -s ${not-os-cfg.build.uRamdisk}/initrd uramdisk.image.gz
cp -s ${not-os-cfg.build.kernel}/dtbs/zynq-zc706.dtb devicetree.dtb
Might be OK to merge since this is already broken all over the place, but some deep cleanup of multiple board management will be required at some point.
Will add multiple board management in the next PR. I'm seeing zc702 and zedboard from Xilinx, may I confirm if these are the ones to be added?
I don't care about those. The goal is to support fast-servo and nothing else. zc706 is only for testing.
Understood. Will do some cleanup once testing is done and add the support for fast-servo.
@ -242,0 +322,4 @@
mkdir firmware
cp ${bootimage { inherit board; }}/boot.bin firmware/
cp ${not-os-cfg.build.kernel}/uImage firmware/
cp ${not-os-cfg.build.uRamdisk}/initrd firmware/uramdisk.image.gz
Inconsistent capitalization.
Will add this on a separate PR since editing the case of
uRamdisk
will require not-os hash update, or are you pointing touramdisk.image.gz
that is inconsistent?Yes the names should be exactly the same everywhere, including upper/lowercase letters.
@ -242,0 +246,4 @@
#!/bin/bash
export PATH=${pkgs.qemu}/bin:$PATH
set -x
IMGDIR=$(mktemp -d)
Shouldn't the script delete this at the end?
d14d965e81
to6fd302b8a5
6fd302b8a5
to3aa5b425d6
add not-os disk image builder and qemuto WIP: add not-os disk image builder and qemu3aa5b425d6
to18146ae313
WIP: add not-os disk image builder and qemuto add not-os disk image builder and qemu18146ae313
toc5623e0529
Add a SD card image download link to hydra (nix-support build product) - see the mcu stuff for examples.
c5623e0529
tof8fc8a6f99
f8fc8a6f99
tod7d627ae42
add not-os disk image builder and qemuto WIP: add not-os disk image builder and qemud7d627ae42
to1f62e6a35e
WIP: add not-os disk image builder and qemuto add not-os disk image builder and qemuUpdates: Added hydra build products and enable network support.