Monday, August 31, 2020

Microsoft Teams on Raspberry Pi: coming soon?!

 



During the "new normal" the education will be virtual, as it is for the most of white collar workers. Kids go to use their Tablets, Laptops and Smartphones to connect with their teachers and classmates using teams. For my kids this is a permanent switch between the Mac and the iPad. Depending on their class and the battery level :)

Since there are some interesting STEM classes, where the kids use a Raspberry Pi as Desktop PC. My Idea here is to use a Pi, stream the Video out to the TV and use a camera and BT Headsets - and run Teams on the Pi. Unfortunately there is no existing ARM Linux package from Microsoft. Every approach with an x86 emulator failed.

There is a Teams Linux ARM Repo from Microsoft but it does not have to much content.


While googling for a solution I realized that there is a punch of lads looking form ARM64 based Teams - unfortunately mostly for Windows on ARM. And it seems their voice is heard by the Tech Giant Microsoft. According to their uservoice forum for Team, a Microsoft Engineer gave some hope that there will be a Window on ARM Teams package.

Microsoft's user voice forum

I am full of hope, that this development will also bring us a Linux ARM64 Teams package. There are more request for Linux packages than for WoA. So... what do you think? Will 2020 bring us a ARM Teams on Linux?

Sunday, August 23, 2020

Back to School means back to Raspberry blog!

Soon the new school year will start and I have spent the last few days working on the kids' curriculum. What can I say, I am really jealous and would like to be 8 years old again myself. Besides the normal subjects there are several STEM courses where programming, robotics and design thinking spark curiosity and creativity. I think it's great that the focus is on integrating boys and girls equally into the STEM topics. I am especially pleased that a central part of the STEM courses is based on the Raspberry PI. 

Minecraft Coding Camp by kjarrett  (CC BY 2.0)


This is reason enough to reactivate this blog and document the projects of the kids here. In the last time of the blog it was very quiet here. That will change now, but I think there will be some topics that are broader than pure Raspberry Pi stuff from the past!


Topics for the next weeks will be:

  • Raspberry Pi Laptop
  • Raspberry Pi Robot
  • Raspberry Pi Minecraft (or other gaming)
  • other stuff for sure
I am not sure if i have enough Raspberries here but anyway we need some displays, cameras, cases, and lot of other cool stuff. Guess someone will be on a shopping spree next days!



Thursday, June 23, 2016

Configure your Raspberry Pi without Keyboard and Display

 As an intensive Raspberry Pi user you have an image with a suitable OS just in case. For example, my images are all preconfigured for my private networks and I just have to copy them to an SD card and put them into the Raspberry. Then I can start right away - with whatever. The configuration of a new Rasbian can usually be done by bringing the small single board computer with a network cable into the LAN.


But there are circumstances where these approaches don't help and the circumstances don't allow you to connect the Raspberry to the network via the network cable and only WLAN is available. There is an easy way to do this configuration on a laptop directly after copying the Raspbian image to the SD card. I describe the steps for Windows, Linux and (soon) OSX.

I refer here to the standard Rasbian, the Howto does NOT work with Raspbian lite. (Stand 2016-05-27-raspbian-jessie-lite.img)

The image is downloaded from https://www.raspberrypi.org/downloads/raspbian/.

I refer here to the standard Rasbian image, the Howto does NOT work with the Raspbian lite image. (Stand 2016-05-27-raspbian-jessie-lite.img)

Initial configuration using Windows

Copy the downloaded image to the SD Card using WinDiskImager32 


Then a part (one of two partitions) of the copied image is visible in Windows Explorer.



A new file called wpa_supplicant.conf is created in this area. The following information will be added to this file (I like to use Notepad++ or Textpad for editing) 

update_config=1
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

network={
   &nbsp ssid="SSID"
    psk="Passwort"
}


Once the file is saved it can be used in the Raspberry. When the Raspberry is started, it gets an IP address from the WLAN which can be used to access the Raspberry. Most routers or access points have a web frontend which can be used to find out the IP address of the Raspberry. If this is not possible, a network scanner will help. Scanning the whole network is not (that easy) possible with Windows onboard tools. On iOS and Android Smartphones I have Fing for this.




Initial configuration using Windows

