USB Boot on Raspberry Pi 4

See also this topic: https://community.home-assistant.io/t/hass-io-transfer-from-sd-card-to-ssd-or-usb/97452/367?u=jodur

I also got it only stable with usb-storage quirks enabled.

Yes, that is the correct way to do it.

in config.txt or cmdline.txt, I am thinking config?

More information about this:

  • As I commented in the past, I have more CPU usage in the new ssd boot version.
  • Today, it seems I have fixed it (at least partially).
    image

The only difference was to add the:
dtparam=sd_poll_once=on
to the config.txt. In theory is only optional to not show ugly messages in the log, but it seems to affect the cpu too.
Of course, I rebooted the rpi to make the change, so maybe the problem was simply at other place and the reboot fixed it, but I have restarted it other two times before this change and the problem was there.

After Applying the quirks my own instance has started misbehaving again.

Updating amcrest camera took longer than the scheduled update interval 0:00:15
11:40:09 – Camera (WARNING) - message first occurred at 11:21:20 and shows up 31 times
Updating rpi_power sensor took longer than the scheduled update interval 0:00:30
11:40:09 – Sensor (WARNING) - message first occurred at 11:21:32 and shows up 31 times
Update of calendar.contacts is taking over 10 seconds
11:40:08 – runner.py (WARNING) - message first occurred at 11:21:00 and shows up 147 times
Updating amcrest binary_sensor took longer than the scheduled update interval 0:00:05
11:40:06 – Binary Sensor (WARNING) - message first occurred at 11:20:55 and shows up 128 times
Updating samsungtv_encrypted media_player took longer than the scheduled update interval 0:00:10
11:39:55 – Media Player (WARNING) - message first occurred at 11:21:00 and shows up 55 times
Updating darksky weather took longer than the scheduled update interval 0:00:30
11:39:47 – Weather (WARNING) - message first occurred at 11:21:44 and shows up 8 times
Updating google calendar took longer than the scheduled update interval 0:01:00
11:39:13 – Calendar (WARNING) - message first occurred at 11:26:11 and shows up 4 times
Timeout error fetching version information from Hassio,
11:39:11 – runner.py (ERROR) - message first occurred at 11:34:11 and shows up 2 times
Config entry for wled not ready yet. Retrying in 80 seconds
11:39:08 – config_entries.py (WARNING) - message first occurred at 11:21:13 and shows up 13 times

What could be causing this, I cannot see anything in the Logs?

HA can run fine for say 12 hrs then excessive CPU, heat, error logs fill up and everything lags.
See CPU use below

Usually deleting the db clears this behaviour but that is far from ideal having to do that everytime?

First, verify that the quirk is working.
In the supervisor, system tab, select the Host log. I see this in mine:

[    1.092126] usb-storage 2-1:1.0: USB Mass Storage device detected
[    1.092598] usb-storage 2-1:1.0: Quirks match for vid 152d pid 0578: 1800000

If all is ok, try to add the dtparam=sd_poll_once=on to the config.txt file. In theory it is not necessary, and my system was stable, but it helped a lot with my cpu.

I think I don’t have more ideas…

did you put the quirks in cmdline.txt

usb-storage.quirks=174c:55aa:u dwc_otg.lpm_enable=0 console=tty1

or or config.txt?

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# HassOS - don't change it!
disable_splash=1
kernel=u-boot.bin

dtparam=sd_poll_once=on

usb-storage.quirks=174c:55aa:u

# uncomment for aarch64 bit support
arm_64bit=1

This is all i am seeing in system log / Host

[    1.163626] usb 2-1: new SuperSpeed Gen 1 USB device number 2 using xhci_hcd
[    1.184596] usb 2-1: New USB device found, idVendor=174c, idProduct=55aa, bcdDevice= 1.00
[    1.187048] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[    1.189673] usb 2-1: Product: Best USB Device
[    1.192267] usb 2-1: Manufacturer: ULT-Best
[    1.194833] usb 2-1: SerialNumber: 042003192AC2
[    1.217297] scsi host0: uas
[    1.220072] scsi 0:0:0:0: Direct-Access     CT120BX5 00SSD1           0    PQ: 0 ANSI: 6

when I search for “quirks” all I get is
[ 0.551644] xhci_hcd 0000:01:00.0: hcc params 0x002841eb hci version 0x100 quirks 0x0000001000000890

OK, put the quirks in cmdline.txt and this is my host log now.

