ubuntu 16.04接入esp32

1、安装虚拟机、ubuntu,确保能够上网

在ubuntu下安装python、pip,一般默认安装python,最好python3.5以上

安装pip

sudo apt-get install python-pip
sudo apt-get update	#更新系统包
pip -V	#检查pip是否安装成功
pip install --upgrade pip	#更新pip,可能需要pip3	install --upgrade pip

注意:默认可能是pip对应python2的版本

安装pip3

sudo apt-get install python3-pip
pip3 -V	#查看pip3的版本
sudo pip3 install --upgrade pip   #更新pip3
# 对于python2
pip install esptool
# 对于python3
pip3 install esptool

在这里插入图片描述

安装失败的话:

先sudo python -m pip uninstall esptool
然后sudo pip3 install esptool
原因可能是pip的时候安装了esptool,即pip2安装了导致失败,先卸载,然后再pip3安装

安装git工具:

apt-get install git
git clone https://github.com/espressif/esptool

#然后使用git clone下载esptool工具,也可以通过访问github网址下载

安装烧录工具

Esp32 的烧录工具是esptool.py

# 对于python2
pip install esptool
# 对于python3
pip3 install esptool

2、安装串口驱动:https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

查看linux版本:uname -r	

下载里面win10、linux两个版本对应的software

将下载后的linux移动到ubuntu中,文件名为Linux_3.x.x_4.x.x_VCP_Driver_Source .zip

在ubuntu下解压:unzip	Linux_3.x.x_4.x.x_VCP_Driver_Source .zip

查看解压后的文件:cat CP210x_VCP_Linux_4.x_Release_Notes.txt

有如下的描述:


Ubuntu:

1. make ( your cp210x driver )
2. cp cp210x.ko to /lib/modules/<kernel-version>/kernel/drivers/usb/serial
3. insmod /lib/modules/<kernel-version/kernel/drivers/usb/serial/usbserial.ko
4. insmod cp210x.ko
按照上述命令进行安装

kernel-version是你用uname -r查看得到的版本

如果安装驱动insmod的过程中提示 ……exits已存在,不用理会即可。

检查驱动是否安装成功

将开发板通过USB串口数据线与电脑连接,对于Windows,查看设备管理器,看到com端口号即可。

#在ubunut中
\# 运行如下命令
ls /dev/ttyUSB*
\# 如果运行结果中有 /dev/ttyUSB0之类的则表明成功,且该端口号就是开发版串口的端口号

3、linux下的串口监控程序可以选择使用minicom或者picocom

# 1 安装minicom
sudo apt-get install minicom
# 2 安装picocom
sudo apt-get install picocom

串口程序的使用:

picocom

获取picocom的使用帮助

picocom --help

连接到串口,进入交互解释环境,

# 对于Linux系统
picocom -b 115200 /dev/ttyUSB0
# 对于Mac OS X系统
picocom -b 115200 /dev/cu.SLAB_USBtoUART

minicom

获取minicom的使用帮助

minicom --help

连接到串口,进入交互解释环境,

# 对于Linux系统
minicom --device /dev/ttyUSB0

4、烧录固件:

下载地址:http://micropython.org/download/esp32/

选择这个下载:GENERIC : esp32-idf3-20191220-v1.12.bin

第一次使用时,需要先擦除固件,以后则可以直接烧录。

# linux
esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash

执行上述命令时发现报错,原因是没有将esptool.py文件

安装到默认的Python可执行文件目录中

打开第一步下载好的esptool文件夹,执行下面内容:

sudo cp esptool.py	/usr/bin

再次执行,发现报错:

/usr/bin/env: "python\r": 没有那个文件或目录

解决方法如下:

Linux下运行Python脚本显示“: /usr/bin/env "python\r" 找不到那个文件或目录

用 ./ 运行python 脚本文件出现 报错信息 /usr/bin/env "python\r" 找不到那个文件或目录

错误原因:这主要是因为\r这个字符的缘故。在linux终端下,输出\r会什么都不显示,只是把光标移到行首。于是终端虽然输出了/usr/bin/env: python,但是碰到\r后,光标会被移到行首,接着输出了:No such file or directory把前面的覆盖掉了。于是出现了那个莫名其妙的出错信息了

解决办法:

  用vim打开sh脚本文件 vim file_name.py 打开后输入

  :set ff 然后回车 再重新设置下文件格式:

  :set ff=unix 然后保存退出

  :wq! 回车

接下来可以擦除固件,但是发现烧录失败,faild。需要在擦除的时候按一下复位键

# linux
esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash

擦除的时候按一下复位键

执行完毕,成功烧写。

使用picocom:

# 对于Linux系统
picocom -b 115200 /dev/ttyUSB0
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This bundle contains a modified CP210x driver for the 4.10.0 kernel (Ubuntu 17.04). It contains: - Support for the CP2102N NOTE: This driver is an example of how to perform GPIO operations within the CP210x driver since the driver on kernel.org does not support GPIO at this time. This driver has only been written and tested on the Linux 3.13.0 kernel on Ubuntu 14.04. This driver is a modified version of the existing driver in the Linux 3.13.0 kernel, which is maintained at kernel.org. It is recommened to use the driver there that matches your specific kernel version: www.kernel.org Build instrutions: Ubuntu: 1. make ( your cp210x driver ) 2. cp cp210x.ko to /lib/modules//kernel/drivers/usb/serial 3. insmod /lib/modules/<kernel-version/kernel/drivers/usb/serial/usbserial.ko 4. insmod cp210x.ko RedHat: 1. yum update kernel* //need to update the kernel first otherwise your header won't match 2. yum install kernel-devel kernel-headers //get the devel and header packages. 3. reboot //your build link should be fixed after your system come back 4. make ( your cp210x driver ) // should be able to build successfully at this point 5. cp cp210x.ko to /lib/modules//kernel/drivers/usb/serial 6a. insmod /lib/modules/<kernel-version/kernel/drivers/usb/serial/usbserial.ko 6. insmod cp210x.ko 7. sudo chmod 666 /dev/ttyUSB0 8. sudo chmod 666 /dev/ttyUSB1 GPIO example: This shows how to use the two IOCTLs to set GPIO state. Build instructions: 1. g++ cp210x_gpio_example.c -o cp210x_gpio_example 2. ./cp210x_gpio_example
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值