def setup(): check_bootsec() print("Performing initial setup") wifi() uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) import esp esp.osdebug(None) #import uos, machine #uos.dupterm(None, 1) # disable REPL on UART(0) import gc from machine import RTC try: if RTC().memory() == b"webrepl": raise import main import settings from homie.utils import disable_ap disable_ap() except Exception: import webrepl from homie.utils import enable_ap enable_ap() webrepl.start(password="******") gc.collect() """) return vfs
def __main__(args): if len(args) < 3: print("Usage:") print("ramdisk <path> count block_size") print("eg. ramdisk /ram0 50 512") print(" mounts 25KB ramdisk to /ram0") return pth = args[2] bsize = 512 cnt = 50 if len(args) > 3: cnt = int(args[3]) if len(args) > 4: bsize = int(args[4]) if bsize * cnt < 512 * 50: print("Min disk size is {}KB".format(512 * 50 / 1024)) print("Entered {}KB".format(bsize * cnt / 1024)) return print("Creating filesystem of {}KB in {}".format(bsize * cnt / 1024, pth)) bdev = RAMDynBlockDev(bsize, cnt) uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, pth) _vfses[pth] = (vfs, bdev)
def setup(): check_bootsec() print("Performing initial setup") uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/flash') uos.chdir('/flash') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) import badge, machine, esp, ugfx badge.init() ugfx.init() esp.rtcmem_write(0,0) esp.rtcmem_write(1,0) if machine.reset_cause() != machine.DEEPSLEEP_RESET: print("cold boot") import splash else: print("wake from sleep") load_me = esp.rtcmem_read_string() if load_me != "": print("starting %s", load_me) esp.rtcmem_write_string("") __import__(load_me) else: import splash """) return vfs
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 machine, esp, os, time, network, socket, gc, webrepl import urllib webrepl.start() gc.collect() sta_if = network.WLAN(network.STA_IF) ap_if = network.WLAN(network.AP_IF) print('connecting to network...') sta_if.active(True) sta_if.connect('LittleNerd', 'theinternet') def uri( uri ): f = urllib.urlopen(uri) f.headers return; """) return vfs
def esp8266_mount(): from machine import Pin, SPI import sdcard import uos spi = SPI(-1, miso=Pin(7), mosi=Pin(8), sck=Pin(6)) sd = sdcard.SDCard(spi, Pin(11)) return uos.VfsFat(sd, "")
def mountflash(self): if self.flash is None: # Not being used return self.flash.begin() # Initialise. vfs = uos.VfsFat(self.flash) # Instantiate FAT filesystem uos.mount(vfs, self.flash.mountpoint) self.mounted = True
def setup(): check_bootsec() print("Performing initial setup") uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') # Make dobby config dir uos.mkdir('/conf') # make lib dir uos.mkdir('/lib') with open("boot.py", "w") as f: f.write("""\ # Print to clear serial on boot print("") print("") # Disable os debugging import esp esp.osdebug(None) """) with open("main.py", "w") as f: f.write("""\ # Import and run loader to check modules import loader # Run loader Loader = loader.Run() # get log queue from loader Log_Queue = Loader.Log_Queue # Delete the Loader and loader to free memory del Loader del loader # Import base system to get wifi up and download modules if needed import base # run base with loader.Run() as arguments, it will return a loader log to be published when connected Base = base.Run(Log_Queue) # delete the log queue del Log_Queue # Run base loop Base.Loop() # If we get to here something went wrong so lets reboot print() print() print() print() print() print("End of loop rebooting - we should not get to here") print() print() print() print() print() """) return vfs
def setup(): check_bootsec() print("Performing initial setup") wifi() uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) #import esp #esp.osdebug(None) import gc #import webrepl #webrepl.start() import network apif = network.WLAN(network.AP_IF) staif = network.WLAN(network.STA_IF) apif.active(False) staif.active(False) gc.collect() """) with open("main.py", "w") as f: f.write("""\ import os import machine import axapp import axreadmfrc522 class Main(object): config = None server = None webroot = "/www" confbox = None app = None gpio = None mqcli = None def __init__(self): super(Main, self).__init__() self.initApp() def initApp(self): self.app = axapp.App() self.config = self.app.getConf() self.app.apifConncet() self.app.staifConnect() def run(self): axreadmfrc522.do_read( self.config) def main(): m = Main() m.run() main() """) return vfs
def connect(host, port): global disk log("Connecting to " + host + ":" + str(port)) disk = Socketdisk(host, port) vfs = uos.VfsFat(disk) uos.mount(vfs, "/__livereload__") uos.chdir("/__livereload__") sys.path.insert(0, "/__livereload__/lib") sys.path.insert(0, "/__livereload__")
def _mount_initrd(num_blocks): try: import uos bdev = RAMBlockDev(512, num_blocks) uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') except: print("error: _mount_initrd")
def setup(): check_bootsec() print("Performing initial setup") 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) """) return vfs
def setup(): from machine import Pin import factory_reset import time check_bootsec() print("Performing initial setup") uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') factory_reset.reset() return vfs
def fstest(format=False): eep = get_eep() if format: uos.VfsFat.mkfs(eep) vfs = uos.VfsFat(eep) try: uos.mount(vfs, '/eeprom') except OSError: # Already mounted pass print('Contents of "/": {}'.format(uos.listdir('/'))) print('Contents of "/eeprom": {}'.format(uos.listdir('/eeprom'))) print(uos.statvfs('/eeprom'))
def fstest(format=False): fram = get_fram() if format: uos.VfsFat.mkfs(fram) vfs = uos.VfsFat(fram) try: uos.mount(vfs, '/fram') except OSError: # Already mounted pass print('Contents of "/": {}'.format(uos.listdir('/'))) print('Contents of "/fram": {}'.format(uos.listdir('/fram'))) print(uos.statvfs('/fram'))
def setup(): check_bootsec() print("Performing initial setup") uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/flash') uos.chdir('/flash') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) import main main.start() """) return vfs
def setup(): check_bootsec() print("Performing initial setup") wifi() uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) import gc gc.collect() """) return vfs
def setup(): check_bootsec() print("Performing initial setup") uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) #import esp #esp.osdebug(None) #import webrepl #webrepl.start() """) return vfs
def setup(): check_bootsec() print("Performing initial setup") uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/flash') uos.chdir('/flash') with open("boot.py", "w") as f: f.write("""\ import network sta_if = network.WLAN(network.STA_IF) sta_if.active(True) sta_if.connect('connax', '1berezka') """) return vfs
def setup(): check_bootsec() print("Performing initial setup") wifi() stop_wifi() uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') with open("boot.py", "w") as f: f.write("""\ import uos, os, machine, gc gc.collect() gc.enable() """) return vfs
def cptest(): fram = get_fram() if 'fram' in uos.listdir('/'): print('Device already mounted.') else: vfs = uos.VfsFat(fram) try: uos.mount(vfs, '/fram') except OSError: print('Fail mounting device. Have you formatted it?') return print('Mounted device.') cp('fram_test.py', '/fram/') cp('fram_i2c.py', '/fram/') print('Contents of "/fram": {}'.format(uos.listdir('/fram'))) print(uos.statvfs('/fram'))
def setup(): check_bootsec() print("Performing initial setup") uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/flash') uos.chdir('/flash') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) # import sdcard # import os # from machine import Pin,SPI # sd = sdcard.SDCard(SPI(sck=Pin(18),mosi=Pin(23),miso=Pin(19)),Pin(5)) # os.mount(sd,'/sd') # os.chdir('/sd') """) return vfs
def setup(): check_bootsec() print("Performing initial setup") uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') # Make dobby config dir uos.mkdir('conf') # make lib dir uos.mkdir('lib') with open("boot.py", "w") as f: f.write("""\ # Print to clear serial on boot print("") print("") import esp # Disable os debugging esp.osdebug(None) # Nothing to see here """) with open("main.py", "w") as f: f.write("""\ # Import base system to get wifi up and download modules if needed import base # run base base.Run() # If we get to here something went wrong so lets reboot print() print() print() print() print() print("End of loop rebooting - we should not get to here") print() print() print() print() print() """) return vfs
def setup(): check_bootsec() print("Performing initial setup") wifi() uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, "/") with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) #import esp #esp.osdebug(None) import uos, machine #uos.dupterm(None, 1) # disable REPL on UART(0) import gc #import webrepl #webrepl.start() gc.collect() """) return vfs
def setup(): check_bootsec() print("Performing initial setup") uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) # Begin makeblock 20171109 by fftust uos.mount(vfs, '/flash') uos.chdir('/flash') uos.mkdir('/flash/flash') uos.mkdir('/flash/lib') # End makeblock 20171109 by fftust uos.chdir('/flash/flash') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) """) with open("main.py", "w") as f: f.write("""\ # This file is executed on every main (including wake-boot from deepsleep) """) return vfs
def _create_disk(self): mnt = "/ramdisk" self.disk = Ramdisk(512, 200) # 500 KiB uos.VfsFat.mkfs(self.disk) vfs = uos.VfsFat(self.disk) uos.mount(vfs, mnt) entries = uos.listdir(self.folder) self.mtime = 0 for entry in entries: path = self.folder + "/" + entry mtime_entry = uos.stat(path)[-1] if self.mtime < mtime_entry: self.mtime = mtime_entry # print(entry, mtime_entry) src = open(path, "r") dest = open(mnt + "/" + entry, "w") dest.write(src.read()) src.close() dest.close() uos.umount(mnt)
def setup(): check_bootsec() print("Performing initial setup...") # wifi() uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) #import esp #esp.osdebug(None) # Start wlan AP with ssid=b"MicroPython-1234", pswd=b"micropythoN" #from inisetup import wifi #wifi(b"MicroPython-1234", b"micropythoN") import gc #import webrepl #webrepl.start() gc.collect() """) return vfs
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 esp #esp.osdebug(None) import gc #import webrepl #webrepl.start() gc.collect() """) # Pythings-related #with open("/version", "w") as f: # f.write('v0.08') return vfs
def setup(): check_bootsec() print("Performing initial setup") wifi() uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) import esp esp.osdebug(None) import uos, machine uos.dupterm(machine.UART(0, 115200), 1) import gc #import webrepl #webrepl.start() gc.collect() # Microhomie setup wizard def setup(): import network from machine import Pin, PWM PWM(Pin(2, Pin.OUT)).duty(900) ap_if = network.WLAN(network.AP_IF) ap_if.active(True) gc.collect() import wizard.app gc.collect() wizard.app.main() if 'main.py' not in uos.listdir(): setup() """) return vfs
def setup(): check_bootsec() print("Performing initial setup") uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/flash') uos.chdir('/flash') with open("boot.py", "w") as f: f.write("""\ # This file is executed on every boot (including wake-boot from deepsleep) #import esp #esp.osdebug(None) import network print('network smartconfig') network.smartconfig() import utime utime.sleep(4) #import webrepl #webrepl.start() import webdav print('webdav start') print(webdav.start()) import os print('check index.py') os.stat('index.py') print('dynamic start index.py') webdav.dynamic().start('index.py') """) return vfs
def setup(): check_bootsec() print("Performing initial setup") wifi() uos.VfsFat.mkfs(bdev) vfs = uos.VfsFat(bdev) uos.mount(vfs, '/') with open("boot.py", "w") as f: f.write("""\ import gc from machine import Pin import time Pin(13, Pin.OUT) p = Pin(0, Pin.IN, Pin.PULL_UP) time.sleep(0.5) if p.value() == 0: import network wlan = network.WLAN(network.STA_IF) wlan.active(True) wlan.active(False) raise OSError("WiFi reset and execution of main.py interrupted.") gc.collect() """) return vfs