# Getting "error: fw\_setenv returned failure: exit status 2" after "Committing update" OTA update

**URL:** <https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669>\
**Category:** General Discussions\
**Tags:** debian, x86, mender-client, ota\
**Created:** [May 24, 2021, 10:44am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669 "2021-05-24T10:44:38Z")\
**Posts on this page:** 8\
**Page:** 3

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 17, 2021, 11:22am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/41 "2021-06-17T11:22:34Z")

</div>

> [@kacf](#):
>
> Can you add the following script as state scripts:
> 
> ```auto
> #!/bin/sh
> set -x
> ENV_DIR=/boot/efi/EFI/BOOT/
> 
> ```

@kacf  
As you proposed, I have added state scripts in mender\_convert and created OS image & mender artifacts.

[custom\_config.yml](https://hub.mender.io/uploads/short-url/rQRSQykS6ZezylSqOYwuYGh4BeI.yml) (1.4 KB)  
**mender\_convert logs**  
[convert.log.a8E2.yml](https://hub.mender.io/uploads/short-url/g1SNSORhEpoy4ZjSnAuqLKlP43U.yml) (27.6 KB)

1. Made a new flash on target device where image having artifact name as V1 (i.e. x86\_64-Testserver\_StateScriptTest\_v1\_170621)

2. Triggered OTA with V2 successfully log as  
[deployments.0001.b542a111-8d87-4045-9230-4fb799a48f96.log1\_successOTA.yml](https://hub.mender.io/uploads/short-url/w4OS9SaN9gM3A55rDBQRe0Mc6cl.yml) (14.3 KB)

3. **Triggered OTA again with V1 but failed as**  
[OTA\_Fail\_states\_log.yml](https://hub.mender.io/uploads/short-url/p3J0cCBhU81fFLah2TqCUtS5dNO.yml) (23.3 KB)

Let me know for any further outputs for debugging issue.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 18, 2021, 7:04am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/42 "2021-06-18T07:04:18Z")

</div>

Thanks. Unfortunately it again revealed nothing. It’s quite incredible how well hidden this is.

I have one more thing for you to try: Let’s enable full script debugging in the `fw_printenv` script itself. In addition to your existing changes, can you add this change to mender-convert, re-convert, and then rerun the deployment:

```diff
diff --git a/mender-convert-modify b/mender-convert-modify
index cf8f215..c064662 100755
--- a/mender-convert-modify
+++ b/mender-convert-modify
@@ -222,6 +222,7 @@ EOF
     run_and_log_cmd "make 2>&1"
     run_and_log_cmd "sudo make DESTDIR=../ BOOT_DIR=boot install-boot-files"
     run_and_log_cmd "sudo make DESTDIR=../rootfs install-tools"
+ sed -i -e '2 i set -x' ../rootfs/usr/bin/fw_printenv
     cd - > /dev/null 2>&1
 
     # Remove conflicting boot files. These files do not necessarily effect the

```

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 21, 2021, 7:55am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/43 "2021-06-21T07:55:50Z")

</div>

> [@kacf](#):
>
> Thanks. Unfortunately it again revealed nothing. It’s quite incredible how well hidden this is.
> 
> I have one more thing for you to try: Let’s enable full script debugging in the `fw_printenv` script itself. In addition to your existing changes, can you add this change to mender-convert, re-convert, and then rerun the deployment:
> 
> ```auto
> 
> ```

@kacf Thanks for giving me your valuable time to debug this issue.

As per your suggestion, I have enabled full script debugging in the `fw_printenv` script and then created again artifacts say v1 & v2.

1. Made a new flash on the target device where the image has artifact name as v1.
2. Triggered full OS OTA deployment v2 artifact but now **it has failed in first OTA itself** as below

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/d/d31ad9d3402436d53ae771959a9dcb52ebad5e25.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/7/72ef2a374710f0c8c1f298d53b8ba9fbc1e69f0e.png)

Failed OTA deployment log is:

[Failed\_logs\_Testserver\_StateScriptTest\_enable\_debug\_v2\_210621.yml](https://hub.mender.io/uploads/short-url/siMtOC42UDDSNex8ax3DvMdPaZr.yml) (19.0 KB)

Let me know for any further details outputs for debugging the issue.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 22, 2021, 5:40am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/44 "2021-06-22T05:40:19Z")

</div>

That’s weird, that last change had no effect on the output at all. Can you run this on one of the failing devices:

```bash
head /usr/bin/fw_printenv
ls -l /usr/bin/fw_setenv

```

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 22, 2021, 5:47am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/45 "2021-06-22T05:47:44Z")

</div>

> [@kacf](#):
>
> Can you run this on one of the failing devices:
> 
> ```auto
> head /usr/bin/fw_printenv
> ls -l /usr/bin/fw_setenv
> 
> ```

@kacf  
output of provided commands are below:

```auto
$ head /usr/bin/fw_printenv 
#!/bin/sh
set -x

# This script mimicks the behavior of fw_printenv/fw_setenv from U-Boot.

# Here is how the environment works. We've got three problems to overcome:
# 1. GRUB doesn't support checksumming the environment.
# 2. There is a hashsum command, but it can only be used to verify checksums,
# not generate them.
# 3. We want to store the environment on the boot partition, which is FAT, and

```

```auto

$ ls -l /usr/bin/fw_setenv 
lrwxrwxrwx 1 root root 11 Jun 18 03:34 /usr/bin/fw_setenv -> fw_printenv

```

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 22, 2021, 6:04am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/46 "2021-06-22T06:04:56Z")

</div>

Hmm, could there be more than one on your system? What does `which -a fw_printenv` say?

---

<div class="post-metadata">

**Author:** ![Rohita83](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/rohita83/32/436_2.png) [@Rohita83](https://hub.mender.io/u/Rohita83)\
**Post date:** [June 22, 2021, 7:46am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/47 "2021-06-22T07:46:55Z")

</div>

> [@kacf](#):
>
> which -a fw\_printenv

@kacf

```auto

$ which -a fw_printenv
/usr/bin/fw_printenv

```

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [June 22, 2021, 8:16am UTC](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669/48 "2021-06-22T08:16:48Z")

</div>

Ok…

At this point, I’m really clueless. I can’t see anything wrong anywhere, and still it’s failing. Your best bet at this point might be to start stepping through the code with a debugger, near the place where it fails. Or if you have the means, look into our [consulting services](https://mender.io/support-and-services/consulting-services) and have someone do board integration where we look into this problem on our side, using a board you send us.

Sorry I can’t be of more assistance.

[Previous page](https://hub.mender.io/t/getting-error-fw-setenv-returned-failure-exit-status-2-after-committing-update-ota-update/3669.md?page=2)
