Modify kernel flags/modules pre-flash?

The new(ish) 36.2 OS needs several kernel features/modules enabled in order to work with Kubernetes.

I’d prefer not to have to modify the kernel after the flash, since it’s a bit of a process, and I always feel like I mess something up. I tried recently with nvbuild, and it seems to only want to take the default .config instead of the modifications I make with nconfig beforehand…

Is there a way to pass a .config file to the installation process? Or prepare the OS within the sample file system so that the flash installs the features I want ahead of time? I’d love to have something reproducible so that I can just re-flash if necessary, and have all my flags set.

I’m doing the flashing manually via this process:

wget -O bsp.tbz2 -L
wget -O rootfs.tbz2 -L

tar -xvpf bsp.tbz2
sudo tar -xvpf rootfs.tbz2 -C Linux_for_Tegra/rootfs/

### I'm thinking I can modify the source to use my custom .config at this point?

cd Linux_for_Tegra

sudo ./  
sudo ./tools/
sudo ./tools/ ...
sudo ./tools/kernel_flash/ ...

This is the content of Linux_for_Tegra/source/kernel/Makefile.
You just run these comnmands separately when you want to customize the kernel:
(Like menuconfig after defconfig and before Image.)

	@echo   "================================================================================"
	@echo   "Building $(KERNEL_SRC_DIR) sources"
	@echo   "================================================================================"
	$(MAKE) \
		ARCH=arm64 \
		-C $(kernel_source_dir) \
		LOCALVERSION=$(version) \

	$(MAKE) -j $(NPROC) \
		ARCH=arm64 \
		-C $(kernel_source_dir) \
		LOCALVERSION=$(version) \
		--output-sync=target Image

	$(MAKE) -j $(NPROC) \
		ARCH=arm64 \
		-C $(kernel_source_dir) \
		LOCALVERSION=$(version) \
		--output-sync=target dtbs

	$(MAKE) -j $(NPROC) \
		ARCH=arm64 \
		-C $(kernel_source_dir) \
		LOCALVERSION=$(version) \
		--output-sync=target modules

	@echo   "================================================================================"
	@if [ -f "$(kernel_image)" ] ; then \
		echo   "Kernel Image: $(kernel_image)"; \
	else \
		echo   "Error: Missing kernel image: $(kernel_image)"; \
        false ; \
	@echo   "Kernel sources compiled successfully."
	@echo   "================================================================================"

You’d better wait for JetPack 6 GA so the kernel compilation process is fixed, or you need to know how to update the initrd to include newly compiled drivers, or NVMe and USB cannot be mounted as rootfs upon booting:

For customizing rootfs:

Hello, Dave!

I do see that Makefile. Does that get invoked sometime during l4t_initrd_flash? Would I just prep my “golden image” where I was thinking originally (before running apply_binaries)?

Thanks for the heads up about JetPack - any sense on when that will be release? I’m not sure I understand, though - is that for when you want to modify an existing distro, or is that a bug during pre-flash, too?

Thanks for the support!

Kernel compilation has nothing to do with flashing.
You just make sure the kernel image/modules are there before flashing.

Usually when you build kernel natively on an x86 machine, many distros like Ubuntu offer a tool for updating the initramfs, or initrd, so appropriate drivers can be loaded upon boot:
Basically we are making a replicate of this tool so it can be run on the host PC when you do cross compilation. Or drivers for NVMe/USB in the vanilla initrd will fail to get loaded because the kernel version does not match.

It’s now scheduled top be released in early May.

Ok, so it seems like my original intuition wasn’t too far off.

  1. Fetch source
  2. Modify source via existing Makefile. If there are files present, they carry over to the board. Would it behoove me to just edit the kernel command, to include nconfig? then just make kernel before flashing?
    a. defconfig
    b. nconfig
    c. Image
  3. Execute flashing scripts

I’m still not following you on the JetPack bits. I’ve successfully flashed 36.2 from a ubuntu x86 to my Orin on NVMe storage. Is this only a problem when modifying the kernel beforehand?

Will the update be in the form of a 36.3, or what should I be on the lookout for?

You run defconfig to populate the initial .config file, then you run nconfig/menuconfig to customize it, then finally you run Image to actually build it.
Nothing difficult.

YES, whenever the kernel image changes.
If you don’t what I’m talking about with initramfs/initrd, then you’d better just stop here and go no further.

YES, 36.3/JetPack 6 GA.

Thank you!! I’ll stay tuned for the patch. You rock!

Ah, one more, if the changes I’m making within nconfig include modules, should I pre-build the modules, or just let the normal process pick them up?

You don’t really need to care about what this file does.
It’s totally fine if you run every commands separately. We just make this Makefile for simplicity, and you don’t necessarily need to follow it.

These instructions work to at least run make kernel (using 36.2). Will report back after the next version is released!

Thanks, again!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.