Skip to content

Commit

Permalink
Platform 2024.04.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Apr 24, 2024
2 parents b9ca4d0 + 1445800 commit fe06d57
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 89 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Espressif Systems is a privately held fabless semiconductor company. They provid
1. [Install PlatformIO](http://platformio.org)
2. Create PlatformIO project and configure a platform option in [platformio.ini](http://docs.platformio.org/page/projectconf.html) file:

### Development build Arduino 3.0.0-rc1 and IDF 5.1.3
### Development build Arduino 3.0.0-rc and IDF 5.1.3
Support for the ESP32/ESP32solo1, ESP32C2, ESP32C3, ESP32C6, ESP32S2, ESP32S3 and ESP32-H2
```
[platformio]
Expand Down
2 changes: 1 addition & 1 deletion builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def compile_source_files(
obj_path = os.path.join(obj_path, os.path.basename(src_path))

preserve_source_file_extension = board.get(
"build.esp-idf.preserve_source_file_extension", False
"build.esp-idf.preserve_source_file_extension", True
)

objects.append(
Expand Down
11 changes: 0 additions & 11 deletions examples/tasmota_platformio_override.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,3 @@ default_envs =

[env:tasmota32_base]
platform = symlink://.

[env:tasmota32c2]
extends = env:tasmota32_base
board = esp32c2
build_unflags = ${env:tasmota32_base.build_unflags
-mtarget-align
-flto
build_flags = ${env:tasmota32_base.build_flags}
-fno-lto
-DFIRMWARE_TASMOTA32
-DOTA_URL='""'
146 changes: 75 additions & 71 deletions monitor/filter_exception_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,76 +32,57 @@
class Esp32ExceptionDecoder(DeviceMonitorFilterBase):
NAME = "esp32_exception_decoder"

ADDR_PATTERN = re.compile(r"((?:0x[0-9a-fA-F]{8}[: ]?)+)\s?$")
ADDR_SPLIT = re.compile(r"[ :]")
PREFIX_RE = re.compile(r"^ *")

def __call__(self):
self.buffer = ""
# regex matches potential PC value (0x4xxxxxxx)
# Logic identical to https://github.com/espressif/esp-idf/blob/master/tools/idf_monitor_base/constants.py#L56
self.pcaddr_re = re.compile(r'0x4[0-9a-f]{7}', re.IGNORECASE)

self.firmware_path = None
self.addr2line_path = None
self.enabled = self.setup_paths()

return self

def setup_paths(self):
self.project_dir = os.path.abspath(self.project_dir)

self.project_strip_dir = os.environ.get("esp32_exception_decoder_project_strip_dir")
self.firmware_path = os.environ.get("esp32_exception_decoder_firmware_path")
self.addr2line_path = os.environ.get("esp32_exception_decoder_addr2line_path")

if self.project_strip_dir is None:
self.project_strip_dir = self.project_dir

try:
if self.firmware_path is None or self.addr2line_path is None:
# Only load if necessary, as the call is expensive
data = load_build_metadata(self.project_dir, self.environment)

if self.firmware_path is None:
# Only do this check when the firmware path is not externally provided
if self.config.get("env:" + self.environment, "build_type") != "debug":
print(
if self.config.get("env:" + self.environment, "build_type") != "debug":
print(
"""
Please build project in debug configuration to get more details about an exception.
See https://docs.platformio.org/page/projectconf/build_configurations.html
"""
)
self.firmware_path = data["prog_path"]
)

return self

def setup_paths(self):
self.project_dir = os.path.abspath(self.project_dir)
try:
data = load_build_metadata(self.project_dir, self.environment, cache=True)

self.firmware_path = data["prog_path"]
if not os.path.isfile(self.firmware_path):
sys.stderr.write(
"%s: disabling, firmware at %s does not exist, rebuild the project?\n"
"%s: firmware at %s does not exist, rebuild the project?\n"
% (self.__class__.__name__, self.firmware_path)
)
return False

if self.addr2line_path is None:
cc_path = data.get("cc_path", "")
if "-gcc" in cc_path:
self.addr2line_path = cc_path.replace("-gcc", "-addr2line")
else:
sys.stderr.write(
"%s: disabling, failed to find addr2line.\n" % self.__class__.__name__
)
return False

if not os.path.isfile(self.addr2line_path):
sys.stderr.write(
"%s: disabling, addr2line at %s does not exist\n"
% (self.__class__.__name__, self.addr2line_path)
)
return False

return True
cc_path = data.get("cc_path", "")
if "-gcc" in cc_path:
path = cc_path.replace("-gcc", "-addr2line")
if os.path.isfile(path):
self.addr2line_path = path
return True
except PlatformioException as e:
sys.stderr.write(
"%s: disabling, exception while looking for addr2line: %s\n"
% (self.__class__.__name__, e)
)
return False
sys.stderr.write(
"%s: disabling, failed to find addr2line.\n" % self.__class__.__name__
)
return False

def rx(self, text):
if not self.enabled:
Expand All @@ -121,47 +102,70 @@ def rx(self, text):
self.buffer = ""
last = idx + 1

# Output each trace on a separate line below ours
# Logic identical to https://github.com/espressif/esp-idf/blob/master/tools/idf_monitor_base/logger.py#L131
for m in re.finditer(self.pcaddr_re, line):
if m is None:
continue

trace = self.get_backtrace(m)
if len(trace) != "":
text = text[: last] + trace + text[last :]
last += len(trace)
m = self.ADDR_PATTERN.search(line)
if m is None:
continue

trace = self.build_backtrace(line, m.group(1))
if trace:
text = text[: idx + 1] + trace + text[idx + 1 :]
last += len(trace)
return text

def get_backtrace(self, match):
def is_address_ignored(self, address):
return address in ("", "0x00000000")

def filter_addresses(self, adresses_str):
addresses = self.ADDR_SPLIT.split(adresses_str)
size = len(addresses)
while size > 1 and self.is_address_ignored(addresses[size-1]):
size -= 1
return addresses[:size]

def build_backtrace(self, line, address_match):
addresses = self.filter_addresses(address_match)
if not addresses:
return ""

prefix_match = self.PREFIX_RE.match(line)
prefix = prefix_match.group(0) if prefix_match is not None else ""

trace = ""
enc = "mbcs" if IS_WINDOWS else "utf-8"
args = [self.addr2line_path, u"-fipC", u"-e", self.firmware_path]
try:
addr = match.group()
output = (
subprocess.check_output(args + [addr])
.decode(enc)
.strip()
)
output = output.replace(
"\n", "\n "
) # newlines happen with inlined methods
output = self.strip_project_dir(output)
# Output the trace in yellow color so that it is easier to spot
trace += "\033[33m=> %s: %s\033[0m\n" % (addr, output)
i = 0
for addr in addresses:
output = (
subprocess.check_output(args + [addr])
.decode(enc)
.strip()
)

# newlines happen with inlined methods
output = output.replace(
"\n", "\n "
)

# throw out addresses not from ELF
if output == "?? ??:0":
continue

output = self.strip_project_dir(output)
trace += "%s #%-2d %s in %s\n" % (prefix, i, addr, output)
i += 1
except subprocess.CalledProcessError as e:
sys.stderr.write(
"%s: failed to call %s: %s\n"
% (self.__class__.__name__, self.addr2line_path, e)
)
return trace

return trace + "\n" if trace else ""

def strip_project_dir(self, trace):
while True:
idx = trace.find(self.project_strip_dir)
idx = trace.find(self.project_dir)
if idx == -1:
break
trace = trace[:idx] + trace[idx + len(self.project_strip_dir) + 1 :]
trace = trace[:idx] + trace[idx + len(self.project_dir) + 1 :]
return trace
10 changes: 5 additions & 5 deletions platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"type": "git",
"url": "https://github.com/tasmota/platform-espressif32.git"
},
"version": "2024.04.12",
"version": "2024.04.13",
"frameworks": {
"arduino": {
"script": "builder/frameworks/arduino.py"
Expand All @@ -33,25 +33,25 @@
"type": "framework",
"optional": true,
"owner": "tasmota",
"version": "https://github.com/tasmota/arduino-esp32/releases/download/3.0.0.240412/framework-arduinoespressif32.zip"
"version": "https://github.com/tasmota/arduino-esp32/releases/download/3.0.0.240413/framework-arduinoespressif32.zip"
},
"framework-arduino-solo1": {
"type": "framework",
"optional": true,
"owner": "tasmota",
"version": "https://github.com/tasmota/arduino-esp32/releases/download/3.0.0.240412/framework-arduinoespressif32-solo1.zip"
"version": "https://github.com/tasmota/arduino-esp32/releases/download/3.0.0.240413/framework-arduinoespressif32-solo1.zip"
},
"framework-arduino-ITEAD": {
"type": "framework",
"optional": true,
"owner": "tasmota",
"version": "https://github.com/tasmota/arduino-esp32/releases/download/3.0.0.240412/framework-arduinoespressif32-ITEAD.zip"
"version": "https://github.com/tasmota/arduino-esp32/releases/download/3.0.0.240413/framework-arduinoespressif32-ITEAD.zip"
},
"framework-espidf": {
"type": "framework",
"optional": true,
"owner": "tasmota",
"version": "https://github.com/tasmota/esp-idf/releases/download/v5.1.3.240325/esp-idf-v5.1.3.zip"
"version": "https://github.com/tasmota/esp-idf/releases/download/v5.1.3.240418/esp-idf-v5.1.3.zip"
},
"toolchain-xtensa-esp32": {
"type": "toolchain",
Expand Down

0 comments on commit fe06d57

Please sign in to comment.