基于Ubuntu的ESP32平台搭建

 

提要:针对于Ubuntu下的ESP32搭建,网上有很多博文,乐鑫官网也有指导手册,对于到家都知道的部分我就一带而过,我主要描述搭建过程中遇到的问题和细节。

 

1.创建一个ESP的目录

   I)在家目录下创建个ESP文件夹(当然你也可以不在家目录下创建,甚至不创建,只有你找得你的操作目录就行)

mkdir  /home/tom/esp     (note:tom是我的用户名)

II)切换到ESP目录下

     cd ~/esp

 

2.工具链设置

    I)先下载python支持库

   sudo apt-get install git wget make libncurses-dev flex bison gperf python python-serial

 

II)下载工具链

for 64-bit Linux:

https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-75-gbaf03c2-5.2.0.tar.gz

 

for 32-bit Linux:

https://dl.espressif.com/dl/xtensa-esp32-elf-linux32-1.22.0-75-gbaf03c2-5.2.0.tar.gz

 

我的用的是64bitLinux,下载以后的文件是这样的

 

 

III)将工具链解压到esp文件目录下

 tar -xzf  ~/Downloads/xtensa-esp32-elf-linux64-1.22.0-75-gbaf03c2-5.2.0.tar.gz

 

IV)esp工具链写入环境变量PATH中。

~/.profile文件中写入:

export PATH="$PATH:$HOME/esp/xtensa-esp32-elf/bin"

V)重新读取PATH环境变量

    source  ~/.profile

    printenv PATH  

若是可以看到esp工具链的目录,则表示工具链设置成功了!

 

3.下载ESP-IDF(也就是乐鑫提供的SDK

I)下载SDK

git clone --recursive https://github.com/espressif/esp-idf.git

 

II)添加IDF_PATH环境变量

~/.profile文件添加:

export IDF_PATH=~/esp/esp-idf

     加载~/.profile文件:

          Source ~/.profile

     检查IDF_PATH

printenv IDF_PATH

如果打印出IDF_PATH的目录的话,则表示添加成功

 

4)开始一个工程

   I)SDK中拷贝一个Demoesp文件夹下

cp -r $IDF_PATH/examples/get-started/hello_world .

II)设置参数

执行 make menuconfig,会出现以下界面:(置于具体参数的含义,请自行了解)

 

III)编译与运行

在确保硬件连接无误的情况下,执行 make flash,程序将要编译,若编译没有错误,将直接下载到Flash中,出现以下界面,表示程序已经正常运行。

 

 

note:提供一些make 指令集,可供开发使用

Welcome to Espressif IDF build system. Some useful make targets:

 

make menuconfig - Configure IDF project

make defconfig - Set defaults for all new configuration options

 

make all - Build app, bootloader, partition table

make flash - Flash app, bootloader, partition table to a chip

make clean - Remove all build output

make size - Display the static memory footprint of the app

make size-components, size-files - Finer-grained memory footprints

make erase_flash - Erase entire flash contents

make monitor - Run idf_monitor tool to monitor serial output from app

make simple_monitor - Monitor serial output on terminal console

make list-components - List all components in the project

 

make app - Build just the app

make app-flash - Flash just the app

make app-clean - Clean just the app

make print_flash_cmd - Print the arguments for esptool when flash

 

See also 'make bootloader', 'make bootloader-flash', 'make bootloader-clean',

'make partition_table', etc, etc.ls

 

* 5)更新ESP-IDF这阶段本人并未实践,以下内容来自乐鑫官网

 

After some time of using ESP-IDF, you may want to update it to take advantage of new features or bug fixes. The simplest way to do so is by deleting existing esp-idffolder and cloning it again, exactly as when doing initial installation described in sections Get ESP-IDF.

Another solution is to update only what has changed. This method is useful if you have slow connection to the GiHub. To do the update run the following commands:

 

cd ~/esp/esp-idf

git pull

git submodule update --init --recursive

The git pull command is fetching and merging changes from ESP-IDF repository on GitHub. Then git submodule update --init --recursive is updating existing submodules or getting a fresh copy of new ones. On GitHub the submodules are represented as links to other repositories and require this additional command to get them onto your PC.

If you would like to use specific release of ESP-IDF, e.g. v2.1, run:

cd ~/esp

git clone https://github.com/espressif/esp-idf.git esp-idf-v2.1

cd esp-idf-v2.1/

git checkout v2.1

git submodule update --init --recursive

After that remember to Add IDF_PATH to User Profile, so the toolchain scripts know where to find the ESP-IDF in it’s release specific location.

 

 

转载于:https://www.cnblogs.com/mfc1207/p/8743384.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值