# # Check also Ubuntu.txt, unattended.sh... # ARMv6 not compatible with Ubuntu! Tip: Install everything using a Raspberry Pi 4, as long as you ensure everything installed is compatible with ARMv6 it should work on Raspberry Pi Zero (maybe do the first boot with a Zero, check the version of nomachine, etc.)... # Login pi raspberry # Warning: these defaults do not exist any more in Raspberry Pi OS Bullseye but can be preset at first startup by adding a file named userconf.txt and prepared by the following command in the boot partition, see http://rptl.io/newuser echo -n 'pi:' > userconf.txt ; echo 'raspberry' | openssl passwd -6 -stdin >> userconf.txt # Set/check keyboard, timezone, Wi-Fi country, hostname in Menu\Preferences\Raspberry Pi Configuration, CPU Usage Monitor in taskbar, show hidden files... # Links to be similar to standard Ubuntu... sudo ln -s /usr/bin/lxterminal /usr/bin/gnome-terminal sudo ln -s /usr/bin/pcmanfm /usr/bin/nautilus sudo ln -s /usr/bin/leafpad /usr/bin/gedit # If needed, increase swap memory #sudo apt install dphys-swapfile sudo nano /etc/dphys-swapfile CONF_SWAPSIZE=4096 # Various settings (enable SSH (can be also enabled at first startup by adding a file named ssh in the boot partition), enable camera, enable i2c, enable serial port, disable console on serial port, increase GPU memory (set Memory Split to at least 256?))... sudo raspi-config # or edit /boot/config.txt (on Ubuntu, might be /boot/firmware/config.txt...) for most of the settings (in [all] section unless otherwise specified, check also settings in included files...)... # Camera (see also https://raspberrypi.stackexchange.com/questions/37359/how-to-use-raspistill-on-ubuntu) start_x=1 #gpu_mem=128 gpu_mem=256 # For Startup Applications (gnome-session-properties) hdmi_force_hotplug=1 # might be necessary...? # Baudrate of 38400 (or 115200 for versions with Wi-Fi and Bluetooth?) if console enabled on serial port (check something similar to console=serial0,115200 in /boot/cmdline.txt and enable_uart=1 in /boot/config.txt (or check other txt files for Ubuntu...))... # rpi without Wi-Fi and Bluetooth: /dev/ttyAMA0 # pi0w, pi3, pi3+: see https://www.raspberrypi.org/documentation/configuration/uart.md, by default /dev/ttyS0 refers to the mini UART (with a baud rate depending on the processor clock, so the core frequency is automatically fixed to 250 MHz if serial port is enabled) with a console and /dev/ttyAMA0 refers to the PL011 UART connected to the BlueTooth, if needed disable BlueTooth by adding [pi3+] dtoverlay=pi3-disable-bt [pi3] dtoverlay=pi3-disable-bt [pi0w] dtoverlay=pi3-disable-bt # in /boot/config.txt and run sudo systemctl disable hciuart # I2C, in /boot/config.txt dtparam=i2c_arm=on # I2C1 might already have pull up resistors...? # If needed, change I2C bus 1 speed in /boot/config.txt (default is 100000?) dtparam=i2c1_baudrate=200000 # To set I2C bus 6 on GPIO22 and 23, in /boot/config.txt dtoverlay=i2c-gpio,bus=6,i2c_gpio_delay_us=1,i2c_gpio_sda=22,i2c_gpio_scl=23 # If sudo i2cdetect -y 6 slow, add 2K pull up resistors, need also to run (see https://www.raspberrypi.org/forums/viewtopic.php?t=248439)...? #raspi-gpio set 22-23 pu # On pi4, SPI0 with 2 CS (/dev/spidev0.0, /dev/spidev0.1) and SPI6 with 2 CS (/dev/spidev3.0, /dev/spidev3.1?), in /boot/config.txt (see e.g. dtoverlay -h spi3-2cs, limitations https://raspberrypi.stackexchange.com/questions/107357/enable-up-to-5-spi-on-raspberry-pi-4, also SPI1 does not seem to support all the clock modes)...? dtparam=spi=on #dtoverlay=spi0-cs,cs1_pin=40 # If needed to enable SPI4... #dtoverlay=spi3-2cs,cs0_pin=14,cs1_pin=15 #dtoverlay=spi4-2cs dtoverlay=spi6-2cs # Filters described on https://www.raspberrypi.org/documentation/configuration/config-txt/conditional.md do not work for pi4 (errors in dmesg if /boot/config.txt contains dtoverlay=pi3-disable-bt and hdmi_force_hotplug=1 even in filters?)...? # GPIO, (see e.g. http://codefoster.com/pi-basicgpio/) using e.g. sudo bash pinout gpio -v # Enable GPIO05 echo 5 > /sys/class/gpio/export # Digital input echo in > /sys/class/gpio/gpio5/direction cat /sys/class/gpio/gpio5/value # Digital output echo out > /sys/class/gpio/gpio5/direction echo 0 > /sys/class/gpio/gpio5/value echo 1 > /sys/class/gpio/gpio5/value # Shortcut... echo low > /sys/class/gpio/gpio5/direction echo high > /sys/class/gpio/gpio5/direction # PWM, max 3.3V...? sudo nano /boot/config.txt # Add in /boot/config.txt dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4 # Then, using e.g. sudo bash echo 0 > /sys/class/pwm/pwmchip0/export echo 1 > /sys/class/pwm/pwmchip0/export echo 20000000 > /sys/class/pwm/pwmchip0/pwm0/period echo 20000000 > /sys/class/pwm/pwmchip0/pwm1/period echo 1500000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle echo 1500000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable # Now it is possible to play with the duty_cycle... echo 1000000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle echo 2000000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle # Efficient software PWM and more: pigpio #GPIO 0 and 1 might not be always available, see http://abyz.me.uk/rpi/pigpio/, https://raspberrypi.stackexchange.com/questions/98321/pigpio-error-no-permission-to-update-gpio-again...->https://www.raspberrypi.org/forums/viewtopic.php?t=134990: sudo pigpiod -x 0x0FFFFFFF (for python programs)... # PWM input, PPM input: see https://www.ensta-bretagne.fr/lebars/Share/pipwmin.c, https://www.ensta-bretagne.fr/lebars/Share/pippmin.c # RDP server (does not work on pi3 with Ubuntu Mate, works well on pi4 with Raspbian Buster with and without screen but desktop is different from the screen, file and text copy OK but not folder copy, but some GUI apps such as Raspberry Pi Configuration do not work...) sudo apt install xrdp # NoMachine: # _ all: might have wrong keyboard layout, 720x480 resolution without screen but usable (can be changed as for Ubuntu), it has really better network performance...? # _ pi4 with Raspberry Pi OS Bullseye: normal desktop, works well without screen...? # _ pi4 with Raspbian Buster: creates a completely different desktop but works well without screen...? # _ pi0w with Raspbian Buster: only armv6hf version works, normal desktop, good network performance but takes lot of processor... # To stop and set to manual if it is too slow on pi0w sudo service nxserver stop sudo /etc/NX/nxserver --startmode manual #sudo service nxserver start #sudo /etc/NX/nxserver --startmode automatic # Might prompt to accept a license sudo apt-get install rpi-chromium-mods # Firefox #sudo apt-get install iceweasel sudo apt-get install firefox-esr # Upgrade Raspbian sudo apt-get dist-upgrade # Raspbian network profiles: check /etc/dhcpcd.conf, /etc/wpa_supplicant/wpa_supplicant.conf (possibly also /etc/network/interfaces, but might be overwritten) # To associate a specific IP configuration for each Wi-Fi network (last has probably the highest priority but depends also on security...?), add in /etc/dhcpcd.conf e.g. ssid Livebox-0334 ssid ROBOTICS ssid SFR-B8D688 ssid eduroam ssid SARDINE-UBNT static ip_address=192.168.0.150/24 #static routers=192.168.0.4 #static domain_name_servers=192.168.0.4 8.8.8.8 # and ensure /etc/wpa_supplicant/wpa_supplicant.conf has (also, can be preset at first startup by copying it in the boot partition...) ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=FR network={ ssid="Livebox-0334" key_mgmt=NONE } network={ ssid="ROBOTICS" key_mgmt=NONE #priority=100 } network={ ssid="SFR-B8D688" psk="XXXXXXXX" } network={ ssid="eduroam" key_mgmt=WPA-EAP eap=TTLS identity="login@ensta-bretagne.fr" password=hash:HHHHHHHH # HHHHHHHH is the output of: echo -n plaintext_password_here | iconv -t utf16le | openssl md4 phase2="autheap=MSCHAPV2" } network={ ssid="SARDINE-UBNT" key_mgmt=NONE } # Determine to which Wi-Fi wlan0 interface is currently connected iw wlan0 info # For preferred eth0 static IP address when there is a DHCP server...? # Bug: see https://github.com/NetworkConfiguration/dhcpcd/issues/47 , so probably avoid if the dhcpcd version (8.1.2-9.3.X?) is affected... interface eth0 inform 172.20.25.99/16 # OpenCV 4.2.0 (with contrib) for Raspbian Buster and Raspberry Pi Zero W, built with a Raspberry Pi 4 (check unattended.sh and Ubuntu.txt for the configuration used, build time of less than 2h): http://www.ensta-bretagne.fr/lebars/Share/OpenCV-4.2.0-pi.tar.gz, http://www.ensta-bretagne.fr/lebars/Share/OpenCV-4.2.0-pi-static.tar.gz # Disable touch screen sleep (see https://www.raspberrypi.org/forums/viewtopic.php?t=255163) sudo nano /etc/xdg/lxsession/LXDE-pi/autostart @xset s off @xset -dpms # Switch on the HDMI screen xset dpms force on # To disable HDMI edit /etc/rc.local and add at the bottom above exit 0... ? /usr/bin/tvservice -o # Shutdown button to GND maybe via 1K resistor (see https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README) sudo nano /boot/config.txt dtoverlay=gpio-shutdown,gpio_pin=25,active_low=1,gpio_pull=up # See https://box86.org/ to run x86/x86_64 programs... # Get info about hardware and software versions: https://raspberrypi.stackexchange.com/questions/85015/what-pi-model-os-version-is-installed/85016#85016 # ??? # rpiz Raspbian 2017: ssh -X marche pas si sudo (créer mot de passe root et voir trucs avec xauth?)? OLD Raspbian Buster Python 2.7.16, 3.7.3 cv3.2.0 c++/python/python3 # If needed,force load V4L2 Raspberry Pi camera support at boot sudo sh -c "echo bcm2835-v4l2 >> /etc/modules-load.d/modules.conf" # Check if should add in /etc/modules #i2c-bcm2835 #i2c-dev # and enable the kernel modules ‘i2c_bcm2835’ and ‘i2c_dev’ by commenting out that line in /etc/modprobe.d/raspi-blacklist.conf ? # Replaced by i2c-bcm2835...? i2c-bcm2708 # python 3.4 with OpenCV 3.2 # To rebuild... # If __init__.py missing... wget http://www.ensta-bretagne.fr/lebars/Share/cv2.cpython-34m-__init__.py sudo mkdir /usr/local/lib/python3.4/dist-packages/cv2 sudo mv cv2.cpython-34m-__init__.py /usr/local/lib/python3.4/dist-packages/cv2/__init__.py wget https://github.com/opencv/opencv/archive/3.2.0.zip unzip 3.2.0.zip mkdir build cd build cmake -D BUILD_opencv_python3=ON -D BUILD_SHARED_LIBS=OFF -D BUILD_WITH_DEBUG_INFO=OFF -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D BUILD_opencv_world=OFF -D WITH_CUDA=OFF ../opencv-3.2.0 make # ARMv6 sudo cp lib/python3/cv2.cpython-34m.so /usr/local/lib/python3.4/dist-packages/cv2/ #wget http://www.ensta-bretagne.fr/lebars/Share/cv2.cpython-34m.so #sudo cp cv2.cpython-34m.so /usr/local/lib/python3.4/dist-packages/cv2/ # If needed... sudo nano /etc/default/keyboard XKBLAYOUT=fr sudo dpkg-reconfigure tzdata # To test... #sudo dpkg-reconfigure keyboard-configuration #sudo dpkg-reconfigure locales #gparted from other Linux computer to resize... #sudo fdisk /dev/mmcblk0 ## p to see the current start of the main partition ## Delete the second partition (d, 2), then re-create it (n p 2) to create a new primary partition, next you need to enter the start of the old main partition and then the size (enter for complete SD card). The main partition on the Debian image from 2012-04-19 starts at 157696, but the start of your partition might be different. Check the p output, then write and exit (w). Reboot the system, then: #sudo resize2fs /dev/mmcblk0p2 #dd if=2016-03-18-raspbian-jessie.img of="\\.\PhysicalDrive9" bs=2M --progress