5. March 2024

Linking of application failed with: can’t link soft-float modules with single-float modules

When building an application for RISC-V you may get following linking error:

can't link soft-float modules with single-float modules

The problem is that ABI of the library does not match the application. You can use following command to check flags:

readelf -h path_to_library
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           RISC-V
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          736 (bytes into file)
  Flags:                             0x1, RVC, soft-float ABI

The solution is to build the library with the same flags like the rest of application. This can be achieved by using following flags for CMake.

-DCMAKE_C_FLAGS=-march=rv32imafc -mabi=ilp32f
-DCMAKE_CXX_FLAGS=-march=rv32imafc -mabi=ilp32f

If your target has different support for float, you might need to change suggested march and mabi.

28. February 2024

qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found.

After the installation of QtCreator on Linux you might get following error messag when launching the application:

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.

This application failed to start because no Qt platform plugin could be initialized. 
Reinstalling the application may fix this problem.

It is likely one of libraries required by xcb is missing.

To resolve this problem find libxcb.so and run ldd to identify the missing library.

find ~/Qt -name libqxcb.so -exec ldd {} \; | grep "not found"

Install the missing dependency. E.g.:

sudo apt-get install libxcb-cursor0

14. December 2023

How to connect USB and PS/2 Keyboards to ESP32 with Rust no_std and std

Have you ever wondered how to connect a PC keyboard to your ESP32 for innovative projects? Whether it’s an old PS/2 keyboard or a modern USB one, this article will show you how to integrate these input devices with your ESP32, using the versatile and powerful Rust programming language. The first part of the article describes Rust no_std solution. Rust std for USB solution is at the end of the article.

Preparing the ESP32-C3

First, let’s tackle the wiring for the ESP32-C3. Detailed in bjoernQ’s GitHub repository, “ps2keyboard-esp32c3”, this setup requires three resistors and is perfectly illustrated in the “Circuit” section. For a reliable and efficient connection, consider the wire-wrap technique recommended by Andreas Spiess in his enlightening video, “#243 Better than Dupont Wires: Wire Wrapping for our Projects”.

For the PS/2 connector, refer to the detailed pinout available in the Wikipedia article, “PS/2 port”, particularly the pinout diagram for the female connector (PS/2 port pinout diagram). Please, keep in mind that the pinout is for the female connector from the front side. For the male connector or the back side of the female connector you need to flip the image.

For USB keyboart you’ll need a USB keyboards support a COMBO PS/2 support (still available in many USB keyboards, allowing them to function as PS/2 devices). You can connect these USB keyboards directly by following the schematics from the Instructables project, “USB to PS/2 Convertor” with “ps2keyboard-esp32c3 schematics”,. Specifically, use this wiring diagram (USB to PS/2 wiring diagram) to integrate into the ESP32-C3 setup. No code changes are needed for this part.

Flashing the ESP32-C3

After setting up the hardware, it’s time to program the ESP32-C3. The software part is handled using the pc-keyboard crate, developed by thejpster’s. Flash your ESP32-C3 with the cargo espflash --release command, and watch as keyboard inputs appear on your console.

Interesting Project Ideas

Now that you have your keyboard connected to the ESP32. Here are some project ideas to get you started:

  • Smart Home Controller: Use the keyboard to control lights, temperature, or other IoT devices in your home.
  • Custom Game Controller: Create a gaming experience by mapping keyboard keys to game controls.
  • Educational Tool: Teach programming or robotics, using the keyboard as an input device for experiments and projects.
  • Artistic Installations: Incorporate the keyboard into interactive art projects or music synthesizers.

Rust std + ESP-IDF with USB support

The text above describes Rust no_std solution. If you’re using Rust std on top of ESP-IDF, you can use direct USB support on ESP32-S3 with USB HID for mouse and keyboard Board Support Package (BSP).

7. August 2023

How to extract Rust function signatures from .rs file using sed – one-liner

To extract function signatures from .rs file you can use following one-liner with sed:

sed -n -e '/pub fn/,/)/p' file.rs

Sample output:

  pub fn chip(&self) -> Chip {
    pub fn device_info(&mut self) -> Result<DeviceInfo, Error> {
        let chip = self.chip();
    pub fn load_elf_to_ram(
        &mut self,
        elf_data: &[u8],
        mut progress: Option<&mut dyn ProgressCallbacks>,
    ) -> Result<(), Error> {

24. July 2023

ESP32 How to merge firmware into signle binary

Application built on top of ESP-IDF can be merged into single binary using following commands:

cd build
esptool.py --chip ESP32 merge_bin -o merged-flash.bin @flash_args

The esptool will output following command and perform the conversion:

esptool.py --chip ESP32 merge_bin -o merged-flash.bin --flash_mode dio --flash_freq 80m --flash_size 16MB 0x0 bootloader/bootloader.bin 0x10000 wasmachine.bin 0x8000 partition_table/partition-table.bin 0xd000 ota_data_initial.bin
esptool.py v3.3.2
Wrote 0x2ad4d0 bytes to file merged-flash.bin, ready to flash to offset 0x0

The output is stored in build/merged-flash.bin.