Setting up the Realtek’s card reader driver for Linux (Gentoo)

First time as I looked at my build-in into my laptop card reader to configure sdcard for the raspberry pi, it turned out that it was not working out of the box. Okey. It was not really a surprise to me. It was a RTS5229 PCI Express Card Reader:

# lspci -vvnn
09:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5229 PCI Express Card Reader [10ec:5229] (rev 01)
        Subsystem: Toshiba America Info Systems Device [1179:ff1e]
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0, Cache Line Size: 64 bytes
        Interrupt: pin A routed to IRQ 16
        Region 0: Memory at d9400000 (32-bit, non-prefetchable) [size=4K]
        Capabilities: [40] Power Management version 3
                Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0-,D1+,D2+,D3hot+,D3cold-)
                Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
                Address: 0000000000000000  Data: 0000
        Capabilities: [70] Express (v2) Endpoint, MSI 00
                DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s unlimited, L1 unlimited
                        ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
                DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
                        RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop-
                        MaxPayload 128 bytes, MaxReadReq 512 bytes
                DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
                LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 unlimited, L1 <64us
                        ClockPM+ Surprise- LLActRep- BwNot-
                LnkCtl: ASPM L0s L1 Enabled; RCB 64 bytes Disabled- Retrain- CommClk-
                        ExtSynch- ClockPM+ AutWidDis- BWInt- AutBWInt-
                LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
                DevCap2: Completion Timeout: Not Supported, TimeoutDis+, LTR-, OBFF Not Supported
                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
                LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-
                         Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
                         Compliance De-emphasis: -6dB
                LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
                         EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
        Capabilities: [100 v1] Advanced Error Reporting
                UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UEMsk:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
                CESta:  RxErr+ BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
                CEMsk:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
                AERCap: First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
        Capabilities: [140 v1] Device Serial Number 00-00-00-01-00-4c-e0-00
        Kernel driver in use: rts5229
        Kernel modules: rts5229

Next step is towards a working setup configuration is to make sure that the kernel options are properly set:

Device Drivers  --->
<M> MMC/SD/SDIO card support  --->
[*]   MMC debugging
<M>   MMC block device driver
(8)     Number of minors per block device
[*]     Use bounce buffer for simple hosts
<M>   Secure Digital Host Controller Interface support
<M>   SDHCI support on PCI bus

Moreover an additional driver should also be emerged sys-block/rts5229.

# emerge -a1v rts5229

If you have a RTS5209 card reader, then install sys-block/rts_pstor

That’s all, have fun!

Vala, OpenGL and Gtk+ sample code with shaders on Gnu/Linux

This is the follow up post for the discoveries which I was doing for myself to unify OpenGL support with Gtk+. Here, you can find a first post, I have shared towards this direction.
The content of the trivial shader program: vertex-shader.txt

#version 130

attribute vec4 vPosition;

void main () {
	gl_Position = vPosition;


#version 130

precision mediump float;
uniform vec4 vColor;

void main () {
	gl_FragColor = vColor;
using GL;

namespace Evg {
	public class Shader {
		private bool loaded;
		private uint type;
		private uint id;

		public Shader () {
			this.loaded = false; = 0;

		~Shader () {
			this.delete ();

		public bool load_from_string (string shader, uint type) { = glCreateShader (type);

			stdout.printf ("id is %u\n", id);

			glShaderSource (id, shader);
			glCompileShader (id);

			int status;
			glGetShaderiv (id, GL_COMPILE_STATUS, out status);

			if (status == GL_FALSE) {
				stdout.printf ("shader info log: '%s'\n", glGetShaderInfoLog (;
				return false;

			this.type = type;
			this.loaded = true;

			return true;

		public bool load_from_file (string path, uint type) {
			File file = File.new_for_path (path);

			if (!file.query_exists ()) {
				stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
				return false;

			try {
				DataInputStream dis = new DataInputStream ( ());
				StringBuilder sb = new StringBuilder ();
				string line;

				while ((line = dis.read_line ()) != null) {
					sb.append_printf ("%s\n", line);

				return this.load_from_string (sb.str, type);
			} catch (Error e) {
				error ("%s", e.message);

		public bool is_loaded () {
			return this.loaded;

		public uint get_id () {

		public void delete () {
			if (!this.loaded) return;
			this.loaded = false;
			glDeleteShader (;
using GL;

namespace Evg {
	public class Program {
		private bool linked;
		private uint id;

		public Program () { = 0;
			this.linked = false;

		public uint get_id () {

		public bool create () { = glCreateProgram ();
			return ( != 0);

		public bool attach_shader (Evg.Shader shader) {
			if (!shader.is_loaded ())
				return false;

			glAttachShader (, shader.get_id ());
			return true;

		public bool is_linked () {
			return this.linked;

		public bool is_created () {
			return ( != 0);

		public bool link () {
			glLinkProgram (;

			int status;
			glGetProgramiv (, GL_LINK_STATUS, out status);
			this.linked = (status == GL_TRUE);

			if (!this.linked) {
				stdout.printf ("program info log: '%s'\n", glGetProgramInfoLog (;

			return this.linked;

		public void use () {
			if (this.linked)
				glUseProgram (;

		public void delete () {
			if (!this.linked)

			this.linked = false;
			glDeleteProgram (; = 0;

		~Program () {
			this.delete ();
using GLX;
using GL;

class GLXSample : Gtk.Window {

    private unowned X.Display xdisplay;
    private GLX.Context context;
    private GLX.XVisualInfo xvinfo;

	private Evg.Shader vertex_shader;
	private Evg.Shader fragment_shader;
	private Evg.Program program;
	private Triangle triangle;

    public GLXSample () {
        this.title = "OpenGL with GLX";
        this.set_reallocate_redraws (true);
        this.destroy.connect (Gtk.main_quit);

        int[] attrlist = {
            GLX_RED_SIZE, 1,
            GLX_GREEN_SIZE, 1,
            GLX_BLUE_SIZE, 1,
            GLX_DOUBLEBUFFER, 0

        this.xdisplay = Gdk.x11_get_default_xdisplay ();

        if (!glXQueryExtension (xdisplay, null, null)) {
            stderr.printf ("OpenGL not supported\n");

        this.xvinfo = glXChooseVisual (xdisplay,
									   Gdk.x11_get_default_screen (),
									   attrlist );

        if (xvinfo == null) {
            stderr.printf ("Error configuring OpenGL\n");

        var drawing_area = new Gtk.DrawingArea ();
        drawing_area.set_size_request (300, 300);
        drawing_area.set_double_buffered (false);

        this.context = glXCreateContext (xdisplay, xvinfo, null, true);

        drawing_area.configure_event.connect (on_configure_event);
		drawing_area.realize.connect (on_realize);
        drawing_area.draw.connect (on_draw);

        this.add (drawing_area);

	private void on_realize (Gtk.Widget widget) {
		if (!glXMakeCurrent (xdisplay,
							 Gdk.X11Window.get_xid (widget.get_window ()),

		stdout.printf ("Vendor: ........... %s\n", glGetString (GL_VENDOR));
		stdout.printf ("Renderer: ......... %s\n", glGetString (GL_RENDERER));
		stdout.printf ("Version: .......... %s\n", glGetString (GL_VERSION));
		stdout.printf ("GLSL version: ..... %s\n",

		this.vertex_shader = new Evg.Shader ();

		stdout.printf ("loading vertex shader\n");
		vertex_shader.load_from_file ("vertex-shader.txt", GL_VERTEX_SHADER);
		stdout.printf ("vertex shader is loaded %s\n",
					   vertex_shader.is_loaded ().to_string ());

		this.fragment_shader = new Evg.Shader ();

		stdout.printf ("loading fragment shader\n");
		fragment_shader.load_from_file ("fragment-shader.txt", GL_FRAGMENT_SHADER);
		stdout.printf ("fragment shader is loaded %s\n",
					   fragment_shader.is_loaded ().to_string ());

		this.program = new Evg.Program ();
		this.program.create ();
		stdout.printf ("program is created %s\n", program.is_created ().to_string ());
		this.program.attach_shader (this.vertex_shader);
		this.program.attach_shader (this.fragment_shader); ();
		this.program.use ();
		stdout.printf ("program is linked %s\n", program.is_linked ().to_string ());

		this.triangle = new Triangle (this.program.get_id ());

    private bool on_configure_event (Gtk.Widget widget, Gdk.EventConfigure event) {
        if (!glXMakeCurrent (xdisplay,
							 Gdk.X11Window.get_xid (widget.get_window ()),
            return false;

		int width = widget.get_allocated_width ();
		int height = widget.get_allocated_height ();
		int size = int.min (width, height);

		glViewport ((width - size) / 2, (height - size) / 2, size, size);

        return true;

    private bool on_draw (Gtk.Widget widget, Cairo.Context cr) {
        if (!glXMakeCurrent (xdisplay,
							 Gdk.X11Window.get_xid (widget.get_window ()),
            return false;

        glClear( GL_COLOR_BUFFER_BIT );

		this.triangle.draw ();

        glXSwapBuffers (xdisplay, Gdk.X11Window.get_xid (widget.get_window ()));

        return true;

public class Triangle {
	private float[] color = { 0.63671875f, 0.76953125f, 0.22265625f, 1.0f };
	private float[] triangle_vertex = {
         0.0f,  0.622008459f, 0.0f,
        -0.5f, -0.311004243f, 0.0f,
         0.5f, -0.311004243f, 0.0f

	private uint program_id;

	public Triangle (uint program_id) {
		this.program_id = program_id;

	public void draw () {
		int position_id = glGetAttribLocation (this.program_id, "vPosition");
		glEnableVertexAttribArray (position_id);
		glVertexAttribPointer (position_id, 3, GL_FLOAT, false, 12, triangle_vertex);

		int color_id = glGetUniformLocation (this.program_id, "vColor");
		glUniform4fv(color_id, 1, color);

		glDrawArrays (GL_TRIANGLES, 0, 3);

		glDisableVertexAttribArray (position_id);

void main (string[] args) {
    Gtk.init (ref args);

    var sample = new GLXSample ();
    sample.show_all ();

    Gtk.main ();

The content of the makefile:

	valac-0.18 -o glx-test glx-test.vala evg-shader.vala evg-program.vala --vapidir ../vapi --pkg gl --pkg gl3 --pkg gio-2.0 --pkg gtk+-3.0 --pkg glx --pkg gdk-x11-3.0 #--ccode

Quickly applying patches on Gentoo

Sometimes, it’s necessary to apply a patch for a given package and there is no time and no desire to fork an ebuild to a custom overlay. Luckily Gentoo provides an easy way to so. All you need to do is to place a patch into the directory /etc/portage/patches/[category]/[ebuild’s name]/new-fix.patch. Sadly, not all ebuilds in the portage tree has a build-in support for this feature and to be on the safe side you can put the following hook into the portage’s bashrc file:

# cat /etc/portage/bashrc 
post_src_prepare() {
    if type epatch_user &> /dev/null ; then

Reference: Gentoo wiki

Getting Stack Traces and Debugging Information on Gentoo

If you want to extract a useful debugging information from a crashing application do not try mistakenly to enable the “debug” USE flag in the corresponding ebuild. The “debug” USE flag is used for other purposes [1]. The proper way to do so, is mostly to enable the “-ggdb” compile flag and rebuild the application. In the case of “evince” the command line would be:

# CFLAGS="-march=native -pipe -O2 -ggdb" \
FEATURES="${FEATURES} splitdebug" emerge -1av evince

Luckily, there is no need to keep this in mind, because portage provides a possibility of configuration storing [2,3]. So the debugging configuration can be created once and used for all later purposes. To make use of it, create an “env” directory

# mkdir -p /etc/portage/env/

and put the above introduced debug setup in the file of your taste, like a “debug.conf”:

# cat /etc/portage/env/debug.conf
CFLAGS="-march=native -pipe -O2 -ggdb"
FEATURES="${FEATURES} splitdebug"

For now you can place all packages you would like to debug in the “package.env” file, using the following already similar to you syntax:

# cat /etc/portage/package.env
app-text/evince debug.conf
dev-libs/glib debug.conf
dev-libs/gtk+ debug.conf
# >gnome-base/nautilus-3.8.1 debug.conf

Rebuild the desired packages and you are ready for debugging:

# emerge -a1v evince glib gtk+

Obtaining stack traces is a straightforward process from this point, which mainly consists of issuing the following commands in order within gdb [1,4]:

$ gdb evince
GNU gdb (Gentoo 7.5.1 p2) 7.5.1

(gdb) run

(gdb) set logging file backtrace.log
(gdb) set logging on
Copying output to backtrace.log.

(gdb) thread apply all bt full

(gdb) set logging off
Done logging to backtrace.log.
(gdb) quit

Further resources:

  1. How to get meaningful backtraces in Gentoo
  2. Overriding environment variables per package
  3. /etc/portage/env
  4. Getting Traces in GNOME

GNOME 3.8 is underway

During the sources of the one of the most beautiful graphical desktop environments are landing on the official gnome server, I would like to forward the message to everyone that GNOME 3.8 is going to be released officially in the coming weeks.gnome 3.6 desktop It will have for sure a lot of new and great features, which increase the pleasure of computer usage. One the features I have discovered already is the integrated MTP support (via libmtp) in gvfs. It allows you in nautilus an out of the box connection, transfer and managing of you files with new Android devices, like tabs and smartphones, respectively. Enjoy!!!

Вышла новая версия файлового менаджера Thunar 1.6.1

Совсем недавно, пару дней назад вышла в свет новая версия осень быстрого и использующего мало системных ресурсов файлового менеджера thunar версии 1.6.1. Одна из основных добавленных функций в новой версии это возможность использования вкладок, что иллюстрированно на картинке. thunar входит с состав программ быстрой и современной графической поверхности Xfce. Так что если у вас есть старый компьютер пятилетней давности, то у вас появляется уникальная возможность установить на него совершенно бесплатную операционную систему xubuntu, разрабатывающуюся многими тысячами программистов по всему земному шару и конечно при поддержки обширного ряда крупных компаний. Так что не удивляйтесь, если ваш старый компьютер с установленным xubuntu будет работать быстрее, только что купленного ноутбука с Windows 8!!! Добро пожаловать в мир неисчерпанных возможностей))

Öfnen von ISO Image-Dateien in Ubuntu GNU/Linux

Um in Gnu/Linux Image-Dateien, inbesondere mit der ISO-Endung, zu öffnen, benötigt man, im Gegensatz zu Windows, keine externe kostenpflichtige Anwendungen, wie zum Beispiel DEAMON Tools. Die auf Gnu/Linux basierende und Windows weit überlegende Betriebssysteme, wie das frei verfügbare Ubuntu bieten auch in diesem Fall sehr einfache Lösungen an.
Man erstellt dafür einen neuen Ordner, falls noch nicht vorhanden, mit dem Befehl:

sudo mkdir /media/iso_image

und bindet die Image-Datei, hier genannt als filename.iso

sudo mount filename.iso /media/iso_image -t iso9660 -o loop

Dieser Prozess wird als Mount bezeichnet. Schon, es ist erledigt. Man braucht nun nur zu diesem Ordner zu navigieren, um den Inhalt der gerade eingebundenen ISO-Datei anzuschauen.
Wenn der Inhalt der Image-Datei nicht mehr benötigt wird, lässt sich diese mit dem ausführen vom Befehl

sudo umount /media/iso

wieder schließen.