Post Reply 
Python script caused prime reboot - beta 2021-4-27
04-28-2021, 09:45 PM
Post: #1
Python script caused prime reboot - beta 2021-4-27
After entering something like this script in main.py
Code:
def mary():
    x={1:11,2:22,3:55}
    y=x.keys()
    for i in range(5):
        print(i, f"{y} i={i}", end=" ")
and running it with
Code:
import main
main.mary()
the G1 Prime rebooted itself! After going back into the Python app I found that the contents of the main.py script was gone. But the worst of it is that I can't run any Python programs anymore because even though main.py is empty, going into numeric view always gives me the following error
Code:
>import main
Traceback (most recent call last)
  File "<stdin>", line 1, in <module>
ImportError: no module named 'main'
Anything I type into main.py is cleared and lost when going from the Python editor into Python numeric mode, and the above error traceback appears.

Interestingly, if you say cancel when asked to re-import, then the contents of main.py are not lost, but the error traceback still occurs.

I tried deleting main.py and it gets recreated but the problem persists. I tried resetting the Python app on the G1 Prime, but that doesn't help either. I'm stuck!
Find all posts by this user
Quote this message in a reply
04-29-2021, 07:50 PM (This post was last modified: 04-29-2021 08:09 PM by froehlic.)
Post: #2
RE: Python script caused prime reboot - beta 2021-4-27
(04-28-2021 09:45 PM)tcab Wrote:  After entering something like this script in main.py
Code:
def mary():
    x={1:11,2:22,3:55}
    y=x.keys()
    for i in range(5):
        print(i, f"{y} i={i}", end=" ")
and running it with
Code:
import main
main.mary()
the G1 Prime rebooted itself! After going back into the Python app I found that the contents of the main.py script was gone. But the worst of it is that I can't run any Python programs anymore because even though main.py is empty, going into numeric view always gives me the following error
Code:
>import main
Traceback (most recent call last)
  File "<stdin>", line 1, in <module>
ImportError: no module named 'main'
Anything I type into main.py is cleared and lost when going from the Python editor into Python numeric mode, and the above error traceback appears.

Interestingly, if you say cancel when asked to re-import, then the contents of main.py are not lost, but the error traceback still occurs.

I tried deleting main.py and it gets recreated but the problem persists. I tried resetting the Python app on the G1 Prime, but that doesn't help either. I'm stuck!

I had exactly the same problem. The only solution: CFO-Reset, -> 4. FLS Utility -> Format C -> Reset and everything is clear but I could enter my Python code until the next error came.
My G1 was stable with the actual FW. But with your code I have also a problem. I get the trace back error and my main.py is empty. Every new code will be cleared by changing to Num Console. But I had no reset. The last days I helped myself in saving Python App to another App and working with this one. As soon as I have this behavior, I delete my new Python App, save the original again and so on.
Find all posts by this user
Quote this message in a reply
04-29-2021, 10:32 PM
Post: #3
RE: Python script caused prime reboot - beta 2021-4-27
(04-29-2021 07:50 PM)froehlic Wrote:  But with your code I have also a problem. I get the trace back error and my main.py is empty. Every new code will be cleared by changing to Num Console. But I had no reset.

So the reformat trick won’t help with the damage that my particular code has made, right?, and the only way out is to make another copy of the Python App and delete the broken app. Unfortunately I’ve already messed up my original Python app and ‘resetting’ the Python app doesn’t help. I wonder if I can get a pure copy of the Python app from somewhere and get it into the calc somehow?

I wonder if re-installing a firmware would help?

P.S. What is CFO Reset? And what does format C affect - the entire user data or just Python user data?
Find all posts by this user
Quote this message in a reply
04-30-2021, 05:26 PM
Post: #4
RE: Python script caused prime reboot - beta 2021-4-27
(04-29-2021 10:32 PM)tcab Wrote:  
(04-29-2021 07:50 PM)froehlic Wrote:  But with your code I have also a problem. I get the trace back error and my main.py is empty. Every new code will be cleared by changing to Num Console. But I had no reset.

So the reformat trick won’t help with the damage that my particular code has made, right?, and the only way out is to make another copy of the Python App and delete the broken app. Unfortunately I’ve already messed up my original Python app and ‘resetting’ the Python app doesn’t help. I wonder if I can get a pure copy of the Python app from somewhere and get it into the calc somehow?

I wonder if re-installing a firmware would help?

P.S. What is CFO Reset? And what does format C affect - the entire user data or just Python user data?

No, your code causes damage. But I think, that's a general problem. So for that you don't need to install the newest FW.
The CFO Reset: Turn your prime off. Press and hold the keys C + F + O (no Alpha needed). Now turn it on, release the On key but still hold CFO and wait until you see the "EA656 Diagnostic" menue. Here you have several test-options and the possibility to format the flash memory (with 4. FLS Utility). This format C: clears all like the format on a Win PC. You will loose all programs, variables, functions, matrices, lists, ... Be sure to have a backup of your work. The FW is resident, you have not to reinstall that. After the format you will reset from the diagnostic menue and the prime starts complete empty with standard apps and the FW you installed last.
Find all posts by this user
Quote this message in a reply
04-30-2021, 10:38 PM
Post: #5
RE: Python script caused prime reboot - beta 2021-4-27
Thanks for the instructions. Since I will want to restore from backup immediately after the format (luckily I do have a backup via the connectivity kit), I’m wondering if just restoring from backup would be enough? I’ll try it and see.
Find all posts by this user
Quote this message in a reply
05-01-2021, 01:46 AM
Post: #6
RE: Python script caused prime reboot - beta 2021-4-27
Restoring from backup (that I made pre-beta firmware) causes my G1 Prime to reboot any time I open the Prime Folder tree via the HP Connectivity kit. So I cannot access any of my files and resources on my G1 Prime anymore (via the PC). Using the calculator normally works ok.

