07-15-2020, 07:01 PM
(06-03-2020, 09:45 AM)danielt Wrote:[color= var(--text-muted)][color= var(--header-primary)]Lupyuen said to me that unless the developers of mcuboot are able to get your help that Wasp OS wont be able to run on the Mcuboot bootloader that will soon be shipping early edition pinetimes. It would be a severe loss if we lost WaspOS with this release, so i personally hope you would be able to help get it working on there[/color][/color](06-01-2020, 06:53 PM)lupyuen Wrote: Hi @danielt: I'm almost done documenting my wasp-os experiment on Mynewt, please have a look...
https://lupyuen.github.io/pinetime-rust-...icropython
I'm stuck with a multitasking conflict between wasp-os and Mynewt... wasp-os runs the REPL loop forever, scheduling its own tasks. But Mynewt needs to run the Event Loop to handle NimBLE Bluetooth packets.
Any idea which part of wasp-os I should modify to feed the Mynewt Event Loop?
Alternatively I could start another Mynewt task to run wasp-os, but that would consume extra memory (for the stack). Plus extra overheads for task switching. Thank you so much :-)
Sorry for the delay. I'm afraid missed this when I looked at the forum yesterday.
To keep things robust you probably need to deeply integrate this into Micropython rather then the wasp-os code.
I'd consider adding an implementation of MICROPY_VM_HOOK_LOOP to the MyNewt port that handles pending MyNewt events. This allows will dispatch the events from the main VM execution loop and will share the processor regardless of what Python code we are running. Note that this code is a really, really hot path so needs to be written for maximum performance. That usually means a divisor so the hook does not for every virtual opcode, take a loop at ports/esp8266/mpconfigport.h for an example.
After that you'd probably also need to call the MyNewt event loop from mp_hal_stdin_rx_chr() as well since most implementation of micropython just stop dead in that function when they are seeking user input! This code is less performance critical because is mostly runs a human speed however for simplicity I think it would be OK to call MICROPY_VM_HOOK_LOOP here as well.
A simpler alternative that would probably also work is to dispatch MyNewt events from mp_hal_stdin_rx_char(), machine_deepsleep and machine_lightsleep. That would rely on the system calling one of the sleep functions when it want to save power (which wasp-os does).
[color= var(--text-muted)][color= var(--header-primary)]<3 WaspOS[/color][/color]