Loading Files via JTAG

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
marc4444
Posts: 14
Joined: Sat Aug 03, 2019 12:16 pm

Loading Files via JTAG

Post by marc4444 » Sat Dec 21, 2019 1:14 pm

Hi All,

I'm looking to flash a custom build of micropython onto my board via an exposed JTAG connector. The build I have uses an external SPI flash chip and is based closely on the pyboard lite. This is all working fine. Ideally I'd also like to put my python scripts on the board via JTAG or UART if not possible. I don't plan to have a USB connector on the board so can't connect this interface.

Is it possible to put .py files onto the filesystem via JTAG and if so, how is this done? If not how would it be done over UART?

Alternatively I'm not sure if it's possible to include scripts within the micropython image that show up in the filesystem? I'd rather not use frozen scripts as I plan to update these remotely occasionally once the board is deployed.

I also looked at accessing the REPL over UART (as described here https://docs.micropython.org/en/latest/ ... /repl.html) but that requires you to execute commands on the microcontroller to enable the UART. My board would be empty as it would have just been flashed with micropython over JTAG.

Any help is much appreciated, thanks.

chrismas9
Posts: 152
Joined: Wed Jun 25, 2014 10:07 am

Re: Loading Files via JTAG

Post by chrismas9 » Sun Dec 22, 2019 2:40 am

You can add UART REPL in mpconfigport.h. See NUCLEO_F411RE port for an example.

For Linux use rshell to copy scripts to the flash. I use Thonny on Windows. There are discussions on the forum about other IDEs and plugins.

For production you can use JTAG to read out a complete flash image and clone it to each board.

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

Re: Loading Files via JTAG

Post by jimmo » Sun Dec 22, 2019 11:58 pm

There's not an easy way to directly read and write files via JTAG. This is of course technically possible, but I don't think it's practically feasible.

You can however just read and write the _filesystem_ directly. As Chris has suggested, by far the easiest way to do this is to build up the filesystem on a device, then extract the whole image and use that on other devices.

But you mentioned that you have external spiflash, so does that mean that your spiflash is part of the scan chain or do you have a way to program the spiflash via the stm32 via jtag?

The other option is that you can build the filesystem image locally on your PC (perhaps as part of the build process) and deploy it like you would the firmware image. See this thread (starting on about the second page I think) for some more hints on this viewtopic.php?f=16&t=6677

marc4444
Posts: 14
Joined: Sat Aug 03, 2019 12:16 pm

Re: Loading Files via JTAG

Post by marc4444 » Sun Jan 12, 2020 6:46 pm

Thanks for the comments on this. As a temporary method I've just been programming upy onto the board via STLInk and done what christmas9 suggested and configured a UART REPL to start up and program our boot files over UART onto the SPI Flash. Will have a look at reading off a complete image and programming as suggested. I'm also thinking of including them as frozen modules to reduce the RAM requirements but having issues with that (created a separate post as it's a different issue).

Re the question from Jimmo - I'm not entirely sure? I'm assuming that when I flash via STLink it is putting micropython onto the STM32 chip but is there a way for me to check.

Thank you for the help chrismas9 and Jimmo!

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

Re: Loading Files via JTAG

Post by jimmo » Sun Jan 12, 2020 11:04 pm

marc4444 wrote:
Sun Jan 12, 2020 6:46 pm
Re the question from Jimmo - I'm not entirely sure? I'm assuming that when I flash via STLink it is putting micropython onto the STM32 chip but is there a way for me to check.
Yes, the st-link provides an easy way to program the internal flash of the stm32 chip.

So your spiflash probably isn't directly accessible via jtag (you'd know if it was), but you could almost certainly use jtag/swd to make the stm32 program the spiflash. (i'ts jtag...you can do pretty much anything).

Post Reply