Under Linux you can copy the image with the dd command to the SD card. First you have to check the device name of the SD card under Linux. Before the card is inserted the mounted storage devices are listed. This is done with the command: 

df -h


Then the SD card is inserted and the command 

df -h


is executed again. The return should contain

/dev/mmcblk0p1


or

/dev/sdd1

I will use the mmcblk0p1 in this case. Afterwards the device is unmounted with umount. If there are several partitions on the SD card (recognizable by mmcblk0p2, mmcblk0p3, ...), all of them have to be unmounted.

Afterwards the image can be copied to the SD card. It is important that the image is copied to the SD card and not to a partition. Therefore the name to copy to is /dev/mmcblk0 or /dev/sdd and not /dev/mmcblk0p1 or /dev/sdd1.

The command to copy is:

dd bs=4M if=2016-05-27-raspbian-jessie.img of=/dev/mmcblk0


Of course you can also copy with your preferred GUI on a current Ubuntu (16.x). This is quite easy with the usb-imagewriter. The usb-imagewriter must be installed.

After the card has been written, the SD card must be remounted. The easiest way is to remove the card for a short time and plug it in again. 


df -h


With you can see that the card has two partitions. One partition is called /dev/mmcblk0p1 and the other /dev/mmcblk0p2. Here the smaller partition with a size of about 50 to 100MB is interesting. On this partition we will copy the WLAN information, which will be moved to the right place later on the first start of Raspbian in Raspberry.

In the terminal I open the file wpa_supplicant.conf with the command: 

sudo wpa_passphrase testwifi testpassword >> /dev/ mmcblk0p1/wpa_supplicant.conf


and all information for the WIFI configuration needs to be inserted with the following structure:

update_config=1
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
    ssid="testwifi"
    #psk="testpassword"
    psk=d28f6e7bcc45536a1930c0010f1d8a8e16c5dc154cc1309ae97859f2586924df
}

In order to connect to the Raspberry later, the IP address must be obtained. If the MAC address (or the manufacturer code) is known, the Raspberry is started and after a few moments scanned for the Raspberry with nMap. The manufacturer code (called OUI) can be found at http://aruljohn.com/mac.pl. Click on vendor lookup in the input mask and enter the manufacturer of the map.


The MAC address part 80:F1:02 is here exemplary for my Edimax WIFI USB adapter. 

nmap -sP 192.168.50.0/24 | awk '/^Nmap/{ip=$NF}/80:F1:02/{print ip}'


Now you known everything to connect to your Raspberry with SSH. Have fun :)

Saturday, June 4, 2016

Configure WIFI on Raspbian before the first boot

Usually when I prepare a Raspberry for a new project or just want set up a new operation system I configured the network with attached screen and keyboard. Sometimes this is not possible and the WIFI needs to be configured before the first boot of the Pi.

The actual Raspbian distribution Jessie released on May 27 216 (NOT the lite version) or newer brings a cool feature to preconfigure the WIFI settings. A keyboard and a screen aren't necessary to bring a Raspberry Pi with Raspbian to life.

