|
|
# CAN Latency tester - CTU CAN FD setup
|
|
|
|
|
|
## Kernel build
|
|
|
|
|
|
1) First we need to get the Linux kernel source
|
|
|
`git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git`
|
|
|
|
|
|
2) Next we'll have to get [some patches](https://github.com/ppisa/zynq-rt-utils-and-builds/tree/master/projects/linux/patches) that will generate a Device Tree Blob that we'll need to make the kernel boot. The first one is the most important. Apply it with `git apply`.
|
|
|
|
|
|
2) The latency tester also needs the CTU CAN FD driver to be patched to support hardware timestamps. These patches will be part of the mainline kernel in the future and will no longer be neccessary. For now they are available [here](https://gitlab.fel.cvut.cz/vasilmat/linux-can-test/) on the `ctucanfd-timestamps` branch.
|
|
|
|
|
|
3) When compiling on a CPU with architecture different than armhf, we need to install the toolchain needed for cross-compilation. On Debian the package is called `gcc-arm-linux-gnueabihf`. Apart from that, every time `make` is called we must provide `ARCH` and `CROSS_COMIPLE` variables. To make this easy we can use this [Makefile](https://github.com/ppisa/zynq-rt-utils-and-builds/blob/master/projects/linux/build/arm/zynq/GNUmakefile) which also simplifies placing build files outside the source directory. Simply create a directory for the build files, place the Makefile there and modify it so that the path on line 19 points to your kernel source.
|
|
|
|
|
|
4) Next the kernel needs to be configured. Make the default configuration by running `make defconfig` in the build directory, open the generated `.config` file in the source directory and replace everything from General Setup forward with content from the following file: (.....)
|
|
|
Most notably, these options need to be enabled (.....)
|
|
|
You can also run `make menuconfig` afterwards and in the System Type section remove support for some unneeded SoCs to reduce the amount of things that need to be compiled.
|
|
|
|
|
|
5) Compile the kernel by running `make -j4` (-j4 will run compilation on 4 cores in parallel)
|
|
|
|
|
|
6) Next we can take the resulting zImage along with dts/zynq-microzed-uart0.dtb from arch/arm/boot in the build directory and place it on the boot partition of the SD card into zynq/mzapo/images/linux. The image will then need to be packed into another image that can be booted by UBoot. This image is described in the file `uboot-image.its` under `mzapo` directory. Open this file and make sure the `data` fields point to correct files. `system.bit.gz` is in the root of the partition and intramfs is the following: (.....)
|
|
|
|
|
|
7) Back up the original `image.ub` under `mzapo` and then create a new one with the new kernel by running `mkimage -f uboot-image.its image.ub`. This command is available from the `u-boot-tools` package.
|
|
|
|
|
|
8) Next we need to install the new kernel modules onto the SD card. This can be done by running `sudo make modules_install INSTALL_MOD_PATH=/mnt/sdcard/`, where the path points to where the root partiton of the card is mounted. Alternatively it can be any other directory and the modules can be copied over later.
|
|
|
|
|
|
9) Other modules might need to be rebuilt for the new kernel, for example the [dtbocfg](https://github.com/ikwzm/dtbocfg) module will be needed to allow swapping FPGA designs and updating the device tree at runtime. |
|
|
\ No newline at end of file |