Skip to content

Conversation

@aykevl
Copy link
Member

@aykevl aykevl commented Aug 28, 2020

This PR is a followup to #1289. It adds support for the custom image format used by the ESP32 and flashes it using esptool.py.
A future improvement may be to use one of the Go implementations of esptool to avoid the extra dependency.

Making this a draft for now until #1289 is merged (it should be rebased when it gets merged).

@deadprogram
Copy link
Member

deadprogram commented Aug 31, 2020

If you install via the Debian package, it names it esptool not esptool.py:

$ esptool.py version
esptool.py: command not found

$ esptool version
esptool.py v2.1
2.1

aykevl added 2 commits August 31, 2020 12:00
Some chips (like the ESP family) have a particular image format that is
more complex than simply dumping everything in a raw image.
Right now this requires setting the -port parameter, but other than that
it totally works (if esptool.py is installed). It works by converting
the ELF file to the custom ESP32 image format and flashing that using
esptool.py.
@aykevl
Copy link
Member Author

aykevl commented Aug 31, 2020

If you install via the Debian package, it names it esptool not esptool.py:

Yes. I installed it with pip3. I also checked macOS and the Homebrew version also calls it esptool.py, so I think it's better to stick to that.
(And in any case, I'd like to do this natively in TinyGo eventually which means these external commands aren't necessary anymore).

@aykevl aykevl marked this pull request as ready for review August 31, 2020 10:26
@sago35
Copy link
Member

sago35 commented Aug 31, 2020

I used apt install esptool on ubuntu 20.04 and it installed esptool instead of esptool.py.
I was able to do ln -s esptool esptool.py to tinygo flash.

@deadprogram
Copy link
Member

@sago35 on my machine it was

sudo ln -s /usr/bin/esptool /usr/bin/esptool.py

@sago35
Copy link
Member

sago35 commented Aug 31, 2020

@sago35 on my machine it was

sudo ln -s /usr/bin/esptool /usr/bin/esptool.py

me too.

@deadprogram
Copy link
Member

Just tried this branch, received the following error:

$ tinygo flash -target esp32 examples/serial
error: ROM segments are non-contiguous: /tmp/tinygo829831007/main

Am I doing this correctly?

@deadprogram
Copy link
Member

Wait, I think I have wrong version. Rebuilding...

@deadprogram
Copy link
Member

$ tinygo flash -target esp32 -port /dev/ttyUSB0 examples/serial
esptool.py v2.1
Connecting....
Chip is ESP32D0WDQ6 (revision (unknown 0xa))
Enabling default SPI flash mode...
Configuring flash size...
Auto-detected Flash size: 4MB
Erasing flash...
Flash params set to 0x032f
Took 0.04s to erase flash block
Wrote 1024 bytes at 0x00001000 in 0.1 seconds (82.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...

Worked exactly as promised. Great job @aykevl this is getting more exciting by the hour!

Now merging, we need this!

@sago35
Copy link
Member

sago35 commented Aug 31, 2020

my build log.

$ ./build/tinygo version
tinygo version 0.15.0-dev-5640eae linux/amd64 (using go version go1.14.4 and LLVM version 10.0.1)

$ ./build/tinygo build -o test.bin --target esp32 ./src/examples/serial/

$ ./build/tinygo build -o test.hex --target esp32 ./src/examples/serial/
error: ROM segments are non-contiguous: /tmp/tinygo391525433/main

$ ./build/tinygo flash --port /dev/ttyUSB0 --target esp32 ./src/examples/serial/
esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: a4:cf:12:56:2b:08
Enabling default SPI flash mode...
Configuring flash size...
Auto-detected Flash size: 4MB
Erasing flash...
Flash params set to 0x032f
Took 0.04s to erase flash block
Wrote 1024 bytes at 0x00001000 in 0.1 seconds (73.2 kbit/s)...
Hash of data verified.

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

@deadprogram deadprogram merged commit 0df4a7a into dev Aug 31, 2020
@deadprogram deadprogram deleted the esp32-flash branch August 31, 2020 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants