Options
All
  • Public
  • Public/Protected
  • All
Menu

one.raspberry

one.raspberry

Current workflow

  1. Copy the raspberry-identity.json you want to use in the root folder
  2. Adjust the "url" to the commServer you want to use in raspberry_pi_pairing_information.json
  3. Open raspberry_pi_pairing_information.json and use the same raspberry-identity.json to init the web view with the same identity.
  4. Call yarn start or node lib/replicant/index.js start -l -c raspberry-identity.json --pairing raspberry_pi_pairing_information.json if you want to adjust any CLI arguments
  5. After an additional device shows up under Connection myDevices and is green, a connection was established, and new data will be sent to the Webpage
  6. The restart works after this initial connection was successful

Current workflow using an image

  1. Download the image smiler-raspberry-v2.0.0.img from the mailbox-drive area "Freigegebene Datein".
  2. Follow the Writing to an image manual.
  3. After writing the image, mount it, or unplug and then replug it.
  4. Edit three files in the mounted boot/firmware folder.
    • 51-wlan-auto-connect-config.yaml
      • Replace 'SSID-NAME-HERE: with your WLAN name, e.g. 'TP-Link_754B'
      • Replace 'PASSWORD-HERE' with your WLAN password, e.g., '41393588'
    • raspberry_pi_pairing_information.json Ensure to set "url" to the comm server you want to use, e.g., "wss://comm.dev.refinio.one"
    • raspberry-identity.json has to be overwritten with your raspberry-identity-xxx.json.
  5. Unmount the microSD card and insert it in your Raspberry Pi, and you are good to go.

Install requirements on Raspberry Pi

  • Node.js v14.6.1 LTS and yarn
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
    source ~/.bashrc
    nvm install --lts
    npm i -g yarn
  • sudo apt install libudev-dev build-essential

Add HemoCue USB rules

You need to add the access rights for the HemoCue vendor to your udev rules.

Copy the 51-hemocue.rules file to /etc/udev/rules.d/ to allow HemoCue devices to access the USB interface.

Run on boot with systemd

sudo ln -s /home/ubuntu/one.raspberry/systemd/refinio-copy-image-configs.service /etc/systemd/system/refinio-copy-image-configs.service

Enable configuration via /boot/firmware files

sudo ln -s /home/ubuntu/one.raspberry/systemd/refinio-hemocue-replicant.service /etc/systemd/system/refinio-hemocue-replicant.service

see copy-image-configurations.sh for what it does.

Wifi

For all changes, you will need your Wifi ssid and psk

for example:

  • ssid: SSID-NAME-HERE
  • psk: PASSWORD-HERE

ubuntu-server

When the raspberry pi runs ubuntu-server, netplan is used to configure networks.

  1. Edit 51-wlan-auto-connect-config.yaml and replace SSID-NAME-HERE and PASSWORD-HERE with your ssid and password.
  2. sudo cp 51-wlan-auto-connect-config.yaml /etc/netplan/
  3. to apply it call sudo netplan apply or reboot

Raspberry OS

When the raspberry pi runs Raspberry OS, wpa_supplicant is used for network configuration.

  1. Open sudo vim /etc/wpa_supplicant/wpa_supplicant.conf
  2. And edit ssid and psk to the iPhone Hotspot values
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE

network={
        ssid="SSID-NAME-HERE"
        psk="PASSWORD-HERE"
        key_mgmt=WPA-PSK
}

Enable Raspberry PI to boot from USB ONLY Pi 3B

Raspberry OS

Follow these instructions

ubuntu-server

You will need this library.

sudo install libraspberrypi-bin

else you can follow the Raspberry OS instructions but instead of adding it to /boot/config you will need to add it to /boot/firmware/usercfg.txt or just use:

echo program_usb_boot_mode=1 | sudo tee -a /boot/firmware/usercfg.txt

afterward reboot sudo reboot

This will set a bit to 1 permanently, so you should remove the line afterward if you don't want to accidentally set the flag with images you might create from the current installation.

Raspberry Img handling

Before getting started with the creation of the img it needs to be prepared.

Make sure:

  • The correct contact object is in one.raspberry/contactObjects
  • It is imported in one.raspberry/src/replicant/SmilerAccessRightsManager.ts
  • The url in /boot/firmware/raspberry_raspberry_pi_pairing_information.json is wss://comm.smiler.one
  • The src is build yarn build
  • And finally to delete:
    • rm /home/ubuntu/one.raspberry/raspberry-identity.json
    • sudo rm /boot/firmware/raspberry-identity.json
    • sudo rm /home/ubuntu/one.raspberry/app-state.txt
    • sudo rm -rf /home/ubuntu/one.raspberry/OneDB
    • rm -rf /home/ubuntu/.ssh

