Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for latest Espressif ESP8266 frameworks: NONOS-SDK 3.0.4 and RTOS-SDK 3.4 #284

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

freedib
Copy link

@freedib freedib commented Nov 11, 2022

This Pull Request implements support for the latest Espressif ESP8266 frameworks

Changes are explained in each commit of the Pull Request

Support for the Espressif NONOS-SDK requires two additional packages

  • The latest Espressif NONOS-SDK @ 3.0.5 framework with additional platformio's package.json
    GIT: https://github.com/freedib/framework-esp8266-nonos-sdk.git
  • a new tool called genbin.py in replacement of esptool which can create the two legacy OTA bin files in one call
    GIT: https://github.com/freedib/tool-genbin.git
    The builder appends -DSPI_FLASH_SIZE_MAP=n to CCFLAGS for the compiler. main.c should handle this value accordingly to Espressif documentation.
    OTA is activated the same way than ESP-IDF thru a build.partition in board definition. If used, two bin files are generated, and the first one uploaded. Then, the two bin files can be uploaded to a web server for FOTA update.

Support for the Espressif RTOS-SDK @ 3.4 is very similar to the latest ESP-IDF platform with ESP8266 in mind. Support for old RTOS-SDK @ 1.5 have been removed.
It requires one additional package:

Embed_files support have been included in esp8266-nonos-sdk and Arduino builders. It should replace the one proposed in Pull Request #267 to support the new esp8266-rtos-sdk builder

Requires package framework-esp8266-nonos-sdk@ 3.0.5
https://github.com/freedib/framework-esp8266-nonos-sdk.git

Fix build bugs
  platform.py
    - Remove dependency to xtensa 1.40802.0
  esp8266-nonos-sdk & esp8266-rtos-sdk
    - Suppress literal-suffix warnings from SDK building
    - Set correct libraries list for nonos-sdk & rtos-sdk
  esp8266-nonos-sdk
    - Set correct include paths for nonos-sdk
    - Avoid building SDK drivers on each run for nonos-sdk

Support for nonos-sdk 3.0.5
  platform.json:
    - Update nonos-sdk and rtos-sdk version numbers
  esp8266-nonos-sdk.py:
    - Add SPI_FLASH_SIZE_MAP to compile flags
    - Use the new "esp_init_data_default_v08.bin" file for NONOS 3.0.4
Requires package tool-genbin
https://github.com/freedib/tool-genbin.git @ 1.0.0

OTA is build if board contains a build.partitions entry containing the
word "ota". a good practice is to use "partitions_two_ota.csv" as in
esp-idf

esp8266-nonos-sdk.py and esp8266-rtos-sdk.py
- change linker script LDSCRIPT_PATH if OTA
- change ElfToBin builder to use genbin.py instead of esptool
  genbin.py allows to create user1.bin and user2.bin in one call
  (named firmware.bin.user1.bin and firmware.bin.user2.bin)
- set correct FLASH_EXTRA_IMAGES list for flashing

main.py
- allow a custom bootloader like firmware.bin.user1.bin to upload

platform.json
- add dependency to genbin

boards/esp12e_ota.json
- example board for use with OTA
Requires package framework-esp8266-rtos-sdk @ 3.4
https://github.com/freedib/framework-esp8266-rtos-sdk.git

Code adapted from Wallace William to fit most recent esp-idf code

esp8266-rtos-sdk.py (replacement)
- remove all code for old rtos-sdk @ 1.5 and replace it with 3.4 code

_embed_files.py (new)
- support for embedded data

main.py
- add _get_board_flash_mode function
- add definition for ESPTOOL
- change definition for OBJCOPY if esp8266-rtos-sdk
- use a different uploader command for esp8266-rtos-sdk

platform.py
- change xtensa version and cmake/ninja usage if esp8266-rtos-sdk

platform.json
- change framework-esp8266-rtos-sdk version
- add cmake & ninja tools

esp8266-nonos-sdk.py
- remove references to old rtos sdk
esp8266-nonos-sdk.py & arduino.py
- source the _embed_files.py
@freedib
Copy link
Author

freedib commented Nov 14, 2022

RTOS-SDK @ 3.4 requires a new toolchain-xtensa @ 8.4.0.
I packaged it locally for my Linux system, but I could prepare a version suitable for the Registry

@freedib
Copy link
Author

freedib commented Nov 15, 2022

tool-genbin have been renamed to tool-genbin-esp8266.
GIT: https://github.com/freedib/tool-genbin-esp8266.git

@qnxsgwy
Copy link

qnxsgwy commented Nov 20, 2022

Thank you for your contribution, hope to support RTOS-SDK 3.4 as soon as possible, the current version is too old

