-
Notifications
You must be signed in to change notification settings - Fork 242
Adding Embedded Linux platform #1480
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
base: public
Are you sure you want to change the base?
Conversation
I will add this for "why we need this new platform?" in the linemb.md file. Please also comment on new use cases:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks quite good. Please let me know if you have any questions about the comments.
|
||
c_memset(the, 0, sizeof(txMachine)); | ||
the->preparation = preparation; | ||
the->keyArray = preparation->keys; | ||
the->keyCount = (txID)preparation->keyCount + (txID)preparation->creation.initialKeyCount; | ||
the->keyIndex = (txID)preparation->keyCount; | ||
the->nameModulo = preparation->nameModulo; | ||
the->nameTable = preparation->names; | ||
the->symbolModulo = preparation->symbolModulo; | ||
the->symbolTable = preparation->symbols; | ||
|
||
the->stack = &preparation->stack[0]; | ||
the->stackBottom = &preparation->stack[0]; | ||
the->stackTop = &preparation->stack[preparation->stackCount]; | ||
|
||
the->firstHeap = &preparation->heap[0]; | ||
the->freeHeap = &preparation->heap[preparation->heapCount - 1]; | ||
the->aliasCount = (txID)preparation->aliasCount; | ||
|
||
setvbuf(stdout, NULL, _IONBF, 0); | ||
the = fxCloneMachine(&preparation->creation, the, "linemb", NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more-or-less xsPrepareMachine
(implemented in fxPrepareMachine
). If possible, it would be more maintainable to use the xsPrepareMachine
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
const char *gXSAbortStrings[] ICACHE_FLASH_ATTR = { | ||
"debugger", | ||
"memory full", | ||
"stack overflow", | ||
"fatal", | ||
"dead strip", | ||
"unhandled exception", | ||
"not enough keys", | ||
"too much computation", | ||
"unhandled rejection" | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use fxAbortString()
instead of maintaining your own list of abort strings (the function was added very recently)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
void fxAbort(xsMachine *the, int status) | ||
{ | ||
const char *msg = (status <= XS_UNHANDLED_REJECTION_EXIT) ? gXSAbortStrings[status] : "unknown"; | ||
#if 0 // MODDEF_XS_ABORTHOOK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall you had a question about the abort hook. Is this disabled because you weren't able to resolve that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phoddie Actually the abort hook works... But I was having trouble figuring out how to make MODDEF_XS_ABORTHOOK defined... somehow adding this
"defines": {
"xs": {
"abortHook": 1
}
}
does not get MODDEF_XS_ABORTHOOK defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MODDEF_XS_ABORTHOOK
should be defined in mc.defines.h
. It looks like main.c
isn't including that?
#include "mc.defines.h"
static void fatal_error_handler(int signum) { | ||
const char* signame = "UNKNOWN"; | ||
switch(signum) { | ||
case SIGABRT: signame = "SIGABRT"; break; | ||
case SIGFPE: signame = "SIGFPE"; break; | ||
case SIGILL: signame = "SIGILL"; break; | ||
case SIGINT: signame = "SIGINT"; break; | ||
case SIGQUIT: signame = "SIGQUIT"; break; | ||
case SIGSEGV: signame = "SIGSEGV"; break; | ||
case SIGTERM: signame = "SIGTERM"; break; | ||
case SIGBUS: signame = "SIGBUS"; break; | ||
case SIGPIPE: signame = "SIGPIPE"; break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is strsignal()
an option here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
examples/helloworld/manifest.json
Outdated
"platforms": { | ||
"linemb/*": { | ||
"strip": [] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"helloworld", and most applications, shouldn't need a platform specific section of its manifest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I have a question here. After syncing recent code, I'm getting "Aborting with status 4, dead strip" error, unless adding this config to disable stripping. I assume there are some book keeping logic mssing here.
On the other hand, given there should be (relatively) plenty of memory on those linux chips, it might be a good idea to disable stripping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After syncing recent code, I'm getting "Aborting with status 4, dead strip" error, unless adding this config to disable stripping. I assume there are some book keeping logic missing here.
I wonder if that is because you allow for top-level await in the host (which is fine) but no script uses a promise or async/await (for example, in helloworld).
On the other hand, given there should be (relatively) plenty of memory on those linux chips, it might be a good idea to disable stripping?
Your host can certainly make that choice. A project can still enable engine stripping if it wants to. The default for "strip"
is set in manifest_base.json
. I think you can simply override that in your host's manifest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
documentation/devices/linemb.md
Outdated
@@ -0,0 +1,129 @@ | |||
# Using the Moddable SDK with embedded Linux (Raspberry Pi Zero) | |||
This is a demo document to demostration how to bring up an embedded Linux device with the Moddable SDK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"demonstrate" in place of "demostration"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@linfan68 – we were thinking we could include this in our May release if you are able to resolve the comments.. Any chance of that in the coming days? Thanks! |
Hello @linfan68. I am trying with Ubuntu 22.04.4 LTS x86_64 host. I get this error trying to build
|
Sorry I just had a crazy week.... sure I'll try to resolve these comments in the coming days. |
HI @mkellner , where did you see this error? When building moddable tools? |
I've resolved most of the comments. Also fixed an issue that caused 100% cpu... faeec84 I'll test the error handling code a little bit before finalized this PR. Also please give me some pointers on the abortHook issue I mentioned above。 |
No. This was buildhost: Ubuntu 22.04.4 LTS, target: linemb/arm64 building helloworld. |
Found the problem, you need glib for arm64
I'll update the document |
This pull request introduces support for the
linemb
platform, targeting embedded Linux devices such as the Raspberry Pi Zero. The changes include updates to several configuration and source files to ensure compatibility and functionality for this new platform.The original disscussion: Running on ARM Linux boards (Raspberry Pi Zero)
The most important changes are summarized below:
Main Entrance for new platform:
build/devices/linemb/xsProj-glib/main.c
: The main entrance for the new platform. Also added signal handling, timeout management, and stack trace functionality to improve error handling and debugging capabilities on the newlinemb
platform, refer to discussion here: Exception message from JS not showing in log #1474.Build System:
tools/mcconfig/make.linemb.mk
to define the build process for thelinemb
platform, including toolchain configurations and compilation flags.Platform-Specific Headers:
xs/platforms/linemb/xsPlatform_linemb.h
to define platform-specific macros and include necessary headers for thelinemb
platform.Platform Support:
linemb
platform configuration in variousmanifest.json
files to include necessary modules and settings for thelinemb
platform. [1] [2] [3] [4] [5] [6] [7] [8] [9]Documentation:
documentation/devices/linemb.md
to guide users on setting up and using the Moddable SDK with embedded Linux devices. This includes preparation steps, toolchain installation, and sample project build instructions.