Yocto build error in u-boot-toradex patch file for imx8mp soc

Hi,

Hi @ToradexAI,

I have facing error issue in the patch file of the uboot recipes-bsp in my custom layer.

device info:
root@verdin-imx8mp-15722244:~# tdx-info
Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           6.6.101-7.5.0-devel #1 SMP PREEMPT Mon Oct 27 12:24:20 UTC 2025
Kernel command line:      root=PARTUUID=264a51a5-051e-4975-a6c6-a0920bffbd91 ro rootwait console=tty1 console=ttymxc2,115200 console=null quiet loglevel=0 vt.global_cursor_default=0 vt.default_redraw=0 consoleblank=0
Distro name:              NAME="TDX Wayland with XWayland"
Distro version:           VERSION_ID=7.5.0-devel-20260122114211-build.0
Distro variant:           -
Hostname:                 verdin-imx8mp-15722244
------------------------------------------------------------
Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin iMX8M Plus WB on Ivy
Toradex version:          0070 V1.1A
Serial number:            15722244
Processor arch:           aarch64
------------------------------------------------------------
root@verdin-imx8mp-15722244:~#

Failing on the u-boot-toradex at patch file,

hari@Administrator:~/oe-core/layers/meta-lokbest$ cat recipes-bsp/u-boot/files/verdin-imx8mp/disable-console-logs.patch
Index: git/include/configs/verdin-imx8mp.h
===================================================================
--- git.orig/include/configs/verdin-imx8mp.h
+++ git/include/configs/verdin-imx8mp.h
@@ -44,6 +44,8 @@
        "fdt_board=dev\0" \
        "initrd_addr=0x43800000\0" \
        "initrd_high=0xffffffffffffffff\0" \
+       "setupargs=console=ttymxc2,115200\0" \
+       "tdxargs=quiet loglevel=0 vt.global_cursor_default=0 vt.default_redraw=0 consoleblank=0\0" \
        "update_uboot=askenv confirm Did you load flash.bin (y/N)?; " \
                "if test \"$confirm\" = \"y\"; then " \
                "setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt " \
hari@Administrator:~/oe-core/layers/meta-lokbest$ cat recipes-bsp/u-boot/u-boot-toradex_%.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

SRC_URI += "\
    file://disable-console-logs.patch \
"

do_configure:append() {
    # Set boot delay to 0 for fast boot
    if grep -q "#define CONFIG_BOOTDELAY" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i 's/#define CONFIG_BOOTDELAY.*[0-9]/#define CONFIG_BOOTDELAY 0/' ${S}/include/configs/verdin-imx8mp.h
    else
        echo "#define CONFIG_BOOTDELAY 0" >> ${S}/include/configs/verdin-imx8mp.h
    fi

    # Remove existing fdtfile, if there is one
    sed -i '/"fdtfile=.*\\0" \\/d' ${S}/include/configs/verdin-imx8mp.h
    # Add new fdtfile for Ivy carrier board
    sed -i 's/\("fdt_board=.*\\0" \\\)/\0\n      "fdtfile=imx8mp-verdin-wifi-ivy.dtb\\0" \\/' ${S}/include/configs/verdin-imx8mp.h
}
hari@Administrator:~/oe-core/layers/meta-lokbest$

Error in bitbake build:

Sstate summary: Wanted 522 Local 480 Mirrors 0 Missed 42 Current 5662 (91% match, 99% complete)#####         | ETA:  0:00:01
Removing 3 stale sstate objects for arch verdin_imx8mp: 100% |###############################################| Time: 0:00:00
NOTE: Executing Tasks
ERROR: u-boot-toradex-1_2024.07-r0 do_patch: Applying patch 'disable-console-logs.patch' on target directory '/home/hari/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/u-boot-toradex/2024.07/git'
CmdError('quilt --quiltrc /home/hari/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/u-boot-toradex/2024.07/recipe-sysroot-native/etc/quiltrc push', 0, 'stdout: Applying patch disable-console-logs.patch
patching file include/configs/verdin-imx8mp.h
Hunk #1 FAILED at 44.
1 out of 1 hunk FAILED -- rejects in file include/configs/verdin-imx8mp.h
Patch disable-console-logs.patch does not apply (enforce with -f)

stderr: ')
ERROR: Logfile of failure stored in: /home/hari/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/u-boot-toradex/2024.07/temp/log.do_patch.703726
ERROR: Task (/home/hari/oe-core/build/../layers/meta-toradex-bsp-common/recipes-bsp/u-boot/u-boot-toradex_2024.07.bb:do_patch) failed with exit code '1'

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


The error you’re encountering is due to a patch mismatch where your patch file cannot find the expected context in the U-Boot source code(1). This typically happens when the U-Boot source has changed and your patch no longer applies cleanly.

Analysis of the Issue

Your patch is trying to modify include/configs/verdin-imx8mp.h at line 44, but the context has changed in the U-Boot source. The error message “Hunk #1 FAILED at 44” indicates that the surrounding code doesn’t match what your patch expects(1).

Solutions to Fix the Patch

1. Update Your Patch File

First, examine the current U-Boot source to see what the file looks like now. You can do this by:

  1. Building without the patch to see the current state
  2. Manually checking the file in the work directory: /home/hari/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/u-boot-toradex/2024.07/git/include/configs/verdin-imx8mp.h

2. Regenerate the Patch

Based on the current U-Boot source structure, you may need to regenerate your patch:

  1. Make the changes manually to the source file
  2. Use git diff to create a new patch file
  3. Update the line numbers and context in your patch

3. Alternative Approach Using do_configure

Since you’re already using do_configure:append() for other modifications, consider moving your console configuration there instead of using a patch file(2):

do_configure:append() {
    # Set boot delay to 0 for fast boot
    if grep -q "#define CONFIG_BOOTDELAY" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i 's/#define CONFIG_BOOTDELAY.*[0-9]/#define CONFIG_BOOTDELAY 0/' ${S}/include/configs/verdin-imx8mp.h
    else
        echo "#define CONFIG_BOOTDELAY 0" >> ${S}/include/configs/verdin-imx8mp.h
    fi

    # Add console configuration
    if ! grep -q "setupargs=console=ttymxc2,115200" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i '/initrd_high=0xffffffffffffffff\\0/a\\t"setupargs=console=ttymxc2,115200\\0" \\' ${S}/include/configs/verdin-imx8mp.h
        sed -i '/setupargs=console=ttymxc2,115200\\0/a\\t"tdxargs=quiet loglevel=0 vt.global_cursor_default=0 vt.default_redraw=0 consoleblank=0\\0" \\' ${S}/include/configs/verdin-imx8mp.h
    fi

    # Remove existing fdtfile, if there is one
    sed -i '/"fdtfile=.*\\0" \\/d' ${S}/include/configs/verdin-imx8mp.h
    # Add new fdtfile for Ivy carrier board
    sed -i 's/\("fdt_board=.*\\0" \\\)/\0\n      "fdtfile=imx8mp-verdin-wifi-ivy.dtb\\0" \\/' ${S}/include/configs/verdin-imx8mp.h
}

(2)

4. Check U-Boot Version Compatibility

Your system shows U-Boot version 2024.07, so ensure your patch is compatible with this specific version(1). The U-Boot source structure may have changed between versions.

Debugging Steps

  1. Examine the current file structure:

    cd /home/hari/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/u-boot-toradex/2024.07/git
    cat include/configs/verdin-imx8mp.h
    
  2. Check what’s around line 44 to understand the current context

  3. Update your patch accordingly or use the do_configure:append() approach

The do_configure:append() method is often more reliable than patches since it adapts to the current source structure dynamically(2).

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hi @ToradexAI,

recipes-bsp:

hari@Administrator:~/oe-core/layers/meta-lokbest/recipes-bsp/u-boot$ cat u-boot-toradex_%.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

SRC_URI += "\
    file://disable-console-logs.patch \
"

do_configure:append() {
    # Set boot delay to 0 for fast boot
    if grep -q "#define CONFIG_BOOTDELAY" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i 's/#define CONFIG_BOOTDELAY.*[0-9]/#define CONFIG_BOOTDELAY 0/' ${S}/include/configs/verdin-imx8mp.h
    else
        echo "#define CONFIG_BOOTDELAY 0" >> ${S}/include/configs/verdin-imx8mp.h
    fi

    # Remove existing fdtfile, if there is one
    sed -i '/"fdtfile=.*\\0" \\/d' ${S}/include/configs/verdin-imx8mp.h
    # Add new fdtfile for Ivy carrier board
    sed -i 's/\("fdt_board=.*\\0" \\\)/\0\n      "fdtfile=imx8mp-verdin-wifi-ivy.dtb\\0" \\/' ${S}/include/configs/verdin-imx8mp.h
}
hari@Administrator:~/oe-core/layers/meta-lokbest/recipes-bsp/u-boot$ cat files/verdin-imx8mp/disable-console-logs.patch
Index: git/include/configs/verdin-imx8mp.h
===================================================================
--- git.orig/include/configs/verdin-imx8mp.h
+++ git/include/configs/verdin-imx8mp.h
@@ -44,6 +44,8 @@
        "fdt_board=dev\0" \
        "initrd_addr=0x43800000\0" \
        "initrd_high=0xffffffffffffffff\0" \
+       "tdxargs=quiet loglevel=0 vt.global_cursor_default=0 vt.default_redraw=0 consoleblank=0\0" \
        "update_uboot=askenv confirm Did you load flash.bin (y/N)?; " \
                "if test \"$confirm\" = \"y\"; then " \
                "setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt " \
hari@Administrator:~/oe-core/layers/meta-lokbest/recipes-bsp/u-boot$

Build Error:

Sstate summary: Wanted 507 Local 476 Mirrors 0 Missed 31 Current 5677 (93% match, 99% complete)#####         | ETA:  0:00:00
Initialising tasks: 100% |###################################################################################| Time: 0:00:12
NOTE: Executing Tasks
ERROR: u-boot-toradex-1_2024.07-r0 do_patch: Applying patch 'disable-console-logs.patch' on target directory '/home/hari/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/u-boot-toradex/2024.07/git'
CmdError('quilt --quiltrc /home/hari/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/u-boot-toradex/2024.07/recipe-sysroot-native/etc/quiltrc push', 0, 'stdout: Applying patch disable-console-logs.patch
patching file include/configs/verdin-imx8mp.h
patch: **** malformed patch at line 12:

Patch disable-console-logs.patch does not apply (enforce with -f)

stderr: ')
ERROR: Logfile of failure stored in: /home/hari/oe-core/build/tmp/work/verdin_imx8mp-tdx-linux/u-boot-toradex/2024.07/temp/log.do_patch.729724
ERROR: Task (/home/hari/oe-core/build/../layers/meta-toradex-bsp-common/recipes-bsp/u-boot/u-boot-toradex_2024.07.bb:do_patch) failed with exit code '1'

The error “malformed patch at line 12” indicates your patch file has formatting issues. The patch is failing because it’s not properly formatted for the quilt patch system used by Yocto(1).

Solution: Remove the Patch and Use do_configure Only

Since you’re getting patch formatting errors and the approach is becoming complex, I recommend removing the patch file entirely and handling everything in the do_configure:append() function(2). This is more reliable and maintainable.

Updated Recipe Without Patch

Remove the patch from your bbappend file and update it as follows:

# Remove the SRC_URI line and patch file completely
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

do_configure:append() {
    # Set boot delay to 0 for fast boot
    if grep -q "#define CONFIG_BOOTDELAY" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i 's/#define CONFIG_BOOTDELAY.*[0-9]/#define CONFIG_BOOTDELAY 0/' ${S}/include/configs/verdin-imx8mp.h
    else
        echo "#define CONFIG_BOOTDELAY 0" >> ${S}/include/configs/verdin-imx8mp.h
    fi

    # Add tdxargs for console configuration if not already present
    if ! grep -q "tdxargs=" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i '/initrd_high=0xffffffffffffffff\\0/a\\t"tdxargs=quiet loglevel=0 vt.global_cursor_default=0 vt.default_redraw=0 consoleblank=0\\0" \\' ${S}/include/configs/verdin-imx8mp.h
    fi

    # Remove existing fdtfile, if there is one
    sed -i '/"fdtfile=.*\\0" \\/d' ${S}/include/configs/verdin-imx8mp.h
    # Add new fdtfile for Ivy carrier board
    sed -i 's/\("fdt_board=.*\\0" \\\)/\0\n      "fdtfile=imx8mp-verdin-wifi-ivy.dtb\\0" \\/' ${S}/include/configs/verdin-imx8mp.h
}

(2)

Why This Approach is Better

  1. No patch formatting issues: The do_configure:append() method avoids patch file formatting problems(2)
  2. More maintainable: Changes are applied programmatically and adapt to source changes
  3. Proper U-Boot variable usage: The tdxargs variable is the correct way to add custom kernel parameters in Toradex U-Boot configurations(3)(4)

Understanding the tdxargs Variable

According to Toradex documentation, tdxargs is specifically reserved for user-defined kernel parameters and is appended to the final bootargs during boot(4). This is the proper way to add console configuration parameters like quiet loglevel=0.

Steps to Implement

  1. Delete the patch file: Remove files/verdin-imx8mp/disable-console-logs.patch
  2. Update your bbappend: Use the recipe above without the SRC_URI line
  3. Clean and rebuild:
    bitbake -c cleanall u-boot-toradex
    bitbake u-boot-toradex
    

This approach eliminates the patch formatting issues and uses the proper Toradex U-Boot variable structure for your console configuration needs(3)(4).

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hi @ToradexAI,

In the yocto build I need to remove this setupargs for the initial boot without these ‘console=tty1’,

Already the default toradex build contains this in the boot.scr file for the,

env set setupargs console=tty1 console=${console}

But I need the setupargs only these,

root@verdin-imx8mp-15722244:~# strings /run/media/BOOT_A-mmcblk2p1/boot.scr | grep setupargs
env set setupargs console=${console}
env set bootcmd_args 'run rootfsargs_set && env set bootargs ${rootfsargs} ${setupargs} ${appendargs} ${tdxargs}'
root@verdin-imx8mp-15722244:~# cat /proc/cmdline
root=PARTUUID=7b15ed00-d2da-4abf-8494-439f83d7afb4 ro rootwait console=ttymxc2,115200 console=null quiet loglevel=0 vt.global_cursor_default=0 vt.default_redraw=0 consoleblank=0

This result to be executed at last for the bootloader initiated, and these changes is done by whcih recipes and file in the yocto build or it can directly change by the u-boot-initial-env-sd file in the build generated tar file? need suggestion to fix this issue!..

To remove console=tty1 from the setupargs in your Yocto build, you need to modify the U-Boot boot script that generates the setupargs environment variable(1). The issue is that the default Toradex boot script includes both console=tty1 and console=${console} in setupargs.

Understanding the Boot Process

According to Toradex documentation, the final kernel command line bootargs is assembled as follows(1):

env set bootcmd_args 'run rootfsargs_set && env set bootargs ${rootfsargs} ${setupargs} ${appendargs} ${tdxargs}'

(1)

The setupargs variable is “defined dynamically at boot time using run setup” and is “used to set platform-specific kernel arguments”(1).

Solution: Modify U-Boot Boot Script

You have two approaches to fix this:

Approach 1: Modify U-Boot Configuration in Your Recipe

Add this to your u-boot-toradex_%.bbappend:

do_configure:append() {
    # Set boot delay to 0 for fast boot
    if grep -q "#define CONFIG_BOOTDELAY" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i 's/#define CONFIG_BOOTDELAY.*[0-9]/#define CONFIG_BOOTDELAY 0/' ${S}/include/configs/verdin-imx8mp.h
    else
        echo "#define CONFIG_BOOTDELAY 0" >> ${S}/include/configs/verdin-imx8mp.h
    fi

    # Modify setupargs to remove console=tty1
    if grep -q "console=tty1" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i 's/console=tty1 console=/console=/' ${S}/include/configs/verdin-imx8mp.h
    fi

    # Add tdxargs for console configuration if not already present
    if ! grep -q "tdxargs=" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i '/initrd_high=0xffffffffffffffff\\0/a\\t"tdxargs=quiet loglevel=0 vt.global_cursor_default=0 vt.default_redraw=0 consoleblank=0\\0" \\' ${S}/include/configs/verdin-imx8mp.h
    fi

    # Remove existing fdtfile, if there is one
    sed -i '/"fdtfile=.*\\0" \\/d' ${S}/include/configs/verdin-imx8mp.h
    # Add new fdtfile for Ivy carrier board
    sed -i 's/\("fdt_board=.*\\0" \\\)/\0\n      "fdtfile=imx8mp-verdin-wifi-ivy.dtb\\0" \\/' ${S}/include/configs/verdin-imx8mp.h
}

(1)

Approach 2: Override setupargs Variable

You can also override the setupargs variable directly in your U-Boot configuration by adding this line to your configuration:

# Add custom setupargs without console=tty1
if ! grep -q "setupargs=console=" ${S}/include/configs/verdin-imx8mp.h; then
    sed -i '/tdxargs=/a\\t"setupargs=console=${console}\\0" \\' ${S}/include/configs/verdin-imx8mp.h
fi

(1)

Understanding the Variables

According to Toradex documentation, these are the key variables involved(1):

  • setupargs: “Defined dynamically at boot time using run setup. Used to set platform-specific kernel arguments”(1)
  • tdxargs: “Kernel arguments used in Toradex BSPs. This is a Toradex-specific variable”(1)
  • bootargs: “Final string of kernel arguments passed to Linux. Built from rootfsargs, setupargs, appendargs (from the Yocto APPEND variable) and tdxargs(1)

Why This Approach Works

The setupargs variable is managed by the boot script and should not be modified manually according to Toradex documentation(1). However, you can modify the source configuration that defines how setupargs is initially set.

Your desired result showing console=${console} instead of console=tty1 console=${console} will be achieved by modifying the U-Boot source configuration before the boot script runs.

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hi @ToradexAI,

I have found the verdin-imx8mp.h file in the dev shell terminal but i cant able to find the setupargs env variable in that, then the u-boot bbappend how it will modify it.

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright 2022 Toradex
 */

#ifndef __VERDIN_IMX8MP_H
#define __VERDIN_IMX8MP_H

#include <asm/arch/imx-regs.h>
#include <linux/sizes.h>

#define CFG_SYS_UBOOT_BASE      \
        (QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)

#ifdef CONFIG_SPL_BUILD

/* malloc f used before GD_FLG_FULL_MALLOC_INIT set */
#define CFG_MALLOC_F_ADDR                               0x184000
/* For RAW image gives a error info not panic */

#endif /* CONFIG_SPL_BUILD */

#define MEM_LAYOUT_ENV_SETTINGS \
        "fdt_addr_r=0x50200000\0" \
        "kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
        "kernel_comp_addr_r=0x40200000\0" \
        "kernel_comp_size=0x08000000\0" \
        "ramdisk_addr_r=0x50300000\0" \
        "scriptaddr=0x50280000\0"

/* Enable Distro Boot */
#define BOOT_TARGET_DEVICES(func) \
        func(MMC, mmc, 1) \
        func(MMC, mmc, 2) \
        func(DHCP, dhcp, na)
#include <config_distro_bootcmd.h>

/* Initial environment variables */
#define CFG_EXTRA_ENV_SETTINGS \
        BOOTENV \
        MEM_LAYOUT_ENV_SETTINGS \
        "boot_script_dhcp=boot.scr\0" \
        "console=ttymxc2\0" \
        "fdt_board=dev\0" \
        "initrd_addr=0x43800000\0" \
        "initrd_high=0xffffffffffffffff\0" \
        "tdxargs=console=null quiet loglevel=0 vt.global_cursor_default=0 vt.default_redraw=0 consoleblank=0\0" \
        "update_uboot=askenv confirm Did you load flash.bin (y/N)?; " \
                "if test \"$confirm\" = \"y\"; then " \
                "setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt " \
                "${blkcnt} / 0x200; mmc dev 2 1; mmc write ${loadaddr} 0x0 " \
                "${blkcnt}; fi\0"

#define CFG_SYS_INIT_RAM_ADDR   0x40000000
#define CFG_SYS_INIT_RAM_SIZE   SZ_512K

/* i.MX 8M Plus supports max. 8GB memory in two albeit concecutive banks */
#define CFG_SYS_SDRAM_BASE              0x40000000
#define PHYS_SDRAM                      0x40000000
#define PHYS_SDRAM_SIZE                 (SZ_2G + SZ_1G)
#define PHYS_SDRAM_2                    0x100000000
#define PHYS_SDRAM_2_SIZE               (SZ_4G + SZ_1G)

#endif /* __VERDIN_IMX8MP_H */

Any solution for this to fix the issue.

I can see that the setupargs variable is not directly defined in the verdin-imx8mp.h file. According to Toradex documentation, setupargs is “defined dynamically at boot time using run setup” and is used to set platform-specific kernel arguments(1). The issue is that this variable is set by U-Boot’s boot script, not in the static configuration file.

Understanding Where setupargs Comes From

The setupargs variable is managed by U-Boot’s boot script and should not be modified manually according to Toradex documentation(1). The documentation states that variables like setupargs are “managed by the boot script and should not be modified manually”(1).

Solution: Override setupargs in U-Boot Configuration

Since setupargs is set dynamically, you need to override it by adding a static definition in your U-Boot configuration. Here’s how to modify your u-boot-toradex_%.bbappend:

do_configure:append() {
    # Set boot delay to 0 for fast boot
    if grep -q "#define CONFIG_BOOTDELAY" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i 's/#define CONFIG_BOOTDELAY.*[0-9]/#define CONFIG_BOOTDELAY 0/' ${S}/include/configs/verdin-imx8mp.h
    else
        echo "#define CONFIG_BOOTDELAY 0" >> ${S}/include/configs/verdin-imx8mp.h
    fi

    # Add setupargs override without console=tty1
    if ! grep -q "setupargs=" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i '/tdxargs=/a\\t"setupargs=console=${console}\\0" \\' ${S}/include/configs/verdin-imx8mp.h
    fi

    # Remove existing fdtfile, if there is one
    sed -i '/"fdtfile=.*\\0" \\/d' ${S}/include/configs/verdin-imx8mp.h
    # Add new fdtfile for Ivy carrier board
    sed -i 's/\("fdt_board=.*\\0" \\\)/\0\n      "fdtfile=imx8mp-verdin-wifi-ivy.dtb\\0" \\/' ${S}/include/configs/verdin-imx8mp.h
}

(2)

Alternative Approach: Modify the setup Variable

Another approach is to override the setup variable that creates setupargs. Add this to your configuration:

do_configure:append() {
    # Previous configurations...
    
    # Override the setup command to exclude console=tty1
    if ! grep -q "setup=setenv setupargs console=" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i '/tdxargs=/a\\t"setup=setenv setupargs console=${console}\\0" \\' ${S}/include/configs/verdin-imx8mp.h
    fi
}

(3)

Why This Approach Works

According to Toradex documentation, when you save the environment using saveenv, “an image of the entire environment is saved to persistent memory, not just the variable that was changed”(4). By defining setupargs statically in the U-Boot configuration, it will override the dynamic version created by the boot script.

The final bootargs is built from rootfsargs, setupargs, appendargs and tdxargs(1). By controlling the setupargs variable, you can ensure it only contains console=${console} without the unwanted console=tty1.

Testing the Changes

After implementing these changes:

  1. Clean and rebuild U-Boot:
bitbake -c cleanall u-boot-toradex
bitbake u-boot-toradex
  1. Check the generated boot.scr file to verify that setupargs now only contains console=${console}

This approach ensures that your custom setupargs definition takes precedence over the dynamic one created by the boot script(4).

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hi @ToradexAI,

Or we can modify directly by this env-u-boot-initial-sd file,

arch=arm
baudrate=115200
board=verdin-imx8mp
board_name=verdin-imx8mp
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootaa64.efi; if fdt addr -q ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_efi_bootmgr=if fdt addr -q ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_net_usb_start=usb start
boot_pci_enum=pci enum
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_script_dhcp=boot.scr
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc1 mmc2 dhcp 
bootcmd=run distro_bootcmd
bootcmd_dhcp=devtype=dhcp; run boot_net_usb_start; run boot_pci_enum; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; setenv efi_old_vci ${bootp_vci};setenv efi_old_arch ${bootp_arch};setenv bootp_vci PXEClient:Arch:00011:UNDI:003000;setenv bootp_arch 0xb;if dhcp ${kernel_addr_r}; then tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};if fdt addr -q ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_arch};setenv efi_fdtfile;setenv efi_old_arch;setenv efi_old_vci;
bootcmd_mmc1=devnum=1; run custom_mmc_boot
bootcmd_mmc2=devnum=2; run custom_mmc_boot
bootdelay=0
console=ttymxc2
cpu=armv8
distro_bootcmd=setenv nvme_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
ethprime=eth0
fdt_addr_r=0x50200000
fdt_board=dev
fdtfile=imx8mp-verdin-wifi-ivy.dtb
initrd_addr=0x43800000
initrd_high=0xffffffffffffffff
kernel_addr_r=0x48200000
kernel_comp_addr_r=0x40200000
kernel_comp_size=0x08000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x48200000
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
nvme_boot=run boot_pci_enum; run nvme_init; if nvme dev ${devnum}; then devtype=nvme; run scan_dev_for_boot_part; fi
nvme_init=if ${nvme_need_init}; then setenv nvme_need_init false; nvme scan; fi
preboot=test -n ${fdtfile} || setenv fdtfile imx8mp-verdin-${variant}-${fdt_board}.dtb
ramdisk_addr_r=0x50300000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then part uuid ${devtype} ${devnum}:${distro_bootpart} distro_bootpart_uuid ; run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;run boot_efi_bootmgr;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootaa64.efi; then echo Found EFI removable media binary efi/boot/bootaa64.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo EXTLINUX FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0x50280000
soc=imx8m
tdxargs=console=null quiet loglevel=0 vt.global_cursor_default=0 vt.default_redraw=0 consoleblank=0
update_uboot=askenv confirm Did you load flash.bin (y/N)?; if test "$confirm" = "y"; then setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200; mmc dev 2 1; mmc write ${loadaddr} 0x0 ${blkcnt}; fi
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
usb_ignorelist=0x1050:*,
vendor=toradex
bootfs_a_part=1
bootfs_b_part=2
rootfs_a_part=3
rootfs_b_part=4
active_bootfs=A
active_rootfs=A
select_bootfs=if test "${active_bootfs}" = "B"; then setenv distro_bootpart ${bootfs_b_part}; else setenv distro_bootpart ${bootfs_a_part}; fi
select_rootfs=if test "${active_rootfs}" = "B"; then if part uuid mmc ${devnum}:${rootfs_b_part} uuid; then setenv root_part ${rootfs_b_part}; else setenv root_part ${rootfs_a_part}; fi; else if part uuid mmc ${devnum}:${rootfs_a_part} uuid; then setenv root_part ${rootfs_a_part}; else setenv root_part ${rootfs_b_part}; fi; fi
rootfsargs_set=part uuid mmc ${devnum}:${root_part} uuid && env set rootfsargs root=PARTUUID=${uuid} ro rootwait
bootcmd_args=run rootfsargs_set && env set bootargs ${tdxargs} ${rootfsargs} console=${console},${baudrate}
custom_scan_dev_for_boot_part=run select_bootfs; run scan_dev_for_boot; if test "${kernel_loaded}" != "1"; then if test "${active_bootfs}" = "A"; then setenv active_bootfs B; setenv distro_bootpart ${bootfs_b_part}; else setenv active_bootfs A; setenv distro_bootpart ${bootfs_a_part}; fi; run scan_dev_for_boot; fi
custom_mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run select_rootfs; run bootcmd_args; run custom_scan_dev_for_boot_part; fi

