FalcoGer
Posts: 26
Joined: Mon Jul 09, 2018 6:35 am

Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:408

Mon Jul 09, 2018 7:39 am

EDIT: This issue is resolved. For a complete tutorial on how to install Ubuntu arm64 for raspberry pi 3b, please go here: viewtopic.php?f=56&t=220079

The goal
So I want a 64 bit system due to software being unsupported for 32 bit operating systems (mongodb specifically) for my Raspberry Pi3B V1.2 and I tried a few (opensuse, fedora, debian), but all had some sort of problem that inhibited using them. So I learned about ubuntu 18.04 server edition.
I followed this guide to install it: https://wiki.ubuntu.com/ARM/RaspberryPi ... .2FAArch64
This is one part I didn't quite understand though.
Finally(!), you will have to copy the GPU firmware/bootloader files and U-boot to the system's fat partition. This will be mounted at /boot/efi if installation has gone correctly.
But it did boot into ubuntu just fine, so I kinda just left it out.

The problem
The parts in red at the bottom are where I deviated from the instructions. I also tried this on 2 different raspberry pi 3Bs to make sure it was the sd card.
So when I came back to the pi today it greeted me with U-Boot, 5 usb devices found
Then starting grub2, which then promptly told me:
Failure writing sector 0x790000 to hd0
No such partition [x3]
Then can't boot fallback bootloader proceeded by spamming the screen full of
WARNING at drivers/mmc/bcm2835_sdhost.c:408/bcm2835_send_command()!
After about 10 minutes or so of it spamming that message it gave a stack overflow warning and dropped into grub2.02 giving me

Code: Select all

*Ubuntu
 Advanced options for Ubuntu
If I select any entry in the menu it gives me a couple of bcm2835 warnings again, then

Code: Select all

partition not found [x4]
press any key to continue...
before dropping back into the menu.
Dropping into console and writing ANY command, including ls or help result in a couple more bcm2835_sdhost.c warnings before dropping back into the console and giving me

Code: Select all

error: no such partition.
autocomplete to list commands work, and unknown commands give me

Code: Select all

error: can't find command '...'
How I got there
Here are the detailed steps of what I did to create sd card. I used an Ubuntu VM on windows to handle partitioning, etc on the SD card.

Getting Netboot onto SD Card
With GParted
  • Delete partition table on SD Card
  • Create msdos partition table on SD Card
  • Create Primary Partion 1 with FAT32 about 128MB
  • Set 'Boot' Flag
Mount the partition to /mnt

Code: Select all

sudo mount /dev/sdb1 /mnt
Get and Unpack the bootloader

Code: Select all

wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-bootloader_1.20180417-1_armhf.deb
dpkg-deb -x raspberrypi-bootloader_1.20180417-1_armhf.deb ~/Desktop/pi-bootloader
rm raspberrypi-bootloader_1.20180417-1_armhf.deb
sudo cp ~/Desktop/pi-bootloader/boot* /mnt
Clone U-Boot, compile and copy kernel8.img

Code: Select all

sudo apt-get install build-essential bison flex git make gcc gcc-aarch64-linux-gnu
git clone --progress http://git.denx.de/u-boot.git
cd u-boot
make rpi_3_defconfig
make CROSS_COMPILE=aarch64-linux-gnu-
sudo cp u-boot.bin /mnt/kernel8.img
cd ..
Get and copy device tree blob (although I have no idea where it is stated that it should be loaded or anything else about this)

Code: Select all

wget http://ports.ubuntu.com/dists/bionic/main/installer-arm64/current/images/device-tree/bcm2837-rpi-3-b.dtb
sudo mkdir /mnt/dtb/broadcom/
sudo cp bcm2837-rpi-3-b.dtb /mnt/dtb/broadcom
Get netboot installer mini-iso and copy it onto the sdcard

Code: Select all

mkdir /tmp/mini-iso
sudo mount -o loop mini.iso /tmp/mini-iso
sudo cp -rT /tmp/mini-iso /mnt
mkdir /tmp/efi-img
sudo mount -o loop /tmp/mini-iso/boot/grub/efi.img /tmp/efi-img
sudo cp -rT /tmp/efi-img /mnt
sudo umount /tmp/efi-img
sudo umount /tmp/mini-iso
Force writing changes and unmount sd card from VM

Code: Select all

sync
sudo umount /mnt
Installing Ubuntu with Netboot
  • Stick the card into the Raspberry Pi 3B
  • Boot it up.
  • Select Install
  • Set Locale, Keyboard layout, Geographic position, etc
  • Partition disk. (I use a 16GB SD Card like this: 128MB Fat32 boot partition (part1), 1.5GB swap partition (part2), rest ext4 mounted on / (part3))
  • Additional software: Don't install desktop environment at this point, openssh if wanted
  • Grub installation (expectedly) fails -> continue without bootloader
  • set clock to utc
Fixing the bootloader - This is the part that probably borked somehow
  • Reboot into installer
  • On Grub (Menu with Auto Install, Advanced options, etc), enter console mode by pressing C
  • set root partition

    Code: Select all

    set root=(hd0,msdos3)
  • Check file system is the correct one

    Code: Select all

    ls /
    Should list a linux root file system with typical directories /root, /usr/, /var, etc
  • select kernel

    Code: Select all

    linux /boot/vmlinuz root=/dev/mmcblk0p3
  • Whatever this does

    Code: Select all

    initrd /boot/initrd.img
Unlike the manual tells, /boot/efi doesn't exist, and nothing is mounted there. So this is where I deviate from the manual and likely messed something up.

Code: Select all

sudo grub-install --no-nvram
sudo update-grub
This returns errors that grub can't find the efi partition or something of the kind. so what I did instead was this:

Code: Select all

sudo mkdir /boot/efi
sudo mount /dev/mmcblk0p1 /boot/efi
sudo grub-install --no-nvram
sudo update-grub
and then I put

Code: Select all

UUID=<UUID> /boot/efi vfat defaults 0 2
at the end of /etc/fstab
Get UUID with

Code: Select all

sudo blkid /dev/mmcblk0p1
I did not follow this step, because I didn't know what it meant at all, and no commands or paths were given.
Finally(!), you will have to copy the GPU firmware/bootloader files and U-boot to the system's fat partition. This will be mounted at /boot/efi if installation has gone correctly.
Rebooting now does boot into ubuntu without a problem, at least it did for me.
At this point I made some changes to the system, like installing the package xubuntu-desktop, mongodb, mono-complete and a few other things I wanted.
A few problems did occur:
  • The desktop was hanging up
  • wifi not working, which is no big deal for me
The desktop hanging up was related to the vc4 framebuffer kernel module not working correctly. When switching to tty1 (ctrl + alt + f1) it gave me some hdmi errors related to vc4. On a fedora forum I found out that blacklisting the module gets rid of the error (and it did for me on ubuntu).
So I will add this to the list of things I did that the installation instructions didn't mention
I added the vc4 kernel module to the blacklist

Code: Select all

sudo bash
echo blacklist vc4 > /etc/modprobe.d/blacklist-vc4.conf
exit
reboot
After that everything worked fine without even the hint of a problem, except for wifi, as I mentioned.
However I powered down over the weekend, returned to the project and nothing works anymore.
Also I rebooted several times, and it always came back into ubuntu before, including with disconnected power.


That's all I did, and I don't have a clue what's going on. I'm no expert at booting, nor am I deep down into linux or the raspberry, I just want to use the thing to log some data.
Any help would be greatly appreciated. Thank you.
Last edited by FalcoGer on Thu Aug 09, 2018 6:48 pm, edited 5 times in total.

feelslikeautumn
Posts: 245
Joined: Wed Aug 09, 2017 9:51 pm

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 10:05 am

Firstly, edit out the swear word.

Have you stuck the sd card into a pc and run a file system check?

FalcoGer
Posts: 26
Joined: Mon Jul 09, 2018 6:35 am

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 10:39 am

I just did run fsck on all three partitions
Results:

Code: Select all

sudo fsck -n -V /dev/sdb1
fsck from util-linux 2.31.1
[/sbin/fsck.vfat (1) -- /dev/sdb1] fsck.vfat -n /dev/sdb1
fsck.fat 4.1 (2017-01-24)
dev/sdb1: 231 files, 129803/258078 clusters

sudo fsck -n -V /dev/sdb2
fsck from util-linux 2.31.1

sudo fsck -n -V /dev/sdb3
fsck from util-linux 2.31.1
[/sbin/fsck.ext4 (1) -- /dev/sdb3] fsck.ext4 -n /dev/sdb3
e2fsck 1.44.1 (24-Mar-2018)
root: clean, 174871/848640 files, 1328221/3390208 blocks
I have also overwritten the boot partition again with the bootloader that I used to start the netboot thing. That worked just fine.
I could then manually boot again, and the grub from the netboot image allowed ls and all the other nice things without problems.
I did the same steps as before, and it booted a few times. And then acted up again.
Last edited by FalcoGer on Mon Jul 09, 2018 11:52 pm, edited 1 time in total.

feelslikeautumn
Posts: 245
Joined: Wed Aug 09, 2017 9:51 pm

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 11:31 am

You could install the raspi2 kernel and flash-kernel packages so you don't need uboot/grub2.

To be honest I'm amazed you had it working at all because that is not my experience. There is something in Ubuntu's default grub.cfg that causes grub2 to crash for me. I haven't investigated it because I switch to raspi2.

FalcoGer
Posts: 26
Joined: Mon Jul 09, 2018 6:35 am

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 11:39 am

feelslikeautumn wrote:
Mon Jul 09, 2018 11:31 am
You could install the raspi2 kernel and flash-kernel packages so you don't need uboot/grub2.

To be honest I'm amazed you had it working at all because that is not my experience. There is something in Ubuntu's default grub.cfg that causes grub2 to crash for me. I haven't investigated it because I switch to raspi2.
Could you elaborate on that please?
I wish to use a 64bit OS, ubuntu if possible. Isn't the raspi2 kernel 32bit?

To be quite honest, I just wish they would stop their 'the raspberry pi only has 1gb of ram, therefore 64 bit is not needed' nonsense.
there is a lot more to 64 bit than how much memory you can map.
an official raspbian 64bit would be much preferred.

feelslikeautumn
Posts: 245
Joined: Wed Aug 09, 2017 9:51 pm

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 12:05 pm

https://wiki.ubuntu.com/ARM/RaspberryPi ... .2FAArch64

You need to also create config.txt and cmdline.txt files. The necessary info is scattered around the wiki https://wiki.ubuntu.com/ARM/RaspberryPi ... B.2F3B.2B- . The arm64 xubuntu installer shows how it can be done.

64bit raspbian would just be debian. The mistake they made was re-branding debian as raspbian. It should of been a debian port.

FalcoGer
Posts: 26
Joined: Mon Jul 09, 2018 6:35 am

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 12:23 pm

feelslikeautumn wrote:
Mon Jul 09, 2018 12:05 pm
https://wiki.ubuntu.com/ARM/RaspberryPi ... .2FAArch64

You need to also create config.txt and cmdline.txt files. The necessary info is scattered around the wiki https://wiki.ubuntu.com/ARM/RaspberryPi ... B.2F3B.2B- . The arm64 xubuntu installer shows how it can be done.

64bit raspbian would just be debian. The mistake they made was re-branding debian as raspbian. It should of been a debian port.
I'd like to avoid reinstalling everything (it took about a whole day to download and install everything)
I can boot into Ubuntu manually using the netboot bootloader (uboot + grub2)
Could you explain how I get from where I am now to changing out the bootloader without killing everything?
In the links you provided are confusing, because I followed the installation steps just below.

For example
There is a config.txt entry to make the ARM start in 64-mode (otherwise 32-bit mode is used):

arm_control=0x200
(This will fail to boot unless you provide a kernel compiled for 64-bit mode)

64 bit versions of the linux-raspi2 kernels were introduced in Ubuntu 16.10 (Yakkety Yak).
I don't have a raspberry 2 and there is no config file of any sort except for the grub bootloader config.

or
The official Ubuntu images use u-boot as the bootloader. The u-boot binary built for the Pi 2 does not work on the Pi 3 and this is why there are separate images for the Pi 2 and Pi 3. However, the Raspberry Pi has its own built in bootloader. This can be used with a few changes to the config.txt file on the system-boot partition.

