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:

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:

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+

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:

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:

Appendix: List of target headers in Makefile