Porting to Nordic Semiconductor nRF52

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.
Terrence
Posts: 13
Joined: Thu Aug 18, 2016 6:40 pm

Re: Porting to Nordic Semiconductor nRF52

Post by Terrence » Fri Jun 30, 2017 9:47 pm

Where is the current GitHub repo for this incredible project?

I see the pull request here:
https://github.com/micropython/micropython/pull/3137

Where should I download it from and is there a tutorial of sorts?

Thank you.

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

Re: Porting to Nordic Semiconductor nRF52

Post by c45713 » Fri Jun 30, 2017 10:17 pm

The code for the PR is hosted at https://github.com/tralamazza/micropython/tree/master

There is a README.md tutorial in the nrf/ folder, which explains how to compile and flash the various targets. Also, to show some basics, some scripts have been added to the nrf/examples.

oliverr
Posts: 5
Joined: Mon May 08, 2017 5:16 am
Location: Melbourne, Australia
Contact:

Re: Porting to Nordic Semiconductor nRF52

Post by oliverr » Fri Jul 07, 2017 5:11 am

Hi again guys,

I currently have an application for the nRF52 port that would greatly benefit from having division, and even more so with having decimals and rounding. I am of the understanding that currently all but the most primitive of math is not included in order to reduce build size. Would it be possible to selectively include some functionality (such as division), and how would one go about doing so?

If I'm mistaken and my divisions shouldn't be throwing "unsupported types for: 'int', 'int' " and my decimals shouldn't be throwing "decimal numbers not supported", then please let me know and I'll try and figure out how I borked my build so badly!

Cheers,
Oliver

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

Re: Porting to Nordic Semiconductor nRF52

Post by c45713 » Mon Jul 17, 2017 11:00 pm

Hi Oliver,

If i understand you correctly, you are looking for two things, division of integers and floating point numbers.

Division of integers are available already now, using the syntax "//". I believe it's called something like floor division or integer division in python3. Let me put up an example:

Code: Select all

>>> MicroPython v1.8.1-2763-g1ac8f67e on 2017-07-18; PCA10040 with NRF52832
Type "help()" for more information.
>>> a = 9
>>> b = 4
>>> a / b
Traceback (most recent call last):
  File "<stdin>", in <module>
TypeError: unsupported types for : 'int', 'int'
>>> a // b
2
The second issue related to floating point number is a bit more tricky. You are right, it's left out to make build size smaller. My simple tests are showing that enabling floating points by default on nrf51 and nrf52 will increase the code about 32k (nrf51) and 23k (nrf52). For now, I have created a PR to add float support for nrf52 in order for you to help you proceed on your project. I'm a bit unsure if this PR is going into master in the end, as it consumes quite a lot of flash. However, it does not stop you from enabling floating points locally using this patch ;-)
https://github.com/tralamazza/micropyth ... 208204586f

Cheers,
Glenn

oliverr
Posts: 5
Joined: Mon May 08, 2017 5:16 am
Location: Melbourne, Australia
Contact:

Re: Porting to Nordic Semiconductor nRF52

Post by oliverr » Tue Jul 18, 2017 12:02 am

Hi Glenn,

Thank you so much for that! I've just pulled down your patch and it's doing exactly what I wanted - much appreciated!

I really need to get more familiar with the insides of Micropython so I can sort this stuff out without calling in reinforcements...but in the meantime, thank your for your support!

Cheers,
Oliver

User avatar
RWLTOK
Posts: 53
Joined: Thu Dec 14, 2017 7:24 pm

NFC Tag, was Re: Porting to Nordic Semiconductor nRF52

Post by RWLTOK » Sat Sep 22, 2018 10:42 pm

Does anyone know if there has been any work in exposing the NFC type 4 tag interface of the nRF528240 within micropython?

Thanks

Rich

Post Reply