From 450f55262f4ef41c240de0a2754824125cbe83da Mon Sep 17 00:00:00 2001 From: Jochen Kiemes Date: Sun, 25 Aug 2024 21:53:50 +0200 Subject: [PATCH] fix StepperDemo compile error and adjust simavr limits --- CHANGELOG.md | 3 ++- examples/StepperDemo/StepperDemo.ino | 14 ++++++++++++-- extras/tests/esp32_hw_based/Makefile | 6 ++++++ extras/tests/esp32_hw_based/test_all.sh | 13 +++++++++++++ .../test_sd_04_timing_2560/expect.txt | 16 ++++++++-------- .../test_sd_04_timing_328p/expect.txt | 10 +++++----- .../test_sd_04_timing_328p_37k/expect.txt | 2 +- .../simavr_based/test_sd_11_328p/expect.txt | 6 +++--- src/fas_arch/espidf_esp32.h | 2 +- 9 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 extras/tests/esp32_hw_based/test_all.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bab1a85..8bb7e682 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ pre-0.31.0: - compatibility with esp-idf 5.3.0 (not working with 5.0.x to 5.2.x) `pio run -e esp32_idf_V6_8_1` in `pio_espidf/UsageExample` works. - Drop support for esp-idf 3.x.y versions - beta level. barely tested +- Add github build tests for esp32c6 with espidf5 +- StepperDemo can be compiled with esp-idf4/5 without arduino 0.30.15: - Fix missing initialization in `getCurrentSpeedInTicks()` (#262) diff --git a/examples/StepperDemo/StepperDemo.ino b/examples/StepperDemo/StepperDemo.ino index b8b8e226..390672c6 100644 --- a/examples/StepperDemo/StepperDemo.ino +++ b/examples/StepperDemo/StepperDemo.ino @@ -903,12 +903,20 @@ void test_direct_drive(const struct stepper_config_s *stepper) { void setup() { PRINT_INIT(); -#ifdef ARDUINO_ARCH_ESP32 +#if defined(ARDUINO_ARCH_ESP32) printf("LOG start\n"); esp_log_level_set("*", ESP_LOG_INFO); esp_log_level_set("rmt", ESP_LOG_INFO); ESP_LOGI("StepperDemo", "Started INFO"); ESP_LOGE("*", "Started ERROR"); + PRINTLN(""); +#endif +#if defined(ARDUINO_ARCH_ESP32) || defined(ESP_PLATFORM) + PRINT("ESP-IDF: "); + PRINTI16((int16_t)ESP_IDF_VERSION_MAJOR); + PRINTCH('.'); + PRINTI16((int16_t)ESP_IDF_VERSION_MINOR); + PRINTLN(""); #endif for(uint8_t i = 0;i < MAX_STEPPER;i++) { @@ -1189,9 +1197,9 @@ bool process_cmd(char *cmd) { ESP.restart(); #else esp_reset(); -#endif #endif } +#endif #if defined(ARDUINO_ARCH_AVR) if (*cmd == 0) { output_msg(MSG_STRAY_DIGITAL_READ_TOGGLE); @@ -1780,6 +1788,8 @@ extern "C" void app_main() { esp_task_wdt_add(NULL); #endif esp_task_wdt_add(NULL); + + printf("Non-arduino version\n"); setup(); while(true) { loop(); diff --git a/extras/tests/esp32_hw_based/Makefile b/extras/tests/esp32_hw_based/Makefile index edd7e778..346513e4 100644 --- a/extras/tests/esp32_hw_based/Makefile +++ b/extras/tests/esp32_hw_based/Makefile @@ -19,5 +19,11 @@ test: M1.test M7.test compile: (cd ../../../pio_dirs/StepperDemo;rm -fR .pio; pio run -e esp32_V6_8_1 -t upload --upload-port /dev/$(DEV)) +compile_idf4: + (cd ../../../pio_espidf/StepperDemo;rm -fR .pio; pio run -e esp32_idf_V5_3_0 -t upload --upload-port /dev/$(DEV)) + +compile_idf5: + (cd ../../../pio_espidf/StepperDemo;rm -fR .pio; pio run -e esp32_idf_V6_8_1 -t upload --upload-port /dev/$(DEV)) + clean: rm -f seq*.log diff --git a/extras/tests/esp32_hw_based/test_all.sh b/extras/tests/esp32_hw_based/test_all.sh new file mode 100644 index 00000000..2006569f --- /dev/null +++ b/extras/tests/esp32_hw_based/test_all.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# arduino idf4 based test +make compile +make M1.test M7.test + +# idf4 based test +make compile_idf4 +make M1.test M7.test + +# idf5 only rmt-module supporting 8 steppers +make compile_idf5 +make M1.test diff --git a/extras/tests/simavr_based/test_sd_04_timing_2560/expect.txt b/extras/tests/simavr_based/test_sd_04_timing_2560/expect.txt index f5d073ad..4827cf7f 100644 --- a/extras/tests/simavr_based/test_sd_04_timing_2560/expect.txt +++ b/extras/tests/simavr_based/test_sd_04_timing_2560/expect.txt @@ -4,9 +4,9 @@ EnableA: 1*L->H, 1*H->L EnableB: 2*L->H, 1*H->L EnableC: 2*L->H, 1*H->L - StepA: 64000*L->H, 64000*H->L, Max High=22us Total High=312923us - StepB: 64000*L->H, 64000*H->L, Max High=33us Total High=360304us - StepC: 64000*L->H, 64000*H->L, Max High=35us Total High=391846us + StepA: 64000*L->H, 64000*H->L, Max High=22us Total High=313053us + StepB: 64000*L->H, 64000*H->L, Max High=34us Total High=360569us + StepC: 64000*L->H, 64000*H->L, Max High=35us Total High=384714us Position[A]=64000 Position[B]=64000 @@ -17,13 +17,13 @@ Time in EnableA max=233599 us, total=233599 us Time in EnableB max=246086 us, total=246086 us -Time in EnableC max=254243 us, total=254243 us +Time in EnableC max=254244 us, total=254244 us -Time in FillISR max=2774 us, total=2119073 us +Time in FillISR max=2774 us, total=2119112 us -Time in StepA max=22 us, total=312923 us +Time in StepA max=22 us, total=313053 us -Time in StepB max=33 us, total=360304 us +Time in StepB max=34 us, total=360569 us -Time in StepC max=35 us, total=391846 us +Time in StepC max=35 us, total=384714 us diff --git a/extras/tests/simavr_based/test_sd_04_timing_328p/expect.txt b/extras/tests/simavr_based/test_sd_04_timing_328p/expect.txt index 43aa3290..5942a762 100644 --- a/extras/tests/simavr_based/test_sd_04_timing_328p/expect.txt +++ b/extras/tests/simavr_based/test_sd_04_timing_328p/expect.txt @@ -2,8 +2,8 @@ DirB: 1*L->H, 0*H->L EnableA: 1*L->H, 1*H->L EnableB: 2*L->H, 1*H->L - StepA: 1000*L->H, 1000*H->L, Max High=13us Total High=4234us - StepB: 1000*L->H, 1000*H->L, Max High=14us Total High=5038us + StepA: 1000*L->H, 1000*H->L, Max High=13us Total High=4252us + StepB: 1000*L->H, 1000*H->L, Max High=15us Total High=5049us Position[A]=1000 Position[B]=1000 @@ -12,11 +12,11 @@ Time in EnableA max=225398 us, total=225398 us Time in EnableB max=238118 us, total=238118 us -Time in FillISR max=2651 us, total=47826 us +Time in FillISR max=2651 us, total=47834 us -Time in StepA max=13 us, total=4234 us +Time in StepA max=13 us, total=4252 us -Time in StepB max=14 us, total=5038 us +Time in StepB max=15 us, total=5049 us Time in StepISR max=6 us, total=8566 us diff --git a/extras/tests/simavr_based/test_sd_04_timing_328p_37k/expect.txt b/extras/tests/simavr_based/test_sd_04_timing_328p_37k/expect.txt index b668de35..944fbd7e 100644 --- a/extras/tests/simavr_based/test_sd_04_timing_328p_37k/expect.txt +++ b/extras/tests/simavr_based/test_sd_04_timing_328p_37k/expect.txt @@ -8,7 +8,7 @@ Position[A]=1000 Time in EnableA max=225399 us, total=225399 us -Time in FillISR max=2023 us, total=27791 us +Time in FillISR max=2023 us, total=27796 us Time in StepA max=9 us, total=3978 us diff --git a/extras/tests/simavr_based/test_sd_11_328p/expect.txt b/extras/tests/simavr_based/test_sd_11_328p/expect.txt index c0b102d4..919fc7bf 100644 --- a/extras/tests/simavr_based/test_sd_11_328p/expect.txt +++ b/extras/tests/simavr_based/test_sd_11_328p/expect.txt @@ -2,11 +2,11 @@ DirB: 1*L->H, 0*H->L EnableA: 1*L->H, 1*H->L EnableB: 1*L->H, 0*H->L - StepA: 99558*L->H, 99558*H->L, Max High=11us Total High=384501us + StepA: 99808*L->H, 99808*H->L, Max High=11us Total High=385248us StepB: 0*L->H, 0*H->L, Max High=0us Total High=0us -Position[A]=50286 +Position[A]=50536 Time in EnableA max=225395 us, total=225395 us -Time in StepA max=11 us, total=384501 us +Time in StepA max=11 us, total=385248 us diff --git a/src/fas_arch/espidf_esp32.h b/src/fas_arch/espidf_esp32.h index 55f2621f..47d571c9 100644 --- a/src/fas_arch/espidf_esp32.h +++ b/src/fas_arch/espidf_esp32.h @@ -14,7 +14,7 @@ #define LOW 0 #define HIGH 1 #define OUTPUT GPIO_MODE_OUTPUT -#define pinMode(pin, mode) gpio_set_direction((gpio_num_t)pin, mode) +#define pinMode(pin, mode) gpio_set_direction((gpio_num_t)pin, (mode) == OUTPUT ? GPIO_MODE_OUTPUT : GPIO_MODE_INPUT) #define digitalWrite(pin, level) gpio_set_level((gpio_num_t)pin, level) #define digitalRead(pin) gpio_get_level((gpio_num_t)pin)