@omar-mohamed-khallaf
Copy link

omar-mohamed-khallaf commented Nov 27, 2022

When will it be merged?

@YashxD
Copy link

YashxD commented Dec 25, 2022

I am sure a lot of folks are eagerly awaiting this PR to be merged. Is there any particular reason it's being held back? Can I contribute in any way?

@h1aji
Copy link

h1aji commented Mar 26, 2023

@freedib I am getting this error when i try to install

remote: Counting objects: 100% (105/105), done.
remote: Compressing objects: 100% (79/79), done.
remote: Total 105 (delta 54), reused 46 (delta 13), pack-reused 0
Receiving objects: 100% (105/105), 46.42 KiB | 864.00 KiB/s, done.
Resolving deltas: 100% (54/54), done.
Platform Manager: espressif8266@4.2.0+sha.032d938 has been installed!
Tool Manager: Installing platformio/toolchain-xtensa @ ~2.100300.0
Unpacking  [####################################]  100%          
Tool Manager: toolchain-xtensa@2.100300.220621 has been installed!
Tool Manager: Installing platformio/tool-genbin-esp8266 @ ~1.0.0
Error: Could not find the package with 'platformio/tool-genbin-esp8266 @ ~1.0.0' requirements for your system 'linux_x86_64'

Any chance to fix it?

@freedib
Copy link
Author

freedib commented Mar 26, 2023

Because this pull request have not been merged, tool-genbin-esp8266 have not been added to platformio registry.
From your log, it seems also that "pio run" downloads the current espressif8266 framework (version 4.2.0) and not the one of the pull request (version 4.0.1)
You have to modify your platformio.ini file to specify where to get components.

If developing for NONOS SDK:
[env]
platform = https://github.com/freedib/platform-espressif8266.git
framework = esp8266-nonos-sdk
platform_packages =
framework-esp8266-nonos-sdk @ https://github.com/freedib/framework-esp8266-nonos-sdk@3.0.5
tool-genbin-esp8266 @ https://github.com/freedib/tool-genbin-esp8266@1.0.0

If developing for RTOS SDK on Linux 64:
[env]
platform = https://github.com/freedib/platform-espressif8266.git
framework = esp8266-rtos-sdk
platform_packages =
framework-esp8266-rtos-sdk @ https://github.com/freedib/framework-esp8266-rtos-sdk.git@3.4
toolchain-xtensa @ https://github.com/freedib/toolchain-xtensa-8.4.0-linux-amd64.git@8.4.0
tool-genbin-esp8266 @ https://github.com/freedib/tool-genbin-esp8266@1.0.0

@h1aji
Copy link

h1aji commented May 16, 2023

@freedib Thanks it all works except mdns from components.

Building in release mode
Linking .pio/build/esp12e/firmware.elf
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/webserver.o:(.bss.clientIvol+0x0): multiple definition of `clientIvol'; .pio/build/esp12e/src/main.o:(.bss.clientIvol+0x0): first defined here
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/main.o:(.literal.app_main+0xf4): undefined reference to `mdns_init'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/main.o: in function `app_main':
/home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/main.c:745: undefined reference to `mdns_init'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/main.c:750: undefined reference to `mdns_hostname_set'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/main.c:755: undefined reference to `mdns_instance_name_set'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/main.c:760: undefined reference to `mdns_service_add'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/main.c:763: undefined reference to `mdns_service_add'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/interface.o:(.literal.setHostname+0x2c): undefined reference to `mdns_service_remove'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/interface.o:(.literal.setHostname+0x30): undefined reference to `mdns_hostname_set'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/interface.o:(.literal.setHostname+0x34): undefined reference to `mdns_instance_name_set'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/interface.o:(.literal.setHostname+0x38): undefined reference to `mdns_service_add'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/interface.o: in function `heapSize':
/home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/interface.c:1155: undefined reference to `mdns_service_remove'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/interface.o: in function `setHostname':
/home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/interface.c:1161: undefined reference to `mdns_service_remove'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/interface.c:1162: undefined reference to `mdns_hostname_set'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/interface.c:1163: undefined reference to `mdns_instance_name_set'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/interface.c:1165: undefined reference to `mdns_service_add'
/home/hmurad/.platformio/packages/toolchain-xtensa@src-5e1dba65eabc364c0001e57aa616c039/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/hmurad/Documents/PlatformIO/Projects/Le-Radio/src/interface.c:1166: undefined reference to `mdns_service_add'
collect2: error: ld returned 1 exit status
*** [.pio/build/esp12e/firmware.elf] Error 1

VScode finds mdns.h library fine, but when i run compilation i see this error.

@freedib
Copy link
Author

freedib commented May 25, 2023

@h1aji Right. I didn't test mDNS :-(
mDNS is not enabled by default. You have to execute "pio run -t menuconfig" to enable it in sdkconfig.
In menuconfig, it is in "Component Config" / "mDNS" / "Enable mDNS".
When mDNS is activated, the side effect is that IPv6 is automatically enabled ("Component Config" / "LWIP" / "Enable IPv6")

@Bastian0302
Copy link

Hallo,

i was searching for a long time and now found this.
But i get an error while installing the packages.

TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType: File "C:\Users\Bastian\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 174: env.SConscript("$BUILD_SCRIPT") File "C:\Users\Bastian\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Script\SConscript.py", line 598: return _SConscript(self.fs, *files, **subst_kw) File "C:\Users\Bastian\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Script\SConscript.py", line 285: exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals) File "C:\Users\Bastian\.platformio\platforms\espressif8266\builder\main.py", line 250: target_elf = env.BuildProgram() File "C:\Users\Bastian\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py", line 242: return self.method(*nargs, **kwargs) File "C:\Users\Bastian\.platformio\penv\lib\site-packages\platformio\builder\tools\piobuild.py", line 60: env.ProcessProgramDeps() File "C:\Users\Bastian\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py", line 242: return self.method(*nargs, **kwargs) File "C:\Users\Bastian\.platformio\penv\lib\site-packages\platformio\builder\tools\piobuild.py", line 120: env.BuildFrameworks(env.get("PIOFRAMEWORK")) File "C:\Users\Bastian\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Util\envs.py", line 242: return self.method(*nargs, **kwargs) File "C:\Users\Bastian\.platformio\penv\lib\site-packages\platformio\builder\tools\piobuild.py", line 331: SConscript(env.GetFrameworkScript(name), exports="env") File "C:\Users\Bastian\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Script\SConscript.py", line 662: return method(*args, **kw) File "C:\Users\Bastian\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Script\SConscript.py", line 598: return _SConscript(self.fs, *files, **subst_kw) File "C:\Users\Bastian\.platformio\packages\tool-scons\scons-local-4.5.2\SCons\Script\SConscript.py", line 285: exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals) File "C:\Users\Bastian\.platformio\platforms\espressif8266\builder\frameworks\esp8266-rtos-sdk.py", line 60: assert os.path.isdir(TOOLCHAIN_DIR) File "C:\Users\Bastian\.platformio\python3\lib\genericpath.py", line 42: st = os.stat(s))

Im working on windows.

Thanks.

@h1aji
Copy link

h1aji commented May 31, 2023

@Bastian0302 what python version are you using?

@Bastian0302
Copy link

Bastian0302 commented Jun 1, 2023

I installed 3.10.11 with the check box „add to path“ but still not working.

Update: I uninstalled Paython, deleted .platformio,and isntalled all new.
But still same error.

Additional Information:
`Tool Manager: Installing git+https://github.com/freedib/toolchain-xtensa-8.4.0-linux-amd64.git @ 8.4.0
Tool Manager: toolchain-xtensa@8.4.0+sha.61d3129 has been installed!
Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini_pro.html
PLATFORM: Espressif 8266 (4.0.1+sha.4979251) > WeMos D1 mini Pro
HARDWARE: ESP8266 80MHz, 80KB RAM, 16MB Flash
PACKAGES:

  • framework-esp8266-rtos-sdk @ 3.4.0+sha.519046b
  • tool-cmake @ 3.16.4
  • tool-esptool @ 1.413.0 (4.13)
  • tool-esptoolpy @ 1.30000.201119 (3.0.0)
  • tool-genbin-esp8266 @ 1.0.0+sha.baddadf
  • tool-ninja @ 1.9.0`

I have no clue where i can start finding the error.

@remuslazar
Copy link

@ivankravets it will be really awesome if this PR could get merged! ESP8266 is still an awesome and cheap device to use. 🙏

@jeecrypt
Copy link

I would like to return to PlatformIO, but the old version of RTOS SDK does not allow me to do this. I'm really looking forward to the update. I want stability.

@milo1000
Copy link

Apparently this project is dead, year passed and nobody cares to merge most important PR.

@cziter15
Copy link

cziter15 commented Apr 9, 2024

@ivankravets is there any chance to get this merged? It might be not so trivial as it links two external dependencies (RTOS sdk repo and tool-genbin), but please at least give it a try.

I'm porting https://github.com/cziter15/ksIotFrameworkLib to espidf, but it would be nice to support esp8266 too.

@tbb98
Copy link

tbb98 commented Apr 21, 2024

@ivankravets @valeros
Is it possible to merge this?
Even into an another branch, if You can't really test it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.