Or in the boot.scr file means it is generated by the yocto build once the build success by any of one layer recipes right, then we can edit there right,

root@verdin-imx8mp-15722251:~# cat /run/media/BOOT_B-mmcblk2p2/boot.scr
'V6��M�����w0Distro boot script�# SPDX-License-Identifier: GPL-2.0+ OR MIT
#
# Copyright 2020 Toradex
#
# Toradex boot script.
#
# Allows to change boot and rootfs devices independently.
# Supports:
# - boot device type: boot_devtype := {mmc, usb, dhcp}
# - boot device num (for mmc, usb types): boot_devnum := {0 .. MAX_DEV_NUM}
# - boot partition (for mmc, usb types): boot_part := {1 .. MAX_PART_NUM}
# - root device type: root_devtype := {mmc, usb, dhcp}
# - root device num (for mmc, usb types): root_devnum := {0 .. MAX_DEV_NUM}
# - root partition (for mmc, usb types): root_part := {1 .. MAX_PART_NUM}
#
# Defaults:
#    root_devtype = boot_devtype = devtype
#    root_devnum = boot_devnum = devnum
#    boot_part = distro_bootpart
#    root_part = 2
#
# Common flags:
# - Skip loading overlays: skip_fdt_overlays := {1, 0}
#   1 - skip, any other value (or undefined variable) - don't skip.
#   This variable is adopted from the TorizonCore and shouldn't be
#   renamed separately.

