一、为何要再次搭建环境
- 因为看到最新的idf,有lvgl,oled SSD1306的支持,我懒得自己改了,所以才想着重新搭个环境
二、Vmware安装ubuntu20.04
- 之前尝试过,在18.04下面搭建,结果发现python版本是3.6,而idf5.0要求的是3.7以上,所以直接改用20.04的
- 用阿里的镜像http://mirrors.aliyun.com/ubuntu-releases/20.04/ubuntu-20.04.4-desktop-amd64.iso?spm=a2c6h.25603864.0.0.30414509rHrwzU
三、配置环境
-
上代理
//git代理 git config --global http.proxy 192.168.0.103:7890 //全局代理 export https_proxy=192.168.0.103:7890 export http_proxy=192.168.0.103:7890
-
循例先更新一下包
sudo apt-get -o Acquire::http::proxy="http://192.168.31.88:7890" update
-
拉一些包
sudo apt-get -o Acquire::http::proxy="http://192.168.31.88:7890" install -y make build-essential zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm tk-dev libc6-dev gcc libssl-dev sudo apt-get -o Acquire::http::proxy="http://192.168.31.88:7890" install git wget flex bison gperf python python-setuptools cmake ninja-build ccache libffi-dev libssl-dev sudo apt-get install python3-distutils
-
拉5.0的IDF ==这里注意了,可以不带
-b v5.0-dev
去拉…如果带了-b v5.0-dev,好像example是旧的…因为我现在这个时间节点,idf版本就是5.0,所以我没加,或者,之后可以自己切一下版本
另外需要重点注意,这里拉IDF的位置,要放在虚拟机里面的目录,别放在共享目录,否则链接mbedtls时,会出现一个Could not create symbolic link for xxxxx
的错误
原因是:在Linux虚拟机与windows主机进行文件共享,将代码放在共享文件夹中进行编译,以期在windows及Linux环境中都可以进行修改及编译而不需要额外的拷贝,此时在共享文件夹中的磁盘格式的是windows 的磁盘格式,ln命令并不适用,此时是由于在编译动态库的时候会在库的结尾加入版本信息,然后再通过ln建立链接。 即:代码源文件在window端,便会发生这种情况ln: failed to create symbolic link ‘*.so’: Operation not supported 所以换个思路:把代码源文件放在Linux端,然后共享文件给WIN端口即可
这里有解决方法:
https://blog.csdn.net/baidu_39603247/article/details/122234556SAM-BA的配置:
https://blog.csdn.net/qq_44078824/article/details/119847027
注意一下目录要用绝对路径,什么~
这些就不能用,会出现找不到网络名错误
配置文件用下面这个,改一下自己的文件夹和用户名密码[global] workgroup = WORKGROUP display charset = UTF-8 unix charset = UTF-8 dos charset = cp936 ### 注:如果 #security 存在就直接修改,不存在就创建 #security = user security = user username map = /etc/Samba/smbusers [xuanzihao] comment = share folder browseable = yes path = /home/xuanzihao/ create mask = 0777 directory mask = 0777 valid users = xuanzihao force user = xuanzihao force group = xuanzihao public = yes available = yes writable = yes
git clone --recursive https://github.com/espressif/esp-idf.git esp-idf-5.0 git branch -r git checkout -b origin/release/v5.0
拉子模块最后,会出现错误,不需要管
-
拉一下PIP,这里注意一下先将python改成3.8,之后再安装,注意一下,我们以前用的 3.7以下,是
https://bootstrap.pypa.io/pip/3.6/get-pip.py
,而我们现在是3.8,比较新,直接是https://bootstrap.pypa.io/get-pip.py
就可以了cd ~ wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate cd /usr/bin/ sudo rm python sudo ln -s python3.8 python cd ~ python get-pip.py
-
更新一下IDF的环境(这里5.0已经换成
export.fish
来操作了,我们还是继续用 老方法requirements
)export IDF_PATH=~/esp-idf-5.0 python -m pip install --user -r $IDF_PATH/tools/requirements/requirements.core.txt
-
进入idf目录,重新拉子模块
git submodule update --init --recursive
之后,这里出现一些奇怪的错误,感觉像是ub20.04导致的…逐一修复
这里我举个例子:xuanzihao@ubuntu:/mnt/hgfs/share/esp-idf-5.0$ git submodule update --init --recursive Submodule path 'examples/build_system/cmake/import_lib/main/lib/tinyxml2': checked out '7e8e249990ec491ec15990cf95b6d871a66cf64a' fatal: detected dubious ownership in repository at '/mnt/hgfs/share/esp-idf-5.0/examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib' To add an exception for this directory, call: git config --global --add safe.directory /mnt/hgfs/share/esp-idf-5.0/examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib Unable to find current revision in submodule path 'examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib'
我们按照提示,全部逐一搞一下
git config --global --add safe.directory /mnt/hgfs/share/esp-idf-5.0/examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib Unable to find current revision in submodule path 'examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib'
最终,没有任何错误了
xuanzihao@ubuntu:/mnt/hgfs/share/esp-idf-5.0$ git submodule update --init --recursive Submodule path 'examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib': checked out '36d0642e66ff5b1c7a291873f24c498ca6ffedef'
-
再次拉一个包
sudo apt-get install python3.8-venv
-
拉一下工具链
./install.sh
-
加环境变量
. ./export.sh
-
随便进个目录,愉快编译拉
cd examples/get-started/hello_world/ idf.py set-target esp32 idf.py build