Write the image to an SD card as normal, but before you insert it into the Pi mount the two partitions so that you can make changes. Open the config.txt on the first partition (labelled system-boot). Change the kernel line, add an initramfs line, and comment out (#) the device_tree_address line as follows:
What's the official ubuntu image? The whole point of this ordeal was there was no image. Only the iso. Had there been an image I'd just dd it onto the sd card and be done with the whole thing.
Also 'write the image to an sd card as normal', what image?

Where can I find this built in bootloader (that I'm not having on my boot partition) how do I get it onto my drive and what needs to be done so it boots from the ext4 partion (hd0,msdos3)?


Alternatively:
I'd be happy as long as it boots. Because the netboot uboot+grub seems to work just fine, I'd be okay with changing the grub config around so it autoboots like i would do it manually like so.

Code: Select all

set root=(hd0,msdos3)
linux /boot/vmlinuz root=/dev/mmcblk0p3
initrd /boot/initrd.img
boot
Edit:

after running grub-install and grub-update with /dev/mmcblk0p1 mounted at /boot/efi I get the following diff with the boot partition mounted at /mnt and ~/Desktop/boot being the netboot installation

Code: Select all

diff -r /mnt ~/Desktop/boot
Binary files .efi/boot/bootaa64.efi and /home/[...]/boot/efi/boot/bootaa64.efi differ
Only in /mnt/efi: ubuntu
in /mnt/efi/ubuntu:

Code: Select all


fw/
fwupaa64.efi
grubaa64.efi

fw is empty
Last edited by FalcoGer on Mon Jul 09, 2018 1:34 pm, edited 1 time in total.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20065
Joined: Sat Jul 30, 2011 7:41 pm

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 1:24 pm

There are a few reasons why we do not have a 64 bit OS.

The main one is that if we did we would need TWO distro's because the 64bit one would not work on the Pi0 or Pi1. We do not have the support capability to maintain two distro's. At the moment we have one that suits all models of Pi. I suspect that eventually we will have to bite the bullet and produce two versions.

If there was a massive advantage to 64 bit, then would probably do it sooner rather than later, but at the moment, its really not clear how much of an advantage running 64bit is.

Raspbian is mostly Debian, with enough changes to make it work on the Pi itself. A few things are done differently. The naming is historical.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

FalcoGer
Posts: 26
Joined: Mon Jul 09, 2018 6:35 am

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 2:33 pm

That doesn't help me, really.
I need a bootable 64bit system.

Or rather a system that boots automatically and doesn't destroy itself when updating, because technically I can boot it manually.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20065
Joined: Sat Jul 30, 2011 7:41 pm

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 2:38 pm

FalcoGer wrote:
Mon Jul 09, 2018 2:33 pm
That doesn't help me, really.
I need a bootable 64bit system.

Or rather a system that boots automatically and doesn't destroy itself when updating, because technically I can boot it manually.
I was just responding to some questions raised above.

I believe there is a decent Gentoo 64 bit distro - I think forum contributor sakaki (?) is behind it.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

FalcoGer
Posts: 26
Joined: Mon Jul 09, 2018 6:35 am

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 3:34 pm

I'd rather fix this than to start over a 5th time. Can't be that hard.
Do you think I can grab the raspbian bootloader and bend it so it loads up from the third partition, rather than the second and also boots 64bit and the specific kernel I want?

I'd like idiot proof instructions if that's possible.
mounting the image is a problem, I think, since the image itself has multiple partitions in it. and I'd rather not overwrite my sd cards all too often. they don't like that.

FalcoGer
Posts: 26
Joined: Mon Jul 09, 2018 6:35 am

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Mon Jul 09, 2018 11:58 pm

feelslikeautumn wrote:
Mon Jul 09, 2018 11:31 am
You could install the raspi2 kernel and flash-kernel packages so you don't need uboot/grub2.
  • How do you do that from where I am (ubuntu installed, boot partition needs changing/reconfiguring) (for idiots like me, preferably with copypasta code where you just put in whatever values you need and how to figure those values out)?
  • will it still boot the ubuntu 64 bit kernel and everything related?
  • will having run grub-install interfere with it in any way? For example with dist-upgrades or something like that. if so, how do I avoid conflicts?
  • is there any configuration to be done, and if so, what are the steps?


feelslikeautumn
Posts: 245
Joined: Wed Aug 09, 2017 9:51 pm

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Tue Jul 17, 2018 9:46 pm

FalcoGer wrote:
Mon Jul 09, 2018 12:23 pm
Alternatively:
I'd be happy as long as it boots. Because the netboot uboot+grub seems to work just fine, I'd be okay with changing the grub config around so it autoboots like i would do it manually like so.

Code: Select all

set root=(hd0,msdos3)
linux /boot/vmlinuz root=/dev/mmcblk0p3
initrd /boot/initrd.img
boot
A simple way to test this is to edit the configuration file /boot/grub/grub.cfg to the above. You may have to add some insmod lines too if the grub modules you need are not built in.

Note, update-grub will be run automatically when you install a new kernel (due to this file /etc/kernel/postinst.d/zz-update-grub) and this will overwite any custom grub.cfg you have made.

FalcoGer
Posts: 26
Joined: Mon Jul 09, 2018 6:35 am

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Fri Jul 27, 2018 12:11 pm

It works!

I put

Code: Select all

set timeout=10

menuentry 'Ubuntu' {
	set background_color=black
	set root=(hd0,msdos3)
	linux /boot/vmlinuz root=/dev/mmcblk0p3
	initrd /boot/initrd.img
}
menuentry 'UbuntuOLD' {
	set background_color=black
	set root=(hd0,msdos3)
	linux /boot/vmlinuz.old root=/dev/mmcblk0p3
	initrd /boot/initrd.img.old
}
after

Code: Select all

insmod gzio
and before the install menu entries

then I uninstalled grub from ubuntu so it doesn't mess with /boot/efi when I get a kernel update or something like that
now after 10 seconds it boots into ubuntu without a problem

*happy*

cyclic
Posts: 3
Joined: Thu May 30, 2013 4:47 pm

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Thu Aug 09, 2018 1:08 pm

If I understand you correctly, you have come up with a work around to solve:
-install arm64 18.04 ubuntu server from the iso(?),
-modify whatever is necessary e.g. copy stuff from raspbian latest (?) and
-then to patch to get it to boot on a pi3b+
-from SD card if I read the previous post? (+usb?) and
-without it self destructing subsequently including permitting updates.

As you already know there are many forum threads + ubuntu wiki pages on this
some stated to "should work" but don't and
some of them part work for this but not that,
intermingled with unhelpful off thread red herrings about desktops, armhf and other distributions
plus of course the helpful posts (!!) which helped you to solve this and therefore
it makes it very difficult to know exactly what you did do, and replicate to what you have done.

Would it be possible please to bring all together in one post all the steps that you took from start to finish which gave you the working solution.
Would you also be able to list what baseline hardware is working and
what other hardware is not working (yet?)
Perhaps for clarity a new thread would be useful?

FalcoGer
Posts: 26
Joined: Mon Jul 09, 2018 6:35 am

Re: Ubuntu 18.04 LTS for ARM64 suddenly stops booting with failure to write sector to hd0, warning at bcm2835_sdhost.c:4

Thu Aug 09, 2018 3:15 pm

cyclic wrote: If I understand you correctly, you have come up with a work around to solve:
-install arm64 18.04 ubuntu server from the iso(?),
-modify whatever is necessary e.g. copy stuff from raspbian latest (?) and
-then to patch to get it to boot on a pi3b+
-from SD card if I read the previous post? (+usb?) and
-without it self destructing subsequently including permitting updates.

As you already know there are many forum threads + ubuntu wiki pages on this
some stated to "should work" but don't and
some of them part work for this but not that,
intermingled with unhelpful off thread red herrings about desktops, armhf and other distributions
plus of course the helpful posts (!!) which helped you to solve this and therefore
it makes it very difficult to know exactly what you did do, and replicate to what you have done.

Would it be possible please to bring all together in one post all the steps that you took from start to finish which gave you the working solution.
Would you also be able to list what baseline hardware is working and
what other hardware is not working (yet?)
Perhaps for clarity a new thread would be useful?
I manged to:
- Put Ubuntu's net installer for arm64 onto an sd card
- boot the net installer from the sd card on the raspberry pi 3 (not +)
- install ubuntu 18.04 64bit
- mess around with the grub config file of the net installer so it boots ubuntu instead of the net installer again

I made a new topic here: viewtopic.php?f=56&t=220079

Return to “Other”

Who is online

Users browsing this forum: No registered users and 5 guests