if test ${devtype} = "ubi"; then
    echo "This script is not meant to distro boot from raw NAND flash."
    exit
fi

# Fixup: In the dhcp case standard boot reports the devtype as
# "ethernet" vs. distro boot's "dhcp"
test ${devtype} = "ethernet" && env set devtype "dhcp"

test -n ${m4boot} || env set m4boot ';'
test -n ${fdtfile} || env set fdtfile ${fdt_file}
test -n ${boot_part} || env set boot_part ${distro_bootpart}
test -n ${root_part} || env set root_part 2
test -n ${boot_devnum} || env set boot_devnum ${devnum}
test -n ${root_devnum} || env set root_devnum ${devnum}
test -n ${kernel_image} || env set kernel_image Image.gz
test -n ${boot_devtype} || env set boot_devtype ${devtype}
test -n ${root_devtype} || env set root_devtype ${devtype}
test -n ${overlays_file} || env set overlays_file "overlays.txt"
test -n ${overlays_prefix} || env set overlays_prefix "overlays/"
test -n ${fitconf_fdt_overlays} || env set fitconf_fdt_overlays ''

test ${boot_devtype} = "mmc" && env set load_cmd 'load ${boot_devtype} ${boot_devnum}:${boot_part}'
test ${boot_devtype} = "usb" && env set load_cmd 'load ${boot_devtype} ${boot_devnum}:${boot_part}'
test ${boot_devtype} = "tftp" && env set load_cmd 'tftp'
test ${boot_devtype} = "dhcp" && env set load_cmd 'dhcp'

# Set console baudrate only when required
setexpr _res sub "," "_" ${console}
if test "${_res}" = "" -o "${_res}" = "${console}"; then
        env set console "${console},${baudrate}"
fi

env set appendargs
env set setupargs console=tty1 console=${console}

env set bootcmd_unzip ';'
if test ${kernel_image} = "fitImage"; then
    env set kernel_addr_load ${ramdisk_addr_r}
elif test -n ${kernel_comp_addr_r}; then
    # use booti automatic decompression
    env set kernel_addr_load ${loadaddr}
elif test ${kernel_image} = "Image.gz"; then
    env set kernel_addr_load ${loadaddr}
    env set bootcmd_unzip 'unzip ${kernel_addr_load} ${kernel_addr_r}'
else
    env set kernel_addr_load ${kernel_addr_r}
fi

# Set dynamic commands
env set set_bootcmd_kernel 'env set bootcmd_kernel "${load_cmd} \\${kernel_addr_load} \\${kernel_image}"'
env set set_load_overlays_file 'env set load_overlays_file "${load_cmd} \\${loadaddr} \\${overlays_file} && env import -t \\${loadaddr} \\${filesize}"'
if test ${kernel_image} = "fitImage"; then
    env set fdt_high
    env set fdt_resize true
    env set set_bootcmd_dtb 'env set bootcmd_dtb "true"'
    env set set_apply_overlays 'env set apply_overlays "for overlay_file in \"\\${fdt_overlays}\"; do env set fitconf_fdt_overlays \"\\"\\${fitconf_fdt_overlays}#conf-\\${overlay_file}\\"\"; env set overlay_file; done; true"'
    env set bootcmd_boot 'echo "Bootargs: \${bootargs}" && bootm ${kernel_addr_load}#conf-freescale_\${fdtfile}\${fitconf_fdt_overlays}'
