mikemoy
October 31, 2018, 9:38pm
#1
I noticed that using “board_build.f_cpu = 240000000L” in the platform.ini file does not affect the speed.
Using an ESP32 Dev module, I have always included this in my platform.ini file to make it run as fast as possible:
; set frequency to 240MHz
board_build.f_cpu = 240000000L
I have often wondered if that was really doing anything, so today I set out to prove that.
I am running the following code.
#include <Arduino.h>
void setup() {
pinMode(4, OUTPUT);
}
void loop() {
digitalWrite(4, HIGH);
digitalWrite(4, LOW);
}
I have my scope connected to pin 4, and this shot of the scope using
“board_build.f_cpu = 240000000L” in my .ini file.
I then commented out “board_build.f_cpu = 240000000L” in my .ini file. Re-compiled and uoploaded and here is the result of that.
I even tried changing it to “160000000L” and it still does not affect the GPIO speed.
So my question is, why doesn’t “board_build.f_cpu = 240000000L” in my .ini file. do anything ?
I guess this feature works only in ESP-IDF, not in Ardunio environment?
If clean a project and start building in verbose mode, do you see that F_CPU
macro changes?
mikemoy
November 4, 2018, 6:09pm
#4
Nope, it has no affect in either environment.
yes, here is the output:
PS C:\Users\Mike\Documents\PlatformIO\Projects\CD_Motor_Spin> pio run -v
Processing esp32dev (monitor_port: COM5; board_build.f_cpu: 240000000L; framework: arduino; monitor_speed: 115200; platform: espressif32; upload_speed: 921600; board: esp32dev; upload_port: COM5)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 > Espressif ESP32 Dev Module
SYSTEM: ESP32 240MHz 320KB RAM (4MB Flash)
DEBUG: CURRENT(esp-prog) EXTERNAL(esp-prog, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 24 compatible libraries
Scanning dependencies...
No dependencies
<lambda>(["checkprogsize"], [".pioenvs\esp32dev\firmware.elf"])
MethodWrapper(["checkprogsize"], [".pioenvs\esp32dev\firmware.elf"])
Memory Usage -> http://bit.ly/pio-memory-usage
DATA: [ ] 4.3% (used 13972 bytes from 327680 bytes)
PROGRAM: [= ] 14.0% (used 182988 bytes from 1310720 bytes)
.pioenvs\esp32dev\firmware.elf :
section size addr
.rtc.text 0 1074528256
.rtc_noinit 0 1342177792
.iram0.vectors 1024 1074266112
.iram0.text 41132 1074267136
.dram0.data 9172 1073479680
.noinit 0 1073488852
.dram0.bss 4800 1073488856
.flash.rodata 34796 1061158944
.flash.text 96864 1074593816
.comment 419 0
.xtensa.info 56 0
.xt.lit._ZN14HardwareSerialD5Ev 0 0
.xt.prop._ZN14HardwareSerialD5Ev 0 0
.xt.prop._ZN14HardwareSerialD2Ev 36 0
.xt.prop._ZN14HardwareSerialD0Ev 36 0
.xt.prop._ZTV14HardwareSerial 12 0
.xt.lit._ZN9IPAddressD5Ev 0 0
.xt.prop._ZN9IPAddressD5Ev 0 0
.xt.prop._ZN9IPAddressD2Ev 36 0
.xt.prop._ZN9IPAddressD0Ev 36 0
.xt.prop._ZTV9IPAddress 12 0
.xt.lit._ZN5Print5writeEPKc 8 0
.xt.prop._ZN5Print5writeEPKc 60 0
.xt.prop._ZTISt9exception 12 0
.xt.prop._ZTISt9bad_alloc 12 0
.xt.prop._ZTVN10__cxxabiv117__class_type_infoE 12 0
.xt.lit._ZNK9__gnu_cxx24__concurrence_lock_error4whatEv 8 0
.xt.lit._ZNK9__gnu_cxx26__concurrence_unlock_error4whatEv 8 0
.xt.lit._ZN9__gnu_cxx24__concurrence_lock_errorD5Ev 8 0
.xt.lit._ZN9__gnu_cxx26__concurrence_unlock_errorD5Ev 8 0
.xt.lit._ZN9__gnu_cxx7__mutex4lockEv 8 0
.xt.lit._ZN9__gnu_cxx13__scoped_lockD5Ev 8 0
.xt.prop._ZNK9__gnu_cxx24__concurrence_lock_error4whatEv 48 0
.xt.prop._ZNK9__gnu_cxx26__concurrence_unlock_error4whatEv 48 0
.xt.prop._ZN9__gnu_cxx24__concurrence_lock_errorD5Ev 12 0
.xt.prop._ZN9__gnu_cxx26__concurrence_unlock_errorD5Ev 12 0
.xt.prop._ZN9__gnu_cxx7__mutex4lockEv 60 0
.xt.prop._ZN9__gnu_cxx13__scoped_lockD5Ev 12 0
.xt.prop._ZN9__gnu_cxx24__concurrence_lock_errorD2Ev 36 0
.xt.prop._ZN9__gnu_cxx26__concurrence_unlock_errorD2Ev 36 0
.xt.prop._ZN9__gnu_cxx24__concurrence_lock_errorD0Ev 36 0
.xt.prop._ZN9__gnu_cxx26__concurrence_unlock_errorD0Ev 36 0
.xt.prop._ZN9__gnu_cxx13__scoped_lockD2Ev 72 0
.xt.prop._ZTIN9__gnu_cxx24__concurrence_lock_errorE 12 0
.xt.prop._ZTIN9__gnu_cxx26__concurrence_unlock_errorE 12 0
.xt.prop._ZTVN9__gnu_cxx24__concurrence_lock_errorE 12 0
.xt.prop._ZTVN9__gnu_cxx26__concurrence_unlock_errorE 12 0
.xt.prop._ZTVSt9bad_alloc 12 0
.xt.prop._ZTVN10__cxxabiv120__si_class_type_infoE 12 0
.debug_line 557328 0
.debug_info 1175663 0
.debug_abbrev 148980 0
.debug_aranges 26736 0
.debug_frame 67616 0
.debug_loc 468255 0
.debug_ranges 27904 0
.debug_str 203941 0
Total 2865486
===================================================================================================== [SUCCESS] Took 3.28 seconds =====================================================================================================
PS C:\Users\Mike\Documents\PlatformIO\Projects\CD_Motor_Spin>
I mean build flags… Try to run these commands:
pio run -t clean
pio run -v
You should see -D F_CPU
…
mikemoy
November 4, 2018, 7:04pm
#6
ivankravets:
pio run -v
I do see it (see below). I have tried re-making it with:
“board_build.f_cpu = 160000000L”
and
“board_build.f_cpu = 240000000L”
using this for both attempts
pio run -t clean
pio run -v
When I clean and build again i do see that "-DF_CPU= " what I set in the platform.ini file. However uploading it has no affect on the speed. I should also note that the speed on the GPIO pin shows its always running at 240MHZ regardless what I set “board_build.f_cpu =” to, and what “-DF_CPU=” stated in the build process.
.
I then jumped over to IDF using mingw32.exe and tried this example,
#include <stdio.h>
#include "driver/gpio.h"
#include "sdkconfig.h"
#define BLINK_GPIO 4
void app_main()
{
gpio_pad_select_gpio(BLINK_GPIO);
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
while(1)
{
gpio_set_level(BLINK_GPIO, 0);
gpio_set_level(BLINK_GPIO, 1);
}
}
running menuconfig I changed it to 160MHZ & 240MHZ and it does indeed change the speed of the waveform.
Here is the output when I had “board_build.f_cpu = 160000000L”
Done cleaning
===================================================================================================== [SUCCESS] Took 1.83 seconds =====================================================================================================
PS C:\Users\Mike\Documents\PlatformIO\Projects\GPIOTest> pio run -v
Processing esp32dev (monitor_port: COM5; board_build.f_cpu: 160000000L; framework: arduino; monitor_speed: 115200; platform: espressif32; upload_speed: 921600; board: esp32dev; upload_port: COM5)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 > Espressif ESP32 Dev Module
SYSTEM: ESP32 160MHz 320KB RAM (4MB Flash)
DEBUG: CURRENT(esp-prog) EXTERNAL(esp-prog, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 24 compatible libraries
Scanning dependencies...
No dependencies
xtensa-esp32-elf-g++ -o .pioenvs\esp32dev\src\main.cpp.o -c -fno-rtti -fno-exceptions -std=gnu++11 -Os
-Wall -nostdlib -Wpointer-arith -Wno-error=unused-but-set-variable -Wno-error=unused-variable -mlongcalls
-ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wno-error=deprecated-declarations -Wno-
error=unused-function -Wno-unused-parameter -Wno-sign-compare -fstack-protector -fexceptions
-DPLATFORMIO=30602 -DARDUINO_ESP32_DEV -DESP32 -DESP_PLATFORM -DF_CPU=160000000L
-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DARDUINO=10805
mikemoy:
-DF_CPU
This is Arduino historical macro. Could you ask a help in GitHub - espressif/arduino-esp32: Arduino core for the ESP32 ?
mikemoy
November 17, 2018, 7:01am
#8
They said the same thing there. So where does that leave us at ?
I think is better to ask here GitHub - espressif/arduino-esp32: Arduino core for the ESP32 . You should have access to ESP-IDF API from Arduino core.