ESP8266 Unofficial Windows Development Environment

A Restart in 2018


It has been long time since I worked on ESP8266 and that too native SDK from Esperssif. With the rusty know-how and lack on info online, I had a mixed start again. Hope that the experience shared here might be helpful for many users, who wish to do ESP8266 native SDK development on Windows Platform. But are afraid that most of the working tools for ESP8266 are linux friendly.

Not to worry you are in good company.

Most of Windows users like myself first try to see if there are any docker alternatives.

But if you try to build the tool-chain on your own you can land-up deep into troubled waters. Its not impossible but takes lots of bandwidth, space and hair ripping to get a working setup.

The I found an old repository I had worked on long back fixing some issues:

https://github.com/boseji/esp8266-devkit

Well its a fork of the original work:

https://github.com/CHERTS/esp8266-devkit

Mr. Mikhail Grigorev has been kind enough to provide us with packaged installer.

Yet, getting re-started was not straight forward.

It took actually effort of 2 days. Getting a basic program running on Wemos D1 Mini. That hosts the ESP-12E Module of ESP8266.

Here is how you can avoid suffering. And have a quick running setup,


Getting All stuff Downloaded & Installed

There are 3 main pieces of software that needs to be installed in your windows machine.

#1 Unofficial DevKit for ESP8266 v2.2.1

Icon image of the Unofficial DevKit for ESP8266 v2.2.1

Espressif-ESP8266-DevKit-v2.2.1-x86.exe

MD5: ca6ba36c2dc9c3821c1e631d1d7c8580

From the website released nearly 2 years ago but still works great if used correctly.

Links:

This can be installed without any fear of corruption or damage to your already delicate Windows machine.

Just that this would create C:\Espressif directory where all would get installed.

We would revisit this directory when we finish the MinGW installation and to upgrade the SDK from Espressif.

#2 MinGW Setup

Image of MinGW Installer

This is the special sauce needed to do Makefile stuff and provide the tools needed to emulate Linux tools.

For more experienced user WARNING : Please do not add the c:\MinGW etc. to path. The toolchain discussed here would intelligently include stuff needed to work with tools inside MinGW / Msys.

Links:

In the MinGW setup

Make sure to select the following choices to install:

Image of options to install in MinGW

Next

NOTE : In my case I had already installed the MinGW tools so the Apply Changes is not highlighted. In a fresh installation this must get enabled

Image of Install Dependency location MinGW Installer

Just press the Apply Changes begin the installation.

#3 Eclipse IDE

Choose the respective Windows architectures X86 = 32-bit X64 = 64-bit for

CDT Icon Eclipse IDE for C/C++ Developers

Links:

Just choose which ever install comes latest do not worry about version of Eclipse CDT or flavor.

Make sure to setup the Workspace directory as described or as you desire while opening the Eclipse IDE for the first time.

#3.5 Missing JRE !!! ERROR

Yep, I too missed this Not to worry …

You can Search or directly go to Oracle JAVA SE runtime

Check the Accept License Agreement and then click on correct version of Windows architecture.

Make sure this is aligned with your Eclipse architecture that was downloaded earlier.

Links:


Working with Code

Now its time to make comfortable with the workspace.

#1 Getting the Example Code

Typically the example code is stored in :

c:\Espressif\examples\ESP8266

We are interested in keeping the originals pristine.

Hence we would copy this ESP8266 folder to our work-space.

This is the same workspace as what’s recommended by eclipse.

NOTE : In my case I have the location at C:\home\Temp\eclipse-workspace.
I know that’s a strange place to keep the files but lets just roll with that.

Finally your setup should look like

c:\<Your Eclipse Wrokspace>\ESP8266

This where all the examples shall be copied.

#2 Importing Projects in Eclipse

NOTE : By default each of the project is configured for default configuration of ESP-01 that’s with a 512KB flash. And the programming serial port is configured on COM2.

That’s the thing I missed to Note while trying out the SDK.

We would configure the stuff properly so that – we don’t land up in non working board + anguish and lot of head-banging.

Don’t worry we would get through this together

First things first

Get the project imported

Note : This is Eclipse IDE Photon Release (4.8.0) other might not differ significantly but just in case.

Selecting Import in Eclipse

Now select the Correct type to import:

Project Workspace Import in Eclipse

From Browse... button Select the Blinky2 Project Folder Only.

And click Select Folder button in the open dialog

There is distinct reason to choose this project since its easier to understand modify.

Selecting the Correct Project and Import in Eclipse

Press Finish button to complete the import.

Imported ESP8266 project in Eclipse

#3 Configuring the Project

Now, we are all set with IDE and the software.

The crucial part of Makefile modification is needed.

By Default the Makefile should look like:

# Main settings includes
include	../settings.mk

# Individual project settings (Optional)
#BOOT		= new
#APP		= 1
#SPI_SPEED	= 40
#SPI_MODE	= QIO
#SPI_SIZE_MAP	= 2
#ESPPORT		= COM2
#ESPBAUD		= 256000

# Basic project settings
MODULES	= driver user
LIBS	= c gcc hal phy pp net80211 lwip wpa main crypto

# Root includes
include	../common_nonos.mk

Note the two important pieces:

include	../settings.mk

...

include	../common_nonos.mk

The first line actually is used to setup the defaults.

The last line indicates the processing for NON-OS SDK.

We don’t have to mess around with file includes and correct file list etc. The Makefile script common_nonos.mk does all that automatically.

All that we now need is configure the project settings in this Makefile.

