Here is my presentation to the Raspberry Pi Introduction @ PiAndMore 10 (University Trier, 24.06.2017)
RPiEinführung_PiAndMore10.pdf (1,96 MB, PDF)
Videorecording of the talk can be found here
IT Systemelektroniker & Master of Science, IT Security, Networks, Embedded Systems, Docker Campus Ambassador and Raspberry Pi Geek
Computer Stuff
Here is my presentation to the Raspberry Pi Introduction @ PiAndMore 10 (University Trier, 24.06.2017)
RPiEinführung_PiAndMore10.pdf (1,96 MB, PDF)
Videorecording of the talk can be found here
I have been working with Docker and resin.io as well as resinOS for quite some time now and I am actively using those services actively for different projects: The possibility to just throw away a container and build it anew in record breaking time is just awesome and also the fact that I can now just ship images to some device, deploy it there - and it will just work. As some of you know, I am working as volunteer in different NPOs, i.e. the RepairCafé Trier in which I repair Computers and Mobile phones for free, the PiAndMore / CMD e.V. on which I teach interessted guys and gals about Raspberry Pi and Linux (and even did two presentations on resin.io and resinOS, both linked on this blog - and as video :)) - and also one other NPO which is trying to give information about Japanese Culture. For those events I already created an Tickting System called JCTixx, which uses QR Codes to sell and check tickets for those named festivals. However, I created the Scanner Hardware in 2010, just starting my second year in an Apprenticeship as IT Systemselectronics guy, without anything as a Raspberry Pi available. However, being a bit creative, I just took some old Linux routers, threw the good old OpenWRT on those and soldered directly to the its testpoints / CPU to get the GPIO pins I needed ;). That worked very well - however, nowadays, TLS 1.2 and such eat away those small MIPS cores - and I could - with a lot of work - just get them working with said crypto in 2015. However, being 7 years old now, I need new Scanners - and more flexible way of delivery software as well. So resinOS it is! 🙂
Full disclosure: As I am currently developing the Hardware for the Scanners and I am always looking for some Raspberry Pis and other hardware, I stumbled upon resin.ios #blog4swag program and decided to make this tutorial because of two reasons: 1.) I actually need an dockerized GUI for the scanners and therefore am working on a good solution to the problem - and as usually - I want my dear readers to get some interesting stuff to read. 2.) Maybe I can acquire some hardware support from the resin guys which then would help me out to get my NPO helped :). So in the end, everyone wins and no one dies - to cite Doctor Who :).
So, lets get started!
1.) Getting some GUI working at all
I saw some users experimenting with Docker and Chromium along the x86 systems - however, the first resin project I stumbled upon which really made me think about putting the GUI within a container, was resin.ios ElectronJS example. This thing really rocked, but I saw that I needed to work on something a bit easier which would just deploy some sort of GUI - and being as simple as it gets. So I started to look around and stumbled across different projects, namely
RPiBrowser-resin.io and resin-electron-app. Those two were a great starting point and using resin.ios ElectronJS example as well, I started hacking the code together, which I finally submitted to this Git Repo:
docker-raspbian_xinit. With the great help of Gergely Imreh from the resinIO Team (thanks a lot :)!) I got the project working and pushed it onto Docker Hub. To walk you through the Git Repo: I made two versions, one nailed to the release of the 26.04.2017 Raspbian and one made from the latest version. I basically grabbed resin.ios Raspbian from Docker Hub, injected the qemu files (which they did show in one tutorial) and used this as a starting point. It enables Docker Hub to build the Raspberry Pi Images, so that you can use them on your Pi.
If you want to build the docker-raspbian_xinit image yourself, you need to remove the RUN [ "cross-build-start" ] and RUN [ "cross-build-stop" ] command from the Dockerfile :).
The Dockerfile itself builds a basic system with xinit / xorg, alsa and even touchscreen support (xinput-calibrator). It generated german locales and a user called pi (which is both not needed, but I included it as matter of personal preference), copys the needed files and enables systemd. Systemd will start the xinit-docker.service which invokes the start.sh which does prepare the system, i.e. adds the container name to the /etc/hostname, so that sudo will work, activates its own SSH server on port 22, includes a touchscreen calibiration file - if available, creates a very needed config folder, removes files from old X11 sections, sets volume to 100% on speakers and phones and then starts the xinit process with the launch_app.sh :).
The launch_app.sh then works in the xinit context and does xinit specific stuff: It disables screen blanking, sets the keyboard to the created german locales (you can comment this out as well if you want or overwrite the file ;)) - then - finally - starts the matchbox-window-manager without titlebar, but WITH keyboard and mousesupport and launches....
... gedit.
Yeah. Right. I know that is a real disappointment. But I needed a small tool which would not add too much file size and show that keyboard and mouse are working - so I just went for gedit ^^'. Sorry if you were hoping to find something really awesome and cool at this place. But nonetheless, it works, and this image as well as the Git Files should serve as a starting point for your own Xinit adventure - so, thats the reason :).
After I got it finally working, I thought about my personal usecase: I will be using a lot of Python and thought about using Flask as a GUI. However, Flask is just a webframework and does not have the ability to shown something "GUI-like" - thus needing some kind of Webbrowser - and this part could be found in shape of pywebview. Pywebview just includes some website, app or similiar into a small GUI Frame with Webkit Browser in it. Cool! Exactly what I needed. However, I did not have time get to work on my own UI - and wanted to jumpstart the project by getting the Docker Container to work - so I decided to grab a cool small Flask Web GUI project and use this to showcase how easy it is to built a self-starting Docker Container GUI - on resinOS. And with that in mind, I went for the very cool helloflask Calculator by Grey Li.
2.) Getting a Flask GUI working - using 1. 😉
Ok, as soon as I got my Xinit project working, I decided to use this a base image, just overwriting changes in the system and injecting the files needed to run the pywebview'd Calculator.
With that in mind, the Dockerfile became quite small (you'll find the Source Files on Github and the Image on Docker Hub as well :))
FROM nmaas87/docker-raspbian_xinit:jessie-20170426
MAINTAINER Nico Maas <mail@nico-maas.de>
ENV DEBIAN_FRONTEND noninteractive
RUN [ "cross-build-start" ]
RUN apt-get update \
&& apt-get install -yq --no-install-recommends \
python3-pip python3-pyqt5 python-gi gir1.2-webkit-3.0=2.4.9-1~deb8u1+rpi1 gir1.2-javascriptcoregtk-3.0=2.4.9-1~deb8u1+rpi1 libjavascriptcoregtk-3.0-0=2.4.9-1~deb8u1+rpi1 libwebkitgtk-3.0-0=2.4.9-1~deb8u1+rpi1 \
&& apt-get autoremove -qqy \
&& apt-get autoclean -y \
&& apt-get clean && rm -rf /var/lib/apt/lists/* && mkdir /var/lib/apt/lists/partial \
&& pip3 install Flask pywebview \
&& mkdir /usr/src/app/templates /usr/src/app/static
# copy program
COPY src /usr/src/app
# start init system
ENV INITSYSTEM on
RUN [ "cross-build-end" ]
I just needed to include the cross-build-start and end for Docker Hub again, installed python3-pip and pyqt5 dependencies with webkit (in a special version, otherwise it did not work...) and then installed Flask and pywebview. I then proceded to inject the pywebview-erized Calculator:
def start_server():
app.run(host="0.0.0.0",port="80");
if __name__ == '__main__':
t = threading.Thread(target=start_server)
t.daemon = True
t.start()
webview.create_window("Calculator", "http://127.0.0.1:80/")
webview.toggle_fullscreen()
sys.exit()
I had to create a start_server function to let Flask run in its own thread while pywebview would show the GUI in fullscreen mode and connect to the Flask server.
As last step, I need to rewrite the launch_app.sh
#!/bin/bash # Disable DPMS / Screen blanking xset -dpms xset s off xset s noblank # Change Keyboard Layout from US to German setxkbmap de # Debug Tools #xinput --list #evtest # Start Window Manager sudo matchbox-window-manager -use_cursor yes -use_titlebar no & #sudo matchbox-window-manager -use_cursor no -use_titlebar no & # Start Payload App #gedit python3 /app/app.py
As seen, I only changed the "Start Payload App" line and now initialize Python 3 with the pywebview/Flask/Caculator app.
And thats it :).
To use this app with resinOS, just go to resinos.io, download the latest 2.0.3 release for the RPi, flash the image to your SD Card using i.e. etcher, boot your RPi and ssh to your system IP, using user root and port 22222. From then on, you can just run the app via
docker run --name pywebview --privileged --restart=unless-stopped nmaas87/docker-raspbian_pywebview:jessie-20170426
or you upload the Git src to the /mnt/data folder and build your own version of this pywebview using
docker build -t pywebview .
Please do NOT forget to comment out the RUN [ "cross-build-start" ] and RUN [ "cross-build-end" ] commands!
After that worked, you can start the app via
docker run --name pywebview --privileged --restart=unless-stopped pywebview
You can also use the app with resin.io by creating an resin.io account, a new RPi App, pushing either the latest or jessie-20170426 tag to resin - and it should built and work :). However, I am more a fan of the flexibility resinOS offers in terms of developing Docker Apps - so I decided to describe this way here.
And with that said, you can now starting working on your own GUI Apps - working in resinOS / resin.io on your RPi or similar device :)! Have fun - and if you'll excuse me, I now have 4 JCTixx Ticket Scanners to build ^^'.
My Docker 101 Workshop @ T3C Trier (Trier Tech Talk Conference) (29.04.2017, Hochschule Trier, https://t3c.uni-trier.de/).
Docker_T3C2017.pdf (0,74 MB, PDF).
Sourcecode / Example can be found on https://github.com/nmaas87/docker-demo
EDIT: This post is from 30.09.2013 and should be the "how to" to this post. However, I never released it for a now unknown reason. Because of the interest in this topic, I still will publish it today so that it can stand as some kind of documentation of what I did back then. However, I might not work anymore.
This is the latest Guide.
What are we doing here?
Building OpenWRT Trunk with the offical RPi 3.10 (next) Kernel.
Packages:
You can use some packages of the offical OpenWRT 12.09 Attitude Adjustment repo.
However, most kernel modules and stuff has to be built but yourself, as I
got no repo. Sorry!
sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip
cd ~
mkdir rpi_openwrt
cd rpi_openwrt
git clone git://git.openwrt.org/openwrt.git
cd openwrt
mkdir dl
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make prereq
cd /tmp
wget https://github.com/raspberrypi/linux/archive/rpi-3.10.y.tar.gz
tar xfvz rpi-3.10.y.tar.gz
mv linux-rpi-3.10.y linux-3.10.13
tar -cJvf linux-3.10.13.tar.xz linux-3.10.13/
mv linux-3.10.13.tar.xz ~/rpi_openwrt/openwrt/dl/
cd ~/rpi_openwrt/openwrt/target/linux/brcm2708/
mv patches-3.10 patches-3.10.bkp
mkdir patches-3.10
vi Makefile
cd ../generic/patches-3.10
rm 063-arm-fix-fiq-vivt.patch
rm 880-gateworks_system_controller.patch
#Make
cd ~/rpi_openwrt/openwrt/
make menuconfig # Choose BCM2708 Chipset, Raspberry Pi Board, Exit and Save
make target/linux/{clean,prepare} V=99 # does extract kernel and patch it
make kernel_oldconfig # builds some tools
make kernel_menuconfig # configures kernel
make menuconfig # to change RPi Patterns, i.e.:
make V=99 -j 3
Files are in ~/rpi_openwrt/openwrt/bin/brcm2708
( i.e. openwrt-brcm2708-sdcard-vfat-ext4.img )
New build:
make kernel_menuconfig
make menuconfig
make V=99 -j 3
I got following error on an really badly "injured" Ubuntu machine:
Failed to start reboot.target: Failed to activate service 'org.freedesktop.systemd1': timed out See system logs and 'systemctl status reboot.target' for details. Failed to talk to init daemon.
Rebooting was not possible anymore, due to the beauty of 2933 zombie processes - slowing down the machine to a crawl.
However, this neat issue provided the answer to STILL get it to reboot:
# Reboot sudo systemctl --force --force reboot # Shutdown sudo systemctl --force --force poweroff
"Cool", as Gregory House would say 😉
1.) Setup on Linux (Ubuntu)
sudo apt-get update sudo apt-get install -y android-tools-adb android-tools-fastboot
1b.) Setup on Windows
I recommend the Minimal ADB and fastboot Package by shimp208, which you can get from: https://forum.xda-developers.com/showthread.php?t=2317790.
After you've installed it, you should add the folder of the installation to your PATH Variable: Press WIN+X Key, choose System, Advanced Systemsettings, Advanced, Path Variables - or just press WIN+R and enter "C:\Windows\system32\rundll32.exe" sysdm.cpl,EditEnvironmentVariables- you will need to click on the entry Path in the User Variables, edit and then create a new entry by clicking on new. There, you'll need to enter the path to Minimal ADB and Fastboot, i.e. C:\Program Files (x86)\Minimal ADB and Fastboot, click ok and close everything. Now you can use adb and fastboot from CMD in every folder.
2) Using it!
ADB can be used to do almost anything with Android Devices - as long as Android Debugging is activated. Developer Mode is activated via Settings -> Status and clicking 7 times on "Build number". After that, the Developer Options are available in the Settingsmenu. In this menu, you need to activate Android Debugging and connect your Phone via USB to your PC. You can start i.e. the Android Shell by accessing your Terminal and starting adb shell
In the Android Shell, you can navigate the file system of your phone or change different settings, i.e. you can change the brightness of your screen via:
settings put system screen_brightness 200
There are a lot of settings you can change, some are listed here:
Settings System: https://developer.android.com/reference/android/provider/Settings.System.html
Settings Global: https://developer.android.com/reference/android/provider/Settings.Global.html
Settings Secure: https://developer.android.com/reference/android/provider/Settings.Secure.html
You can also get a list of your current settings with settings list [namespace], i.e.
settings list system
You can also reboot your phone if it is rooted, move files, edit them, delete them - everything you can do on a normal linux system.
Another useful adb commands are pull and push. With adb pull you can pull a file from your phone to your pc. And with adb push you can upload a file to your phone.
Also, you can adb install install apk files / apps or adb uninstall uninstall them.
Important for debugging is the access to the logcat daemon via adb logcat so you can see what happens on your phone. You can even filter for different apps, i.e. chromium: adb logcat -s chromium
There is a bunch of other goodies like forwarding socket connections or reverse sockets and backup / restore of apps - which you can find out by looking at the useful adb help output.
Fastboot is the last command I want to describe here. You can use adb to reboot your phone to bootloader (adb reboot bootloader) or recovery (adb reboot recovery). If your phone is rooted and you get it into the bootloader, you can access it via fastboot. This tool is vital to flashing new kernels, images, recoverys and other stuff if everything else fails. Knowing that it exists should be enough for the "normal status of operation" - but if something breaks - use it ;)!
The SSH config is a powerful tool to get "more" out of your normal SSH connection.
Just create an file called "config" in your .ssh folder and it will be used on a new SSH session.
Lets start with a simple example of how a connection configuration could look like:
Host myHost Hostname 1.2.3.4 IdentityFile ~/.ssh/myHostKey User myUser
With this code, an "ssh myHost" will try to connect to the host 1.2.3.4 - using the user myUser and the keyfile myHostKey. And with this - you can use multiple keys and users on the same host without too much trouble 🙂
Another example with different ssh port:
Host myHost2 Hostname myhost.com Port 3001 User anotheruser IdentityFile ~/.ssh/anotherKey
You can also just give your ssh connection another keyfile:
Host github.com IdentityFile ~/.ssh/github
Forward a local port from your remote pc to yours:
Host myHost_tunnel Hostname myhost.com IdentityFile ~/.ssh/myHostKey User myUser LocalForward 443 127.0.0.1:443
Or even use your remote host as HTTP proxy (binding on your local port 8888):
Host myHost_proxy Hostname myhost.com IdentityFile ~/.ssh/myHostKey User myUser DynamicForward 127.0.0.1:8888
And the ssh config is even able to do a lot more but ... you'll find that in the manpage of ssh 🙂
This Blog Post consists in huge parts of Daniel Hüskens awesome work, but I still had to rewrite it a bit as I tended to add some stuff on :).
1.) Download latest Git for Windows: https://git-for-windows.github.io/
2.) Install (Entires with * can be changed to your own liking, ** can be changed, but this setting is recommended)
3.) Configure
set HOME=%HOMEDRIVE%%HOMEPATH% in your Windows User Path Variables: Press WIN+X Key, choose System, Advanced Systemsettings, Advanced, Path Variables - or just press WIN+R and enter "C:\Windows\system32\rundll32.exe" sysdm.cpl,EditEnvironmentVariables- you will need to click on New, then create a new Variable HOME with the Value %HOMEDRIVE%%HOMEPATH%, click ok and close everything.mklink /D "C:\Users\YourName\.ssh" "D:\mySecretFolder\.ssh" The path D:\mySecretFolder\.ssh does have to exist before this action, .ssh in the YourName folder not :).4.) Create a key and test access to Github
ssh-keygen -t rsa -C "a good comment on what this key is for" -b 4096ssh -T git@github.com5.) Word of advice:
SSH can be a bit tricky, as it tends to only look for id_rsa named keys in your .ssh folder. So if you have multiple keys with different names chances are high that this won't work. However, you can get around that with entries in the user defined ssh config file (called "config" and placed in the .ssh folder of the user) to tell ssh which key to use with which ssh connection. I will add a post on that topic later and link it here.
EDIT: Here is the link
Infineon created the ARM Cortex M Series "XMC" in 2012 to give their users access to a rich portfolio of different AMR Cortex M0+ and M4 MCUs. These Microcontrollers, being supported by powerful peripherals had support for two different IDEs: Keils MDK and Infineons DAVE. While Keil is the definitive choice for most professionals (and expensive...), DAVE was an self-developed plug-and-play kind of programming tool, using Eclipse as framework. However, both tools were directed towards professional endusers and developers, while hobbyists and makers with less experience in ARM Cortex programming would have a sturdy learning curve. Seeing that, and the first tests of the fanproject XMC-to-Arduino - Infineon decided to create an own boards package for the Arduino IDE. And thats what finally arrived some days ago :)!
Here is the link with all information: https://www.infineon.com/cms/en/tools/landing/infineon-for-makers/#microcontroller-boards
And the Github Link: https://github.com/Infineon/XMC-for-Arduino
And now we start with installing this package and Arduino 🙂
0.) Download the Arduino IDE: https://www.arduino.cc/en/Main/Software
1.) After downloading, unpack or install the Software and start it.
2.) Go to File -> Preferences and click on the Button right at the End of "Additional Boards Manager URLs" to open the dialog.
3.) Enter the URL of the XMC Repository ( https://github.com/Infineon/Assets/releases/download/current/package_infineon_index.json ) into the dialog and save it by clicking on OK - also closing the Preferences Menu via OK.
4.) Goto Tools -> Board -> Boards Manager and search for XMC. Then install the XMC package:
5.) After installation, close the dialog and close Arduino.
6.) Download and install the Segger J-Link Software from this link: https://www.segger.com/downloads/jlink
7.) Start Arduino again, go to Tools -> Boards and chose your board, mine is the XMC2Go:
8.) Also chose the right port under Tools -> Port
9.) I started with a blink example which I choose from File -> Examples -> 01. Basics -> Blink
10.) Click on the Upload arrow just over the name of the Sketch "Blink".
11.) If you got an older XMC2Go module, Arduino / Segger J-Link will ask wheter it should update the Firmware on the XMC2Go. Confirm that.
12.) Arduino should successfully end the upload proccess and you' ll have your XMC2Go blinking 🙂
13.) Already done - that was easy, wasn't it :)?
As an additional feature I decided to throw in a short graphic of the different ports of the XMC2Go and the mapping between Arduino IDE and MCU:
While I am now hosting this blog for nearly 9 years - without any incident - problems tend to happen sooner or later. A lot of hassle and problems has been reduced due to the WordPress Auto Update system - so to update WordPress itself, as well as its plugins - and it works great. However, WordPress introduced - and enabled by default - a REST API - which has a great deal of security problems. And without me always checking each installed version - well, I did not know that... The REST API problems should be fixed by now, but - that came a bit too late for my blog. Nonetheless, I would recommend going to Jetpack -> Settings and disabling JSON API - especially if you're not using it... I learned it the hard way ^^'..
PS: If you disable it, WordPress.com won't be able to talk to your website anymore so... You're gonna have a bad time, if you need that :/. You'll need to decide for yourself...
Regards