U-boot bug - missing #ifdef guard in apalis-imx6.c

Hello,

This is a quick bug report/note for @francesco.tx (the maintainer for the Toradex u-boot boards).
In the displays[] array, the HDMI display entry (u-boot/board/toradex/apalis_imx6/apalis_imx6.c at 15d6518c942f0da13f9a7ceeadbd925c3317ec8d · u-boot/u-boot · GitHub) is missing a guard to check if CONFIG_IMX_HDMI is defined. If it is not, then the functions detect_hdmi etc are not defined and leads to a compile error if CONFIG_VIDEO is enabled (since CONFIG_IMX_HDMI is not part of the imx6 defconfig)

Regards,
~BW908

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

Thank you for bringing this issue to our attention. You’ve correctly identified a potential problem with the U-Boot configuration for the Apalis iMX6 module, where the absence of an #ifdef guard for CONFIG_IMX_HDMI in the displays[] array can lead to compile errors if CONFIG_VIDEO is enabled without CONFIG_IMX_HDMI being defined.

To address this, you can modify the U-Boot source code by adding an #ifdef guard around the HDMI display entry. This ensures that HDMI-related functions, such as detect_hdmi, are only included when CONFIG_IMX_HDMI is defined. Here’s how you can implement this fix:

  1. Locate the displays[] array in the apalis_imx6.c file within the U-Boot source directory.
  2. Surround the HDMI display entry with #ifdef CONFIG_IMX_HDMI and #endif preprocessor directives.

For example:

#ifdef CONFIG_IMX_HDMI
    // HDMI display entry
    {
        .detect = detect_hdmi,
        // other HDMI-specific configurations
    },
#endif

This change will prevent the compilation of HDMI-related code unless CONFIG_IMX_HDMI is explicitly defined, thus avoiding the compile errors you encountered.

If you are maintaining a custom U-Boot build, please ensure to test this modification thoroughly to confirm that it resolves the issue without introducing new problems.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

Compiling U-Boot for Verdin AM62.

Greetings @bw908,

Thanks for reporting this. Let me try to bring it up internally for visibility.

If this something you want urgently addressed or is it just something you found while developing?

Best Regards,
Jeremias

No urgency on my part as we have already patched it via a Yocto recipe. Just something I encountered while trying to port our u-boot customizations to the 7.x branch of the bootloader, so I figured I would report it for a possible upstream fix :slight_smile:

No urgency on my part as we have already patched it via a Yocto recipe.

Sounds good then. I’ll go ahead and make a ticket for the team internally to look at. Thanks again for bringing this to our attention.

Best Regards,
Jeremias

1 Like

Thanks!

Note that after writing this post I found a further reference to undefined imx_setup_hdmi in setup_display() that must also be appropriately #ifdefed for similar reasons.

Just an FYI, our team submitted a commit for this to the upstream U-Boot and it was just merged: toradex: apalis-imx6: Fix build failure when CONFIG_VIDEO_IPUV3 is en… · u-boot/u-boot@a3139fe · GitHub

This is only on master for now, but eventually it will organically make it’s way down to our builds. Thank you again for reporting this.

Best Regards,
Jeremias

1 Like

Thanks for the update!