# Error when integrating u-boot patch 0003-Integration-of-Mender-boot-code-into-U-Boot

**URL:** <https://hub.mender.io/t/error-when-integrating-u-boot-patch-0003-integration-of-mender-boot-code-into-u-boot/3525>\
**Category:** General Discussions\
**Tags:** yocto\
**Created:** [April 19, 2021, 6:23am UTC](https://hub.mender.io/t/error-when-integrating-u-boot-patch-0003-integration-of-mender-boot-code-into-u-boot/3525 "2021-04-19T06:23:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KolyaHD](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@KolyaHD](https://hub.mender.io/u/KolyaHD)\
**Post date:** [April 19, 2021, 6:23am UTC](https://hub.mender.io/t/error-when-integrating-u-boot-patch-0003-integration-of-mender-boot-code-into-u-boot/3525/1 "2021-04-19T06:23:30Z")

</div>

Hi all,  
i have an existing yocto project (zeus) and i want to add mender to it.  
Im using a fork of u-boot, so i am following the manual u-boot integration page: [Manual U-Boot integration | Mender documentation](https://docs.mender.io/system-updates-yocto-project/board-integration/bootloader-support/u-boot/manual-u-boot-integration)

When i get to the part where i need to extract the patch:  
`bitbake -c save_mender_auto_configured_patch u-boot`

I get the following Error:

> ERROR: u-boot-secc-secc-1.0-r0 do\_patch: Command Error: ‘quilt --quiltrc /home/seccdev/secc-yocto/build/tmp/work/secc\_secc-poky-linux-gnueabi/u-boot-secc-secc/1.0-r0/recipe-sysroot-native/etc/quiltrc push’ exited with 0 Output:  
> Applying patch 0003-Integration-of-Mender-boot-code-into-U-Boot.patch  
> patching file include/env\_default.h  
> Hunk #1 succeeded at 10 with fuzz 2 (offset 1 line).  
> Hunk #2 FAILED at 23.  
> 1 out of 2 hunks FAILED – rejects in file include/env\_default.h  
> patching file scripts/Makefile.autoconf  
> Hunk #1 succeeded at 111 (offset 2 lines).  
> Patch 0003-Integration-of-Mender-boot-code-into-U-Boot.patch does not apply (enforce with -f)  
> ERROR: Logfile of failure stored in: /home/seccdev/secc-yocto/build/tmp/work/secc\_secc-poky-linux-gnueabi/u-boot-secc-secc/1.0-r0/temp/log.do\_patch.6410  
> ERROR: Task (/home/seccdev/secc-yocto/sources/meta-secc-secc/recipes-bsp/u-boot/u-boot-secc-secc.bb:do\_patch) failed with exit code ‘1’

I looked at patch 0003-Integration-of-Mender-boot-code-into-U-Boot, and it looks like that one line does not match with the env\_default.h file that it is attempting to patch:  
Relevant extract from patch file:

```
@@ -21,6 +23,7 @@ static char default_environment[] = {
 #else
 const uchar default_environment[] = {
 #endif
+	MENDER_ENV_SETTINGS
 #ifndef CONFIG_USE_DEFAULT_ENV_FILE <<<---- This line does not exist in header file
 #ifdef	CONFIG_ENV_CALLBACK_LIST_DEFAULT
 	ENV_CALLBACK_VAR "=" CONFIG_ENV_CALLBACK_LIST_DEFAULT "\0"

```

Does anyone know how to solve this?  
Regards,  
Kolya

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [April 19, 2021, 1:19pm UTC](https://hub.mender.io/t/error-when-integrating-u-boot-patch-0003-integration-of-mender-boot-code-into-u-boot/3525/2 "2021-04-19T13:19:59Z")

</div>

Hi @KolyaHD,

You probably will need a customized version of that patch that works for your particular U-Boot version. This is not an uncommon change. You can see how it is handled for the [Toradex platforms here](https://github.com/mendersoftware/meta-mender-community/blob/722292a1af3aa1fb259b3c2fb27b9530b7f9d465/meta-mender-toradex-nxp/recipes-bsp/u-boot/u-boot-toradex_%25.bbappend#L16).

Generally, when I need to make those kinds of changes, I use `git am` to attempt to apply the patch. This will fail but set up the commit log and such. Then you can use `patch` directly against the `0003-Integration-of-Mender-boot-code-into-U-Boot.patch` file. Then you can find the `*.rej` files which are the portions of the patch that do not cleanly apply. You’ll need to figure out an equivalent change for each of these. Then remove all the `*.orig` and `*.rej` files, run `git add -A` and `git am --continue`.

Drew

---

<div class="post-metadata">

**Author:** ![KolyaHD](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@KolyaHD](https://hub.mender.io/u/KolyaHD)\
**Post date:** [May 25, 2021, 6:49am UTC](https://hub.mender.io/t/error-when-integrating-u-boot-patch-0003-integration-of-mender-boot-code-into-u-boot/3525/3 "2021-05-25T06:49:41Z")

</div>

Hi @drewmoseley,  
thanks for the tip. I ended up simply manually editing the file, so it looks like this now:

> ```
> @@ -21,6 +23,7 @@ static char default_environment[] = {
> #else
> const uchar default_environment[] = {
> #endif
> +	MENDER_ENV_SETTINGS
> #ifdef	CONFIG_ENV_CALLBACK_LIST_DEFAULT
> ENV_CALLBACK_VAR "=" CONFIG_ENV_CALLBACK_LIST_DEFAULT "\0"
> #endif
> 
> ```

Thanks,  
Kolya
