Capturing and Decoding Lego Mindstorms EV3 Bluetooth Communication
The Lego Mindstorms EV3 robots can be controlled with an Android app (Lego Mindstorms Commander) communicating with the brick via Bluetooth. The command protocol is documented by Lego in the EV3 Communication Developer Kit and the commands themselves in the EV3 Firmware Developer Kit (get them from Mindstorms Downloads).
I wondered what exactly goes on and I decided to capture the communication and decode it, to learn both about Bluetooth and about the details of the EV3 protocol.
I succeeded and made a couple of useful tools along the way:
See also the previous post about sending data (EV3 commands) over USB.
Outline
- Enable Android Bluetooth logging
- Run the Commander app and exercise the robot a bit
- Transfer the log to a PC
- Extract the serial data (RFCOMM) from the Bluetooth dump
- Decode the EV3 protocol
- Disassemble the EV3 instructions
1. Enable Android Bluetooth Logging
- Open Settings
- In the System section, choose Developers (this needs to be enabled first by tapping Build number 7 times)
- Enable Bluetooth HCI Log
2. Run the Commander app and exercise the robot a bit
3. Transfer the log to a PC
On the phone/tablet:
- Open Settings
- System > Developers
- Disable Bluetooth HCI Log
Connect to the PC with a USB cable.
My older Android phone offered to mount its storage as a USB disk drive, but the newer one no longer has that option, offering MTP instead. I transfered the log file with a KDE tool:
$ kioclient cp 'mtp:/Xperia Z3/Interní úložiště/btsnoop_hci.log' .4. Extract the serial data (RFCOMM) from the Bluetooth dump
The tool I made for this is btsnoop-decode.rb.
I learned the bare minimum needed about Bluetooth so it is very likely the tool only works for this specific use case.
Originally I opened the btsnoop log with Wireshark and guessed my way through the BT protocol layers. In the end the RFCOMM length field was harder than usual to guess and half of my packets were wrong. So I resorted to finding the appropriate part of the Linux kernel source to find out the format.
5+6. Decode the EV3 protocol and dissassemble the EV3 instructions
The people of the ev3dev project have already produced a disassembler which we will use in the next step. But that one assumes you start with a program file (RBF).
Here we have a log containing not only the usual RBF instructions but also System Commands.
I made an ugly hack of the lmsdisasm tool and arrived at a version that disassembles the log produced by the RFCOMM extractor.
Play time
The above experiments enabled me to put together a little script that can control the robot from a Linux terminal, having it ride around and even speak a custom sound file: lethargic-ministers/lms.py.
MyGica T230C hacking
As DVB-T(1) is phased out in Germany soon, I got me a new DVB-T2 stick. The MyGica T230 is supported under Linux, and has a quite low price (~20€).
Instead of the expected T230, I received a T230C which has silently replaced the T230. The T230C is – although quite similar to the T230 – currently (Linux 4.10rc2) not supported by the mainline kernel.
Compared to the T230, the T230C uses the same Cypress FX2 CY7C68013A USB bridge chip, a Silabs Si2168-D60 demodulator (new revision) and a new tuner chip, Silabs Si2141-A10 (T230 uses a Si2157).
Beyond the bridge/RF chips, there is an I2C eeprom (FX2 firmware?), two LowPowerSemi adjustable, synchronous DC/DC buck converters (marking LPS A36j1, LP3202?), a 74ACT1G00 NAND gate (marking A00), two 24MHz oscillators and a bunch of passives.
Install openSUSE Tumbleweed + KDE on MacBook 2015
It is pretty easy to install openSUSE Linux on a MacBook as operating system. However there are some pitfalls, which can cause trouble. The article gives some hints about a dual boot setup with OS X 10.10 and at time of writing current openSUSE Tumbleweed 20170104 (oS TW) on a MacBookPro from early 2015. A recent Linux kernel, like in TW, is advisable as it provides better hardware support.
The LiveCD can be downloaded from www.opensuse.org and written with ImageWriter GUI to a USB stick ~1GB. I’ve choose the Live KDE one and it run well on a first test. During boot after the first sound and display light switches on hold Option/alt key and wait for the disk selection icon. Put the USB key with Linux in a USB port and wait until the removable media icon appears and select it for boot. For me all went fine. The internal display, sound, touchpad and keyboard where detected and worked well. After that test. It was a good time to backup all data from the internal flash drive. I wrote a compressed disk image to a stick using the unix dd command. With that image and the live media I was able to recover, in case anything went wrong. It is not easy to satisfy OS X for it’s journaled HFS and the introduced logical volume layout, which comes with a separate repair partition directly after the main OS partition. That combination is pretty fragile, but should not be touched. The rescue partition can be booted with the command key + r pressed. External tools failed for me. So I booted into rescue mode and took the OS X diskutil or it’s Disk Utility GUI counter part. The tool allows to split the disk into several partitions. The EFI and the rescue ones are hidden in the GUI. The newly created additional partitions can be formatted to exfat and later be modified for the Linux installation. One additional HFS partition was created for sharing data between OS X and Linux with the comfortable Unix attributes. The well know exfat used by many bigger USB sticks, is a possible option as well, but needs the exfat-kmp kernel module installed, which is not by default installed due to Microsofts patent license policy for the file system. In order to write to HFS from Linux, any HFS partition must have switched off the journal feature. This can be done inside the OS X Disk Utility GUI, by selecting the data partition and holding the alt key and searching in the menu for the disable journaling entry. After rebooting into the Live media, I clicked on the Install icon on the desktop background and started openSUSE’s Yast tool. Depending on the available space, it might be a good idea to disable the btrfs filesystem snapshot feature, as it can eat up lots of disk space during each update. An other pitfall is the boot stage. Select there secure GrubEFI mode, as Grub needs special handling for the required EFI boot process. That’s it. Finish install and you should be able to reboot into Linux with the alt key.
My MacBook has unfortunedly a defect. It’s Boot Manager is very slow. Erasing and reinstalling OS X did not fix that issue. To circumvent it, I need to reset NVRAM by pressing alt+cmd+r+p at boot start for around 14 second, until the display gets dark, hold alt on the soon comming next boot sound, select the EFI TW disk in Apple Boot Manager and can then fluently go through the boot process. Without that extra step, the keyboard and mouse might not respond in Linux at all, except the power button. Hot reboot from Linux works fine. OS X does a cold reboot and needs the extra sequence.
KDE’s Plasma needs some configuration to run properly on a high resolution display. Otherwise additional monitors can be connected and easily configured with the kscreen SystemSettings module. Hibernate works fine. Currently the notebooks SD slot is ignored and the facetime camera has no ready oS packages. Battery run time can be extended by spartan power consumption (less brightness, less USB devices and pulseaudio -k, check with powertop), but is not too far from OS X anyway.
KDE и перспективный формат FLIF