else
    env set fdt_resize 'fdt addr ${fdt_addr_r} && fdt resize 0x20000'
    env set set_bootcmd_dtb 'env set bootcmd_dtb "echo Loading DeviceTree: \\${fdtfile}; ${load_cmd} \\${fdt_addr_r} \\${fdtfile}"'
    env set set_apply_overlays 'env set apply_overlays "for overlay_file in \\${fdt_overlays}; do echo Applying Overlay: \\${overlay_file} && ${load_cmd} \\${loadaddr} \\${overlays_prefix}\\${overlay_file} && fdt apply \\${loadaddr}; env set overlay_file; done; true"'
    env set bootcmd_boot 'echo "Bootargs: \${bootargs}" && booti ${kernel_addr_r} - ${fdt_addr_r}'
fi

# Set static commands
if test ${root_devtype} = "dhcp"; then
    env set rootfsargs_set 'env set rootfsargs "root=/dev/nfs nfsroot=${serverip}:/${rootpath} ip=dhcp"'
else
    env set uuid_set 'part uuid ${root_devtype} ${root_devnum}:${root_part} uuid'
    env set rootfsargs_set 'run uuid_set && env set rootfsargs "root=PARTUUID=${uuid} ro rootwait"'
fi

env set bootcmd_args 'run rootfsargs_set && env set bootargs ${rootfsargs} ${setupargs} ${appendargs} ${tdxargs}'
if test ${skip_fdt_overlays} != 1; then
    env set bootcmd_overlays 'run load_overlays_file && run fdt_resize && run apply_overlays'
