# preempt_rt kernel compile [EC-master blog post](https://www.acontis.com/zh/blog.html) several realtime kernel setting, install make sure your linux kernel version, and modify the relevent part in instruction below. - [Building a Real-time Linux Kernel in Ubuntu with PREEMPT_RT](https://www.acontis.com/en/building-a-real-time-linux-kernel-in-ubuntu-preemptrt.html) - [Linux RT补丁/分析/性能测试(@Ubuntu)](https://www.cnblogs.com/arnoldlu/p/9065912.html) - 舊版 linux kernel 對 preempt 的 config 位置不同。 --- some `.config` need to modify `*** 沒有規則可製作目標「debian/canonical-certs.pem」,由「certs/x509_certificate_list」 需求。 停止。` [ Linux Kernel & 文件系统编译 ](https://blog.wjhwjhn.com/archives/811/) [ Linux 内核编译,终于实践了 ](https://juejin.cn/post/7082548338431623176) `sudo make -j8` --- Finally, grub menu will help you enter specific kernel. [如何開啟 GRUB 選單?](https://magiclen.org/grub-menu) ## example arm First of all check your gcc version and path ```bash which arm-linux-gnueabihf-gcc ``` > /usr/bin/arm-linux-gnueabihf-gcc or you can prepare your own cross compiler > CC=/home/morgana/x-tools/arm-cortexa9_neon-linux-gnueabihf/bin/arm-cortexa9_neon-linux-gnueabihf-gcc CXX=/home/morgana/x-tools/arm-cortexa9_neon-linux-gnueabihf/bin/arm-cortexa9_neon-linux-gnueabihf-g++ LD=/home/morgana/x-tools/arm-cortexa9_neon-linux-gnueabihf/bin/arm-cortexa9_neon-linux-gnueabihf-ld ` wget https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.4.19.tar.gz` `wget https://cdn.kernel.org/pub/linux/kernel/projects/rt/4.4/older/patch-4.4.19-rt27.patch.xz` 很奇怪的是,板子顯示的是 `4.4.19-rt25` ,但根本沒有 rt25 的 patch。 ### am437x sdk --> 要去官網下載對應版本的sdk,[Linux-RT Processor SDK for AM437x 03.01.00.06 (02 Oct 2016)](https://www.ti.com/tool/download/PROCESSOR-SDK-LINUX-RT-AM437X/03.01.00.06) `cd ~/board-support/linux-rt-4.4.19+gitAUTOINC+f572d285f0-gf572d285f0` ```bash ti_config_fragments/defconfig_builder.sh 1. SDK_Debug_Defconfigs 2. SDK_Release_Defconfigs Please choose a defconfig type to build for or 'q' to exit: 2 Available SDK_Release_Defconfigs defconfig build options: 1. ti_sdk_am3x_release 2. ti_sdk_am4x_release 3. ti_sdk_dra7x_release 4. ti_sdk_omap2_release 5. ti_sdk_k2g_release 6. ti_sdk_keystone_release 7. ti_sdk_am3x_rt_release 8. ti_sdk_am4x_rt_release 9. ti_sdk_dra7x_rt_release 10. ti_sdk_omap2_rt_release 11. ti_sdk_k2g_rt_release 12. ti_sdk_keystone_rt_release Please enter the number of the defconfig to build or 'q' to exit: 8 Creating defconfig file /home/morgana/board-support/linux-rt-4.4.19+gitAUTOINC+f572d285f0-gf572d285f0/arch/arm/configs/ti_sdk_am4x_rt_release_defconfig ``` [SDK Kernel Configuration](https://software-dl.ti.com/processor-sdk-linux/esd/docs/05_03_00_07/linux/Foundational_Components_Kernel_Users_Guide.html) ```bash export CROSS_COMPILE=/home/morgana/x-tools/arm-cortexa9_neon-linux-gnueabihf/bin/arm-cortexa9_neon-linux-gnueabihf- export ARCH=arm ti_sdk_am4x_rt_release_defconfig make ``` if you have previous build, plz `make clean` first. #### bug [解決"multiple definition of yylloc"問題](https://steward-fu.github.io/website/phone/pixel3axl/dd_fix_yylloc.htm) --- can find this `.confing` file through [Obtain Kernel Config from Currently Running Linux System](https://www.baeldung.com/linux/kernel-config) --- cross compiler tool **prefix**?:`arm-linux-gnueabihf-` or `export CROSS_COMPILE=arm-none-linux-gnueabi-` `export CROSS_COMPILE=/home/morgana/x-tools/arm-cortexa9_neon-linux-gnueabihf/bin/arm-cortexa9_neon-linux-gnueabihf-` may need to `make clean` first aware env variable is case sensitive and necessary. `make ARCH=arm` [几种linux内核文件的区别(vmlinux、zImage、bzImage、uImage、vmlinuz、initrd )](https://blog.csdn.net/hanxuefan/article/details/7454352), default create the `zImage`. ```bash CC kernel/bounds.s gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’ gcc: note: valid arguments to ‘-mabi=’ are: ms sysv gcc: error: unrecognized command-line option ‘-mlittle-endian’ gcc: error: unrecognized command-line option ‘-mapcs’ gcc: error: unrecognized command-line option ‘-mno-sched-prolog’ gcc: error: unrecognized command-line option ‘-mno-thumb-interwork’ gcc: error: unrecognized command-line option ‘-mfpu=vfp’ make[1]: *** [Kbuild:45: kernel/bounds.s] Error 1 make: *** [Makefile:990: prepare0] Error 2 ``` [kernel编译报错|/bin/sh: 1: bc: not found](https://blog.csdn.net/qq_28837389/article/details/118100687) [解決"multiple definition of yylloc"問題](https://steward-fu.github.io/website/phone/pixel3axl/dd_fix_yylloc.htm) 成果都在 linux/arch/arm/boot