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.

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.

2. May 2023

How to build single flashable binary for ESP32 with esptool.py

Build of ESP-IDF project produces several files, like bootloader, application binary or partition table.

Having several files makes it harder to ship the application outside of build computer.

Solution to the problem is merging binaries into single flashable file.

Build your project with idf.py as always:

cd project
idf.py build

Merge binaries into single file. At the end of build process the tool will display command for flashing. This can be used to compose command like this:

esptool.py --chip ESP32 merge_bin -o merged-flash.bin --flash_mode dio ^
  --flash_size ^
  2MB 0x0 build\bootloader\bootloader.bin ^
  0x8000 build\partition_table\partition-table.bin ^
  0x10000 build\my_app.bin

Luckily there is a simpler way, because all those arguments are stored in build/flash_args file:

Example for Bash

(cd build; esptool.py --chip esp32 merge_bin -o merged-flash.bin @flash_args)

Example for PowerShell

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

17. April 2023

Matter: chip-tool pairing ble-wifi failing with Abort trap: 6 on macOS

chip-tool can be used for commissioning ESP32 with Matter.

macOS users may face the following error with iTerm:

chip-tool interactive start

pairing ble-wifi 0x7283 SSID PASS PIN 3840
..[FP] Validating NOC chain
..[FP] NOC chain validation successful
..[FP] Added new fabric at index: 0x1
...
Abort trap: 6

It’s necessary to grant access to Bluetooth to apps launched from iTerm.

Click System SettingsPrivacy & Security. Select Bluetooth. Click +, Select Applications, and find iTerm.

Close and open iTerm. The problem with “trap 6” should be gone.

Just do not forget to install Bluetooth Central Matter Client Developer mode profile. Otherwise the provisioning will fail with UUID problem.