Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

What reasons are causing "soft reboot" ?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

What reasons are causing "soft reboot" ?

by FriehoffT on Tue Mar 03, 2020 4:01 am

Hi,
I searched the forum and in the posts there given as the reason for "soft reboot" access to the filesystem.
I assume "writing" access.
In my use case, the code is rarely updated, and still, I get from time to time the message "soft reboot" on the console.
Also after uploading new code, there seems to be another soft reboot short after the first.

I attach a capture of the console, the lines with ~~~ are my comments not console output:

~~~~~~~~~~~~~~ start of capture ~~~~~~~~~~~~
Linux background: ⠃⠕⠕⠅⠀⠗⠂⠙⠻⠀⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀
~~~~~~~~~~~~~~ here I uploaded new code ~~~~~~~~~~~~
Code done running. Waiting for reload.
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py

ItsyBitsy --- libraries loaded
ItsyBitsy --- analogiocode
ItsyBitsy --- done
Ok 1
~~~~~~~~~~~~~~ here I did not upload new code this happens almost immediately after the earlier reboot ~~~~~~~~~~~~
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:

ItsyBitsy --- libraries loaded
ItsyBitsy --- analogiocode
ItsyBitsy --- done
Ok 1
main Loop
bits:11111111111111111111111111111111111111110111111110001111

Linux background: ⠃⠕⠕⠅⠀⠗⠂⠙⠻⠀⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀
~~~~~~~~~~~~~~ end of capture ~~~~~~~~~~~~

Also, the "spurious soft reboot" happens while the code is running.

The difference I see in the capture is, that after the "real upload" of new code, the line:
"Code done running. Waiting for reload."
appears immediately before the line "soft reboot"

So, this leads me to my question: What reasons are causing "soft reboot"?

Would it be possible to give the reason added to the message "soft reboot" like:
- soft reboot (writing access to the file system happened)
- soft reboot (caused by supervisor.reload())
- soft reboot (caused by microcontroller.reset())
- soft reboot (caused by .....)

Thanks for taking a look!

Thomas

PS: are you aware that supervisor.reload() is only working in code and not when entering in REPL ?

FriehoffT
 
Posts: 12
Joined: Wed Sep 11, 2019 7:30 am

Re: What reasons are causing "soft reboot" ?

by dastels on Tue Mar 03, 2020 10:00 am

This is typically due to the Flash Filesystem (i.e. CIRCUITPY) being poked by your computers OS. It's the same feature that will restart the board when you update files stored on it (e.g. copying/saving a new version of code.py).

You can turn the feature off with:
Code: Select all | TOGGLE FULL SIZE
import supervisor
supervisor.disable_autoreload()

and turn it on again with:
Code: Select all | TOGGLE FULL SIZE
import supervisor
supervisor.enable_autoreload()

dastels
 
Posts: 3102
Joined: Tue Oct 20, 2015 3:22 pm

Re: What reasons are causing "soft reboot" ?

by danhalbert on Tue Mar 03, 2020 10:08 am

