Skip to content

Instantly share code, notes, and snippets.

@astrolemonade
Forked from abobija/esp-idf-on-wsl2.md
Created September 15, 2024 19:54
Show Gist options
  • Select an option

  • Save astrolemonade/53f5d756b28c97091c368d9fc3fcdbd5 to your computer and use it in GitHub Desktop.

Select an option

Save astrolemonade/53f5d756b28c97091c368d9fc3fcdbd5 to your computer and use it in GitHub Desktop.

Revisions

  1. @abobija abobija revised this gist Aug 5, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    `sudo apt update && sudo apt upgrade -y`

    - Install tools required for esp-idf<br>
    `sudo apt install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0`
    `sudo apt install -y git wget curl flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0`

    - Make python3 as default python<br>
    `sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1`
    @@ -49,7 +49,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    `echo -e '\n\n. $HOME/esp/esp-idf/export.sh > /dev/null 2>&1 || true' >> ~/.profile`

    - Install **idfx** ( [**?**](https://github.com/abobija/idfx) )<br>
    `wget https://raw.githubusercontent.com/abobija/idfx/main/idfx -O $HOME/.local/bin/idfx && chmod u+x $HOME/.local/bin/idfx`
    `curl https://git.io/JyBgj --create-dirs -L -o $HOME/bin/idfx && chmod u+x $HOME/bin/idfx`

    - Source profile script to add all necessary tools to the PATH<br>
    `. ~/.profile || true`
  2. @abobija abobija revised this gist Aug 3, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    `sudo apt update && sudo apt upgrade -y`

    - Install tools required for esp-idf<br>
    `sudo apt install -y git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0`
    `sudo apt install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0`

    - Make python3 as default python<br>
    `sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1`
  3. @abobija abobija revised this gist Aug 21, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    `sudo apt update && sudo apt upgrade -y`

    - Install tools required for esp-idf<br>
    `sudo apt install -y git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util`
    `sudo apt install -y git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0`

    - Make python3 as default python<br>
    `sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1`
  4. @abobija abobija revised this gist Dec 5, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@

    [WSL2](https://docs.microsoft.com/en-us/windows/wsl/compare-versions) still [does not support USB devices](https://github.com/microsoft/WSL/issues/4322), but with a little effort we can make possible to flash and monitor ESP device from WSL2.

    > **Info:**<br>Tested on [Ubuntu 20.04 LTS](https://www.microsoft.com/en-us/p/ubuntu-2004-lts/9n6svws3rx71) distribution.
    > **Info:**<br>Tested on [Ubuntu 20.04 LTS](https://www.microsoft.com/en-us/p/ubuntu-2004-lts/9n6svws3rx71) and [Debian](https://www.microsoft.com/en-us/p/debian/9msvkqc78pk6) distributions.
    For flashing and monitoring over the serial COM port, I've wrote this compact [idfx](https://github.com/abobija/idfx) shell script.

    @@ -21,7 +21,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    ## Commands :scroll:
    ### Installation :rocket:

    - Update Ubuntu<br>
    - Update Linux<br>
    `sudo apt update && sudo apt upgrade -y`

    - Install tools required for esp-idf<br>
  5. @abobija abobija revised this gist Dec 5, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    `wget https://raw.githubusercontent.com/abobija/idfx/main/idfx -O $HOME/.local/bin/idfx && chmod u+x $HOME/.local/bin/idfx`

    - Source profile script to add all necessary tools to the PATH<br>
    `. ~/.profile`
    `. ~/.profile || true`

    ### Create (a copy of hello_world) project :page_facing_up:

  6. @abobija abobija revised this gist Dec 5, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -49,7 +49,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    `echo -e '\n\n. $HOME/esp/esp-idf/export.sh > /dev/null 2>&1 || true' >> ~/.profile`

    - Install **idfx** ( [**?**](https://github.com/abobija/idfx) )<br>
    `curl -L https://raw.githubusercontent.com/abobija/idfx/main/idfx -o $HOME/.local/bin/idfx && chmod u+x $HOME/.local/bin/idfx`
    `wget https://raw.githubusercontent.com/abobija/idfx/main/idfx -O $HOME/.local/bin/idfx && chmod u+x $HOME/.local/bin/idfx`

    - Source profile script to add all necessary tools to the PATH<br>
    `. ~/.profile`
  7. @abobija abobija revised this gist Dec 5, 2020. 1 changed file with 3 additions and 6 deletions.
    9 changes: 3 additions & 6 deletions esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -24,18 +24,15 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    - Update Ubuntu<br>
    `sudo apt update && sudo apt upgrade -y`

    - Install tools required for esp-idf<br>
    `sudo apt install -y git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util`

    - Make python3 as default python<br>
    `sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1`

    - Install python3-pip<br>
    `sudo apt install -y python3-pip`

    - Make pip3 as default pip<br>
    `sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1`

    - Install tools required for esp-idf<br>
    `sudo apt install -y git wget flex bison gperf python python-pip python-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util`

    - Make esp directory and go inside<br>
    `cd ~ && mkdir esp && cd esp`

  8. @abobija abobija revised this gist Dec 5, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    `sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1`

    - Install tools required for esp-idf<br>
    `sudo apt install -y git wget flex bison gperf python-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util`
    `sudo apt install -y git wget flex bison gperf python python-pip python-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util`

    - Make esp directory and go inside<br>
    `cd ~ && mkdir esp && cd esp`
  9. @abobija abobija revised this gist Nov 29, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -49,7 +49,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    `. ./install.sh || true`

    - Add esp-idf export script to the user profile script in order to make isp-idf tools visible on the PATH for every session<br>
    `echo -e "\n\n. $HOME/esp/esp-idf/export.sh > /dev/null 2>&1 || true" >> ~/.profile`
    `echo -e '\n\n. $HOME/esp/esp-idf/export.sh > /dev/null 2>&1 || true' >> ~/.profile`

    - Install **idfx** ( [**?**](https://github.com/abobija/idfx) )<br>
    `curl -L https://raw.githubusercontent.com/abobija/idfx/main/idfx -o $HOME/.local/bin/idfx && chmod u+x $HOME/.local/bin/idfx`
  10. @abobija abobija revised this gist Nov 24, 2020. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,6 @@

    ## Demo

    YouTube:

    [![How to setup ESP-IDF on WSL2 Ubuntu 20.04 - Config, Build and Flash](https://img.youtube.com/vi/eQ0D8pnZTSY/mqdefault.jpg)](https://www.youtube.com/watch?v=eQ0D8pnZTSY)

    ## Intro
  11. @abobija abobija revised this gist Nov 24, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

    ## Demo

    YouTube:

    [![How to setup ESP-IDF on WSL2 Ubuntu 20.04 - Config, Build and Flash](https://img.youtube.com/vi/eQ0D8pnZTSY/mqdefault.jpg)](https://www.youtube.com/watch?v=eQ0D8pnZTSY)

    ## Intro
  12. @abobija abobija revised this gist Nov 24, 2020. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    # ESP-IDF on WSL2 - Build, Flash and Monitor :zap:

    ## Demo

    [![How to setup ESP-IDF on WSL2 Ubuntu 20.04 - Config, Build and Flash](https://img.youtube.com/vi/eQ0D8pnZTSY/mqdefault.jpg)](https://www.youtube.com/watch?v=eQ0D8pnZTSY)

    ## Intro

    [WSL2](https://docs.microsoft.com/en-us/windows/wsl/compare-versions) still [does not support USB devices](https://github.com/microsoft/WSL/issues/4322), but with a little effort we can make possible to flash and monitor ESP device from WSL2.

    > **Info:**<br>Tested on [Ubuntu 20.04 LTS](https://www.microsoft.com/en-us/p/ubuntu-2004-lts/9n6svws3rx71) distribution.
  13. @abobija abobija revised this gist Nov 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -48,7 +48,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    - Install **idfx** ( [**?**](https://github.com/abobija/idfx) )<br>
    `curl -L https://raw.githubusercontent.com/abobija/idfx/main/idfx -o $HOME/.local/bin/idfx && chmod u+x $HOME/.local/bin/idfx`

    - Run profile script to add all necessary tools to the PATH<br>
    - Source profile script to add all necessary tools to the PATH<br>
    `. ~/.profile`

    ### Create (a copy of hello_world) project :page_facing_up:
  14. @abobija abobija revised this gist Nov 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -49,7 +49,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    `curl -L https://raw.githubusercontent.com/abobija/idfx/main/idfx -o $HOME/.local/bin/idfx && chmod u+x $HOME/.local/bin/idfx`

    - Run profile script to add all necessary tools to the PATH<br>
    `. ~./.profile`
    `. ~/.profile`

    ### Create (a copy of hello_world) project :page_facing_up:

  15. @abobija abobija revised this gist Nov 23, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -42,15 +42,15 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    - Run esp-idf installation script<br>
    `. ./install.sh || true`

    - Run esp-idf export script<br>
    `. ./export.sh || true`

    - Add esp-idf export script to the user profile script in order to make isp-idf tools visible on the PATH for every session<br>
    `echo -e "\n\n. $HOME/esp/esp-idf/export.sh > /dev/null 2>&1 || true" >> ~/.profile`

    - Install **idfx** ( [**?**](https://github.com/abobija/idfx) )<br>
    `curl -L https://raw.githubusercontent.com/abobija/idfx/main/idfx -o $HOME/.local/bin/idfx && chmod u+x $HOME/.local/bin/idfx`

    - Run profile script to add all necessary tools to the PATH<br>
    `. ~./.profile`

    ### Create (a copy of hello_world) project :page_facing_up:

    - Make a copy of hello_world example project in home directory<br>
  16. @abobija abobija revised this gist Nov 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -79,7 +79,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    `idfx monitor COM2`<br>
    <sub>(To exit monitor press `CTRL+]` or `CTRL+T`,`X`)</sub>

    > **Note:**<br>Flash and monitor with single command:<br>`idfx flash COM2 monitor`
    > **Tip:**<br>Flash and monitor with single command:<br>`idfx flash COM2 monitor`
    <br>
    That's it.<br>
  17. @abobija abobija revised this gist Nov 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -77,7 +77,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    - Monitor<br>
    <sup>(change `COM2` with your port)</sup><br>
    `idfx monitor COM2`<br>
    <sup>(To exit monitor press `CTRL+]` or `CTRL+T`,`X`)</sup>
    <sub>(To exit monitor press `CTRL+]` or `CTRL+T`,`X`)</sub>

    > **Note:**<br>Flash and monitor with single command:<br>`idfx flash COM2 monitor`
  18. @abobija abobija revised this gist Nov 23, 2020. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -77,7 +77,6 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    - Monitor<br>
    <sup>(change `COM2` with your port)</sup><br>
    `idfx monitor COM2`<br>
    <br>
    <sup>(To exit monitor press `CTRL+]` or `CTRL+T`,`X`)</sup>

    > **Note:**<br>Flash and monitor with single command:<br>`idfx flash COM2 monitor`
  19. @abobija abobija revised this gist Nov 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -78,7 +78,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    <sup>(change `COM2` with your port)</sup><br>
    `idfx monitor COM2`<br>
    <br>
    <sup>To exit monitor press `CTRL+]` or `CTRL+T`,`X`</sup>
    <sup>(To exit monitor press `CTRL+]` or `CTRL+T`,`X`)</sup>

    > **Note:**<br>Flash and monitor with single command:<br>`idfx flash COM2 monitor`
  20. @abobija abobija revised this gist Nov 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -78,7 +78,7 @@ Ok, that was short intro, now you can open WSL and start to execute next command
    <sup>(change `COM2` with your port)</sup><br>
    `idfx monitor COM2`<br>
    <br>
    To exit monitor press `CTRL+]` or `CTRL+T`,`X`
    <sup>To exit monitor press `CTRL+]` or `CTRL+T`,`X`</sup>

    > **Note:**<br>Flash and monitor with single command:<br>`idfx flash COM2 monitor`
  21. @abobija abobija revised this gist Nov 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # ESP-IDF on WSL2 - Build, Flash and Monitor
    # ESP-IDF on WSL2 - Build, Flash and Monitor :zap:

    [WSL2](https://docs.microsoft.com/en-us/windows/wsl/compare-versions) still [does not support USB devices](https://github.com/microsoft/WSL/issues/4322), but with a little effort we can make possible to flash and monitor ESP device from WSL2.

  22. @abobija abobija revised this gist Nov 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,7 @@ Happy coding and flashing! :zap:
    <br>
    <br>

    ![idfx preview](https://github.com/abobija/idfx/raw/main/preview.gif)
    ![idfx preview](https://user-images.githubusercontent.com/45392201/99966731-090b9e00-2d97-11eb-947b-c7b4f9d8fe25.gif)

    ## Author

  23. @abobija abobija created this gist Nov 23, 2020.
    95 changes: 95 additions & 0 deletions esp-idf-on-wsl2.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,95 @@
    # ESP-IDF on WSL2 - Build, Flash and Monitor

    [WSL2](https://docs.microsoft.com/en-us/windows/wsl/compare-versions) still [does not support USB devices](https://github.com/microsoft/WSL/issues/4322), but with a little effort we can make possible to flash and monitor ESP device from WSL2.

    > **Info:**<br>Tested on [Ubuntu 20.04 LTS](https://www.microsoft.com/en-us/p/ubuntu-2004-lts/9n6svws3rx71) distribution.
    For flashing and monitoring over the serial COM port, I've wrote this compact [idfx](https://github.com/abobija/idfx) shell script.

    > **Note:**<br>As a prerequisite for using `idfx`, [Python :snake:](https://www.python.org) needs to be installed on the Windows.
    More about `idfx` you can find in [official repository](https://github.com/abobija/idfx).

    Ok, that was short intro, now you can open WSL and start to execute next commands.

    ## Commands :scroll:
    ### Installation :rocket:

    - Update Ubuntu<br>
    `sudo apt update && sudo apt upgrade -y`

    - Make python3 as default python<br>
    `sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1`

    - Install python3-pip<br>
    `sudo apt install -y python3-pip`

    - Make pip3 as default pip<br>
    `sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1`

    - Install tools required for esp-idf<br>
    `sudo apt install -y git wget flex bison gperf python-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util`

    - Make esp directory and go inside<br>
    `cd ~ && mkdir esp && cd esp`

    - Clone esp-idf repository<br>
    `git clone --recursive https://github.com/espressif/esp-idf.git`

    - Modify esp-idf installation script to work with WSL<br>
    `cd esp-idf && ! grep -q "dirname --" install.sh; [ $? -eq 0 ] && sed -i 's/dirname/dirname --/g' install.sh`

    - Run esp-idf installation script<br>
    `. ./install.sh || true`

    - Run esp-idf export script<br>
    `. ./export.sh || true`

    - Add esp-idf export script to the user profile script in order to make isp-idf tools visible on the PATH for every session<br>
    `echo -e "\n\n. $HOME/esp/esp-idf/export.sh > /dev/null 2>&1 || true" >> ~/.profile`

    - Install **idfx** ( [**?**](https://github.com/abobija/idfx) )<br>
    `curl -L https://raw.githubusercontent.com/abobija/idfx/main/idfx -o $HOME/.local/bin/idfx && chmod u+x $HOME/.local/bin/idfx`

    ### Create (a copy of hello_world) project :page_facing_up:

    - Make a copy of hello_world example project in home directory<br>
    `cd ~ && cp -r $IDF_PATH/examples/get-started/hello_world .`

    ### Build, flash and monitor :zap:

    - Go inside of project<br>
    `cd hello_world`

    - Set target<br>
    `idf.py set-target esp32`

    - Configure<br>
    `idf.py menuconfig`

    - Build<br>
    `idf.py build`

    - Flash<br>
    <sup>(open Device Manager on Windows to find COM port of your ESP, mine is `COM2`)</sup><br>
    `idfx flash COM2`

    - Monitor<br>
    <sup>(change `COM2` with your port)</sup><br>
    `idfx monitor COM2`<br>
    <br>
    To exit monitor press `CTRL+]` or `CTRL+T`,`X`

    > **Note:**<br>Flash and monitor with single command:<br>`idfx flash COM2 monitor`
    <br>
    That's it.<br>
    Happy coding and flashing! :zap:
    <br>
    <br>

    ![idfx preview](https://github.com/abobija/idfx/raw/main/preview.gif)

    ## Author

    [abobija](https://github.com/abobija) - [abobija.com](https://abobija.com)