Closed winny2809 closed 5 years ago
Thank you very much for the timeliness with which you helped me, very kind. I integrated his library into my esp-idf system in Platformio, it is, unfortunately it generates me a lot of errors and I can not find the cause. Could you tell me what I'm wrong?
i cannot tell where the issue is, but looks to me that your build system is not correctly configured. more information would certainly help.
platformio.ini
by the way, platformio
does not support esp-idf
very well, e.g. sdkconfig
handling and other build-related issues. you need to understand and translate various build flags. the tool-chains they ship are often lagged behind.
Below, I attached the results of the compilation. Of course, as you say, platformer has problems especially with regard to "sdkconfig". Usually, however, I solve by inserting the various variables within the C file, such as in this case I put in the file i2cdev.c this definition: #define CONFIG_I2CDEV_TIMEOUT 1000 Unfortunately however, I do not understand the cause of all these mistakes, it will definitely be a nonsense to solve, but you need someone with more experience than me.
Executing task: C:\Users\Winny.platformio\penv\Scripts\platformio.exe run <
Verbose mode can be enabled via -v, --verbose
option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 1.11.0 > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: toolchain-xtensa32 2.50200.80 (5.2.0), framework-espidf 3.30300.190916 (3.3.0), tool-esptoolpy 1.20600.0 (2.6.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|--
^
lib\i2cdev\i2cdev.c:167:5: note: in expansion of macro 'ESP_LOGV' ESP_LOGV(TAG, "[0x%02x at %d] deleting mutex", dev->addr, dev->port); ^ lib\i2cdev\i2cdev.c:167:14: note: each undeclared identifier is reported only once for each function it appears in ESP_LOGV(TAG, "[0x%02x at %d] deleting mutex", dev->addr, dev->port); ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:299:81: note: in definition of macro 'ESP_LOG_LEVEL' if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:269:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
^
lib\i2cdev\i2cdev.c:167:5: note: in expansion of macro 'ESP_LOGV' ESP_LOGV(TAG, "[0x%02x at %d] deleting mutex", dev->addr, dev->port); ^ lib\i2cdev\i2cdev.c: In function 'i2c_dev_take_mutex': lib\i2cdev\i2cdev.c:187:14: error: 'TAG' undeclared (first use in this function) ESP_LOGV(TAG, "[0x%02x at %d] taking mutex", dev->addr, dev->port); ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:299:81: note: in definition of macro 'ESP_LOG_LEVEL' if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:269:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
^
lib\i2cdev\i2cdev.c:187:5: note: in expansion of macro 'ESP_LOGV' ESP_LOGV(TAG, "[0x%02x at %d] taking mutex", dev->addr, dev->port); ^ lib\i2cdev\i2cdev.c: In function 'i2c_dev_give_mutex': lib\i2cdev\i2cdev.c:215:14: error: 'TAG' undeclared (first use in this function) ESP_LOGV(TAG, "[0x%02x at %d] giving mutex", dev->addr, dev->port); ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:299:81: note: in definition of macro 'ESP_LOG_LEVEL' if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:269:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
^
lib\i2cdev\i2cdev.c:215:5: note: in expansion of macro 'ESP_LOGV' ESP_LOGV(TAG, "[0x%02x at %d] giving mutex", dev->addr, dev->port); ^ lib\i2cdev\i2cdev.c: In function 'i2cdev_done': lib\i2cdev\i2cdev.c:235:20: error: invalid storage class for function 'cfg_equal' inline static bool cfg_equal(const i2c_config_t a, const i2c_config_t b) ^ lib\i2cdev\i2cdev.c:257:18: error: invalid storage class for function 'i2c_setup_port' static esp_err_t i2c_setup_port(i2c_port_t port, const i2c_config_t *cfg) ^ In file included from lib\i2cdev\i2cdev.c:7:0: lib\i2cdev\i2cdev.c: In function 'i2c_setup_port': lib\i2cdev\i2cdev.c:271:18: error: 'TAG' undeclared (first use in this function) ESP_LOGD(TAG, "Reconfiguring I2C driver on port %d", port); ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:299:81: note: in definition of macro 'ESP_LOG_LEVEL' if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:268:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
^
lib\i2cdev\i2cdev.c:271:9: note: in expansion of macro 'ESP_LOGD' ESP_LOGD(TAG, "Reconfiguring I2C driver on port %d", port); ^ lib\i2cdev\i2cdev.c: In function 'i2c_dev_read': lib\i2cdev\i2cdev.c:371:22: error: 'TAG' undeclared (first use in this function) ESP_LOGE(TAG, "Could not read from device [0x%02x at %d]: %d", dev->addr, dev->port, res); ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:299:81: note: in definition of macro 'ESP_LOG_LEVEL' if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:265:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
^
lib\i2cdev\i2cdev.c:371:13: note: in expansion of macro 'ESP_LOGE' ESP_LOGE(TAG, "Could not read from device [0x%02x at %d]: %d", dev->addr, dev->port, res); ^ lib\i2cdev\i2cdev.c:389:1: error: expected 'while' before 'esp_err_t' esp_err_t i2c_dev_write(const i2c_dev_t dev, const void out_reg, size_t out_reg_size, const void *out_data, size_t out_size) ^ lib\i2cdev\i2cdev.c:437:1: error: expected declaration or statement at end of input } ^ lib\i2cdev\i2cdev.c:437:1: error: expected declaration or statement at end of input lib\i2cdev\i2cdev.c: In function 'i2cdev_done': lib\i2cdev\i2cdev.c:437:1: error: expected declaration or statement at end of input lib\i2cdev\i2cdev.c:437:1: error: expected declaration or statement at end of input lib\i2cdev\i2cdev.c:437:1: error: control reaches end of non-void function [-Werror=return-type] } ^ cc1.exe: some warnings being treated as errors [.pio\build\esp32doit-devkit-v1\lib6ca\i2cdev\i2cdev.o] Error 1 In file included from lib\pcf8575\pcf8575source.c:31:0: lib/i2cdev/i2cdev.h:285:43: error: 'dev' undeclared here (not in a function) esp_err_t = i2c_dev_take_mutex(dev); \ ^ lib/i2cdev/i2cdev.h:287:9: error: expected identifier or '(' before 'if' if (__ != ESP_OK) return ;\ ^ lib/i2cdev/i2cdev.h:289:5: error: expected identifier or '(' before '}' token } while (0) ^ lib/i2cdev/i2cdev.h:289:7: error: expected identifier or '(' before 'while' } while (0) ^ lib/i2cdev/i2cdev.h:297:9: error: expected identifier or '(' before 'if' if ( != ESP_OK) return _;\ ^ lib/i2cdev/i2cdev.h:299:5: error: expected identifier or '(' before '}' token } while (0) ^ lib/i2cdev/i2cdev.h:299:7: error: expected identifier or '(' before 'while' } while (0) ^ lib/i2cdev/i2cdev.h:307:9: error: expected identifier or '(' before 'if' if ( != ESP_OK) { \ ^ lib/i2cdev/i2cdev.h:315:7: error: expected identifier or '(' before 'while' } while (0) ^ [.pio\build\esp32doit-devkit-v1\lib588\pcf8575\pcf8575source.o] Error 1 ==================================================== [FAILED] Took 26.14 seconds ==================================================== The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
The main errors I find in these lines of code:
esp_err_t __ = i2c_dev_take_mutex(dev); \
if (__ != ESP_OK) return __;\
} while (0)
esp_err_t __ = i2c_dev_give_mutex(dev); \
if (__ != ESP_OK) return __;\
} while (0)
esp_err_t ___ = X; \
if (___ != ESP_OK) { \
I2C_DEV_GIVE_MUTEX(dev); \
return ___; \
} \
} while (0)
and also in the definitions of SEMAPHORE... It seems to me that the problems come from SEMAPHORE or at least from The Freertos. In my file c_cpp_properties.json i have this code:
"intelliSenseMode": "clang-x64", "cStandard": "c99", "cppStandard": "c++11", "compilerPath": "\"C:/Users/Winny/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gcc.exe\" -mlongcalls"
I hope this will help you understand my problem
what would happen if you add #include <esp_err.h>
to lib/i2cdev/i2cdev.h
? something like:
diff --git a/components/i2cdev/i2cdev.h b/components/i2cdev/i2cdev.h
index ba68248..63e75d5 100644
--- a/components/i2cdev/i2cdev.h
+++ b/components/i2cdev/i2cdev.h
@@ -15,6 +15,7 @@
#include <driver/i2c.h>
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
+#include <esp_err.h>
#ifdef __cplusplus
extern "C" {
Hello, I did the tests you asked me to do. Below is the result of the compilation, unfortunately no improvement. The header of the i2cdev.h file is this:
extern "C" {
Below is the result of the compilation:
Executing task: C:\Users\Winny.platformio\penv\Scripts\platformio.exe run <
Verbose mode can be enabled via -v, --verbose
option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 1.11.0 > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: toolchain-xtensa32 2.50200.80 (5.2.0), framework-espidf 3.30300.190916 (3.3.0), tool-esptoolpy 1.20600.0 (2.6.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|--
^
lib\i2cdev\i2cdev.c:167:5: note: in expansion of macro 'ESP_LOGV' ESP_LOGV(TAG, "[0x%02x at %d] deleting mutex", dev->addr, dev->port); ^ lib\i2cdev\i2cdev.c:167:14: note: each undeclared identifier is reported only once for each function it appears in ESP_LOGV(TAG, "[0x%02x at %d] deleting mutex", dev->addr, dev->port); ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:299:81: note: in definition of macro 'ESP_LOG_LEVEL' if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:269:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
^
lib\i2cdev\i2cdev.c:167:5: note: in expansion of macro 'ESP_LOGV' ESP_LOGV(TAG, "[0x%02x at %d] deleting mutex", dev->addr, dev->port); ^ lib\i2cdev\i2cdev.c: In function 'i2c_dev_take_mutex': lib\i2cdev\i2cdev.c:187:14: error: 'TAG' undeclared (first use in this function) ESP_LOGV(TAG, "[0x%02x at %d] taking mutex", dev->addr, dev->port); ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:299:81: note: in definition of macro 'ESP_LOG_LEVEL' if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:269:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
^
lib\i2cdev\i2cdev.c:187:5: note: in expansion of macro 'ESP_LOGV' ESP_LOGV(TAG, "[0x%02x at %d] taking mutex", dev->addr, dev->port); ^ lib\i2cdev\i2cdev.c: In function 'i2c_dev_give_mutex': lib\i2cdev\i2cdev.c:215:14: error: 'TAG' undeclared (first use in this function) ESP_LOGV(TAG, "[0x%02x at %d] giving mutex", dev->addr, dev->port); ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:299:81: note: in definition of macro 'ESP_LOG_LEVEL' if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:269:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
^
lib\i2cdev\i2cdev.c:215:5: note: in expansion of macro 'ESP_LOGV' ESP_LOGV(TAG, "[0x%02x at %d] giving mutex", dev->addr, dev->port); ^ lib\i2cdev\i2cdev.c: In function 'i2cdev_done': lib\i2cdev\i2cdev.c:235:20: error: invalid storage class for function 'cfg_equal' inline static bool cfg_equal(const i2c_config_t a, const i2c_config_t b) ^ lib\i2cdev\i2cdev.c:257:18: error: invalid storage class for function 'i2c_setup_port' static esp_err_t i2c_setup_port(i2c_port_t port, const i2c_config_t *cfg) ^ In file included from lib\i2cdev\i2cdev.c:7:0: lib\i2cdev\i2cdev.c: In function 'i2c_setup_port': lib\i2cdev\i2cdev.c:271:18: error: 'TAG' undeclared (first use in this function) ESP_LOGD(TAG, "Reconfiguring I2C driver on port %d", port); ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:299:81: note: in definition of macro 'ESP_LOG_LEVEL' if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:268:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
^
lib\i2cdev\i2cdev.c:271:9: note: in expansion of macro 'ESP_LOGD' ESP_LOGD(TAG, "Reconfiguring I2C driver on port %d", port); ^ lib\i2cdev\i2cdev.c: In function 'i2c_dev_read': lib\i2cdev\i2cdev.c:371:22: error: 'TAG' undeclared (first use in this function) ESP_LOGE(TAG, "Could not read from device [0x%02x at %d]: %d", dev->addr, dev->port, res); ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:299:81: note: in definition of macro 'ESP_LOG_LEVEL' if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ ^ C:/Users/Winny/.platformio/packages/framework-espidf/components/log/include/esp_log.h:265:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
^
lib\i2cdev\i2cdev.c:371:13: note: in expansion of macro 'ESP_LOGE' ESP_LOGE(TAG, "Could not read from device [0x%02x at %d]: %d", dev->addr, dev->port, res); ^ lib\i2cdev\i2cdev.c:389:1: error: expected 'while' before 'esp_err_t' esp_err_t i2c_dev_write(const i2c_dev_t dev, const void out_reg, size_t out_reg_size, const void *out_data, size_t out_size) ^ lib\i2cdev\i2cdev.c:437:1: error: expected declaration or statement at end of input } ^ lib\i2cdev\i2cdev.c:437:1: error: expected declaration or statement at end of input lib\i2cdev\i2cdev.c: In function 'i2cdev_done': lib\i2cdev\i2cdev.c:437:1: error: expected declaration or statement at end of input lib\i2cdev\i2cdev.c:437:1: error: expected declaration or statement at end of input lib\i2cdev\i2cdev.c:437:1: error: control reaches end of non-void function [-Werror=return-type] } ^ cc1.exe: some warnings being treated as errors [.pio\build\esp32doit-devkit-v1\lib6ca\i2cdev\i2cdev.o] Error 1 In file included from lib\pcf8575\pcf8575source.c:31:0: lib/i2cdev/i2cdev.h:255:43: error: 'dev' undeclared here (not in a function) esp_err_t = i2c_dev_take_mutex(dev); \ ^ lib/i2cdev/i2cdev.h:257:9: error: expected identifier or '(' before 'if' if (__ != ESP_OK) return ;\ ^ lib/i2cdev/i2cdev.h:259:5: error: expected identifier or '(' before '}' token } while (0) ^ lib/i2cdev/i2cdev.h:259:7: error: expected identifier or '(' before 'while' } while (0) ^ lib/i2cdev/i2cdev.h:267:9: error: expected identifier or '(' before 'if' if ( != ESP_OK) return _;\ ^ lib/i2cdev/i2cdev.h:269:5: error: expected identifier or '(' before '}' token } while (0) ^ lib/i2cdev/i2cdev.h:269:7: error: expected identifier or '(' before 'while' } while (0) ^ lib/i2cdev/i2cdev.h:277:9: error: expected identifier or '(' before 'if' if ( != ESP_OK) { \ ^ lib/i2cdev/i2cdev.h:285:7: error: expected identifier or '(' before 'while' } while (0) ^ [.pio\build\esp32doit-devkit-v1\lib588\pcf8575\pcf8575source.o] Error 1 ==================================================== [FAILED] Took 26.84 seconds ==================================================== The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
I'm at a loss. I've never dealt with the PlatformIO.
Could you try to manually build examples using make
or idf.py
?
Yes now i try it
OK, I've rethought it and it all went a good fine. Now come I proceed with visual studio code (platformio)?
Since the build of examples with the recommended method was successful, I believe that you should ask questions related to the platformIO or VisualStudio on the esp-32 forum. I am closing this issue.
Would like to say that UncleRus could program the I2C with the paths he claims he has , then try it on another PC with the advice he gives out , then he also would find it does not work!... it's not a native path in platformIO or Visual Studio plugin tools. Or Eclipse... Better I write one from scratch would have taken me less time... What a pain..........
we support esp-idf as a build system. I'm sorry to hear that your favourite tool doesn't work with the libraries. however, as the issue doesn't happen with the supported build system, I'd like to say that our efforts to help diagnosing the issue is only a best efforts basis. it would be faster to solve the issue if you ask someone who knows your tool than adding another "it doesn't work" comment without any details. thanks for your understanding.
Is it possible to have some examples regarding the i2c device and if possible also of the device pcf8575?
I can't understand many things about it, and I would have some examples, maybe even an initial configuration :-(