Visual Studio Code 与 Win10 64bit Ubuntu bash 的ESP8266 编译开发环境搭建(无需编译toolchain)

本文主要是介绍Visual Studio Code 与 Win10 64bit Ubuntu bash 的ESP8266 编译开发环境搭建(无需编译toolchain),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

本文参考如下文章:

1. ESP8266 建立Linux開發環境

2. Win10 Bash搭建ESP8266编译环境(RTOS SDK)

Note:工具链是直接下载的,无需编译

最近重装win系统,然后按照我以前写的博文重新搭建ESP8266编译环境 https://blog.csdn.net/toopoo/article/details/80528536

但是发现如果直接运行Eclipse.exe而不是从安信可IDE.exe启动,那么会导致错误,clean的时候出现"FIND: 参数格式不正确"的错误提示,从bash直接运行也一样,(用安信可一体环境v0.5是没问题的)。

$ make clean
make -C user clean;  make -C driver clean;  make -C Gizwits clean;  make -C Utils clean;
make[1]: Entering directory '/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/user'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
FIND: 参数格式不正确
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/user'
make[1]: Entering directory '/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/driver'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
FIND: 参数格式不正确
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/driver'
make[1]: Entering directory '/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Gizwits'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
FIND: 参数格式不正确
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Gizwits'
make[1]: Entering directory '/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Utils'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
FIND: 参数格式不正确
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Utils'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
FIND: 参数格式不正确
rm -f -r ../bin/upgrade

此时编译也会失败:

$ ./gen_misc.sh
gen_misc.sh version 20150511boot mode: new
app:1
spi speed: 40 MHz
spi mode: QIO
spi_size_map:6
make[1]: Entering directory '/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/user'
DEPEND: xtensa-lx106-elf-gcc -M -Os -g -Wpointer-arith -Wundef -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ./ -I ../../include/ets -I ../include -I ../../include -I ../../include/eagle -I ../..//app/gagent/inc -I ../..//app/Gizwits -I ../..//app/Utils pwm.c
/bin/sh: line 1: /e/ESP8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc: cannot execute binary file: Exec format error
DEPEND: xtensa-lx106-elf-gcc -M -Os -g -Wpointer-arith -Wundef -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ./ -I ../../include/ets -I ../include -I ../../include -I ../../include/eagle -I ../..//app/gagent/inc -I ../..//app/Gizwits -I ../..//app/Utils user_main.c
/bin/sh: line 1: /e/ESP8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc: cannot execute binary file: Exec format error
DEPEND: xtensa-lx106-elf-gcc -M -Os -g -Wpointer-arith -Wundef -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ./ -I ../../include/ets -I ../include -I ../../include -I ../../include/eagle -I ../..//app/gagent/inc -I ../..//app/Gizwits -I ../..//app/Utils user_json.c
/bin/sh: line 1: /e/ESP8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc: cannot execute binary file: Exec format error
xtensa-lx106-elf-gcc -Os -g -Wpointer-arith -Wundef -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections   -DICACHE_FLASH   -I include -I ./ -I ../../include/ets -I ../include  -I ../../include -I ../../include/eagle -I ../..//app/gagent/inc -I ../..//app/Gizwits -I ../..//app/Utils  -o .output/eagle/debug/obj/user_json.o -c user_json.c
/e/ESP8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc: /e/ESP8266/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc: cannot execute binary file
make[1]: *** [../../Makefile:322: .output/eagle/debug/obj/user_json.o] Error 126
make[1]: Leaving directory '/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/user'
make: *** [../Makefile:307: .subdirs] Error 2

说到底就是个Eclipse配置的问题,因为原先是可以的。

顺便试了一下Visual Studio Code, 使用VSC terminal 的bash编译是相同的错误,所以决定重新整理一下,实现Visual Studio Code + win10 64bit bash 的ESP8266 linux编译环境。

首先打开Windows10开发者模式:设置-更新和安全-开发者选项,选中“开发人员模式”,等待相关文件安装完成。

