Latest OS tested: Raspberry Pi OS Buster Lite 2021-05-07
If you burned the OS image successfully, you should see a folder named boot appear on your main computer. If it doesn't, try removing and reinserting the SD card. If it still doesn't, try burning the image again.
There are four text files we will create/edit in boot.
- userconf.txt - user account id and password
- wpa_supplicant.conf - wifi settings
- config.txt - global system settings
- ssh - an empty text file to enable ssh
We are going to edit these directly on the SD card before putting it in the Pi Zero. This way you can edit these files using your favorite text editor on your main computer. Try to avoid using a word processor though. A "text editor" edits text and nothing else, whereas a "word processor" allows for all kinds of formatting, like making text bold, inserting images, etc.
Create User Account and Password
As of the bullseye release of the Raspberry Pi OS, the default account with username pi and password raspberry has been removed. This blog post has more information.
To create a user account, a file named userconf.txt is created that contains the account username and encrypted password. The password must be encrypted, which can be a hassle. If you have access to a running Pi or other linux machine, can use the following:
pi@raspberrypi:~ $ echo "raspberry" | openssl passwd -6 -stdin $6$AAEwDli5NhfHfGpt$Wtvv7DiMGR8mtGn/rDlgn80.MYQ2.bGCBmWrULW75KyTsXNm1vFndSS8TLdlxWZbNMoEuWqlmIwr3f9grFMf5/
The resulting contents of the userconf.txt file would then look like:
pi:$6$AAEwDli5NhfHfGpt$Wtvv7DiMGR8mtGn/rDlgn80.MYQ2.bGCBmWrULW75KyTsXNm1vFndSS8TLdlxWZbNMoEuWqlmIwr3f9grFMf5/
That will create a user account with username pi and password raspberry.
Configure WiFi
The Pi Zero W has built in WiFi so nothing additional is required. WiFi is only supported on 2.4 GHz band. If you are using the original Pi Zero, you will need some form of WiFi Adapter and a way to connect it: cable or adapter.
The WiFi configuration file does not exist and needs to be created. The name of the file should be wpa_supplicant.conf and its contents will get copied to the system folder at boot time. It will then be deleted. So this a one time only process. If you want to try again, you have to recreate the file and reboot.
The contents of the file should be as shown below. Replace YOURSSID and YOURPASSWORD with whatever is used for your network setup.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=US network={ ssid="YOURSSID" psk="YOURPASSWORD" scan_ssid=1 }
Like this:
On the country= line, if not in the US, replace with code for your specific country.
Save file and move on to next step. (more details here)
Enable UART
The file called config.txt already exists, we are just going to edit its contents. We will add some text to the bottom to enable the UART on the GPIO header pins. This allows a USB console cable to be attached later for troubleshooting.
Open the file in a text editor and add the following text to the bottom.
# Enable UART enable_uart=1
Like this:
Save it and move on to next step. (more details here)
Add dtparam=uart0_console=on to bootfs/config.txt on latest Pi OS releases.
Enable SSH
SSH used to be enabled by default, but was then (Nov 2016) turned off by default. This was due to security concerns since the pi user id and password are well known. However, you'll likely want this enabled so you can remotely connect to the Pi Zero.
To do so, we simply create a file called ssh. This file does not exist and needs to be created. It can be empty. The system looks for it at boot time and will enable ssh if it is there. It is then deleted. So just create a new file and save it as ssh to the boot folder.
Final Check
After the above steps, you should have the following files on the SD card in the boot folder.
Safely remove the SD card from the main computer and install it in the Pi Zero.
Text editor powered by tinymce.