-
• #27
Yes, understood.
So what I'm going to do is clone the latest repository of Espruino 2v21. And upon this, I'll make the current changes with three conditional definitions, ESP32-IDF3, ESP32-IDF4, and ESP32-C3-IDF4
and I'll upload the changes to my branch... and this way it can be integrated into the original repository.
-
• #28
Thanks! I've actually done a bunch of this myself already - so please hold off until I say I've pushed my changes as we might end up duplicating work.
I vaguely remember this coming up, but IDF 5 has changed a lot of the network handling stuff, so even though I seem to have got a lot of stuff building, there's going to be a big chunk of work there getting that through.
-
• #29
Thanks!
-
• #30
Ok, so I've just pushed my changes to
master
. You may have to addtarget_compile_options(${COMPONENT_TARGET} PUBLIC -DESP_IDF_VERSION_MAJOR=4)
but it's possible it is set by default.... but if you:
- copy in your https://github.com/rgomezwap/EspruinoS3/tree/main/make/esp32idf4 folder
- disable TLS/AES/CRYPTO in
boards/ESP32.py
BOARD=ESP32 make
(to generate the contents ofgen
- Go into
make/esp32idf4
andidf.py build
I think you should be almost there. Because you're not building in BLE stuff yet (I daren't check that!) you'll get errors about
enableBLE
/etc in jswrapper.c - but I just edited jswrapper.c and changed the relevant function names with any old function in the list nearby, and it builds!Not had a chance to try yet - but if you include the relevant BLE stuff and can get that building then we should be almost there - it's just a matter of porting Espruino to use the new mbedtls I think
- copy in your https://github.com/rgomezwap/EspruinoS3/tree/main/make/esp32idf4 folder
-
• #31
Hello, sounds perfect, thank you very much for the work. I see that we can give it a boost.
Right now I am tied up with other projects, but I will make time to contribute.
We are betting on version 5.x directly, which I think is excellent. I worked on 4.x because it wasn't difficult. I will retrieve all the notes from 5.x to remember.
We'll keep notifying about the tests and progress.
-
• #32
Ok, great!
Having looked at it, I think going with 4.x was definitely the right choice - having to change the TCPIP library over looks like a reasonable chunk of work, but it looks like all the changes for 4.x are things that would have to change for 5.x anyway.
I reckon if we can get something building and working with 4.x then moving up to 5.x from there should be a little easier.
-
• #33
There is now the start of an IDF4 build documented at https://github.com/espruino/Espruino/blob/master/targets/esp32/IDF4/README.md
BOARD=ESP32_IDF4 RELEASE=1 make
Currently gets to:
[100%] Linking CXX executable espruino.elf xtensa-esp32-elf/bin/ld: espruino.elf section `.iram0.text' will not fit in region `iram0_0_seg' xtensa-esp32-elf/bin/ld: IRAM0 segment data does not fit. xtensa-esp32-elf/bin/ld: region `iram0_0_seg' overflowed by 9780 bytes
So I think it's a compiler flag about putting consts and stuff in RAM that's probably enabled by default. But at least it gets that far...
-
• #34
Nice, I will check this, because in the ESP32 build with esp-idf 4.4.4 I faced the same issue.
-
• #35
A fresh installation of Espruino complains about
BOARD=ESP32_IDF4 RELEASE=1 make clean BOARD=ESP32_IDF4 RELEASE=1 make CMake Error at /home/markbecker/Espruino/esp-idf/tools/cmake/component.cmake:478 (add_library): Cannot find source file: /home/markbecker/ESPRUINO/gen/jswrapper.c
gen folder contains
markbecker@vmux091:~/ESPRUINO$ ls -lrt gen total 20 -rw-rw-r-- 1 markbecker markbecker 45 May 3 21:33 README -rw-rw-r-- 1 markbecker markbecker 459 May 3 21:42 CURRENT_BOARD.make -rw-rw-r-- 1 markbecker markbecker 3485 May 3 21:42 platform_config.h -rw-rw-r-- 1 markbecker markbecker 1024 May 3 21:42 jspininfo.h -rw-rw-r-- 1 markbecker markbecker 2974 May 3 21:42 jspininfo.c
-
• #37
You can just do
BOARD=ESP32_IDF4 RELEASE=1 make gen/jswrapper.c
and I think it'll be ok.But I just pushed a change which should fix it if you pull now
-
• #38
Just a note to say if you pull now it should actually build for ESP32. I haven't had a chance to try it yet though as I don't have one on me.
Not tried the C3 yet but there will likely be more changes required for that
-
• #39
Yes it does - thanks
now this pop's up
In file included from /home/markbecker/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/sys/reent.h:503, from /home/markbecker/Espruino/esp-idf/components/newlib/platform_include/sys/reent.h:17, from /home/markbecker/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch5-8.4.0/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/string.h:11, from /home/markbecker/Espruino/src/jsutils.h:22, from /home/markbecker/Espruino/src/jslex.h:17, from /home/markbecker/Espruino/src/jslex.c:14: /home/markbecker/Espruino/src/jslex.c: In function 'jslNewStringFromLexer': /home/markbecker/Espruino/src/jslex.c:1364:11: error: 'totalStringLength' undeclared (first use in this function); did you mean 'jsvGetStringLength'? assert((totalStringLength == jsvGetStringLength(var)) || (jsErrorFlags&JSERR_MEMORY) || !jsvStringIteratorHasChar(&it)); ^~~~~~~~~~~~~~~~~ /home/markbecker/Espruino/src/jslex.c:1364:11: note: each undeclared identifier is reported only once for each function it appears in
-
• #40
That's odd - not sure what to suggest. It works for me.
-
• #41
Oh no.... reset environment and have the same result
are you running
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
? -
• #42
I just looked at that code, and it looks like for some reason the NO_ASSERT define is set in your case - I think maybe I was building without RELEASE=1
I just pushed a change - but honestly if this sort of thing happens it should be pretty easy for you to look at the code and get an idea what the issue is.
-
• #43
Yes, now it compiles - thanks.
-
• #44
Hmm, next thing, look's like excluding bluetooth is not happening, what is missing?
markbecker@vmux091:~/Espruino$ make -n echo ================================== Generating platform configs python scripts/build_platform_config.py ESP32_IDF4 gen/platform_config.h -DGIT_COMMIT=5d927491e -DNO_ASSERT -DRELEASE -DBUILDNUMBER=\"157\" -DESP32_IDF4 -DESP_PLATFORM -DESP32=1 -DESP_STACK_SIZE=25000 -DJSVAR_MALLOC -DUSE_FONT_6X8 -DUSE_DEBUGGER -DUSE_TAB_COMPLETE -DUSE_HEATSHRINK -DUSE_FILESYSTEM -DUSE_FLASHFS -DUSE_GRAPHICS -DUSE_NET -DUSE_NETWORK_JS -DUSE_ESP32 -DUSE_TELNET -DBLUETOOTH -DUSE_NEOPIXEL -DESP32 -DESPR_DEFINES_ON_COMMANDLINE -DEMBEDDED echo ================================== Generating pin info python scripts/build_pininfo.py ESP32_IDF4 gen/jspininfo.c gen/jspininfo.h echo ================================== Generating pin info python scripts/build_pininfo.py ESP32_IDF4 gen/jspininfo.c gen/jspininfo.h echo ================================== Generating JS wrappers echo WRAPPERSOURCES = src/jswrap_array.c src/jswrap_arraybuffer.c src/jswrap_dataview.c src/jswrap_date.c src/jswrap_error.c src/jswrap_functions.c src/jswrap_json.c src/jswrap_number.c src/jswrap_object.c src/jswrap_regexp.c src/jswrap_string.c src/jswrap_modules.c src/jswrap_math.c src/jswrap_espruino.c src/jswrap_flash.c src/jswrap_interactive.c src/jswrap_io.c src/jswrap_pin.c src/jswrap_pipe.c src/jswrap_process.c src/jswrap_onewire.c src/jswrap_promise.c src/jswrap_serial.c src/jswrap_storage.c src/jswrap_spi_i2c.c src/jswrap_stepper.c src/jswrap_stream.c src/jswrap_waveform.c libs/compression/jswrap_heatshrink.c libs/filesystem/jswrap_fs.c libs/filesystem/jswrap_file.c libs/graphics/jswrap_graphics.c libs/network/jswrap_net.c libs/network/http/jswrap_http.c libs/network/js/jswrap_jsnetwork.c libs/network/jswrap_wifi.c libs/network/esp32/jswrap_esp32_network.c targets/esp32/jswrap_esp32.c libs/network/telnet/jswrap_telnet.c libs/bluetooth/jswrap_bluetooth.c libs/neopixel/jswrap_neopixel.c echo DEFINES = -DGIT_COMMIT=5d927491e -DNO_ASSERT -DRELEASE -DBUILDNUMBER=\"157\" -DESP32_IDF4 -DESP_PLATFORM -DESP32=1 -DESP_STACK_SIZE=25000 -DJSVAR_MALLOC -DUSE_FONT_6X8 -DUSE_DEBUGGER -DUSE_TAB_COMPLETE -DUSE_HEATSHRINK -DUSE_FILESYSTEM -DUSE_FLASHFS -DUSE_GRAPHICS -DUSE_NET -DUSE_NETWORK_JS -DUSE_ESP32 -DUSE_TELNET -DBLUETOOTH -DUSE_NEOPIXEL -DESP32 -DESPR_DEFINES_ON_COMMANDLINE -DEMBEDDED python scripts/build_jswrapper.py src/jswrap_array.c src/jswrap_arraybuffer.c src/jswrap_dataview.c src/jswrap_date.c src/jswrap_error.c src/jswrap_functions.c src/jswrap_json.c src/jswrap_number.c src/jswrap_object.c src/jswrap_regexp.c src/jswrap_string.c src/jswrap_modules.c src/jswrap_math.c src/jswrap_espruino.c src/jswrap_flash.c src/jswrap_interactive.c src/jswrap_io.c src/jswrap_pin.c src/jswrap_pipe.c src/jswrap_process.c src/jswrap_onewire.c src/jswrap_promise.c src/jswrap_serial.c src/jswrap_storage.c src/jswrap_spi_i2c.c src/jswrap_stepper.c src/jswrap_stream.c src/jswrap_waveform.c libs/compression/jswrap_heatshrink.c libs/filesystem/jswrap_fs.c libs/filesystem/jswrap_file.c libs/graphics/jswrap_graphics.c libs/network/jswrap_net.c libs/network/http/jswrap_http.c libs/network/js/jswrap_jsnetwork.c libs/network/jswrap_wifi.c libs/network/esp32/jswrap_esp32_network.c targets/esp32/jswrap_esp32.c libs/network/telnet/jswrap_telnet.c libs/bluetooth/jswrap_bluetooth.c libs/neopixel/jswrap_neopixel.c -DGIT_COMMIT=5d927491e -DNO_ASSERT -DRELEASE -DBUILDNUMBER=\"157\" -DESP32_IDF4 -DESP_PLATFORM -DESP32=1 -DESP_STACK_SIZE=25000 -DJSVAR_MALLOC -DUSE_FONT_6X8 -DUSE_DEBUGGER -DUSE_TAB_COMPLETE -DUSE_HEATSHRINK -DUSE_FILESYSTEM -DUSE_FLASHFS -DUSE_GRAPHICS -DUSE_NET -DUSE_NETWORK_JS -DUSE_ESP32 -DUSE_TELNET -DBLUETOOTH -DUSE_NEOPIXEL -DESP32 -DESPR_DEFINES_ON_COMMANDLINE -DEMBEDDED -BESP32_IDF4 -Fgen/jswrapper.c cp /home/markbecker/Espruino/targets/esp32/IDF4/sdkconfig bin cp /home/markbecker/Espruino/targets/esp32/IDF4/CMakeLists.txt bin cp /home/markbecker/Espruino/targets/esp32/IDF4/partitions.csv bin cd bin && idf.py build
complains about ble stuff
In file included from /home/markbecker/Espruino/targets/esp32/BLE/esp32_bluetooth_utils.c:16: /home/markbecker/Espruino/targets/esp32/BLE/esp32_bluetooth_utils.h:19:10: fatal error: esp_bt_defs.h: No such file or directory [#include](https://forum.espruino.com/search/?q=%23include) "esp_bt_defs.h" ^~~~~~~~~~~~~~~ compilation terminated.
-
• #45
I realy like the style how you decided to handel the integration of the esp-idf, looks much simpler.
-
• #46
look's like excluding bluetooth is not happening, what is missing?
Sorry, not sure I understand... You had it building? What did you change to break it?
edit: I made some minor tweaks to the partition table and whether the task chooses to yield, and the build for standard ESP32 now appears to work. Wifi even works!
-
• #47
Just so you know, there's still something a bit odd. AFAIK you should be able to do
while(1);
and then Ctrl-C out of it.It seems that for some reason IDF4 isn't preempting the
espruinoTask
task foruartTask
when UART data arrives, despite theuartTask
having a higher priority. I think it is only stepping in when theespruinotask
callsvTaskDelay
to wait (which I had to add so the watchdog didn't freak out). -
• #48
Ok, lets start from scratch
git clone https://github.com/espruino/Espruino.git EspruinoIDF4 cd EspruinoIDF4 scripts/provision.sh ESP32_IDF4 BOARD=ESP32_IDF4 RELEASE=1 make clean BOARD=ESP32_IDF4 RELEASE=1 make
It works and I can see you already added more stuff - many thanks!
-
• #49
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:6652 ho 0 tail 12 room 4 load:0x40078000,len:15052 load:0x40080400,len:3836 entry 0x4008069c ;32mI (28) boot: ESP-IDF v4.4.7 2nd stage bootloaderm ;32mI (29) boot: compile time 12:56:57m ;32mI (29) boot: Multicore bootloaderm ;32mI (32) boot: chip revision: v1.0m ;32mI (36) boot.esp32: SPI Speed : 40MHzm ;32mI (40) boot.esp32: SPI Mode : DIOm ;32mI (45) boot.esp32: SPI Flash Size : 4MBm ;32mI (49) boot: Enabling RNG early entropy source...m ;32mI (55) boot: Partition Table:m ;32mI (58) boot: ## Label Usage Type ST Offset Lengthm ;32mI (66) boot: 0 nvs WiFi data 01 02 00009000 00006000m ;32mI (73) boot: 1 phy_init RF data 01 01 0000f000 00001000m ;32mI (81) boot: 2 factory factory app 00 00 00010000 001f4000m ;32mI (88) boot: 3 flash Unknown data 01 40 00310000 00010000m ;32mI (95) boot: 4 js_code Unknown data 01 06 00320000 00040000m ;32mI (103) boot: 5 storage Unknown data 01 06 00360000 000a0000m ;32mI (111) boot: End of partition tablem ;32mI (115) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=3a4a4h (238756) mapm ;32mI (210) esp_image: segment 1: paddr=0004a4cc vaddr=3ff80063 size=00008h ( 8) loadm ;32mI (210) esp_image: segment 2: paddr=0004a4dc vaddr=3ffbdb60 size=05334h ( 21300) loadm ;32mI (224) esp_image: segment 3: paddr=0004f818 vaddr=40080000 size=00800h ( 2048) loadm ;32mI (225) esp_image: segment 4: paddr=00050020 vaddr=400d0020 size=121c98h (1186968) mapm ;32mI (662) esp_image: segment 5: paddr=00171cc0 vaddr=40080800 size=1aa3ch (109116) loadm ;32mI (707) esp_image: segment 6: paddr=0018c704 vaddr=400c0000 size=00064h ( 100) loadm ;32mI (721) boot: Loaded app from partition at offset 0x10000m ;32mI (721) boot: Disabling RNG early entropy source...m ;32mI (732) cpu_start: Multicore appm ;32mI (733) cpu_start: Pro cpu up.m ;32mI (733) cpu_start: Starting app cpu, entry point is 0x400815a0m ;32mI (0) cpu_start: App cpu up.m ;32mI (753) cpu_start: Pro cpu start user codem ;32mI (753) cpu_start: cpu freq: 160000000m ;32mI (753) cpu_start: Application information:m ;32mI (757) cpu_start: Project name: espruinom ;32mI (762) cpu_start: App version: RELEASE_2V20-240-g65b4497c1m ;32mI (769) cpu_start: Compile time: May 9 2024 12:56:32m ;32mI (775) cpu_start: ELF file SHA256: 29a6c701...m ;32mI (780) cpu_start: ESP-IDF: v4.4.7m ;32mI (785) cpu_start: Min chip rev: v0.0m ;32mI (790) cpu_start: Max chip rev: v3.99 m ;32mI (795) cpu_start: Chip rev: v1.0m ;32mI (800) heap_init: Initializing. RAM available for dynamic allocation:m ;32mI (807) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAMm ;32mI (813) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAMm ;32mI (819) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAMm ;32mI (825) heap_init: At 3FFCEBB0 len 00011450 (69 KiB): DRAMm ;32mI (831) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAMm ;32mI (838) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAMm ;32mI (844) heap_init: At 4009B23C len 00004DC4 (19 KiB): IRAMm ;32mI (852) spi_flash: detected chip: genericm ;32mI (855) spi_flash: flash io: diom ;32mI (860) cpu_start: Starting scheduler on PRO CPU.m ;32mI (0) cpu_start: Starting scheduler on APP CPU.m WARNING: Bluetooth is disabled per ESP32.enableBLE(false) ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v21.158 (c) 2024 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate >;31mE (6187) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:m ;31mE (6187) task_wdt: - IDLE0 (CPU 0)m ;31mE (6187) task_wdt: Tasks currently running:m ;31mE (6187) task_wdt: CPU 0: espruinoTaskm ;31mE (6187) task_wdt: CPU 1: IDLE1m ;31mE (6187) task_wdt: Print CPU 0 (current core) backtracem
-
• #50
You sure you tried the latest? That's what I got before but then I made a few more tweaks
There's now an ESP32C3_IDF4.py board file - it actually builds and gets to:
I (538) cpu_start: Starting scheduler.
but no further than that currently. But I'm not going to be able to get any more done on this for a while
Ok, great! Thanks for your work on the repo! I believe you can change your username just by clicking
Edit Profile
in top right?Before I saw this post, I just did a diff between your code and Espruino 2v16 and got the diff attached, which seems pretty nice - as you say if you can use ifdefs like that to handle the different boards it'll be great.
It would be really handy for us if you could try and apply your work on top of the existing Espruino Github repo though - and then it's very easy for us to pull changes upstream. When you start by just copying some of the files in it gets a lot more difficult to both see and transfer any changes -as well as for you to pull in any changes from new versions of Espruino.
If you can get the original repo built with your
CMakeLists.txt
then I'm very happy to try and modify the espruino Makefile such that it will auto-generate aCMakeLists.txt
that basically matches, and we could have a working solution quite quick.If we're going to change everything around, I'd really like to move to IDF 5.2.1 and not just 4.4.7 though. I'm interested in the C2 (ESP8684), and that wouldn't be supported by IDF 4.
1 Attachment