准备工作

1.NodeMCU模块

2.ESP8266Flasher.exe

3.EspTouch.apk

3.docker toolbox(win7系统) 或 docker(win10以上),本教程是在win7系统上开发,Win7安装Docker

选择构建固件方式

NodeMCU入门(2):在线构建、刷入固件,上传代码 中提到固件编译有三种方式,官方说明,当时我们选择了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服务器,配置网络连接之后想实现SmartConfig时,需要执行wifi.startsmart()方法。

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

执行报错:

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]: ?

这问题真的郁闷了半天,构建固件时选择了wifi模块为什么不能调用startsmart?!仔细看文档、仔细看文档、仔细看文档。。。

默认没有开启,这坑货啊,这么常用的功能竟然没开启,无奈之下智能自己动手丰衣足食了。

刚开始是想采用第三种方式Linux Build Environment,因为看到过有大神封装了一个visualbox的虚机提供下载(现在找不到链接了),也找到了中文的教程nodemcu固件编译方法(不是很懂),post in the esp8266.com Wiki  一大片英文字母(感觉有难度)。以前接触过docker,所以就选择Docker Image方式吧。

构建固件

1. 安装Docker

win7系统参考Win7安装Docker,其它系统参考 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(替换成你的账号名字)\nodemcu-firmware目录下。

  

3.运行nodemcu-build,编译固件

运行docker输入如下命令:

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

然后开始编译,这个过程要等很久,我这大约半个多小时。

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

刷入固件到NodeMCU模块

没有了保护的模块信息以及版本信息,看着不爽哈,外国小朋友也提出来了,http://stackoverflow.com/questions/41102558/general-questions-about-docker-nodemcu-build

问题

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都放开。有的默认就开了,没有放开的就把前面的注释去掉。

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.刷固件,重启模块,没有把预期的模块信息显示出来有点小失望。

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

上传代码,通过手机上的EspTouch测试SmartConfig功能。

完美,准备睡觉已经到两点半了。。。。。

参考链接

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

NodeMCU入门(5):Docker Image 构建固件,开启SmartConfig的更多相关文章

  1. NodeMCU入门(2):在线构建、刷入固件,上传代码

    准备工作 1.NodeMCU模块 2.ESP8266Flasher.exe 3.ESPlorer v0.2.0-rc6 构建固件 Building the firmware提供了三种构建你自己固件的方 ...

  2. NodeMCU入门(4):搭建Web服务器,配置网络连接

    准备工作 1.NodeMCU模块 2.ESPlorer v0.2.0-rc6 3.NodeMCU-HTTP-Server 搭建web服务器 下载https://github.com/wangzexi/ ...

  3. docker+mysql 构建数据库的主从复制

    docker+mysql 构建数据库的主从复制 在最近的项目中,决定将项目改造成数据库读写分离的架构,后续会有博文详细讲述我的开发改造,本文主要记录我是如何一步步的构建数据库的主从复制. 为什么使用d ...

  4. 用前端姿势玩docker【四】基于docker快速构建webpack的开发与生产环境

    目录 用前端姿势玩docker[一]Docker通俗理解常用功能汇总与操作埋坑 用前端姿势玩docker[二]dockerfile定制镜像初体验 用前端姿势玩docker[三]基于nvm的前端环境构建 ...

  5. IDEA使用Docker插件构建镜像

    IDEA使用Docker插件构建镜像 记一次坑  第一次插件docker-maven-plugin的 配置文件中没写远程主机的地址 <dockerHost>http://192.168.1 ...

  6. Docker镜像构建的两种方式(六)--技术流ken

    镜像构建介绍 在什么情况下我们需要自己构建镜像那? (1)当我们找不到现有的镜像,比如自己开发的应用程序 (2)需要在镜像中加入特定的功能 docker构建镜像有两种方式:docker commit命 ...

  7. docker学习构建镜像---第三章节

    一.docker镜像使用 运行docker容器时,使用的镜像如果在本地不存在,docker会自动从docker镜像仓库中下载,默认是从docker hub公共镜像源下载 在这里,我们需要了解:管理和使 ...

  8. docker环境安装与开启远程访问

    一,安装docker 1,服务器安装 docker yum install docker 直接yum安装版本太低 2,卸载:老版本的Docker在yum中名称为docker或docker-engine ...

  9. 老毛子 Padavan 路由器固件开启教育网 IPv6 并实现IPv6转发

    老毛子 Padavan 路由器固件开启教育网 IPv6 并实现IPv6转发 文章目录[隐藏] 一.开启opt环境 二.开启 WAN 端 IPv6 三.安装并运行 6relayd 四.开机自动安装并配置 ...

随机推荐

  1. 什么是PROFINET IO系统的实时性

    实时系统是指系统能及时响应外部事件的请求,在规定的时间内完成对该事件的处理,并控制所有实时任务协调一致的运行. PROFINET IO系统的实时性就是指当有一个外部事件发生时,从输入信号到传输.到控制 ...

  2. Mvc Ajax提交多个checkbox,也说绑定和提交select

    Ajax Mvc的 checkbox 后端必须是List<T> ,T是ID类型,一般int 或guid 模型必须初始化List<T> 防止客户端没有提交任何值时空引用的问题,如 ...

  3. VueJS 事件修饰符

    事件修饰符 在事件处理程序中调用 event.preventDefault() 或 event.stopPropagation()是非常常见的需求.尽管我们可以在 methods 中轻松实现这点,但更 ...

  4. ElasticSearch-5.3.1集群环境搭建,安装ElasticSearch-head插件,安装错误解决

    说起来甚是惭愧,博主在写这篇文章的时候,还没有系统性的学习一下ES,只知道可以拿来做全文检索,功能很牛逼,但是接到了任务不想做也不行, leader让我搭建一下分布式的ES集群环境,用来支持企业信用数 ...

  5. 数据库之Oracle(一)

    前段时间项目中需要做数据管理和迁移的工作,于是又重新拾起了数据库,在javaEE阶段,我们对于数据库的使用仅限于DML(insert,update,delete,select).数据库的使用也比较狭隘 ...

  6. 二分图的最大匹配——最大流EK算法

    序: 既然是个图,并且求边数的最大值.那么这就可以转化为网络流的求最大流问题. 只需要将源点与其中一子集的所有节点相连,汇点与另一子集的所有节点相连,将所有弧的流量限制置为1,那么最大流 == 最大匹 ...

  7. js原型链部分详细使用说明案例

    1. 'index.html'文件 ```html <!DOCTYPE html> <html lang="en"> <head> <me ...

  8. poj2774 Long Long Message 后缀数组求最长公共子串

    题目链接:http://poj.org/problem?id=2774 这是一道很好的后缀数组的入门题目 题意:给你两个字符串,然后求这两个的字符串的最长连续的公共子串 一般用后缀数组解决的两个字符串 ...

  9. 机器学习:从编程的角度理解BP神经网络

    1.简介(只是简单介绍下理论内容帮助理解下面的代码,如果自己写代码实现此理论不够) 1) BP神经网络是一种多层网络算法,其核心是反向传播误差,即: 使用梯度下降法(或其他算法),通过反向传播来不断调 ...

  10. 【wannacry病毒之暗网】-如何访问"暗网"(慎入)

    心里能力不强的人,请别看. 有些事情还是不要接触比较好, 社会最恶一面不是随随便便就能接触到的, 也不是你能理解的 你想要用暗网做什么是你考虑的一个问题 什么是暗网? 所谓的"暗网" ...