準(zhǔn)備工作

1.NodeMCU模塊

2.ESP8266Flasher.exe

3.EspTouch.apk

3.docker toolbox(win7系統(tǒng)) 或 docker(win10以上),本教程是在win7系統(tǒng)上開發(fā),Win7安裝Docker

選擇構(gòu)建固件方式

NodeMCU入門(2):在線構(gòu)建、刷入固件,上傳代碼 中提到固件編譯有三種方式,官方說(shuō)明,當(dāng)時(shí)我們選擇了Cloud Build Service。

Tools

Cloud Build Service

NodeMCU "application developers" just need a ready-made firmware. There's a cloud build servicewith a nice UI and configuration options for them.

Docker Image

Occasional NodeMCU firmware hackers don't need full control over the complete tool chain. They might not want to setup a Linux VM with the build environment. Docker to the rescue. Give Docker NodeMCU build a try.

Linux Build Environment

NodeMCU firmware developers commit or contribute to the project on GitHub and might want to build their own full fledged build environment with the complete tool chain. There is a post in the esp8266.com Wiki that describes this.

做完NodeMCU入門(4):搭建Web服務(wù)器,配置網(wǎng)絡(luò)連接之后想實(shí)現(xiàn)SmartConfig時(shí),需要執(zhí)行wifi.startsmart()方法。

wifi.setmode(wifi.STATION)
wifi.startsmart(0,    function(ssid, password)        print(string.format("Success. SSID:%s ; PASSWORD:%s", ssid, password))    end)

執(zhí)行報(bào)錯(cuò):

NodeMCU custom build by frightanic.com
branch: master
commit: c8ac5cfb912ff206b03dd7c60ffbb2dafb83fe5e
SSL: true
modules: crypto,file,gpio,http,mqtt,net,node,pwm,sjson,tmr,uart,wifi,tls
build built on: 2017-06-10 01:42
powered by Lua 5.1.4 on SDK 2.1.0(116b762)
lua: init.lua:2: attempt to call field 'startsmart' (a nil value)
stack traceback:
init.lua:2: in main chunk
[C]: ?

這問(wèn)題真的郁悶了半天,構(gòu)建固件時(shí)選擇了wifi模塊為什么不能調(diào)用startsmart?!仔細(xì)看文檔、仔細(xì)看文檔、仔細(xì)看文檔。。。

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

默認(rèn)沒有開啟,這坑貨啊,這么常用的功能竟然沒開啟,無(wú)奈之下智能自己動(dòng)手豐衣足食了。

剛開始是想采用第三種方式Linux Build Environment,因?yàn)榭吹竭^(guò)有大神封裝了一個(gè)visualbox的虛機(jī)提供下載(現(xiàn)在找不到鏈接了),也找到了中文的教程nodemcu固件編譯方法(不是很懂),post in the esp8266.com Wiki  一大片英文字母(感覺有難度)。以前接觸過(guò)docker,所以就選擇Docker Image 方式吧。

構(gòu)建固件

1. 安裝Docker

win7系統(tǒng)參考Win7安裝Docker,其它系統(tǒng)參考 https://docs.docker.com/ → 'Get Started' 

 2.獲取NodeMCU固件代碼

 git clone https://github.com/nodemcu/nodemcu-firmware.git

   也可以在瀏覽器中打開 https://github.com/nodemcu/nodemcu-firmware.git,下載壓縮包,然后解壓到C:\Users\zhaobaolong(替換成你的賬號(hào)名字)\nodemcu-firmware目錄下。

  iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

3.運(yùn)行nodemcu-build,編譯固件

 運(yùn)行docker輸入如下命令:

docker run --rm -it -v "//C/Users/zhaobaolong/nodemcu-firmware":/opt/nodemcu-firmware marcelstoer/nodemcu-build

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

 然后開始編譯,這個(gè)過(guò)程要等很久,我這大約半個(gè)多小時(shí)。

 iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

最后在C:\Users\zhaobaolong\nodemcu-firmware\bin目錄下生成了固件文件

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

 

 刷入固件到NodeMCU模塊

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

沒有了保護(hù)的模塊信息以及版本信息,看著不爽哈,外國(guó)小朋友也提出來(lái)了,http://stackoverflow.com/questions/41102558/general-questions-about-docker-nodemcu-build

問(wèn)題

Some general questions about the docker nodemcu-build process:

  1. Is there a way to specify which modules are included in the build? (similar to the way the cloud build service works)

  2. Is there a way to include a description that will appear when the resultant firmware is run?

  3. Is SSL enabled?

  4. The size of the bin file created by the docker nodemcu-build process (from dev branch source) is 405k. A recent build using the cloud service resulted in a bin file of size 444k. The cloud service build only included the following modules: cjson, file, gpio, http, net, node, tmr, uart, wifi, ssl. Why is the docker build bin file, that contains all modules(?), smaller than the cloud build bin file that only contains 10 modules? (i am concerned that my local docker build version is missing something - even though the build process was error free).

答案:

  1. You specify the modules to be built by uncommenting them in the /app/include/user_modules.hfile in the source tree. The default build from the source tree is relatively minimal - not an "all modules" build.

  2. The banner at connection is the "Version" field. The nodemcu-build.com builds change this out for custom text. It is defined in /app/include/user_version.h as the USER_VERSION define. You'll need to embed "\n" newlines in the string to get separate lines.

  3. Yes, the Net module can include limited SSL support (TLS 1.1 only) (TLS 1.2 in dev per Marcel's comment below). You need to enable it in /app/include/user_config.h by defining CLIENT_SSL_ENABLE.

  4. The default module and config setup in user_modules.h / user_config.h is different than the defaults on nodemcu-build.com, so the builds are not likely to be the same out of the box.

 

修改固件重新編譯,刷固件 

1.修改\app\include\user_modules.h文件,把 crypto file gpio http mqtt net node pwm sjson tmr uart wifi都放開。有的默認(rèn)就開了,沒有放開的就把前面的注釋去掉。

2.修改\app\include\user_config.h文件,把 //#define WIFI_SMART_ENABLE開頭的注釋去掉,//#define CLIENT_SSL_ENABLE 開頭的注釋也去掉

3.修改\app\include\user_version.h文件,修改 #define __USER_VERSION_H__ "NodeMCU custom build by zeroes QQ305744659"

4. 保存文件后重新編譯,20多分鐘完成

docker run --rm -it -v "//C/Users/zhaobaolong/nodemcu-firmware":/opt/nodemcu-firmware marcelstoer/nodemcu-build

5.刷固件,重啟模塊,沒有把預(yù)期的模塊信息顯示出來(lái)有點(diǎn)小失望。

wifi.setmode(wifi.STATION)
wifi.startsmart(0,    function(ssid, password)        print(string.format("Success. SSID:%s ; PASSWORD:%s", ssid, password))    end)

 上傳代碼,通過(guò)手機(jī)上的EspTouch測(cè)試SmartConfig功能。

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

完美,準(zhǔn)備睡覺已經(jīng)到兩點(diǎn)半了。。。。。

 

參考鏈接 

http://espressif.com/zh-hans/support/explore/get-started/esp8266/getting-started-guide  

分類: IoT

準(zhǔn)備工作

1.NodeMCU模塊

2.ESP8266Flasher.exe

3.EspTouch.apk

3.docker toolbox(win7系統(tǒng)) 或 docker(win10以上),本教程是在win7系統(tǒng)上開發(fā),Win7安裝Docker

選擇構(gòu)建固件方式

NodeMCU入門(2):在線構(gòu)建、刷入固件,上傳代碼 中提到固件編譯有三種方式,官方說(shuō)明,當(dāng)時(shí)我們選擇了Cloud Build Service。

Tools

Cloud Build Service

NodeMCU "application developers" just need a ready-made firmware. There's a cloud build servicewith a nice UI and configuration options for them.

Docker Image

Occasional NodeMCU firmware hackers don't need full control over the complete tool chain. They might not want to setup a Linux VM with the build environment. Docker to the rescue. Give Docker NodeMCU build a try.

Linux Build Environment

NodeMCU firmware developers commit or contribute to the project on GitHub and might want to build their own full fledged build environment with the complete tool chain. There is a post in the esp8266.com Wiki that describes this.

做完NodeMCU入門(4):搭建Web服務(wù)器,配置網(wǎng)絡(luò)連接之后想實(shí)現(xiàn)SmartConfig時(shí),需要執(zhí)行wifi.startsmart()方法。

wifi.setmode(wifi.STATION)
wifi.startsmart(0,    function(ssid, password)        print(string.format("Success. SSID:%s ; PASSWORD:%s", ssid, password))    end)

執(zhí)行報(bào)錯(cuò):

NodeMCU custom build by frightanic.com
branch: master
commit: c8ac5cfb912ff206b03dd7c60ffbb2dafb83fe5e
SSL: true
modules: crypto,file,gpio,http,mqtt,net,node,pwm,sjson,tmr,uart,wifi,tls
build built on: 2017-06-10 01:42
powered by Lua 5.1.4 on SDK 2.1.0(116b762)
lua: init.lua:2: attempt to call field 'startsmart' (a nil value)
stack traceback:
init.lua:2: in main chunk
[C]: ?

這問(wèn)題真的郁悶了半天,構(gòu)建固件時(shí)選擇了wifi模塊為什么不能調(diào)用startsmart?!仔細(xì)看文檔、仔細(xì)看文檔、仔細(xì)看文檔。。。

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

默認(rèn)沒有開啟,這坑貨啊,這么常用的功能竟然沒開啟,無(wú)奈之下智能自己動(dòng)手豐衣足食了。

剛開始是想采用第三種方式Linux Build Environment,因?yàn)榭吹竭^(guò)有大神封裝了一個(gè)visualbox的虛機(jī)提供下載(現(xiàn)在找不到鏈接了),也找到了中文的教程nodemcu固件編譯方法(不是很懂),post in the esp8266.com Wiki  一大片英文字母(感覺有難度)。以前接觸過(guò)docker,所以就選擇Docker Image 方式吧。