Configuration on Windows

  1. download the Raspbian image on RapsberryPi.org and extract it
  2. if you don't have download the Win32DiskImager to copy the image to the SD card
  3. insert the SD card in your card reader (micro SD cards with adapter, start the Win32Diskimager (it will ask to run as Administrator), and select the extracted image file (from 1)
  4. click "Write" to start the transfer of the image to the SD card 
  5. when the process is finished successfully, you should see a part of the SD card in Windows Explorer
  6. right click into the SD card folder and create a new text-file with the name wpa_supplicant.conf
  7. open the file (if possible with Textpad or Notepad++) copy the following text into the file, ensure the bold parts are changed to your WIFI, the quote marks are necessary

    update_config=1
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    network={
        ssid="testwifi"
        psk="testpassword"   
    }

  8. save the file, move the SD card from your computer to the Raspberry and start it 
During the first boot of Raspbian, the file wpa_supplicant.conf will be moved into the folder /etc/wpa_supplicant/ for future starts the WIFI credentials will be in the right place and the Raspberry should be able to connect to the WIFI. The file will be not longer accessible under Windows. 

Configuration on Linux

  1.  download the Raspbian image on RapsberryPi.org and extract it
  2. before inserting the SD card, check the attached devices with this command:

    df -h

  3. then insert the SD card and repeat the command after a few seconds

    df -h

    in the output you should find a line like

    /dev/mmcblk0p1

    or

    /dev/sdd1

    okay in this example I will use "mmcblk0p1".
  4. With the command:

    mount

    you need to check if the SD card is mounted somewhere. If so, unmount the SD card with

    sudo umount /mnt/sdcrd

  5. Because df shows the partition and we want to copy the image file to the device, the name of the device in the copy command will be /dev/mmcblk0 or /dev/ssd 
  6. when the device name of the SD card is known, the image file can be copied there. the command is:

    dd bs=4M if=2016-05-27-raspbian-jessie.img of=/dev/mmcblk0
  7. after the successful copy to the SD card, the card can be removed and reinserted. There will be a check for the partitions again

    df -h

    in the output you should find again the same /dev/mmcblk0p1device with the command

    mount

    you will see the mountpoint of the SD card (in this example should be /mnt/sdcrd) 
  8. in this folder should be files like

    bcm2708-rpi-b.dtb
    bcm2708-rpi-b-plus.dtb
    bcm2708-rpi-cm.dtb
    bcm2708-rpi-2-b.dtb
    bcm2708-rpi-3-b.dtb
    bootcode.bin
    cmdline.txt
    config.txt
    ...
  9. with the command (change in the command mywifi to your SSID and mypassword to the password of your WIFI)

    sudo wpa_passphrase mywifi mypassword >> mnt/sdcrd/wpa_supplicant.conf

    you will create a file wpa_supplicant.conf in this folder
  10. now the SD card can be unmounted

    sudo umount /mnt/sdcrd

    the card can be removed and inserted in the Raspberry. 
While starting the Raspberry the first time, the file wpa_supplicant.conf will be moved to it's usual location in /etc/wpa_supplicant. The Pi will connect with the configured WIFI during boot and you can use SSH to connect to the Raspberry. The default login is
username: pi
password: raspberry

Wednesday, February 10, 2016

key based, password free SSH connection to your Raspberry

If the Raspberry will be only accessed remote without a GUI, normally SSH is the tool of choice. By default the user will use the login name and the password to connect to the Pi. While in Unix, Linux and OSX the user can connect with default tools under Windows putty will do the job.
Putty can be downloaded form http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.

Generally there are some advantage of using key based SSH connections:
  • the password will not be transferred over the network (not even encrypted)
  • if your Raspberry is running online, you can reduce the probability of successful brute force attacks
  • there can be automated connections to the raspberry

Generating the Key

To generate a SSH Key with Windows, in the first step download the PuttyGen tool from Putty project site. Check if the key type is SSH-2 RSA and the numbers of bits for the key are t least 2048. Click Generate to start the generation of the Key.
After the key has been generated, the window looks like this, showing the public part of the key and the fingerprint.

If you want to add a comment for the key, it might be easier to know what the key was generated for. Additional the key can be protected with a password. In the case of automated connections to the Raspberry, if you set a password, this will be asked for every connection. In my idea it is not necessary for my use case. Okay now everything is done and the private key can be saved. If the key will only used from Windows with putty, just click save private key. The filename extension should be ppk. If you want to use the key on Linux systems (to connect to the Raspberry), you need to export the key as OpenSSH Key.
In the example the public key will not be saved, because the key will be afterwards inserted into the Raspberry configuration. Therefore, the PuttyGen window will not be closed at the moment.

configure the Raspberry for SSH keys

Assuming the Raspberry is running and connected to the network, you will use Putty under Windows to create a connection with your user name and password. In most cases this should be the default user pi and the password raspberry


After the successful log in (with Putty!) you create a folder for the public SSH Key. The command is:

mkdir -p ~/.ssh

Next you create the file authorized_keys, in which we store the public key. The full path to the file will be /home/pi/.ssh/authorized_keys. This location creates a connection with the user pi and the public key.

sudo nano ~/.ssh/authorized_keys

In PuttyGen, select and copy the key from the window below the line "Public key for pasting into OpenSSH authorized_keys file" and insert with a right click into the Putty window with the open editor. The inserted key should be only one! line. If not, something is wrong. Jump with the end key to the end of line and check if the last characters form the authorized_keys file are the same as in the window form PuttyGen.

In nano text editor, the files will be saved with the key combination CTRL X, then Y then Enter. After the file is saved, we will secure it with the following command. Copy, paste and execute it line by line.:

sudo chmod 644 ~/.ssh/authorized_keys
sudo chown pi:pi ~/.ssh/authorized_keys
sudo chmod 700 ~/.ssh

Now the public key is stored on the Raspberry and is connected to a specific user. In the next step, a few settings for the key based SSH connection need to be checked or changed. The config file will be opened for editing with this command:  

sudo nano /etc/ssh/sshd_config

The following settings should be in the file (in different places or different order). If necessary, remove the number sign on the begin of the line (#).

PermitRootLogin no
AllowUsers pi
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication yes
UsePAM no

If anything has been changed in the file, this will be saved with CTRL+X, then Y and then Enter. In the last step the SSH daemon will be restarted with this command:

sudo systemctl restart sshd

configure Putty for key based SSH connections

Now there is some configuration on the SSH Client Putty. Open a new Putty window:
  • Navigate in the Category tree to Connection -> Data and add under auto-login username your chosen user (here "pi")
  • now navigate to Connection->SSH->Auth and enter path and file name to the private key
  • as a last step navigate to Sessions and enter Host name or IP Address, chose a name for the session under Saved Sessions and click Save
For later connections open a Putty window, double click the saved session name and a connection to the Raspberry will be established. If the key based authentication was successful, the Putty window will look like this:


That's it, congratulations! You successfully created a private key, configured your Raspberry to use the public key for authentication and the Putty for establishing key based SSH connections. If this was helpful or you have an idea what I can improve, I would happy if you leave a comment.

Sunday, July 19, 2015

Raspberry Shairport speaker in IKEA bamboo box

Round about two years ago, I started to play around with Shairport on Raspberry. Over the time the solution become a great part to listen podcasts and Music in the house. Unfortunately, a Raspberry and an attached speaker wasn't looking nice. Stumbling over the IKEA hack web page the idea was born to put the Raspberry in one of the IKEA bamboo boxes I had at home.
 
Assembling the hardware
Setting up the software

In the end the result will look like this.

The project did not focus to high end HIFI and therefore I did not spend any time calculating a perfect speaker. The equipment for the speaker is very cheap to keep the budget at a lower level.

Assembling the hardware


What did I use
 All together I spend less than 60 or 70 Euros - well for this price you will find wireless speakers with Bluetooth... probably also with better audio quality. But of course you will not find a Airplay compatible speaker nor have the fun of tinkering the things.

The amp uses 12V, so the box will run on 12V power source. The source of the Raspberry Pi is 5V. To convert the 12V input voltage I removed all plastic parts and from the USB charger and soldered some wires on it.


Before assembling the raspberry and the speaker into the IKEA box, I soldered the resistors and the potentiometer to a stereo to mono converter. The layout should be as in this diagram:

After finalizing the electrical work, I need to macgyver the box. Honestly I think that I am not very skilled for wood work but luckily all of this would be covered in the IKEA Box and by a piece of fabric :) I finished the assembling after I completed the software configuration because until the completion of the network configuration a keyboard and display was necessary.






Setting up the software

As in the most of my project i have chosen Raspbian as operation system. It's a Raspberry specific Port of the always stable Debian. What we need more?
Download the latest version of Raspbian Jessie from the Raspberry Pi project site. In a first step I removed all the unnecessary packages:

sudo apt-get purge console-setup desktop.* desktop-base dillo gnome.* gsfonts gtk.* gvfs.* libgtk.* libqt.* libxcb.* libxfont.* libxt.* lightdm lxde.* lxpanel omxplayer openbox penguinspuzzle python-tk python3-tk shared-mime-info tcl.* x11.* xarchiver xauth xdg-.* xkb-data xinit xserver.* wolfram

Afterwards the network configuration. First the WIFI passphrase will be stored as hash value in the conf file:

sudo wpa_passphrase mywifi mypass>> /etc/wpa_supplicant/wpa_supplicant.conf

In the next step the WIFI adapter wlan0 will be configured as DHCP, which means that the Raspberry will get it's IP address from the router the config file should look like this:

sudo nano /etc/network/interfaces


auto lo
iface lo inet loopback
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "ssid"
wpa-psk "password"

The network configuration is complete and the interface can be restarted:

sudo ifdown wlan0 && sudo ifup wlan0

After a few seconds we check if the wifi interface has been connected to the Router and obtained a IP address:

sudo ifconfig

Next step was to update and upgrade the OS:

sudo apt-get -y update && sudo apt-get -y upgrade

After the successfull update a new firmware has been installed:

sudo rpi-update

Okay the OS is up to date, now we can install some necessary packages for Shairport:


apt-get install autoconf libtool libdaemon-dev libasound2-dev libpopt-dev avahi-daemon libavahi-client-dev git


The next step is to clone the Shairport sources from git

git clone https://github.com/mikebrady/shairport-sync.git

When it is done we change the directory

cd shairport-sync

an build the config files for the installation of Shairport

autoreconf –i –f

followed by a configure command with following options:

./configure --with-alsa --with-avahi --with-ssl=openssl

in the next step Shairport will be compiled from the cloned source

make

and finaly installed.

make install

For Raspian Jessie is a start up script nessesary, to ensure that Shairport will come up on boot. Create a new file with the following command

nano /etc/systemd/system/shairport-sync.service

and paste this contend (change the bold part for YOUR Shairport name):

[Unit]
Description=Shairport AirTunes receiver
After=sound.target
Requires=avahi-daemon.service
After=avahi-daemon.service
[Service]
Type=simple
ExecStart=/usr/local/bin/shairport-sync -a "MyShairport"
Restart=always
[Install]
WantedBy=multi-user.target

After saving the file, the script need to be added to systemd services:

systemctl enable shairport-sync.service

Done. Shairport can be started with the command:

systemctl start shairport-sync.service

to check if the start was successful:

systemctl status shairport-sync.service

The result should ne something like this.:

shairport-sync.service - Shairport AirTunes receiver
Loaded: loaded (/etc/systemd/system/shairport-sync.service; enabled)
Active: active (running) since Sun 2015-03-01 17:33:51 UTC; 3s ago
Main PID: 3040 (shairport-sync)
CGroup: /system.slice/shairport-sync.service
           ΓΆΓΆ3040 /usr/local/bin/shairport-sync -a MyShairport

Mar 01 17:33:51 spi03 systemd[1]: Started Shairport AirTunes receiver.
Mar 01 17:33:51 spi03 shairport-sync[3040]: startup

Okay now we do a reboot and check if the Raspberry will obtain a IP address and Shairport is starting. If so, after a few seconds the Shairport will be available as target in iOS.
As I mentioned before, the final assembling has been done after successful software configuration. The result is a low budget Airplay player in a nice box. :)

