Skip to content

esp32-hal-cpu.c corrupt log entry #7250

@mrengineer7777

Description

@mrengineer7777

Board

ESP32-WROOM-32UE

Device Description

Custom hardware but same pinout as the Adafruit ESP32-Feather

Hardware Configuration

USB on UART0 for programming/debugging

Version

v2.0.3

IDE Name

PlatformIO

Operating System

Win10

Flash frequency

? default

PSRAM enabled

no

Upload speed

460800 (default)

Description

This is an error I've been ignoring for a long time but finally investigated and isolated. When "CORE_DEBUG_LEVEL=5", I see a corrupt entry in the startup messages in the output terminal. I thought it was an issue with my code, but I traced it down to this Arduino library:
https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-cpu.c#L214

Basically setCpuFrequencyMhz() contains a debug message stating what frequency is set. However it prints while the CPU frequency is changing, which causes trash to print to UART 0.

Possible fixes:

  1. Move the debug message after the frequency switch.
    I moved log_d("%s: %u / %u = %u Mhz, APB: %u Hz", (conf.source == RTC_CPU_FREQ_SRC_PLL)?"PLL":((conf.source == RTC_CPU_FREQ_SRC_APLL)?"APLL":((conf.source == RTC_CPU_FREQ_SRC_XTAL)?"XTAL":"8M")), conf.source_freq_mhz, conf.div, conf.freq_mhz, apb); to the end of the function setCpuFrequencyMhz() and the message appears to print properly.

  2. Wait for debug message to finish sending (Flush UART 0) before continuing.

Sketch

platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.3/platform-espressif32-2.0.3.zip
I verified the issue exists in the latest master.  See https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-cpu.c#L214.
_________________________________

#include "Arduino.h"

void setup() {
  log_d("setup()");
}

void loop() {
  Serial.println("Hello World");
  delay(1000);
}

Debug Message

Original log:
`
entry 0x400805c4
��␙ɕ�Օ���5��J�␂���J␂�␂z␂�␂�␂���␂j��␂
␅%J␂������␂B�5R�[    20][D][main.cpp:12] setup(): setup()
`

Log after moving debug line:
`
entry 0x400805c4
[     4][D][esp32-hal-cpu.c:246] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[    20][D][main.cpp:12] setup(): setup()
`

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Status: SolvedThe issue has been resolved and requires no further action.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions