To add a custom module to the MicroPython firmware for the ESP32
Follow: blog.mmone.de/2019/09/26/howto-build-micropython-for-esp32-on-osx/ to setup a build environment on OSX.
Pass the module to the make command like that:
ESPIDF=<path to IDF> PYTHON2=/usr/bin/python USER_C_MODULES=<path to module> make all
A prebuild toolchain for the ESP32 is available from Espressif: https://dl.espressif.com/dl/xtensa-esp32-elf-osx-1.22.0-80-g6c4433a-5.2.0.tar.gz
If you’re interested in building from scratch check the docs for IDF v.3.3 https://docs.espressif.com/projects/esp-idf/en/v3.3/get-started/macos-setup.html
Get MicroPython and initialise its dependencies
git clone https://github.com/micropython/micropython.git
git submodule update --init
Get the correct version of the IDF and its dependencies
As of 09/2019 the MicroPython build needs v3.3 of the IDF. Later versions use cmake instead of make.
git clone https://github.com/espressif/esp-idf.git
git checkout 6ccb4cf5b7d1fdddb8c2492f9cbc926abaf230df
git submodule update --init --recursive
Unpack the toolchain and add IT to the PATH
tar -zxf xtensa-esp32-elf-osx-1.22.0-80-g6c4433a-5.2.0.tar.gz
export PATH=$PATH:<replace with absolute path to toolchain>/bin
Some of the build tools and dependencies require Python 3. Lets create a virtual environment and activate it to keep things separated.
virtualenv --python=python3 esp32buildEnv
Install the python dependencies required by the IDF
pip install -r esp-idf/requirements.txt
Build the crosscompiler
Build the ESP32 port
ESPIDF=<path to IDF root> PYTHON2=/usr/bin/python make
The resulting “firmware.bin” can be uploaded to your ESP32 with the “esptool” as usual.
List all interfaces by running the command ‘ifconfig’ in a terminal. Pick the interface you want to change e.g “en0“
To set a different MAC on the interface run:
sudo ifconfig [interface] lladdr [MAC]
e.g: sudo ifconfig en0 lladdr dc:03:be:a0:a5:ab
You can generate a random MAC by running:
openssl rand -hex 6 | sed ‘s/\(..\)/\1:/g; s/.$//’
If the Disk Utility GUI on OSX doesn’t allow you to format a USB Stick or SD Card with FAT32 the command-line does.
- List the available disks with: “diskutil list”
- Find the device you want to format eg.: “/dev/disk2” and use this device in the next command.
- Format with: “sudo diskutil eraseDisk FAT32 DISKNAME MBRFormat /dev/disk2″
Here is the official Apple way to create a bootable USB stick from a OSX installer: https://support.apple.com/en-us/HT201372
A great set of scripts by by Iván Rodríguez Murillo that builds the Structure from Motion solution VisualSfm as a self contained App on OSX. Just clone the repository from GitHub and execute “run ./scripts/all.” You might need to install XQuartz from http://xquartz.macosforge.org
find . -name "*.bak" -type f -delete
But use it with precaution. Run first:
find . -name "*.bak" -type f
Most of the time it doesn’t make a difference what you use, “localhost” or 127.0.0.1. It turns out that it does make a somehow big difference when connecting to a mysql server.
If you use “localhost” most clients will try to “connect” via the socket file that the server puts, if it adheres to the standard, into /tmp, if you use 127.0.0.1 a IP connection is made.
I was made aware of this fact when I tried to connect to the mysql server that comes with XAMP. Its configuration does not adhere to the standard and puts the socket file into /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock on OSX.
The clients that wasn’t aware of this fact obviously failed to connect and threw the error: “Connect Error: SQLSTATE[HY000]  No such file or directory” when a connection attempt was made. Hope who ever has the same problem finds this and spends less time debugging then I did 🙂
A nice writeup of how to get a cross compiling enviroment for the Pi going on OSX with Eclipse: Raspberry PI – Cross Compiling unter Mac OS X mit Eclipse | Wel!s Blog (German).
Unigine Heaven is a cross-platform DX11 graphics benchmark for Windows, Linux and Mac OSX. It is based on the Unigine Engine.