Typically for ESP-01 the additional configuration looks like:

# Switching to DIO mode for Flash as there might be poor PCB routing
SPI_MODE	= DIO
# Change the COM port based on your PC and USB-to-UART adapter
ESPPORT		= COM10

So the new Makefile would become:

# Main settings includes
include	../settings.mk

# Individual project settings (Optional)
#BOOT		= new
#APP		= 1
#SPI_SPEED	= 40
#SPI_MODE	= QIO
#SPI_SIZE_MAP	= 2
#ESPPORT		= COM2
#ESPBAUD		= 256000

# Switching to DIO mode for Flash as there might be poor PCB routing
SPI_MODE	= DIO
# Change the COM port based on your PC and USB-to-UART adapter
ESPPORT		= COM10

# Basic project settings
MODULES	= driver user
LIBS	= c gcc hal phy pp net80211 lwip wpa main crypto

# Root includes
include	../common_nonos.mk

Note : the location of the modified setting is crucial. Else that would not effect the build output.

With this modifications we are ready to test the blinky2 example with our ESP-01 module.

#4 Build and Load the Code

On the Build Targets double click all item.

That should initiate the build.

Build output in Eclipse

Now set the ESP8266 in Bootloader Mode.

Finally double click on flash build target.

Flashing output in Eclipse

Everting goes well you would have a blinking LED on the ESP-01 Module.


How to Update to the Latest SDK

The packaged NON-OS SDK in Espressif-ESP8266-DevKit-v2.2.1-x86.exe is v2.0.0.

But, one might like to have the Latest NON-OS SDK

Presently its v2.2.1 as on August 2018.

First we can download the Latest SDK:

#1 Extract

Typically the files would extract into their unique folder.

E.g.

for ESP8266_NONOS_SDK-2.2.1.zip it would be extracted to ESP8266_NONOS_SDK-2.2.1

It must be such that ESP8266_NONOS_SDK-2.2.1\Makefile should be the folder structure.

Note : Make sure that the directory ESP8266_NONOS_SDK-2.2.1 should have the Main Makefile of the SDK else integration would fail. Its common mistake to have a directory such as ESP8266_NONOS_SDK-2.2.1\ESP8266_NONOS_SDK-2.2.1\Makefile.

#2 Copy

Once you have the file correctly extracted.

Copy it to the C:\Espressif directory.

We would be considering upgrade for the NON-OS SDK to ESP8266_NONOS_SDK-2.2.1

#3 Rename the Original

Now rename the C:\Espressif\ESP8266_SDK to C:\Espressif\ESP8266_SDK_original

#4 Update the SDK

Create a Copy the C:\Espressif\ESP8266_NONOS_SDK-2.2.1 in the same C:\Espressif directory.

Rename the copy of the ESP8266_NONOS_SDK-2.2.1 as ESP8266_SDK

Such that we have:

C:\Espressif\ESP8266_NONOS_SDK\Makefile == C:\Espressif\ESP8266_NONOS_SDK-2.2.1\Makefile

That’s It, you have successfully Upgraded your SDK


Common Makefile values

Now to make your hair stay ;-)

Here is some configuration examples for Makefile typically useful

ESP-12F Configuration

For OTA configuration (512 KB + 512 KB):

# SPI_SIZE_MAP
# 0 : 512 KB (256 KB + 256 KB)
# 1 : 256 KB
# 2 : 1024 KB (512 KB + 512 KB)
# 3 : 2048 KB (512 KB + 512 KB)
# 4 : 4096 KB (512 KB + 512 KB)
# 5 : 2048 KB (1024 KB + 1024 KB)
# 6 : 4096 KB (1024 KB + 1024 KB)
SPI_SIZE_MAP = 4

Here apart from the OTA allocation of 512KB for secondary firmware, we have 512KB for primary firmware.

One can also use the 6 configuration such that OTA = 1024KB + FW = 1024KB.

For Poor PCB wiring

Typically cheaper modules do not have good signal integrity on the PCB of the module. That can cause problems in normal operation. Or worst get interfered by external noise.

# SPI_SPEED = 40, 26, 20, 80
SPI_SPEED = 40
# SPI_MODE: QIO, QOUT, DIO, DOUT
SPI_MODE = DIO

If you have an Official WROOM Module from Espressif then you can use:

# SPI_SPEED = 40, 26, 20, 80
SPI_SPEED = 80
# SPI_MODE: QIO, QOUT, DIO, DOUT
SPI_MODE = QIO

Note : This is the fastest setting of Flash operation use this with caution. Some times voltage dips can cause Reset issues. In case you have Low power or Battery operated design Do not use this

Bootloader selection

# BOOT = none
# BOOT = old - boot_v1.1
# BOOT = new - boot_v1.2+
BOOT = none

Typically if you are doing simpler development you might not need the secondary bootloader stuff. Its needed if you want to use OTA and WiFi .etc.

However for finished products its best to have an upgrade capability hence on should use:

# BOOT = none
# BOOT = old - boot_v1.1
# BOOT = new - boot_v1.2+
BOOT = new

Note : This setting might have issues in ESP8266_NONOS_SDK-2.2.1. In order to resolve that just copy C:\Espressif\ESP8266_SDK\bin\esp_init_data_default_v08.bin to C:\Espressif\ESP8266_SDK\bin\esp_init_data_default.bin. That should resolve the build problem.


Log:

Completed on: 12th August 2018

TODO:

  • Add New project Creation details
  • Add RTOS and C++ Examples
 
comments powered by Disqus