然后进入 控制面板-程序和功能-启用或关闭Windows功能

选中“适用于Linux的Windows子系统”

点击“确定”以后等待安装完成,进入cmd命令行,然后输入 bash ,仍然得到如下提示:

E:\Documents\Eclipseworkspace>bash
适用于 Linux 的 Windows 子系统没有已安装的分发版。
可以通过访问 Microsoft Store 来安装分发版:
https://aka.ms/wslstore

访问提示的网址 https://aka.ms/wslstore,根据提示从Microsoft Store打开链接:

然后可以看到若干Linux版本:Ubuntu, openSUSE Leap 42, SUSE Linux Enterprise Server 12, Debian GNU/Linux, Kali Linux

选择Ubuntu进行安装

按照提示创建账号和密码,账号不一定需要和windows账号相同

Installing, this may take a few minutes...
AAPlease create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: simonliu
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

看一下版本,是Ubuntu 18.04.1

simonliu@DESKTOP-JF56RKP:~$ cat /etc/issue
Ubuntu 18.04.1 LTS \n \l

查看版本,x86_64表示这是64位系统:

$ uname -m
x86_64

先更新一下源

sudo apt update

然后安装相关依赖(64bit),其中nano 和 emacs属于编辑器,可选。

sudo apt install git wget nano emacs sed autoconf make automake gperf bison flex texinfo gawk libtool libncurses5-dev expat python python-serial build-essential pacman

创建一个新目录并修改权限,用于存放预编译好的工具链

sudo mkdir /opt/espressif
sudo chmod 777 /opt/espressif

64bit系统工具链下载(如果速度很慢,也可以用迅雷等工具下载,大小28.86M,然后复制到/opt/expressif)

cd /opt/espressif
wget http://arduino.esp8266.com/linux64-xtensa-lx106-elf-gb404fb9.tar.gz

解压

 tar zxvf linux64-xtensa-lx106-elf-gb404fb9.tar.gz

下载库补丁至/opt/espressif/xtensa-lx106-elf/xtensa-lx106-elf/lib,先切换目录,注意是xtensa-lx106-elf下面的xtensa-lx106-elf同名子目录:

cd /opt/espressif/xtensa-lx106-elf/xtensa-lx106-elf
wget -O lib/libc.a https://github.com/esp8266/esp8266-wiki/raw/master/libs/libc.a
wget -O lib/libhal.a https://github.com/esp8266/esp8266-wiki/raw/master/libs/libhal.a
wget -O include.tgz https://github.com/esp8266/esp8266-wiki/raw/master/include.tgz
tar zxvf include.tgz

 编辑~/.bashrc 添加路径

nano ~/.bashrc

最后一行添加如下内容:

PATH="/opt/espressif/xtensa-lx106-elf/bin:$PATH"

 然后source ~/.bashrc 使其立刻生效,然后输入echo $PATH确认 /opt/espressif/xtensa-lx106-elf/bin 在路径中:

$source ~/.bashrc
$echo $PATH

输入xtensa-lx106-elf-gcc -v 确认看到如下信息即可:

$ xtensa-lx106-elf-gcc -v
Using built-in specs.
COLLECT_GCC=xtensa-lx106-elf-gcc
COLLECT_LTO_WRAPPER=/opt/espressif/xtensa-lx106-elf/bin/../libexec/gcc/xtensa-lx106-elf/4.8.2/lto-wrapper
Target: xtensa-lx106-elf
Configured with: /home/igrokhotkov/xtensa/crosstool-NG/.build/src/gcc-4.8.2/configure --build=x86_64-build_unknown-linux-gnu --host=x86_64-build_unknown-linux-gnu --target=xtensa-lx106-elf --prefix=/home/igrokhotkov/xtensa/crosstool-NG/builds/xtensa-lx106-elf --with-local-prefix=/home/igrokhotkov/xtensa/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/sysroot --disable-libmudflap --with-sysroot=/home/igrokhotkov/xtensa/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/sysroot --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG 1.20.0' --disable-__cxa_atexit --with-gmp=/home/igrokhotkov/xtensa/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-mpfr=/home/igrokhotkov/xtensa/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-mpc=/home/igrokhotkov/xtensa/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-isl=/home/igrokhotkov/xtensa/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-cloog=/home/igrokhotkov/xtensa/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-libelf=/home/igrokhotkov/xtensa/crosstool-NG/.build/xtensa-lx106-elf/buildtools --enable-lto --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-nls --disable-multilib --enable-languages=c,c++
Thread model: single
gcc version 4.8.2 (crosstool-NG 1.20.0)

