Skip to content

Commit 4eb8af3

Browse files
authored
Merge pull request #144 from sarfata/feature/fix-esp-upload
Feature/fix esp upload
2 parents 415cc8d + 6455096 commit 4eb8af3

File tree

7 files changed

+48
-15
lines changed

7 files changed

+48
-15
lines changed

.travis.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,23 @@ script:
4141
after_success:
4242
- coveralls --exclude src/test --exclude /lib --exclude lib --exclude .piolibdeps
4343

44+
before_deploy:
45+
- mv .pioenvs/host/firmware.elf ./kbox-firmware-$TRAVIS_TAG.elf
46+
- mv .pioenvs/host/firmware.hex ./kbox-firmware-$TRAVIS_TAG.hex
47+
- mv .pioenvs/esp/firmware.elf ./kbox-wifi-$TRAVIS_TAG.elf
48+
- mv .pioenvs/esp/firmware.bin ./kbox-wifi-$TRAVIS_TAG.bin
49+
- mv .pioenvs/sktool/program ./sktool-$TRAVIS_TAG
50+
4451
deploy:
4552
provider: releases
4653
api_key:
4754
secure: QYe/1yIJZbSe5uZfoCROTT7s+1Yhe0lY1Ww8Ia//yYMQOYjvkjY+UAHaZ7FN+X3MBHPcMQCEPxeG4Hmy7fvTTV2nIRPlkheirZqSYt7HYr9WdbA/N29F92o/EMT5nQgqfmOf9u61Hx5K3JLyBnLIilajOpnHgARJXgg7w8lC2hE57k9oO0PWlFLGrNZRa9xfHeHnrOVL90TW3sk6/YR6J5u+cg2ZMwFPs8PPCxw/cBDowvQ3JrXrrQwRxHiAnrTscYlHoFEidsAAnrL99GROiRgFEGYQhddilztQ/h52AUy9+QDxAlVgxV/hi1+AUOGeeSK4GQPugrfH1+3kTR4a6T/XdTBoydTQSUYTHU4PcKJwzoaEwOVGVr4lg0Fl5ZCktcPLlY+TBHfBfitPAaNujWTA5P/pUv3Vwdq5pX4xYfhqFKIqZohlDOYEhk0xtAYvlYB4teaLCGkPNjtBi+8e11FghdaSZ/G6vXCkvGeOPrSIcp9g4pwnpwwhMMJISdpnpxm5cSLZJBOAJybsYUIPjVtjfvAQ6e0GpvcQsePDFBz6qSFSvYIpgEBE8gOcNotWHyiHjCkV4aAm+mBFmJ5Ndfr6XMSK+uARWG98FRrGNN4HZJl3h7cRrd2f1cOIm9N7SWLIXmMwEMYyIq+X++ZCKqOMhFnw3THhFxZ+U5ACOQM=
4855
file:
49-
- ".pioenvs/host/firmware.elf"
50-
- ".pioenvs/host/firmware.hex"
51-
- ".pioenvs/esp/firmware.elf"
52-
- ".pioenvs/esp/firmware.bin"
53-
- ".pioenvs/sktool/program"
56+
- ./kbox-firmware-$TRAVIS_TAG.elf
57+
- ./kbox-firmware-$TRAVIS_TAG.hex
58+
- ./kbox-wifi-$TRAVIS_TAG.elf
59+
- ./kbox-wifi-$TRAVIS_TAG.bin
60+
- ./sktool-$TRAVIS_TAG
5461
skip_cleanup: true
5562
on:
5663
repo: sarfata/kbox-firmware

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,21 @@ been possible!**
192192

193193
## Changelog
194194

195+
* 2018 07 06 - v1.3.3
196+
* Fix a bug which forced us to use `program-esp` to update the wifi module.
197+
It is now possible again to just use the following commands to update KBox:
198+
199+
platform run -e host -t upload
200+
platformio run -e esp -t upload
201+
202+
* Change default esp upload speed to 921600 because 2000000 does not seem well
203+
supported on Windows.
204+
* Changed the 'end of programming' detection method to more reliably detect when
205+
we are done programming and reboot KBox.
206+
* Tested the official ESP uploader on Windows and OS X. Comment out the line
207+
`tools/platformio_cfg_esp.py` in `platformio.ini` to use it.
208+
It will be a little bit slower but might work better for some people.
209+
195210
* 2018 07 06 - v1.3.2
196211
* Changes to the build configuration to improve compatibility with Windows
197212
and address breaking changes in plaformio.

lib/KBoxHardware/src/KBoxHardware.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ void KBoxHardware::setBacklight(BacklightIntensity intensity) {
106106
}
107107

108108
void KBoxHardware::espInit() {
109-
WiFiSerial.begin(1000000);
110-
WiFiSerial.setTimeout(0);
111-
112109
digitalWrite(wifi_enable, 0);
113110
digitalWrite(wifi_rst, 0);
114111

@@ -129,6 +126,9 @@ void KBoxHardware::espInit() {
129126
}
130127

131128
void KBoxHardware::espRebootInFlasher() {
129+
WiFiSerial.begin(115200);
130+
WiFiSerial.setTimeout(0);
131+
132132
digitalWrite(wifi_enable, 0);
133133
digitalWrite(wifi_rst, 0);
134134
digitalWrite(wifi_program, 0);
@@ -141,6 +141,9 @@ void KBoxHardware::espRebootInFlasher() {
141141
}
142142

143143
void KBoxHardware::espRebootInProgram() {
144+
WiFiSerial.begin(1000000);
145+
WiFiSerial.setTimeout(0);
146+
144147
digitalWrite(wifi_enable, 0);
145148
digitalWrite(wifi_rst, 0);
146149
digitalWrite(wifi_program, 1);

platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ build_flags = -Wall -Werror -fno-strict-aliasing
9191
platform=https://github.com/platformio/platform-espressif8266.git#feature/stage
9292
framework = arduino
9393
board = esp_wroom_02
94+
upload_speed = 921600
9495
extra_scripts =
9596
tools/platformio_cfg_esp.py
9697
tools/platformio_cfg_gitversion.py

src/host/esp-programmer/ESPProgrammer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ void ESPProgrammer::loopByteMode() {
121121
if (espSerial.available()) {
122122
int read = espSerial.readBytes(buffer, min(bootloaderMtu, espSerial.available()));
123123
computerSerial.write(buffer, read);
124-
timeSinceLastByte = 0;
125124
}
126125
}
127126
}
@@ -165,7 +164,6 @@ void ESPProgrammer::loopFrameMode() {
165164
size_t len = espConnection.readFrame(buffer, bootloaderMtu);
166165
debugFrame("ESP", buffer, len);
167166
computerConnection.writeFrame(buffer, len);
168-
timeSinceLastByte = 0;
169167
}
170168
}
171169

@@ -210,7 +208,7 @@ void ESPProgrammer::updateColors() {
210208
wheelIndex++;
211209
}
212210

213-
// Intensity of color will be proportial to how recent the last byte received was
211+
// Intensity of color will be proportional to how recent the last byte received was
214212
// After 500ms, the color will be 0
215213
int dim = 0;
216214
if (timeSinceLastByte < 500) {

src/host/services/USBService.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ void USBService::loop() {
7474
_state = ConnectedDebug;
7575
}
7676

77-
/* Switching serial port to 230400 on computer signals that the host
77+
/* Switching serial port to 230400 (or 921600) on computer signals that the host
7878
* wants to go into ESP Programming mode.
7979
*/
80-
if (Serial.baud() == 230400) {
80+
if (Serial.baud() == 230400 || Serial.baud() == 921600) {
8181
_state = ConnectedESPProgramming;
8282
}
8383

@@ -158,10 +158,19 @@ void USBService::loopConnectedESPProgramming() {
158158
ESPProgrammerDelegateImpl delegate;
159159
ESPProgrammer programmer(KBox.getNeopixels(), Serial, Serial1, delegate);
160160

161+
#if DEBUGGING_ESP_UPLOAD
162+
// Redirect all logs to NMEA2 at 1Mbit/s.
163+
NMEA2_SERIAL.begin(1000000);
164+
KBoxLogging.setLogger(new KBoxLoggerStream(NMEA2_SERIAL));
165+
#endif
166+
DEBUG("Switching to ESP Programming mode");
167+
161168
while (programmer.getState() != ESPProgrammer::ProgrammerState::Done) {
162169
programmer.loop();
170+
KBox.watchdogRefresh();
163171
}
164-
DEBUG("Exiting programmer mode");
172+
173+
DEBUG("Exiting programmer mode"); delay(100);
165174
KBox.rebootKBox();
166175
}
167176

tools/platformio_cfg_esp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
env.Replace(
77
LOCAL_UPLOADERFLAGS=[
88
"-p", "$UPLOAD_PORT",
9-
"-b", "2000000",
9+
"-b", "$UPLOAD_SPEED",
1010
"write_flash", "--flash_mode", "dio", "--flash_size", "16m",
1111
],
1212
UPLOADER=LOCAL_UPLOADER,

0 commit comments

Comments
 (0)