Create Linux kernel headers of SP7021

The document shows the steps to create Linux kernel headers of SP7021.

1. Download source files

Source files of SP7021 can be downloaded from GitHub or Yocto server of SP7021. Refer to https://github.com/sunplus-plus1/SP7021 or https://sunplus.atlassian.net/wiki/spaces/doc/pages/506757122. Refer to report of ll command for the contents of top folder of sources of SP7021:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 wellslu@scdiu3:~/q628/sdc$ ll total 56 drwxr-xr-x 13 wellslu sp 4096 Jan 20 11:36 ./ drwxr-xr-x 21 wellslu sp 4096 Jan 17 16:36 ../ drwxr-xr-x 9 wellslu sp 4096 Oct 3 15:10 boot/ drwxr-xr-x 4 wellslu sp 4096 Jan 18 12:38 build/ drwxr-xr-x 11 wellslu sp 4096 Aug 2 17:44 crossgcc/ drwxr-xr-x 6 wellslu sp 4096 Feb 9 2021 dwc/ drwxr-xr-x 6 wellslu sp 4096 Sep 9 2019 eCos/ drwxr-xr-x 5 wellslu sp 4096 Jan 18 12:38 freertos/ drwxr-xr-x 8 wellslu sp 4096 Jan 18 12:38 ipack/ drwxr-xr-x 7 wellslu sp 4096 Sep 9 2019 linux/ -r--r--r-- 1 wellslu sp 23 Sep 9 2019 Makefile drwxr-xr-x 4 wellslu sp 4096 Sep 9 2019 nonos/ drwxr-xr-x 7 wellslu sp 4096 Sep 9 2019 .repo/ drwxr-xr-x 3 wellslu sp 4096 Jun 29 2020 yocto/ wellslu@scdiu3:~/q628/sdc$

2. Config build environment (create linux/kernel/.config)

For example, config build environment for boot from SD card and use BusyBox for BPI-F2S board. Please go to project top folder and run make config. Select 5 for BPI-F2S board, select 2 for boot from SD card, and select 1 for using BusyBox. Refer screenshot below:

make config is starting to configure building environment. It takes 1~2 minutes to complete.

3. Build all images (create linux/kernel/Module.symvers)

Run make all command to start to create image for SD card. It might take several minutes to complete. After make all completes, you will see screen like:

4. Create kernel headers

Please run make headers to create Linux kernel headers. After make headers completes, use ll command to list content of project top folder: Refer to report of ll command below:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 wellslu@scdiu3:~/q628/sdc$ ll total 68 drwxr-xr-x 15 wellslu sp 4096 Jan 20 11:40 ./ drwxr-xr-x 21 wellslu sp 4096 Jan 17 16:36 ../ drwxr-xr-x 9 wellslu sp 4096 Oct 3 15:10 boot/ drwxr-xr-x 4 wellslu sp 4096 Jan 18 12:38 build/ -rw-r--r-- 1 wellslu sp 341 Jan 20 11:37 .config drwxr-xr-x 11 wellslu sp 4096 Aug 2 17:44 crossgcc/ drwxr-xr-x 6 wellslu sp 4096 Feb 9 2021 dwc/ drwxr-xr-x 6 wellslu sp 4096 Sep 9 2019 eCos/ drwxr-xr-x 5 wellslu sp 4096 Jan 18 12:38 freertos/ drwxr-xr-x 8 wellslu sp 4096 Jan 18 12:38 ipack/ drwxr-xr-x 7 wellslu sp 4096 Sep 9 2019 linux/ drwxr-xr-x 6 wellslu sp 4096 Jan 20 11:40 linux-headers-5.10.59-SUNPLUS-v7+/ -r--r--r-- 1 wellslu sp 23 Sep 9 2019 Makefile drwxr-xr-x 4 wellslu sp 4096 Sep 9 2019 nonos/ drwxr-xr-x 3 wellslu sp 4096 Jan 20 11:39 out/ drwxr-xr-x 7 wellslu sp 4096 Sep 9 2019 .repo/ drwxr-xr-x 3 wellslu sp 4096 Jun 29 2020 yocto/ wellslu@scdiu3:~/q628/sdc$

Linux kernel headers is stored at folder: linux-headers-5.10.59-SUNPLUS-v7+

Refer to content of folder: linux-headers-5.10.59-SUNPLUS-v7+

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 wellslu@scdiu3:~/q628/sdc$ ll linux-headers-5.10.59-SUNPLUS-v7+/ total 608 drwxr-xr-x 6 wellslu sp 4096 Jan 20 11:40 ./ drwxr-xr-x 15 wellslu sp 4096 Jan 20 11:40 ../ drwxr-xr-x 3 wellslu sp 4096 Jan 20 11:40 arch/ -rw-r--r-- 1 wellslu sp 97224 Jan 20 11:40 .config -rw-r--r-- 1 wellslu sp 39 Jan 20 11:40 .gitignore drwxr-xr-x 4 wellslu sp 4096 Jan 20 11:40 include/ drwxr-xr-x 2 wellslu sp 4096 Jan 20 11:40 kernel/ -rw-r--r-- 1 wellslu sp 149 Jan 20 11:40 Makefile -rw-r--r-- 1 wellslu sp 1028 Jan 20 11:40 .missing-syscalls.d -rw-r--r-- 1 wellslu sp 484422 Jan 20 11:40 Module.symvers drwxr-xr-x 8 wellslu sp 4096 Jan 20 11:40 scripts/ lrwxrwxrwx 1 wellslu sp 35 Jan 20 11:40 source -> /home/wellslu/q628/sdc/linux/kernel/ wellslu@scdiu3:~/q628/sdc$

5. Install Linux kernel-headers to root file-system of your target board

Before you use Linux kernel-header, please copy whole folder of linux-headers-5.10.59-SUNPLUS-v7+ to /usr/src/ of your target board. Refer to report of ls -l command in RaspiOS where linux-headers has been copied to:

1 2 3 4 5 6 7 8 9 10 11 12 13 pi@raspberrypi:~$ ls -l /usr/src/linux-headers-5.10.59-SUNPLUS-v7+/ total 604 drwxr-xr-x 6 4031 501 4096 Jan 13 09:45 . drwxr-xr-x 3 root root 4096 Jan 13 09:43 .. drwxr-xr-x 3 4031 501 4096 Jan 21 2022 arch -rw-r--r-- 1 4031 501 97224 Jan 21 2022 .config drwxr-xr-x 4 4031 501 4096 Jan 21 2022 include drwxr-xr-x 2 4031 501 4096 Jan 21 2022 kernel -rw-r--r-- 1 4031 501 151 Jan 21 2022 Makefile -rw-r--r-- 1 4031 501 484422 Jan 21 2022 Module.symvers drwxr-xr-x 8 4031 501 4096 Jan 21 2022 scripts lrwxrwxrwx 1 4031 501 36 Jan 21 2022 source -> /home/wellslu/q628/test/linux/kernel pi@raspberrypi:~$

Please remove soft link named source in /usr/src/linux-headers-5.10.59-SUNPLUS-v7+/. It is useless.

Create a soft link named build at /lib/modules/5.10.59-SUNPLUS-V7+/ to /usr/src/linux-headers-5.10.59-SUNPLUS-v7+. For example:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 pi@raspberrypi:~$ sudo ln -s /usr/src/linux-headers-5.10.59-SUNPLUS-v7+ /lib/modules/5.10.59-SUNPLUS-v7+/build pi@raspberrypi:~$ ls -l /lib/modules/5.10.59-SUNPLUS-v7+ total 136 lrwxrwxrwx 1 root root 42 Jan 13 09:49 build -> /usr/src/linux-headers-5.10.59-SUNPLUS-v7+ drwxr-xr-x 6 4031 501 4096 Jan 21 2022 kernel -rw-r--r-- 1 root root 1706 Jan 13 08:45 modules.alias -rw-r--r-- 1 root root 2602 Jan 13 08:45 modules.alias.bin -rw-r--r-- 1 4031 501 7079 Jan 21 2022 modules.builtin -rw-r--r-- 1 root root 9432 Jan 13 08:45 modules.builtin.bin -rw-r--r-- 1 4031 501 50655 Jan 21 2022 modules.builtin.modinfo -rw-r--r-- 1 root root 851 Jan 13 08:45 modules.dep -rw-r--r-- 1 root root 1794 Jan 13 08:45 modules.dep.bin -rw-r--r-- 1 root root 0 Jan 13 08:45 modules.devname -rw-r--r-- 1 4031 501 571 Jan 21 2022 modules.order -rw-r--r-- 1 root root 55 Jan 13 08:45 modules.softdep -rw-r--r-- 1 root root 14595 Jan 13 08:45 modules.symbols -rw-r--r-- 1 root root 18165 Jan 13 08:45 modules.symbols.bin pi@raspberrypi:~$

Appendix: List of target headers in Makefile

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 headers: @KERNELRELEASE=$(shell cat $(LINUX_PATH)/include/config/kernel.release 2>/dev/null) @if ! [ -f $(LINUX_PATH)/.config ]; then \ echo File \'$(LINUX_PATH)/.config\' does not exist!; \ exit 1; \ fi @if ! [ -f $(LINUX_PATH)/Module.symvers ]; then \ echo File \'$(LINUX_PATH)/Module.symvers\' does not exist!; \ exit 1; \ fi rm -rf linux-headers-$(KERNELRELEASE) mkdir -p linux-headers-$(KERNELRELEASE) cp -f $(LINUX_PATH)/.config linux-headers-$(KERNELRELEASE) cp -f $(LINUX_PATH)/Module.symvers linux-headers-$(KERNELRELEASE) $(MAKE_ARCH) $(MAKE_JOBS) -C $(LINUX_PATH) CROSS_COMPILE=$(CROSS_COMPILE_FOR_LINUX) mrproper $(MAKE_ARCH) $(MAKE_JOBS) -C $(LINUX_PATH) O=../../linux-headers-$(KERNELRELEASE) CROSS_COMPILE=$(CROSS_COMPILE_FOR_LINUX) modules_prepare