至于non_os的SDK的使用我就不写了,这里以机智云的SOC代码为例说明, 在Visual Studio Code中点击 Add workspace folder

选择项目ESP项目存放的文件夹,本例中为:

E:\Documents\Eclipseworkspace\

首先,机智云的SoC代码需要修改项目文件夹下根目录的makefile内容的如下几行为:bo
BOOT?=new
APP?=1
SPI_SPEED?=40
SPI_MODE?=QIO
SPI_SIZE_MAP?=6

然后点击菜单 "Terminal-New Terminal"

然后在Terminal中输入bash:

当前目录切换到路径下的具体项目(本例为Filter_SoC_ESP8266_20181220)下的app子文件夹:

cd /mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app

然后make clean,再也不出现前面的find参数错误了

simonliu@DESKTOP-JF56RKP:/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app$ make clean
make -C user clean;  make -C driver clean;  make -C Gizwits clean;  make -C Utils clean;
make[1]: Entering directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/user'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/user'
make[1]: Entering directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/driver'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/driver'
make[1]: Entering directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Gizwits'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Gizwits'
make[1]: Entering directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Utils'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Utils'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
rm -f -r ../bin/upgrade

然后输入 sh gen_misc.sh即可编译成功:

simonliu@DESKTOP-JF56RKP:/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app$ make clean
make -C user clean;  make -C driver clean;  make -C Gizwits clean;  make -C Utils clean;
make[1]: Entering directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/user'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/user'
make[1]: Entering directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/driver'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/driver'
make[1]: Entering directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Gizwits'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Gizwits'
make[1]: Entering directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Utils'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
rm -f -r ../bin/upgrade
make[1]: Leaving directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Utils'
rm -f -r .output/eagle/debug
find ../ -name .output | xargs rm -fr
rm -f -r ../bin/upgrade
simonliu@DESKTOP-JF56RKP:/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app$ sh gen_misc.sh
gen_misc.sh version 20150511boot mode: new
app:1
spi speed: 40 MHz
spi mode: QIO
spi_size_map:6
make[1]: Entering directory '/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/user'
DEPEND: xtensa-lx106-elf-gcc -M -Os -g -Wpointer-arith -Wundef -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -DICACHE_FLASH -I include -I ./ -I ../../include/ets -I ../include -I 
......(此处省略....)
'/mnt/e/Documents/Eclipseworkspace/Filter_SoC_ESP8266_20181220/app/Utils'
xtensa-lx106-elf-gcc  -L../lib -nostdlib -T../ld/eagle.app.v6.new.2048.ld -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain -ljson -lupgrade -lssl -lpwm -lcrypto -lsmartconfig -lairkiss -lgagent user/.output/eagle/debug/lib/libuser.a driver/.output/eagle/debug/lib/libdriver.a Gizwits/.output/eagle/debug/lib/libGizwits.a Utils/.output/eagle/debug/lib/libUtils.a -Wl,--end-group -o .output/eagle/debug/image/eagle.app.v6.out
mkdir -p ../bin/upgrade!!!
-1674082697
1674082696
Support boot_v1.4 and +
Generate user1.4096.new.6.bin successully in folder bin/upgrade.
boot.bin------------>0x00000
user1.4096.new.6.bin--->0x01000
!!!

