How to copy files onto a 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.
Post Reply
User avatar
sebi
Posts: 48
Joined: Tue Mar 29, 2016 9:36 pm
Location: France

How to copy files onto a nRF52?

Post by sebi » Tue Sep 17, 2019 5:03 am

Dear community,
I am having difficulties copying files onto a nRF52 (using standard tools such as pyboard.py, rshell, ...)
I have never experience such issues with other ports (esp8266, esp32, ...).
Does a special feature needs to be set in the build to successfully copy files?
Error illustration:

Code: Select all

C:\MicroPython\CODE\>python pyboard.py --device COM1 -f cp test.txt :
cp test.txt :test.txt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 1] EPERM
Last edited by sebi on Tue Sep 24, 2019 6:28 pm, edited 1 time in total.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: How to copy files onto a nRF52?

Post by jimmo » Fri Sep 20, 2019 6:12 am

I think I had this issue also on an nrf52840 board that I was adding support for (Particle Xenon) but didn't pay close attention because I was getting other things working. Could be related to uart buffering maybe, or possibly irq priority? You're using the soft define I assume? Which specific board and nrf52?

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

Re: How to copy files onto a nRF52?

Post by sebi » Fri Sep 20, 2019 6:46 am

jimmo wrote:
Fri Sep 20, 2019 6:12 am
Which specific board and nrf52?
Thanks Jim for trying to solve my issue. The board is indeed not standard: it is a MPOW/Desay DS-D6 fitness tracker with a nRF52832 (viewtopic.php?f=12&t=6498#p36981). Enclosed are the board definition files:
mpconfigboard.zip
MPOW/Desay DS-D6 board definition files
(1.64 KiB) Downloaded 234 times
It is the ones designed by @fanoush except the extra space he reserved for the bootloader at the end of the flash that I got rid off (by calling the standard nrf52832_512k_64k.ld file) as I am using pyocd to flash the firmware (I am having UICR=0xFF to boot at sector 0x00) and not a DFU upgrade process. I believe the board is quite standard (except it doesn't have a cristal oscillator as on a few boards only). But indeed some configuration parameters might be missing or altered.
jimmo wrote:
Fri Sep 20, 2019 6:12 am
Could be related to uart buffering maybe, or possibly irq priority? You're using the soft define I assume?
Are those features, #define that need to be enabled in the mpconfigport.h file? (I am not sure I understood correctly what you meant by soft define.) I was unable to activate the buffered stdio (viewtopic.php?f=12&t=6335#p39452) as this resulted in linker errors. Is buffered stdio the same as the uart buffering you are talking of?

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

Re: How to copy files onto a nRF52?

Post by sebi » Sat Sep 21, 2019 6:32 pm

I cleaned up the board definition and attest it gets pretty standard when compared to others':
dsd6.zip
MPOW/Desay DS-D6 board definition files (no DFU)
(1.8 KiB) Downloaded 242 times
Unfortunately I don't have any other nRF board to test if I encounter the same issues copying files using pyboard.py or rshell.
Currently the only solution I have found to copy files onto my board is to use direct REPL commands such as `with open("file.txt", "w") as f: f.write("text\n")`. Thankfully there are some scripts available to automate this process (mpy-utils, mipy, etc).
But `time.sleep()` is missing from the build (time.sleep_ms() exists) impacting some of the automation scripts.
I didn't find a way to turn on MICROPY_PY_SYS_STDFILES and MICROPY_PY_IO_FILEIO in mpconfigport.h without encountering linker errors (even using the standard pca10040 board definition).
I also noticed that `os.ilistdir()` gets missing when turning on MICROPY_VFS (and simultaneously MICROPY_FATFS invoking `make`).
I think those are all reasons contributing to the standard tools failing copying files, aren't they?
You don't encounter such issues with your nRF boards if I understand right?

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

Re: How to copy files onto a nRF52?

Post by sebi » Sat Sep 21, 2019 8:25 pm

Here are the errors obtained after invoking rshell (and pyboard.py):
- with MICROPY_FATFS enabled:

Code: Select all

(MPY) C:\MicroPython\CODE\>rshell -p COM1
Using buffer-size of 32
Connecting to COM1 (buffer-size 32)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ... Traceback (most recent call last):
  File "c:\users\sebi\anaconda3\envs\mpy\lib\site-packages\rshell\main.py", line 1282, in connect
    ip_address = socket.gethostbyname(port)
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\sebi\anaconda3\envs\mpy\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  ...
  File "c:\users\sebi\anaconda3\envs\mpy\lib\site-packages\rshell\main.py", line 1470, in remote
    output = self.pyb.exec_raw_no_follow(func_src)
  File "c:\users\sebi\anaconda3\envs\mpy\lib\site-packages\rshell\pyboard.py", line 250, in exec_raw_no_follow
    raise PyboardError('could not exec command')
rshell.pyboard.PyboardError: could not exec command
And pyboard.py yields the error depicted in the first post of this thread viewtopic.php?f=12&t=6961#p39485.

- MICROPY_FATFS disabled:

Code: Select all

(MPY) C:\MicroPython\CODE\>rshell -p COM1
Using buffer-size of 32
Connecting to COM1 (buffer-size 32)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ... Traceback (most recent call last):
  File "c:\users\sebi\anaconda3\envs\mpy\lib\site-packages\rshell\main.py", line 1282, in connect
    ip_address = socket.gethostbyname(port)
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\sebi\anaconda3\envs\mpy\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  ...
  File "c:\users\sebi\anaconda3\envs\mpy\lib\site-packages\rshell\main.py", line 1371, in __init__
    self.root_dirs = ['/{}/'.format(dir) for dir in self.remote_eval(listdir, '/')]
  File "c:\users\sebi\anaconda3\envs\mpy\lib\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
But pyboard.py works successfully!
Maybe this can give some hints about the problem.

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

Re: How to copy files onto a nRF52?

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

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

Post Reply