Skip to content
Snippets Groups Projects
Select Git revision
  • 7e436cb0ebddf1f60c1f39a89182beaee08ea34b
  • master default protected
  • add-utime-unix_time-expansion
  • add-monotonic-time
  • add-digiclk
  • genofire/rockets-state
  • genofire/ble-follow-py
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • genofire/haule-ble-fs-deactive
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
34 results

contextlib.py

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    inisetup.py 1.21 KiB
    import uos
    import network
    from flashbdev import bdev
    
    def wifi():
        import ubinascii
        ap_if = network.WLAN(network.AP_IF)
        essid = b"MicroPython-%s" % ubinascii.hexlify(ap_if.config("mac")[-3:])
        ap_if.config(essid=essid, authmode=network.AUTH_WPA_WPA2_PSK, password=b"micropythoN")
    
    def check_bootsec():
        buf = bytearray(bdev.SEC_SIZE)
        bdev.readblocks(0, buf)
        empty = True
        for b in buf:
            if b != 0xff:
                empty = False
                break
        if empty:
            return True
        fs_corrupted()
    
    def fs_corrupted():
        import time
        while 1:
            print("""\
    FAT filesystem appears to be corrupted. If you had important data there, you
    may want to make a flash snapshot to try to recover it. Otherwise, perform
    factory reprogramming of MicroPython firmware (completely erase flash, followed
    by firmware programming).
    """)
            time.sleep(3)
    
    def setup():
        check_bootsec()
        print("Performing initial setup")
        wifi()
        uos.VfsFat.mkfs(bdev)
        vfs = uos.VfsFat(bdev, "")
        with open("/boot.py", "w") as f:
            f.write("""\
    # This file is executed on every boot (including wake-boot from deepsleep)
    import gc
    #import webrepl
    #webrepl.start()
    gc.collect()
    """)
        return vfs