这样编译快多了,在我的NAS J3160平台上,使用安信可Eclipse一体化平台,clean需要30秒+,编译需要3分钟+,但是win10 Ubuntu bash下,make clean只需要2秒,编译只需要26秒!速度快多了~~

这篇关于Visual Studio Code 与 Win10 64bit Ubuntu bash 的ESP8266 编译开发环境搭建(无需编译toolchain)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/914397

相关文章

基于 Cursor 开发 Spring Boot 项目详细攻略

《基于Cursor开发SpringBoot项目详细攻略》Cursor是集成GPT4、Claude3.5等LLM的VSCode类AI编程工具,支持SpringBoot项目开发全流程,涵盖环境配... 目录cursor是什么?基于 Cursor 开发 Spring Boot 项目完整指南1. 环境准备2. 创建

通过Docker容器部署Python环境的全流程

《通过Docker容器部署Python环境的全流程》在现代化开发流程中,Docker因其轻量化、环境隔离和跨平台一致性的特性,已成为部署Python应用的标准工具,本文将详细演示如何通过Docker容... 目录引言一、docker与python的协同优势二、核心步骤详解三、进阶配置技巧四、生产环境最佳实践

SpringBoot 多环境开发实战(从配置、管理与控制)

《SpringBoot多环境开发实战(从配置、管理与控制)》本文详解SpringBoot多环境配置,涵盖单文件YAML、多文件模式、MavenProfile分组及激活策略,通过优先级控制灵活切换环境... 目录一、多环境开发基础(单文件 YAML 版)(一)配置原理与优势(二)实操示例二、多环境开发多文件版

使用docker搭建嵌入式Linux开发环境

《使用docker搭建嵌入式Linux开发环境》本文主要介绍了使用docker搭建嵌入式Linux开发环境,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录1、前言2、安装docker3、编写容器管理脚本4、创建容器1、前言在日常开发全志、rk等不同

Ubuntu如何升级Python版本

《Ubuntu如何升级Python版本》Ubuntu22.04Docker中,安装Python3.11后,使用update-alternatives设置为默认版本,最后用python3-V验证... 目China编程录问题描述前提环境解决方法总结问题描述Ubuntu22.04系统自带python3.10,想升级

Python实战之SEO优化自动化工具开发指南

《Python实战之SEO优化自动化工具开发指南》在数字化营销时代,搜索引擎优化(SEO)已成为网站获取流量的重要手段,本文将带您使用Python开发一套完整的SEO自动化工具,需要的可以了解下... 目录前言项目概述技术栈选择核心模块实现1. 关键词研究模块2. 网站技术seo检测模块3. 内容优化分析模

Linux搭建ftp服务器的步骤

《Linux搭建ftp服务器的步骤》本文给大家分享Linux搭建ftp服务器的步骤,本文通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录ftp搭建1:下载vsftpd工具2:下载客户端工具3:进入配置文件目录vsftpd.conf配置文件4:

解决Nginx启动报错Job for nginx.service failed because the control process exited with error code问题

《解决Nginx启动报错Jobfornginx.servicefailedbecausethecontrolprocessexitedwitherrorcode问题》Nginx启... 目录一、报错如下二、解决原因三、解决方式总结一、报错如下Job for nginx.service failed bec

基于Java开发一个极简版敏感词检测工具

《基于Java开发一个极简版敏感词检测工具》这篇文章主要为大家详细介绍了如何基于Java开发一个极简版敏感词检测工具,文中的示例代码简洁易懂,感兴趣的小伙伴可以跟随小编一起学习一下... 目录你是否还在为敏感词检测头疼一、极简版Java敏感词检测工具的3大核心优势1.1 优势1:DFA算法驱动,效率提升10

Python开发简易网络服务器的示例详解(新手入门)

《Python开发简易网络服务器的示例详解(新手入门)》网络服务器是互联网基础设施的核心组件,它本质上是一个持续运行的程序,负责监听特定端口,本文将使用Python开发一个简单的网络服务器,感兴趣的小... 目录网络服务器基础概念python内置服务器模块1. HTTP服务器模块2. Socket服务器模块