USB quirks

1. Finding the VID and PID of your USB SSD
Disconnect the USB SSD. In a terminal window, run the command sudo dmesg -C.
Now, plug in the SSD and run dmesg with no parameters.
You should get output that looks like this:

[ 4096.609817] usb 2-1: new SuperSpeed Gen 1 USB device number 4 using xhci_hcd
[ 4096.646369] usb 2-1: New USB device found, idVendor=2109, idProduct=0715, bcdDevice=a0.00
[ 4096.646385] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 4096.646397] usb 2-1: Product: SABRENT
[ 4096.646409] usb 2-1: Manufacturer: SABRENT
[ 4096.646421] usb 2-1: SerialNumber: 000000123AD2
[ 4096.655154] scsi host0: uas
[ 4096.669178] scsi 0:0:0:0: Direct-Access SABRENT 2210 PQ: 0 ANSI: 6
[ 4096.670993] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 4096.673710] sd 0:0:0:0: [sda] 234441648 512-byte logical blocks: (120 GB/112 GiB)
The idVendor and idProduct are the two hexadecimal numbers you need to take a note of.

1a. Multiple SSDs
If you have multiple USB SSD devices plugged into a single Pi 4, then for each device experiencing issues repeat Step 1 above and make a note of each idVendor and idProduct pair.

2. Add the quirks to /boot/cmdline.txt
Run a text editor as root – sudo nano /boot/cmdline.txt from the console or sudo leafpad /boot/cmdline.txt from the desktop.
At the start of the line of parameters, add the text usb-storage.quirks=aaaa:bbbb:u where aaaa is the idVendor for your device and bbbb is the idProduct. So, with the device above the string will be usb-storage.quirks=2109:0715:u.
cmdline.png (21.45 KiB) Viewed 46967 times
For multiple devices with different VID:PID pairs, expand the parameter with a comma between each vid:pid:u triplet like this: usb-storage.quirks=0123:4567:u,2109:0715:u.

Save the file and exit the editor.

3. Reboot.

4. Check that it worked
To check that the quirk has been applied successfully, run dmesg | grep usb-storage and check that the VID and PID is listed as having a quirk applied:

[ 2.495725] usb 2-1: UAS is blacklisted for this device, using usb-storage instead
[ 2.512739] usb 2-1: UAS is blacklisted for this device, using usb-storage instead
[ 2.531823] usb-storage 2-1:1.0: USB Mass Storage device detected
[ 2.549642] usb-storage 2-1:1.0: Quirks match for vid 2109 pid 0715: 800000
[ 2.566177] scsi host0: usb-storage 2-1:1.0

Re: STICKY: If you have a Raspberry Pi 4 and are getting bad speeds transferring data to/from USB3.0 SSDs, read this
Post by harrytv » 25 Jan 2020 13:42

I had a lot of issues with stuttering video playback using Libreelec 9.2.0. Media files (mkv, h264) were located on a very fast 1TB SSD connected via a USB3.0 adapter. I finally hit this post and it helped tremendously. Here is what I did for completeness.

* I logged in as user `root` using Putty SSH from a Windows machine, using default password.
* Disconnected USB drive and ran (since this is libreelec no need for `sudo`)

dmesh -c
* Reconnected the USB drive and ran:

[ 342.605668] usb 2-1: new SuperSpeed Gen 1 USB device number 3 using xhci_hcd
[ 342.626900] usb 2-1: New USB device found, idVendor=152d, idProduct=1561, bcd Device= 2.04
[ 342.626921] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 342.626938] usb 2-1: Product: SABRENT
[ 342.626953] usb 2-1: Manufacturer: SABRENT
[ 342.626968] usb 2-1: SerialNumber: DB9876543214E
[ 342.639515] scsi host0: uas
[ 342.640972] scsi 0:0:0:0: Direct-Access SABRENT 0204 PQ : 0 ANSI: 6
[ 345.935277] sd 0:0:0:0: [sda] 1953525168 512-byte logical blocks: (1.00 TB/93 2 GiB)
[ 345.935286] sd 0:0:0:0: [sda] 4096-byte physical blocks
[ 345.935531] sd 0:0:0:0: [sda] Write Protect is off
[ 345.935538] sd 0:0:0:0: [sda] Mode Sense: 53 00 00 08
[ 345.936048] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, does n’t support DPO or FUA
[ 345.936856] sd 0:0:0:0: [sda] Optimal transfer size 33553920 bytes not a mult iple of physical block size (4096 bytes)
[ 345.940078] sda: sda1
* As can be seen this is a USB3.0 SATA 3 adapter from Sabrent. Running in `uas` mode.
* To verify how poorly this was running I tested the speed using:

hdparm -t /dev/sda1
Timing buffered disk reads: 516 MB in 33.25 seconds = 15.52 MB/sec
* Which of course is extremely slow. I then checked the log again using `dmesg`:

