02 Environment setup (venv, flash tools and firmware)
Do this page before starting. Commands assume the repository root - the
SR-Supportfolder you downloaded from GitHub (a zip extract may be namedSR-Support-main; it is the folder that containsfirmware/andtools/). Every Python command runs in the terminal with.venvactivated (2.3). Flashing the prebuilt firmware needs no PlatformIO and no compilation; the developer environment (2.5) is only for changing the code.
2.1 Requirements
- Windows, Linux or macOS (each command below is given for all three where it matters);
- a USB data cable (a charge-only cable will not enumerate the board);
- ESP32-S3-DevKitC-1 (8 MB flash).
2.2 Get the code and the prebuilt firmware
Clone the repository (or unzip the supplied archive) and run later commands from the repository root:
bashgit clone https://github.com/Juxi-Technology/SR-Support.git cd SR-Support(The repository is private - request access first.)
The prebuilt image lives in
firmware/releases/:File Purpose sr_support_b_ptk_factory.binmain firmware (flash at 0x0; also used for assembly centering: power up to the firmware zero, eoptional)SHA256SUMSchecksums
2.3 Create and activate the virtual environment (.venv)
All computer-side Python tools (esptool, PlatformIO, the MuJoCo tools) go into the same project-local .venv, and that .venv must be created inside the SR-Support folder downloaded from GitHub (a zip extract may be named SR-Support-main; again, the folder that contains firmware/ and tools/).
Enter that folder first - the commands below run there:
Windows (PowerShell)
cd D:\Project\SR-Support # replace with where your SR-Support folder lives
py -3.12 -m venv .venv
.\.venv\Scripts\Activate.ps1- Not sure you are in the right place? Run
dir; it must listfirmware,tools,tutorial; - Without Python 3.12, use
py -3 -m venv .venv(3.10+ works); - If PowerShell refuses to run scripts, run
Set-ExecutionPolicy -Scope Process Bypassin this window and activate again; .\.venv\Scripts\Activate.ps1is the PowerShell activation script that venv creates: the leading.\means "run the script in the current folder" and is required in PowerShell (plainActivate.ps1will not be found). Other shells use their own file:- cmd.exe:
.venv\Scripts\activate.bat - Git Bash:
source .venv/Scripts/activate - Leave the venv with
deactivate
- cmd.exe:
Windows (cmd.exe)
cd /d D:\Project\SR-Support # cmd needs /d to change drive; plain cd D:\... stays on C:
py -3.12 -m venv .venv
.venv\Scripts\activate.batTelling the shells apart: cmd prompts look like
C:\...>, PowerShell likePS C:\...>. The tutorial uses PowerShell by default; in cmd just swap the activation command foractivate.bat, everything else is identical. Administrator rights are not needed.The activation file must match the shell: cmd uses
activate.bat, PowerShell usesActivate.ps1. Running the.ps1from cmd does not activate the current window (usually nothing happens, or a separate window opens). Also make sure.venvexists first (dirmust list the.venvfolder); if not, runpy -3.12 -m venv .venvfirst.
Linux / macOS
cd ~/SR-Support # replace with where your SR-Support folder lives
python3 -m venv .venv
source .venv/bin/activate- Not sure you are in the right place? Run
ls; it must listfirmware,tools,tutorial.
After activation the prompt shows (.venv). Every command below and on the later tutorial pages runs in this activated terminal; re-activate after opening a new window. Without activation pip / python point at the system installation and installs or runs will fail.
Confirm the activation worked:
- Windows:
where python- the first line must be...\SR-Support\.venv\Scripts\python.exe; - Linux / macOS:
which python- must be.../SR-Support/.venv/bin/python.
Screen cleared after activating in cmd? The stock
activate.battemporarily switches the console code page (chcp 65001) and some terminals redraw the screen - it is not a new terminal. If the new prompt starts with(.venv)andwhere pythonpoints into.venv, the activation succeeded. To avoid the redraw, use PowerShell'sActivate.ps1(it does not touch the code page) or call.venv\Scripts\python.exewithout activating.
Directory requirement (important):
.venvmust live in theSR-Supportfolder (the repository root), never in a subfolder. The create/activate commands above use relative paths, so they must be run from that folder - after opening a new terminal, enter it first (PowerShell:cd D:\Project\SR-Support; cmd:cd /d D:\Project\SR-Support, with your path) before activating, or use an absolute path such asC:\path\SR-Support\.venv\Scripts\Activate.ps1/source /path/SR-Support/.venv/bin/activate.Once activated you can
cdinto any subfolder andpython/pip/piostill point at that.venv; but the tutorial'stools/...,firmware/...andhardware/v1/...paths are relative, so run them from theSR-Supportfolder. The venv is bound to the path where it was created: after moving or renaming the repository, delete.venvand recreate it.
2.4 Flash tools (all customers - pick one)
A prebuilt image is one bin flashed at 0x0 - no PlatformIO, no toolchain download. Make sure the terminal is in the SR-Support folder and the prompt shows (.venv).
A. Windows GUI: Espressif Flash Download Tool
- Open Espressif's official "Other Tools" page and download Flash Download Tools: https://www.espressif.com/en/support/download/other-tools
- Run it; select ESP32-S3, load
firmware/releases/sr_support_b_ptk_factory.binat address0x0, choose the port and click START.
Flash Download Tool is Windows-only; on Linux/macOS use esptool below.
B. Windows / Linux / macOS: esptool (command line)
pip install esptoolSlow network in China - use a mirror:
pip install esptool -i https://pypi.tuna.tsinghua.edu.cn/simpleFlash (COM27 is your port; Linux /dev/ttyACM0, macOS /dev/tty.usbmodem*):
python -m esptool --chip esp32s3 -p COM27 -b 460800 write_flash 0x0 firmware/releases/sr_support_b_ptk_factory.binIf connecting fails, enter download mode: hold BOOT, tap RST, release BOOT.
2.5 PlatformIO (developers only - building from source)
Skip this unless you change the code. Note: PlatformIO (including the VS Code PlatformIO extension) downloads the espressif32 platform and the Xtensa toolchain on first use (~1 GB from the PlatformIO registry and GitHub). On many networks in China this is slow or fails and needs a proxy/VPN; the VS Code extension does not avoid the download.
With the terminal in the SR-Support folder and (.venv) active:
pip install platformioOn Windows you can also run tools/install_platformio.ps1, which installs into this same .venv. Verify:
pio --versionOlder tutorial versions installed PlatformIO into a separate
.venv-pio; it now lives in the single.venv. Ifpiois not found after upgrading, runpip install platformioin the activated.venv(or reruntools/install_platformio.ps1); the old.venv-piocan be deleted.
2.6 Computer-side tools and MuJoCo environment (twin / zeroing / logs)
Not needed for flashing. Install it when you use the arrow-key zero tool, the MuJoCo live twin (tools/live_twin.py), the simulation replay or the log tools. With the terminal in the SR-Support folder and .venv active, install the dependencies (pyserial, numpy, MuJoCo 3.1+, gymnasium):
pip install -r tools/requirements.txtOn Windows you can also run tools/install_tools_env.ps1 (creates/reuses .venv and installs the same set). On a slow network in China append the Tsinghua mirror -i https://pypi.tuna.tsinghua.edu.cn/simple; the first install downloads a few hundred MB.
Check: run the environment self-test (it loads and steps MuJoCo, not just imports)
python tools/env_check.pyThe last line must be env check: PASS, with output like:
[ok] mujoco 3.16.0
[ok] model hardware\v1\robot_v1.xml: nq=9 nv=8 dt=0.0002s, 200 steps stable ...With no board plugged in, [--] no serial port found is informational and does not affect PASS.
On Linux, a GLFW/OpenGL error when the MuJoCo window opens means missing system libraries: install
libgl1andlibglew-dev(e.g.sudo apt install libgl1 libglew-dev). The Windows/macOS MuJoCo wheels bundle what they need. Thetraining/b_linesimulation and replay use the same environment - nothing extra to install.
2.7 Connect the board and confirm the serial port
- Connect over USB-C; on Windows read the COM number in Device Manager, on Linux it is usually
/dev/ttyACM0(add your user to thedialoutgroup), on macOS usually/dev/tty.usbmodem*; - Remember the port - every
COM27in later pages is this value; - A serial monitor or
hw_monitor.pyholds the port; close it before flashing.
2.8 Checklist
- [ ] the terminal is in the repository root and the prompt shows
(.venv)(check withpwd/Get-Location); - [ ]
firmware/releases/sr_support_b_ptk_factory.binexists and verifies (sha256sum -c firmware/releases/SHA256SUMS); - [ ]
python -m esptool versionworks, or Flash Download Tool opens; - [ ] the board's serial port is visible;
- [ ] (developers)
pio --versionworks; - [ ]
python tools/env_check.pyprintsenv check: PASS.
Only continue once the items you need pass.

