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

esp*: updates to the programmer configuration #11646

Merged
merged 4 commits into from
Sep 10, 2019

Conversation

cladmi
Copy link
Contributor

@cladmi cladmi commented Jun 6, 2019

Contribution description

This updates/cleans up some the declaration of the flasher/reset interaction.

  • Set FLASHFILE as file used for flashing. A machine with only esptool.py and no toolchain can correctly flash the device (Split in cpu/esp*: use FLASHFILE for esp32 and esp8266 boards #11648)
  • use esptool.py from the path removed from this one
  • Update to use RESET_FLAGS and use ?= for affectation
  • Use PORT for reset too.
  • Append the FLASHDEPS
  • Use new size format (only a warning removal)

These updates are required for me for flashing the boards that are on another machine without toolchain with multiple boards connected. #10870

Testing procedure

Flashing and resetting with esptool.py installed from pip and without the SDK installed using PORT.

PORT=/dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_d27cb210df3de81181be72c97a7060d0-if00-port0 BOARD=esp32-wroom-32 BUILD_IN_DOCKER=1 DOCKER="sudo docker" make -C examples/default/ reset flash term

PORT=/dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_d27cb210df3de81181be72c97a7060d0-if00-port0 BOARD=esp32-wroom-32 BUILD_IN_DOCKER=1 DOCKER="sudo docker" make -C examples/default/ reset flash term 2>&1 | tee output_esp32
make: Entering directory '/home/harter/work/git/RIOT/examples/default'
ESP32_SDK_DIR should be defined as /path/to/esp-idf directory
ESP32_SDK_DIR is set by default to /opt/esp/esp-idf
esptool.py --port /dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_d27cb210df3de81181be72c97a7060d0-if00-port0 --before default_reset run
esptool.py v2.6
Serial port /dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_d27cb210df3de81181be72c97a7060d0-if00-port0
Connecting....
Detecting chip type... ESP32
Chip is ESP32D0WDQ5 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: 30:ae:a4:d3:46:00
Uploading stub...
Running stub...
Stub running...
Hard resetting via RTS pin...
�[1;32mLaunching build container using image "riot/riotbuild:latest".�[0m
sudo docker run --rm -t -u "$(id -u)" \
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/RIOT:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'     \
    -e 'BOARD=esp32-wroom-32' \
    -w '/data/riotbuild/riotbase/examples/default/' \
    'riot/riotbuild:latest' make   
ESP32_SDK_DIR should be defined as /path/to/esp-idf directory
ESP32_SDK_DIR is set by default to /opt/esp/esp-idf
�[1;32mBuilding application "default" for "esp32-wroom-32" with MCU "esp32".�[0m

"make" -C /data/riotbuild/riotbase/boards/esp32-wroom-32
"make" -C /data/riotbuild/riotbase/boards/common/esp32
"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/cpu/esp32
"make" -C /data/riotbuild/riotbase/cpu/esp32/freertos
"make" -C /data/riotbuild/riotbase/cpu/esp32/periph
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf/driver
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf/esp32
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf/heap
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf/soc
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf/spi_flash
"make" -C /data/riotbuild/riotbase/cpu/esp32/vendor/esp-idf/wpa_supplicant
"make" -C /data/riotbuild/riotbase/cpu/esp_common
"make" -C /data/riotbuild/riotbase/cpu/esp_common/vendor
"make" -C /data/riotbuild/riotbase/cpu/esp_common/vendor/xtensa
"make" -C /data/riotbuild/riotbase/drivers
"make" -C /data/riotbuild/riotbase/drivers/periph_common
"make" -C /data/riotbuild/riotbase/drivers/saul
"make" -C /data/riotbuild/riotbase/sys
"make" -C /data/riotbuild/riotbase/sys/auto_init
"make" -C /data/riotbuild/riotbase/sys/auto_init/saul
"make" -C /data/riotbuild/riotbase/sys/div
"make" -C /data/riotbuild/riotbase/sys/fmt
"make" -C /data/riotbuild/riotbase/sys/isrpipe
"make" -C /data/riotbuild/riotbase/sys/log
"make" -C /data/riotbuild/riotbase/sys/luid
"make" -C /data/riotbuild/riotbase/sys/newlib_syscalls_default
"make" -C /data/riotbuild/riotbase/sys/phydat
"make" -C /data/riotbuild/riotbase/sys/ps
"make" -C /data/riotbuild/riotbase/sys/random
"make" -C /data/riotbuild/riotbase/sys/random/tinymt32
"make" -C /data/riotbuild/riotbase/sys/saul_reg
"make" -C /data/riotbuild/riotbase/sys/shell
"make" -C /data/riotbuild/riotbase/sys/shell/commands
"make" -C /data/riotbuild/riotbase/sys/stdio_uart
"make" -C /data/riotbuild/riotbase/sys/tsrb
"make" -C /data/riotbuild/riotbase/sys/xtimer
   text	   data	    bss	    dec	    hex	filename
  71157	   4884	   6252	  82293	  14175	/data/riotbuild/riotbase/examples/default/bin/esp32-wroom-32/default.elf
esptool.py --chip esp32 elf2image -fm dout -fs 2MB -ff 40m    -o /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/default.elf.bin /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/default.elf; echo "" > /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/partitions.csv; echo "nvs, data, nvs, 0x9000, 0x6000" >> /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/partitions.csv; echo "phy_init, data, phy, 0xf000, 0x1000" >> /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/partitions.csv; echo -n "factory, app, factory, 0x10000, " >> /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/partitions.csv; ls -l /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/default.elf.bin | awk '{ print $5 }' >> /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/partitions.csv; python /home/harter/work/git/RIOT/cpu/esp32/gen_esp32part.py --disable-sha256sum --verify /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/partitions.csv /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/partitions.bin
esptool.py v2.6
Parsing CSV input...
esptool.py --chip esp32 -p /dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_d27cb210df3de81181be72c97a7060d0-if00-port0 -b 460800 --before default_reset --after hard_reset write_flash -z -fm dout -fs detect -ff 40m    0x1000 /home/harter/work/git/RIOT/cpu/esp32/bin/bootloader.bin 0x8000 /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/partitions.bin 0x10000 /home/harter/work/git/RIOT/examples/default/bin/esp32-wroom-32/default.elf.bin
esptool.py v2.6
Serial port /dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_d27cb210df3de81181be72c97a7060d0-if00-port0
Connecting....
Chip is ESP32D0WDQ5 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: 30:ae:a4:d3:46:00
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0320
Compressed 20608 bytes to 12166...

Writing at 0x00001000... (100 %)
Wrote 20608 bytes (12166 compressed) at 0x00001000 in 0.3 seconds (effective 597.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 85...

Writing at 0x00008000... (100 %)
Wrote 3072 bytes (85 compressed) at 0x00008000 in 0.0 seconds (effective 4526.8 kbit/s)...
Hash of data verified.
Compressed 103840 bytes to 49682...

Writing at 0x00010000... (25 %)
Writing at 0x00014000... (50 %)
Writing at 0x00018000... (75 %)
Writing at 0x0001c000... (100 %)
Wrote 103840 bytes (49682 compressed) at 0x00010000 in 1.4 seconds (effective 597.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
/home/harter/work/git/RIOT/dist/tools/pyterm/pyterm -p "/dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_d27cb210df3de81181be72c97a7060d0-if00-port0" -b "115200"
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2019-06-06 15:17:35,259 - INFO # Connect to serial port /dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_d27cb210df3de81181be72c97a7060d0-if00-port0
Welcome to pyterm!
Type '/exit' to exit.
2019-06-06 15:17:36,265 - INFO # esp_image: segment 1: paddr=0x000127e0 vaddr=0x3ffb0000 size=0x01314 (  4884) load�[0m
2019-06-06 15:17:36,266 - INFO # �[0;32mI (105) esp_image: segment 2: paddr=0x00013afc vaddr=0x40080000 size=0x00400 (  1024) load�[0m
2019-06-06 15:17:36,267 - INFO # �[0;32mI (112) esp_image: segment 3: paddr=0x00013f04 vaddr=0x40080400 size=0x054e8 ( 21736) load�[0m
2019-06-06 15:17:36,268 - INFO # �[0;32mI (130) esp_image: segment 4: paddr=0x000193f4 vaddr=0x00000000 size=0x06c1c ( 27676) �[0m
2019-06-06 15:17:36,269 - INFO # �[0;32mI (141) esp_image: segment 5: paddr=0x00020018 vaddr=0x400d0018 size=0x09558 ( 38232) map�[0m
2019-06-06 15:17:36,270 - INFO # �[0;32mI (158) boot: Loaded app from partition at offset 0x10000�[0m
2019-06-06 15:17:36,271 - INFO # �[0;32mI (158) boot: Disabling RNG early entropy source...�[0m
2019-06-06 15:17:36,271 - INFO # 
2019-06-06 15:17:36,272 - INFO # Starting ESP32 with ID: 1730aea4d34600
2019-06-06 15:17:36,272 - INFO # 
2019-06-06 15:17:36,273 - INFO # Current clocks in Hz: CPU=80000000 APB=80000000 XTAL=40000000 SLOW=150000
2019-06-06 15:17:36,274 - INFO # PRO cpu is up (single core mode, only PRO cpu is used)
2019-06-06 15:17:36,274 - INFO # PRO cpu starts user code
2019-06-06 15:17:36,275 - INFO # Used clocks in Hz: CPU=80000000 APB=80000000 XTAL=40000000 FAST=8000000 SLOW=150000
2019-06-06 15:17:36,276 - INFO # XTAL calibration value: 3283802
2019-06-06 15:17:36,276 - INFO # Heap free: 184320 bytes
2019-06-06 15:17:36,276 - INFO # System time: 1970-01-01 00:00:00
2019-06-06 15:17:36,276 - INFO # 
2019-06-06 15:17:36,277 - INFO # Board configuration:
2019-06-06 15:17:36,277 - INFO # 	UART_DEV(0)	txd=1 rxd=3
2019-06-06 15:17:36,277 - INFO # 	UART_DEV(1)	txd=10 rxd=9
2019-06-06 15:17:36,278 - INFO # 	LED		pins=[ ]
2019-06-06 15:17:36,278 - INFO # 	BUTTONS		pins=[ 0 ]
2019-06-06 15:17:36,278 - INFO # 
2019-06-06 15:17:36,278 - INFO # Starting RIOT kernel on PRO cpu
2019-06-06 15:17:36,279 - INFO # I (258) [main_trampoline]: main(): This is RIOT! (Version: 2019.07-devel-621-g1b354-pr/esp/programmer_update)
2019-06-06 15:17:36,280 - INFO # Welcome to RIOT!
> 2019-06-06 15:17:47,574 - INFO #  help
2019-06-06 15:17:47,581 - INFO # Command              Description
2019-06-06 15:17:47,585 - INFO # ---------------------------------------
2019-06-06 15:17:47,587 - INFO # reboot               Reboot the node
2019-06-06 15:17:47,592 - INFO # ps                   Prints information about running threads.
2019-06-06 15:17:47,597 - INFO # random_init          initializes the PRNG
2019-06-06 15:17:47,603 - INFO # random_get           returns 32 bit of pseudo randomness
2019-06-06 15:17:47,607 - INFO # rtc                  control RTC peripheral interface
2019-06-06 15:17:47,611 - INFO # saul                 interact with sensors and actuators using SAUL
> 

PORT=/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_8266-if00-port0 BOARD=esp8266-esp-12x BUILD_IN_DOCKER=1 DOCKER="sudo docker" make -C examples/default/ reset flash term

PORT=/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_8266-if00-port0 BOARD=esp8266-esp-12x BUILD_IN_DOCKER=1 DOCKER="sudo docker" make -C examples/default/ reset flash term 2>&1 | tee output_esp8266
make: Entering directory '/home/harter/work/git/RIOT/examples/default'
ESP8266_NEWLIB_DIR should be defined as /path/to/newlib directory
ESP8266_NEWLIB_DIR is set by default to /opt/esp/newlib-xtensa
ESP8266_SDK_DIR should be defined as /path/to/sdk directory
ESP8266_SDK_DIR is set by default to /opt/esp/esp-open-sdk/sdk
esptool.py --port /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_8266-if00-port0 --before default_reset run
esptool.py v2.6
Serial port /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_8266-if00-port0
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: 68:c6:3a:ac:a1:fb
Uploading stub...
Running stub...
Stub running...
Hard resetting via RTS pin...
�[1;32mLaunching build container using image "riot/riotbuild:latest".�[0m
sudo docker run --rm -t -u "$(id -u)" \
    -v '/usr/share/zoneinfo/Europe/Berlin:/etc/localtime:ro' -v '/home/harter/work/git/RIOT:/data/riotbuild/riotbase' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'     \
    -e 'BOARD=esp8266-esp-12x' \
    -w '/data/riotbuild/riotbase/examples/default/' \
    'riot/riotbuild:latest' make   
ESP8266_NEWLIB_DIR should be defined as /path/to/newlib directory
ESP8266_NEWLIB_DIR is set by default to /opt/esp/newlib-xtensa
ESP8266_SDK_DIR should be defined as /path/to/sdk directory
ESP8266_SDK_DIR is set by default to /opt/esp/esp-open-sdk/sdk
�[1;32mBuilding application "default" for "esp8266-esp-12x" with MCU "esp8266".�[0m

"make" -C /data/riotbuild/riotbase/boards/esp8266-esp-12x
"make" -C /data/riotbuild/riotbase/boards/common/esp8266
"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/cpu/esp8266
"make" -C /data/riotbuild/riotbase/cpu/esp8266/periph
"make" -C /data/riotbuild/riotbase/cpu/esp8266/sdk
"make" -C /data/riotbuild/riotbase/cpu/esp8266/vendor
"make" -C /data/riotbuild/riotbase/cpu/esp8266/vendor/esp
"make" -C /data/riotbuild/riotbase/cpu/esp_common
"make" -C /data/riotbuild/riotbase/cpu/esp_common/vendor
"make" -C /data/riotbuild/riotbase/cpu/esp_common/vendor/xtensa
"make" -C /data/riotbuild/riotbase/drivers
"make" -C /data/riotbuild/riotbase/drivers/mtd
"make" -C /data/riotbuild/riotbase/drivers/periph_common
"make" -C /data/riotbuild/riotbase/drivers/saul
"make" -C /data/riotbuild/riotbase/sys
"make" -C /data/riotbuild/riotbase/sys/auto_init
"make" -C /data/riotbuild/riotbase/sys/auto_init/saul
"make" -C /data/riotbuild/riotbase/sys/div
"make" -C /data/riotbuild/riotbase/sys/fmt
"make" -C /data/riotbuild/riotbase/sys/isrpipe
"make" -C /data/riotbuild/riotbase/sys/luid
"make" -C /data/riotbuild/riotbase/sys/newlib_syscalls_default
"make" -C /data/riotbuild/riotbase/sys/phydat
"make" -C /data/riotbuild/riotbase/sys/ps
"make" -C /data/riotbuild/riotbase/sys/random
"make" -C /data/riotbuild/riotbase/sys/random/tinymt32
"make" -C /data/riotbuild/riotbase/sys/saul_reg
"make" -C /data/riotbuild/riotbase/sys/shell
"make" -C /data/riotbuild/riotbase/sys/shell/commands
"make" -C /data/riotbuild/riotbase/sys/stdio_uart
"make" -C /data/riotbuild/riotbase/sys/tsrb
"make" -C /data/riotbuild/riotbase/sys/xtimer
   text	   data	    bss	    dec	    hex	filename
  81987	   4324	   7296	  93607	  16da7	/data/riotbuild/riotbase/examples/default/bin/esp8266-esp-12x/default.elf
esptool.py elf2image -fs 1MB /home/harter/work/git/RIOT/examples/default/bin/esp8266-esp-12x/default.elf
esptool.py v2.6
Creating image for ESP8266...
esptool.py -p /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_8266-if00-port0 -b 460800 write_flash -fm dout 0 /home/harter/work/git/RIOT/examples/default/bin/esp8266-esp-12x/default.elf-0x00000.bin 0x10000 /home/harter/work/git/RIOT/examples/default/bin/esp8266-esp-12x/default.elf-0x10000.bin; esptool.py -p /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_8266-if00-port0 run
esptool.py v2.6
Serial port /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_8266-if00-port0
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: 68:c6:3a:ac:a1:fb
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0340
Compressed 23456 bytes to 12030...

Writing at 0x00000000... (100 %)
Wrote 23456 bytes (12030 compressed) at 0x00000000 in 0.3 seconds (effective 696.6 kbit/s)...
Hash of data verified.
Compressed 62904 bytes to 44608...

Writing at 0x00010000... (33 %)
Writing at 0x00014000... (66 %)
Writing at 0x00018000... (100 %)
Wrote 62904 bytes (44608 compressed) at 0x00010000 in 1.0 seconds (effective 501.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
esptool.py v2.6
Serial port /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_8266-if00-port0
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: 68:c6:3a:ac:a1:fb
Uploading stub...
Running stub...
Stub running...
Hard resetting via RTS pin...
/home/harter/work/git/RIOT/dist/tools/pyterm/pyterm -p "/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_8266-if00-port0" -b "115200"
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2019-06-06 15:11:45,846 - INFO # Connect to serial port /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_8266-if00-port0
Welcome to pyterm!
Type '/exit' to exit.
2019-06-06 15:11:46,858 - INFO # heap: 62944 (free 61440) byte
2019-06-06 15:11:46,860 - INFO # sysmem: 1500 (used 36, free 1464)
2019-06-06 15:11:46,860 - INFO # 
2019-06-06 15:11:46,861 - INFO # Board configuration:
2019-06-06 15:11:46,862 - INFO # 	PWM_DEV(0): channels=[ 2 4 5 ]
2019-06-06 15:11:46,864 - INFO # 	I2C_DEV(0): scl=5 sda=4
2019-06-06 15:11:46,864 - INFO # 	SPI: no devices
2019-06-06 15:11:46,865 - INFO # 	UART_DEV(0): txd=1 rxd=3
2019-06-06 15:11:46,867 - INFO # 	TIMER_DEV(0): 1 channel(s)
2019-06-06 15:11:46,867 - INFO # 	LED: pins=[ 2 ]
2019-06-06 15:11:46,868 - INFO # 
2019-06-06 15:11:46,872 - INFO # main(): This is RIOT! (Version: 2019.07-devel-621-g1b354-pr/esp/programmer_update)
2019-06-06 15:11:46,873 - INFO # Welcome to RIOT!
> 2019-06-06 15:11:48,738 - INFO #  help
2019-06-06 15:11:48,741 - INFO # Command              Description
2019-06-06 15:11:48,744 - INFO # ---------------------------------------
2019-06-06 15:11:48,747 - INFO # reboot               Reboot the node
2019-06-06 15:11:48,752 - INFO # ps                   Prints information about running threads.
2019-06-06 15:11:48,756 - INFO # random_init          initializes the PRNG
2019-06-06 15:11:48,761 - INFO # random_get           returns 32 bit of pseudo randomness
2019-06-06 15:11:48,768 - INFO # saul                 interact with sensors and actuators using SAUL
> 

FLASHDEPS can already contain values, these two prints info-build before flashing

FLASHDEPS=info-build BOARD=esp32-wroom-32 make -C examples/default/ flash-only
FLASHDEPS=info-build  BOARD=esp8266-esp-12x make -C examples/default/ flash-only

RESET can be overwritten from the environment

RESET=true BOARD=esp32-wroom-32 make --no-print-directory -C examples/default/ reset
ESP32_SDK_DIR should be defined as /path/to/esp-idf directory
ESP32_SDK_DIR is set by default to /opt/esp/esp-idf
true --port /dev/ttyUSB0 --before default_reset run
 RESET=true BOARD=esp8266-esp-12x make --no-print-directory -C examples/default/ reset
ESP8266_NEWLIB_DIR should be defined as /path/to/newlib directory
ESP8266_NEWLIB_DIR is set by default to /opt/esp/newlib-xtensa
ESP8266_SDK_DIR should be defined as /path/to/sdk directory
ESP8266_SDK_DIR is set by default to /opt/esp/esp-open-sdk/sdk
true --port /dev/ttyUSB0 --before default_reset run

FLASHFILE test will gets on its own in a separate PR

Issues/PRs references

#10870

Depends on #11648

@cladmi cladmi added Area: build system Area: Build system State: waiting for other PR State: The PR requires another PR to be merged first Area: tools Area: Supplementary tools Platform: ESP Platform: This PR/issue effects ESP-based platforms labels Jun 6, 2019
@cladmi cladmi added this to the Release 2019.07 milestone Jun 6, 2019
@cladmi cladmi requested a review from gschorcht June 6, 2019 13:22
@cladmi cladmi added the Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation label Jun 6, 2019
@cladmi cladmi requested a review from MrKevinWeiss June 6, 2019 13:43
@@ -59,7 +59,7 @@ PSEUDOMODULES += esp_wifi_any

export CPU ?= esp32
export TARGET_ARCH ?= xtensa-esp32-elf
export ESPTOOL ?= $(ESP32_SDK_DIR)/components/esptool_py/esptool/esptool.py
export ESPTOOL ?= esptool.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use the esptool package from the distribution, its version might be too old. For example, Ubuntu 18.04 LTS comes with version 2.1 which should work, but Ubuntu 16.04 comes with version 0.4. The SDK comes with version 2.6.

On the other hand, the Makefile.inclue in master requires that ESP-IDF in installed which wouldn't be necessary if RIOT docker image is used and esptool in system installation is only used for flashing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning to completely remove $(ESP32_SDK_DIR)/components/esptool_py/esptool/ is that RESET already uses only esptool.py without the path in the ESP32_SDK_DIR. So it is required to have esptool.py in your PATH.
The esp8266 also uses esptool.py. And if it is coherent for both, I can have the same handling for the two architectures.

It may require a documentation update too.

Also a fallback with $(or $(wildcard $(ESP32_SDK_DIR)/components/esptool_py/esptool/esptool.py),esptool.py) could easily work for me, but reset still uses esptool.py directly.

It could require additional cleanups, I first just did the minimum to make it work in my configuration. (DOCKER, no toolchain).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you prefer, I can currently remove this change from this PR and change the way of handling it in a dedicated discussion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cladmi I agree with you, that the goal should be to be able to flash the device without having the ESP32 SDK installed. It wouldn't make sense to install the ESP32 SDK when riotdocker is used for compilation. Thus, I agree to remove the whole path.

Therefore, I have checked the documentation of ESP32 MCU.

If the riotdocker is used, everything should be clear. In section Preparing the Enviroment of chapter RIOT Docker Toolchain (riotdocker) , esptool.py is documented as following:

The ESP flasher program esptool.py is available at GitHub. Don't use the the esptool package of your OS. esptool.py requires either Python 2.7 or Python 3.4 or later. The latest stable version of esptool.py can be installed with pip:

pip install esptool

If the user doesn't follow the documentation, it is his fault.

However, if the user installs the toolchain and follows the Manual Toolchain Installation, there is no word left about esptool.py. The reason is that it was supposed that esptool.py is used from $(ESP32_SDK_DIR)/components/esptool_py/esptool/ in that case.

Therefore, we have to change the documentation and I would restructure it a bit once I'm touching it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cladmi PR #12028 clarifies the installation of esptool.py, hopefully.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I will look at it.

@@ -132,7 +132,7 @@ LINKFLAGS += -Wl,--warn-unresolved-symbols
FLASHFILE ?= $(ELFFILE)

# configure preflasher to convert .elf to .bin before flashing
FLASH_SIZE = -fs 8m
FLASH_SIZE = -fs 1MB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to avoid the warning.

@@ -8,4 +8,5 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
include $(RIOTMAKE)/tools/serial.inc.mk

# reset tool configuration
RESET = esptool.py --before default_reset run
RESET ?= esptool.py
RESET_FLAGS ?= --before default_reset run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the advantage of splitting it into RESET and RESET_FLAGS variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is our normal scheme so it makes it compliant to the way it is done in RIOT. Which means, not another use case to handle.

Also, with it you can overwrite only the tool used for resetting. You could do RESET=path_to_my_esptool_executable only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@@ -9,4 +9,4 @@ include $(RIOTMAKE)/tools/serial.inc.mk

# reset tool configuration
RESET ?= esptool.py
RESET_FLAGS ?= --before default_reset run
RESET_FLAGS ?= --port $(PORT) --before default_reset run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@cladmi cladmi force-pushed the pr/esp/programmer_update branch from 1b354ba to bc80d25 Compare June 7, 2019 10:15
@cladmi
Copy link
Contributor Author

cladmi commented Jun 7, 2019

Rebased as #11649 was merged.

cladmi added 3 commits June 14, 2019 15:58
Update to use RESET and RESET_FLAGS variables set conditionally.
This allows selecting the correct device when multiple boards are connected.
Append to FLASHDEPS instead of overwriting/lazy setting it.
@cladmi cladmi force-pushed the pr/esp/programmer_update branch from bc80d25 to 4d7b421 Compare June 14, 2019 13:59
@MrKevinWeiss
Copy link
Contributor

I just noticed that I get .elf.bin files for some reason...

@cladmi
Copy link
Contributor Author

cladmi commented Jul 23, 2019

I just noticed that I get .elf.bin files for some reason...

It is what is done in the port.

PREFLASHER = $(ESPTOOL)
PREFFLAGS = --chip esp32 elf2image
PREFFLAGS += -fm $(FLASH_MODE) -fs $(FLASH_SIZE) -ff $(FLASH_FREQ)
PREFFLAGS += -o $(FLASHFILE).bin $(FLASHFILE);

Before it was $(ELFFILE).bin which was replaced by $(FLASHFILE).bin but it is the same behavior.

@gschorcht
Copy link
Contributor

Is it a problem? It is simply easier than handling it with make's basename function.

@cladmi
Copy link
Contributor Author

cladmi commented Jul 23, 2019

If you want to have just .bin, there is no need to use basename, there is the $(BINFILE) variable converted from ELFFILE or to keep coherent with using $(FLASHFILE), use $(FLASHFILE:.elf=.bin).

However it is a different file from the one created with

RIOT/Makefile.include

Lines 499 to 500 in b1babe5

%.bin: %.elf
$(Q)$(OBJCOPY) $(OFLAGS) -Obinary $< $@

So keeping a different name is not a bad thing.

For esp8266 it even creates 2 files $(FLASHFILE)-0x00000.bin and $(FLASHFILE)-0x10000.bin.

@tcschmidt
Copy link
Member

@gschorcht do you agree? Can we get this moving?

@cladmi
Copy link
Contributor Author

cladmi commented Sep 4, 2019

@gschorcht do you want to update the esptool.py in #12028 or should we go with this one in the current state?

@gschorcht
Copy link
Contributor

@gschorcht do you want to update the esptool.py in #12028 or should we go with this one in the current state?

As you prefer. I can modify #12028 to change cpu/esp32/Makefile.include as well as the documentation for esptool or we can go with this PR.

@cladmi
Copy link
Contributor Author

cladmi commented Sep 4, 2019

I will remove the esptool.py from here, this way the documentation stay consistent. You can steal the commit directly :) b4b1dd4

Using flash size in megabits is deprecated by esptool.
Use the new megabyte notation.

    WARNING: Flash size arguments in megabits like '8m' are deprecated.
    Please use the equivalent size '1MB'.
    Megabit arguments may be removed in a future release.
    esptool.py v2.6
@cladmi cladmi force-pushed the pr/esp/programmer_update branch from 4d7b421 to 422644b Compare September 4, 2019 13:07
@cladmi
Copy link
Contributor Author

cladmi commented Sep 4, 2019

Updated.

@gschorcht gschorcht added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed State: waiting for other PR State: The PR requires another PR to be merged first labels Sep 6, 2019
@gschorcht
Copy link
Contributor

I will remove the esptool.py from here, this way the documentation stay consistent. You can steal the commit directly :) b4b1dd4

@cladmi Done

@jcarrano jcarrano merged commit c50d8fa into RIOT-OS:master Sep 10, 2019
@cladmi
Copy link
Contributor Author

cladmi commented Sep 10, 2019

Thank you for the review !

@cladmi cladmi deleted the pr/esp/programmer_update branch September 10, 2019 16:01
@kb2ma kb2ma added this to the Release 2019.10 milestone Sep 16, 2019
@benpicco
Copy link
Contributor

Now either the documentation or RIOT-Xtensa-ESP8266-toolchain need an update too.

When following the instructions, esptool.py v2.5.1 gets installed which doesn't know about this new notation.

@cladmi
Copy link
Contributor Author

cladmi commented Sep 16, 2019

The esptool.py path was not changed by this PR (I removed this commit).
It was like this before for the reset command.

Update of the documentation and esptool.py path when flashing is updated in #12028

@cladmi
Copy link
Contributor Author

cladmi commented Sep 16, 2019

Oh I misread. The issue is with the 1MB ?

@benpicco
Copy link
Contributor

Yes, see #12247

@cladmi
Copy link
Contributor Author

cladmi commented Sep 16, 2019

If you follow http://doc.riot-os.org/group__cpu__esp8266.html#esp8266_precompiled_toolchain you should get esptool.py 2.7

pip search esptool
esptool (2.7)  - A serial utility to communicate & flash code to Espressif ESP8266 & ESP32 chips.
  INSTALLED: 2.6
  LATEST:    2.7

The flag was supported in 2.6 at least.

@benpicco
Copy link
Contributor

The Precompiled Toolchain section doesn't mention pip, that is only in the RIOT Docker Toolchain section.

I suppose a simple documentation update is enough then. (although an update to the toolchain repo would be even nicer - I really like that you can install the entire toolchain with just one command)

@cladmi
Copy link
Contributor Author

cladmi commented Sep 16, 2019

Indeed, I searched 'esptool.py' in the page and did not notice it was the other section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants