def toggle_safeboot_off(): safeboot = pycom.bootmgr()[2] if safeboot == "SafeBoot: False": print("Already in normal mode") elif safeboot == "SafeBoot: True": print("Switching to normal mode") pycom.bootmgr(safeboot=False, reset=True)
def toggle_safeboot_on(): safeboot = pycom.bootmgr()[2] if safeboot == "SafeBoot: False": print("Switching to safeboot mode") pycom.bootmgr(safeboot=True, reset=True) elif safeboot == "SafeBoot: True": print("Already in safeboot mode")
def switch_to(name, type): current_name = pycom.bootmgr()[1] if current_name != name: print("Switch from", current_name, "to", name) pycom.bootmgr(fs_type=type) machine.reset() else: print("Nothing to do, already on", name)
import os import pycom def ls(dir): contents = os.listdir(dir) for c in contents: d = dir + "/" + c if dir == "/": d = dir + c try: print(d, "[", len(os.listdir(d)), "]") ls(d) except: print(d) print("fs_type:", pycom.bootmgr()[1]) ls("/")
import pycom import machine fs_type = pycom.bootmgr()[1] print("fs_type=", fs_type) if fs_type == "LittleFS": print("Switch from", fs_type, "to FAT") pycom.bootmgr(fs_type=pycom.FAT) elif fs_type == "FAT": print("Switch from", fs_type, "to LittleFS") pycom.bootmgr(fs_type=pycom.LittleFS) else: raise "Oh no" machine.reset()
def toggle_safeboot(): safeboot = pycom.bootmgr()[2] if safeboot == "SafeBoot: False": toggle_safeboot_on() elif safeboot == "SafeBoot: True": toggle_safeboot_off()
import pycom #print(pycom.bootmgr()) safeboot = pycom.bootmgr()[2] #print(safeboot) if safeboot == "SafeBoot: True": print("Already in safeboot mode") elif safeboot == "SafeBoot: False": print("Switching to safeboot mode") pycom.bootmgr(safeboot=True, reset=True) else: raise Exception("Script error")
import pycom import machine fs_type = pycom.bootmgr()[1] print("fs_type=", fs_type) if fs_type != "FAT": print("Switch from", fs_type, "to FAT") pycom.bootmgr(fs_type=pycom.FAT) machine.reset() else: print("Nothing to do, already on", fs_type)
# from deepsleep elif mwr[0] == machine.ULP_WAKE: print("ULP_WAKE") print("===== os =========================================") print("sysname", os.uname().sysname) # e.g., GPy print("release", os.uname().release) # e.g., 1.20.1.r1 print("release", os.uname().version) print("uname", os.uname()) import pycom print("===== pycom ======================================") try: print("free_heap", pycom.get_free_heap()) # print("bootmgr", pycom.bootmgr()) print("partition", pycom.bootmgr()[0]) print("fs_type", pycom.bootmgr()[1]) print("free", os.getfree('/flash')) print(pycom.bootmgr()[2]) # safeboot print(pycom.bootmgr()[3]) # status print("ota_slot", hex(pycom.ota_slot())) if (pycom.ota_slot() == 0x210000): print("ota_slot is", "'ota_0' in 'new' 8MB layout") elif (pycom.ota_slot() == 0x1A0000): print("ota_slot is", "'ota_0' in 'old' 4MB layout") elif (pycom.ota_slot() == 0x10000): print("ota_slot is", "'Factory'") else: raise Exception("Unkown ota_slot"+ str(pycom.ota_slot())) except: pass
def get(): fs = pycom.bootmgr()[1] print('FS:', fs)
def switch_to_other(): current_name = pycom.bootmgr()[1] if current_name == "FAT": switch_to_LittleFS() else: switch_to_FAT()