Setup ⚙️

Welcome to the class! Setting up a Linux environment and compiling your own kernel is required for the course, and this assignment will serve as a guide to get you started. Use this as an opportunity to introduce yourself to the class, and get your feet wet with the git send-email patch submission process we'll be using.

For the purposes of grading, this assignment will be part of the "Homework Exercises" category.

Outcomes:

What to submit:

Procedure:

  1. Install Podman

  2. Open a terminal

  3. (Windows & MacOS only) Initialize and start the Podman machine

    podman machine init
    podman machine start
    
  4. Build your container using the Containerfile we serve you:

    Linux/MacOS:

    sh -c 'read -rp "username: " username && curl -u $username https://fall2026-uml.kdlp.underground.software/Containerfile | podman build -t f26_kdlp_container -'
    

    Windows:

    cmd /v /c "set /p "username=username: " && curl -u !username! https://fall2026-uml.kdlp.underground.software/Containerfile | podman build -t f26_kdlp_container -"
    

    If you want vim to be the default editor in your container instead of nano, include the query parameter ?vim=yes at the end of the URL after /Containerfile.

  5. Create a podman volume for persistent storage

    podman volume create f26_kdlp_volume
    
  6. Get into the container

    podman run -it --rm --hostname kdlp --name kdlp -v f26_kdlp_volume:/home f26_kdlp_container
    

    Note: A previous version of these instructions incorrectly used the volume name kdlp_volume. If you've previously started on this assignment and lost progress:

  7. Clone the submission repository

    git clone https://fall2026-uml.kdlp.underground.software/cgit/submissions
    cd submissions
    
  8. Create a new branch that is a copy of the origin master branch to do your work for the setup assignment

    git checkout --no-track -b setup origin/master
    
  9. Create the $USER/setup directory and subdirectory

    mkdir -p $USER/setup
    cd $USER/setup
    
  10. Add a file named setup.txt to this folder containing an introduction about yourself.

    The content can be whatever you want, whether it be why you are taking this class, your favorite ice cream flavor, or a fun fact about yourself. Use whichever text editor you prefer.

    nano setup.txt # or: vim setup.txt
    
  11. Save the file and exit your text editor

  12. Make a commit out of your changes

  13. Go home

    cd
    
  14. Copy the provided init.config configuration file and init.s source listing from the submissions folder into your home directory

    cp ~/submissions/setup/init.* .
    
  15. Make a directory called rootfs and compile the init program, outputting to this rootfs directory

    mkdir rootfs
    riscv64-linux-gnu-gcc -static-pie -ffreestanding -nostdlib init.s -march=rv64i -mabi=lp64 -o rootfs/init
    
  16. Create a root filesystem image

    cd rootfs && find . | cpio -co > ../rootfs.cpio && cd ..
    
  17. Clone the v7.2 Linux kernel release from git.kernel.org. It's recommended that you set --depth=1 to minimize the download size.

    git clone --depth=1 --branch v7.2 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
    
  18. Enter the linux directory

    cd linux
    
  19. Create a branch to make it easier to track your future work. You will notice a message about being in a "detached head state". When the --branch argument to git clone is supplied with a tag (e.g vX.Y), git doesn't make a branch automatically.

    git checkout -b master
    
  20. Create a file named localversion in the linux directory and add something cool. We suggest it begin with a '.' character, and it must NOT contain spaces. For example, cat localversion might print

    .my-cool-kernel-version
    

    which will result in a kernel version like

    7.2.0.my-cool-kernel-version
    
  21. Make a complete config from the provided config file seed

    ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- make KCONFIG_ALLCONFIG=../init.config allnoconfig
    
  22. Build the kernel

    ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- make -j $(nproc) Image
    
  23. Boot!

    qemu-system-riscv64 -machine virt -bios none -nographic -no-reboot -kernel arch/riscv/boot/Image -initrd ../rootfs.cpio -append 'panic=-1'
    

    At the top of the qemu output you will see the linux kernel version, along with the custom version string you set before in localversion. At the bottom, shortly before the kernel messages about powering down, you will the message "Hello!" that was printed by the sample init program.

  24. Extra credit opportunity

    edit the provided init program to make it interactive, prompt the user for their name by printing a message, then set up a buffer and use the read system call to get a line of input. Print hello followed by echoing back out whatever the user entered to create a custom greeting. The output might look something like

    What is your name? <type in e.g. Linus Torvalds and hit enter>
    Hello, Linus Torvalds
    

    If you choose to do this extra credit, be sure to leave comments in your code since assembly can be hard to read without them. Copy your modified init.s file back into your ~/submissions/$USER/setup/ folder. You will make a commit containing that file as an additional third commit at the end.

  25. Re-run qemu to capture the output in a file you will submit as patch 2. This command uses a shell pipe and the tee program to send a second copy of the output to the standard error stream so it still appears on your terminal while also forwarding it along to the next stage in the pipeline. The tr program then deletes the carriage return characters that would cause whitespace errors. The final stage uses output redirection to save the processed text into a file in your folder.

    qemu-system-riscv64 -machine virt -bios none -nographic -no-reboot -net none -kernel arch/riscv/boot/Image -initrd ../rootfs.cpio -append 'panic=-1' | tee /dev/stderr | tr -d '\r' > ~/submissions/$USER/setup/qemu.txt
    
  26. Create another commit containing just the new $USER/setup/qemu.txt file

    cd ~/submissions
    git add $USER/setup/qemu.txt
    git diff --staged --check #check for whitespace errors, you might have some to fix. Edit the file, re run git add and check until there are none left
    git commit -s
    
  27. If you completed the extra credit, make a commit containing just the init.s file.

    git add $USER/setup/init.s
    git commit -s
    
  28. Next, you'll want to create a patch series, also known as a patchset, with a cover letter out of your commits. To do this, run git format-patch -2 --cover-letter -v1 --rfc (or substitute -3 for -2 if you did the extra credit).

  29. The result of this command should be your directory containing three (or four) new .patch files, courtesy of git. You'll want to open the first of these, v1-0000-cover-letter.patch, in your text editor so that you can write your cover letter according to the guidelines. Don't forget to add the Signed-off-by line at the end of the body right before the automatically generated section containing a summary of the patchset (the first line will have your name and the number of patches in parenthesis e.g. Linus Torvalds (2):).

  30. Verify that your patches apply correctly on the master branch by making a new branch to try applying them

    git checkout -b test origin/master
    
  31. Apply your patches making sure to exclude the cover letter which does not contain any actual changes. Ensure that no errors or warnings are printed. If the patches do not apply, ensure that you created the right number of commits and formatted them into the right number of patches. If there are warnings from whitespace errors, correct the commits using git rebase.

    git am v1-0001*.patch
    git am v1-0002*.patch
    git am v1-0003*.patch #you only need this command if you did the extra credit
    
  32. Switch back to the previous branch and remove your testing branch

    git switch -
    git branch -D test
    
  33. Once you've finished your cover letter, send your patches to the class mailing list. You can do this by running the command git send-email --to=setup@fall2026-uml.kdlp.underground.software v1*.patch.

If your git send-email output ends in Result: 250 then your patchset was sent successfully.

Check your work

You can check the Course Dashboard on the course website to confirm your submission was received. On the dashboard there is a section for each assignment that has been assigned. Look for the section labeled setup. In the table beneath it, if you see a Timestamp and Submission ID in their respective cells, your submission was received successfully. If instead, you see - in those fields, your submission was not received.

After submitting all later assignments, you can check the course dashboard to make sure your submission was successfully received.

Frequently Asked Questions


msg = (silence)
whoami = None
singularity v0.8-13-g02f8b87 https://github.com/underground-software/singularity