else
    env set bootcmd_overlays true
fi
env set bootcmd_prepare 'run set_bootcmd_kernel; run set_bootcmd_dtb; run set_load_overlays_file; run set_apply_overlays'
env set bootcmd_run 'run m4boot; run bootcmd_dtb && run bootcmd_overlays && run bootcmd_args && run bootcmd_kernel && run bootcmd_unzip && run bootcmd_boot; echo "Booting from ${devtype} failed!" && false'

run bootcmd_prepare
run bootcmd_run

root@verdin-imx8mp-15722251:~#

Perfect! You’ve found the exact location where the issue is occurring. Looking at your boot.scr file, I can see this line:

env set setupargs console=tty1 console=${console}

This is exactly what’s causing the unwanted console=tty1 in your kernel command line(1). You have two viable approaches to fix this:

Solution 1: Modify the U-Boot Environment File

You can directly modify the u-boot-initial-env-sd file. Looking at your environment file, I notice you already have a custom bootcmd_args line:

bootcmd_args=run rootfsargs_set && env set bootargs ${tdxargs} ${rootfsargs} console=${console},${baudrate}

This is actually bypassing the setupargs entirely, which is good! However, you need to ensure this custom command is being used instead of the default one in the boot script(1).

Solution 2: Override setupargs in U-Boot Configuration

