ThakeeNathees / pocketlang

A lightweight, fast embeddable scripting language.
https://thakeenathees.github.io/pocketlang/
MIT License
1.51k stars 78 forks source link

Embedded systems #300

Open davidvfx07 opened 3 weeks ago

davidvfx07 commented 3 weeks ago

I've been interested in creating a language that can be interpreted on embedded systems (esp32) with platformio, arduino and esp-idf for use in a larger project. I came across pocketlang and it fits into this project really nicely. However, while I've managed to get it to compile successfully with platformio, there are Guru Meditation errors when registering libs (backtrace attached bellow).

So is this indeed the case, and if so, is there a way to workaround or fix it? If not, where can one be pointed to when considering embedding pocketlang into a project on a microcontroller?

PS. I am interfacing with pocketlang through the language Nim and its flexible FFI features with a Nim module named NimPk. I don't think it should be an issue, but I'll point it out just in case.


Full backtrace:


Backtrace: 0x4200ac8c:0x3fcf3910 0x4200acc7:0x3fcf3930 0x4200acf9:0x3fcf3950 0x420173ed:0x3fcf3980 0x420086d2:0x3fcf39b0 0x4201089c:0x3fcf39d0 0x4200f2dd:0x3fcf39f0 0x4200856a:0x3fcf3a10 0x420050f5:0x3fcf3a50 0x42008109:0x3fcf3a70 0x420082c7:0x3fcf3ac0 0x420082d2:0x3fcf3ae0 0x420082de:0x3fcf3b00 0x4203d510:0x3fcf3b20 0x4037d7d1:0x3fcf3b40

  #0  0x4200ac8c:0x3fcf3910 in moduleGetStringAt at lib/pocketlang/core/value.c:1335
  #1  0x4200acc7:0x3fcf3930 in moduleGetGlobalIndex at lib/pocketlang/core/value.c:1366
  #2  0x4200acf9:0x3fcf3950 in moduleSetGlobal at lib/pocketlang/core/value.c:1347
  #3  0x420173ed:0x3fcf3980 in moduleAddFunctionInternal at lib/pocketlang/core/core.c:967
  #4  0x420086d2:0x3fcf39b0 in pkModuleAddFunction at lib/pocketlang/core/public.c:277
  #5  0x4201089c:0x3fcf39d0 in registerModuleAlgorithm at lib/pocketlang/libs/std_algorithm.c:330
  #6  0x4200f2dd:0x3fcf39f0 in registerLibs at lib/pocketlang/libs/libs.c:34
  #7  0x4200856a:0x3fcf3a10 in pkNewVM at lib/pocketlang/core/public.c:153
  #8  0x420050f5:0x3fcf3a50 in newVm__OOZnimlibZnimpk_u257(PkConfiguration*) at src/nimcache/@m..@snimlib@snimpk.nim.cpp:316
  #9  0x42008109:0x3fcf3a70 in NimMainModule() at src/nimcache/@mmain.nim.cpp:528
  #10 0x420082c7:0x3fcf3ac0 in NimMainInner() at src/nimcache/@mmain.nim.cpp:511
  #11 0x420082d2:0x3fcf3ae0 in NimMain at src/nimcache/@mmain.nim.cpp:522
  #12 0x420082de:0x3fcf3b00 in app_main at src/nimcache/@mmain.nim.cpp:481
  #13 0x4203d510:0x3fcf3b20 in main_task at /Users/user/.platformio/packages/framework-espidf/components/freertos/port/port_common.c:141 (discriminator 2)
  #14 0x4037d7d1:0x3fcf3b40 in vPortTaskWrapper at /Users/user/.platformio/packages/framework-espidf/components/freertos/port/xtensa/port.c:142
davidvfx07 commented 3 weeks ago

There is an issue on the nimpk module repo in case the info there can help, khchen/nimpk#1.

davidvfx07 commented 3 weeks ago

UPDATE. Moved to RP2040 for convenience. I think I'm going to stay here and manually implement the libraries I want from within Nim. The std_lib isn't very important to the project anyway. I am still doing a lot of testing around memory, and will report back with any meaningful discoveries for those interested...