Esp8266 Installing Sming Framework on Mac
To make it work on Mac, make sure you follow this instructions on the esp-open-sdk github repo. If you happen to follow the quick start guide for Mac it might be that the instructions are incomplete. The installation process is quite long- for me it failed twice. First after 15m because case-sensitive issues, and then after ~30min because of a missing declaration.
First error message:
./ct-ng build
[INFO ] Performing some trivial sanity checks
[ERROR] Your file system in '/opt/esp-open-sdk.src/crosstool-NG/.build' is *not* case-sensitive!
[ERROR]
[ERROR] >>
[ERROR] >> Build failed in step '(top-level)'
[ERROR] >>
[ERROR] >> Error happened in: CT_Abort[scripts/functions@329]
[ERROR] >> called from: CT_TestAndAbort[scripts/functions@351]
[ERROR] >> called from: main[scripts/crosstool-NG.sh@93]
[ERROR] >>
[ERROR] >> For more info on this error, look at the file: 'build.log'
[ERROR] >> There is a list of known issues, some with workarounds, in:
[ERROR] >> 'share/doc/crosstool-ng/ct-ng.1.20.0/B - Known issues.txt'
[ERROR]
[ERROR] (elapsed: 24154209:27.00)
[00:00] / make[2]: *** [build] Error 1
make[1]: *** [_toolchain] Error 2
You need to make the build in a case sensitive environment or grep will wine. After updating dependencies with brew
, make sure to execute the following commands.
$ sudo hdiutil create ~/Documents/case-sensitive.dmg -volname "case-sensitive" -size 10g -fs "Case-sensitive HFS+"
$ sudo hdiutil mount ~/Documents/case-sensitive.dmg
$ cd /Volumes/case-sensitive
Then, after the first installation it will most likely fail do to a bunch of errors:
[ERROR] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1854:11: error: unknown type name 'ptrdiff_t'
[ERROR] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1854:29: error: use of undeclared identifier 'ptrdiff_t'
[ERROR] fatal error: too many errors emitted, stopping now [-ferror-limit=]
[ERROR] make[4]: *** [graphite-blocking.o] Error 1
[ERROR] make[4]: *** [graphite.o] Error 1
[ERROR] make[4]: *** [graphite-clast-to-gimple.o] Error 1
[ERROR] make[4]: *** [graphite-interchange.o] Error 1
[ERROR] make[4]: *** [graphite-dependences.o] Error 1
[ERROR] make[4]: *** [graphite-optimize-isl.o] Error 1
[ERROR] make[3]: *** [all-gcc] Error 2
This is a known issue, but it took me a bit to find out. Read more about it here, but TLDR:
After running make issue the following command. Do not make clean
since we need to modify a file that is downloaded during make
:
sed -i '/__need_size_t/d' ./crosstool-NG/.build/src/gmp-5.1.3/gmp-h.in
After this make
again. It took me about an hour to compile the library.
$ sudo mv /Volumes/case-sensitive/esp-open-sdk /opt
$ export PATH=/opt/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
Now, if you try to run one of the examples:
$ make
C+ app/application.cpp
AR out/build/app_app.a
LD out/build/app.out
/opt/esp-open-sdk/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: cannot find -lsming
collect2: error: ld returned 1 exit status
make: *** [out/build/app.out] Error 1
You need to compile the library...
$ cd /opt/Sming/Sming
$ make
You will also need to have esptool2
installed. To do so, clone the repo, cd to the esptool2 directory and make
. You have to make the binary executable, so you could move it to /usr/bin/
.
Examples
After compiling the library, probably the first thing you want to do is to try some of the examples.
cd
into one of the examples, like Basic_Blink. You need to update the Makefile-user.mk
file with the values appropriate for your machine. Enable the lines with SMING_HOME
and ESP_HOME
declarations.
On a Mac, it would look something like this:
## Local build configuration
## Parameters configured here will override default and ENV values.
## Uncomment and change examples:
#Add your source directories here separated by space
MODULES = app
## ESP_HOME sets the path where ESP tools and SDK are located.
## Windows:
# ESP_HOME = c:/Espressif
## MacOS / Linux:
ESP_HOME = /opt/esp-open-sdk
## SMING_HOME sets the path where Sming framework is located.
## Windows:
# SMING_HOME = c:/tools/sming/Sming
# MacOS / Linux
SMING_HOME = /opt/Sming/Sming
## COM port parameter is reqruied to flash firmware correctly.
## Windows:
# COM_PORT = COM3
# MacOS / Linux:
COM_PORT = /dev/cu.SLAB_USBtoUART
# Com port speed
# COM_SPEED = 115200
Next, you need to compile the application with make
, this will generate a directory out with two folders, build and firmware. Next, you need to flash your board with the application's binary. You do it by issuing make flash
.
Pin mapping
I'm using a NodeMCU board. The pin mapping is the same as in the Arduino codebase.
static const uint8_t D0 = 16;
static const uint8_t D1 = 5;
static const uint8_t D2 = 4;
static const uint8_t D3 = 0;
static const uint8_t D4 = 2;
static const uint8_t D5 = 14;
static const uint8_t D6 = 12;
static const uint8_t D7 = 13;
static const uint8_t D8 = 15;
static const uint8_t D9 = 3;
static const uint8_t D10 = 1;