В номере №205 журнала Linux Format я писал о новом графическом формате FLIF (Free Lossless Image Format), который превосходит PNG и WebP по сжатию данных без потерь. В комплекте с исходным кодом FLIF (т.н. reference implementation) имеются библиотеки кодировщика и декодера, сам кодировщик, а также простейшее средство просмотра — консольная программа viewflif. С таким минимальным набором вполне можно работать, однако формат, по сути, в этом случае выполняет роль архиватора: ни листать, ни редактировать FLIF-файлы без предварительной конвертации нельзя. Правда, есть ещё набор консольных утилит ImageMagick, который с некоторых пор поддерживает формат FLIF. Приличных графических программ просмотра, которые были бы основаны на ImageMagick, в природе нет, к тому же, большинство готовых сборок ImageMagick собраны без поддержки FLIF и не могут его читать. Хотите поддержку — собирайте из исходного кода сами.
На этом фоне Qt FLIF Plugin оказался глотком свежего воздуха. Данная разработка сделана датским программистом Себастьяном Валем (Sebastian Wahl), который ведёт свой блог и увлекается алгоритмами сжатия изображений. Суть Qt FLIF Plugin проста: в вашем распоряжении появляется разделяемая библиотека libflif.so (не путать с одноимённой библиотекой из состава самого кодировщика FLIF!), которая может быть использована любыми Qt-приложениями, поддерживающими QImageIOPlugins, например Gwenview, Kolourpaint и многими другими. Автор плагина также написал свой собственный минималистичный просмотрщик графических файлов, вполне неплохой!
Итак, для сборки нам потребуется слегка подредактировать файл project.pro, добавив туда строку CONFIG += c++14:

Если этого не сделать, то проект просто не соберётся современными версиями GCC. Затем нужно убедиться в том, что заголовочные файлы FLIF лежат в нужном месте — между прочим, их нужно заранее вручную положить в /usr/include/FLIF:

Далее командуем make и ждём несколько секунд. Получившуюся библиотеку нужно проверить на успешную линковку с кодировщиком FLIF (дело в том, что плагин почему-то иногда не линкуется):

Дальше, нужно установить саму библиотеку, скопировать .desktop-файлы и зарегистрировать соответствующий тип файла для share MIME database. Следующие команды я выполнял из директории ~/qt_flif_plugin/configuraton:
sudo cp ../libflif.so /usr/lib64/qt5/plugins/imageformats/
sudo cp qimageioplugins/x-flif.desktop /usr/share/kservices5/qimageioplugins/
sudo cp imagethumbnail-flif.desktop /usr/share/kservices5/
sudo cp x-flif.xml /usr/share/mime/packages/
sudo /usr/bin/update-mime-database /usr/share/mime
Результат будет заметен сразу же. Во-первых, заработает генератор миниатюр в файловом менеджере Dolphin:

