cpu/esp8266: reset tool to allow automatic tests
This commit is contained in:
parent
309eab9ae0
commit
555a7040db
@ -4,5 +4,5 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
|
||||
include $(RIOTMAKE)/tools/serial.inc.mk
|
||||
|
||||
# reset tool configuration
|
||||
RESET ?= esptool.py
|
||||
RESET_FLAGS ?= --port $(PROG_DEV) --before default_reset run
|
||||
RESET ?= $(RIOTTOOLS)/esptool/espreset.py
|
||||
RESET_FLAGS ?= --port $(PROG_DEV)
|
||||
|
||||
@ -175,7 +175,7 @@ FLASH_FREQ = 26m # FIX configuration, DO NOT CHANGE
|
||||
FLASH_SIZE ?= 1MB
|
||||
FLASHDEPS += preflash
|
||||
|
||||
PREFLASHER ?= $(RIOTBASE)/dist/tools/esptool/esptool.py
|
||||
PREFLASHER ?= $(RIOTTOOLS)/esptool/esptool.py
|
||||
PREFFLAGS = --chip esp8266 elf2image
|
||||
PREFFLAGS += --flash_mode $(FLASH_MODE) --flash_size $(FLASH_SIZE)
|
||||
PREFFLAGS += --flash_freq $(FLASH_FREQ) --version 3
|
||||
@ -210,7 +210,7 @@ else
|
||||
export PROGRAMMER_SPEED ?= 460800
|
||||
FLASHER = $(RIOTBASE)/dist/tools/esptool/esptool.py
|
||||
FFLAGS += --chip esp8266 --port $(PROG_DEV) --baud $(PROGRAMMER_SPEED)
|
||||
FFLAGS += --before default_reset --after hard_reset write_flash -z
|
||||
FFLAGS += --before default_reset write_flash -z
|
||||
FFLAGS += --flash_size detect
|
||||
FFLAGS += --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ)
|
||||
FFLAGS += 0x0000 $(RIOTCPU)/$(CPU)/bin/$(BOOTLOADER)
|
||||
|
||||
74
dist/tools/esptool/espreset.py
vendored
Executable file
74
dist/tools/esptool/espreset.py
vendored
Executable file
@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2019 Gunar Schorcht <gunar@schorcht.net>
|
||||
# 2014 Oliver Hahm <oliver.hahm@inria.fr>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301 USA
|
||||
|
||||
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
import ConfigParser as configparser
|
||||
|
||||
import serial
|
||||
import sys
|
||||
import time
|
||||
import argparse
|
||||
|
||||
try:
|
||||
serial.Serial
|
||||
except AttributeError:
|
||||
print("\033[1;37;41m\n")
|
||||
print("Something went terribly wrong when loading the pyserial package.")
|
||||
print("There is a good chance that you installed the 'serial' package instead")
|
||||
print("of 'pyserial'. Try running 'pip uninstall serial && pip install pyserial'")
|
||||
print("\033[0m")
|
||||
sys.exit(1)
|
||||
|
||||
# default serial port
|
||||
defaultport = "/dev/ttyUSB0"
|
||||
|
||||
# default baudrate for serial connection
|
||||
defaultbaud = 115200
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="espreset - ESP reset program")
|
||||
parser.add_argument("-p", "--port",
|
||||
help="Specifies the serial port to use, default is %s"
|
||||
% defaultport,
|
||||
default=defaultport)
|
||||
parser.add_argument("-b", "--baudrate",
|
||||
help="Specifies baudrate for the serial port, default "
|
||||
"is %s" % defaultbaud,
|
||||
default=defaultbaud)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
ser = serial.Serial(port=args.port, dsrdtr=0, rtscts=0)
|
||||
ser.baudrate = args.baudrate
|
||||
# set RST low and GPIO0 high
|
||||
ser.setRTS(1)
|
||||
ser.setDTR(0)
|
||||
# keep the RST line low for 0.1 seconds
|
||||
time.sleep(0.1)
|
||||
# set the RST high
|
||||
ser.setRTS(1)
|
||||
ser.setDTR(1)
|
||||
# wait 1 second for boot
|
||||
time.sleep(1)
|
||||
sys.exit(0)
|
||||
Loading…
x
Reference in New Issue
Block a user