This page contains the following information:
- Create a Linux Image describes how to build your own Linux image for the iMX7 Dual Developer's Kit and how to add DS-MDK specific settings to the image.
- Linux Kernel Module Debug shows how to debug a Linux kernel module with DS-MDK.
- The Linux Kernel Debug application note explains how to load the Linux kernel debug information and the source code so that you can debug the full Linux kernel with DS-MDK.
Create a Linux Image
The necessary steps in order to build the BSP from source code are described in the Working with Yocto to Build Linux document.
Build the Image
Embedded Artists' documentation describes how to build the BSP from source. Just before the final step where you use bitbake to build the image, you need to do the following:
In the recipe local configuration file ~/ea-bsp/build/conf/local.conf, add the following line:
EXTRA_IMAGE_FEATURES += "package-management dev-pkgs tools-sdk tools-debug tools-profile eclipse-debug"
Remove the following lines if a root password is not desired:
INHERIT += " extrausers"
EXTRA_USERS_PARAMS = " \
useradd -p '' tester; \
usermod -s /bin/sh tester; \
usermod -P 'pass' root \
"
Build the core-image-base recipe (it will take a long time):
bitbake core-image-base
(Optional for Streamline) Add Gator driver to source code by following the instructions from ARM.
Copy the driver folder into ~/ea-bsp/build/tmp/work/imx6sxea_com-poky-linux-gnueabi/linux-ea/4.1.15-r0/build/source
/drivers and rename it to "gator". Add this line to the drivers' Makefile:
obj-$(CONFIG_GATOR) += gator/
And to Kconfig:
source "drivers/gator/Kconfig"
Workaround for LOCAL_TIMERS absence: comment it out in the gator’s Kconfig:
#depends on LOCAL_TIMERS || !(ARM && SMP)
In the file ~/ea-bsp/build/conf/local.conf add the following line:
IMAGE_INSTALL_append += "kernel-module-gator"
Open kernel configuration utility and use your preferred configuration options. Take this .config file as a reference. Rewrite the file ~/ea-bsp/build/tmp/work/imx6sxea_com-poky-linux-gnueabi/linux-ea/4.1.15-r0/defconfig with the same content as the new .config.
Go to ~/ea-bsp/build/tmp/work/imx6sxea_com-poky-linux-gnueabi/linux-ea/4.1.15-r0/build/drivers/crypto/caam and in the
file secvio.c comment the command " HP_SECVIO_INTEN_SRC1 | ", the code should look like this:
wr_reg32(&svpriv->svregs->hp.secvio_intcfg,
HP_SECVIO_INTEN_SRC4 | HP_SECVIO_INTEN_SRC2 |
/*HP_SECVIO_INTEN_SRC1 |*/ HP_SECVIO_INTEN_SRC0);
Rebuild and deploy kernel with new config:
bitbake -c compile -f linux-ea
bitbake -c deploy linux-ea
bitbake core-image-base
The output files will be in the folder ~/ea-bsp/build/tmp/deploy/images/imx6sxea-com
Write the image files into the eMMC flash as described in the chapter 5 "Deploying Images" from the "Working with Yocto to Build Linux" document. The Manufacturing Tool is downloadable from here. Use the version for the Linux Kernel v4. Unzip the tool to your disk and overwrite the files located in Profiles\Linux\OS Firmware\files with the ones you have created or from the Linux image ZIP file.
(Optional for Streamline) Copy the gator daemon (gatord) into /lib/modules//kernel/drivers/gator/
Set UART clock parent. At the U-Boot console add uart_from_osc into mmcargs:
setenv mmcargs ‘setenv bootargs console=${console},${baudrate} root=${mmcroot}, uart_from_osc, ${args_from_script} clk_ignore_unused’; saveenv;
On the U-Boot console, set the M4 device tree file:
setenv fdt_file imx6sxea-com-kit-m4.dtb; saveenv;
Linux Kernel Module Debug
Only a few things are required to make kernel module debugging work. This sections explains how to do this for the imx_rpmsg_tty module that is used in the example projects that are explained in detail in the Getting Started with DS-MDK user guide. Copy and build the projects RPMSG TTY RTX and Linux Application TTY as available from the i.MX 6 Pack.
- Download and unzip the Linux kernel symbols, called vmlinux.
- Download and unzip the kernel module source code and object file: imx_rpmsg_tty.zip
Create CMSIS C/C++ Project
Create a new CMSIS C/C++ Project for the Cortex-A7 processor of the i.MX 6. Name the project Kernel_Debug
Add two DS-5 Debugger scripts: right-click the project and select New → Other....
In the upcoming window select DS-5 Debugger → DS-5 Debugger Script. Specify the file names "stop" and "load_ko".
In the stop.ds script add:
stop
In the load_ko.ds script add:
add-symbol-file imx_rpmsg_tty.ko
Note: Make sure that the file is stored in the workspace so that DS-MDK can find it. Otherwise, specify the fully qualified path to it.
The stop command in the first script will halt the processor before loading the kernel symbols and the add-symbol-file command will load the kernel module object file.
Right-click the project and select Debug As → CMSIS DS-5 Debugger....
On the Connections tab, set the CPU Instance to either 0 or SMP. Go to the Advanced tab and specify the path to the vmlinux file and enable Load symbols only. Also, set the initialization debugger scripts as shown here:
Apply the settings and close the dialog.
Debug the Kernel Module
The following steps are required to come to a point where you can debug the kernel module:
- Restart your target and halt in U-Boot.
- Debug and run the Cortex-M4 application RPMSG TTY RTX.
- Boot Linux.
- At the Linux prompt, issue the following command to install the driver for the kernel module: modprobe imx_rpmsg_tty.
- Debug and run the Kernel_Debug project.
- Now, you can open the imx_rpmsg_tty.c and set breakpoints.
- Finally, debug the Linux Application TTY as well (make sure that the RSE connection is still live). When you run the application, the debugger will stop at the breakpoint you have set in the previous step.
Debug the Kernel Module
The following steps are required to come to a point where you can debug the kernel module:
- Restart your target and halt in U-Boot.
- Debug and run the Cortex-M4 application RPMSG TTY RTX.
- Boot Linux.
- At the Linux prompt, issue the following command to install the driver for the kernel module: modprobe imx_rpmsg_tty.
- Debug and run the Kernel_Debug project.
- Now, you can open the imx_rpmsg_tty.c and set breakpoints.
- Finally, debug the Linux Application TTY as well (make sure that the RSE connection is still live). When you run the application, the debugger will stop at the breakpoint you have set in the previous step.