Add this to your u-boot-toradex_%.bbappend:

do_configure:append() {
    # Set boot delay to 0 for fast boot
    if grep -q "#define CONFIG_BOOTDELAY" ${S}/include/configs/verdin-imx8mp.h; then
        sed -i 's/#define CONFIG_BOOTDELAY.*[0-9]/#define CONFIG_BOOTDELAY 0/' ${S}/include/configs/verdin-imx8mp.h
    else
        echo "#define CONFIG_BOOTDELAY 0" >> ${S}/include/configs/verdin-imx8mp.h
    fi

    # Override setupargs to remove console=tty1
    if ! grep -q '"setupargs=console=${console}\\0"' ${S}/include/configs/verdin-imx8mp.h; then
        sed -i '/tdxargs=/a\\t"setupargs=console=${console}\\0" \\' ${S}/include/configs/verdin-imx8mp.h
    fi

    # Remove existing fdtfile, if there is one
    sed -i '/"fdtfile=.*\\0" \\/d' ${S}/include/configs/verdin-imx8mp.h
    # Add new fdtfile for Ivy carrier board
    sed -i 's/\("fdt_board=.*\\0" \\\)/\0\n      "fdtfile=imx8mp-verdin-wifi-ivy.dtb\\0" \\/' ${S}/include/configs/verdin-imx8mp.h
}

Understanding the Boot Process

According to Toradex documentation, the final bootargs is assembled as follows(1):

env set bootcmd_args 'run rootfsargs_set && env set bootargs ${rootfsargs} ${setupargs} ${appendargs} ${tdxargs}'

Your current u-boot-initial-env-sd file shows you’ve already customized this to:

bootcmd_args=run rootfsargs_set && env set bootargs ${tdxargs} ${rootfsargs} console=${console},${baudrate}

This bypasses setupargs and appendargs entirely, which should give you the clean console configuration you want(1).

Verification

To verify this is working correctly, check that your final kernel command line shows:

console=ttymxc2,115200 console=null quiet loglevel=0 vt.global_cursor_default=0 vt.default_redraw=0 consoleblank=0

Without the unwanted console=tty1.

The approach you’ve discovered by modifying the environment file directly is actually a valid solution, as the U-Boot environment variables can be customized to override the default boot script behavior(2).

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.