Во-вторых, можно будет смотреть FLIF-файлы в Gwenview, стандартной программе просмотра из набора KDE:

На данный момент можно использовать лишь версию Gwenview 16.08 или более старую, так как из-за этого коммита программа, начиная с версии 16.12, содержит другой механизм поддержки сторонних форматов. Но это уже вопрос к автор FLIF-плагина — надеюсь, он обновит свой код когда-нибудь. Меня же очень радует сжатие, которое обеспечивает FLIF. Только посмотрите:

How we run our OpenStack cloud
This post it to document how we setup cloud.suse.de which is one of our many internal SUSE OpenStack Cloud deployments for use by R&D.
In 2016-06 we started the deployment with SOC6 on 4 nodes. 1 controller and 3 compute nodes that also served for ceph (distributed storage) with their 2nd HDD. Since the nodes are from 2012 they only have 1gbit network and spinning disks. Thus ceph only delivers ~50 MB/s which is sufficient for many use cases.
We did not deploy that cloud with HA, even though our product supports it. The two main reasons for that are
- that it will use up two or three nodes instead of one for controller services, which is significant if you start out with only 4 (and grow to 6)
- that it increases the complexity of setup, operations and debugging and thus might lead to decreased availability of the cloud service
Then we have a limited supply of vlans even though technically they are just numbers between 1 and 4095, in SUSE we do allocations to be able to switch together networks from further away. So we could not use vlan mode in neutron if we want to allow software defined network (=SDN) (we did not in old.cloud.suse.de and I did not hear complaints, but now I see a lot of people using SDN)
So we went with ovs+vxlan +dvr (open vSwitch + Virtual eXtensible LAN + Distributed Virtual Router) because that allows VMs to remain reachable even when the controller node reboots.
But then I found that they cannot use DNS during that time, because distributed virtual DNS was not yet implemented. And ovs has some annoying bugs are hard to debug and fix. So I built ugly workarounds that mostly hide^Wsolve the problems from our users’ point of view.
For the next cloud deployment, I will try to use linuxbridge+vlan or linuxbridge+vxlan mode.
And the uptime is pretty good. But it could be better with proper monitoring.
Because we needed to redeploy multiple times before we got all the details right and to document the setup, we scripted most of the deployment with qa_crowbarsetup (which is part of our CI) and extra files in https://github.com/SUSE-Cloud/automation/tree/production/scripts/productioncloud. The only part not in there are the passwords.
We use proper SSL certs from our internal SUSE CA.
For that we needed to install that root CA on all involved nodes.
We use kvm, because it is the most advanced and stable of the supported hypervisors. Xen might be a possible 2nd choice. We use two custom kvm patches to fix nested virt on our G3 Opteron CPUs.
Overall we use 3 vlans. One each for admin, public/floating, sdn/storage networks.
We increased the default /24 IP ranges because we needed more IPs in the fixed and public/floating networks
For authentication, we use our internal R&D LDAP server, but since it does not have information about user’s groups, I wrote a perl script to pull that information from the Novell/innerweb LDAP server and export it as json for use by the hybrid_json assignment backend I wrote.
In addition I wrote a cloud-stats.sh to email weekly reports about utilization of the cloud and another script to tell users about which instances they still have, but might have forgotten.
On the cloud user side, we and other people use one or more of
- Salt-cloud
- Nova boot
- salt-ssh
- terraform
- heat
to script instance setup and administration.
Overall we are now hosting 70 instance VMs on 5 compute nodes that together have cost us below 20000€
Modern CUDA + CuDNN Theano/Keras AMI on AWS
Wow, what a jargon-filled post title. Basically, we do a lot of our deep learning currently on the AWS EC2 cloud – but to use the GPU there with all the goodies (up to CuDNN that supports modern Theano’s batch normalization) is a surprisingly arduous process which you basically need to do manually, with a lot of trial and error and googling and hacking. This is awful, mind-boggling and I hate that everyone has to go through this. So, to fix this bad situation, I just released a community AMI that:
- …is based on Ubuntu 16.04 LTS (as opposed to 14.04)
- …comes with CUDA + CuDNN drivers and toolkit already set up to work on g2.2xlarge instances
- …has Theano and Keras preinstalled and preconfigured so that you can run the Keras ResNet model on a GPU right away (or anything else you desire)
To get started, just spin up a GPU (g2.2xlarge) instance from community AMI ami-f0bde196 (1604-cuda80-cudnn5110-theano-keras), ssh in as the ubuntu@ user and get going! No hassles. But of course, EC2 charges apply.
Edit (errata): Actually, there’s a bug – sorry about that! Out of the box, the nvidia kernel driver is not loaded properly on boot. I might update the AMI later, for now to fix it manually:
- Edit
/etc/modprobe.d/blacklist.conf(using for examplesudo nano) and append the lineblacklist nouveauto the end of that file - Run
sudo update-initramfs -u - Reboot. Now, everything should finally work.
This AMI was created like this:
- The stock Ubuntu 16.04 LTS AMI
- NVIDIA driver 367.57 (older drivers do not support CUDA 8.0, while this is the last driver version to support the K520 GRID GPU used in AWS)
- To make the driver setup go through, the trick to install
apt-get install linux-image-extra-`uname -r`per - CUDA 8.0 and CuDNN 8.0 set up from the official though unannounced NVIDIA Debian packages by replaying the nvidia-docker recipes
- bashrc modified to include cuda in the path
- Theano and Keras from latest Git as of writing this blogpost (feel free to git pull and reinstall), and some auxiliary python-related etc. packages
- Theano configured to use GPU and Keras configured to use Theano (and the “th” image dim ordering rather than “tf” – this is currently non-default in Keras!)
- Example Keras deep learning models, even an elephant.jpg! Just run
python resnet50.py - Exercise: Install TensorFlow on the system as well, release your own AMI and post its id in the comments!
- Tip: Use nvidia-docker based containers to package your deep learning software; combine it with docker-machine to easily provision GPU instances in AWS and execute your models as needed. Using this for development is a hassle, though.
Enjoy!
GNU Screen v.4.5.0
I’m proud to announce the release of GNU Screen v.4.5. This time it’s mostly a bugfix release. We added just one new feature: now it’s possible to specify logfile name by using parameter -L (default name stays screenlog.0). Myself also spent some time to make source code a bit cleaner.
As you probably noticed we were going to release 4.5 until Christmas. Unfortunately, we could not do it because of some internal GNU problems. I apologise for that.
As usual, we merged some community patches from our bug tracing system (small patches also were presented in IRC) and I would like to thank everyone who contribute to Screen and helps us to test development git-version!
For openSUSE users: I updated our devel-package already. It’s soon in factory and, as usual, after openQA routine new package will be available in Tumbleweed.
Happy Birthday ownCloud
I was there, sharing a room with Frank at the infamous Banana Bungalow. Epic times, I can tell you that - there was lots of rum, lots of rain and loads of good conversations and making new friends.





