The Raspberry Pi is an excellent platform for starting to learn OpenCV and also doubles as an affordable and small device. Here is all the equipment that we recommend for this Raspberry Pi OpenCV tutorial. Raspberry Pi 1, 2, 3 or 4. Ethernet Cord or WiFi dongle (The Pi 3 and 4 has WiFi. Learn how to install Portainer to your Raspberry Pi. Portainer is a Docker management tool that makes managing your containers a breeze. Creating and maintaining your Docker containers becomes a simple task when using this web interface.
Earlier this week I set up .NET Core and Docker on a Raspberry Pi and found that I could run my podcast website quite easily on a Pi. Check that post out as there's a lot going on. I can test within a Linux Container and output the test results to the host and then open them in VS. I also explored a reasonably complex Dockerfile that is both multiarch and multistage. I can reliably build and test my website either inside a container or on the bare metal of Windows or Linux. Very fun.
As primarily a Windows developer I have lots of batch/cmd files like 'test.bat' or 'dockerbuild.bat.' They start as little throwaway bits of automation but as the project grows inevitably more complex.
I'm not interested in 'selling' anyone PowerShell. If you like bash, use bash, it's lovely, as are shell scripts. PowerShell is object-oriented in its pipeline, moving lists of real objects as standard output. They are different and most importantly, they can live together. Just like you might call Python scripts from bash, you can call PowerShell scripts from bash, or vice versa. Another tool in our toolkits.
Bash and shell scripts are SUPER powerful. It's a whole world. But it is text based (or json for some newer things) so you're often thinking about text more.
You can take it as far as you like. For some it's intuitive power, for others, it's baroque.
Point is, there's choice. Here's a nice article about PowerShell from the perspective of a Linux user. Can I install PowerShell on my Raspberry Pi (or any Linux machine) and use the same scripts in both places? YES.
For many years PowerShell was a Windows-only thing that was part of the closed Windows ecosystem. In fact, here's video of me nearly 12 years ago (I was working in banking) talking to Jeffrey Snover about PowerShell. Today, PowerShell is open source up at https://github.com/PowerShell with lots of docs and scripts, also open source. PowerShell is supported on Windows, Mac, and a half-dozen Linuxes. Sound familiar? That's because it's powered (ahem) by open source cross platform .NET Core. You can get PowerShell Core 6.0 here on any platform.
Don't want to install it? Start it up in Docker in seconds with
Sweet. How about Raspbian on my ARMv7 based Raspberry Pi? I was running Raspbian Jessie and PowerShell is supported on Raspbian Stretch (newer) so I upgraded from Jesse to Stretch (and tidied up and did the firmware while I'm at it) with:
Cool. Now I'm on Raspbian Stretch on my Raspberry Pi 3. Let's install PowerShell! These are just the most basic Getting Started instructions. Check out GitHub for advanced and detailed info if you have issues with prerequisites or paths.
NOTE: Here I'm getting PowerShell Core 6.0.2. Be sure to check the releases page for newer releases if you're reading this in the future. I've also used 6.1.0 (in preview) with success. The next 6.1 preview will upgrade to .NET Core 2.1. If you're just evaluating, get the latest preview as it'll have the most recent bug fixes.
Lovely.
GOTCHA: Because I upgraded from Jessie to Stretch, I ran into a bug where libssl1.0.0 is getting loaded over libssl1.0.2. This is a complex native issue with interaction between PowerShell and .NET Core 2.0 that's being fixed. Only upgraded machines like mind will it it, but it's easily fixed with sudo apt-get remove libssl1.0.0
Now this means my PowerShell build scripts can work on both Windows and Linux. This is a deeply trivial example (just one line) but note the 'shebang' at the top that lets Linux know what a *.ps1 file is for. That means I can keep using bash/zsh/fish on Raspbian, but still 'build.ps1' or 'test.ps1' on any platform.
Here's a few totally random but lovely PowerShell examples:
You can take PowerShell objects to and from Objects, Hashtables, JSON, etc.
Here's a nice one from MCPMag:
Or a one-liner if you want to be obnoxious.
Example: This won't work on Linux as it's using Windows specific AIPs, but if you've got PowerShell on your Windows machine, try out this one-liner for a cool demo:
iex (New-Object Net.WebClient).DownloadString('http://bit.ly/e0Mw9w')
Thoughts?
Sponsor: Check out JetBrains Rider: a cross-platform .NET IDE. Edit, refactor, test and debug ASP.NET, .NET Framework, .NET Core, Xamarin or Unity applications. Learn more and download a 30-day trial!
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
AboutNewsletter
Available on Raspberry Pi 2B v1.2, 3A+, 3B, 3B+, 4B, 400, Compute Module 3, Compute Module 3+ and Compute Module 4 only.
This page explains how to boot your Raspberry Pi from a USB mass storage device such as a flash drive or a USB hard disk. When attaching USB devices, particularly hard disks and SSDs, be mindful of their power requirements. If you wish to attach more than one SSD or hard disk to the Pi, this normally requires external power - either a powered hard disk enclosure, or a powered USB hub. Note that models prior to the Pi 4B have known issues which prevent booting with some USB devices.
Raspberry Pi 4B and Raspberry Pi 400
The Raspberry Pi Pi 400 and newer Raspberry Pi 4B boards support USB boot by default. On earlier Raspberry Pi 4B boards, or to select alternate boot modes, the bootloader must be updated.
Using Raspberry Pi Imager to update the bootloader (recommended)
Raspberry Pi Imager provides a GUI for updating the bootloader
- Download Raspberry Pi Imager
- Select a spare SD card. The contents will get overwritten!
- Launch
Raspberry Pi Imager
- Select
Misc utility images
underOperating System
- Select
Bootloader
- Select
USB
- Select Storage and then Write
Using raspi-config to update the bootloader from within Raspberry Pi OS
To change the boot-mode from within Raspberry Pi OS run raspi-config
- Run
sudo raspi-config
- Select
Advanced Options
- Select
Boot Order
- Select
USB
- Reboot
See also:-
- The bootloader configuration page for other boot configuration options
- The bootloader EEPROM page for more information
Compute Module 4
Please see the Flashing the Compute Module eMMC for bootloader update instructions.
Raspberry Pi 3B+
The Raspberry Pi 3B+ supports USB mass storage boot out of the box.
Raspberry Pi 2B v1.2, 3A+, 3B, Compute Module 3, 3+
On the Raspberry Pi 2B v1.2, 3A+, 3B, and Compute Module 3, 3+ you must first enable USB host boot mode. This is to allow USB mass storage boot, and network boot. Note that network boot is not supported on the Raspberry Pi 3A+.
To enable USB host boot mode, the Raspberry Pi needs to be booted from an SD card with a special option to set the USB host boot mode bit in the one-time programmable (OTP) memory. Once this bit has been set, the SD card is no longer required. Note that any change you make to the OTP is permanent and cannot be undone.
On the Raspberry Pi 3A+, setting the OTP bit to enable USB host boot mode will permanently prevent that Pi from booting in USB device mode.
You can use any SD card running Raspberry Pi OS to program the OTP bit.
Enable USB host boot mode with this code:
This adds program_usb_boot_mode=1
to the end of /boot/config.txt
.
Note that although the option is named program_usb_boot_mode
, it only enables USB host boot mode. USB device boot mode is only available on certain models of Raspberry Pi - see USB device boot mode.
The next step is to reboot the Raspberry Pi with sudo reboot
and check that the OTP has been programmed with:
Check that the output 0x3020000a
is shown. If it is not, then the OTP bit has not been successfully programmed. In this case, go through the programming procedure again. If the bit is still not set, this may indicate a fault in the Pi hardware itself.
If you wish, you can remove the program_usb_boot_mode
line from config.txt
, so that if you put the SD card into another Raspberry Pi, it won't program USB host boot mode. Make sure there is no blank line at the end of config.txt
.
You can now boot from a USB mass storage device in the same way as booting from an SD card - see the following section for further information.
Booting from the USB mass storage device
Docker In Raspberry Pi Raspberry Pi
The procedure is the same as for SD cards - simply image the USB storage device with the operating system image.
After preparing the storage device, connect the drive to the Raspberry Pi and power up the Pi, being aware of the extra USB power requirements of the external drive.After five to ten seconds, the Raspberry Pi should begin booting and show the rainbow splash screen on an attached display. Make sure that you do not have an SD card inserted in the Pi, since if you do, it will boot from that first.
See the bootmodes documentation for the boot sequence and alternative boot modes (network, USB device, GPIO or SD boot).
Known issues (not Pi 4B, CM4 and Pi 400)
Docker Raspberry Pi Zero
- The default timeout for checking bootable USB devices is 2 seconds. Some flash drives and hard disks power up too slowly. It is possible to extend this timeout to five seconds (add a new file
timeout
to the SD card), but note that some devices take even longer to respond. - Some flash drives have a very specific protocol requirement that is not handled by the bootcode and may thus be incompatible.
Docker In Raspberry Pi Spi
Special bootcode.bin-only boot mode (not Pi 4B, CM4 and Pi 400)
Docker In Raspberry Pi 4
If you are unable to use a particular USB device to boot your Raspberry Pi, an alternative for the Pi 2B v1.2, 3A+, 3B and 3B+ is to use the special bootcode.bin-only boot mode as described here. The Pi will still boot from the SD card, but bootcode.bin
is the only file read from it.