Hi,
I have a barebone custom board based on the nRF52832 SoC which run the latest Micropython REPL successfully. Aside from running simple code using a terminal, it is counterintuitive to keep pasting the same code everytime the module reset. How can I store code in memory for the breakout board I have?
Thanks
[nRF52832] Store python code on chip
Re: [nRF52832] Store python code on chip
MicroPython provides a filesystem backed by the device flash. You can store your code there (and main.py will be executed at startup).
To access the filesystem remotely (i.e. to transfer files) you can do this over the UART (or USB UART) used by the REPL using http://docs.micropython.org/en/latest/r ... rd.py.html
To access the filesystem remotely (i.e. to transfer files) you can do this over the UART (or USB UART) used by the REPL using http://docs.micropython.org/en/latest/r ... rd.py.html
Re: [nRF52832] Store python code on chip
Hi,
I am trying to use the pyboard.py tool with the following line:
I am getting:
usage: pyboard [-h] [--device DEVICE] [-b BAUDRATE] [-u USER] [-p PASSWORD]
[-c COMMAND] [-w WAIT] [--follow]
[files [files ...]]
pyboard: error: unrecognized arguments: -f
Is this how it supposed to be done?
I am trying to use the pyboard.py tool with the following line:
Code: Select all
pyboard --device COM5 -f cp main.py :main.py
usage: pyboard [-h] [--device DEVICE] [-b BAUDRATE] [-u USER] [-p PASSWORD]
[-c COMMAND] [-w WAIT] [--follow]
[files [files ...]]
pyboard: error: unrecognized arguments: -f
Is this how it supposed to be done?
Re: [nRF52832] Store python code on chip
You may have to update pyboard.py, and call pyboard.py instead of pyboard (withouth .py).
Re: [nRF52832] Store python code on chip
I pulled the latest build of the micropython and calling pyboard.py script, the result is still the same:
Forgive my ignorance, what am I missing?
Regards,
Code: Select all
python B:\micropython\tools\pyboard.py --device COM5 -f cp main.py :main.py
usage: pyboard.py [-h] [--device DEVICE] [-b BAUDRATE] [-u USER] [-p PASSWORD]
[-c COMMAND] [-w WAIT] [--follow]
[files [files ...]]
pyboard.py: error: unrecognized arguments: -f
Regards,
Re: [nRF52832] Store python code on chip
I did ask for forgiveness ahead of time, I had the wrong git repo. I re-cloned it and now I am able to store the file in flash.
The file is very simple, it has this code:
When I reset the board, the REPL start without showing me anything as if it didn't execute the main.py. I thought the main.py is automatically read on boot and run, no?
So I checked on the content on the file and I do see my code:
Thanks
The file is very simple, it has this code:
Code: Select all
import os
os.listdir()
So I checked on the content on the file and I do see my code:
Code: Select all
MicroPython v1.12-614-gc2317a3a8-dirty on 2020-07-05; PCA10040 with NRF52832
Type "help()" for more information.
>>>import os
>>>os.listdir()
['main.py']
>>> f = open('main.py')
>>> f.read()
'import os\r\nos.listdir()'
Re: [nRF52832] Store python code on chip
I think the issue is that you'll need
The automatic printing of expressions is a REPL-specific feature (in fact, it's the P in REPL).
Code: Select all
import os
print(os.listdir())
Re: [nRF52832] Store python code on chip
Yes, thank you so much.