1.151849] usb 2-1: new SuperSpeed Gen 1 USB device number 2 using xhci_hcd
[    1.172636] usb 2-1: New USB device found, idVendor=174c, idProduct=55aa, bcdDevice= 1.00
[    1.175034] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[    1.177652] usb 2-1: Product: Best USB Device
[    1.180294] usb 2-1: Manufacturer: ULT-Best
[    1.182886] usb 2-1: SerialNumber: 042003192AC2
[    1.188950] usb 2-1: UAS is blacklisted for this device, using usb-storage instead
[    1.190848] usb 2-1: UAS is blacklisted for this device, using usb-storage instead
[    1.192006] usb-storage 2-1:1.0: USB Mass Storage device detected
[    1.193421] usb-storage 2-1:1.0: Quirks match for vid 174c pid 55aa: c00000
[    1.194679] scsi host0: usb-storage 2-1:1.0
[    2.207964] scsi 0:0:0:0: Direct-Access     CT120BX5 00SSD1           0    PQ: 0 ANSI: 6

I presume from the above my quirks have been correctly implemented?

Question I would like to ask now is how to test the speed of the SSD? I have terminal installed.

Yes, this looks far better. The quirk goes into the cmdline.txt and the dtparam in the config.txt.

I’m not an expert in Linux, to check the speed, I’ve used a command from the other thread: hdparm -t [device]

> hdparm -t /dev/sda 

/dev/sda:
Timing buffered disk reads:  752 MB in 3.00 seconds = 256645 kB/s

This is using the ssh&web addon disabling the protection mode. Under standard ssh I suppose you could do the same with sudo in the command.

I think the raw speed will be similar, reading in the net seems that with UAS we can get a little more performance when using several parallel data flows.

Thanks, my results as follows.

Our command line:
$ ha help
➜  ~ hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  805 MB in 3.00 seconds = 274352 kB/s

@McGiverGim, after reading your post, i never checked the logs if the quirk is really applied and after studying the OS log, i saw that the usb.quirks was not applied, so it seems i am now running with UAS enabled stable for already more then 1 week :grinning:

I made the mistake not reading well and applied the quirk in the config.txt instead of cmdline.txt so that explains why usbquirk was not applied in my case.

I report now the following speed (with UAS), :

# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  899 MB in 3.00 seconds = 306662 kB/s
# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  815 MB in 3.00 seconds = 277945 kB/s
# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  976 MB in 3.00 seconds = 333051 kB/s

I am using a Geekworm X825 with a Curcial BX500 240 GB SSD

Would be nice if everybody reports the speed they get with :

hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  802 MB in 3.00 seconds = 273685 kB/s
➜  ~ hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads:  803 MB in 3.00 seconds = 273752 kB/s

ELUTENG USB 3.0 to SATA Cable for 2.5" HDD or SSD Adapter 5Gbps High Speed Plug and Play Support UASP SATA I II III Hard Disk Drive USB S-ATA Converter

Crucial BX500 120 GB CT120BX500SSD1(Z)-Up to 540 MB/s (Internal SSD, 3D NAND, SATA, 2.5 Inch)

I am using quirks usb-storage.quirks=174c:55aa:u

If you are interested, it seems there is an addon to monitor SMART data of the SSD, that executes a test:

[Thu Aug  6 09:16:39 CEST 2020][Info] Run performance test
     Category                  Test                      Result              
HDParm                    Disk Read                  MB/s                    
HDParm                    Cached Disk Read           MB/s                    
DD                        Disk Write                171 MB/s                 
FIO                       4k random read            4599 IOPS (18396 KB/s)   
FIO                       4k random write            IOPS ( KB/s)            
IOZone                    4k read                   21472 KB/s               
IOZone                    4k write                  16395 KB/s               
IOZone                    4k random read            15465 KB/s               
IOZone                    4k random write           22464 KB/s               
                          Score:                                             
Compare with previous benchmark results at:
https://storage.jamesachambers.com/ 
[Thu Aug  6 09:18:22 CEST 2020][Info] Performance test end

You can get it from here:

EDIT: When I start the addon Home Assistant restarts at the end of the test. It seems only once, but I don’t know why.

1 Like
RandRead: 15004 - RandWrite: 21512 - Read: 22311 - Write: 16936

     Category                  Test                      Result              
HDParm                    Disk Read                 160.46 MB/s              
HDParm                    Cached Disk Read          246.51 MB/s              
DD                        Disk Write                117 MB/s                 
FIO                       4k random read            4139 IOPS (16556 KB/s)   
FIO                       4k random write           4813 IOPS (19252 KB/s)   
IOZone                    4k read                   22311 KB/s               
IOZone                    4k write                  16936 KB/s               
IOZone                    4k random read            15004 KB/s               
IOZone                    4k random write           21512 KB/s               

                          Score: 4988             

My own results

Hi all
may I ask a dummy question
how download the dev image for rasp pi usb boot?
tks

Maybe to much, but for those who want Debian 10(buster) 64Bit running on SSD/USB on RPi4

https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-05-28/2020-05-27-raspios-buster-arm64.zip

Flash image on a SDCard. Add SDcard and your SSD to your RPi4
You can also add already ssh option and you wifi settings on the /boot/ partition of SDcard

Remove the old dphys version

sudo /etc/init.d/dphys-swapfile stop
sudo apt-get remove --purge dphys-swapfile

Refresh your OS

sudo apt-get update
sudo apt-get full-upgrade

Prepare RPi4 for USB Boot

Refresh your OS with the latest firmware

sudo nano /etc/default/rpi-eeprom-update
sudo rpi-eeprom-update -d -a
reboot

Install RPICLONE (For cloning from SDCard to my SSD, my SSD is /dev/sda, yours can be different)

git clone https://github.com/billw2/rpi-clone.git 
cd rpi-clone
sudo cp rpi-clone rpi-clone-setup /usr/local/sbin
sudo rpi-clone sda

After RPICLONE is done open a new terminal window

nano /mnt/clone/boot/cmdconfig.txt

Add rootdelay=5 cgroup_memory=1 cgroup_enable=memory to the line and save the file.
Exit the terminal

shutdown now

Remove the SDCard and boot from SSD now.
Correct location and timezone

raspi-config

Install Docker

sudo -i
apt-get install software-properties-common -y
apt-get update
apt-get install modemmanager
reboot now

Reason I install modem manager first and reboot, because when do with network-manager my RPi freeze

apt-get install network-manager
apt-get install apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq socat bash curl 
curl -fsSL get.docker.com | sh

Install Hass.io

systemctl stop ModemManager
systemctl disable ModemManager
curl -sL https://raw.githubusercontent.com/home-assistant/supervised-installer/master/installer.sh | bash -s -- -m raspberrypi4

DONE

Here some links I get the information from:


https://www.uberbuilder.com/using-rpi-clone/

Things went downhill fast today…

This afternoon I had a perfectly running HassOS 5.1 x64 image running from a USB thumb drive, installed two weeks ago. But I ran into trouble when trying to add a Arduine Mega peripheral, as I couldn’t boot the device due to the Arduino messing up the boot order.

First I’ve tried to put in a bootable SD card (with a fully updated minimal install) and put the exact PARTUUID in the boot order to get it to boot. That didn’t work as planned.

So after hours of trials and failing, I upgraded the firmware today to the latest version and fiddled a bit with the bootloader and bootorder. I have checked the boot order and it looks correct (0xf41) but somehow my Pi won’t boot into the USB thumb drive any longer. No matter what I try. All it does is the 4x-blinking green LED, telling me there is nothing to boot.

As I have a recent backup of my hassOS install, I decided to re-flash the thumb drive with the HassOS image. Nothing but the green blinking LED. Any idea of what I’m doing wrong? Might have to revert to a manual Hassio install…

UPDATE 1
I realized this doesn’t work without me posting used hard- and software specs.
Raspberry Pi 4B 4GB
Raspberry Pi USB-C power supply
Sandisk Extreme Pro USB 3.0 128GB (flashed with HassOS 64-bit v.5.1 dev image for the Pi)
Raspbery Pi OS (5.4.61-v7l+)
Bootloader version: Jul 31 2020 14:43:39 (release)
Bootloader config:

[all]
BOOT_UART=0
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0
DHCP_TIMEOUT=45000
DHCP_REQ_TIMEOUT=4000
TFTP_FILE_TIMEOUT=30000
TFTP_IP=
TFTP_PREFIX=0
BOOT_ORDER=0xf41
[none]
FREEZE_VERSION=0

Eeprom status

BCM2711 detected
Dedicated VL805 EEPROM detected
BOOTFS /boot
BOOTLOADER: up-to-date
CURRENT: Fri 31 Jul 13:43:39 UTC 2020 (1596203019)
 LATEST: Fri 31 Jul 13:43:39 UTC 2020 (1596203019)
 FW DIR: /lib/firmware/raspberrypi/bootloader/stable
VL805: up-to-date
CURRENT: 000138a1
 LATEST: 000138a1

UPDATE 2
Must have been an integrity issue with the bootloader. Quick fix was a reset to the latest stable release

sudo rpi-eeprom-update -a -d

And all is well. My apologies for taking your time.

Hi, A have the same problem! It works fine with Raspbian, but black screen with Hassio!

I’m using a PI4 4GB + CSL USB 3.0 Type A adapter - this works fine on my PI3B+ with 4.13. PI4 arrived today and i’ve upgraded to the Sep bootloader fine but drive plugged in i see the ‘bios’ screen and then things go black… no boot. Tried 5.1 dev build (32bit) to no avail so far…

Going to blow raspian onto the drive to see if that boots.

…and it does. Oh dear.

Am sitting looking at a working Raspian desktop entirely running orf SSD.

HassOS be dead :frowning: