Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give SerialNINAPassthrough flash rate 10x speedup #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sameer
Copy link

@sameer sameer commented Mar 19, 2020

Buffering the Serial TX/RX makes flashing with esptool that much faster.
Instead of 13.5 minutes it now takes a mere 47.9 seconds on MKR Vidor 4000.

I tested flashing with a couple buffer sizes: 16, 64, 4096, 512, 128 and settled on 512 which gave the highest transfer rate:

> python /opt/esp-idf/components/esptool_py/esptool/esptool.py --no-stub --chip esp32 --port /dev/ttyACM0 --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x0 WiFi101-FirmwareUpdater-Plugin/firmwares/NINA/1.2.1/NINA_W102.bin
esptool.py v2.8
Serial port /dev/ttyACM0
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 80:7d:3a:86:7f:78
Changing baud rate to 460800
Changed.
Enabling default SPI flash mode...
Configuring flash size...
Auto-detected Flash size: 2MB
Erasing flash...
Compressed 880640 bytes to 495730...
Took 7.31s to erase flash block
Wrote 880640 bytes (495730 compressed) at 0x00000000 in 47.9 seconds (effective 147.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Buffering the Serial TX/RX makes flashing with esptool that much faster.
Instead of 13.5 minutes it now takes a mere 47.9 seconds on MKR Vidor 4000.

I tested flashing with a couple buffer sizes: 16, 64, 4096, 512, 128 and settled on 512 which gave the highest transfer rate:
```
> python /opt/esp-idf/components/esptool_py/esptool/esptool.py --no-stub --chip esp32 --port /dev/ttyACM0 --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x0 WiFi101-FirmwareUpdater-Plugin/firmwares/NINA/1.2.1/NINA_W102.bin
esptool.py v2.8
Serial port /dev/ttyACM0
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 80:7d:3a:86:7f:78
Changing baud rate to 460800
Changed.
Enabling default SPI flash mode...
Configuring flash size...
Auto-detected Flash size: 2MB
Erasing flash...
Compressed 880640 bytes to 495730...
Took 7.31s to erase flash block
Wrote 880640 bytes (495730 compressed) at 0x00000000 in 47.9 seconds (effective 147.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
```
@per1234 per1234 added the type: enhancement Proposed improvement label Mar 20, 2020
@JAndrassy
Copy link

JAndrassy commented Mar 20, 2020

did you test it with other boards with Nina? Wouldn't replacing if with while be sufficient?
I don't see how this should be faster for normal UART. But on Vigor I guess the connection is not direct and the buffers help to go faster over some protocol (FPGA). (The first Uno WiFi had similar problems, because it has I2C to Serial adapter to wire the esp8266.)

@sameer
Copy link
Author

sameer commented Mar 20, 2020

did you test it with other boards with Nina?

I only own the Vidor, but if someone has another wifi board it would would be helpful to have a test there.

Wouldn't replacing if with while be sufficient?

I tried this first, but the speed-up was only around 3x to 4x.

I don't see how this should be faster for normal UART. But on Vigor I guess the connection is not direct and the buffers help to go faster over some protocol (FPGA). (The first Uno WiFi had similar problems, because it has I2C to Serial adapter to wire the esp8266.)

That could be it, I didn't realize the SerialNINA was going through the FPGA. Then a test is definitely needed with another board to know if this logic should be gated solely for the Vidor.

@JuliDi
Copy link

JuliDi commented Mar 26, 2021

I can confirm that @sameer 's change works on the MKR Vidor 4000. Flashing firmware version 1.4.3 took only around one minute.
However, esptool failed with the suggested baud rate of 460800. Had to use esptool with --baud 115200.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants