- Installing Raspbian to SD card
- Headless Setup
- Installing Wi-Fi
- Controlling LEDs
- Linux Kernel
- Installing Java
- Installing Eclipse
- Live Streaming Camera on Local Network
- Useful Scripts
- CPU Temperature
- Deprecated APT Key Storage
- References
Raspberry Pi
Unless otherwise stated, these notes relate to running Debian 8 (Jessie) on the Raspberry Pi.
Installing Raspbian to SD card
On macOS:
$ diskutil list
/dev/disk4 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *7.9 GB disk4
1: Windows_FAT_32 boot 58.7 MB disk4s1
2: Linux 7.8 GB disk4s2
In this case, the old Raspian boot volume is mounted, so unmount:
$ diskutil unmount /dev/disk4s1
Copy the image to the SD card using dd. The rdisk4 is a raw disk mode for
disk4 and results in faster transfers:
$ sudo dd if=./2022-01-28-raspios-bullseye-armhf-lite.img of=/dev/rdisk4 bs=1m
See
- http://rpf.io/configtxt
- https://raspberrypi.stackexchange.com/questions/4144/writing-img-file-to-sd-card-from-a-mac
-- Frank Dean - 24 Sep 2022
Headless Setup
Versions of Raspian prior to 12 (Bookworm), the process was simple. Since Bookworm, the process has become a little more complicated if you do not wish to use the Official Raspberry Pi Imager.
Raspian 11 (Bullseye)
An hard-wired ethernet connection is required to initially run the Rasperry Pi headless from first boot.
Enable SSH by mounting the SD card on computer and create a blank file on the
boot partition named ssh:
$ touch /Volumes/boot/ssh
Boot the device using the SD card.
Use your network adminstration tool to determine what IP address was assigned to the device.
You should then be able to login using the default username and password
pi/rasberrry. E.g.
$ ssh pi@192.168.1.1
You should then immediately change the password for the default user.
$ passwd
You can then run the raspi-config utility to make any preferred
configuration changes. E.g. setting up Wi-Fi.
-- Frank Dean - 24 Sep 2022
Raspbian 12 (Bookworm)
An initial default user with publicly known password is no longer created. The [Raspberry Pi Imager] is used to create an initial user and password, chosen by the end user.
As in Raspian 12 (Bullseye), enable SSH by mounting the SD card on computer
and create a blank file on the boot partition named ssh:
$ touch /Volumes/bootfs/ssh
Then create a userconf in the same partition which contains the user name
and encrypted password in the format $username:$encrypted_password. One way
of doing this without leaving the password exposed in the history file or
process stack:
$ echo -n 'USERNAME:' | tee /Volumes/bootfs/userconf
The following command will prompt you to enter and verify the password, then
append the encrypted password to userconf:
$ openssl passwd -6 | tee -a /Volumes/bootfs/userconf
See:
-- Frank Dean - 3 Apr 2021 -- Frank Dean - 12 May 2024
Installing Wi-Fi
This sub-section relates to runnning Raspian 10 (Buster) and 11 (Bullseye). See the previous section for setting up Wi-Fi with Raspian 12 (Bookworm).
You should be able to enable Wi-Fi just by configuring WPA
Supplicant. No entries are needed in
/etc/networking/interfaces.
See the Wireless CLI
Instructions.
It is easiest to use the raspi-config utiltity (as root) to setup Wi-Fi.
It should create a configuration file as follows:
$ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=$COUNTRY_CODE
network={
ssid="$SSID"
#psk="$PASSWORD_CLEAR_TEXT"
psk=$ENCODED_PASSWORD
}
The country code should have been added by raspi-config for more recent
Raspberry Pi models for 5GHz networking. If it needs correcting, edit the
file as follows using your favourite editor and replace $COUNTRY_CODE with
the appropriate
2 letter ISO 3166-1 code.
If you need to change the password, replace $SSID with the SSID of the
target Wi-Fi network.
$ sudo -v
$ wpa_passphrase $SSID | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf
wpa_passphrase will wait on a new line for password input. Type the
password for the SSID followed by the Return or Enter key.
Then edit the configuration file to remove any previous network entry for the
same SSID.
The first line of the configuration file configures wpa_supplicant
to create a Unix socket under /var/run/wpa_supplicant and allow
users belonging to the netdev group to run wpa_cli without being
root. The default user should belong to that group as shown with the
id command. If not, add the user to the group:
$ sudo adduser $USERNAME netdev
If the Wi-Fi network isn't working, examine the output of sudo journalctl -u
wpa_supplicant for any reported issues.
You can also check the status of wpa_supplicant with:
$ wpa_cli status
Which should have a wpa_state of COMPLETED and show the ip_address
provided by the Wi-Fi network.
If all else fails, examining the commands used in the raspi-config script may be useful.
-- Frank Dean - 12 May 2024
Listing Available SSIDs
$ sudo iwlist wlan0 scan | grep ESSID
-- Frank Dean - 19 Aug 2023
Controlling LEDs
The red LED can be turned on and off with the following commands:
# echo 1 >/sys/class/leds/led1/brightness
# echo 0 >/sys/class/leds/led1/brightness
Any value bigger than zero turns it on, zero turns it off.
After turning off the green LED (led0), it is necessary to re-enable the trigger for when the SD card is accessed.
# cat /sys/class/leds/led0/trigger
# echo 0 >/sys/class/leds/led0/brightness
# cat /sys/class/leds/led0/trigger
# echo 1 >/sys/class/leds/led0/brightness
# cat /sys/class/leds/led0/trigger
# echo mmc0 >/sys/class/leds/led0/trigger
# cat /sys/class/leds/led0/trigger
Linux Kernel
apt-cache show linux-image-rpi-rpfv states:
Description: This metapackage will pull in the raspbian kernel for the raspberry pi 1
based on the version currently reccomended by the raspberry pi foundation
(currently 3.18).
apt-cache show raspberrypi-bootloader states:
Description: Raspberry Pi bootloader
This package contains the Raspberry Pi bootloader (plus, temporarily, a
kernel).
and
$ dpkg --search /boot/kernel.img
raspberrypi-bootloader: /boot/kernel.img
$ dpkg --search /boot/kernel7.img
raspberrypi-bootloader: /boot/kernel7.img
This page suggests the kernel is updated as one of the Debian packages, which conflicts with the page suggesting use of rpi-update
Understanding kernels on the Raspberry Pi and Raspi-LTSP
explains there are two sources of kernels for the Raspberry Pi. 'foundation
kernels' and 'team kernels'. My guess is that rpi-update provides foundation
kernels, and the linux-image-rpi-rpfv package provides the team kernels,
even though the package description for linux-image-rpi-rpfv says
"reccomended[sic] by the raspberry pi foundation".
At the time of writing, the Raspbian Downloads page states that Raspian Jessie is kernel version 4.1.
apt-cache show linux-image-rpi-rpfv depends on
linux-image-3.18.0-trunk-rpi.
apt-cache show linux-image-3.18.0-trunk-rpi gives its version as
3.18.5-1~exp1+rpi19 and booting into that image uname -r gives
3.18.0-trunk-rpi
Booting kernel.img uname -r gives 4.1.17+.
So I guess rpi-update gets you the latest and greatest and the
linux-image-rpi-rpfv package gets you an older, but presumably stable kernel
and the foundation expect most people to use rpi-update, but ultimately it
will depend on what hardware support you need from the kernel.
Note also that rpi-update doesn't clean up the modules after itself. You will
need to manually delete (with care) the kernel modules installed under
/lib/modules/.
See also:
- https://github.com/raspberrypi
- http://elinux.org/RPi_Kernel_Compilation
- https://www.raspberrypi.org/forums/viewtopic.php?t=90289&p=632588
- https://www.raspberrypi.org/forums/viewtopic.php?p=456702
- https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=77214
- https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=57401
- https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=109453
Kernel Configuration
If you do not want to use the default kernel.img or kernel7.img, you need
to add some entries to
config.txt, e.g.:
kernel=vmlinuz-3.18.0-trunk-rpi
initramsfs initrd.img-3.18.0-trunk-rpi followkernel
Installing Java
$ sudo apt-get install oracle-java8-jdk
Installing Eclipse
$ sudo apt-get install eclipse eclipse-jdt
for C/C++
$ sudo apt-get install eclipse-cdt
Live Streaming Camera on Local Network
For releases prior to Raspian 12 (Bookworm) you may need to enable the camera
using the raspi-config utility. See:
- https://www.raspberrypi.com/documentation/accessories/camera.html
- https://www.raspberrypi.com/documentation/computers/camera_software.html#getting-started
Note that there is no security in this method. Anyone who can access the same network can view or capture the stream.
Install VLC on Raspberry Pi.
$ sudo apt-get install vlcCreate stream:
Bullseye:
$ raspivid -o - -t 0 -w 800 -h 600 -fps 12 | \ cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264Bookworm:
$ rpicam-vid --nopreview --timeout 0 --vflip --hflip --output - | cvlc -v stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264Open VLC on another device.
Choose
File > Open Network...from VLC menuEnter the URL as
rtsp://IP_ADDRESS_OF_PI:8554/Click
OpenThe Video should play. Sometimes it fails to connect and it is worth another try or so.
See https://raspberry-projects.com/pi/pi-hardware/raspberry-pi-camera/streaming-video-using-vlc-player
-- Frank Dean - 3 Apr 2021 -- Frank Dean - 12 May 2024
Useful Scripts
Take a still shot:
#!/bin/bash
# Bullseye
# $ raspistill --nopreview --rotation 180 -o ~/photos/img-$(date +"%F-%H%M").jpg
# Bookworm
$ rpicam-jpeg --nopreview --rotation 180 -o ~/photos/img-$(date +"%F-%H%M").jpg
Take a short video clip:
Install the gpac package which has the MP4Box utility.
Bullseye:
#!/bin/bash
set -e
FILENAME=~/photos/video-$(date +"%F-%H%M")
raspivid -w 800 -h 600 -fps 12 --timeout 10000 -o $FILENAME.h264
MP4Box -add $FILENAME.h264 $FILENAME.mp4
rm $FILENAME.h264
See raspicam for all options common to the camera utilities. Other options
to consider for video streaming:
-vf Flip image vertically
-hf Flip image horizontally
-ex night Exposure mode
Bookworm:
#!/bin/bash
set -e
FILENAME=~/photos/video-$(date +"%F-%H%M")
rpicam-vid --nopreview --timeout 10s --vflip --hflip --output $FILENAME.h264
MP4Box -add $FILENAME.h264 $FILENAME.mp4
rm $FILENAME.h264
-- Frank Dean - 26 Sep 2022 -- Frank Dean - 12 May 2024
CPU Temperature
$ vcgencmd measure_temp
-- Frank Dean - 10 Jun 2023
Deprecated APT Key Storage
When running apt-get update the following message may be displayed:
W: http://raspbian.raspberrypi.com/raspbian/dists/bookworm/InRelease: Key is
stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the
DEPRECATION section in apt-key(8) for details.
If so, the key needs to be exported to /etc/apt/trusted.gpg.d/ and removed
from /etc/apt/trusted.gpg.
Obtain the last 8 digits of the key's fingerprint:
$ KEY=$(apt-key list | grep -A 4 "trusted.gpg$" | awk '/[0-9A-F]+ [0-9A-F]+$/ { print $9$10;}') $ echo $KEYExport the key:
$ sudo apt-key export $KEY | sudo gpg --dearmor -o raspi.gpgBackup the key list:
$ cp /etc/apt/trusted.gpg trusted.gpg~Delete the exported key:
$ sudo apt-key del $KEYThe key should no longer be included in the list
$ apt-key listMove the exported key to it's new location:
$ sudo mv raspi.gpg /etc/apt/trusted.gpg.d/The key should now be included in the list again:
$ apt-key listWhen running
apt-get update, you should no longer see the deprecation warning:$ sudo apt-get update
-- Frank Dean - 11 Apr 2025
References
- https://blogs.oracle.com/hinkmond/entry/new_raspberry_pi_model_b
- http://www.raspberrypi.org/forums/viewtopic.php?f=34&t=20503
- http://raspberrypi.stackexchange.com/questions/19957/java-eclipse-configuration-for-raspberry-pi
- http://eclipsesource.com/blogs/2014/05/01/programming-the-pi-with-eclipse-and-java/
-- Frank Dean - 2 Mar 2015
Related Topics: DebianTips, LinuxDevelopment