Skip to content
Chenming Zhang edited this page Feb 24, 2021 · 1 revision

1. disable internal wifi on boot 2017-06-15 10:35

Just put these to the file /etc/modprobe.d/raspi-blacklist.conf

 blacklist brcmfmac
 blacklist brcmutil

2. use normal lan cable to connect laptop with rpi

This procedure is extremely important when using headless rpi as logger in the remote area. For the rpi, one needs to append a small text in the file /boot/cmdline.txt:

  ip=169.254.10.10

Note that there is a space between the new string and existing strings. by doing this, one always gets same ip address at eth0:

 pi@camellia:~ $ ifconfig
 eth0      Link encap:Ethernet  HWaddr b8:27:eb:83:c8:9d  
           inet addr:169.254.10.10  Bcast:169.254.255.255  Mask:255.255.0.0
           inet6 addr: fe80::ba27:ebff:fe83:c89d/64 Scope:Link
           UP BROADCAST MULTICAST  MTU:1500  Metric:1
           RX packets:70 errors:0 dropped:0 overruns:0 frame:0
           TX packets:132 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000 
           RX bytes:12403 (12.1 KiB)  TX bytes:22786 (22.2 KiB)

For the laptop, one needs to do assign a static ip address as rpi has done. my laptop with Debian does not come up with file /boot/cmdline.txt and so I choose to change file /etc/network/interfaces

 source /etc/network/interfaces.d/*
 
 # The loopback network interface
 auto lo
 iface lo inet loopback
 
 
 auto eth2
 iface eth2 inet static
     #your static IP
     #address 192.168.1.118  
     address 169.254.10.5
     #your gateway IP
     netmask 255.255.0.0
     #your network address "family"
     broadcast 169.254.255.255

now the system always get ip based on the static prescription.

3. connecting 10 hdmi cable for rpi camera2018-01-05 16:46

I wish to use 10m hdmi cable to work with pi camera using tindie flex cable to hdmi converter. it was found that 5m hdmi cable works perfectly fine while 10m would have strong noise. turns out, the noise could be reduced simply by shorten all the flex cable to 5cm. this suggests that high frequence data transimission does require proper cables.

4. list of apps to install for pi

apt-get install tmux mplayer tightvncserver rdesktop htop vim git ffmpeg vlc python-rpi.gpio ipython

5. change time zone

# dpkg-reconfigure tzdata

6. if arduino code is not correct, it may cause low power for rpi in the logger.

7. a powered arduino connecting a non-powered rpi through usb cable will let rpi powered up.

7. storing a raspberry pi image:

(a). use gparted to shrink the empty space

(b). use 
dd if=/dev/mmcblk0 of=/home/YOUR_USERNAME/Desktop/backup.img bs=1M count=2048 status=progress
sync

to save the file, the size is estimated to be 1M* 2048 for the case above.

when extracting the image to disk first

dd if=/home/YOUR_USERNAME/Desktop/backup.img of=/dev/sdc bs=1M status=progress
sync

and do not forget to use gparted to enlarge your space!

reference: https://www.raspberrypi.org/forums/viewtopic.php?f=26&t=5947&start=25 https://raspberrypi.stackexchange.com/questions/36456/how-to-shrink-an-image-file-after-allocating-full-space

8. use pi as a router:

put the below to /et/dhcpcd.conf, i think the server always need to determine their own IP in the first place

interface wlan0
    static ip_address=192.168.4.1/24

becareful that debian squeeze seems not having this TO180620

add the following to /etc/dnsmasq.conf

interface=wlan0      # Use the require wireless interface - usually wlan0
  dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h

try infinite if one does not want the ip to be expired then add the following to /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=hydrogeologger
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
wpa=2
wpa_passphrase=123456123
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

after that, uncomment in /etc/default/hostapd

DAEMON_CONF="/etc/hostapd/hostapd.conf"

finally, restart the services

sudo systemctl start hostapd
sudo systemctl start dnsmasq

the next is to forward the data to one port that is supposed to have internet eth0 here

/etc/sysctl.conf and uncomment this line:

net.ipv4.ip_forward=1

then run below two commands:

sudo iptables -t nat -A  POSTROUTING -o eth0 -j MASQUERADE
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

save the rules on boot by Edit /etc/rc.local and add this just above "exit 0" to install these rules on boot.

iptables-restore < /etc/iptables.ipv4.nat

now reboot reference: https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

9. change img file without burning it:

first find out the number of partitions in the file by:

$ /sbin/fdisk -l 2018-06_21_rpi3_stretch_hydrogeolog.img
Disk 2018-06_21_rpi3_stretch_hydrogeolog.img: 9.8 GiB, 10485760000 bytes, 20480000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc4b3f138

Device                                   Boot  Start      End  Sectors  Size Id Type
2018-06_21_rpi3_stretch_hydrogeolog.img1        8192   137215   129024   63M  c W95 FAT32 (LBA)
2018-06_21_rpi3_stretch_hydrogeolog.img2      **137216** 22067199 21929984 10.5G 83 Linux

so the start of the second partition is 137216*512=70254592

the way to mount it would be:

mount -o loop,offset=70254592 2018-06_21_rpi3_stretch_hydrogeolog.img /home/user/usb

Reference: https://unix.stackexchange.com/questions/82314/how-to-find-the-type-of-an-img-file-and-mount-it

10. create hash key for password

run the command below:

$ echo -n password | iconv -t utf16le | openssl md4
(stdin)= 8846f7eaee8fb117ad06bdd830b7586c

so that the password in /etc/wpa_supplicant/wpa_supplicant.conf can be written as:

ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
ap_scan=1
fast_reauth=1
network={
    ssid="eduroam"
    scan_ssid=1
    key_mgmt=WPA-EAP
    eap=PEAP
    phase2="auth=PAP auth=MSCHAPV2"
    identity="[email protected]"
    password=hash:abcde
}

TO201214 it is found that after upgrading from wpa_supplicant version 2.4 to 2.6 in stretch, the above mentioned script is not working anymore, particularly that system does not reconglise PAP authentication when running the program:

systemctl status [email protected]

This will be resolved by removing auth=PAP in the line phase2:

ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
ap_scan=1
fast_reauth=1
network={
    ssid="eduroam"
    scan_ssid=1
    key_mgmt=WPA-EAP
    eap=PEAP
    phase2="auth=MSCHAPV2"
    identity="[email protected]"
    password="password"
}

it is also found that after the upgrade it is worthy to enable wlan0 by:

systemctl enable [email protected]

10. password change does not affect direct ssh access after ssh-copy-id

11. change pi terminal keyboard layout from Britain to US

go to /etc/default/keyboard and change

12. TO190718 counter clockwise turning the lens on pi camera will reduce its focal length

13. TO201214 Installing linux headers in Raspbian.

When installing soft_uart it was asked to install linux headers. this could be done by running:

apt install raspberrypi-kernel-headers

The header file will be appeared in folder /usr/src

  1. check if pi is underpowered
pi@dp19_camera:~ $ vcgencmd get_throttled
throttled=0x0

so 0x0 means it is all good

always try to compare the directory name (ls /usr/src) with the acutal linux kernel (checked by running uname -a). if they are unmatched, just update the system up-to-date (apt update & apt upgrade)

Clone this wiki locally