-
when Bangle.js wakes up, it jumps straight into an IRQ which might try and access an XIP memory address while flash is asleep.
It could be used only for storage so it works basically as Storage module on top of internal flash. that would give you direct pointers to data and even code. However it may be tricky to implement writing to such storage when XIP is turned on.
my poor server's going to suffer if loads of people start downloading and forcing it to compile the same big project all the time
This could be part of minification so people uploading app to watch get js code with already compiled binary. Or in this case it could be part of non minified app (like this)
So we're saying that just adding -lgcc could be an option here, and doesn't appear to grow code size for 'normal' code that's completely self contained?
Yes, same for
-lm
.
So we're saying that just adding
-lgcc
could be an option here, and doesn't appear to grow code size for 'normal' code that's completely self contained?I have tried enabling XIP, but there are some big issues with it - for instance the flash has to be put to sleep when sleeping but then when Bangle.js wakes up, it jumps straight into an IRQ which might try and access an XIP memory address while flash is asleep.
It's a nightmare - what you can do is enable a second flash filesystem in internal flash that by default JS files go in - I was going to start producing a second build for it as it's a lot faster, but even that seems to have some problems at the moment (I'm not 100% sure why).
Yes, exactly - definitely don't do
E.getAddressOf(new Uint8Array(size), true);
or GC will free the area you just got the pointer to as soon as getAddressOf exits!Yes - although I can't say enough how bad an idea I think trying to dynamically allocate data from C is. Can you not just statically allocate everything you need? In which case it's all handled for you by
E.compiledC
.I just feel like you're trying to do something that this isn't designed for at all. As @fanoush says it was really only designed for the odd function, and even if you did get your project working and release it, my poor server's going to suffer if loads of people start downloading and forcing it to compile the same big project all the time.
I wonder whether really what you need is almost a separate project with a Makefile so you can make it locally, and then when it's done just upload the base64 of the compiled code into the app and link to your repo?
There are definitely things you can do, for instance when starting up you could call
peek32(E.getAddressOf(Math.sin))
and so on from JS, which will get you the address of the underlying functions, which you could then pass into C to do what you need.