trombik / freebsd-ports-esp-quick-toolchain

GCC toolchain for esp8266/arduino on FreeBSD. see https://github.com/trombik/freebsd-ports-esp-quick-toolchain/tree/main/devel/esp-quick-toolchain for details.
3 stars 1 forks source link

Fail to build ESPHome for ESP8266 on FreeBSD13 amd64 #11

Open rozhuk-im opened 1 year ago

rozhuk-im commented 1 year ago

With gcc103 got:

Compiling .pioenvs/hipper-ir-gate/src/esphome/components/remote_base/samsung_protocol.cpp.o
Compiling .pioenvs/hipper-ir-gate/src/esphome/components/remote_base/toshiba_ac_protocol.cpp.o
In file included from src/esphome/core/log.h:8,
                 from src/esphome/components/remote_base/samsung_protocol.cpp:2:
src/esphome/components/remote_base/samsung_protocol.cpp: In member function 'virtual void esphome::remote_base::SamsungProtocol::dump(const esphome::remote_base::SamsungData&)':
src/esphome/components/remote_base/samsung_protocol.cpp:61:46: error: expected ')' before '__INT64'
   61 |   ESP_LOGD(TAG, "Received Samsung: data=0x%" PRIX64 ", nbits=%d", data.data, data.nbits);
      |                                              ^~~~~~
/home/rim/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:39:76: note: in definition of macro 'FPSTR'
   39 | #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
      |                                                                            ^~~~~~~~~~~~
src/esphome/core/log.h:67:36: note: in expansion of macro 'F'
   67 | #define ESPHOME_LOG_FORMAT(format) F(format)
      |                                    ^
src/esphome/core/log.h:92:59: note: in expansion of macro 'ESPHOME_LOG_FORMAT'
   92 |   esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
      |                                                           ^~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:152:28: note: in expansion of macro 'esph_log_d'
  152 | #define ESP_LOGD(tag, ...) esph_log_d(tag, __VA_ARGS__)
      |                            ^~~~~~~~~~
src/esphome/components/remote_base/samsung_protocol.cpp:61:3: note: in expansion of macro 'ESP_LOGD'
   61 |   ESP_LOGD(TAG, "Received Samsung: data=0x%" PRIX64 ", nbits=%d", data.data, data.nbits);
      |   ^~~~~~~~
/home/rim/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:40:34: note: to match this '('
   40 | #define F(string_literal) (FPSTR(PSTR(string_literal)))
      |                                  ^~~~
/home/rim/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:39:76: note: in definition of macro 'FPSTR'
   39 | #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
      |                                                                            ^~~~~~~~~~~~
src/esphome/core/log.h:67:36: note: in expansion of macro 'F'
   67 | #define ESPHOME_LOG_FORMAT(format) F(format)
      |                                    ^
src/esphome/core/log.h:92:59: note: in expansion of macro 'ESPHOME_LOG_FORMAT'
   92 |   esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
      |                                                           ^~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:152:28: note: in expansion of macro 'esph_log_d'
  152 | #define ESP_LOGD(tag, ...) esph_log_d(tag, __VA_ARGS__)
      |                            ^~~~~~~~~~
src/esphome/components/remote_base/samsung_protocol.cpp:61:3: note: in expansion of macro 'ESP_LOGD'
   61 |   ESP_LOGD(TAG, "Received Samsung: data=0x%" PRIX64 ", nbits=%d", data.data, data.nbits);
      |   ^~~~~~~~
In file included from src/esphome/core/log.h:8,
                 from src/esphome/components/remote_base/toshiba_ac_protocol.cpp:2:
src/esphome/components/remote_base/toshiba_ac_protocol.cpp: In member function 'virtual void esphome::remote_base::ToshibaAcProtocol::dump(const esphome::remote_base::ToshibaAcData&)':
src/esphome/components/remote_base/toshiba_ac_protocol.cpp:108:56: error: expected ')' before '__INT64'

looks like there is no __INT64 definition.

With gcc4.8 got:

Compiling .pioenvs/hipper-ir-gate/src/esphome/components/api/api_connection.cpp.o
xtensa-lx106-elf-g++: error: unrecognized command line option '-std=gnu++17'
rozhuk-im commented 1 year ago

Quick fix^ replace in /usr/local/esp-quick-toolchain-gcc103/xtensa-lx106-elf/xtensa-lx106-elf/include/inttypes.h:

#define PRIX64      __PRI64(X)

to

#define PRIX64 "Xll"
trombik commented 1 year ago

@rozhuk-im thanks for the reporting. i also noticed this before but patched esphome instead. as espressif does not love ESP8266 RTOS SDK as much as they do esp-idf, (unlikely the maintainer will fix in a timely manner) probably patch the toolchain is the only option for us.

rozhuk-im commented 1 year ago

Looks like there is some mess with include files. I have no idea how to fix this on ESPHome side and make this fix.

PS: sorry for off topic, I almost done ESPHome port for FreeBSD. Last part is compiler and tools injection into packages. If I have time this script will be run as prebuild and inject missed packages, but now it is useful too.

package_inject.sh ``` #!/bin/sh __pkg_make() { # src, name, ver, owner local __PKG_SRC_DIR="${1}" local __PKG_NAME="${2}" local __PKG_VER="${3}" local __PKG_OWNER="${4}" local __PKG_DST_DIR="${HOME}/.platformio/packages/${__PKG_NAME}@${__PKG_VER}@${__PKG_OWNER}" # Check dirs. if [ "${__PKG_SRC_DIR}" != 'none' ] && [ ! -d "${__PKG_SRC_DIR}" ]; then echo "${__PKG_SRC_DIR}: not found!" return 1 fi if [ -d "${__PKG_DST_DIR}" ]; then echo "${__PKG_DST_DIR}: already exist!" return 1 fi # Create new package dir. mkdir -p "${__PKG_DST_DIR}" # Fill with content. if [ "${__PKG_SRC_DIR}" != 'none' ]; then find "${__PKG_SRC_DIR}/" -maxdepth 1 -type d -not -name '' -exec ln -s {} "${__PKG_DST_DIR}/" \; fi # Add description files. # .piopm cat < "${__PKG_DST_DIR}/.piopm" { "type": "tool", "name": "%%PKG_NAME%%", "version": "%%PKG_VER%%", "spec": { "owner": "%%PKG_OWNER%%", "name": "%%PKG_NAME%%", "url": null } } EOF # package.json cat < "${__PKG_DST_DIR}/package.json" { "name": "%%PKG_NAME%%", "version": "%%PKG_VER%%", "system": [ "freebsd_amd64" ], "url": null } EOF return 0 } __pkg_make '/usr/local/esp-quick-toolchain-gcc103/xtensa-lx106-elf' \ 'toolchain-xtensa' \ '2.100300.0' \ 'platformio' __pkg_make '/usr/local/xtensa-esp32-elf' \ 'toolchain-xtensa32' \ '2.50200.0' \ 'platformio' __pkg_make '/usr/local/xtensa-esp32-elf' \ 'toolchain-esp32ulp' \ '1.22851.0' \ 'platformio' __pkg_make '/usr/local/xtensa-esp32-elf' \ 'toolchain-xtensa-esp32' \ '8.4.0+2021r2-patch3' \ 'espressif' __pkg_make '/usr/local/xtensa-esp32-elf' \ 'toolchain-xtensa-esp32' \ '8.4.0+2021r2-patch2' \ 'espressif' __pkg_make '/usr/local/xtensa-esp32-elf' \ 'toolchain-xtensa-esp32s2' \ '8.4.0+2021r2-patch2' \ 'espressif' __pkg_make '/usr/local/riscv32-unknown-elf' \ 'toolchain-riscv32-esp' \ '8.4.0+2021r2-patch2' \ 'espressif' __pkg_make 'none' \ 'tool-cmake' \ '3.16.0' \ 'platformio' __pkg_make 'none' \ 'tool-ninja' \ '1.7.0' \ 'platformio' ```
trombik commented 1 year ago

good to know there are other FreeBSD users who works on esphome or "IoT" thingy. the problem of maintaining the toolchains is that, it take a long time to test all of them. I am actively using the toolchains, but some fixes have not been in my ports.

trombik commented 1 year ago

looks like this is a historical issue.

https://github.com/espressif/esp-idf/issues/52

it is deliberately disabled, but happened to work thanks to the following commit.

https://github.com/esp8266/Arduino/pull/5435

it seems to me that esphome is not interested in ESP8266 anymore. here is an issue i opened.

https://github.com/esphome/issues/issues/3348

rozhuk-im commented 1 year ago

Why not to add patch include/inttypes.h to fix at least known used things?