- Mastering OpenCV 4
- Roy Shilkrot David Millán Escrivá
- 957字
- 2021-07-02 14:47:37
Configuring a new Raspberry Pi
The following steps are specific to Raspberry Pi, so if you are using a different embedded device or you want a different type of setup, search the web about how to set up your board. To set up an Raspberry Pi 1, 2, or 3 (including their variants such as Raspberry Pi Zero, Raspberry Pi 2B, 3B, and so on, and Raspberry Pi 1A+ if you plug in a USB Ethernet dongle), follow these steps:
- Get a fairly new, good quality micro-SD card of at least 8 GB. If you use a cheap micro-SD card or an old micro-SD card that you already used many times before and it has degraded in quality, it might not be reliable enough to boot the Raspberry Pi, so if you have trouble booting the Raspberry Pi, you should try a good quality Class 10 micro-SD card (such as SanDisk Ultra or better) that says it handles at least 45 Mbps or can handle 4K video.
- Download and burn the latest Raspbian IMG (not NOOBS) to the micro-SD card. Note that burning an IMG is different to simply copying the file to SD. Visit https://www.raspberrypi.org/documentation/installation/installing-images/ and follow the instructions for your desktop's OS to burn Raspbian to a micro-SD card. Be aware that you will lose any files that were previously on the card.
- Plug a USB keyboard, mouse, and HDMI display into the Raspberry Pi, so you can easily run some commands and see the output.
- Plug the Raspberry Pi into a 5V USB power supply with at least 1.5 A, ideally 2.5 A or higher. Computer USB ports aren't powerful enough.
- You should see many pages of text scrolling while it is booting up Raspbian Linux, then it should be ready after 1 or 2 minutes.
- If, after booting, it's just showing a black console screen with some text (such as if you downloaded Raspbian Lite), you are at the text-only login prompt. Log in by typing pi as the username and then hit Enter. Then, type raspberry as the password and hit Enter again.
- Or if it booted to the graphical display, click on the black Terminal icon at the top to open a shell (Command Prompt).
- Initialize some settings in your Raspberry Pi:
- Type sudo raspi-config and hit Enter (see the following screenshot).
- First, run Expand Filesystem and then finish and reboot your device, so the Raspberry Pi can use the whole micro-SD card.
- If you use a normal (US) keyboard, not a British keyboard, in Internationalization Options, change to Generic 104-key keyboard, Other, English (US), and then for the AltGr and similar questions, just hit Enter unless you are using a special keyboard.
- In Enable Camera, enable the Raspberry Pi Camera Module.
- In Overclock Options, set to Raspberry Pi 2 or similar to the device runs faster (but generates more heat).
- In Advanced Options, enable the SSH server.
- In Advanced Options, if you are using Raspberry Pi 2 or 3, change Memory Split to 256 MB so the GPU has plenty of RAM for video processing. For Raspberry Pi 1 or Zero, use 64 MB or the default.
- Finish, then reboot the device.
- (Optional): Delete Wolfram to save 600 MB of space on your SD card:
sudo apt-get purge -y wolfram-engine
It can be reinstalled using sudo apt-get install wolfram-engine.
To see the remaining space on your SD card, run df -h | head -2:

- Assuming you plugged the Raspberry Pi into your internet router, it should already have internet access. So, update your Raspberry Pi to the latest Raspberry Pi firmware, software locations, OS, and software. Warning: many Raspberry Pi tutorials say you should run sudo rpi-update; however, in recent years, it's no longer a good idea to run rpi-update since it can give you an unstable system or firmware. The following instructions will update your Raspberry Pi to have stable software and firmware (note that these commands might take up to one hour):
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo reboot
- Find the IP address of the device:
hostname -I
- Try accessing the device from your desktop. For example, assume the device's IP address is 192.168.2.101. Enter this on a Linux desktop:
ssh-X pi@192.168.2.101
- Or, do this on a Windows desktop:
- Download, install, and run PuTTY
- Then in PuTTY, connect to the IP address (192.168.2.101), as the user pi with the password raspberry
- Optionally, if you want your Command Prompt to be a different color than the commands and show the error value after each command, use this:
nano ~/.bashrc
- Add this line to the bottom:
PS1="[e[0;44m]u@h: w ($?) $[e[0m] "
- Save the file (hit Ctrl + X, then hit Y, and then hit Enter).
- Start using the new settings:
source ~/.bashrc
- To prevent the screensaver/screen blank power saving feature in Raspbian from turning off your screen on idle, use this:
sudo nano /etc/lightdm/lightdm.conf
- And follow these steps:
- Look for the line that says #xserver-command=X (jump to line 87 by pressing Alt + G and then typing 87 and hitting Enter).
- Change it to xserver-command=X -s 0 dpms.
- Save the file (hit Ctrl + X, then hit Y, then hit Enter).
- Finally, reboot the Raspberry Pi:
sudo reboot
You should be ready to start developing on the device now!
推薦閱讀
- 新編Visual Basic程序設計上機實驗教程
- Java逍遙游記
- 從零構建知識圖譜:技術、方法與案例
- Python for Secret Agents:Volume II
- Learning Neo4j 3.x(Second Edition)
- Nexus規模化Scrum框架
- 軟件工程
- Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
- Python Data Analysis Cookbook
- Mastering ROS for Robotics Programming
- Visual Basic程序設計
- 51單片機C語言開發教程
- Vue.js 2 Web Development Projects
- C語言程序設計實訓教程與水平考試指導
- RubyMotion iOS Develoment Essentials