Questions about the nRF port

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
User avatar
sebi
Posts: 36
Joined: Tue Mar 29, 2016 9:36 pm
Location: France

Questions about the nRF port

Post by sebi » Fri Sep 27, 2019 4:41 pm

Dear community,

I encountered some issues with the nRF port on a nRF52382 board and would like to submit them to you:

- I was unable to turn on some of the features in mpconfigport.h, such as MICROPY_PY_SYS_STDFILES, MICROPY_PY_MATH_SPECIAL_FUNCTIONS, MICROPY_PY_IO_FILEIO and MICROPY_PY_MACHINE_SPI, as `make` would fail with those features on. Is there a way to enable all mpconfigport.h features successfully?

- I noticed that MICROPY_FATFS couldn't be enabled as open("code.py", "wb") would fail when enabled making it impossible to create files onto the board. How to enable successfully the FAT file system?

Thanks for any of your comments.

c45713
Posts: 51
Joined: Fri Dec 09, 2016 7:09 pm

Re: Questions about the nRF port

Post by c45713 » Sat Oct 05, 2019 7:00 pm

Hi Sebi,

I'm using MICROPY_FATFS very often with the nrf-port together with SD cards, specially if the internal storage of microbitfs is a bit to small for for my usecase, or if i want to have a way to swap out large set of scripts without freezing them.

nrf port sample on mounting hard-soldered SD card:
https://github.com/micropython/micropyt ... mountsd.py

And the SD card driver itself:
https://github.com/micropython/micropyt ... /sdcard.py

I normally copy these to the freeze folder and let them be frozen with a command similar to this:
make BOARD=pca10056 MICROPY_FATFS=1 FROZEN_MPY_DIR=freeze

Hope this was to some help!

Edit:
I figured out when verifying it here, you will also need to add the configuration in your boards/<board>/mpconfigboard.h :

Code: Select all

#define MICROPY_VFS                 (1)

User avatar
sebi
Posts: 36
Joined: Tue Mar 29, 2016 9:36 pm
Location: France

Re: Questions about the nRF port

Post by sebi » Sun Oct 06, 2019 6:33 pm

Dear c45713,
I am talking to Glenn Rub right?

I was thinking of activating the FAT file system on the main flash memory of a nRF52382 board (it is a fitness tracker wristband and there is no possibility to connect an external SD card to it). As I wrote in this issue on GitHub activating the FAT FS results in an "OSError: [Errno 1] EPERM" error when opening a file. Do you understand the reason for this?

User avatar
sebi
Posts: 36
Joined: Tue Mar 29, 2016 9:36 pm
Location: France

Re: Questions about the nRF port

Post by sebi » Wed Oct 09, 2019 10:06 pm

As of today (2019-10-10), it is now possible to activate MICROPY_PY_SYS_STDFILES in mpconfigport.h for the nRF port: see this issue on GitHub and the corresponding commit by @dpgeorge to fix it.

Additionally, MICROPY_PY_MATH_SPECIAL_FUNCTIONS can also be enabled following the recipe presented in the same issue on GitHub.

c45713
Posts: 51
Joined: Fri Dec 09, 2016 7:09 pm

Re: Questions about the nRF port

Post by c45713 » Mon Oct 21, 2019 5:34 pm

Hi Sebi,
I am talking to Glenn Rub right?
Yes =)
How to enable successfully the FAT file system?
It's definitely possible to use FatFS on the internal flash. However, we discovered that FatFS on internal flash had substantial overhead in terms of space of partition/file table and kind of bad utilization on the flash pages.
I'll provide you the link to the issue where we discussed. https://github.com/tralamazza/micropython/issues/96
After testing out the different solutions, we decided mostly on IRC to enable microbitfs as default on all targets.

There might be use cases where FatFS would make sense, like in a USB mass storage device scenario. Another alternative might be to take a look at the LittleFS work that is ongoing, that might be a good alternative to microbitfs. If you are still in need of FatFS for the internal flash after reading through the issue i linked, i'll try to help you bundle Ayke's work so that we get it up again.

User avatar
sebi
Posts: 36
Joined: Tue Mar 29, 2016 9:36 pm
Location: France

Re: Questions about the nRF port

Post by sebi » Mon Oct 21, 2019 5:52 pm

Hi Glenn,
c45713 wrote:
Mon Oct 21, 2019 5:34 pm
There might be use cases where FatFS would make sense, like in a USB mass storage device scenario.
I would like to build a data logger. Are there some limitations with the default microbitFS?
c45713 wrote:
Mon Oct 21, 2019 5:34 pm
Another alternative might be to take a look at the LittleFS work that is ongoing, that might be a good alternative to microbitfs.
This would be a must indeed! Do the other FS do wear leveling as the LittleFS does?

User avatar
rcolistete
Posts: 331
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: Questions about the nRF port

Post by rcolistete » Tue Aug 18, 2020 1:29 am

See this MicroPython GitHub issue #6344 "nRF microbit (nRF51822) issues", for example :
- ports/nrf for microbit with default configuration;
- file system microbitfs is not accessible via ufs or Mu Editor. How to externally acess the internal file system ? With official MicroPython for BBC micro:bit ufs and Mu Editor can access the files;
- Ctrl+d in REPL freezes, as well as machine.soft_reset();
- deepsleep() and lightsleep() don't work. It seems that __WFIand __WFE are not working on microbit/nRF51822;
- unstable I2C scan reading;
- with Bluetooth enable (SD=s110), REPL is not accessible at all.

Any comment about these problems ?
Last edited by rcolistete on Thu Aug 20, 2020 4:51 pm, edited 1 time in total.
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

User avatar
rcolistete
Posts: 331
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: Questions about the nRF port

Post by rcolistete » Wed Aug 19, 2020 10:11 pm

rcolistete wrote:
Tue Aug 18, 2020 1:29 am
- file system microbitfs is not accessible via ufs or Mu Editor. How to externally acess the internal file system ? With official MicroPython for BBC micro:bit ufs and Mu Editor can access the files;
Update : the above issue has a workaround, see my comment in GitHub issue #6344 "nRF microbit (nRF51822) issues" :
basically, by changing 1-2 lines of 'microfs.py' source code, "ufs"/"Mu Editor" work with microbitFS used by MicroPython mainline on nRF (including BBC Micro:bit).
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

User avatar
rcolistete
Posts: 331
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: Questions about the nRF port

Post by rcolistete » Thu Aug 20, 2020 4:52 pm

My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

Post Reply