Skip to content

Instantly share code, notes, and snippets.

@cyring
Created July 16, 2023 11:14
Show Gist options
  • Save cyring/51a43d71e1dc0ec736c0055b08f438ba to your computer and use it in GitHub Desktop.
Save cyring/51a43d71e1dc0ec736c0055b08f438ba to your computer and use it in GitHub Desktop.
linux-orangepi
linux-orangepi
@cyring
Copy link
Author

cyring commented Jul 16, 2023

Build Kernel

In a working directory of your board, clone, build and install the kernel.

  • Adapt the branch name, below, with yours. Mine is Orange Pi 5+
git clone -b orange-pi-5.10-rk3588 git@github.com:orangepi-xunlong/linux-orangepi.git
cd linux-orangepi
zcat /proc/config.gz > .config
make menuconfig

2023-07-16-112057_642x563_scrot

  • Load your build configuration file

2023-07-16-112151_642x563_scrot

  • And check your Platform is the right selected

2023-07-16-112310_642x563_scrot

  • If anything changed then save the configuration

2023-07-16-112618_642x563_scrot

  • Now exit from the configuration menu

2023-07-16-112740_642x563_scrot

*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.
  • Using gcc version 12, fix any building issues like:
  1. mm/page_alloc.c
nano mm/page_alloc.c
#define adj_init_size(start, end, size, pos, adj) \
        do { \
                if (&start[0] <= &pos[0] && &pos[0] < &end[0] && size > adj) \
                        size -= adj; \
        } while (0)
  1. include/linux/etherdevice.h
nano include/linux/etherdevice.h
static inline bool ether_addr_equal_64bits(const u8 *addr1, const u8 *addr2)
  1. Disable XFS_FS
    2023-07-16-122823_642x563_scrot
  2. Disable SCSI_LPFC
    2023-07-16-123826_642x563_scrot
  3. Disable RTLWIFI_DEBUG CONFIG_RTL8192CU CONFIG_RTL8723BE
    2023-07-16-125743_642x563_scrot
  4. Disable BCMDHD
    2023-07-16-130216_642x563_scrot
  5. Disable CONFIG_ATH11K
    2023-07-16-131136_642x563_scrot
  6. Disable CONFIG_AT76C50X_USB
    2023-07-16-132122_642x563_scrot
  7. Disable CONFIG_RTL8852BE
    2023-07-16-132418_642x563_scrot
  8. Disable CONFIG_RTL8189ES CONFIG_RTL8189FS CONFIG_RTL8192EU CONFIG_88XXAU CONFIG_RTL8821CU CONFIG_RTL8188EU CONFIG_RTL8822BU CONFIG_RTL8822CS CONFIG_RTL8723DS CONFIG_RTL8723DU CONFIG_RTL8822BS
    2023-07-16-135020_642x563_scrot
  9. Disable CONFIG_BONDING CONFIG_MACSEC CONFIG_MACVLAN
    2023-07-16-140849_642x563_scrot
  • Build the Kernel using all possible CPUs
make -j8 CFLAGS='-Wno-deprecated-array-compare -Wno-dangling-pointer'

2023-07-16-114645_642x563_scrot

  • Install Kernel and Reboot
sudo make modules_install install

sudo shutdown -r now

2023-07-16-143636_642x563_scrot

@cyring
Copy link
Author

cyring commented Jul 17, 2023

Make Debian package

cd /tmp
wget https://raw.githubusercontent.com/armbian/build/master/patch/misc/headers-debian-byteshift.patch

cd ; cd linux-orangepi
make -j8 deb-pkg

ls *.deb
linux-dtb-_5.10.110+-2_arm64.deb      linux-image-_5.10.110+-2_arm64.deb
linux-headers-_5.10.110+-2_arm64.deb
sudo dpkg -i linux-image-_5.10.110+-2_arm64.deb linux-headers-_5.10.110+-2_arm64.deb linux-dtb-_5.10.110+-2_arm64.deb
Selecting previously unselected package linux-image-.
(Reading database ... 42068 files and directories currently installed.)
Preparing to unpack linux-image-_5.10.110+-2_arm64.deb ...
Unpacking linux-image- (5.10.110+-2) ...
Selecting previously unselected package linux-headers-.
Preparing to unpack linux-headers-_5.10.110+-2_arm64.deb ...
Unpacking linux-headers- (5.10.110+-2) ...
Selecting previously unselected package linux-dtb-.
Preparing to unpack linux-dtb-_5.10.110+-2_arm64.deb ...
Unpacking linux-dtb- (5.10.110+-2) ...
Setting up linux-image- (5.10.110+-2) ...
dkms: running auto installation service for kernel 5.10.110+.
dkms: autoinstall for kernel: 5.10.110+.
update-initramfs: Generating /boot/initrd.img-5.10.110+
update-initramfs: Converting to u-boot format
Free space after deleting the package linux-image- in /boot: 942.4M
Setting up linux-headers- (5.10.110+-2) ...
Compiling headers - please wait ...
Setting up linux-dtb- (5.10.110+-2) ...

Screenshot

2023-07-17-032008_642x563_scrot

sensors
gpu_thermal-virtual-0
Adapter: Virtual device
temp1:        +61.0°C  

littlecore_thermal-virtual-0
Adapter: Virtual device
temp1:        +66.5°C  

bigcore0_thermal-virtual-0
Adapter: Virtual device
temp1:        +67.5°C  

tcpm_source_psy_6_0022-i2c-6-22
Adapter: rk3x-i2c
in0:           0.00 V  (min =  +0.00 V, max =  +0.00 V)
curr1:         0.00 A  (max =  +0.00 A)

npu_thermal-virtual-0
Adapter: Virtual device
temp1:        +62.8°C  

center_thermal-virtual-0
Adapter: Virtual device
temp1:        +61.9°C  

bigcore1_thermal-virtual-0
Adapter: Virtual device
temp1:        +67.5°C  

soc_thermal-virtual-0
Adapter: Virtual device
temp1:        +65.6°C  (crit = +115.0°C)

@cyring
Copy link
Author

cyring commented Jul 17, 2023

Cross compilation

sudo pacman -S aarch64-linux-gnu-gcc

git clone -b orange-pi-5.10-rk3588 git@github.com:orangepi-xunlong/linux-orangepi.git
cd linux-orangepi
make -j1 deb-pkg ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu-
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  CHK     include/generated/compile.h
  CC      kernel/locking/semaphore.o
In file included from ./include/linux/rculist.h:10,
                 from ./include/linux/pid.h:5,
                 from ./include/linux/sched.h:14,
                 from kernel/locking/semaphore.c:30:
In function '__list_add',
    inlined from 'list_add_tail' at ./include/linux/list.h:100:2,
    inlined from '__down_common' at kernel/locking/semaphore.c:209:2:
./include/linux/list.h:70:20: warning: storing the address of local variable 'waiter' in '((struct list_head *)sem)[2].prev' [-Wdangling-pointer=]
error, forbidden warning:list.h:70
   70 |         next->prev = new;
      |         ~~~~~~~~~~~^~~~~
kernel/locking/semaphore.c: In function '__down_common':
kernel/locking/semaphore.c:207:33: note: 'waiter' declared here
  207 |         struct semaphore_waiter waiter;
      |                                 ^~~~~~
kernel/locking/semaphore.c:204:59: note: 'sem' declared here
  204 | static inline int __sched __down_common(struct semaphore *sem, long state,
      |                                         ~~~~~~~~~~~~~~~~~~^~~
make[2]: *** [scripts/Makefile.build:273: kernel/locking/semaphore.o] Error 1
make[2]: *** Deleting file 'kernel/locking/semaphore.o'
make[1]: *** [scripts/Makefile.build:516: kernel/locking] Error 2
make: *** [Makefile:1920: kernel] Error 2

@lalakii
Copy link

lalakii commented Sep 16, 2023

aarch64-linux-gnu-ld: Unexpected GOT/PLT entries detected!
aarch64-linux-gnu-ld: Unexpected run-time procedure linkages detected!
aarch64-linux-gnu-ld: ID map text too big or misaligned
aarch64-linux-gnu-ld: drivers/net/phy/sunxi-ephy.o: in function `ephy_config_init':
sunxi-ephy.c:(.text+0x5f4): undefined reference to `sun50i_ephy_calibrate_value'
aarch64-linux-gnu-ld: drivers/net/phy/sunxi-ephy.o: in function `ac200_ephy_enable.constprop.0':
sunxi-ephy.c:(.text+0x934): undefined reference to `ac200_enable'
aarch64-linux-gnu-ld: sunxi-ephy.c:(.text+0x95c): undefined reference to `ac200_enable'
aarch64-linux-gnu-ld: sunxi-ephy.c:(.text+0xa14): undefined reference to `sun50i_ephy_calibrate_value'
make[1]: *** [scripts/Makefile.vmlinux:34: vmlinux] Error 1
make: *** [Makefile:1255: vmlinux] Error 2
make: *** Waiting for unfinished jobs....

Is it possible for me to get help?

@cyring
Copy link
Author

cyring commented Sep 16, 2023

Is it possible for me to get help?

aarch64-linux-gnu-ld: apparently this is cross compilation; I didn't try further than that.

My Orange-Pi 5+ w/ NVMe storage is fast enough to build kernel directly inside the "box". See How-to above.

@cyring
Copy link
Author

cyring commented Nov 10, 2023

cd
git clone -b orange-pi-5.10-rk35xx git@github.com:orangepi-xunlong/linux-orangepi.git

cd /tmp
wget https://raw.githubusercontent.com/armbian/build/master/patch/misc/headers-debian-byteshift.patch

cd ; cd linux-orangepi
make -j8 bindeb-pkg

cd ; ls *.deb
linux-image-_5.10.160+-3_arm64.deb  linux-headers-_5.10.160+-3_arm64.deb
linux-dtb-_5.10.160+-3_arm64.deb
sudo dpkg -i linux-image-_5.10.160+-3_arm64.deb linux-headers-_5.10.160+-3_arm64.deb linux-dtb-_5.10.160+-3_arm64.deb
Preparing to unpack linux-image-_5.10.160+-3_arm64.deb ...
Unpacking linux-image- (5.10.160+-3) over (5.10.110+-2) ...
Preparing to unpack linux-headers-_5.10.160+-3_arm64.deb ...
Unpacking linux-headers- (5.10.160+-3) over (5.10.110+-2) ...
Setting up linux-image- (5.10.160+-3) ...
dkms: running auto installation service for kernel 5.10.160+.
dkms: autoinstall for kernel: 5.10.160+.
update-initramfs: Generating /boot/initrd.img-5.10.160+
update-initramfs: Converting to u-boot format
Remove unused generated file: /boot/initrd.img-5.10.110+
Free space after deleting the package linux-image- in /boot: 942.1M
Setting up linux-headers- (5.10.160+-3) ...
Compiling headers - please wait ...
Preparing to unpack linux-dtb-_5.10.160+-3_arm64.deb ...
Unpacking linux-dtb- (5.10.160+-3) over (5.10.110+-2) ...
Setting up linux-dtb- (5.10.160+-3) ...
  • Reboot
sudo /sbin/shutdown -r now
  • Cleaning-up
sudo dpkg -l |grep 5.10.110
ii  linux-dtb-legacy-rockchip-rk3588   1.0.6                          arm64        Linux DTB, version 5.10.110-rockchip-rk3588
ii  linux-image-legacy-rockchip-rk3588 1.0.6                          arm64        Linux kernel, version 5.10.110-rockchip-rk3588
sudo dpkg -P linux-dtb-legacy-rockchip-rk3588 linux-image-legacy-rockchip-rk3588
  • Loader
sudo nano /boot/orangepiEnv.txt
verbosity=1
bootlogo=false
extraargs=cma=128M
overlay_prefix=rk3588
fdtfile=rockchip/rk3588-orangepi-5-plus.dtb
rootdev=UUID=xxxx-xxxx-xxxx-xxxx-xxxx
rootfstype=ext4
docker_optimizations=off
verbosity=3
extraargs=nokaslr audit=0 nowatchdog efi=noruntime disable_ipv6=1 carrier_timeout=1 netpoll.carrier_timeout=1
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment