Several patches I’m using for running Linux 5.0 on Phicomm N1meson-text-offset.patch
: Patch for moving TEXT_OFFSET
. This is necessary for booting Linux on Meson SoCs.123456789101112131415161718192021222324 diff -uNr a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S--- a/arch/arm64/kernel/head.S 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/kernel/head.S 2019-01-01 00:00:00.000000000 +0000@@ -52,7 +52,7 @@ #elif (PAGE_OFFSET & 0x1fffff) != 0 #error PAGE_OFFSET must be at least 2MB aligned #elif TEXT_OFFSET > 0x1fffff-#error TEXT_OFFSET must be less than 2MB+// #error TEXT_OFFSET must be less than 2MB #endif /*diff -uNr a/arch/arm64/Makefile b/arch/arm64/Makefile--- a/arch/arm64/Makefile 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/Makefile 2019-01-01 00:00:00.000000000 +0000@@ -98,7 +98,7 @@ int(2 * 1024 * 1024 / (2 ^ $(CONFIG_ARM64_PAGE_SHIFT)) * \ rand()) * (2 ^ $(CONFIG_ARM64_PAGE_SHIFT))}") else-TEXT_OFFSET := 0x00080000+TEXT_OFFSET := 0x01080000 endif ifeq ($(CONFIG_KASAN_SW_TAGS), y)
decrease-emmc-max-frequency.patch
: Cap (internal) eMMC’s max-frequency
. This is necessary for Phicomm N1 to boot.123456789101112 diff -uNr a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi--- a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi 2019-01-01 00:00:00.000000000 +0000@@ -202,7 +202,7 @@ bus-width = <8>; cap-mmc-highspeed;- max-frequency = <200000000>;+ max-frequency = <100000000>; non-removable; disable-wp; mmc-ddr-1_8v;
disable-usb2-lpm.patch
: Disable USB2 LPM. This works around several broken USB2 LPM implementations found in USB3 devices.123456789101112 diff -uNr a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi--- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi 2019-01-01 00:00:00.000000000 +0000@@ -33,6 +33,8 @@ dr_mode = "host"; maximum-speed = "high-speed"; snps,dis_u2_susphy_quirk;+ /* Workaround for broken LPM implementation found in many USB3 devices. */+ usb2-lpm-disable; phys = <&usb3_phy>, <&usb2_phy0>, <&usb2_phy1>; }; };
use-level-high-for-eth-phy-interrupt.patch
: Honestly I’m not sure it’s the right patch. Anyway, it solves the issue that IRQ #35 (or some other one dedicated to Ethernet PHY by kernel) keeps firing, which results in high load average
in top
.
This patch does not work for Linux 5.10 (and possibly other versions I haven’t tested).
1234567891011121314 ```diffdiff -uNr a/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts 2019-01-01 00:00:00.000000000 +0000@@ -85,7 +85,7 @@ reg = <0>; max-speed = <1000>; interrupt-parent = <&gpio_intc>;- interrupts = <29 IRQ_TYPE_LEVEL_LOW>;+ interrupts = <29 IRQ_TYPE_LEVEL_HIGH>; }; };```
reduce-reserved-memory-for-hwrom.patch
: Free some once reserved memory. This patch is not necessary if you don’t care about free memory or experience issues after applying it.1234567891011121314 --- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi 2019-01-01 00:00:00.000000000 +0000@@ -23,9 +23,10 @@ #size-cells = <2>; ranges; - /* 16 MiB reserved for Hardware ROM Firmware */+ /* 1 MiB reserved for Hardware ROM Firmware */+ /* @sa: https://github.com/khadas/linux/commit/698df2c6cfbb0d1a9359743208e83517b31da6ce */ hwrom_reserved: hwrom@0 {- reg = <0x0 0x0 0x0 0x1000000>;+ reg = <0x0 0x0 0x0 0x100000>; no-map; };
remove-eee-broken-1000t.patch
: Remove no longer necessary eee-broken-1000t
. This patch makes little difference in daily use.12345678910 diff -uNr a/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts 2019-01-01 00:00:00.000000000 +0000@@ -86,7 +86,6 @@ max-speed = <1000>; interrupt-parent = <&gpio_intc>; interrupts = <29 IRQ_TYPE_LEVEL_LOW>;- eee-broken-1000t; }; };
expose-all-memory-to-linux.patch
: Expose all memory to Linux, including those reserved for frame buffer. This patch could mass up Phicomm N1’s video output completely. (Not permanently, however. The video output will happily come back once you revert the patch.) Apply it only if you’re using the box headlessly (as I am).12345678910 diff -uNr a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi--- a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi 2019-01-01 00:00:00.000000000 +0000@@ -20,6 +20,7 @@ memory@0 { device_type = "memory";+ linux,usable-memory = <0x0 0x0 0x0 0x80000000>; reg = <0x0 0x0 0x0 0x80000000>; };
Here is the zip archive of all the patches above: linux-5.0.0-phicomm-n1-patches.zip.
meson-text-offset.patch
: Patch for movingTEXT_OFFSET
. This is necessary for booting Linux on Meson SoCs.123456789101112131415161718192021222324diff -uNr a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S--- a/arch/arm64/kernel/head.S 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/kernel/head.S 2019-01-01 00:00:00.000000000 +0000@@ -52,7 +52,7 @@#elif (PAGE_OFFSET & 0x1fffff) != 0#error PAGE_OFFSET must be at least 2MB aligned#elif TEXT_OFFSET > 0x1fffff-#error TEXT_OFFSET must be less than 2MB+// #error TEXT_OFFSET must be less than 2MB#endif/*diff -uNr a/arch/arm64/Makefile b/arch/arm64/Makefile--- a/arch/arm64/Makefile 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/Makefile 2019-01-01 00:00:00.000000000 +0000@@ -98,7 +98,7 @@int(2 * 1024 * 1024 / (2 ^ $(CONFIG_ARM64_PAGE_SHIFT)) * \rand()) * (2 ^ $(CONFIG_ARM64_PAGE_SHIFT))}")else-TEXT_OFFSET := 0x00080000+TEXT_OFFSET := 0x01080000endififeq ($(CONFIG_KASAN_SW_TAGS), y)decrease-emmc-max-frequency.patch
: Cap (internal) eMMC’smax-frequency
. This is necessary for Phicomm N1 to boot.123456789101112diff -uNr a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi--- a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi 2019-01-01 00:00:00.000000000 +0000@@ -202,7 +202,7 @@bus-width = <8>;cap-mmc-highspeed;- max-frequency = <200000000>;+ max-frequency = <100000000>;non-removable;disable-wp;mmc-ddr-1_8v;disable-usb2-lpm.patch
: Disable USB2 LPM. This works around several broken USB2 LPM implementations found in USB3 devices.123456789101112diff -uNr a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi--- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi 2019-01-01 00:00:00.000000000 +0000@@ -33,6 +33,8 @@dr_mode = "host";maximum-speed = "high-speed";snps,dis_u2_susphy_quirk;+ /* Workaround for broken LPM implementation found in many USB3 devices. */+ usb2-lpm-disable;phys = <&usb3_phy>, <&usb2_phy0>, <&usb2_phy1>;};};use-level-high-for-eth-phy-interrupt.patch
: Honestly I’m not sure it’s the right patch. Anyway, it solves the issue that IRQ #35 (or some other one dedicated to Ethernet PHY by kernel) keeps firing, which results in highload average
intop
.
This patch does not work for Linux 5.10 (and possibly other versions I haven’t tested).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ```diff diff -uNr a/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts --- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts 2019-01-01 00:00:00.000000000 +0000 +++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts 2019-01-01 00:00:00.000000000 +0000 @@ -85,7 +85,7 @@ reg = <0>; max-speed = <1000>; interrupt-parent = <&gpio_intc>; - interrupts = <29 IRQ_TYPE_LEVEL_LOW>; + interrupts = <29 IRQ_TYPE_LEVEL_HIGH>; }; }; ``` |
reduce-reserved-memory-for-hwrom.patch
: Free some once reserved memory. This patch is not necessary if you don’t care about free memory or experience issues after applying it.1234567891011121314--- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi 2019-01-01 00:00:00.000000000 +0000@@ -23,9 +23,10 @@#size-cells = <2>;ranges;- /* 16 MiB reserved for Hardware ROM Firmware */+ /* 1 MiB reserved for Hardware ROM Firmware */+ /* @sa: https://github.com/khadas/linux/commit/698df2c6cfbb0d1a9359743208e83517b31da6ce */hwrom_reserved: hwrom@0 {- reg = <0x0 0x0 0x0 0x1000000>;+ reg = <0x0 0x0 0x0 0x100000>;no-map;};remove-eee-broken-1000t.patch
: Remove no longer necessaryeee-broken-1000t
. This patch makes little difference in daily use.12345678910diff -uNr a/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905d-p230.dts 2019-01-01 00:00:00.000000000 +0000@@ -86,7 +86,6 @@max-speed = <1000>;interrupt-parent = <&gpio_intc>;interrupts = <29 IRQ_TYPE_LEVEL_LOW>;- eee-broken-1000t;};};expose-all-memory-to-linux.patch
: Expose all memory to Linux, including those reserved for frame buffer. This patch could mass up Phicomm N1’s video output completely. (Not permanently, however. The video output will happily come back once you revert the patch.) Apply it only if you’re using the box headlessly (as I am).12345678910diff -uNr a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi--- a/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi 2019-01-01 00:00:00.000000000 +0000+++ b/arch/arm64/boot/dts/amlogic/meson-gx-p23x-q20x.dtsi 2019-01-01 00:00:00.000000000 +0000@@ -20,6 +20,7 @@memory@0 {device_type = "memory";+ linux,usable-memory = <0x0 0x0 0x0 0x80000000>;reg = <0x0 0x0 0x0 0x80000000>;};Here is the zip archive of all the patches above: linux-5.0.0-phicomm-n1-patches.zip.
decrease-emmc-max-frequency.patch is not needed at all. here is my N1 DTS:
cap-mmc-highspeed;
max-frequency = ;