下载ubuntu18.04,这里用阿里的开源镜像站来拉(为什么选择18.04,因为python版本就是3.6了)
http://mirrors.aliyun.com/ubuntu-releases/18.04/
下载VMware,必须用 16.0.0以上,否则很容易出现蓝屏问题…家里电脑14.x的版本,只要开镜像,必死机 http://big3.ddooo.com/vmware_177981.rar?key=0dfa0a4e8e3bacbc44094054b61354f7
镜像导入到vmware里面
设置网络适配器为桥接,复制物理状态
设置共享文件夹
该上代理上代理
//git代理 git config --global http.proxy 192.168.1.7:1080 //全局代理 export https_proxy=192.168.1.7:1080 export http_proxy=192.168.1.7:1080
更新APT源,这里使用代理方法 ,所有的apt-update或者apt-install都可以加这个后缀
有时会一直卡着,那就断开ubuntu的网络,重连一下wireless,重连成功后一段时间肯定是正常的
sudo apt-get update -o Acquire::http::proxy="http://192.168.31.88:7890"
更新一些用到的包
sudo apt-get 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 install git wget flex bison gperf python python-pip python-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util
将python切换到python3.6
cd /usr/bin/ sudo rm python sudo ln -s python3.6 python
安装pip
1.sudo rm /var/lib/dpkg/lock sudo rm /var/lib/dpkg/lock-frontend #先删除了apt的锁,有可能apt被锁住了提示 Could not get lock /var/lib/dpkg/lock-frontend 问题 1.wget https://bootstrap.pypa.io/pip/3.6/get-pip.py --no-check-certificate #拉取PIP下载文件(这里是按照提示拉的地址,之前拉的是 https://bootstrap.pypa.io/get-pip.py ) 2.python get-pip.py #安装pip,这里提示错误,找不到 distutils 3.sudo apt-get install python3-distutils #安装distutils 4.sudo apt-get install python3.6-dev #安装py36的dev
拉取SDK,指定4.4版本,子模块都拉取,并将名字定义成esp-idf-4.4
git clone -b v4.4 --recursive https://github.com/espressif/esp-idf.git esp-idf-4.4
拉取SDK需要用到的包
python -m pip install --user -r $IDF_PATH/requirements.txt
拿工具链,芯片是啥就拿哪个,我这里拿的是xtensa-esp32-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz
https://github.com/espressif/crosstool-NG/releases
注意,对于ESP32-C3的工具链,这里使用idf.py的命令去获取就行,必须先配置好idf.py到环境变量(或者直接在 tools/里面用)
安装好工具链以后,需要将工具链路径放到全局里面,这里是通过 export.sh 脚本来执行的,具体可以看官方的说明。我这里直接手动将工具链加到全局,工具链位置:~/.espressif/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin
cd /mnt/hgfs/ubshare/esp-idf/ ./install.sh
工具链解压到opt,并设置一下环境变量
sudo cp /mnt/hgfs/share/xtensa-esp32-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz /opt sudo tar -xvf xtensa-esp32-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz sudo gedit /etc/environment #加入 source /etc/environment
设置IDF_PATH
export IDF_PATH=/mnt/hgfs/share/esp-idf-4.4
设置idf.py到环境变量
sudo gedit /etc/environment /mnt/hgfs/ubshare/esp-idf/tools source /etc/environment
设置芯片类型注意切换平台,必须先rm -rf build 文件夹
rm -rf build idf.py set-target esp32c3
配置,编译
../../../tools/idf.py menuconfig ../../../tools/idf.py build
/mnt/hgfs/share/esp-idf-4.4/examples/get-started/hello_world$ history 1 cd /opt/ 2 ls 3 rm -rf xtensa-esp32-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz.sgdownload 4 sudo rm -rf xtensa-esp32-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz.sgdownload 5 sudo cp /mnt/hgfs/share/xtensa-esp32-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz ./ 6 sudo tar -xvf xtensa-esp32-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz 7 cd xtensa-esp32-elf/ 8 ls 9 cd bin/ 10 sudo gedit /etc/environment 11 cd /mnt/hgfs/share/esp-idf-4.4/ 12 ls 13 export IDF_PATH=/mnt/hgfs/share/esp-idf-4.4/ 14 source /etc/environment 15 python -m pip install --user -r $IDF_PATH/requirements.txt 16 idf.py 17 ./tools/idf.py 18 sudo update-alternatives --list python 19 sudo update -alternatives --list python 20 ./tools/idf.py 21 python -m pip install --user -r $IDF_PATH/requirements.txt 22 cd .. 23 wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate 24 python get-pip.py 25 wget https://bootstrap.pypa.io/pip/3.6/get-pip.py --no-check-certificate 26 python get-pip.py1 27 python get-pip.py.1 28 sudo apt-get install python3.6-dev 29 sudo apt-get install python3.6-dev 30 pkill -9 apt 31 sudo pkill -9 apt 32 sudo apt-get install python3.6-dev 33 ps afx|grep apt 34 sudo rm /var/lib/dpkg/lock-frontend 35 sudo apt-get install python3.6-dev 36 sudo rm /var/lib/dpkg/lock 37 sudo apt-get install python3.6-dev 38 sudo apt-get install python3-distutils 39 python get-pip.py.1 40 python -m pip install --user -r $IDF_PATH/requirements.txt 41 cd esp-idf-4.4/ 42 ./tools/idf.py 43 ./tools/idf.py menuconfig 44 cd examples/get-started/ 45 ls 46 cd hello_world/ 47 ls 48 ../../../tools/idf.py menuconfig 49 ../../../tools/idf.py build 50 history