Sunday, September 28, 2014

Hostapd/ WIFI Timouts "rt2800usb_entry_txstatus_timeout"

During the last days, i had been disconnected from my hostapd based AP. Digging into it i found suspicious entries in the syslog.

tail -n 400 /var/log/syslog

similar like this:
Sep 27 14:55:33 Raspi kernel: [ 4916.133773] ieee80211 phy0: rt2800usb_entry_txstatus_timeout: Warning - TX status timeout for entry 14 in queue 2
Sep 27 14:55:33 Raspi kernel: [ 4916.432124] ieee80211 phy0: rt2800usb_txdone: Warning - Got TX status for an empty queue 2, dropping
Sep 27 14:55:37 Raspi kernel: [ 4920.459732] ieee80211 phy0: rt2800usb_txdone: Warning - Got TX status for an empty queue 2, dropping

The log file was full of them. Searching in Google, most hints focused the power management of USB WIFI adapters. I tried differed approaches, but in the end the successful hint was an additionally entry in the network configuration. Open this file:

nano /etc/network/interfaces

and add this line:

wireless-power off

Mostly this command was then recommended but in my case, with Raspbian Wheezy, it was not successful:

iwconfig wlan0 power off

The following command made me smile again:

/usr/sbin/ifplugd wlan0 --kill

Since this, timeouts on hostapd are history and the AP is running stable.