So I formatted the G1, installed the latest firmware (21-04-28), and restored from backup - same problem - Prime reboots itself whenever I access it from the Connectivity kit.

Accessing a cleanly formatted G1 Prime from the Connectivity kit works ok, its only after the backup is restored that this reboot problem happens. I guess I'll have to rebuild my G1 prime from scratch by dragging resources from a virtual prime into a freshly formatted prime? I wonder how much I can salvage this way.

So this apparent bug in the backup/restore situation, together with the corruption of the Python App user space if you use certain Python syntax means that using this beta is much riskier than I thought.
Find all posts by this user
Quote this message in a reply
05-01-2021, 07:58 AM (This post was last modified: 05-01-2021 08:59 AM by Thomas_Sch.)
Post: #7
RE: Python script caused prime reboot - beta 2021-4-27
@tcab:
I'm not sure, but maybe it could be the special behavior of main.py within micropython.
Some filenames in micropython like main.py and boot.py have special meanings during startup.

If you could restore your backup to the Virtual Prime, try to remove or modify the main.py file.

Please have a look at https://forum.micropython.org/viewtopic.php?t=2504
("How to use main.py to deploy my code") and https://forum.micropython.org/viewtopic.php?t=5831

Edit: backup*.zip could be opened e.g. by 7-zip.
Your *.py files are located at subdir &Python.hpappdir\ and could be removed or renamed within 7-zip.
Find all posts by this user
Quote this message in a reply
05-01-2021, 10:14 AM
Post: #8
RE: Python script caused prime reboot - beta 2021-4-27
(05-01-2021 01:46 AM)tcab Wrote:  Restoring from backup (that I made pre-beta firmware) causes my G1 Prime to reboot any time I open the Prime Folder tree via the HP Connectivity kit. So I cannot access any of my files and resources on my G1 Prime anymore (via the PC). Using the calculator normally works ok.

So I formatted the G1, installed the latest firmware (21-04-28), and restored from backup - same problem - Prime reboots itself whenever I access it from the Connectivity kit.

Accessing a cleanly formatted G1 Prime from the Connectivity kit works ok, its only after the backup is restored that this reboot problem happens. I guess I'll have to rebuild my G1 prime from scratch by dragging resources from a virtual prime into a freshly formatted prime? I wonder how much I can salvage this way.

So this apparent bug in the backup/restore situation, together with the corruption of the Python App user space if you use certain Python syntax means that using this beta is much riskier than I thought.

And what is the behaviour without restoring from backup? I also have some defective Backups which I do not recover full. I open the zip file as thomas said and copy my programs via CK step by step. Sometimes there should be a problem with files from the root directory (e.g. settings, calc.hpsettings and so on).
Find all posts by this user
Quote this message in a reply
05-01-2021, 12:27 PM
Post: #9
RE: Python script caused prime reboot - beta 2021-4-27
(05-01-2021 01:46 AM)tcab Wrote:  ... I guess I'll have to rebuild my G1 prime from scratch by dragging resources from a virtual prime into a freshly formatted prime? I wonder how much I can salvage this way.
So this apparent bug in the backup/restore situation, together with the corruption of the Python App user space if you use certain Python syntax means that using this beta is much riskier than I thought.
No, it seems not to be a bug. It's presumably "behavior by design".
According to the special meaning of "main.py" (and boot.py) in micropython you should try to remove your main.py in the backup (open your backup with 7-zip or similar tool, open the python app folder, remove main.py) before you're restoring the backup. Don't use the name main.py again to avoid this problem.
I'm curious to see if this helps.
Find all posts by this user
Quote this message in a reply
05-02-2021, 12:02 AM
Post: #10
RE: Python script caused prime reboot - beta 2021-4-27
(05-01-2021 07:58 AM)Thomas_Sch Wrote:  If you could restore your backup to the Virtual Prime, try to remove or modify the main.py file.

My attempts at restoring from backup are from a backup file made of my G1 Prime prior to installing the 2021 beta firmware with all its Python App functionality - thus the backup does not and could not possibly contain main.py.

Interestingly, there is another active thread at the moment relating to failed Prime backups https://www.hpmuseum.org/forum/thread-16693.html
Find all posts by this user
Quote this message in a reply
05-02-2021, 09:05 PM
Post: #11
RE: Python script caused prime reboot - beta 2021-4-27
(05-02-2021 12:02 AM)tcab Wrote:  
(05-01-2021 07:58 AM)Thomas_Sch Wrote:  If you could restore your backup to the Virtual Prime, try to remove or modify the main.py file.

My attempts at restoring from backup are from a backup file made of my G1 Prime prior to installing the 2021 beta firmware with all its Python App functionality - thus the backup does not and could not possibly contain main.py.

Interestingly, there is another active thread at the moment relating to failed Prime backups https://www.hpmuseum.org/forum/thread-16693.html
I am sorry if my tips are not useful for your problem.

Maybe it would be helpful für Tim & Cyrille, if they get an direct hint via mail (calcbeta@hp.com) regarding the problems with backup / restoring from backup. (It might be costly for them to scan every thread here in the forum.)

See thread from Tim, https://www.hpmuseum.org/forum/thread-16647.html
"While you can post in forums such as this at your discretion, we ask that the primary way of reporting be to send reports to calcbeta@hp.com.
Basically, the goal is avoid disruption or annoyance to other forum participants.
You can pop up a pre-populated email template by clicking the "Report Issue" menu item in the programs themselves. "

Good luck!
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: