Modify, rebuild and reload the Linux® kernel

Revision as of 19:10, 6 February 2019 by Registered User

Template:ArticleMainWriter Template:ArticleProposedVersion



1. Overview[edit source]

This stage will explain you how modify, rebuild and reload the Linux® kernel.
You will first be guide to install the Linux® kernel source code in the Developer Package directory. Then step by step you will execute procedures to modify, rebuild and reload the Linux® kernel.

2. Download the the Linux® kernel source code[edit source]

  • Download the STM32MP15-Ecosystem-v1.0.0 Developer Package Sources in your $HOME/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package directory
  • Uncompress the tarball file to get the Linux® kernel tarball, the ST patches and the ST configuration fragments
 cd $HOME/STM32MPU_workspace/STM32MP15-Ecosystem-v1.0.0/Developer-Package
 tar xvf SOURCES-stm32mp1-openstlinux-4.19-thud-mp1-19-02-20.tar.xz

3. Prepare the Linux® kernel source code[edit source]

  • Extract the Linux® kernel source
 cd stm32mp1-openstlinux-4.19-thud-mp1-19-02-20/sources/arm-openstlinux_weston-linux-gnueabi/linux-stm32mp-4.19-r0
 tar xvf linux-4.19.9.tar.xz
  • Apply the ST patches
 cd linux-4.19.9/
 for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
  • Apply fragments
 make multi_v7_defconfig fragment*.config
 for f in `ls -1 ../fragment*.config`; do scripts/kconfig/merge_config.sh -m -r .config $f; done
 yes '' | make oldconfig

4. Build the Linux® kernel source code for the first time[edit source]

Info white.png Information
The first time the kernel is build it could take several minutes.
  • Build kernel images (uImage and vmlinux) and device tree (dtbs)
 make uImage vmlinux dtbs LOADADDR=0xC2000040
  • Build kernel module
 make modules
  • Generate output build artifacts
 mkdir -p $PWD/install_artifact/
 make INSTALL_MOD_PATH="$PWD/install_artifact" modules_install

5. Deploy the Linux® kernel on the board[edit source]

6. Reboot the board[edit source]

7. Modify[edit source]

8. Modifying a built-in Linux kernel device driver[edit source]

This simple example adds unconditional log information when the display driver is probed.

  • Check that there's no log information when the display driver is probed
 dmesg | grep -i stm_drm_platform_probe

  • Go to the <Linux kernel source directory>
 cd <Linux kernel source directory>
  • Edit the ./drivers/gpu/drm/stm/drv.c source file
  • Add a log information in the stm_drm_platform_probe function
static int stm_drm_platform_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct drm_device *ddev;
	int ret;
	[...]

	DRM_INFO("Simple example - %s\n", __func__);

	return 0;
	[...]
}
  • Go to the <Linux kernel build directory>
 cd <Linux kernel build directory>
  • Cross-compile the Linux kernel (please check the load address in the README.HOW_TO.txt helper file)
 make uImage LOADADDR=0xC2000040
 cp arch/arm/boot/uImage install_artifact/boot/
  • Update the Linux kernel image on board
 scp install_artifact/boot/uImage root@<board ip address>:/boot/
Info white.png Information
If the /boot mounting point doesn't exist yet, please see how to create a mounting point
  • Reboot the board
 reboot
  • Check that there is now log information when the display driver is probed
 dmesg | grep -i stm_drm_platform_probe
[    5.005833] [drm] Simple example - stm_drm_platform_probe
No categories assignedEdit