sudo apt update
sudo apt install -y git python3 python3-venv python3-pip build-essential
python3 -m pip install --user platformio
sudo apt install -y pipx
pipx ensurepath
pipx install platformio
pio --version
# lalu sama seperti langkah 3–6 di atas (tanpa perlu venv)
# aktifkan untuk sesi terminal ini
export PATH="$HOME/.local/bin:$PATH"
# simpan permanen untuk sesi berikutnya
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# cek
which pio || ls -l ~/.local/bin/pio
pio --version
cd ~
[ -d speeduino ] || git clone --depth=1 https://github.com/speeduino/speeduino.git
cd speeduino
grep -n "^\[env:blackpill_f411ce\]" platformio.ini || cat >> platformio.ini <<'EOF'
[env:blackpill_f411ce]
platform = https://github.com/platformio/platform-ststm32.git#237956571a140374dada64008d63628788ab6e3b
board = blackpill_f411ce
framework = arduino
board_build.core = stm32
upload_protocol = dfu
build_flags =
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
-Os -ffunction-sections -fdata-sections
-Wl,--gc-sections
; (opsional untuk memperkecil size) -flto
monitor_speed = 115200
monitor_dtr = 1
EOF
pio run -e blackpill_f411ce -t size
pio lib install "wizard97/SimplyAtomic@^1.0"
sed -i 's|#include <util/atomic.h>|#if __has_include(<SimplyAtomic.h>)\n#include <SimplyAtomic.h>\n#else\n#include <util/atomic.h>\n#endif|' speeduino/statuses.h
# install dependency RTC ke project (nama lib pakai tanda kutip karena ada spasi)
pio lib install "stm32duino/STM32duino RTC@^1.3"
# (kalau belum) SimplyAtomic juga perlu untuk non-AVR:
pio lib install "wizard97/SimplyAtomic@^1.0"