No announcement yet.

Building custom kernel for 4DPi-24-HAT ?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Building custom kernel for 4DPi-24-HAT ?


    A while back I purchased the 4DPi-24-HAT to use with a Raspberry PI3.
    It worked fine, but each time I did an apt-get update & upgrade, it stopped working (known problem...).

    In theory I can avoid problems by waiting for an updated kernel release, the problem is to know which kernel package is the most recent.
    The product page still shows: 4DPi-24-HAT Kernel Package (Kernel 4.9.35). I know there are more recent releases.
    The page doesn't seem up to date. PS: the webserver disallows directory browsing so I can't easily find out the most recent file.

    So I am looking for a more permanent and stable solution.
    I understand that building a custom kernel for the Raspberry PI could be the solution.
    I have some experience with Linux but building a custom kernel is something new for me.I checked the posts on the forum and did some research.
    Some relevant posts:Building the custom kernel

    I followed the documentation:

    My host computer is Arch Linux 64-bit
    uname -a
    Linux ########## 4.16.5-1-ARCH #1 SMP PREEMPT Thu Apr 26 16:53:40 UTC 2018 x86_64 GNU/Linux
    I chose cross-compiling, as doing it on the PI would be too slow.
    I performed the following steps:

    Install toolchain:
    git clone ~/tools
    Updating the $PATH environment variable (for a 64-bit host system):
    echo PATH=\$PATH:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin >> ~/.bashrc
    source ~/.bashrc
    Get sources:
    git clone --depth=1
    Then I followed the instructions here:

    cd drivers/video
    git clone
    Editing the files:
        Add to drivers/video/Kconfig:   source "drivers/video/4d-hats/Kconfig"
        config HDMI
        source "drivers/video/4d-hats/Kconfig"
        if VT
                source "drivers/video/console/Kconfig"
        Add to drivers/video/Makefile:  obj-y += 4d-hats/
        obj-y                  += fbdev/
        obj-y                                 += 4d-hats/
        obj-$(CONFIG_VIDEOMODE_HELPERS) += display_timing.o videomode.o
    I did not follow the last step:
      Compiling device tree overlays (only necessary if overlay sources are mofified):
        recent dtc (device tree compiler) has to be installed. A script is provided.
        For example DT overlay for 24-hat can be compiled with:
        ./ 24-hat
        resulting .dtb files should be flashed to HAT EEPROMs or copied to:
        /boot/overlays on RPi.
    I am not sure it is relevant here.

    Enable driver(s) in menuconfig and build the kernel:
    cd ~/linux
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
    I enabled the 4D modules as described here:
      Enable driver(s) in menuconfig and build the kernel:
        Device Drivers-->Graphics support
        <*> Support for 4D Systems display modules  --->
            <*>   4D Systems LCD HAT support (2.4, 3.2 and 3.5 inch)
            <*>   DMA Enabled SPI Master Driver
            <M>   Module for ADS7846 resistive touch screen controller
        <M> Module for AR1020 resistive touch screen controller
        <M> Module for DMA supported PWM backlight driver
    Menuconfig for 4D
    Menuconfig for 4D

    Build sources:
    For Pi 2, Pi 3, or Compute Module 3:
    cd linux
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

    Finally, I followed the section 'Install directly onto the SD card'.
    I have a clean and working micro SD card with Raspbian.
    Raspbian Stretch with desktop
    Version: April 2018
    Release date: 2018-04-18
    Using lsblk my SD cards shows up as sdh1 & sdh2

    mkdir mnt
    mkdir mnt/fat32
    mkdir mnt/ext4
    sudo mount /dev/sdh1 mnt/fat32
    sudo mount /dev/sdh2 mnt/ext4
    Next, install the modules:
    sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install
    Finally, copy the kernel and Device Tree blobs onto the SD card, making sure to back up your old kernel:
    sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img
    sudo cp arch/arm/boot/zImage mnt/fat32/$KERNEL.img
    sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/
    sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/
    sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/
    sudo umount mnt/fat32
    sudo umount mnt/ext4
    I have verified that the resulting image is still bootable by connecting a screen to the HDMI plug.
    However, I am wondering if I got the steps in the right order.

    In the /boot/overlays/ directory I don't see any 4D files
    At this time my /boot/config.txt does not contain directives about overloads.
    Could someone confirm if I am on the right track ?

    @4D team: as a workaround is there any way you could keep the product page up to date with a link to the most recent kernel files ?

  • #2
    Hi Marjorie,

    Good Day.

    Welcome to the forum.

    We do update the product page as soon as the new kernel pack is available and has been tested. We try to do this as promptly as we can after a new Raspbian release has been done.

    We are currently updating the datasheet to update some instructions to catch with the raspberry pi fast update.

    For now, here is the new link for new 4DPi kernel:


    Best Regards,


    • #3
      Dear frsantiago,

      thank you for trying to keep up with the kernel development and Raspbian releases. I'm the creator of the other topic ( and would like to compile a kernel for the current 4.14 branch. Could you please provide the used sources for the display driver?

      Thank you


      • #4
        Dear PeterPablo,

        Good Day.

        Here is the link of the sources of 4DPi display driver.

        You can also use the latest kernel of 4DPi displays for Raspbian Stretch release 2018-04-18 at the link below.

        Hope this helps.


        • #5
          Dear frsantiago,

          please take a look at my posting at
          You'll notice that at least in January compilation of a 4.14.y kernel did not succeed with the sources that were releaased back then ( I'll take a look at the new sources.

          Thank you for your fast response.


        • #6
          I needed this thanks guys