예제 #1
0
    def __init__(self, _debug=True):
        self.debug = _debug
        self.update_file_pages_counter = 0
        self.update_file_page_data = bytearray()

        current_partition = Partition(Partition.RUNNING)
        current_partition_name = current_partition.info()[4]

        self.plot_debug("current partition:" + str(current_partition.info()))

        if not current_partition_name.startswith(
                "ota_"):  # firmware is adapted to OTA ?
            print(
                "memory_esp32: skipping... Partition table not adapted to OTA")
            raise SystemExit

        self.partition = current_partition.get_next_update()
        self.plot_debug("next partition:" + str(self.partition.info()))
예제 #2
0
    def get_current_partition_name(self):
        """
            returns current partition name.

            Args:
                void.
            Returns:
                string with current partition name (ota_0 or ota_1).
        """
        cur = Partition(Partition.RUNNING)
        return cur.info()[4]
import random
from esp32 import Partition
import esp
import uos

filename = "csv_data_file.txt"

# Get some statistics:
print(
    "Available flash space: ",
    esp.flash_size())  # This will give you the total amount of Flash available

partition = Partition(Partition.RUNNING)
print(
    partition.info()
)  # Print out information about the running flash partition on which you can store your files.

file_stats = uos.stat(filename)
print(
    "File size before write: ", file_stats[6]
)  # the item at index 6 of the tupple contains the total bytes in the file.

# This loop will add 10 lines that contain dummy comma-delimited data.
for x in range(10):
    random_temp = random.randint(0, 50)
    random_humi = random.randint(20, 90)
    random_pres = random.randint(900, 1100)  # in hPa

    file = open(filename, "a")  # Append to the end of an existing file
    #new_entry = str(random_temp) + "," + str(random_humi) + "," + str(random_pres) + "\n"  # Create the string that contains the dummy CSV data
예제 #4
0
    pass

# PARTITIONS // Path

import sys
import uos
import gc

bootpart = Partition(Partition.BOOT)
runningpart = Partition(Partition.RUNNING)

print("INFO - Partitions")
print("Boot: {}".format(bootpart))
print("Run: {}".format(runningpart))

part_info = runningpart.info()
part_name = part_info[4]

try:
    uos.mkdir(part_name)
except OSError as e:
    print("Path already exist")
    pass

pyversion = 'None'
try:
    with open("/{}/VERSION".format(part_name), "r") as f:
        pyversion = f.read()
except:
    pass
print("Version hash: {}".format(pyversion.strip()))
예제 #5
0
# Test ESP32 OTA updates, including automatic roll-back.
# Running this test requires firmware with an OTA Partition, such as the GENERIC_OTA "board".
# This test also requires patience as it copies the boot partition into the other OTA slot.

import machine
from esp32 import Partition

# start by checking that the running partition table has OTA partitions, 'cause if
# it doesn't there's nothing we can test
cur = Partition(Partition.RUNNING)
cur_name = cur.info()[4]
if not cur_name.startswith("ota_"):
    print("SKIP")
    raise SystemExit

DEBUG = True


def log(*args):
    if DEBUG:
        print(*args)


# replace boot.py with the test code that will run on each reboot
import uos

try:
    uos.rename("boot.py", "boot-orig.py")
except:
    pass
with open("boot.py", "w") as f:
예제 #6
0
 def part(self):
     runningpart = Partition(Partition.RUNNING)
     part_info = runningpart.info()
     part_name = part_info[4]
     return part_name
예제 #7
0
파일: boot.py 프로젝트: CleberPeter/iOTA
if '_manifest.json' in files:  # have an new manifest ? make upgrade

    _manifest_file = open('_manifest.json', 'r')
    _manifest_str = _manifest_file.read()
    _manifest_file.close()

    try:
        _manifest_object = json.loads(_manifest_str)

        if _manifest_object['type'] == 'bin':

            print('monolithic upgrade identified.')

            _current_partition = Partition(Partition.RUNNING)
            if _manifest_object['ota'] == _current_partition.info(
            )[4]:  # changed ota partition ?

                os.rename("_manifest.json", "manifest.json")
                print('update with success.')
                _updated = True
            else:
                print('failed to update.')
                os.remove('_manifest.json')
        else:

            print('diferential upgrade identified.')

            for file in files:
                if file[0] == '_':  # is an update file (_xxx)
                    os.rename(file, file[1:])  # rename: _xxx -> xxx