The device is a pyboard d, the micropython version is 1.15.
This is the complete boot.py:
Code: Select all
import os, pyb
os.umount('/flash')
p1 = pyb.Flash(start=0, len=512*1024)
p2 = pyb.Flash(start=512*1024)
os.VfsFat.mkfs(p1)
os.VfsLfs2.mkfs(p2)
os.mount(p1, '/flash')
os.mount(p2, '/data')
os.chdir('/flash')
The first 512 KB is configured as FAT32 and the rest as littlefs.
In my main code i have the following lines to mount the data partition:
Code: Select all
data_partition = pyb.Flash(start=512*1024)
os.mount(data_partition, '/data')
Then the code to write a file with the config being a dictionary is:
Code: Select all
def write(config, file):
try:
config_file = open(file, 'w')
config_file.write(json.dumps(config))
config_file.close()
except OSError as e:
logging.error("Failed to write config file: {}".format(e))
There were already 35 files on the flash and i called write() another 100 times. The following code is not the actual code but what it basically does is:
Code: Select all
self.config_file = None
self.config = {}
self.config['id'] = test
for x in range(100):
self.config_file = '/data/' + str(x) # create new file name
write(self.config, self.config_file)