Пример #1
0
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)
Пример #2
0
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")
Пример #3
0
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)
Пример #4
0
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("/")
Пример #5
0
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()
Пример #6
0
def toggle_safeboot():
    safeboot = pycom.bootmgr()[2]
    if safeboot == "SafeBoot: False":
        toggle_safeboot_on()
    elif safeboot == "SafeBoot: True":
        toggle_safeboot_off()
Пример #7
0
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")
Пример #8
0
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)
Пример #9
0
    # 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
Пример #10
0
def get():
    fs = pycom.bootmgr()[1]
    print('FS:', fs)
Пример #11
0
def switch_to_other():
    current_name = pycom.bootmgr()[1]
    if current_name == "FAT":
        switch_to_LittleFS()
    else:
        switch_to_FAT()