Compiling ESP8266 Legacy App with SDK 1.1.1

SDK

Have you ever upgraded to a newer version of software or operating system, only to find once working Apps suddenly broken? And now it is not so easy to turn back…

I ran into this sort of thing with the ESP8266 SDK version 1.1.1. It had fixes for the problems I had been experiencing, but my application would no longer compile without error. Yep, this SDK was not compatible with programs developed using my earlier SDK (1.0.1). Some things were added. One item was now required, yet it did not exist before version 1.1.1. Still other features were removed.

Even the IoT_Demo example included with this latest version would not build successfully.

This upgrade started to rub me the wrong way. But finally, through some code review, minor modifications and interaction with EspressIf, the incompatibilities I had encountered were eventually sorted out.

Here is what I discovered and had to change to build an older application (based on the IoT_Demo example) with the improvements offered with SDK 1.1.1. So you can minimize the upgrade challenges and move on. To focus on your latest creation.

Tweaking your application for SDK 1.1.1 compatibility

1. The structure “rst_info” in user_interface.h has changed.

From this:

struct rst_info{
    uint32 <strong>flag</strong>;
    uint32 exccause;
    uint32 epc1;
    uint32 epc2;
    uint32 epc3;
    uint32 excvaddr;
    uint32 depc;
};

To this:

struct rst_info{
    uint32 <strong>reason</strong>;
    uint32 exccause;
    uint32 epc1;
    uint32 epc2;
    uint32 epc3;
    uint32 excvaddr;
    uint32 depc;
};

This will require a change to the structure reference in the function user_esp_platform_init(void) in the file user_esp_platform.c. Change all references from rtc_info.flag to rtc_info.reason.

2. PULLDWN has been removed.

The code statements need to be removed or commented out in the gpio16.c file:

	switch(pull) {
		case GPIO_PULLUP:
			//PIN_PULLDWN_DIS(pin_mux[pin]);
			PIN_PULLUP_EN(pin_mux[pin]);
			break;
		case GPIO_PULLDOWN:
			PIN_PULLUP_DIS(pin_mux[pin]);
			//PIN_PULLDWN_EN(pin_mux[pin]);
			break;
		case GPIO_FLOAT:
			PIN_PULLUP_DIS(pin_mux[pin]);
			//PIN_PULLDWN_DIS(pin_mux[pin]);
			break;
		default:
			PIN_PULLUP_DIS(pin_mux[pin]);
			//PIN_PULLDWN_DIS(pin_mux[pin]);
			break;
	}

NOTE: My application also called “PIN_PULLDWN_DIS” in ds18b20.c. If you are using the ds18b20.c or any other library that calls “PIN_PULLDWN_DIS”, it will need to be removed or commented out.
3. “user_main.c” now is required to include the function “user_rf_pre_init().

void user_rf_pre_init(void)
{
	system_phy_set_rfoption(2);
}

You do not need to include a call to “system_phy_set_rfoption()” in this function, but this is the ONLY function that allows this function to be called. If interested in learning more, refer to the latest SDK programming guide for this new feature.

4. The “Make” file is missing a required library.

Add “pwm” to the LIB line in the Make file for a successful application build:

# libraries used in this project, mainly provided by the SDK
LIBS		= c gcc hal phy pp net80211 lwip wpa <strong>pwm</strong> main json upgrade

And with these minor adjustments, I have successfully built my previously built App using SDK 1.1.1.

This is quite thrilling for me and I hope you too have success using SDK 1.1.1 and beyond. For me, this is the best SDK version yet.

The issues I had in the past with the Wifi server failing to respond to requests (STATION Mode) after about a minute and the AP mode simply not working with Android devices are gone.

Now we can focus on creating amazing things, with all the features of the always improving SDK APIs. From my experience, the SDK is by far the most capable environment to build your IoT visions available for the cheap yet capable ESP8266.

I hope you find this information useful.

Loading

Share This:
FacebooktwitterredditpinterestlinkedintumblrFacebooktwitterredditpinterestlinkedintumblr
Social tagging: > >

Leave a Reply