[ 1247.365069] usb 2-1: reset SuperSpeed Gen 1 USB device number 3 using xhci_hcd
[ 1247.387663] scsi host0: uas_eh_device_reset_handler success
[ 1279.648929] sd 0:0:0:0: [sda] tag#3 uas_eh_abort_handler 0 uas-tag 4 inflight: CMD IN
[ 1279.648937] sd 0:0:0:0: [sda] tag#3 CDB: opcode=0x28 28 00 03 fa 64 50 00 01 00 00
[ 1279.649085] sd 0:0:0:0: [sda] tag#1 uas_eh_abort_handler 0 uas-tag 2 inflight: CMD IN
[ 1279.649091] sd 0:0:0:0: [sda] tag#1 CDB: opcode=0x28 28 00 00 00 10 00 00 04 00 00
[ 1279.649553] sd 0:0:0:0: [sda] tag#0 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD IN
[ 1279.649559] sd 0:0:0:0: [sda] tag#0 CDB: opcode=0x28 28 00 00 00 0c 00 00 04 00 00
[ 1286.049165] sd 0:0:0:0: tag#4 uas_eh_abort_handler 0 uas-tag 5 inflight: CMD
[ 1286.049173] sd 0:0:0:0: tag#4 CDB: opcode=0x0 00 00 00 00 00 00
[ 1286.065838] scsi host0: uas_eh_device_reset_handler start
* Same issues as discussed in this post.
* Fixing this on libreelec was a bit different though, hence why I wrote this post.
* Navigate to root after logging in, ensure you can edit the `/flash/cmdline.txt` by remounting, then edit file.

cd ..
mount -o remount,rw /flash
nano /flash/cmdline.txt
* I simply adding the below to the beginning of the file and saved:

* And then rebooted:

* After rebooting I checked that the quirk was applied:

dmesg | grep usb-storage
[ 0.673330] usbcore: registered new interface driver usb-storage
[ 1.024033] usb 2-1: UAS is blacklisted for this device, using usb-storage in stead
[ 1.024147] usb 2-1: UAS is blacklisted for this device, using usb-storage in stead
[ 1.024163] usb-storage 2-1:1.0: USB Mass Storage device detected
[ 1.024576] usb-storage 2-1:1.0: Quirks match for vid 152d pid 1561: 800000
[ 1.024726] scsi host0: usb-storage 2-1:1.0
* Which it was, and I then retested the performance:

LibreELEC:~ # hdparm -t /dev/sda1

Timing buffered disk reads: 930 MB in 3.00 seconds = 309.71 MB/sec
* A 20x improvement and it runs so much better. So thank you for this sticky. 🙂

Mouse double click speed

Trouble like me with Mouse double click speed?

Google “lxde double click speed”, there is a hidden file named “.gtkrc-2.0” in your home directory. So if it does not exist, create it. If it does exit, read it before you proceed — it may advise you to use “.gtkrc-2.0.mine” instead.
Type these commands from the prompt, or inside LXTerminal.

sudo nano ~/.gtkrc-2.0

Add the following line:


Press Ctrl – X, y and enter to save and quit the editor. Logout of the desktop and startx again for it to take effect.


rpi_hal from is an incredible rich and uptodate unit for Freepascal to use the I/O of the Raspberry.

From Freepascal programs all works as expected when run as root. Otherwise accessing /dev/mem is causing real problems.

The unit can be used from Lazarus also (avoid the test procedures with writeln’ 😉 ) but also require root access and setting cthreads in the program heading.

For X apps  running as root is not possible with just sudo.
Seems I found a solution here:

I applied method 2:

sudo nano /etc/profile

and added this line as last line

export XAUTHORITY=/home/pi/.Xauthority

Now i can do

$ sudo ./testinit (my simple test program with only the init line of rpi_hal)

and this worked without error, init succeeded.

If you want debugging the app in Lazarus, start Lazarus as root (and ignore all the warnings)

xhost +localhost
sudo /usr/bin/startlazarus

Original text from

Method 2: Globally in /etc/profile
Add the following line to /etc/profile:

export XAUTHORITY=/home/username/.Xauthority
This will permanently allow root to connect to a non-root user’s X server.

Or, merely specify a particular app:

XAUTHORITY=/home/username/.Xauthority appname
where appname is the name of the particular app. (e.g. kwrite

Arduino on Raspberry

Install Arduino on Buster

  1. Arduino 1.8.12 (or higher) from – Software – Arduino ARM 32 bits
  2. Download to e.g. Downloads
  3. cd /Downloads
  4. tar -x -f arduino-1.8.5-linuxarm.tar.xz
  5. cd arduino-1.8.12
  6. sudo ./
  7. and Arduino appears in Home – Programming desktop

XRDP revisited

Shutdown menu not working:

You can get the Buttons working, just change the line ‘Logout=lxde-pi-shutdown-helper’ to ‘Logout=sudo lxde-pi-shutdown-helper’
in ‘/home/pi/.config/lxpanel/LXDE-pi/config’.

Install Freepascal/Lazarus again

For Buster see here!

Installed using instructions from several posts by Thaddy as follows:

1. Add stretch-backports to sources.list

Create:   sudo nano /etc/apt/sources.list.d/backports.list
Add:      deb stretch-backports main

Update:   sudo apt-get update

Ignore complaints about not signed

2.  FPC 3.0.4 and Lazarus 1.8.4 are both in stretch-backports

Use apt or apt-get, need to install with the -t option.
Answer Y to install without verification.

sudo apt-get -t stretch-backports install fpc
sudo apt-get -t stretch-backports install lazarus

Ignore complaints about not verified