構(gòu)建固件

1. 安裝Docker

win7系統(tǒng)參考Win7安裝Docker,其它系統(tǒng)參考 https://docs.docker.com/ → 'Get Started' 

 2.獲取NodeMCU固件代碼

 git clone https://github.com/nodemcu/nodemcu-firmware.git

   也可以在瀏覽器中打開 https://github.com/nodemcu/nodemcu-firmware.git,下載壓縮包,然后解壓到C:\Users\zhaobaolong(替換成你的賬號(hào)名字)\nodemcu-firmware目錄下。

  iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

3.運(yùn)行nodemcu-build,編譯固件

 運(yùn)行docker輸入如下命令:

docker run --rm -it -v "//C/Users/zhaobaolong/nodemcu-firmware":/opt/nodemcu-firmware marcelstoer/nodemcu-build

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

 然后開始編譯,這個(gè)過(guò)程要等很久,我這大約半個(gè)多小時(shí)。

 iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

最后在C:\Users\zhaobaolong\nodemcu-firmware\bin目錄下生成了固件文件

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

 

 刷入固件到NodeMCU模塊

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

沒有了保護(hù)的模塊信息以及版本信息,看著不爽哈,外國(guó)小朋友也提出來(lái)了,http://stackoverflow.com/questions/41102558/general-questions-about-docker-nodemcu-build

問(wèn)題

Some general questions about the docker nodemcu-build process:

  1. Is there a way to specify which modules are included in the build? (similar to the way the cloud build service works)

  2. Is there a way to include a description that will appear when the resultant firmware is run?

  3. Is SSL enabled?

  4. The size of the bin file created by the docker nodemcu-build process (from dev branch source) is 405k. A recent build using the cloud service resulted in a bin file of size 444k. The cloud service build only included the following modules: cjson, file, gpio, http, net, node, tmr, uart, wifi, ssl. Why is the docker build bin file, that contains all modules(?), smaller than the cloud build bin file that only contains 10 modules? (i am concerned that my local docker build version is missing something - even though the build process was error free).

答案:

  1. You specify the modules to be built by uncommenting them in the /app/include/user_modules.hfile in the source tree. The default build from the source tree is relatively minimal - not an "all modules" build.

  2. The banner at connection is the "Version" field. The nodemcu-build.com builds change this out for custom text. It is defined in /app/include/user_version.h as the USER_VERSION define. You'll need to embed "\n" newlines in the string to get separate lines.

  3. Yes, the Net module can include limited SSL support (TLS 1.1 only) (TLS 1.2 in dev per Marcel's comment below). You need to enable it in /app/include/user_config.h by defining CLIENT_SSL_ENABLE.

  4. The default module and config setup in user_modules.h / user_config.h is different than the defaults on nodemcu-build.com, so the builds are not likely to be the same out of the box.

 

修改固件重新編譯,刷固件 

1.修改\app\include\user_modules.h文件,把 crypto file gpio http mqtt net node pwm sjson tmr uart wifi都放開。有的默認(rèn)就開了,沒有放開的就把前面的注釋去掉。

2.修改\app\include\user_config.h文件,把 //#define WIFI_SMART_ENABLE開頭的注釋去掉,//#define CLIENT_SSL_ENABLE 開頭的注釋也去掉

3.修改\app\include\user_version.h文件,修改 #define __USER_VERSION_H__ "NodeMCU custom build by zeroes QQ305744659"

4. 保存文件后重新編譯,20多分鐘完成

docker run --rm -it -v "//C/Users/zhaobaolong/nodemcu-firmware":/opt/nodemcu-firmware marcelstoer/nodemcu-build

5.刷固件,重啟模塊,沒有把預(yù)期的模塊信息顯示出來(lái)有點(diǎn)小失望。

wifi.setmode(wifi.STATION)
wifi.startsmart(0,    function(ssid, password)        print(string.format("Success. SSID:%s ; PASSWORD:%s", ssid, password))    end)

 上傳代碼,通過(guò)手機(jī)上的EspTouch測(cè)試SmartConfig功能。

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

iOS培訓(xùn),Swift培訓(xùn),蘋果開發(fā)培訓(xùn),移動(dòng)開發(fā)培訓(xùn)

完美,準(zhǔn)備睡覺已經(jīng)到兩點(diǎn)半了。。。。。

 

參考鏈接 

http://espressif.com/zh-hans/support/explore/get-started/esp8266/getting-started-guide  

http://www.cnblogs.com/zeroes/p/nodemcu_build_smartconfig.html