[Would it be possible to give the reason added to the message "soft reboot" like:
- soft reboot (writing access to the file system happened)
- soft reboot (caused by supervisor.reload())
- soft reboot (caused by microcontroller.reset())
- soft reboot (caused by .....)


That's an interesting idea, though I believe the only two reasons are a filesystem write and an explicit call to `supervisor.reload()`.
`microcontroller.reset()` will cause a hard reboot.

PS: are you aware that supervisor.reload() is only working in code and not when entering in REPL ?
[/quote]
I'll make a note to look at this.

danhalbert
 
Posts: 2073
Joined: Tue Aug 08, 2017 12:37 pm

Re: What reasons are causing "soft reboot" ?

by FriehoffT on Tue Mar 03, 2020 11:35 am

Thank both you for looking and commenting.

It' still puzzles me that after the two "reloads" the console shows different output of the circuitpython runtime:
1. Code done running. Waiting for reload.
soft reboot
2. "only" soft reboot.

and as one can see that the same initial startup messages are showing up in the console log .
So I think before both reload "events" code was running.

When are you issuing the message "Code done running. Waiting for reload." ?

Thomas

FriehoffT
 
Posts: 12
Joined: Wed Sep 11, 2019 7:30 am

Re: What reasons are causing "soft reboot" ?

by dastels on Tue Mar 03, 2020 12:43 pm

FriehoffT wrote:When are you issuing the message "Code done running. Waiting for reload." ?


That gets printed when the code on the board (i.e. code.py or main.py) finishes running. This will be the case for code that doesn't include an infinite loop (e.g. the common while True: loop as the last structure in the code).

dastels
 
Posts: 3102
Joined: Tue Oct 20, 2015 3:22 pm

Re: What reasons are causing "soft reboot" ?

by FriehoffT on Tue Mar 03, 2020 1:13 pm

Sure, this is how I thought it works.
But in the (consecutive) console log above of the code running inside the ItsyBitsy is the same in for the two "soft reboot events".
And you see before the second reboot the same console output by the loaded code.
May it be, that you start reloading before the whole file is saved to the flash disk, so execution starts on only a complete partial python code file?
In my case code.py is 49KB.

How long do you wait after access to the file system until you start reloading?

FriehoffT
 
Posts: 12
Joined: Wed Sep 11, 2019 7:30 am

Re: What reasons are causing "soft reboot" ?

by danhalbert on Tue Mar 03, 2020 1:34 pm

We wait a half a second. What editor are you using to edit the code? Not all editors do a flush when they write. On Linux, if you just `cp` or drag something over, do a `sync` immediately afterwards.

danhalbert
 
Posts: 2073
Joined: Tue Aug 08, 2017 12:37 pm

Re: What reasons are causing "soft reboot" ?

by FriehoffT on Tue Mar 03, 2020 2:42 pm

I develop with Pycharm on Windows and copy single files over with TotalCommander.
If I update all project (with files 10 files and about 100K code) I use a batch file.

FriehoffT
 
Posts: 12
Joined: Wed Sep 11, 2019 7:30 am

Re: What reasons are causing "soft reboot" ?

by danhalbert on Tue Mar 03, 2020 7:45 pm

For PyCharm, turn on "Safe Write". See https://learn.adafruit.com/welcome-to-c ... ve-it-7-16.
Do an "Eject" after copying with Total Commander, and after running your batch file.

(You mentioned Linux in the first post, so I mistakenly assumed you were on Linux.)

danhalbert
 
Posts: 2073
Joined: Tue Aug 08, 2017 12:37 pm

Re: What reasons are causing "soft reboot" ?

by FriehoffT on Wed Mar 04, 2020 3:47 am

Sorry folks for having occuping your time !

I know now what is happening I my project and I can work on a solution...

My original question was: What reasons are causing "soft reboot" ?
And the answer to that I got from the forum and from you was:
- Flash Disk write activities on the board.
Now I see, that this is not the only cause, because as you see in this small console - log snippet:
-------------------------------------------------
Linux foreground: ⠎⠑⠞⠞⠬⠎⠀⠎⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
soft reboot
~~~~~~~ Here "out of the blue" a soft reboot happened!!!!! With Auto-reload is off. !!!!!!!
~~~~~~~
Auto-reload is off.
code.py output:
ItsyBitsy --- libraries loaded
ItsyBitsy --- analogiocode
ItsyBitsy --- done
Ok 1
main Loop
-------------------------------------------------
That "soft reboot" is happening also with "Auto-reload is off."

I figured out, that this is all my fault in code.py because I caught an error and "silently" called supervisor.reload()
except MemoryError as e:
supervisor.reload()

So sorry again for bothering you!
But: In order to save hours of investigations for others, my question/suggestion from some replies above stands:

Would it be possible to give the reason added to the message "soft reboot" like:
- soft reboot (writing access to the file system happened)
- soft reboot (caused by supervisor.reload())
- soft reboot (caused by microcontroller.reset())
- soft reboot (caused by .....)

If the reason for the "soft reboot" would have been given, you and I would have saved time...

Thomas

PS1: Maybe this is also the case for others which were hunting spurious Flash Write activities.
PS2: Maybe I come back to this great forum to ask for help how to solve my "MemoryError" problem.
Which is caused probably by too many string operations! .....

FriehoffT
 
Posts: 12
Joined: Wed Sep 11, 2019 7:30 am

Please be positive and constructive with your questions and comments.