# Pi3 USB boot support

**URL:** <https://hub.mender.io/t/pi3-usb-boot-support/595>\
**Category:** General Discussions\
**Tags:** raspberry-pi-3\
**Created:** [May 21, 2019, 1:06am UTC](https://hub.mender.io/t/pi3-usb-boot-support/595 "2019-05-21T01:06:33Z")\
**Posts on this page:** 1\
**Showing post:** 50

<div class="post-metadata">

**Author:** ![peac](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/peac/32/1200_2.png) [@peac](https://hub.mender.io/u/peac)\
**Post date:** [June 15, 2021, 11:33am UTC](https://hub.mender.io/t/pi3-usb-boot-support/595/50 "2021-06-15T11:33:18Z")

</div>

adding

```auto
CONFIG_ENV_OFFSET=0x400000
CONFIG_ENV_OFFSET_REDUND=0x800000

```

did not change the .config file, so i guess they’re ignored if they’re not with

```auto
CONFIG_ENV_IS_IN_MMC=y
CONFIG_ENV_OFFSET=0x400000
CONFIG_ENV_OFFSET_REDUND=0x800000

```

that yields the following .config

```auto
$ cat .config | grep CONFIG_ENV | grep -v "# "
CONFIG_ENV_SIZE=0x4000
CONFIG_ENV_OFFSET=0x400000
CONFIG_ENV_OFFSET_REDUND=0x800000
CONFIG_ENV_VARS_UBOOT_CONFIG=y
CONFIG_ENV_SUPPORT=y
CONFIG_ENV_IS_IN_FAT=y
CONFIG_ENV_IS_IN_MMC=y
CONFIG_ENV_FAT_INTERFACE="usb"
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_ENV_FAT_FILE="uboot.env"
CONFIG_ENV_FAT_FILE_REDUND="uboot-redund.env"
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y

```

Which surprisingly boots over USB, contrary to the previous post i had made earlier where these lines disabled USB detection in u-boot. The resulting booted environment then still does not seem to be correct and shows `Warning: Bad CRC, using default environment`.

EDIT

Investigating further, I seem to understand that CONFIG\_ENV\_IS\_IN\_FAT means to write env in the boot partition’s uboot.env and uboot-redund.env, whereas CONFIG\_ENV\_IS\_IN\_MMC means to write at the device block level with offsets, and originally for mmcblk\* type devices, but somewhat overused for USB devices.

I found that a uboot-redund.env file has been created on by boot partition, but not a uboot.env file, that’s quite strange. Then modifying /etc/fw\_env.config:

```auto
# cat /etc/fw_env.config 
/boot/u-boot/uboot-redund.env 0x0000 0x4000

```

the file is taken into account as i’ve made path mistakes that resulted in fw\_printenv mentioning the file does not exist, so it does for /boot/u-boot/uboot.env as it has not been created. However the output of fw\_printenv still mentions `Bad CRC, using default environment`.

EDIT

I found [this thread](https://hub.mender.io/t/beaglebone-missing-default-u-boot-environment-in-mmc/1505/1) to be quite informative. I think u-boot should not need to write the env to a raw device and writing to a file should be sufficient, and that works for us to write in the boot partition for now. However i can’t figure out why the env file is not getting written and why the CRC is wrong.

From the u-boot console, `run mender_setup` works without issues, and is supposed to write the config using `saveenv`. Even manually executing `saveenv`, does not create `uboot.env` on the boot partition. `uboot-rendund.env` is written but the CRC is incorrect. I don’t understand how that happens…

EDIT

I’ve just tested to double-check. Removed /boot/u-boot/uboot-redund.env, reboot, the file has been re-created by u-boot on startup, and the CRC is still incorrect. How is it possible that u-boot writes a file with an incorrect CRC?

EDIT

I could not find a resolution for this. To allow the device to boot, i’ve copied the output of `printenv` in u-boot prompt to a uEnv.txt files and executed mkenvimage to create a properly CRC checked file in the boot partition, which fw\_printenv can read so that mender-client can connect. However i’m pretty sure this will not allow switching partitions from mender, as u-boot does not seem to be able to write this file. I summed up the issue [here](https://stackoverflow.com/questions/68000206/u-boot-writes-incorrect-crc-in-env).

---

_[View the full topic](https://hub.mender.io/t/pi3-usb-boot-support/595)._
