Success! Attached is the firmware for running micropython on the nRF52832

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Success! Attached is the firmware for running micropython on the nRF52832

Post by WhiteHare » Thu Oct 04, 2018 4:55 pm

I followed the instructions here: https://github.com/micropython/micropyt ... /ports/nrf

and everything seemed to go fine up until:
make flash

which threw an error:
pi@raspberrypi:/home/david/micropython/ports/nrf $ sudo make flash
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
nrfjprog --program build-pca10040/firmware.hex --sectorerase -f nrf52
make: nrfjprog: Command not found
Makefile:280: recipe for target 'flash' failed
make: *** [flash] Error 127

which is confusing because prfjprog should be in the path:
pi@raspberrypi:/home/david/micropython/ports/nrf $ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/home/pi/Downloads/nrfjprog

What to do?

As an aside, why aren't the .hex files for nRF52832 and nRF52840 posted to github? I don't see the point of having to go through this make procedure.
Last edited by WhiteHare on Fri Oct 05, 2018 2:52 pm, edited 2 times in total.

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: I can't seem to make the .hex file for the nRF52

Post by WhiteHare » Thu Oct 04, 2018 6:24 pm

Answering my own question: I was using a raspberry pi to do the make, but it turns out that the nrfjprog executable doesn't work on ARM: https://devzone.nordicsemi.com/f/nordic ... berry-pi-3 and I guess it never will.

So, I'll try again to make the nRF52832 micropython hex file by loading Debian onto a PC and starting all over again from the beginning with the github instructions.

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: I can't seem to make the .hex file for the nRF52

Post by WhiteHare » Fri Oct 05, 2018 1:50 pm

I made it as far as this:

root@debian9:/home/david/micropython/ports/nrf# sudo make flash
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build-pca10040/genhdr/mpversion.h
CC ../../py/modsys.c
CC ../../extmod/modwebrepl.c
CC ../../lib/utils/pyexec.c
CC modules/uos/moduos.c
LINK build-pca10040/firmware.elf
text data bss dec hex filename
144280 8 1352 145640 238e8 build-pca10040/firmware.elf
arm-none-eabi-objcopy -O ihex build-pca10040/firmware.elf build-pca10040/firmware.hex
nrfjprog --program build-pca10040/firmware.hex --sectorerase -f nrf52
ERROR: There is no debugger connected to the PC.
Makefile:280: recipe for target 'flash' failed
make: *** flash Error 41

This time I'm running Debian 9 Linux inside a VirtualBox VM. I do have an nRF52832 DK connected to the PC via USB, but apparently to no avail.

However, it looks as though maybe a firmware.hex file was made anywy?
-rw-r--r-- 1 root root 405870 Oct 5 08:19 firmware.hex

Maybe this is the micropython firmware? It's large, but it looks like it would fit in the nRF52832's 512K of flash .

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: I can't seem to make the .hex file for the nRF52

Post by WhiteHare » Fri Oct 05, 2018 2:28 pm

Success! I uploaded firmware.hex to the nRF52832 DK, and it's now running micropython. :D :D :D

I confirmed it by opening a putty terminal to the DK at 115200 baud. I am getting the >>> prompt, and it added together 1 + 1, as expected. 8-)

Quite honestly, though, the build process is a needless ritual. Attached is the firmware.hex file so that others do not have to go through this gauntlet. IMHO, this should have been included on github in the first place. Maybe the moderator can post it there, where it belongs?
Attachments
firmware.zip
(146.51 KiB) Downloaded 278 times

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Success! Attached is the firmware for running micropython on the nRF52832

Post by pythoncoder » Mon Oct 08, 2018 6:00 am

I haven't any NRF hardware to test but I suspect that flashing it directly from within a VM may not work.

I was able to produce hex files for various NRF targets by issuing (under Linux):

Code: Select all

make BOARD=pca10031 hex
There were no build errors. The resultant hex file might then need to be copied to a real machine for flashing.

I can't find any obvious problem with the build process. I think the approach you took is the right one: create a Linux VM on a PC and follow the instructions. Just replace flash with hex as the build target.
Peter Hinch
Index to my micropython libraries.

Post Reply