Copying a config file onto the Micro:Bit

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
User avatar
tim1mw
Posts: 2
Joined: Sat Apr 29, 2017 5:42 pm
Location: Birmingham, UK
Contact:

Copying a config file onto the Micro:Bit

Post by tim1mw » Sat Apr 29, 2017 6:01 pm

I've hunted everywhere for the answer to this question, but I've drawn a complete blank in my searches. How do I copy files in and out of the persistent storage on the Micro:Bit? I've successfully read and written files using the MicroPython code running on the Micro:Bit, but I'm at a loss as to how I might copy such a file on or off the Micro:Bit.

For my initial project, I would like to be able get the Micro:Bit to read a few simple parameters out of a config file held in the persistent storage, but it would also be nice at some point in the future to be able to write logs files to the storage and the copy them out for analysis.

I've tried copying the config files across with the .hex file when the Micro:Bit is flashed, but the files seem to vanish into thin air and files which are created by the Micropython code never show up, so I'm assuming that the storage device which I connect to when I plug the micro:bit into my computer has nothing to do with the persistent storage and only handles the flashing process. Ideally I would like to be able to mount the persistent storage onto my Linux desktop so I can copy files on and off easily, but I'll settle for any simple tool which gives access.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Copying a config file onto the Micro:Bit

Post by deshipu » Sat Apr 29, 2017 7:07 pm

You can either use the GUI in the "Mu" editor (http://codewith.mu) or use the command-line tool called "microfs" (https://github.com/ntoll/microfs).

User avatar
tim1mw
Posts: 2
Joined: Sat Apr 29, 2017 5:42 pm
Location: Birmingham, UK
Contact:

Re: Copying a config file onto the Micro:Bit

Post by tim1mw » Sat Apr 29, 2017 11:40 pm

Thanks, I've got Mu installed and just gave the files function a go, that seems to do the trick, although it took me a while realise that I have to put the file I want to transfer into ~/mu_code and then drag+drop it across. Clicking the files button and getting two blank panes gave me the initial impression it wasn't working.

"ufs" came up in some of my searches, but the repository link for microfs didn't and the pages I did see gave the impression it was low-level code which was involved in flashing the hex files, rather than for file management.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Copying a config file onto the Micro:Bit

Post by deshipu » Sun Apr 30, 2017 7:12 pm

ufs is basically what mu uses under the hood. It's related to uflash, which is what mu uses to flash the hex files.

Post Reply