Skip to content

Commit e291505

Browse files
Add comprehensive firmware upload documentation
Co-authored-by: simonachmueller <3511513+simonachmueller@users.noreply.github.com>
1 parent 6b4f111 commit e291505

2 files changed

Lines changed: 287 additions & 0 deletions

File tree

FIRMWARE_UPLOAD.md

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
# Firmware Upload Guide
2+
3+
This guide explains how to upload firmware to your ESP32Focuser microcontroller.
4+
5+
## Prerequisites
6+
7+
Before uploading firmware, ensure you have the following:
8+
9+
### Hardware Requirements
10+
- ESP32 development board (as used in the ESP32Focuser hardware)
11+
- USB cable (typically USB-A to Micro-USB or USB-C, depending on your board)
12+
- Computer with USB port
13+
14+
### Software Requirements
15+
- **USB to UART Bridge Driver**: CP210x driver from [Silicon Labs](https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers)
16+
- Windows usually installs this automatically
17+
- Linux and macOS typically have built-in support
18+
19+
## Method 1: Using PlatformIO (Recommended for Developers)
20+
21+
PlatformIO is the recommended method if you want to build from source or make modifications.
22+
23+
### Installation
24+
25+
1. **Install Visual Studio Code**
26+
- Download from [https://code.visualstudio.com/](https://code.visualstudio.com/)
27+
28+
2. **Install PlatformIO IDE Extension**
29+
- Open VS Code
30+
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
31+
- Search for "PlatformIO IDE"
32+
- Click Install
33+
34+
### Uploading Firmware
35+
36+
1. **Clone or Download the Repository**
37+
```bash
38+
git clone https://github.com/simonachmueller/ESP32Focuser.git
39+
cd ESP32Focuser
40+
```
41+
42+
2. **Open Project in VS Code**
43+
- Open VS Code
44+
- File → Open Folder
45+
- Select the ESP32Focuser directory
46+
47+
3. **Connect Your ESP32**
48+
- Connect your ESP32 board to your computer via USB
49+
- The board should be recognized as a serial port
50+
51+
4. **Configure Upload Port (if needed)**
52+
- Edit `platformio.ini` and update the `upload_port` line:
53+
- **Windows**: `COM3`, `COM4`, etc.
54+
- **Linux**: `/dev/ttyUSB0`, `/dev/ttyUSB1`, etc.
55+
- **macOS**: `/dev/cu.usbserial-*` or `/dev/cu.SLAB_USBtoUART`
56+
57+
You can also let PlatformIO auto-detect the port by commenting out or removing the `upload_port` line.
58+
59+
5. **Build and Upload**
60+
- Click the PlatformIO icon in the left sidebar
61+
- Click "Upload" under "PROJECT TASKS" → "esp32dev"
62+
- Or use the shortcut: Press Ctrl+Alt+U (Cmd+Alt+U on macOS)
63+
- Or use the command line:
64+
```bash
65+
platformio run --target upload
66+
```
67+
68+
6. **Monitor Serial Output (Optional)**
69+
- Click "Monitor" under "PROJECT TASKS""esp32dev"
70+
- Or press Ctrl+Alt+S (Cmd+Alt+S on macOS)
71+
- Or use the command line:
72+
```bash
73+
platformio device monitor
74+
```
75+
76+
## Method 2: Using esptool.py (For Pre-built Binaries)
77+
78+
This method is useful when you have a pre-built firmware binary (e.g., from GitHub releases).
79+
80+
### Installation
81+
82+
1. **Install Python** (if not already installed)
83+
- Download from [https://www.python.org/downloads/](https://www.python.org/downloads/)
84+
- Make sure to check "Add Python to PATH" during installation
85+
86+
2. **Install esptool**
87+
```bash
88+
pip install esptool
89+
```
90+
91+
### Downloading Firmware
92+
93+
1. **From GitHub Releases**
94+
- Visit [https://github.com/simonachmueller/ESP32Focuser/releases](https://github.com/simonachmueller/ESP32Focuser/releases)
95+
- Download the latest `firmware.bin` file
96+
97+
2. **From GitHub Actions Artifacts**
98+
- Go to [https://github.com/simonachmueller/ESP32Focuser/actions](https://github.com/simonachmueller/ESP32Focuser/actions)
99+
- Click on the latest successful workflow run
100+
- Download the `firmware.bin` artifact
101+
- Extract the zip file to get `firmware.bin`
102+
103+
### Uploading Firmware
104+
105+
1. **Connect Your ESP32**
106+
- Connect your ESP32 board via USB
107+
108+
2. **Find the Serial Port**
109+
- **Windows**: Check Device Manager → Ports (COM & LPT)
110+
- **Linux**: Run `ls /dev/ttyUSB*` or `ls /dev/ttyACM*`
111+
- **macOS**: Run `ls /dev/cu.*`
112+
113+
3. **Upload the Firmware**
114+
115+
Replace `<PORT>` with your serial port (e.g., `COM3`, `/dev/ttyUSB0`, `/dev/cu.SLAB_USBtoUART`):
116+
117+
```bash
118+
esptool.py --chip esp32 --port <PORT> --baud 460800 write_flash -z 0x10000 firmware.bin
119+
```
120+
121+
Example for Windows:
122+
```bash
123+
esptool.py --chip esp32 --port COM3 --baud 460800 write_flash -z 0x10000 firmware.bin
124+
```
125+
126+
Example for Linux/macOS:
127+
```bash
128+
esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x10000 firmware.bin
129+
```
130+
131+
4. **Wait for Upload to Complete**
132+
- The process typically takes 10-30 seconds
133+
- You'll see progress indicators during the upload
134+
135+
## Method 3: Using Arduino IDE (Alternative Method)
136+
137+
If you prefer Arduino IDE:
138+
139+
### Installation
140+
141+
1. **Install Arduino IDE**
142+
- Download from [https://www.arduino.cc/en/software](https://www.arduino.cc/en/software)
143+
144+
2. **Add ESP32 Board Support**
145+
- Open Arduino IDE
146+
- File → Preferences
147+
- Add to "Additional Board Manager URLs":
148+
```
149+
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
150+
```
151+
- Tools → Board → Boards Manager
152+
- Search for "esp32"
153+
- Install "esp32 by Espressif Systems"
154+
155+
3. **Install Required Libraries**
156+
- Tools → Manage Libraries
157+
- Search and install: "ESP32Encoder"
158+
159+
### Uploading Firmware
160+
161+
1. **Open the Project**
162+
- Open `src/main.cpp` in Arduino IDE
163+
164+
2. **Configure Board Settings**
165+
- Tools → Board → ESP32 Arduino → ESP32 Dev Module
166+
- Tools → Port → Select your ESP32's port
167+
- Tools → Upload Speed → 115200
168+
169+
3. **Upload**
170+
- Click the Upload button (→) or press Ctrl+U
171+
- Wait for the upload to complete
172+
173+
## Troubleshooting
174+
175+
### Device Not Detected
176+
177+
**Problem**: Computer doesn't recognize the ESP32 board.
178+
179+
**Solutions**:
180+
- Install or reinstall the CP210x USB to UART bridge driver
181+
- Try a different USB cable (some cables are power-only)
182+
- Try a different USB port
183+
- Press and hold the BOOT button on the ESP32 while connecting
184+
185+
### Upload Fails / Timeout Errors
186+
187+
**Problem**: Upload starts but fails with timeout or connection errors.
188+
189+
**Solutions**:
190+
1. **Put ESP32 in Download Mode**:
191+
- Hold the BOOT button
192+
- Press and release the EN (reset) button
193+
- Release the BOOT button
194+
- Try uploading again
195+
196+
2. **Reduce Upload Speed**:
197+
- For PlatformIO, add to `platformio.ini`:
198+
```ini
199+
upload_speed = 115200
200+
```
201+
- For esptool, change `--baud 460800` to `--baud 115200`
202+
203+
3. **Check Port Access** (Linux/macOS):
204+
- Add your user to the dialout group:
205+
```bash
206+
sudo usermod -a -G dialout $USER
207+
```
208+
- Log out and log back in
209+
- Or use sudo: `sudo esptool.py ...`
210+
211+
### Wrong Port Selected
212+
213+
**Problem**: Cannot find the correct serial port.
214+
215+
**Solutions**:
216+
- Disconnect the ESP32, note available ports
217+
- Reconnect the ESP32, check which new port appears
218+
- On Linux, check `dmesg | tail` after connecting
219+
- On Windows, check Device Manager → Ports (COM & LPT)
220+
221+
### Permission Denied (Linux/macOS)
222+
223+
**Problem**: Permission errors when accessing the serial port.
224+
225+
**Solutions**:
226+
```bash
227+
# Add user to dialout group
228+
sudo usermod -a -G dialout $USER
229+
230+
# Or change port permissions temporarily
231+
sudo chmod 666 /dev/ttyUSB0
232+
```
233+
234+
### Out of Memory or Flash Errors
235+
236+
**Problem**: Flash operation fails with memory errors.
237+
238+
**Solutions**:
239+
- Erase the flash completely first:
240+
```bash
241+
esptool.py --chip esp32 --port <PORT> erase_flash
242+
```
243+
- Then try uploading again
244+
245+
## Verifying the Upload
246+
247+
After uploading, verify the firmware is running:
248+
249+
1. **Check Serial Output**
250+
- Open a serial monitor at 115200 baud
251+
- You should see output from the focuser
252+
253+
Using PlatformIO:
254+
```bash
255+
platformio device monitor -b 115200
256+
```
257+
258+
Using screen (Linux/macOS):
259+
```bash
260+
screen /dev/ttyUSB0 115200
261+
```
262+
263+
2. **Test Focuser Connection**
264+
- Follow the installation instructions in the main README.md
265+
- Connect using MoonLite software or ASCOM driver
266+
- Test basic focuser movements
267+
268+
## Additional Resources
269+
270+
- **PlatformIO Documentation**: [https://docs.platformio.org/](https://docs.platformio.org/)
271+
- **ESP32 Documentation**: [https://docs.espressif.com/projects/esp-idf/en/latest/esp32/](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/)
272+
- **esptool Documentation**: [https://github.com/espressif/esptool](https://github.com/espressif/esptool)
273+
- **Hardware Repository**: [https://github.com/simonachmueller/ESP32Focuser-hardware](https://github.com/simonachmueller/ESP32Focuser-hardware)
274+
275+
## Getting Help
276+
277+
If you encounter issues not covered in this guide:
278+
- Check the [Issues](https://github.com/simonachmueller/ESP32Focuser/issues) page
279+
- Open a new issue with details about your problem
280+
- Include your operating system, board type, and error messages

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ This is a port of an awesome code from https://github.com/Hansastro/Focuser to E
1111
# Hardware
1212
If you want to build a focuser controller by yourself, please check out a hardware repository https://github.com/simonachmueller/ESP32Focuser-hardware
1313

14+
# Firmware Upload
15+
To upload firmware to your ESP32 microcontroller, see the detailed [Firmware Upload Guide](FIRMWARE_UPLOAD.md). The guide covers multiple upload methods including:
16+
- Using PlatformIO (recommended for developers)
17+
- Using esptool.py for pre-built binaries
18+
- Using Arduino IDE
19+
- Troubleshooting common issues
20+
1421
# Installation for computer-controlled use
1522
## Windows
1623
1. Install CP210x driver from https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers if not installed automatically by windows itself

0 commit comments

Comments
 (0)