Skip to content
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

E.setBootUpCode #740

Closed
gfwilliams opened this issue Nov 27, 2015 · 6 comments
Closed

E.setBootUpCode #740

gfwilliams opened this issue Nov 27, 2015 · 6 comments

Comments

@gfwilliams
Copy link
Member

Discussion here:

http://forum.espruino.com/conversations/275207/

Strangely it didn't seem to make it into a GitHub issue. Would be very easy with the addition of: #738

@gfwilliams
Copy link
Member Author

So currently the code here does:

  • If memory[FLASH_MAGIC_LOCATION]!=FLASH_MAGIC, no code saved - return
  • Check first uint32 of saved code. It tells us how much program data there is
  • Decompress the code from flash into RAM

Ideally, there would be a second uint32 in the saved code that contains the length of a string in flash with code (as text) that would be executed at startup.

If that uint32 existed, at bootup (right before onInit was called) the textual code would be loaded into a memoryarea and executed.

Actually I'll take a quick look at this now...

@nkrkv
Copy link
Contributor

nkrkv commented Mar 30, 2016

Got it. I will think how we can do this.

Is it an existing issue on GitHub (#740?) or should we create new to discuss problems related to the feature?

@gfwilliams
Copy link
Member Author

It's an existing issue, so best to discuss here.

Initially this exists because certain things (like the Espruino PC) would really benefit from having some code that always runs regardless of the state of the interpreter.

But it'll solve your issues on espruino/EspruinoTools#28 too :)

@gfwilliams
Copy link
Member Author

Ok, try the boot_code branch.

You can do:

E.setBootCode("HELLO=42;all_my_js_code_here")

After doing that, Espruino won't actually reset. You'll have to do it with reset() or load().

When you do reset, Espruino will execute all that JS code as if it has just been uploaded.

After that, to reset Espruino to a fresh state you'd need: E.setBootCode("");reset()

Not ideal, but it's a good start. I need to think a bit about the interaction with save() and reset().

gfwilliams added a commit that referenced this issue Mar 31, 2016
…817)

            Add `E.setBootCode` to allow JS scripts to be run without being in RAM (fix #740)
@gfwilliams
Copy link
Member Author

Branch deleted, merged into master.

@nkrkv
Copy link
Contributor

nkrkv commented Mar 31, 2016

Whoa! Works perfectly. Thank you for the feature and for merging it into master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants