# Raspberry Pi Stuck in U-Boot

**URL:** https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554
**Category:** General Discussions
**Created:** [May 13, 2019, 2:56am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554 "2019-05-13T02:56:39Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Silvenga](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/silvenga/32/235_2.png) [@Silvenga](https://hub.mender.io/u/Silvenga)
#### Post date: [May 13, 2019, 2:56am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/1 "2019-05-13T02:56:39Z")

</div>

Rather new to Mender, so I basically followed this post: [Raspberry Pi 3 Model B/B+ Raspbian](https://hub.mender.io/t/raspberry-pi-3-model-b-b-raspbian/140). I substituted the official raspbian image with a custom one built via pi-gen (Only modifications around boot is enabling i2c). I wrote the `.sdimg` to the sd card using etcher. The image does work without using mender-convert.

I used the following to convert:

```auto
./docker-mender-convert from-raw-disk-image \
            --raw-disk-image $RAW_DISK_IMAGE \
            --mender-disk-image $MENDER_DISK_IMAGE \
            --device-type raspberrypi3 \
            --artifact-name $ARTIFACT_NAME \
            --bootloader-toolchain arm-buildroot-linux-gnueabihf \
            --server-url "https://mender.example.com"

```

I noticed the pi wasn’t booting, so I connected a serial and saw the following:

```auto
U-Boot 2018.07-g981cc831e3 (May 13 2019 - 01:06:40 +0000)

DRAM: 948 MiB
RPI 3 Model B (0xa22082)
MMC: mmc@7e202000: 0, sdhci@7e300000: 1
Loading Environment from FAT... *** Warning - bad CRC, using default environment

Failed (-5)
Loading Environment from MMC... OK
In: serial
Out: serial
Err: serial
Net: No ethernet found.
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
300 bytes read in 0 ms
## Executing script at 02400000
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
switch to partitions #0, OK
mmc0 is current device
4944992 bytes read in 209 ms (22.6 MiB/s)
Kernel image @ 0x080000 [0x000000 - 0x4b7460]
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree
SCRIPT FAILED: continuing...
starting USB...

```

I’m not quite sure where to start troubleshooting, any help would be appreciated.

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [May 13, 2019, 6:11am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/2 "2019-05-13T06:11:36Z")

</div>

Hi @Silvenga,

First of all welcome to Mender Hub 🙂.

Did you try the official Raspbian image?

But looks very similar to the problem reported here,

[https://tracker.mender.io/browse/MEN-2436](https://tracker.mender.io/browse/MEN-2436)

Could you try removing `init=/usr/lib/raspi-config/init_resize.sh` from `cmdline.txt` before attempting the first boot. I suspect it is related to this, though we have not found out why.

---

<div class="post-metadata">

### Author: ![Silvenga](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/silvenga/32/235_2.png) [@Silvenga](https://hub.mender.io/u/Silvenga)
#### Post date: [May 13, 2019, 5:19pm UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/3 "2019-05-13T17:19:05Z")

</div>

I appreciate the guidance, you put me on the right path! I removed that directive and my custom image boots (and reboots correctly). I’m wondering if there was some error on first boot now… I’ll reflash again and monitor first boot for anything.

Thanks! Anything I can provide to help track down that bug?

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [May 13, 2019, 7:18pm UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/4 "2019-05-13T19:18:50Z")

</div>

> I’m wondering if there was some error on first boot now… I’ll reflash again and monitor first boot for anything.

What that line does is that it will on first boot try to expand the “data” partition to occupy the remaining space available on the disk and by removing this line you have skipped this step.

There is probably something going wrong in the “expand” procedure that corrupts the SD.

> Thanks! Anything I can provide to help track down that bug?

You could try to manually run the scripts, which is also mentioned in [[MEN-2436] - Mender and CFEngine (by Northern.tech) Jira](https://tracker.mender.io/browse/MEN-2436) and try to isolate which one of the breaks it.

---

<div class="post-metadata">

### Author: ![Silvenga](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/silvenga/32/235_2.png) [@Silvenga](https://hub.mender.io/u/Silvenga)
#### Post date: [May 13, 2019, 11:46pm UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/5 "2019-05-13T23:46:47Z")

</div>

I ran the script manually (well parts of it):

```auto
$ROOT_PART_NAME: mmcblk0p4
$ROOT_DEV_NAME: mmcblk0
$ROOT_DEV: /dev/mmcblk0
$ROOT_PART_NUM: 4
$BOOT_PART_DEV: /dev/mmcblk0p1
$BOOT_PART_NAME: mmcblk0p1
$BOOT_DEV_NAME: mmcblk0
$BOOT_PART_NUM: 1
$ROOT_DEV_SIZE: 62518272
$TARGET_END: 62518271
$PARTITION_TABLE: BYT; /dev/mmcblk0:62518272:d/mmc:512:512:mdo:SD 00000:; 1:24576:114687:90112:fat32::boot, lba; 2:114688:8118271:8003584:ext4::; 3:8118272:16121855:8003584:ext4::; 4:16121856:16383999:262144:ext4::;
$LAST_PART_NUM: 4
$ROOT_PART_LINE: 4:16121856:16383999:262144:ext4::;
$ROOT_PART_START: 16121856
$ROOT_PART_END: 16383999

# Effective command:
parted -m /dev/mmcblk0 u s resizepart 4 62518271

```

And the pi still works. The `/usr/sbin/resizefs.sh` script just aborts.

I re-imaged, and I got the following on the boot right after the resize reboot (without the init work around). The error message differs from the third reboot.

```auto
[7.476983] sysrq: SysRq : Resetting
[7.480635] CPU0: stopping
[7.483637] CPU1: stopping
[7.486595] CPU3: stopping

U-Boot 2018.07-g981cc831e3 (May 13 2019 - 01:06:40 +0000)

DRAM: 948 MiB
RPI 3 Model B (0xa22082)
MMC: mmc@7e202000: 0, sdhci@7e300000: 1
Loading Environment from FAT... *** Warning - bad CRC, using default environment

Failed (-5)
Loading Environment from MMC... OK
In: serial
Out: serial
Err: serial
Net: No ethernet found.
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
300 bytes read in 1 ms (293 KiB/s)
## Executing script at 02400000
libfdt fdt_path_offset() returned FDT_ERR_BADSTRUCTURE
switch to partitions #0, OK
mmc0 is current device
4944992 bytes read in 208 ms (22.7 MiB/s)
Kernel image @ 0x080000 [0x000000 - 0x4b7460]
## Flattened Device Tree blob at 2eff9800
   Booting using the fdt blob at 0x2eff9800
   reserving fdt memory region: addr=0 size=1000
   reserving fdt memory region: addr=2eff9800 size=7800
   Using Device Tree in place at 2eff9800, end 2f003fff
WARNING: could not set serial-number FDT_ERR_BADSTRUCTURE.
ERROR: root node setup failed
 - must RESET the board to recover.

FDT creation failed! hanging...### ERROR ### Please RESET the board ###

```

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [May 17, 2019, 7:13pm UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/6 "2019-05-17T19:13:16Z")

</div>

There has been some progress on this, thanks to @MarekBelisko, more info here,

> <https://github.com/mendersoftware/uboot-mender/pull/3>

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [May 18, 2019, 12:03pm UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/7 "2019-05-18T12:03:48Z")

</div>

@Silvenga  
if you want to try my fix pls apply this patch on top of mender-convert:

```auto
diff --git a/rpi-convert-stage-5.sh b/rpi-convert-stage-5.sh
index 799e652..1ef88c0 100755
--- a/rpi-convert-stage-5.sh
+++ b/rpi-convert-stage-5.sh
@@ -33,8 +33,8 @@ declare -a mender_partitions_regular=("boot" "primary" "secondary" "data")
 build_uboot_files() {
   local CROSS_COMPILE=${1}-
   local ARCH=arm
- local branch="mender-rpi-2018.07"
- local commit="981cc831e3"
+ local branch="mbe-test"
+ local commit="44dc10bb7225c3c578e75b77a03d81cbff56225c"
   local uboot_repo_vc_dir=$uboot_dir/.git
   local defconfig="rpi_3_32b_defconfig"
 
@@ -50,7 +50,7 @@ build_uboot_files() {
   log "\tBuilding U-Boot related files."
 
   if [! -d $uboot_repo_vc_dir]; then
- git clone https://github.com/mendersoftware/uboot-mender.git -b $branch >> "$build_log" 2>&1
+ git clone https://github.com/nandra/uboot-mender.git -b $branch >> "$build_log" 2>&1
   fi
 
   cd $uboot_dir

```

---

<div class="post-metadata">

### Author: ![Silvenga](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/silvenga/32/235_2.png) [@Silvenga](https://hub.mender.io/u/Silvenga)
#### Post date: [May 19, 2019, 3:40am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/8 "2019-05-19T03:40:15Z")

</div>

And it’s alive! I can confirm those changes to `uboot-mender` do resolve the problem. Thanks for the help @mirzak @MarekBelisko!

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [May 21, 2019, 7:01pm UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/9 "2019-05-21T19:01:18Z")

</div>

@Silvenga there have been update pushed fix this issue. Please update your repo to [origin/1.1.x](https://github.com/mendersoftware/mender-convert/commits/1.1.x)

---

<div class="post-metadata">

### Author: ![neoweb](https://avatars.discourse-cdn.com/v4/letter/n/a5b964/32.png) [@neoweb](https://hub.mender.io/u/neoweb)
#### Post date: [May 24, 2019, 7:54am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/10 "2019-05-24T07:54:00Z")

</div>

I am doing the same thing as OP after doing a dry run of mender a few months ago.

Can we update [Raspberry Pi 3 Model B/B+ Raspbian](https://hub.mender.io/t/raspberry-pi-3-model-b-b-raspbian/140) or mention this somewhere on that guide also?

I have been working all night on this stuff, and I got to the end of it all, and it seems I am having the same experience. I do not know for sure yet, but I am working w/ 1.1

I am starting over…

I guess I just

git clone --no-checkout  
git checkout 1.1.x

Thanks for working on all of this, it is pretty late here, so I apologize for my dry lifeless post.

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [May 24, 2019, 8:03am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/11 "2019-05-24T08:03:28Z")

</div>

Thanks for bringing this up, it makes sense to update [Raspberry Pi 3 Model B/B+ Raspbian](https://hub.mender.io/t/raspberry-pi-3-model-b-b-raspbian/140) to utilize `1.1.x` branch which does contain the U-boot fix.

---

<div class="post-metadata">

### Author: ![neoweb](https://avatars.discourse-cdn.com/v4/letter/n/a5b964/32.png) [@neoweb](https://hub.mender.io/u/neoweb)
#### Post date: [May 24, 2019, 8:04am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/12 "2019-05-24T08:04:34Z")

</div>

I am going to have 1.1.x tested over here in a sec too…

---

<div class="post-metadata">

### Author: ![neoweb](https://avatars.discourse-cdn.com/v4/letter/n/a5b964/32.png) [@neoweb](https://hub.mender.io/u/neoweb)
#### Post date: [May 24, 2019, 9:25am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/13 "2019-05-24T09:25:30Z")

</div>

I just got done removing

`init=/usr/lib/raspi-config/init_resize.sh`

From a written image just like in this guide, and it did solve my issue. I am grateful this fix is here.

I am about to write a 1.1.x convert, and I will report on that. I can also report on artifact application, because that is the last step in my testing.

The report on artifact testing will most likely be later today.

---

<div class="post-metadata">

### Author: ![neoweb](https://avatars.discourse-cdn.com/v4/letter/n/a5b964/32.png) [@neoweb](https://hub.mender.io/u/neoweb)
#### Post date: [May 25, 2019, 8:30am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/14 "2019-05-25T08:30:13Z")

</div>

1.1.x is working great!

---

<div class="post-metadata">

### Author: ![MarekBelisko](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/marekbelisko/32/33_2.png) [@MarekBelisko](https://hub.mender.io/u/MarekBelisko)
#### Post date: [May 27, 2019, 7:04am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/15 "2019-05-27T07:04:27Z")

</div>

Thanks for reporting.

---

<div class="post-metadata">

### Author: ![Silvenga](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/silvenga/32/235_2.png) [@Silvenga](https://hub.mender.io/u/Silvenga)
#### Post date: [May 27, 2019, 6:09pm UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/16 "2019-05-27T18:09:44Z")

</div>

Switch over the that branch, and Yay! Everything reboots successfully and the resize of the data partition occurs. Thanks for your help.

Unrelated, I’m not sure if `resizefs.sh` is executing correctly.

```auto
# fdisk -l /dev/mmcblk0p4
Disk /dev/mmcblk0p4: 22.1 GiB
# df -h /dev/mmcblk0p4
/dev/mmcblk0p4 120M 1.6M 110M 2% /data

```

However, the resize unit definitely executed, but it exited with `Data partition already resized, aborting` on first boot and disabled itself:

```auto
# systemctl status resizefs.service
● resizefs.service - Expand data partition file system
   Loaded: loaded (/lib/systemd/system/resizefs.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

```

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [May 29, 2019, 8:16am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/17 "2019-05-29T08:16:49Z")

</div>

Thanks for reporting, I created a ticket for this,

[https://tracker.mender.io/browse/MEN-2564](https://tracker.mender.io/browse/MEN-2564)

---

<div class="post-metadata">

### Author: ![neoweb](https://avatars.discourse-cdn.com/v4/letter/n/a5b964/32.png) [@neoweb](https://hub.mender.io/u/neoweb)
#### Post date: [June 14, 2019, 5:48am UTC](https://hub.mender.io/t/raspberry-pi-stuck-in-u-boot/554/18 "2019-06-14T05:48:59Z")

</div>

It seems to work for me, and I have not examined it on other devices but:

```
/dev/sda1 58G 18G 41G 30% /media/usb0
/dev/mmcblk0p1 44M 18M 26M 40% /uboot
/dev/mmcblk0p4 6.3G 3.2M 6.0G 1% /data

```

What was your mender-convert command…it could be that doing this:  
`--storage-total-size-mb 24000 \`  
Helped?