Identifying the microSD card

Source

Find the name of the microSD card disk

sudo fdisk -l

Disk /dev/mmcblk0: 119,1 GiB, 127865454592 bytes, 249737216 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: 0xec116899

Device         Boot  Start       End   Sectors   Size Id Type
/dev/mmcblk0p1        8192    532479    524288   256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      532480 249737215 249204736 118,9G 83 Linux


Disk /dev/sda: 233,3 GiB, 250450280448 bytes, 489160704 sectors
Disk model:  SanDisk 3.2Gen1
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: 0x63d166f6

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 489158655 489156608 233,3G  7 HPFS/NTFS/exFAT

Disk /dev/mmcblk0: 29,8 GiB, 31954305024 bytes, 62410752 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: 0x4ec8ea53

For us, that is /dev/mmcblk0

Creating an image from a microSD card

Source

First, you should resize the partitions of the microSD you want to copy. Therefore, you need to put your raspberry microSD into a card reader and preferably resize it with gparted. gparted calls some functions to prevent data loss when resizing a partition.

To be on the save side, we resize the writable partition to 8000MiB, resulting in 7.81GiB.

To read only the needed parts do:

pi@raspberrypi:~/Downloads $ sudo fdisk -u -l /dev/mmcblk0
Disk /dev/mmcblk0: 29,8 GiB, 31954305024 bytes, 62410752 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: 0x4ec8ea53

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1 *      2048   526335   524288  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      526336 16910335 16384000  7,8G 83 Linux

To get the total byte count, multiply the Sectors by the Sector size 16384000 * 512 = 8388608000 bytes. (8000MiB) yes, that's what we resized the partition to excellent :) To speed up the copy, we will want to read in 4M blocks. We will need to know how many 4M blocks we want to read for the dd command. 1M is (1024 * 1024)bytes -> 4M is (4 * 1024 * 1024 bytes) = 4194304 bytes per block to read.

Now we divide the total bytes by the block size 8388608000 / 4194304 = 2000 blocks and add one block for good measure 2001.

This results in the following dd command:

sudo dd if=/dev/mmcblk0 of=/home/pi/Downloads/smiler-raspberry-v3.img bs=4M count=2001 status=progress

And you are done.

Writing to an image

Select the device (/dev/mmcblk0) and make sure it is unmounted, then write to it.

sudo dd if=/home/pi/Downloads/smiler-raspberry-v3.img of=/dev/mmcblk0 bs=4M status=progress

Optimize img size

we can use gzip to optimize the image size. This will shrink the img size from 7,8GiB to 1,6GiB :)

Creating an optimized image

sudo dd if=/dev/mmcblk0 bs=4M count=2001 | gzip -c > /home/pi/Downloads/smiler-raspberry-v3.0.2.img.gz

Writing an optimized image

gunzip -c /home/pi/Downloads/smiler-raspberry-v3.0.2.img.gz | sudo dd of=/dev/mmcblk0 bs=4M

Write an optimized img on macOS

Source Webpage

The r before the disk name sais it should write it raw. Also vor bs it needs to be a lower case m.

gunzip -c SMILER/smiler-raspberry-v3.0.4.img.gz | sudo dd of=/dev/rdisk4 bs=4m

FAQ

How to check if the Raspberry recognized the HemoCue?

Call sudo tail -f /var/log/syslog and plug the HemoCue in. You should see something similar to:

Oct 17 17:33:36 raspberrypi kernel: [  650.688797] usb 1-1.1: new high-speed USB device number 6 using xhci_hcd
Oct 17 17:33:37 raspberrypi kernel: [  650.819855] usb 1-1.1: New USB device found, idVendor=3785, idProduct=0006, bcdDevice= 0.01
Oct 17 17:33:37 raspberrypi kernel: [  650.819874] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Oct 17 17:33:37 raspberrypi kernel: [  650.819891] usb 1-1.1: Product: HemoCue WBCDiff Analyzer
Oct 17 17:33:37 raspberrypi kernel: [  650.819906] usb 1-1.1: Manufacturer: HemoCue AB
Oct 17 17:33:37 raspberrypi kernel: [  650.819921] usb 1-1.1: SerialNumber: 01910a00-530a-0000-0000-000000000000

If you see something longer like:

Oct 17 16:41:05 raspberrypi kernel: [ 9449.250996] usb 1-1.4: USB disconnect, device number 3
Oct 17 16:41:05 raspberrypi kernel: [ 9449.545425] usb 1-1.4: new high-speed USB device number 4 using xhci_hcd
Oct 17 16:41:06 raspberrypi kernel: [ 9449.645932] usb 1-1.4: Device not responding to setup address.
Oct 17 16:41:06 raspberrypi kernel: [ 9449.865697] usb 1-1.4: Device not responding to setup address.
Oct 17 16:41:06 raspberrypi kernel: [ 9450.085432] usb 1-1.4: device not accepting address 4, error -71
Oct 17 16:41:06 raspberrypi kernel: [ 9450.405439] usb 1-1.4: new high-speed USB device number 5 using xhci_hcd
Oct 17 16:41:22 raspberrypi kernel: [ 9465.865727] usb 1-1.4: new high-speed USB device number 6 using xhci_hcd
Oct 17 16:41:22 raspberrypi kernel: [ 9465.996723] usb 1-1.4: New USB device found, idVendor=3785, idProduct=0006, bcdDevice= 0.01
Oct 17 16:41:22 raspberrypi kernel: [ 9465.996742] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Oct 17 16:41:22 raspberrypi kernel: [ 9465.996758] usb 1-1.4: Product: HemoCue WBCDiff Analyzer
Oct 17 16:41:22 raspberrypi kernel: [ 9465.996773] usb 1-1.4: Manufacturer: HemoCue AB
Oct 17 16:41:22 raspberrypi kernel: [ 9465.996787] usb 1-1.4: SerialNumber: 01910a00-530a-0000-0000-000000000000
Oct 17 16:42:51 raspberrypi kernel: [ 9555.380618] usb 1-1.4: USB disconnect, device number 6
Oct 17 16:42:55 raspberrypi kernel: [ 9559.547280] usb 1-1.1: new high-speed USB device number 7 using xhci_hcd
Oct 17 16:42:56 raspberrypi kernel: [ 9559.678245] usb 1-1.1: New USB device found, idVendor=3785, idProduct=0006, bcdDevice= 0.01
Oct 17 16:42:56 raspberrypi kernel: [ 9559.678264] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Oct 17 16:42:56 raspberrypi kernel: [ 9559.678280] usb 1-1.1: Product: HemoCue WBCDiff Analyzer
Oct 17 16:42:56 raspberrypi kernel: [ 9559.678295] usb 1-1.1: Manufacturer: HemoCue AB
Oct 17 16:42:56 raspberrypi kernel: [ 9559.678309] usb 1-1.1: SerialNumber: 01910a00-530a-0000-0000-000000000000

Make sure you added the HemoCue USB rules see above.

yarn install fails because of install.sh fails

make sure you have the right lineendings e.g. overwrite them on ubuntu with:

sed 's/\r$//' install.sh > install-u.sh && mv install-u.sh install.sh

Recover password PI

Source

Add a 1 to the end of /boot/firmware/cmdline.txt and remove it again later. Press enter to get into the maintenance mode and then use passwd.

How to add an RTC module Raspbian

Source for raspbian. Source for ubuntu-server

  1. Update your system
sudo apt update
sudo apt upgrade
  1. Install the needed packages:

    • Raspbian: sudo apt-get install python-smbus i2c-tools
    • Ubuntu: sudo apt-get install i2c-tools python3-pip; sudo pip3 install smbus2
  2. Test if the installation was successful

    • sudo i2cdetect -y 1 will show a dump with one byte set to 68.
  3. Load kernel driver on boot

    • Raspbian: Add dtoverlay=i2c-rtc,ds3231 to /boot/config.txt then reboot.
    • Ubuntu: Add dtoverlay=i2c-rtc,ds3231 to /boot/firmware/usercfg.txt then reboot.
  4. Check if it was enabled

    • sudo i2cdetect -y 1 should show the same dump but with UU instead of 68.
  5. Remove fake-hwclock

sudo apt-get -y remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove
  1. Activate orginal hwclock

    • Comment the following lines in /lib/udev/hwclock-set
if [ -e /run/systemd/system ] ; then
    exit 0
fi
  1. Check time of the RTC module

    • sudo hwclock -D -r
  2. Update time of the RTC module

    • make sure your img is up-to-date then
    • sudo hwclock -w to write the time to the RTC module.

How to change the boot order on Raspbian and ubuntu

The boot order can be changed by editing the EEPROM. This provides an example, which is summarized below.

  • View the current config: sudo rpi-eeprom-config
  • Edit the config: sudo -E rpi-eeprom-config --edit
  • BOOT_ORDER=0xf14 means try usb boot first
  • BOOT_ORDER=0xf41means try microSD card first

Generated using TypeDoc