khchen / nimpk Goto Github PK
View Code? Open in Web Editor NEWPocketLang binding for Nim
License: MIT License
PocketLang binding for Nim
License: MIT License
I've been interested in creating a language that can be interpreted on embedded systems (esp32) with platformio for use in a larger project, which would provide an api to the user which calls precompiled procs that talk to the hardware. I came across nimpk
which compiles great and works well on PC, but there are some weird memory issues on esp32, causing Guru Meditation
errors when registering libs (backtrace attached bellow).
Is there some solvable problem that would be causing a memory leak or something that would cause the esp not to boot?
Ultimately this may be impossible given the minuscule power of the esp32 to interpret nimpk on its own, and there may be other unforeseen reasons this won't work, but it would be a great tool for embedded programming and super helpful for the community.
PS. Since importing nimpk/src
requires an os, and is necessary to include pocketlang libs into the compile, it has to be reimplemented in platformio for the platformio compiler. By default, pocketlang.h
is not included in the compile without nimpk/src
, so adding {importc, header: "pocketlang.h"}
in nimpk/includes.nim
includes it. It will then throw errors like error: use of enum 'PkVarType' without previous declaration
, which can be circumvented by reordering pocketlang.h
. Also be sure to use an environment with both arduino
and esp-idf
together. This is because it seems as though pocketlang requires lower level functionality from the esp-idf that's hidden by using just arduino, which is then resurfaced with esp-idf.
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..@[email protected]: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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.