Since then, a lot has changed. But the people who started building a self-hosted, privacy protecting alternative in 2010 and 2011 are still on it! In 2011, a first meetup was held, and the 5 participants at that meetup recently got on stage at the Nextcloud conference to recall some good memories:
Of course, today we continue the work at Nextcloud, that just yesterday published its latest bugfix- and security update. It is great to see so many people have stuck with us for all these years - just this month, the KDE sysadmins migrated their ownCloud instance to Nextcloud!
We'll keep up the good work and you're welcome to join, either if you're looking for a job or just want to code. In both cases I can promise you: working with such a motivated, dedicated, professional team is just plain amazing.
I also published a blog on our Nextcloud blog about this milestone.
EDIT: By the way - there's a meetup tonight in C-Base, B'lin, 19:00 - would be fun to drink a beer on ownCloud's birthday and talk about the future! Join! It will be at least until 10 or so, so if you can't be there before then - still come! ;-)
openSUSE :: kernel of the day
Для тех, кто по той или иной причине хочет использовать последнюю версию ядра, но постоянно пересобирать ее вручную нет ни времени ни желания, openSUSE проект делает это за нас. Идея Kernel Of The Day – предоставить тестерам и прсто kernel инженерам последнюю git-версию ядра в виде RPM пакета. Это devel проект для ядра, в котором собираются версии для последующего тестирования и отправлки в tumbleweed. Делается это также с целью получить feedback от сообщества в виде bugreports или просто в ML/IRC.
Процесс полностью автоматизированный. Вы подключаете репозиторий и обновляетесь (каждый раз как пакет с новым ядром доступен для установки) как и обычно.
Версия unstable, поэтому имеет смысл не перезаписывать каждый раз старое ядро, а добавлять новое. Это не работает автоматически. Для этого надо отредактировать /etc/zypp/zypp.conf. Добавьте две строчки:
multiversion = provides:multiversion(kernel) multiversion.kernels = latest,running
Подробнее о multiple kernel.
Добавлю, что система ломатеся. Ломается достаточно часто. Только что, к примеру, у меня поломался dracut на ядре 4.9.0-2. Я не cмог загрузиться, т.к. он связан с LUKS, а я использую шифрование. Откатился назад на 4.8.13.
Интерсно, что именно сломано, почему и как починить. Это как раз ответ на вопрос “зачем мы этим занимаемся?”. Если бы этого не произошло, я вряд бы ли стал разбираться глубже в dracut. Проект таким способом предоставляет идеальную трейнинг площадку для энтузиастов, где обучение проходит в играющей форме 





