Skip to content

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

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

Closed
1 task done
mrengineer7777 opened this issue Sep 13, 2022 · 1 comment · Fixed by #7264
Closed
1 task done

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

mrengineer7777 opened this issue Sep 13, 2022 · 1 comment · Fixed by #7264
Assignees

Comments

@mrengineer7777
Copy link
Collaborator

mrengineer7777 commented Sep 13, 2022

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.
@mrengineer7777 mrengineer7777 added the Status: Awaiting triage Issue is waiting for triage label Sep 13, 2022
@P-R-O-C-H-Y
Copy link
Member

Hi @mrengineer7777, what about creating a PR for this change? :) Can you handle that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants