Metrika
Ivy Knob

ESP-IDF Quick Tip: Dealing with port configuration and source control

ESP-IDF Quick Tip: Dealing with port configuration and source control

ESP-IDF is official ESP32 Internet of Things Development Framework from Espressif. It's based on FreeRTOS and can be used as a solid base for production firmware. It's also a platform for other Espressif frameworks: ESP-ADF (Audio Development Framework) and ESP-MDF (Mesh Development Framework). It uses closed source toolchain to compile, which is a bad thing, but we will talk about it later.

Problem: cross-platform port notation

Working with the source code of firmware requires to set up a few values: board and OS specific values, stacks configuration values, partitions and so on. These values are stored in sdkconfig file in the root of source code. The thing is, that port, which is used for flashing firmware, is in this configuration file too. But for different platforms (OSX, Linux and Windows) port notations are different. OSX uses /dev/tty.usbserial-1420, Linux uses /dev/ttyUSB0. So you can't use this file in source control for every platform. How to deal with that?

Solution: env variables

ESP-IDF uses CMake and it's possible to override configuration with env variables. You can deal with port adding something like this to your environment.

Add something like this to your ~/.profile or ~/.zshrc files:

export CONFIG_ESPTOOLPY_PORT="/dev/tty.usbserial-1420"

Now you can commit your sdkconfig file to the source control system.

Add something like this to your readme file:

Check esp32 port with command:

```bash
ls /dev | grep usb
```


copy port name.

Add something like this to your `~/.profile` or `~/.zshrc file`

```bash
export CONFIG_ESPTOOLPY_PORT="/dev/tty.usbserial-1420"
```


Reload terminal or use source command.

This should work!

This is just one trick from our tool chain. At Ivy Knob we develop software which connects embedded devices to the cloud covering all parts from both device and cloud sides. We also cover full web-development cycle including interfaces for embedded devices. We use modern tools (CI/CD) and processes (SCRUM) to deliver results quickly and with great quality. Feel free to contact us via site form or email: info@ivyknob.com