Some bizare characters prints on serial monitor with ESP-IDF hello world example

Hi, with ESP-IDF “hello world” example and ESP-WROVER-KIT and PIO VSCODE I get some bizarre ␛[0m characters, is this normal ?

estarting now.
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x3e (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5540
load:0x40078000,len:0
load:0x40078000,len:13560
entry 0x400790a8
␛[0;32mI (28) boot: ESP-IDF 3.30003.0 2nd stage bootloader␛[0m
␛[0;32mI (28) boot: compile time 13:10:30␛[0m
␛[0;32mI (30) boot: Enabling RNG early entropy source...␛[0m
␛[0;32mI (33) boot: SPI Speed      : 40MHz␛[0m
␛[0;32mI (38) boot: SPI Mode       : DIO␛[0m
␛[0;32mI (42) boot: SPI Flash Size : 4MB␛[0m
␛[0;32mI (46) boot: Partition Table:␛[0m
␛[0;32mI (49) boot: ## Label            Usage          Type ST Offset   Length␛[0m
␛[0;32mI (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000␛[0m
␛[0;32mI (64) boot:  1 phy_init         RF data          01 01 0000f000 00001000␛[0m
␛[0;32mI (71) boot:  2 factory          factory app      00 00 00010000 00100000␛[0m
␛[0;32mI (79) boot: End of partition table␛[0m
␛[0;32mI (83) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x04bd4 ( 19412) map␛[0m
␛[0;32mI (99) esp_image: segment 1: paddr=0x00014bfc vaddr=0x3ffc0000 size=0x01ef4 (  7924) load␛[0m
␛[0;32mI (104) esp_image: segment 2: paddr=0x00016af8 vaddr=0x40080000 size=0x00400 (  1024) load␛[0m
␛[0;32mI (110) esp_image: segment 3: paddr=0x00016f00 vaddr=0x40080400 size=0x07e0c ( 32268) load␛[0m
␛[0;32mI (132) esp_image: segment 4: paddr=0x0001ed14 vaddr=0x400c0000 size=0x00000 (     0) load␛[0m
␛[0;32mI (132) esp_image: segment 5: paddr=0x0001ed1c vaddr=0x00000000 size=0x012f4 (  4852) ␛[0m
␛[0;32mI (140) esp_image: segment 6: paddr=0x00020018 vaddr=0x400d0018 size=0x13078 ( 77944) map␛[0m
␛[0;32mI (181) boot: Loaded app from partition at offset 0x10000␛[0m
␛[0;32mI (181) boot: Disabling RNG early entropy source...␛[0m
␛[0;32mI (182) cpu_start: Pro cpu up.␛[0m
␛[0;32mI (185) cpu_start: Starting app cpu, entry point is 0x40080e38␛[0m
␛[0;32mI (178) cpu_start: App cpu up.␛[0m
␛[0;32mI (196) heap_init: Initializing. RAM available for dynamic allocation:␛[0m
␛[0;32mI (203) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM␛[0m
␛[0;32mI (209) heap_init: At 3FFC2700 len 0001D900 (118 KiB): DRAM␛[0m
␛[0;32mI (215) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM␛[0m
␛[0;32mI (221) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM␛[0m
␛[0;32mI (228) heap_init: At 4008820C len 00017DF4 (95 KiB): IRAM␛[0m
␛[0;32mI (234) cpu_start: Pro cpu start user code␛[0m
␛[0;32mI (252) cpu_start: Starting scheduler on PRO CPU.␛[0m
␛[0;32mI (0) cpu_start: Starting scheduler on APP CPU.␛[0m
Hello world!
This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
Restarting in 10 seconds...
Restarting in 9 seconds...
Restarting in 8 seconds...
Restarting in 7 seconds...
Restarting in 6 seconds...
Restarting in 5 seconds...
Restarting in 4 seconds...

Yes these are special shell control characters (ANSI escape code) for changing the color of the line.

Switch miniterm.py to --raw and in a bash-compatible shell you should now see the info, warning, error lines etc printed in different colors.

2 Likes

I’m in VSCode (Windows 8.1) how to do this ?

VSCode > Left side bar > PlatformIO > New Terminal > Redirecting...

ok this is for raw, and how to switch the terminal into a bash compatible shell ?

As you can see below there is no changes with this command (platformio device monitor --raw), so I need to change the terminal into a bash compatible terminal isn’t, it ? but how to do this ?

Microsoft Windows [version 6.3.9600]
(c) 2013 Microsoft Corporation. Tous droits réservés.

C:\Users\charafeddine\Documents\PlatformIO\Projects\180903-182438-espidf-hello-w
orld>platformio device monitor --raw
--- Miniterm on COM7  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Restarting in 4 seconds...
Restarting in 3 seconds...
Restarting in 2 seconds...
Restarting in 1 seconds...
Restarting in 0 seconds...
Restarting now.
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x3e (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5540
load:0x40078000,len:0
load:0x40078000,len:13560
entry 0x400790a8
[0;32mI (28) boot: ESP-IDF 3.30003.0 2nd stage bootloader[0m
[0;32mI (28) boot: compile time 13:10:30[0m
[0;32mI (32) boot: Enabling RNG early entropy source...[0m
[0;32mI (33) boot: SPI Speed      : 40MHz[0m
[0;32mI (38) boot: SPI Mode       : DIO[0m
[0;32mI (42) boot: SPI Flash Size : 4MB[0m
[0;32mI (46) boot: Partition Table:[0m
[0;32mI (49) boot: ## Label            Usage          Type ST Offset   Length[0m
[0;32mI (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000[0m
[0;32mI (64) boot:  1 phy_init         RF data          01 01 0000f000 00001000[0m
[0;32mI (71) boot:  2 factory          factory app      00 00 00010000 00100000[0m
[0;32mI (79) boot: End of partition table[0m
[0;32mI (83) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x04bd4 ( 19412) map[0m
[0;32mI (99) esp_image: segment 1: paddr=0x00014bfc vaddr=0x3ffc0000 size=0x01ef4 (  7924) load[0m
[0;32mI (104) esp_image: segment 2: paddr=0x00016af8 vaddr=0x40080000 size=0x00400 (  1024) load[0m
[0;32mI (110) esp_image: segment 3: paddr=0x00016f00 vaddr=0x40080400 size=0x07e0c ( 32268) load[0m
[0;32mI (132) esp_image: segment 4: paddr=0x0001ed14 vaddr=0x400c0000 size=0x00000 (     0) load[0m
[0;32mI (132) esp_image: segment 5: paddr=0x0001ed1c vaddr=0x00000000 size=0x012f4 (  4852) [0m
[0;32mI (140) esp_image: segment 6: paddr=0x00020018 vaddr=0x400d0018 size=0x13078 ( 77944) map[0m
[0;32mI (181) boot: Loaded app from partition at offset 0x10000[0m
[0;32mI (181) boot: Disabling RNG early entropy source...[0m
[0;32mI (182) cpu_start: Pro cpu up.[0m
[0;32mI (185) cpu_start: Starting app cpu, entry point is 0x40080e38[0m
[0;32mI (178) cpu_start: App cpu up.[0m
[0;32mI (196) heap_init: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (203) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM[0m
[0;32mI (209) heap_init: At 3FFC2700 len 0001D900 (118 KiB): DRAM[0m
[0;32mI (215) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM[0m
[0;32mI (221) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (228) heap_init: At 4008820C len 00017DF4 (95 KiB): IRAM[0m
[0;32mI (234) cpu_start: Pro cpu start user code[0m
[0;32mI (252) cpu_start: Starting scheduler on PRO CPU.[0m
[0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m
Hello world!
This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
Restarting in 10 seconds...
Restarting in 9 seconds...
Restarting in 8 seconds...
Restarting in 7 seconds...
Restarting in 6 seconds...
Restarting in 5 seconds...
Restarting in 4 seconds...
Restarting in 3 seconds...
Restarting in 2 seconds...
Restarting in 1 seconds...
Restarting in 0 seconds...
Restarting now.
ets Jun  8 2016 00:22:57

Did you test it that it works? I just meant that the terminal / shell you are executing miniterm inside from must support these ANSI escape codes.

See my previous answer (I was updating it while you were answering)

Ok I did this in config vscode json file with this command platformio device monitor --raw

{
“terminal.integrated.shell.windows”: “C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe”
}

But nothing changed

i tryind without this command as well but no changes

@ivankravets

This means

platformio device monitor -f colorize

should display the ansi colors? This doesn’t work though.

Under windows you have to enable your console (cmd.exe or powershell) to be able to display those ANSI codes with a setting. One way to do this is by creating or setting the registry key VirtualTerminalLevel (DWORD) at [HKEY_CURRENT_USER\Console] to value 1.
See: Colored text output in PowerShell console using ANSI / VT100 codes

After that you can call the monitor with pio device monitor --raw and the coloring should work.

2 Likes

I have managed to enable the colors and if I run platformio device monitor --raw I get the nice colors in the log.

Is there any way to make this the default, so when I click on the serial monitor icon in the toolbar I also get the colored output?

I don’t think there is a way to do that at the moment. It would be awesome to have the possibility to enable this via a setting in the platformio.ini.

Has anyone tried, just for fun, to say monitor_port = --raw /dev/ttyACM0 ? If it’s just a copy-paste thing from this option line, that might actually construct the correct command string…

I have just tried that unsuccessfully in a few different combinations with different options (monitor-speed, monitor-port, etc.). When PIO parses the ini-file it always catches those “injection” attempts.
could not open port '--raw COM3': could not open port '--raw COM3':
or
ValueError: invalid literal for int() with base 10: '--raw'

Thank’s for trying, too bad it doesn’t work :smile:. Then let’s wait how Add user-definable monitor options to platformio.ini · Issue #2165 · platformio/platformio-core · GitHub is perceived.

2 Likes

Hello!
I was glad when I found out about the support for displaying colored text on the monitor.
Followed the recommendation above (I have Windows 10) created key the VirtualTerminalLevel (DWORD) at [HKEY_CURRENT_USER \ Console] with a value of 1.
Inserted to platformio.ini:

 monitor_flags=
    --echo
    --raw

Rebooted the system. To when I activate the monitor, I see this:

> Executing task: C:\Users\Alexander\.platformio\penv\Scripts\platformio.exe device monitor <

Looking for advanced Serial Monitor with UI? Check http://bit.ly/pio-advanced-monitor

If I execute the command in the terminal:
platformio device monitor --raw
monitor is displayed normally


If when I activate the “Upload and Monitor”:

all displayed normally

What have I done wrong?

1 Like

I haven’t tried setting the flags via monitor_flags yet, but why do you have listed --echo there? It also seems kinda weird to me, that the executed command doesn’t show the additional flags.

My English is only through Google translator. Please explain what do you mean?
What data still needs to be provided to prove that when the “ONLY MONITOR” is activated, it does not work properly (even if all the monitor flags are turned off).

What exactly is the environment you are using this in? Are you using VSCode? What are you doing exactly, when you say

and

?

I can’t reproduce this error using VSCode + PIO IDE. Manually starting the monitor with pio device monitor --raw results in the same output as launching the Serial Monitor with the “PlatformIO: Serial Monitor” button at the bottom of the VSCode window with monitor_flags beeing set to --raw.



So clearly?