Skip to content

Make the startup behavior more explicit #737

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

Closed
deshipu opened this issue Apr 2, 2018 · 1 comment
Closed

Make the startup behavior more explicit #737

deshipu opened this issue Apr 2, 2018 · 1 comment

Comments

@deshipu
Copy link

deshipu commented Apr 2, 2018

Right now the behavior of CircuitPython at startup has a lot of details that are hidden, and have to be learned by reading tutorials, rather than by exploration: what files are run on startup, where to put USB-initializing code, etc. We could make it more visible by putting most of the initialization functions in a boot.py file created from a template on board startup whenever it is missing. Then people can simply look inside to see what is happening, experiment with modifying the contents, and if they break something — delete or rename the file, so that a default can be re-created.

We could also use #184 to allow users to control what file is being run on startup, and possibly also control some options about how it is supposed to be run.

@cefn
Copy link

cefn commented May 21, 2018

I have a use case which may be relevant to this, depending on the breadth of functionality in a boot.py explicitly-coded python supervisor.

If the python-implemented supervisor was explicit in boot.py and oversaw the policy decision of dropping the VM after main.py and giving a fresh VM to the REPL, tweaking boot.py would enable alternative VM management strategies to be employed. Importantly no circuitpython-compatible fork would be needed to achieve this, since it happens in 'userspace' just by tweaking boot.py.

Use case - educators preparing projects

In my use case, I would like to be able to pre-populate a VM with a set of symbols which are immediately available for interactive invocation and investigation (tab-completion) from a newly loaded REPL (without having to explain python imports and without the learner having to type an accurate import before their first line of code).

In the use case, the symbols in this VM can be accessed via wired REPL (e.g. Gnu Screen) or via WebREPL hence presenting whatever python 'vocabulary' is wished by the educator (who is preparing a programmable project wired to some inputs/outputs).

The demo in https://vgkits.org/blog/2018/05/08/introductory-video-tutorial/ indicates the use case as demonstrated through micropython.

Alternate approach

Entering the REPL using an explicit blocking function call made from within the VM (e.g. as a call made within main.py) could be an alternate approach to allow various policies to be achieved. This would allow soft-exiting main.py to continue to be hard-coded as per circuitpython-normal, dropping the VM. It's just that the REPL was explicitly invoked from within the initial VM. For example you could create a main.py tutorial sequence within a continuous VM like...

from fancy import repl, reset
prepare_step_1()
repl(globals())
prepare_step_2()
repl(globals())
prepare_step_3()
repl(globals())
report_progress()
reset()

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

No branches or pull requests

3 participants