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

Use a more recent kernel #2

Closed
wants to merge 2 commits into from
Closed

Use a more recent kernel #2

wants to merge 2 commits into from

Conversation

dnr
Copy link

@dnr dnr commented Apr 30, 2021

You might not want to merge this directly, but use it as a base and redo some parts if you like.

Warnings:

  • I pulled this out of my personal fork which has a lot more changes and reorganization in it, and haven't verified that everything works. Hopefully if I broke anything it should be pretty obvious.
  • I definitely have not verified that the sdimage works (or even builds).
  • This does not work with petitboot.
  • This uses a custom kernel config. It might work with a default build but since we need to build it anyway, I figured I might as well strip it down a little.
  • I haven't tried hdmi or the hc4's display (I have the base model).
  • The serial console works for both u-boot and the kernel.
  • I haven't tried cross-compiling the kernel. It took a few hours to build on the board itself. If cross-compiling doesn't work, I found the arm instances on ec2 could build it pretty fast.
  • Make sure that the bootable bits are correct in the partition table.

Commit message follows:


This uses kernel 5.11.16 from https://github.com/tobetter/linux
with a custom config pulled from
https://docs.linuxfactory.or.kr/install/odroidhc4/image.html

It does not boot with petitboot (in the HC4 board flash), you need to
either hold the boot switch button while booting or disable petitboot
with these instructions:
https://forum.odroid.com/viewtopic.php?p=318658#p318658
(there are instructions for restoring it here:
https://forum.odroid.com/viewtopic.php?f=207&t=42217)

This splits the uboot module into two, one to build the uboot binary,
and another to handle generating the boot scripts.

Everything goes in the ext4 partition and the vfat partition is now
unused. The boot.scr file refers to all the files it needs directly from
the nix store.

This uses kernel 5.11.16 from https://github.com/tobetter/linux
with a custom config pulled from
https://docs.linuxfactory.or.kr/install/odroidhc4/image.html

It does not boot with petitboot (in the HC4 board flash), you need to
either hold the boot switch button while booting or disable petitboot
with these instructions:
https://forum.odroid.com/viewtopic.php?p=318658#p318658
(there are instructions for restoring it here:
https://forum.odroid.com/viewtopic.php?f=207&t=42217)

This splits the uboot module into two, one to build the uboot binary,
and another to handle generating the boot scripts.

Everything goes in the ext4 partition and the vfat partition is now
unused. The boot.scr file refers to all the files it needs directly from
the nix store.
@considerate
Copy link
Owner

At first glance all of this looks good.

It would be a bit nicer if we could avoid staging the full kernel config here, though. It makes it a trickier to see what the changes are compared to upstream. I tried to follow the link to the LinuxFactory source where you got the Ubuntu config from but since it only provides the full image I'm not sure whether downloading using fetchurl and just providing a patch is warranted.

I'm currently building everything but it looks like I can't get the uboot tools compiling due to a missing header file in openssl:

error: builder for '/nix/store/bdhv67s9lnywg3xqmla002s8dli5qnmn-uboot-tools-only_defconfig-2020.07-aarch64-unknown-linux-gnu.drv' failed with exit code 2;
       last 10 log lines:
       >   HOSTCC  tools/lib/crc32.o
       >   HOSTLD  tools/mkenvimage
       >   HOSTCC  tools/aisimage.o
       > In file included from tools/aisimage.c:9:
       > include/image.h:1174:12: fatal error: openssl/evp.h: No such file or directory
       >  1174 | #  include <openssl/evp.h>
       >       |            ^~~~~~~~~~~~~~~
       > compilation terminated.
       > make[1]: *** [scripts/Makefile.host:112: tools/aisimage.o] Error 1
       > make: *** [Makefile:1782: tools] Error 2

@dnr
Copy link
Author

dnr commented May 3, 2021

Changes compared to the tobetter/linux fork? That one doesn't have an HC4-specific config. It has a config for the odroid-xu4, which is arm7. But otherwise there's just the same arm64 defconfig as in mainline, which built quite a large kernel with tons of builtins and modules that would never be used. The ubuntu images that they built has a smaller config, but I'm not sure if it's in a repo anywhere. It might be fine, though, if the load addresses leave enough room.

For ubootTools: the goal was to use the one in nixpkgs, so it will just get the binary from nixos hydra and not need to build anything. That works for configuration.nix on the board, but not for cross-compiling, because I don't actually know what I'm doing with cross-compiling and nix :) I think the fix is to use buildPackages when calling ./uboot-image.nix. I didn't build the whole sdcard image but nix-build on just pkgs.buildPackages.ubootTools seems to produce the right thing on both my (x86) laptop and my hc4.

@dnr
Copy link
Author

dnr commented Jul 3, 2022

Based on the recent reports of success with stock kernels, I just upgraded my HC4 to nixos 22.05, new u-boot (from NixOS/nixpkgs#101454), and switched to the stock kernel. It's working fine so far and my config is much simpler.

@considerate
Copy link
Owner

@dnr Thanks for the report. Are you using the 2021.01 version of uboot as in that PR? Do you use the odroid-hc4_defconfig or the odroid-c4_defconfig?

https://nixos.wiki/wiki/NixOS_on_ARM/ODROID-HC4#NixOS_installation proposes to just replace that one string but for me that failed with the error that no such defconfig was found in configs. This is consistent with that https://github.com/u-boot/u-boot/tree/v2021.01/configs doesn't have any odroid-hc4_defconfig file.

Also, what do you do about zfs? Does it just build for you or do you get into issues when e.g. compressing the SD image?

@considerate
Copy link
Owner

It's working fine so far and my config is much simpler.

Are you comparing against the hardkernel linux kernel or against what I have in my flake.nix on master?

@dnr
Copy link
Author

dnr commented Jul 3, 2022

I did it with the commands on that wiki page exactly as of yesterday. This repo: https://github.com/samueldr/nixpkgs/commits/wip/odroidc4 , which looks like that PR rebased on a more recent nixpkgs. It looks like I got u-boot 2022.01. I can't see the edit history on the wiki so I'm not sure when it was last updated or who did it, maybe the commands were different when you checked last, or samueldr rebased his branch?

I didn't notice anything in the build logs about zfs, u-boot just built fine on the first try for me. Using pkgsCross on an intel laptop, so I guess it did a cross-compile. I didn't build a full sd-image, I just built u-boot and dd'd it onto my existing sd card, then rebooted. Well, after config changes:

So, my config for the HC4 included two major overrides, basically the contents of this closed PR:

  • The kernel was using tobetter's kernel. I dropped all that so it's using the stock kernel. I also had stuff for nix.buildMachines to point to a graviton ec2 instance to actually compile the kernel natively, since it takes hours on the HC4 and minutes on a beefy VM. I can drop that too since it's not building much anymore.
  • I had those hacked-up scripts to generate a boot.scr file that the old u-boot expected, including uncompressing the initrd and doing the mkimage stuff. I dropped all of that and now just use boot.loader.generic-extlinux-compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants