BitFloppy Board Flashing Guide

Install BitFloppy firmware with the method that best fits your setup.

📋 Quick Navigation

📋 Table of Contents

🚀 Quick Start

Method 1: DIYFlasher (Web)

Use DIYFlasher to flash BitFloppy directly from a supported desktop browser. Connect the board with a USB data cable, put it in bootloader mode, then choose the BitFloppy board and firmware version in DIYFlasher.

OPEN DIYFLASHER ↗

Each downloaded firmware artifact also includes flash_firmware.sh, a local script that verifies the artifact checksums and flashes the board from the command line.

Method 2: Interactive Shell Script

./flash_board.sh

Method 3: Python Script

python3 flash_board.py

Method 4: PlatformIO Integration

python3 flash_pio.py

Prerequisites Check

Before flashing, ensure all dependencies are installed:

# Check dependencies
./flash_board.sh --check-deps

# Install missing dependencies
./flash_board.sh --install-deps

# For PlatformIO (optional)
python3 flash_pio.py --install-pio

📜 Available Scripts

1. flash_board.sh - Shell Script Wrapper

Best for: Quick flashing, dependency management, PlatformIO integration

Features:

Usage:

# Interactive mode
./flash_board.sh

# Auto mode
./flash_board.sh --auto

# Specific port and firmware
./flash_board.sh --port /dev/ttyUSB0 --firmware lolin_s2_mini_v0.0.1

# Build and flash from source
./flash_board.sh --build --flash --port /dev/ttyUSB0

# Check dependencies
./flash_board.sh --check-deps

# Install dependencies
./flash_board.sh --install-deps

2. flash_board.py - Python Script

Best for: Programmatic use, detailed control, esptool integration

Features:

Usage:

# Interactive mode
python3 flash_board.py

# Auto mode
python3 flash_board.py --auto

# Specific parameters
python3 flash_board.py --port /dev/ttyUSB0 --firmware lolin_s2_mini_v0.0.1 --baudrate 115200

# List available firmware
python3 flash_board.py --list-firmware

# List available ports
python3 flash_board.py --list-ports

3. flash_pio.py - PlatformIO Script

Best for: Building from source, PlatformIO workflows, development

Features:

Usage:

# Interactive mode
python3 flash_pio.py

# Build only
python3 flash_pio.py --build

# Flash only
python3 flash_pio.py --flash --port /dev/ttyUSB0

# Build and flash
python3 flash_pio.py --build --flash --port /dev/ttyUSB0

# Serial monitor
python3 flash_pio.py --monitor --port /dev/ttyUSB0

🔧 Prerequisites

Required Software

  1. Python 3.6+
    python3 --version
    
  2. esptool
    pip install esptool
    
  3. pyserial
    pip install pyserial
    
  4. PlatformIO (optional, for building from source)
    pip install platformio
    

Automatic Dependency Management

The flashing scripts now include automatic dependency checking and installation:

Improved Error Handling

The scripts now provide:

Hardware Requirements

Supported Board

Lolin S2 Mini ESP32-S2 Board Note: Replace placeholder with actual board image

The primary supported board is the Lolin S2 Mini, a compact ESP32-S2 development board perfect for the BitFloppy project.

Driver Installation

Windows

macOS

Linux

🔌 ESP32-S2 Bootloader Mode

CRITICAL: The board must be in bootloader mode before flashing!

Method 1: GPIO0 (Most Common)

  1. Hold GPIO0 to GND (ground)
  2. Press and hold RESET while keeping GPIO0 pressed
  3. Release RESET first, then release GPIO0
  4. Keep GPIO0 held for at least 2 seconds after RESET

Method 2: GPIO45 (Some Boards)

Some ESP32-S2 boards use GPIO45 instead of GPIO0:

  1. Hold GPIO45 to GND
  2. Press and hold RESET while keeping GPIO45 pressed
  3. Release RESET first, then release GPIO45
  4. Keep GPIO45 held for at least 2 seconds after RESET

Method 3: BOOT Button (If Available)

  1. Hold the BOOT button
  2. Press and hold RESET while keeping BOOT pressed
  3. Release RESET first, then release BOOT

Visual Indicators

🔄 Flashing Methods

Method 1: Pre-built Firmware

Use existing firmware from the website/binaries/ directory:

# Interactive selection
./flash_board.sh

# Specific firmware
./flash_board.sh --firmware lolin_s2_mini_v0.0.1 --port /dev/ttyUSB0

Method 2: Build from Source

Compile and flash from source code:

# Build and flash
./flash_board.sh --build --flash --port /dev/ttyUSB0

# Or using PlatformIO directly
python3 flash_pio.py --build --flash --port /dev/ttyUSB0

Method 3: Flash Erase

Completely erase flash memory before flashing:

# Erase flash memory
./flash_board.sh --erase --port /dev/ttyUSB0
python3 flash_board.py --erase --port /dev/ttyUSB0

# Erase with reset before
./flash_board.sh --erase --port /dev/ttyUSB0 --reset-before
python3 flash_board.py --erase --port /dev/ttyUSB0 --reset-before

Method 4: PlatformIO Commands

Direct PlatformIO usage:

# Build
pio run

# Flash
pio run --target upload --upload-port /dev/ttyUSB0

# Monitor
pio device monitor --port /dev/ttyUSB0

🛠️ Troubleshooting

Common Issues

1. “No serial ports found”

Causes:

Solutions:

2. “Failed to open serial port”

Causes:

Solutions:

3. “Board not detected”

Causes:

Solutions:

4. “Flashing failed”

Causes:

Solutions:

ESP32-S2 Specific Issues

1. GPIO0 vs GPIO45

Some boards use GPIO45 instead of GPIO0:

2. USB-CDC Issues

ESP32-S2 may have USB-CDC configuration issues:

3. Driver Conflicts

Multiple drivers can cause conflicts:

Diagnostic Steps

1. Check Port Detection

# List available ports
./flash_board.sh --list-ports

# Or with Python
python3 flash_board.py --list-ports

2. Test Board Detection

# Test with esptool directly
python3 -m esptool --port /dev/ttyUSB0 --baud 115200 chip_id

3. Check Dependencies

# Check all dependencies
./flash_board.sh --check-deps

# Install missing dependencies
./flash_board.sh --install-deps

4. Verify Firmware Files

# List available firmware
./flash_board.sh --list-firmware

# Check firmware file integrity
ls -la website/binaries/*/lolin_s2_mini/*.bin

🔧 Advanced Usage

Reset Behavior Control

By default, the board is NOT reset before flashing and IS reset after flashing:

# Default behavior (no reset before, reset after)
./flash_board.sh --port /dev/ttyUSB0 --firmware lolin_s2_mini_v0.0.1
python3 flash_board.py --port /dev/ttyUSB0 --firmware lolin_s2_mini_v0.0.1

# Force reset before flashing (if needed)
./flash_board.sh --reset-before --port /dev/ttyUSB0 --firmware lolin_s2_mini_v0.0.1
python3 flash_board.py --reset-before --port /dev/ttyUSB0 --firmware lolin_s2_mini_v0.0.1

# Don't reset after flashing (keep in bootloader mode)
./flash_board.sh --no-reset-after --port /dev/ttyUSB0 --firmware lolin_s2_mini_v0.0.1
python3 flash_board.py --no-reset-after --port /dev/ttyUSB0 --firmware lolin_s2_mini_v0.0.1

# Both options combined
./flash_board.sh --reset-before --no-reset-after --port /dev/ttyUSB0 --firmware lolin_s2_mini_v0.0.1
python3 flash_board.py --reset-before --no-reset-after --port /dev/ttyUSB0 --firmware lolin_s2_mini_v0.0.1

When to use --no-reset-after:

Flash Erase Operations

Completely erase flash memory before flashing:

# Erase only
./flash_board.sh --erase --port /dev/ttyUSB0
python3 flash_board.py --erase --port /dev/ttyUSB0

# Erase with custom baudrate
./flash_board.sh --erase --port /dev/ttyUSB0 --baudrate 57600
python3 flash_board.py --erase --port /dev/ttyUSB0 --baudrate 57600

# Erase with reset before
./flash_board.sh --erase --port /dev/ttyUSB0 --reset-before
python3 flash_board.py --erase --port /dev/ttyUSB0 --reset-before

# Erase without reset after (keep in bootloader mode)
./flash_board.sh --erase --port /dev/ttyUSB0 --no-reset-after
python3 flash_board.py --erase --port /dev/ttyUSB0 --no-reset-after

Port Detection Improvements

The port detection and board checking now avoids resetting the board:

Custom Baudrates

# Use custom baudrate
./flash_board.sh --baudrate 921600 --port /dev/ttyUSB0
python3 flash_board.py --baudrate 57600 --port /dev/ttyUSB0

Environment Selection (PlatformIO)

# Use specific environment
python3 flash_pio.py --environment lolin_s2_mini --build --flash --port /dev/ttyUSB0

Clean Builds

# Clean build directory
./flash_board.sh --clean --build --flash --port /dev/ttyUSB0
python3 flash_pio.py --clean --build --flash --port /dev/ttyUSB0

Serial Monitoring

# Open serial monitor after flashing
./flash_board.sh --monitor --port /dev/ttyUSB0

# Monitor only
python3 flash_pio.py --monitor --port /dev/ttyUSB0

Batch Operations

# Build, copy to binaries, and flash
python3 flash_pio.py --build --copy-binaries --version 0.0.2 --flash --port /dev/ttyUSB0

📊 Error Codes

Code Meaning Solution
1 General error Check error message and try troubleshooting steps
2 Dependencies missing Run ./flash_board.sh --install-deps
3 Port not found Check USB connection and drivers
4 Board not detected Ensure board is in bootloader mode
5 Flashing failed Check connections and try different baudrate
6 Build failed Check source code and PlatformIO configuration
7 Permission denied Check port permissions or run with sudo

🔍 Debug Mode

Enable verbose output for detailed debugging:

# Shell script
./flash_board.sh --verbose

# Python scripts
python3 flash_board.py --verbose
python3 flash_pio.py --verbose

📝 Log Files

Scripts create detailed logs in the console. For persistent logging:

# Save output to file
./flash_board.sh --verbose 2>&1 | tee flash_log.txt
python3 flash_board.py --verbose 2>&1 | tee flash_log.txt

🤝 Support

If you encounter issues:

  1. Check this guide for common solutions
  2. Enable verbose mode for detailed output
  3. Check hardware connections and bootloader mode
  4. Verify dependencies are installed correctly
  5. Try different USB cables/ports
  6. Check board documentation for specific requirements

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Note: This guide is specifically designed for BitFloppy ESP32-S2 boards. For other ESP32 variants, some features may not work as expected.