21. February 2022

Podman: Could not open ‘edk2-aarch64-code.fd’

It’s possible to use brew to install Podman on Apple Silicon (M1). The installation gets slightly more complicated when the user wants to use Homebrew installed in user’s home directory.

Problem #1 – gvproxy

Command:

podman machine start

Error:

Error: unable to start host networking: "could not find \"gvproxy\" in one of ....

Solution: add path to Podman’s helper binaries stored in bin and libexec to ~/.config/containers/containers.conf

[engine]
  helper_binaries_dir=["/Users/georgik.rocks/brew/Cellar/podman/4.0.3/bin","/Users/georgik.rocks/brew/Cellar/podman/4.0.3/libexec"]

Problem #2 – edk2-aarch64-code.fd

Command:

podman machine start

Error:

INFO[0000] new connection from  to /tmp/podman/qemu_podman-machine-default.sock
Waiting for VM ...
qemu-system-aarch64: -drive file=edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on: Could not open 'edk2-aarch64-code.fd': No such file or directory
Error: dial unix /tmp/podman/podman-machine-default_ready.sock: connect: connection refused
ERRO[0003] cannot receive packets from , disconnecting: cannot read size from socket: EOF
ERRO[0003] cannot read size from socket: EOF

Solution: Open file ~/.config/containers/podman/machine/qemu/podman-machine-default.json and change to /Users/USERNAME/brew/Cellar/qemu/6.2.0_1/share/qemu/edk2-aarch64-code.fd

"file=/Users/georgik.rocks/brew/Cellar/qemu/6.2.0_1/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on"

After these changes Podman should start without problem.

1. December 2021

How to connect ESP32 as USB serial device to Linux in WSL2 on Windows 11

There is a nice article and video explaining how to connect USB serial to Linux in WSL2.

Just few details are missing. Here is the full list of steps necessary to flash ESP32 with FTDI from WSL2:

  • Install Windows 11, open Windows Update – join Windows Insider Program (Beta channel) – install updates, reboot machine
  • Windows Update – Advanced Options – check the option “Receive updates for other Microsoft products” – Back – Check for updates
  • Reboot or shutdown WSL2 images
  • start a new WSL2 image e.g. with Ubuntu 20 LTS, check that you have kernel 5.10: uname -a. It does not work on 4.x kernel from normal WSL2
  • install https://github.com/dorssel/usbipd-win/releases on Windows
  • in Linux – sudo apt install linux-tools-5.4.0-77-generic hwdata
  • in Linux – visudo
  • in Linux – prepend path Defaults secure_path=”/usr/lib/linux-tools/5.4.0-77-generic:
  • connect ESP device with FTDI in Windows PowerShell (administrator) type: usbipd wsl list
  • search for 5-3 USB Serial Converter A, USB Serial Converter B Not attached
  • type in Windows: usbipd wsl attach -b 5-3 -d Ubuntu
  • type in Linux:cd examples/get-started/blink; idf.py build flash monitor

Result:

I (263) example: Example configured to blink addressable LED!
I (263) example: Turning the LED OFF!
I (1273) example: Turning the LED ON!

21. September 2021

How to install Podman on Linux Mint 20

Podman binaries for Linux Mint / Ubuntu are hosted by OpenSuse.org.

You need to add the repository to /etc/source.list.d. Common instructions for Ubuntu might not work, because VERSION_ID for Mint is not the same as for Ubuntu.

Instructions for Linux Mint 20.2 from Ubuntu 20.04 repository:

export VERSION_ID="20.04"
sudo sh -c "echo 'deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"
sudo wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O- | apt-key add -
sudo apt update
sudo apt install -y podman

Example of running container for IoT development:

If you’d like to develop for ESP32 chip connected to /dev/ttyUSB0 using C++ or Rust language, just start the container:

podman run --device /dev/ttyUSB0 -it docker.io/espressif/idf-rust-examples

3. September 2021

How to flash ESP32 from WSL

WSL (Windows Subsystems for Linux) is a great way how to build projects based on ESP-IDF. The problem is how to flash the image from WSL Linux to a real chip?

Right now only WSL1 supports mapping of Windows COM ports to Linux /dev/ttyS*.

First of all, make sure that your image is running WSL1 (which is slower than WSL2):

wsl -l -v

In the case of WSL2 image, you can convert it by the following command (let assume the image of Ubuntu):

wsl -t Ubuntu
wsl --set-version Ubuntu 1

Use Windows Device Manager to determine COM ports of your ESP chip. Similar could be achieved by command:

mode

The number of COM.. device will be mapped to the /dev/ttyS.. in Linux.

Start the Linux terminal (e.g. using Windows Terminal). Grant permission so that your user can read write /dev/ttyS* or add your user to dialout group if supported by distribution. Note: on Linux, the device is often mapped to /dev/ttyUSB*, notice the difference on Windows /dev/ttyS*.

chmod a+rw /dev/ttyS*

Build and flash the project. It’s necessary to specify the device name, because autodetection in idf.py is not able to find /dev/ttyS. The second important part is to set the communication speed by “-b” option.

idf.py flash --port /dev/ttyS11 -b 115200
idf.py monitor --port /dev/ttyS11

The last command should launch idf monitor, which you can terminate by CTRL+].

If you’re WSL2 user, you can try alternative approach using idfx tool.

7. May 2021

How to speed up Linux on WSL2? Common mistake when upgrading from WSL1

According to Microsoft WSL2 is way faster than WSL1 for running Linux images. So, why even after upgrade to WSL2 is Linux running slow and with the same IO inefficiency like it was on WSL1?

The reason is simple. Even though the WSL2 was added to the operating system, the old images are running on WSL1. You can verify it by command:

wsl -l -v

Output:

  NAME                   STATE           VERSION
* openSUSE-Leap-15.2     Stopped         1
  Ubuntu                 Stopped         1
  docker-desktop-data    Stopped         2

As you can see both Ubuntu and openSUSE has set version to 1 which means that these images runs on WSL1. It’s necessary to explicitly change the version by following commands:

wsl --shutdown
wsl --set-version "Ubuntu" 2
wsl --set-version "openSUSE-Leap-15.2" 2 

The conversion will take some time. Output:

Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.

Now you can verify the version of WSL for the image:

wsl -l -v
  NAME                   STATE           VERSION
* openSUSE-Leap-15.2     Stopped         2
  Ubuntu                 Stopped         2
  docker-desktop-data    Stopped         2

Simply start the shell of the distribution and you’ll experience better performance.

It’s also possible to set version for future images by command:

wsl --set-default-version 2