Category Archives: Uncategorized

Raspberry Pi 3, Firmware

/usr/bin/vcgencmd
$ vcgencmd get_config int
$ vcgencmd version
$ vcgencmd codec_enabled { H264, MPG2, WVC1, MPG4, MJPG, WMV9 }

RPI vcgencmd usage
Raspberry Pi: Systeminformationen ermitteln
Raspberry Pi: vcgencmd nachinstallieren

Freie Firmware für Raspberry Pi startet Linux-Kernel

“When the pi was release, we were playing around with buildroot distros, firmware was getting updated frequently and many changes were quite important. So we needed a way to upgrade the firmware. The way to do it was to update from the repo and then copy the firmware files, the kernel and the modules to the relevant folders. Hexxeh made rpi-update and it was pretty useful at the time. However, I am of the opinion that it is indeed a hack. It’s not “the right way” to do things, but it is better than having to do it manually or having each person use their own scripts. And since it allowed to downgrade the firmware and get an exact revision, it was awesome.

Now the firmware is a part of the raspberrypi-bootloader package, which also contains the kernel. There are libraspberrypi-* packages which contain some extra userspace stuff like the vc libs and binaries. These are not updated too often, but often enough to ensure that the standard apt-get update; apt-get dist-upgrade; commands will keep your firmware up to date.

However, you may be asked by Dom to upgrade your firmware to a specific revision or the latest version if there is an issue. That is to check if a recently pushed update has fixed the issue. Sometimes people think that they are having problems because of firmware updates, so they may feel like they need to downgrade in order to get a stable system. In other words, there are legitimate uses for rpi-update still.

The problem is that it overwrites files which should be and are typically managed by the distro’s package manager. It is possible to end up with a broken install or a version mismatch between the userspace libraries and the firmware. It’s a bit like installing a package using apt-get, the downloading a different version, compiling it and overwriting the system’s version. There are no ‘real’ problems with any of this, but for purists, it’s just not the right way to do things.

I would say, as a rule of thumbs, use rpi-update if you are helping test the firmware while investigating a potential bug, if you are working on a distro that doesn’t keep the firmware up to date (the important ones do), if the raspberrypi-bootloader package has not been updated in a long time and important updates have been released on github or if you just know what you’re doing and feel like it’s necessary. But I don’t think it’s good practice to just run it all the time without even checking the commits on github. A recent example where rpi-update was a good idea was when some SD corruption fixes were pushed but the raspberrypi-bootloader package was 3 months out of date.”

Raspberry Pi 3, MMAL / OpenMAX

What is MMAL?
Help learning MMAL/contributing to userland utils
Raspicam C++ API mmal linking
Multi-Media Abstraction Layer (MMAL). Draft Version 0.1

$ ldconfig -p | grep libmmal
    libmmal_vc_client.so (libc6,hard-float) => /opt/vc/lib/libmmal_vc_client.so
    libmmal_util.so (libc6,hard-float) => /opt/vc/lib/libmmal_util.so
    libmmal_core.so (libc6,hard-float) => /opt/vc/lib/libmmal_core.so
    libmmal_components.so (libc6,hard-float) => /opt/vc/lib/libmmal_components.so
    libmmal.so (libc6,hard-float) => /opt/vc/lib/libmmal.so

C++ Threads


#include <thread>
#include <mutex>
#include <atomic>

std::thread    t(thread_function);

std::thread::hardware_concurrency()
std::thread::get_id()
std::this_thread::get_id();

t.join();
t.detach();
t.joinable();
t.get_id();

static std::mutex               m;
std::lock_guard<std::mutex>     guard(m);
std::unique_lock<std::mutex>    l(m);
std::atomic<int>                result(0);
std::condition_variable         condvar;

m.lock();
m.unlock();
condvar.wait(...);
condvar.notify_one();

  • Function Pointer
  • Function Objects
  • Lambda functions

C++11 multithreading tutorial
C++11 multithreading tutorial – part 2
C++11 Multithreading – Part 1 : Three Different ways to Create Threads
C++11/C++14 Thread 1. Creating Threads

Posts about C++11 Concurrency Tutorial
C++11 Concurrency – Part 1 : Start Threads
C++11 Concurrency Tutorial – Part 2 : Protect shared data
C++11 Concurrency Tutorial – Part 3: Advanced locking and condition variables

C++ Copy Elision and Return Value Optimization

  • RVO = Return Value Optimization
  • NRVO = Named Return Value Optimization
  • Copy Constructor (ctor)
  • Copy Assignment Operator
  • Move Constructor (ctor): C::C(C&& other);
  • Move Assignment Operator: C& C::operator=(C&& other);
  • Move Semantics
  • Temporary
  • Lvalue: object that occupies some identifiable location in memory (i.e. has an address)
  • Rvalue: temporary register (i.e. has NOT address)
  • Rvalue References: std::string&& rrstr;
  • Lvalue references: std::string& ref;
  • Reference Variables

Understanding lvalues and rvalues in C and C++

Six User-Declared Special Member Functions

  • Default constructor
  • Copy constructor (ctor)
  • Copy assignment operator
  • Move Constructor (ctor)
  • Move Assignment Operator
  • Destructor

C++ declares its remaining special member functions implicitly, if there are no user-declared functions.

Vokabular

  • pilfer = stehlen, entwenden, klauen, stibitzen
  • elision = Weglassung, Auslassung

Hitherto, copying has been the only means for transferring a state from one object to another.
And yet, in many real-world scenarios, you don’t copy objects but move them.
Notwithstanding the conceptual difference between copying and moving, there’s a practical difference too: Move operations tend to be faster than copying because they transfer an existing resource to a new destination, whereas copying requires the creation of a new resource from scratch.

Bislang war das Kopieren das einzige Mittel, um einen Zustand von einem Objekt auf ein anderes zu übertragen.
Doch in vielen realen Szenarien kopiert man Objekte nicht, sondern verschiebt sie.
Ungeachtet des konzeptionellen Unterschieds zwischen Kopieren und Verschieben gibt es auch einen praktischen Unterschied: Verschiebeoperationen sind tendenziell schneller als Kopieren, weil sie eine bestehende Ressource an ein neues Ziel übertragen, während beim Kopieren eine neue Ressource von Grund auf neu erstellt werden muss.

Übersetzt mit www.DeepL.com/Translator (kostenlose Version)

Is there any gorgeous way for C++ to return an object without copying it in memory?
Returning a c++ std::vector without a copy?
What are copy elision and return value optimization?
Move or Named Return Value Optimization (NRVO)?
What Is RVO And NRVO In C++? (YouTube Video)

C++11 Tutorial: Introducing the Move Constructor and the Move Assignment Operator

cppreference.com

Copy elision
Move constructors

Schalter / Wechselschalter / Umschalter

Schalter
Wechselschalter
SPDT

“FOCUS ON” – Switches Explained! (PDF)
Grundlegende Funktionsweise von Stromkreisen

Was ist der Unterschied zwischen Schalter /Taster/ Tastschalter?

Abkürzung des Schalters Beschreibung
SPST Das Kürzel SPST bezeichnet einen einpoligen Schalter, der entweder offen oder geschlossen ist.
SPDT Die Abkürzung SPDT bedeutet, dass dieser einpolige Schalter eine Zusatzfunktion des Wechselschalters beinhaltet. Dies bedeutet, dass der Schalter entweder Gerät 1 oder 2 verbindet.
SPTT / SPCO Hier handelt es sich um die Erweiterung des SPDT durch einen Nullpunkt. Es müssen nicht unbedingt Gerät 1 oder 2 geschaltet werden, es kann auch eine Nullstellung gewählt sein.
DPST Das Kürzel steht für zwei einpolige Schalter. Durch dieses Modell ist es möglich gleich zwei Stromkreise zu schließen.
DPDT Das Kürzel steht für zwei einpolige Schalter. Durch dieses Modell ist es möglich gleich zwei Stromkreise zu schließen.
DPCO Das ist die Erweiterung des DPDT durch die Nullstellung.