Build Linux 5.10 LTS for Phicomm N1

Recently I built Linux 5.10 LTS for my N1 box. Below are the patches I needed during the building process.

TEXT_OFFSET

Obsolete: See comments from justin below, it’s no longer necessary to do this. Chainloading u-boot allows you to boot the kernel without this patch.

Due to some quirks in U-boot shipped with N1, we need to apply an offset on TEXT_OFFSET of bootloader. In the past we did this simply by changing arch/arm64/Makefile. However, TEXT_OFFSET is completely removed from Linux 5.8+.

For this matter, I simply reverted that commit.

Here’s the patch for reverting the commit:

N1-specific

I rebased most of the patches I used for Linux 5.0 to Linux 5.10 and applied them, with the exception of the patch regarding to RTL8211F ethernet PHY.

Interrupt for RTL8211F was originally marked as IRQ_TYPE_LEVEL_LOW. Although it does work to some extent, it keeps burn CPU. From my guess the wrongly-marked IRQ type confused the kernel to believe an IRQ is keep firing. The net result is effectively a busy-polling.

So I marked the interrupt IRQ_TYPE_LEVEL_HIGH when building Linux 5.10. The change might be wrong yet it worked well at that time.

However, on Linux 5.10, that patch no longer works. The NIC does not respond to packets at all. I tried all other IRQ types (rising-edge, failing-edge), and none of them works cleanly. Yes IRQ_TYPE_EDGE_BOTH does appear to work, but if you check to see output of dmesg you’d know it’s not “clean” at all.

After some testing, I totally removed the interrupts node, and things works just fine. Presumbly Linux in this case falls back to do polling, in an adaquate interval or something. Not as good as interrupt-driven, yet much better than busy-polling. Besides, I see no visible CPU burns when the box is idle. That’s a “good enough” solution for me.

Another issue with Linux 5.10 was that block device name is no longer stable across reboot, I believed it had something to do with sd_emmc_b. Since N1 do not support SD-card, so I disabled it in device tree.

And here is the patch:

Misc

Just as before, since I’m using the box headlessly, I repurposed frame-buffer for general use by Linux. Apply this patch only if you don’t need video output.

Note that this patch does not affect console output once Linux is fully booted, not sure the reason though.

End note

You can also download the patches here.

3 thoughts on “Build Linux 5.10 LTS for Phicomm N1”

    1. Chainloading u-boot really is an interesting idea. Thank you for sharing this.

Leave a Reply

Your email address will not be published. Required fields are marked *