Articles Hierarchy

Articles Home » RPI » RPI USB BOOT

RPI USB BOOT

usb boot setup
speed tests
The idea about using USB devices for holding the OS of RPI is old.
but there still was the need for a SD card, now for the RPI3
there can be set a
USB BOOT ENABLE
1 usb boot setup
see here and here and about all boot modes here but that is a one time thing, can not be changed back.
For a PC ( at a public place ) it can make sense to disable USB boot,
because with this a linux/windows password on the OS on HD could be bypassed and the HD content copied.
but for a RPI ? when you can plug in a USB stick you can also take out the SD card... so it should be just enabled in CPU.


but we have to do that how?

sudo nano /boot/config.txt add new last line
program_usb_boot_mode=1
sudo reboot
check if it worked:
vcgencmd otp_dump | grep 17:

pi@RPI3:~ $ vcgencmd otp_dump | grep 17:
17:3020000a
pi@RPI3:~ $

change config.txt back and reboot
so we also know it still boots from SD card without any problem.

so but now the RPI should look for USB drive OS first? and with that i expect a small boot delay? but as i am headless it is difficult to feel


and now? you think i am crazy but instead of making a USB stick first,
i take out the SD card, put it in the card reader, plug it in the RPI and power up
it worked!
would be real nice to know if there is a difference in that 2 ways to run the OS?
+ power
+ speed
anyhow as there are now offers like this i read about here, the question comes again, just now also regarding RPI USB boot ..
what is the electrical difference between a usb stick and a uSD card in a card reader?
here a idea about the inside of a SD card.


using win32diskimager i read this SD card to laptop HD (8GB file)
and write it to a Apacer 16GB USB stick ( at 7 .. 8 MB/s ).
not lucky, it did not boot!
put in the SD Card also and boot from there i see that the USB stick is mounted and has the correct 2 partitions ( and 8GB empty space )
so i look again into the manual what i can do besides try other USB stick.

here is the more detailed boot flow documentation
with this:
If the device fails to respond after this maximum timeout, it is possible to increase the timeout to five seconds using program_usb_timeout=1 in config.txt.

an other OTP switch ( what could work to use that USB stick ) but also make my RPI3 forever 5sec later booting ( from SD card )? maybe not, because it looks for SD card first anyhow?
nee
try a 8GB LEXAR usb stick:
at first the burning (8GB copy) went wrong because stick too small, so i fall back to raspbian image from 2017 04 10
boot ok, and do my usual setup steps to get same system.


using a RPI2 with a cleaned SD card
copy that bootcode.bin file on,
and USB stick in USB port:
OK


would be nice to have something like this and a SSD.


again BOOT ORDER:
if the SD card AND the USB stick is in,
it will boot from SD card


2 speed tests
back with the SD card in RPI i look for my old benchmark tools,
copy a 11MB file between RAM Disk and SD card ( apacer 8GB class 10 )
test1 SD card in RPI:
read from SD card to RAM Disk ( 76 / 61 / 70 MB/s )
write from RAM Disk to SD card ( 47 / 62 / 61 MB/s )
test2 SD card in card reader:
read from SD card to RAM Disk ( 17 / 69 / 91 MB/s )
write from RAM Disk to SD card ( 6 / 50 / 55 MB/s )


test3 USB stick lexar 8GB:
read from USB to RAM Disk ( 73 / 70 / 49 MB/s )
write from RAM Disk to USB ( 49 / 60 / 55 MB/s )
so the speed test not show anything significant between the 3 ways of running the OS ( SD card slot, USB card reader with SD card, USB stick )
but the numbers are about factor 5 .. 10 too fast ( old tests ) so i doubt it all; i just give you here the commands as ref:
nano .bash_aliasesUSER='pi'
BIGFILE='xxx.yyy'
alias speedtestw='rsync -ah --progress /run/shm/'$BIGFILE' /home/'$USER'/'$BIGFILE
alias speedtestr='rsync -ah --progress /home/'$USER'/'$BIGFILE' /run/shm/'$BIGFILE

after each copy i delete the file manually.


doing a other way of speed testing:
_________________________________
alias speedtestw='dd if=/dev/zero of=~/test.tmp bs=500K count=1024'
alias speedtestr='dd if=~/test.tmp of=/dev/null bs=500K count=1024'
_________________________________
pi@RPI3:~ $ speedtestw
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 39.6472 s, 13.2 MB/s
pi@RPI3:~ $ speedtestr
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 0.465594 s, 1.1 GB/s
that is some very doubtful info???
______________________________________________ recheck on a RPI2
pi@RPI2:~ $ speedtestw
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 38.2609 s, 13.7 MB/s
pi@RPI2:~ $ speedtestr
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 1.07913 s, 486 MB/s
pi@RPI2:~ $

hm???
also test RPI2 with the old test ( using a 66MB file):
test_RPI2 SD card in RPI:
read from SD card to RAM Disk ( 42 / 43 / 43 MB/s )
write from RAM Disk to SD card ( 36 / 37 / 36 MB/s )
all this can't be right??
________________________________________________
need to ask the specialists at 4um
________________________________________________
ok, need better speed test command:
here see:
sync; time dd if=/dev/zero of=~/test.tmp bs=500K count=1024; time sync

or
here see:
Write speed
sync; dd if=/dev/zero of=~/test.tmp bs=500K count=1024
Read speed
sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
sync; time dd if=~/test.tmp of=/dev/null bs=500K count=1024
Delete the temporary file
rm ~/test.tmp


so with:
alias speedtestw='sync; dd if=/dev/zero of=~/test.tmp bs=500K count=1024'
alias cleancache='sync; echo 3 | sudo tee /proc/sys/vm/drop_caches'
alias speedtestr='sync; time dd if=~/test.tmp of=/dev/null bs=500K count=1024'
see
pi@RPI3:~ $ cleancache
3
pi@RPI3:~ $ speedtestw
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 42.8439 s, 12.2 MB/s
pi@RPI3:~ $ cleancache
3
pi@RPI3:~ $ speedtestr
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 23.9421 s, 21.9 MB/s

real 0m23.953s
user 0m0.010s
sys 0m1.270s
pi@RPI3:~ $


retest:
SD card 8GB apacer c10 in SD card slot: ( see above )
write : 12MB/s
read : 22MB/s
SD card in card reader in USB port:
write : 12MB/s
read : 20MB/s
USB stick in USB port:
write : 12MB/s
read : 21MB/s
__________________________________
again: even i learned that my first 2 types of speed test are wrong,
speed is no argument to use USB boot
but why my numbers 12 .. 21 MB/s are so close together ( sd card / usb stick )
and still so low compared to 30 .. 35 MB/s of W. H. Heydt tests???

more tests:

RPI3 SD card 32GB samsung evo in SD card slot:
write : 17MB/s
read : 22MB/s

RPI2 SD card 16GB sandisk ultra (red) in SD card slot:
write : 13MB/s
read : 22MB/s

RPI2 SD card bootcode.bin, USB stick:
write : 11MB/s
read : 20MB/s

__________________________________________
i could not stop,
here a test for sync; dd ... with different file size showing
very questionable MB/s numbers.
pi@RPI3:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=1024
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 31.2519 s, 16.8 MB/s
pi@RPI3:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=512
512+0 records in
512+0 records out
262144000 bytes (262 MB) copied, 14.604 s, 18.0 MB/s
pi@RPI3:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=256
256+0 records in
256+0 records out
131072000 bytes (131 MB) copied, 3.902 s, 33.6 MB/s
pi@RPI3:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=128
128+0 records in
128+0 records out
65536000 bytes (66 MB) copied, 0.297222 s, 220 MB/s
pi@RPI3:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=64
64+0 records in
64+0 records out
32768000 bytes (33 MB) copied, 0.148824 s, 220 MB/s
pi@RPI3:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=32
32+0 records in
32+0 records out
16384000 bytes (16 MB) copied, 0.0978845 s, 167 MB/s
pi@RPI3:~ $

so the the file size is the problem.

while a test about the sync:
again write test with your 3.2GB file (each 2 times):
2 sync after dd 15MB/s
1 sync prior dd 13MB/s
0 sync with dd 14MB/s
@W. H. Heydt, pls think again, the sync's after the dd might do a job, like finalizing the writing to disk,
but can never influence / correct the ?wrong? dd MB/s speed reporting..


is it worth to test a USB3 stick ( on the USB2 port of RPI3 )?

did i proof that a USB card reader ( with same SD card / same OS ) not slow down read/write speed?