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

lua FLASH script #10

Closed
tehn opened this issue Sep 24, 2018 · 5 comments
Closed

lua FLASH script #10

tehn opened this issue Sep 24, 2018 · 5 comments
Assignees
Labels
feature new features yet to be added
Milestone

Comments

@tehn
Copy link
Member

tehn commented Sep 24, 2018

normal EVAL mode is just REPL. takes a string and then evaluates it upon completion.

functions to enable flash writing:

  • erase flash
  • start flash chunk
  • (receive a lot of strings that are not eval'd)
  • stop flash chunk
  • (chunk is then evaluated for errors(loadstring()), then written to flash, then executed if it checks out(pcall())
@tehn tehn added the feature new features yet to be added label Sep 24, 2018
@trentgill trentgill added this to the 1 milestone Sep 24, 2018
@trentgill
Copy link
Collaborator

trentgill commented Dec 2, 2018

from #8
for error checking i was thinking we stream serial to RAM buffer, restart the lua VM, and run loadstring() on the new program. then we run a simple lua program that tests the system is functioning (and not eg. in an infinite loop), which can timeout (resulting in error condition), or succeed, causing the program to be written to flash.

before running loadstring we could run a checksum which the command-line util would send at end of each upload. i believe stm32 has an on-board MD5 (or similar) calculator so this shouldn't be difficult to implement. i'm uncertain how reliable we can anticipate the serial communication to be. a simpler approach would be to have a failed upload simply retry once, and error out after second attempt.

@trentgill trentgill modified the milestone: 1 Dec 24, 2018
@trentgill trentgill self-assigned this Dec 24, 2018
@trentgill
Copy link
Collaborator

this is working now.

  • send the command ^^s to start transmission
  • then send your chunks of lua code.
  • code longer than 64chars should be wrapped in a multi-line block (3 backticks ```) before and after.
  • code longer than 1024chars needs to be sent as separate multi-line blocks due to RAM limitation on the device. can fix in future.
  • send ^^e to finish the transmission. this will load & execute the code. if it passes without error, it will be written to flash.
    NOTE: currently the environment is not restarted at this point.

@tehn
Copy link
Member Author

tehn commented Dec 27, 2018

fantastic!

should i create a doc to gather these little usage notes?

@trentgill
Copy link
Collaborator

trentgill commented Dec 27, 2018 via email

@tehn
Copy link
Member Author

tehn commented Dec 27, 2018

ah, sorry! it's hard to keep track of force commits to master without correlating PR's

when you close an issue you could paste the commit number which would reference the change... but again that's not too important until we have more people working on the code

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

No branches or pull requests

2 participants