Page 1 of 1

[NUCLEO-L476RG] How to compile main.py and send to board

Posted: Wed Oct 28, 2020 5:40 pm
by jonathan
Maybe I'm missing something simple, but I am having a difficult time figuring out how to compile a custom main.py and flash it to my STM32 NUCLEO-L476RG board.

I have successfully flashed MicroPython onto the board, and can access the board via PicoCom or a similar terminal program, but I do not know how to upload a main.py I wrote on my computer to the board.

Can anyone provide some guidance please?

Re: [NUCLEO-L476RG] How to compile main.py and send to board

Posted: Wed Oct 28, 2020 11:44 pm
by jimmo
jonathan wrote:
Wed Oct 28, 2020 5:40 pm
I have successfully flashed MicroPython onto the board, and can access the board via PicoCom or a similar terminal program, but I do not know how to upload a main.py I wrote on my computer to the board.
MicroPython provides a filesystem on the device. Depending on the board, this may be available as a virtual USB MSC device (i.e. it'll show up as a USB Flash drive on your PC), but on all boards you can access the filesystem via the UART with a tool like pyboard.py or rshell.
e.g. http://docs.micropython.org/en/latest/r ... rd.py.html

Re: [NUCLEO-L476RG] How to compile main.py and send to board

Posted: Thu Oct 29, 2020 3:25 am
by humberto ontiveros
Hi, i am having the same problem wiht a STM32 NUCLEO-L432KC, were you able to solve it wiht pyborad.py? and by the way what IDE do you use for develop yours scripts for this board?

Re: [NUCLEO-L476RG] How to compile main.py and send to board

Posted: Thu Oct 29, 2020 4:08 am
by jimmo
humberto ontiveros wrote:
Thu Oct 29, 2020 3:25 am
Hi, i am having the same problem wiht a STM32 NUCLEO-L432KC, were you able to solve it wiht pyborad.py? and by the way what IDE do you use for develop yours scripts for this board?
Yes, pyboard.py is compatible with any MicroPython board as it does everything via the REPL (which is a core MicroPython feature). There is a successor to pyboard.py in the works (see https://github.com/micropython/micropython/pull/6375) that is based on pyboard.py but adds a "remote" filesystem feature which allows MicroPython to directly access the filesystem of the host PC. This is tremendously useful for development.

You can use any editor or IDE that you like to actually edit the Python code, then use pyboard.py (or rshell) to copy the files to the device. This matches my workflow for other types of programming too. You might also want to investigate an all-in-one MicroPython IDE like Thonny.

Re: [NUCLEO-L476RG] How to compile main.py and send to board

Posted: Thu Oct 29, 2020 4:15 am
by MostlyHarmless
humberto ontiveros wrote:
Thu Oct 29, 2020 3:25 am
Hi, i am having the same problem wiht a STM32 NUCLEO-L432KC, were you able to solve it wiht pyborad.py? and by the way what IDE do you use for develop yours scripts for this board?
Another option to transfer files to boards that have a USB based REPL is ampy.

Re: [NUCLEO-L476RG] How to compile main.py and send to board

Posted: Fri Oct 30, 2020 4:09 am
by humberto ontiveros
i have been trying with ampy but i have no success, every time that i try, appear this error:

C:\Users\humbe\AppData\Roaming\Python\Python39\Scripts>ampy --port COM6 put led.py


Traceback (most recent call last):
File "c:\program files\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\humbe\AppData\Roaming\Python\Python39\Scripts\ampy.exe\__main__.py", line 7, in <module>
File "C:\Users\humbe\AppData\Roaming\Python\Python39\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "C:\Users\humbe\AppData\Roaming\Python\Python39\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\Users\humbe\AppData\Roaming\Python\Python39\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\humbe\AppData\Roaming\Python\Python39\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\humbe\AppData\Roaming\Python\Python39\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\Users\humbe\AppData\Roaming\Python\Python39\site-packages\ampy\cli.py", line 263, in put
board_files.put(remote, infile.read())
File "C:\Users\humbe\AppData\Roaming\Python\Python39\site-packages\ampy\files.py", line 209, in put
self._pyboard.exec_("f = open('{0}', 'wb')".format(filename))
File "C:\Users\humbe\AppData\Roaming\Python\Python39\site-packages\ampy\pyboard.py", line 267, in exec_
raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n File "<stdin>", line 1, in <module>\r\nOSError: [Errno 1] EPERM\r\n')




does someone here know how to solve this problem? or what is the matter with this?, my board is a STM32 NUCLEO-L432KC
i have severals days trying to solve it but i cannot do it

THANKS A LOT!!!

Re: [NUCLEO-L476RG] How to compile main.py and send to board

Posted: Fri Oct 30, 2020 5:13 am
by MostlyHarmless
EPERM means you don't have permission to access something. My guess is that you need to run this as administrator. That is really just a guess as I never use Windows for any of this.


Regards, Jan