Labs / MicroPython tutorials / 02 Setting up the MicroPython Development Environment — Draft Document Tutorial

Building MicroPython Development Environment on Linux (Container-based)

Author: Li Zisheng · Source: FreakStudio open documentation · License: CC BY 4.0

  1. Install the software package

Prior to the start of development, make sure that docker.io and vscode are installed

# Update the package sources and install docker
sudo apt update && sudo apt install -y docker.io
Building MicroPython Development Environment on Linux (Container-based)
  1. Add user permissions
    1. Check permissions

    Then insert the Raspberry Pi Pico development board with the burned MicroPython firmware and run ls -l /dev/ttyACM0:

    dev/ttyACM0 1 166 0 3 11 15 18

    The output is as follows, indicating that the user group with the required permissions is dialout

    crw-rw---- 1 root dialout 166, 0 Sep 3 15:52 /dev/ttyACM0

    1. Add Permissions

    Run sudo usermod -aG docker $USER to add yourself to the docker group

    Run sudo usermod -aG dialout $USER to add yourself to the dialout group

  2. Sign out again to activate the permissions
20.04.5
  1. vscode add the extension "Dev Containers"
Building MicroPython Development Environment on Linux (Container-based)
  1. Put https://codeberg.org/eoelab/cenv/src/branch/main/Denv/upython the. devcontainer folder under it into the workspace
micropython-n-tools_jetBra...4.zip
Building MicroPython Development Environment on Linux (Container-based)

Press Ctrl+ H to show hidden files (folders with names starting with. are hidden by default), and you will be able to see the. devcontainer folder at this point.

The directory structure is as follows:

micropython_test/
├── .devcontainer/
└── main.py
  1. Select to open the workspace folder in the container
6
5 1
  1. Wait for the container to be ready. The name of the development container is displayed in the bottom left corner, with the development container log in the middle.
v0.1.9 davescodemings.mpremote-1.21.20
  1. Just like on a host machine, write code inside the container MicroPython code
Building MicroPython Development Environment on Linux (Container-based)
  1. For a single file, simply right-click and select mpremote > Run file on remote device to execute it.
Building MicroPython Development Environment on Linux (Container-based)
  1. For multi-file/project development, open a terminal and run mpremote mount. run main.py to get started.
Building MicroPython Development Environment on Linux (Container-based)

You can press Ctrl+ C to terminate the current task, switch the file to be executed at any time simply by running the command again, no extra copying is needed, and it stays synchronized with the host files, making it ideal for development scenarios.