I have RaspberryPi 3B+. I read that there is a way to make my raspberry boot from USB by changing config.txt that will change the OTP. Is there a way to make my raspberry to boot from USB and only if there isn't USB connected or bootable it will try to boot from SD?
Is there a way to make my raspberry to boot from USB and only if there isn't USB connected or bootable it will try to boot from SD
Here you can find details about the Boot sequence of the Raspberry Pi. It is described in detail there but in short you will find, that the Raspberry Pi will allways first boot from the SD Card if one is inserted with at least containing the
So it is not possible what you want. As long as the RasPi finds a bootable SD Card, it will boot from it first.
One very very messy way to achieve part of this is to set the Pi into GPIO boot mode.
You would then have to work out how to strap the GPIO pins to decide to boot from the SD or USB - if the USB is not fitted then the SD card pin must be asserted to boot from that.
This will not help you boot from SD if the USB device is not bootable though...
It may be better to look towards using just the USB boot but have multiple OS partitions via PINN or similar - this gives you an optional manual start but more control along the lines of GRUB.