"Play with pyboardCN V2" 02 pyboardCN v2 safe mode and restore factory settings[Copy link]
This post was last edited by Isolated Proton on 2018-6-16 20:21 I. Introduction In the last chapter, I explained the environment configuration. This time, let’s talk about what to do when the board is broken. After all, it is still the underlying hardware, and there will be more or less problems in use. This time, let’s talk about this issue. The following questions are all based on the second method of writing scripts last time (virtual disk). Why do we need to explain this issue in particular? ① When the board is connected to a virtual disk, it uses the FAT file system internally. Under this file system, if abnormal operations are performed (such as unplugging the virtual disk without ejecting it), the script may be lost or even the file system may be damaged. In this case, you need to restore the factory settings. ②The board can be connected to the computer in many ways, such as: 1) only connected to the power supply, without any communication with the computer; 2) only connected to the virtual serial port (VCP); 3) connected to the virtual serial port and virtual disk at the same time (VCP+MSC); 4) connected to the virtual serial port and hardware device simulation at the same time (VCP+HID); 5) connected to the virtual disk or hardware device simulation in a customized way At all of the above times, you need to enter the safe mode or restore the factory settings. Let's introduce it below 2. Safe Mode Before introducing the safe mode, let me lay the groundwork for everyone: By default, when the board starts up, it is connected to the computer in the form of a virtual serial port + virtual disk. At this time, you can see that the virtual disk startup file boot.py is like this: # boot.py -- run on boot-up # can run arbitrary Python, but best to keep it minimal import machine import pyb #pyb.main('main.py') # main script to run after this one #pyb.usb_mode('VCP+MSC') # act as a serial and a storage device #pyb.usb_mode('VCP+HID') # act as a serial device and a mouse main script to run after this one #pyb.usb_mode('VCP+MSC') # act as a serial and a storage device #pyb.usb_mode('VCP+HID') # act as a serial device and a mouse[/code] At this time, when you eject the virtual disk and insert it into the computer, you will find that the virtual disk disappears and only the virtual serial port is left. At this time, you are confused. What should I do if I want to solidify the script in the future? Is REPL prompt, that is, online programming, the only way to go? At this time, you need safe mode~~~ To put it bluntly, safe mode is to force the display of the driver disk and give you a mode to modify the startup file The application scenario has been laid out, and it’s time to talk about how to enter safe mode:
Plug in the computer for power (nonsense);
While holding down the SW key (that is, the USR key), press and release the RST key;
At this time you will see: green→orange→orange+green, these three lighting modes appear in a cycle;
Then it’s time to test your hand speed. When you see only the orange light on, release the SW key (that is, the USR key);
At this time, the orange light flashes 4 times quickly and then goes out. At this time, you will find that the virtual disk appears! ! ! You can modify the boot.py file and restore it to its original state~~
3. Restore to factory settings (factory reset) I won’t talk about this. Everyone knows that this is a last-ditch measure before flashing the firmware So, how to restore to factory settings? The method is very similar to the above: 1~3: Same as above; 4: When you see the orange + green lights on, release the SW key (i.e. USR key); 5: At this time, the orange + green lights flash 4 times quickly, then go out, then the red light comes on, the red light goes out, wait for a few seconds, the virtual serial port and virtual disk (and internal files) are reset to the initial state~~~ Fourth, Postscript You may find that safe mode and factory reset correspond to two different light states. Some people may ask, what will happen if you release the SW key (i.e. USR key) when only the green light is on? Answer: Nothing will happen, the board will boot.py's settings to enter the running mode. This time I talked about the necessary knowledge before playing with the board. Maybe you didn't understand it, but you need to know that there are two modes to save bricks. The experiment content I will run later will have this problem. At that time, I will note the link to everyone. This content is originally created by EEWORLD forum user Isolated Proton. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source