Skip to content

nrf: Add flash block device for VFS filesystems. #5472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from

Conversation

glennrub
Copy link
Contributor

Follow up on @aykevl's work on providing a block device for the
nRF device's internal flash.

Updating the pca10056 target to use the block device for
VFS/FATFS.

Enabling MICROPY_PY_ARRAY_SLICE_ASSIGN, MICROPY_PY_SYS_STDFILES
and MICROPY_PY_UBINASCII to work with rshell.

Also updated the flash.c driver and ble_drv.c to support flash
access from the flash block device when SoftDevice is active.

@glennrub
Copy link
Contributor Author

glennrub commented Dec 29, 2019

Quite a few of the questions in the forum and in the issue tracker relates to using rshell and fatfs. I decided to PR the working branch which has FatFS working for pca10056. I'll continue updating the branch a bit further to also add LittleFS hooks. In the meanwhile it can be used as a base to get rshell up running for those that wish for editing files through that tool.

I'm having some issues formatting the FAT partition using native block device functions. (When multipartition is enabled). It looks like f_mkfs throws an ABORT as i do not have an MBR (0xAA55 in offset 510). I do see STM port returns a manually construction MBR (block 0). Is there a way to also allow f_mkfs to construct the MBR in this case, or is there a different way of setting up the MBR?

@glennrub glennrub changed the title WIP: nrf: Add fatfs support to nrf52840. WIP: nrf: Add flash block device for VFS filesystems. Dec 29, 2019
@mzdaniel
Copy link
Contributor

mzdaniel commented Jan 1, 2020

Thank you glennrub for this PR.

When adding MP_QSTR_ilistdir and MICROPY_PY_UERRNO (and of course MICROPY_VFS_VFAT, MICROPY_VFS_LFS1, MICROPY_VFS_LFS2 plus minor changes on moduos.c) all Fat and LittleFS tests are passing (with vfs_fat_ramdisklarge.py (way too large for Particle Xenon boards) and vfs_userfs (uio not available) skipping), which is fantastic.

Using vfat seems to work pretty well, formatting and using the fs

>>> import nrf, os
>>> os.umount('/flash')
>>> os.VfsFat.mkfs(nrf.flashbdev)
>>> os.mount(nrf.flashbdev, '/')
>>> os.mkdir('/lib')
>>> with open('/lib/test.py', 'w') as f:
...     f.write("print('Hello world\\n')")
...
22
>>> print(open('/lib/test.py').read())
print('Hello world\n')

Shouldnt modules under /lib be able to import?

>>> import test
Traceback (most recent call last):
  File "<stdin>", in <module>
ImportError: no module named 'test'

Writing on /test.py will import correctly

>>> os.rename('/lib/test.py', '/test.py')
>>> import test
Hello world

The extended interface needed for littlefs seems to be missing so far, but maybe can be worked out in a future PR? I am happy to help.

>>> os.VfsLfs2.mkfs(nrf.flashbdev)
Traceback (most recent call last):
  File "<stdin>", in <module>
TypeError: function takes 3 positional arguments but 4 were given

In any case thank you again for this great addition (including the ability to use rshell ;) and happy New Year!

@dpgeorge
Copy link
Member

dpgeorge commented Jan 6, 2020

I'm having some issues formatting the FAT partition using native block device functions. (When multipartition is enabled). It looks like f_mkfs throws an ABORT as i do not have an MBR (0xAA55 in offset 510). I do see STM port returns a manually construction MBR (block 0). Is there a way to also allow f_mkfs to construct the MBR in this case, or is there a different way of setting up the MBR?

You're using the FM_SFD flag so it shouldn't need a partition table... I'd just disable multipartition support because it's not really needed (you can partition a block device yourself and construct an independent VfsFat object for each partition).

Also, what is the block size and how many blocks are there? It may be that FATFS cannot format what you give it, eg too small.

@pacmac
Copy link

pacmac commented Jan 11, 2020

OK, I have add this pull to my local repo:

git fetch origin pull/5472/head:NRFFAT
git checkout NRFFAT

but after building I don't seem to see the included PR, do I need to do anything else other than the above to include a PR ?

Do I need to change my make command ??

@pacmac
Copy link

pacmac commented Jan 11, 2020

For my custom board, I added the following to mpconfigboard.h

// STORAGE
#define MICROPY_VFS                   (1)
#define MICROPY_HW_ENABLE_STORAGE     (1)
#define MICROPY_MBFS                  (0)

and my make is:

make -j8 BOARD=holyiot_18010 MICROPY_VFS_VFAT=1 -f /nfs/qnap/dev/uPython/build/ports/nrf/custom.mk

And the build fails:

/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/ccjexAfe.ltrans3.ltrans.o: in function `os_sync.lto_priv.388':
/nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/modules/uos/moduos.c:92: undefined reference to `disk_ioctl'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/ccjexAfe.ltrans2.ltrans.o: in function `factory_reset_filesystem':
/nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/main.c:134: undefined reference to `f_mkfs'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/main.c:141: undefined reference to `f_setlabel'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/main.c:142: undefined reference to `mp_fat_vfs_type'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/ccjexAfe.ltrans2.ltrans.o:(.rodata+0x16e4): undefined reference to `mp_fat_vfs_type'
collect2: error: ld returned 1 exit status
make: *** [Makefile:426: build-holyiot_18010/firmware.elf] Error 1

Similar thing happens with pca10056:

CC build-pca10056-s140/pins_gen.c
LINK build-pca10056-s140/firmware.elf
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/ccTw2LFD.ltrans2.ltrans.o:(.rodata+0xbe0): undefined reference to `mp_fat_vfs_type'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/ccTw2LFD.ltrans3.ltrans.o: in function `os_sync.lto_priv.578':
/nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/modules/uos/moduos.c:92: undefined reference to `disk_ioctl'
collect2: error: ld returned 1 exit status
make: *** [Makefile:425: build-pca10056-s140/firmware.elf] Error 1

Would it be possible to provide some notes on how to implement this PR :-)

@mzdaniel
Copy link
Contributor

Not sure what is the issue. The tests I mentioned above were done introducing the exact same changes you did in mpconfigboard.h into pca10059 and simply make BOARD=pca10059 MICROPY_VFS_FAT=1 as mention in https://github.com/micropython/micropython/tree/master/ports/nrf#enable-micropy_vfs_fat

Hope it helps

@pacmac
Copy link

pacmac commented Jan 11, 2020

Thanks, I tried a fresh clone of micropython, but as soon as I un-comment:

//#define MICROPY_VFS (1)
//#define MICROPY_HW_ENABLE_STORAGE (1)
//#define MICROPY_MBFS (0)

The build fails, when commented the build is successful.

I have done this a few times to be sure, did you also pull in PR5472 or ar you using the master branch ?

@mzdaniel
Copy link
Contributor

I don't understand. I thought your repo was in this state
#5472 (comment)

From there make BOARD=pca10056 MICROPY_VFS_FAT=1 does compile and glennrub said its working there.

@pacmac
Copy link

pacmac commented Jan 11, 2020

@mzdaniel -

don't understand. I thought your repo was in this state

Yes, but I don't know if this is the complete / only command to run to pull in the PR as I have never attempted that before.

If i revert to the master, then the build is successful, however os shows no new FS functions:

MicroPython v1.12-45-gbfbd94401 on 2020-01-11; PCA10056 with NRF52840
Type "help()" for more information.
>>> import os
>>> dir(os)
['__class__', '__name__', 'remove', 'sep', 'dupterm', 'ilistdir', 'listdir', 'stat', 'uname']
>>> 

@pacmac
Copy link

pacmac commented Jan 12, 2020

OK, sunday morning and si I thought I would try this again:

  1. Clone fresh micropython
  2. Apply PR as above.
  3. Add 3 lines to mpconfigboard.h
  4. Add "MICROPY_VFS_FAT=1" to make command

and:

make -j8 BOARD=holyiot_18010 SD=s140 MICROPY_VFS_VFAT=1 -f /nfs/qnap/dev/uPython/build/ports/nrf/custom.mk
CC build-holyiot_18010-s140/pins_gen.c
LINK build-holyiot_18010-s140/firmware.elf
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/ccxqr8jq.ltrans3.ltrans.o: in function `factory_reset_filesystem':
/nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/main.c:134: undefined reference to `f_mkfs'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/main.c:141: undefined reference to `f_setlabel'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/main.c:142: undefined reference to `mp_fat_vfs_type'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/ccxqr8jq.ltrans1.ltrans.o:(.rodata+0x1254): undefined reference to `mp_fat_vfs_type'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/ccxqr8jq.ltrans4.ltrans.o: in function `os_sync.lto_priv.493':
/nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/modules/uos/moduos.c:92: undefined reference to `disk_ioctl'
collect2: error: ld returned 1 exit status

There just has to be some step missing, I have spent 2 days on this and made no progress whatsoever.

Disable the 3 lines in mpconfigboard.h and it builds, enable them and it does not.

How / where can I check that the following are correctly defined:

f_mkfs
f_setlabel
mp_fat_vfs_type
disk_ioctl

As these appear to be the vars / functions that is causing the errors ??

@pacmac
Copy link

pacmac commented Jan 13, 2020

OK, finally found the cause, it was due to a typo in my config but not in my posts here:
MICROPY_VFS_VFAT=1

Which should have been:
MICROPY_VFS_FAT=1

So the build now works and I can access the file system after:

import nrf, os
os.VfsFat.mkfs(nrf.flashbdev)
os.mount(nrf.flashbdev, '/')

But still unable to use rshell on the PCA10056:

Using buffer-size of 32
Connecting to /dev/tty.usbmodem0006835105191 (buffer-size 32)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ... Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/rshell/main.py", line 1282, in connect
    ip_address = socket.gethostbyname(port)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/rshell", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/rshell/command_line.py", line 4, in main
    rshell.main.main()
  File "/usr/local/lib/python3.7/site-packages/rshell/main.py", line 2913, in main
    real_main()
  File "/usr/local/lib/python3.7/site-packages/rshell/main.py", line 2875, in real_main
    connect(args.port, baud=args.baud, wait=args.wait, user=args.user, password=args.password)
  File "/usr/local/lib/python3.7/site-packages/rshell/main.py", line 1288, in connect
    connect_serial(port, baud=baud, wait=wait)
  File "/usr/local/lib/python3.7/site-packages/rshell/main.py", line 1312, in connect_serial
    dev = DeviceSerial(port, baud, wait)
  File "/usr/local/lib/python3.7/site-packages/rshell/main.py", line 1602, in __init__
    Device.__init__(self, pyb)
  File "/usr/local/lib/python3.7/site-packages/rshell/main.py", line 1366, in __init__
    unhexlify_exists = self.remote_eval(test_unhexlify)
  File "/usr/local/lib/python3.7/site-packages/rshell/main.py", line 1490, in remote_eval
    return eval(self.remote(func, *args, **kwargs))
  File "<string>", line 0
    
    ^
SyntaxError: unexpected EOF while parsing

on my custom board, everything works including rshell.

@pacmac
Copy link

pacmac commented Jan 13, 2020

OK, a new finding.

If you set: MICROPY_VFS_FAT=0

Then you get the error I was seeing before:

LINK build-holyiot_18010-s140/firmware.elf
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/cc4cqcql.ltrans3.ltrans.o: in function `factory_reset_filesystem':
/nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/main.c:134: undefined reference to `f_mkfs'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/main.c:141: undefined reference to `f_setlabel'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/main.c:142: undefined reference to `mp_fat_vfs_type'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/cc4cqcql.ltrans1.ltrans.o:(.rodata+0x1268): undefined reference to `mp_fat_vfs_type'
/usr/lib/gcc/arm-none-eabi/7.3.1/../../../arm-none-eabi/bin/ld: /tmp/cc4cqcql.ltrans4.ltrans.o: in function `os_sync.lto_priv.496':
/nfs/qnap/dev/uPython/build/micropython/micropython/ports/nrf/modules/uos/moduos.c:92: undefined reference to `disk_ioctl'
collect2: error: ld returned 1 exit status
make: *** [Makefile:426: build-holyiot_18010-s140/firmware.elf] Error 1

@glennrub
Copy link
Contributor Author

Thanks a lot @mzdaniel and @pacmac for the great feedback.

I've updated the branch with a second commit.
I'll sort out a few more things before I squash/split and amend the branch. I'll give a heads up when i start shuffling the commits around.

@pacmac, i have added support for MICROPY_VFS_FAT=0. Good catch!

Pending work i'm looking at is to allow for MICROPY_VFS_FAT on the side of MICROPY_VFS_LFSx, so that FatFS can be used on SD cards, while internal flash is using LittleFS. Right now, i believe they will fight a bit formatting.

I'm considering that none of the compiled in FS should auto format the flash partition, but only mount it if it is possible. In other words, this should should be an explicit documented action how to format the various VFS file systems.

I'm also looking into splitting the mpconfigport.h into device specific configurations instead of ifdef-ing to much in the common file, meaning that the devices will have a section of default configuration each and one common. As VFS + file system will never fit on nrf51 with SoftDevice i need to set up some rules.

Some stats on RAM/ROM usage collected:

make BOARD=pca10056 LTO=0 - MBFS (MICROPY_VFS=0, MICROPY_HW_ENABLE_STORAGE=0, MICROPY_HW_ENABLE_STORAGE=0)
   text    data     bss     dec     hex filename
 161100      36    2448  163584   27f00 build-pca10056/firmware.elf

make BOARD=pca10056 LTO=0
   text    data     bss     dec     hex filename
 162188      36    2444  164668   2833c build-pca10056/firmware.elf

make BOARD=pca10056 LTO=0 MICROPY_VFS_FAT=1
   text    data     bss     dec     hex filename
 176980      36    2960  179976   2bf08 build-pca10056/firmware.elf

make BOARD=pca10056 LTO=0 MICROPY_VFS_LFS1=1
   text    data     bss     dec     hex filename
 172732      36    2444  175212   2ac6c build-pca10056/firmware.elf

make BOARD=pca10056 LTO=0 MICROPY_VFS_LFS2=1
   text    data     bss     dec     hex filename
 177372      36    2444  179852   2be8c build-pca10056/firmware.elf

make BOARD=pca10056 LTO=0 MICROPY_VFS_FAT=1 MICROPY_VFS_LFS1=1
   text    data     bss     dec     hex filename
 187572      36    2960  190568   2e868 build-pca10056/firmware.elf

make BOARD=pca10056 LTO=0 MICROPY_VFS_FAT=1 MICROPY_VFS_LFS2=1
   text    data     bss     dec     hex filename
 192212      36    2960  195208   2fa88 build-pca10056/firmware.elf

@glennrub
Copy link
Contributor Author

Also, what is the block size and how many blocks are there? It may be that FATFS cannot format what you give it, eg too small.

@dpgeorge 256K flash, 4096 block size (which is also my page size on the nrf52840). I'll postpone this a bit, as it is always working with uos.VfsFat.mkfs(), and with FM_SFD without native functions. I'll remove the native functions from the branch for now and look at this later. And, as i wrote in previous comment, i'm considering to remove the main.c auto-format in general to make it an explicit user action.

@mzdaniel
Copy link
Contributor

Fantastic @glennrub! According to a very quick test, with this PR, littlefs works natively on xenon's flash and rshell with it. I'll do more extensive tests, including migrating a production device to littlefs.

Re splitting mpconfigport.h: +1. This should make the code cleaner and improve reliability.

Regarding VFS block size, 4K for a tiny FS of 256K seems really big. I didn't read littlefs specs (yet), but if a file takes a full block, this means the fs cannot host many files.

@glennrub
Copy link
Contributor Author

I'll sort out a few more things before I squash/split and amend the branch. I'll give a heads up when i start shuffling the commits around.

@mzdaniel , @pacmac, So here is the heads up! :) i'll start shuffling the commits now (squash/split).

@mzdaniel
Copy link
Contributor

Awesome @glennrub! Look forward to test them. BTW, I have a device continuously running on a lipo battery and using littleFS for a few months now with no issues.

@glennrub
Copy link
Contributor Author

Updated the PR with a split of the earlier commits. In the process i also moved out the nrf module that was placed under modules/uos into a separate folder as it does not logically belong in uos. I did not have pyb module as other ports exposing their block device and it did not make sense to put a block device into the board module as it is a SoC feature. So i kept the nrf module adding the block device underneath that one.

All target boards now have LittleFS2 activated (except nrf51 with s110) and 64K file system size as default. This is too small for FAT in order to format it, which i expect no-one will use on the internal flash file system.

Also cherry-picked the commits from #5379 to freeze a manifest containing the file system formatting script.

What's left:

  • Get the new files into codeformat.py. @dpgeorge, how do i do this? should i just add a ports/*/*/*/*.[ch] to get a forth level included (ports/nrf/modules/nrf/*)? So far i manually run codeformat on the files.
  • Fine tune commit messages, unless we want to squash a bit.
  • Swap to use MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE instead of MICROPY_HW_ENABLE_STORAGE as enabler for flash block device. @dpgeorge, I had a hard time figuring out which of these to use, so i picked the shortest one. Was that a wrong decision ?

@glennrub glennrub force-pushed the nrf_blockdev branch 2 times, most recently from 7828207 to 0a678ef Compare July 24, 2020 06:54
@dpgeorge
Copy link
Member

Get the new files into codeformat.py

Just add another entry in PATHS, like ports/nrf/modules/uos/*.[ch]

Swap to use MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE instead of MICROPY_HW_ENABLE_STORAGE

stm32 supports both internal and external flash storage (the latter via an external SPI flash). MICROPY_HW_ENABLE_STORAGE is an internal setting that boards do not configure directly, but rather it gets set if-and-only-if there is either internal or external storage (ie at least one block device defined). MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE is for a board to configure if it wants to disable internal flash storage (which is enabled by default).

It might make sense to follow that logic here, but not 100% sure.

@glennrub
Copy link
Contributor Author

glennrub commented Jul 24, 2020

stm32 supports both internal and external flash storage (the latter via an external SPI flash). MICROPY_HW_ENABLE_STORAGE is an internal setting that boards do not configure directly, but rather it gets set if-and-only-if there is either internal or external storage (ie at least one block device defined).

Is my interpretation of MICROPY_HW_ENABLE_STORAGE correctly, that it is used to enable the pyb.Flash class, and it also acts as a grouping config in order to enable mounting and formatting in main.c if any of the two blockdevs have been selected?

MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE is for a board to configure if it wants to disable internal flash storage (which is enabled by default).

I guess this should be similar in the nrf-port. In addition I'm thinking that it also makes sense to change main.c in the nrf-port to also test against MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE instead of MICROPY_HW_ENABLE_STORAGE for auto mounting and formatting as only the const object from nrf/flashbdev.c is used directly in main.c for mounting, not going through a Flash object (stm32/storage.c).

Adding "nrf" module for port specific modules and objects.
Adding "flashbdev" object exposed through the "nrf" module.
The "flashbdev" expose a block device implementation to
access internal SoC flash.

Thanks to @aykevl aka Ayke van Laethem for the initial
implementation.
Update flash.c to also be compiled in when
MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE is enabled and SoftDevice
is present.

Updating bluetooth/ble_drv.c to forward flash events to flash.c
when MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE is enabled.
Documenting parameters that can be passed to make to enable
a specific file system to included in the build. Also,
documenting the makefile override parameter "FS_SIZE" that
can be used to tune the size of the flash region to use as
internal flash file system.
Disabling MICROPY_FATFS_MULTI_PARTITION configuration.

Also, setting MICROPY_FATFS_MAX_SS to the size of a flash page.
For nrf51 the value 1024 is set. For nrf52/nrf91 the value 4096 is set.
Add posibility to override linker script "_fs_size" from
make by adding the FS_SIZE parameter. The syntax of value
is linker script syntax. For example, the value of 131072
bytes can be written as 128K like this: FS_SIZE=128K.

If not set, default value for "_fs_size" from linker script
will be used.
Enable MICROPY_PY_IO_FILEIO if MICROPY_VFS_FAT, MICROPY_VFS_LFS1
or MICROPY_VFS2 has been enabled.
Enable the following features for all boards except
nrf51 boards with SoftDevice present:

- MICROPY_VFS
- MICROPY_PY_NRF
- MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE

And in case of LFS1 or LFS2:

- MICROPY_HW_BDEV_READBLOCKS_EXT
Updating Makefile to handle FROZEN_MANIFEST.

Updating README.md with some small samples on how to use
freeze manifests.

Adding BOARD_DIR to the Makefile which can be referenced in
boards/<board>/mpconfigboard.mk to include a board specific
manifest.
Adding the helper script _mkfs.py which automatically
formats the file system if nrf.Flash() is located and
a VFS file system has been included in the compilation.

The precedence is; first LFS1, LFS2 then FAT.
Setting default manifest to "modules/manifest.py". This includes
files from the folder "modules/scripts". The manifest default
value is overriden by all nrf51 boards that has SoftDevice
present (SD=s110).

Adding "modules/manifest.py" which is set to freeze the
"modules/scripts/_mkfs.py".
extmod/vfs_lfs.c needs to resolve `mp_hal_time_ns()` in order
to calculate a timestamp from 1970 epoch. A wall clock is not
available in the nrf-port. Hence, implementing the function
needed to resolve compilation linkage error. The function always
return 0.
Enable LittleFS v2 for all targets, except nrf51 targets
when SoftDevice is present.
@icarus75
Copy link

I succeeded in compiling the glennrub:nrf_blockdev branch from scratch. However, enabling MICROPY_PY_IO in mpconfigport.h results in following compilation error:
build-feather52840-s140/py/modio.o:(.rodata.mp_module_io_globals_table+0x14): undefined reference to 'fatfs_type_fileio'
build-feather52840-s140/py/modio.o:(.rodata.mp_module_io_globals_table+0x1c): undefined reference to 'fatfs_type_textio'

Not sure how to fix this though. It seems that both the defines for mp_type_fileio and mp_type_textio in mpconfigport.h need to be adapted.

@mzdaniel
Copy link
Contributor

mzdaniel commented Aug 2, 2021

@glennrub, @dpgeorge. Could it be possible to merge this PR? It used to be in great shape for significant periods of time, but of course plenty of things keep changing underneath. Currently the PR rebased on top of master compiles (after solving trivial conflicts), formats the flash, and writing simple files with open seem to work, but trying to create directories or writiting files with mpremote freezes the microcontroller.

Would it be easier to split the PR at this point? (eg: adding the flash device in itself would be a great incremental addition)

And of course let me know if we need more testing, I have several nrf boards we can use.

Thank you for keeping to push forward Micropython!

@dpgeorge
Copy link
Member

dpgeorge commented Aug 5, 2021

Could it be possible to merge this PR? It used to be in great shape for significant periods of time, but of course plenty of things keep changing underneath.

I've rebased this PR on the latest master and submitted it as #7619. Would be good to get it merged.

@mzdaniel
Copy link
Contributor

mzdaniel commented Aug 5, 2021

Fantastic. I'll add my findings there

@dpgeorge
Copy link
Member

dpgeorge commented Aug 8, 2021

Merged in 3b594f7 through 85f0ce2 (via #7619).

@dpgeorge dpgeorge closed this Aug 8, 2021
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants