Skip to content

Commit 001571b

Browse files
authored
ESP Backpack logger improvements (ExpressLRS#252)
* ESPbackpack: STK500 support added * Logger bin renamed to avoid mistakes * Sync wait timeout fix * Logger: support for STM32 flash offset + STK500 fixes * WIFI upload to allow user specific upload_port * ESPbackpack enhancements * STK500 sync fail info improved * STM32 filename check before flashing * ESPbackpack to check firmware filenames Firmware filenames are checked and user noted if filenames does not match to expected.
1 parent 2ae620d commit 001571b

9 files changed

Lines changed: 543 additions & 163 deletions

File tree

src/ESPbackpack/html/index_compressed.html

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<meta charset="utf-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<link rel="stylesheet" href="main.css" />
8+
<style>
9+
.hide {display: none;}
10+
</style>
811
<script>
912
var websock;
1013
function start() {
@@ -27,11 +30,10 @@
2730
};
2831
}
2932
function saveTextAsFile() {
30-
var textToWrite = document.getElementById('logField').innerHTML;
33+
var textToWrite = document.getElementById('logField').value;
3134
var textFileAsBlob = new Blob([textToWrite], { type: 'text/plain' });
32-
var fileNameToSaveAs = "tx_log.txt";
3335
var downloadLink = document.createElement("a");
34-
downloadLink.download = fileNameToSaveAs;
36+
downloadLink.download = "tx_log.txt";
3537
downloadLink.innerHTML = "Download File";
3638
if (window.webkitURL != null) {
3739
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
@@ -90,10 +92,11 @@ <h2>Firmware Update Status:</h2>
9092
<h2>R9M Tx Firmware Update:</h2>
9193
</legend>
9294
<form method='POST' action='/upload' enctype='multipart/form-data'>
93-
<input type='file' accept='.bin' name='filesystem'>
94-
<input type='submit' value='Upload and Flash R9M Tx'>
95+
<input type='file' accept='.bin,.elrs' name='firmware' id='stm_fw'>
96+
<input type='text' value='0x0000' name='flash_address' size='6' id='stm_addr' class="hide">
97+
<input type='submit' value='Upload and Flash R9M Tx' id='stm_submit' disabled='disabled'>
9598
</form>
96-
<div style="color:red;">CAUTION! Be careful to upload the correct firmware file, otherwise a bad flash may occur! If this happens you will need to re-flash the module's firmware via USB/Serial.</div>
99+
<div style="color:red;"><span id="stm_message">CAUTION! Be careful to upload the correct firmware file, otherwise a bad flash may occur! If this happens you will need to re-flash the module's firmware via USB/Serial.</span></div>
97100
</fieldset>
98101
</div>
99102
<hr>
@@ -103,12 +106,47 @@ <h2>R9M Tx Firmware Update:</h2>
103106
<h2>WiFi Backpack Firmware Update:</h2>
104107
</legend>
105108
<form method='POST' action='/update' enctype='multipart/form-data'>
106-
<input type='file' accept='.bin' name='firmware'>
107-
<input type='submit' value='Flash WiFi Backpack'>
109+
<input type='file' accept='.bin,.bin.gz' name='backpack_fw' id='esp_fw'>
110+
<input type='submit' value='Flash WiFi Backpack' id='esp_submit' disabled='disabled'>
108111
</form>
109-
<div style="color:red;">CAUTION! Be careful to upload the correct firmware file, otherwise a bad flash may occur! If this happens you will need to re-flash the module's firmware via USB/Serial.</div>
112+
<div style="color:red;"><span id="esp_message">CAUTION! Be careful to upload the correct firmware file, otherwise a bad flash may occur! If this happens you will need to re-flash the module's firmware via USB/Serial.</span></div>
110113
</fieldset>
111114
</div>
115+
<script type="text/javascript">
116+
document.getElementById('esp_fw').onchange = function (ev) {
117+
const esp_message = document.getElementById('esp_message');
118+
const FIRMWARE_PATTERN = /backpack\.bin$/g;
119+
const uploadButton = document.getElementById('esp_submit');
120+
const value = ev.target.value;
121+
if (FIRMWARE_PATTERN.test(value)) {
122+
uploadButton.removeAttribute('disabled');
123+
esp_message.innerHTML = "Firmware file is correct";
124+
} else {
125+
uploadButton.setAttribute('disabled', 'disabled');
126+
esp_message.innerHTML = " OOPS! Incorrect firmware file! Please select correct file.";
127+
}
128+
};
129+
document.getElementById('stm_fw').onchange = function (ev) {
130+
const stm_message = document.getElementById('stm_message');
131+
const FW_PATTERN_BIN = /firmware\.bin$/g;
132+
const FW_PATTERN_ELRS = /firmware\.elrs$/g;
133+
const uploadButton = document.getElementById('stm_submit');
134+
const address = document.getElementById('stm_addr');
135+
const value = ev.target.value;
136+
address.classList.add('hide');
137+
if (FW_PATTERN_BIN.test(value)) {
138+
uploadButton.removeAttribute('disabled');
139+
address.classList.remove('hide');
140+
stm_message.innerHTML = "Note: DFU flashing will be used";
141+
} else if (FW_PATTERN_ELRS.test(value)) {
142+
uploadButton.removeAttribute('disabled');
143+
stm_message.innerHTML = "Firmware file is correct";
144+
} else {
145+
uploadButton.setAttribute('disabled', 'disabled');
146+
stm_message.innerHTML = " OOPS! Incorrect firmware file! Please select correct file.";
147+
}
148+
};
149+
</script>
112150
<hr>
113151
<div align="left">
114152
<legend>

src/ESPbackpack/platformio.ini

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,27 @@
88
; Please visit documentation for the other options and examples
99
; https://docs.platformio.org/page/projectconf.html
1010

11-
[common_env_data]
12-
src_filter = +<*> -<.git/> -<svn/> -<example/> -<examples/> -<test/> -<tests/>
13-
14-
[env:ESP_BACKPACK_ESP8285]
15-
platform = espressif8266
16-
board = esp8285
11+
[env]
1712
framework = arduino
1813
upload_speed = 115200
1914
monitor_speed = 460800
2015
monitor_dtr = 0
2116
monitor_rts = 0
22-
board_build.ldscript = eagle.flash.1m144.ld
23-
board_build.f_cpu = 80000000L
24-
src_filter = ${common_env_data.src_filter}
17+
extra_scripts =
18+
pre:rename_bin.py
2519
lib_deps =
2620
WebSockets
2721
WiFiManager
22+
src_filter = +<*> -<.git/> -<svn/> -<example/> -<examples/> -<test/> -<tests/>
23+
24+
[env:ESP_BACKPACK_ESP8285]
25+
platform = espressif8266
26+
board = esp8285
27+
board_build.ldscript = eagle.flash.1m144.ld
28+
board_build.f_cpu = 80000000L
2829

2930
[env:ESP_BACKPACK_ESP8266]
3031
platform = espressif8266
3132
board = esp01
32-
framework = arduino
33-
upload_speed = 115200
34-
monitor_speed = 460800
35-
monitor_dtr = 0
36-
monitor_rts = 0
37-
board_build.ldscript = eagle.flash.1m144.ld
33+
board_build.ldscript = eagle.flash.1m144.ld
3834
board_build.f_cpu = 80000000L
39-
src_filter = ${common_env_data.src_filter}
40-
lib_deps =
41-
WebSockets
42-
WiFiManager

src/ESPbackpack/rename_bin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Import("env")
2+
env.Replace(PROGNAME="backpack")

0 commit comments

Comments
 (0)