Fix Invalid Request Code Error When Building Sming Code on Windows

Hello! This is officialy my first post on this site. Today i'll describe my solution to the following error when building Basic_Blink sample after installing Sming using chocolatey on Windows:

make: *** c:/tools/sming/Sming: Invalid request code.  Stop.  

I am using Windows 8, and here's my story:

When i first got that error message, i googled the error message as keyword and then i was led to this issue on Sming respository. A person with github username GavinAndrews has the same issue and offered his own solution on that page. But, when i tried his solution the same error message still appears.

I recommend you to follow his instruction and if you solve the problem, you can stop here and start making things and code. If you still get the same error, you are welcomed to continue reading this post.

Environment Variable Checking

Ok, now i want you to make sure that you have the following key-value pairs on your environment variable.

ESP_HOME: c:\Espressif  
SMING_HOME: c:\tools\sming\Sming  

You can check them by running the following commands on your command prompt window.

echo %ESP_HOME%  
echo %SMING_HOME%  

Those 2 commands should produce the following output:


You see them? Good. Now lets move to the next step.

You don't see them? Please define them by clicking on Control Panel, then find System, then click Advanched system settings on the left. When system properties dialog pop up, click on Environment Variable button on the bottom of the dialog window. Then you can click New on either user or system variable section. Then input ESP_HOME as the name, and c:\Espressif as the value and then do the same way to add SMING_HOME variable.

Building Sming

Run command prompt as administrator and execute following command


Then, open explorer and go to c:\tools\sming\Sming directory and edit file. Find the following lines and uncomment them by removing # on the beginning of each line.

# ESP_HOME = c:/Espressif
# SMING_HOME = c:/tools/sming/Sming 

You know that is not exactly what you find in the file, but i'm sure you see those 2 lines. Let's just keep it simple.

If you uncomment them, they'll look like this:

ESP_HOME = c:/Espressif  
SMING_HOME = c:/tools/sming/Sming  

Now, back to your command prompt window. You have to build sming by running the following command:


You'll see something like

AS system/irq_check.s  
CC system/flashmem.c  
CC Services/FATFS/ff.c  
CC Services/SpifFS/spiffs_cache.c  
CC Services/SpifFS/spiffs_check.c  
CC Services/SpifFS/spiffs_gc.c  
CC Services/SpifFS/spiffs_hydrogen.c  
CC Services/SpifFS/spiffs_nucleus.c  
CC Services/SpifFS/spiffs_sming.c  
CC Services/libemqtt/libemqtt.c  
CC Libraries/Adafruit_GFX/glcdfont.c  
CC Libraries/Adafruit_ILI9341/hspi.c  
C+ system/esp_cplusplus.cpp  
C+ system/m_printf.cpp  
C+ system/stringconversion.cpp  
C+ Wiring/FakePgmSpace.cpp  
C+ Wiring/I2cMaster.cpp  
C+ Wiring/IPAddress.cpp  
C+ Wiring/Print.cpp  
C+ Wiring/SplitString.cpp  
C+ Wiring/Stream.cpp  
C+ Wiring/WMath.cpp  
C+ Wiring/WShift.cpp  
C+ Wiring/WString.cpp  
C+ SmingCore/Clock.cpp  
C+ SmingCore/DataSourceStream.cpp  
C+ SmingCore/Debug.cpp  
C+ SmingCore/Digital.cpp  
C+ SmingCore/DriverPWM.cpp  
C+ SmingCore/ESP8266EX.cpp  
C+ SmingCore/FileSystem.cpp  
C+ SmingCore/HardwarePWM.cpp  
C+ SmingCore/HardwareSerial.cpp  
C+ SmingCore/Interrupts.cpp  
C+ SmingCore/SPI.cpp  
C+ SmingCore/SPISoft.cpp  
C+ SmingCore/SystemClock.cpp  
C+ SmingCore/Timer.cpp  
C+ SmingCore/Wire.cpp  
C+ appinit/user_main.cpp  
C+ SmingCore/Network/FTPServer.cpp  
C+ SmingCore/Network/FTPServerConnection.cpp  
C+ SmingCore/Network/HttpClient.cpp  
C+ SmingCore/Network/HttpFirmwareUpdate.cpp  
C+ SmingCore/Network/HttpRequest.cpp  
C+ SmingCore/Network/HttpResponse.cpp  
C+ SmingCore/Network/HttpServer.cpp  
C+ SmingCore/Network/HttpServerConnection.cpp  
C+ SmingCore/Network/MqttClient.cpp  
C+ SmingCore/Network/NetUtils.cpp  
C+ SmingCore/Network/NtpClient.cpp  
C+ SmingCore/Network/TcpClient.cpp  
C+ SmingCore/Network/TcpConnection.cpp  
C+ SmingCore/Network/TcpServer.cpp  
C+ SmingCore/Network/TelnetServer.cpp  
C+ SmingCore/Network/URL.cpp  
C+ SmingCore/Network/UdpConnection.cpp  
C+ SmingCore/Network/WebSocket.cpp  
C+ SmingCore/Network/rBootHttpUpdate.cpp  
C+ SmingCore/Platform/AccessPoint.cpp  
C+ SmingCore/Platform/RTC.cpp  
C+ SmingCore/Platform/Station.cpp  
C+ SmingCore/Platform/System.cpp  
C+ SmingCore/Platform/WDT.cpp  
C+ Services/ArduinoJson/ArduinoJson.cpp  
C+ Services/CommandProcessing/CommandDelegate.cpp  
C+ Services/CommandProcessing/CommandExecutor.cpp  
C+ Services/CommandProcessing/CommandHandler.cpp  
C+ Services/CommandProcessing/CommandOutput.cpp  
C+ Services/DateTime/DateTime.cpp  
C+ Services/WebHelpers/base64.cpp  
C+ Services/WebHelpers/escape.cpp  
C+ Services/cWebsocket/websocket.cpp  
C+ Libraries/Adafruit_GFX/Adafruit_GFX.cpp  
C+ Libraries/Adafruit_ILI9341/Adafruit_ILI9341.cpp  
C+ Libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp  
C+ Libraries/Adafruit_PCD8544/Adafruit_PCD8544.cpp  
C+ Libraries/Adafruit_SSD1306/Adafruit_SSD1306.cpp  
C+ Libraries/BH1750FVI/BH1750FVI.cpp  
C+ Libraries/BMP180/BMP180.cpp  
C+ Libraries/Bounce/Bounce.cpp  
C+ Libraries/CapacitiveSensor/CapacitiveSensor.cpp  
C+ Libraries/DHT/DHT.cpp  
C+ Libraries/DS18S20/ds18s20.cpp  
C+ Libraries/HMC5883L/HMC5883L.cpp  
C+ Libraries/I2Cdev/I2Cdev.cpp  
C+ Libraries/IR/IRremote.cpp  
C+ Libraries/LiquidCrystal/FastIO.cpp  
C+ Libraries/LiquidCrystal/I2CIO.cpp  
C+ Libraries/LiquidCrystal/LCD.cpp  
C+ Libraries/LiquidCrystal/LiquidCrystal.cpp  
C+ Libraries/LiquidCrystal/LiquidCrystal_I2C.cpp  
C+ Libraries/LiquidCrystal/LiquidCrystal_SR.cpp  
C+ Libraries/LiquidCrystal/LiquidCrystal_SR2W.cpp  
C+ Libraries/LiquidCrystal/LiquidCrystal_SR3W.cpp  
C+ Libraries/MMA_7455/MMA_7455.cpp  
C+ Libraries/Mirf/Mirf.cpp  
C+ Libraries/OneWire/OneWire.cpp  
C+ Libraries/RF24/RF24.cpp  
C+ Libraries/SDCard/SDCard.cpp  
C+ Libraries/TFT_ILI9163C/TFT_ILI9163C.cpp  
C+ Libraries/Ultrasonic/Ultrasonic.cpp  
C+ Libraries/WS2812/WS2812.cpp  
C+ Libraries/si4432/si4432.cpp  
AR out/build/app_app.a  
Installing libsming  

Building Sample Code

Move to c:\tools\sming\samples\Basic_Blink directory and run make command.

cd c:\tools\sming\samples\Basic_Blink  

If you still see the following error,

make: *** c:/tools/sming/Sming: Invalid request code.  Stop.  

open file and find the following lines and comment them by adding # on the beginning of each line.

ESP_HOME = c:/Espressif  
SMING_HOME = c:/tools/sming/Sming  

So, above code will look like the following code:

# ESP_HOME = c:/Espressif
# SMING_HOME = c:/tools/sming/Sming 

At this point, you should be able to build the code successfully. Let's make sure the error disappears.

Run make again on your command prompt window. If you see the following lines after running make, the problem is solved. Hooraay!

# Generating image...
Generate firmware images successully in folder out/firmware.  

Installing esptool2

If you see the following message after running make, there's one more problem to be solved. Don't worry, it won't take your whole day to solve it.

# Generating image...
make: esptool2: Command not found  
make: *** [out/build/app.out] Error 127  

The error says that you don't have esptool2 software installed on your windows. You can install it by running the following commands on your command prompt window. Remember, one line at a time.

cd %ESP_HOME%  
git clone  
cd esptool2  

The code above will clone the esptool2 repository and build the source to create esptool2.exe. In order to make those code work, you must have git installed on your windows.

Next, add c:\Espressif\esptool2 to your PATH environment variable.

Then, restart your command prompt and move to c:\tools\sming\samples\Basic_Blink directory and run make again. The problem should be solved.


Thanks for reading my post! I hope you can solve the problem. If you feel this post is useful, please share it to your friends. Cheers!