repl on the BBC:Microbit
Re: repl on the BBC:Microbit
My microbit doent have a battery pack at present, I wonder if I connected a battery to it it would retain python scripts in memory between connections of the usb? I shall dig out some crokodil clips......
Re: repl on the BBC:Microbit
I tried it with a 3V battery connected during the removal and reconnection of the USB but this made no difference, main.py still vanished.
Seems to mean that the only way to program the microbit is to flash the script using uflash (or mu)
Seems to mean that the only way to program the microbit is to flash the script using uflash (or mu)
Re: repl on the BBC:Microbit
Can you describe in detail how you are uploading the main.py to the micro:bit and how you are checking that it is there?
Re: repl on the BBC:Microbit
This is what I have just done
$ cp main.py /media/MICROBIT/
$ sudo sync
$ ls /media/MICROBIT/
AUTO_RST.CFG DETAILS.TXT main.py MICROBIT.HTM
$ sudo umount /media/MICROBIT
I then manually unplug and replug the USB cable
$ ls /media/MICROBIT/
AUTO_RST.CFG DETAILS.TXT MICROBIT.HTM
main.py has vanished.
I can flash main.py to the board using
$ uflash main.py
... and it keeps the script running after many hard and soft resets.
The system configuration is as follows:
* My linux is Mint 17.3,
* I have the latest Microbit firmware 0234,
The following is from the REPL prompt after a Ctrl-C
* MicroPython v1.7-9-gbe020eb on 2016-04-18; micro:bit with nRF51822
At the moment I'm not too bothered. I can program it using uflash, I will find the time to install mu. Its behaviour is different from the pyboard
$ cp main.py /media/MICROBIT/
$ sudo sync
$ ls /media/MICROBIT/
AUTO_RST.CFG DETAILS.TXT main.py MICROBIT.HTM
$ sudo umount /media/MICROBIT
I then manually unplug and replug the USB cable
$ ls /media/MICROBIT/
AUTO_RST.CFG DETAILS.TXT MICROBIT.HTM
main.py has vanished.
I can flash main.py to the board using
$ uflash main.py
... and it keeps the script running after many hard and soft resets.
The system configuration is as follows:
* My linux is Mint 17.3,
* I have the latest Microbit firmware 0234,
The following is from the REPL prompt after a Ctrl-C
* MicroPython v1.7-9-gbe020eb on 2016-04-18; micro:bit with nRF51822
At the moment I'm not too bothered. I can program it using uflash, I will find the time to install mu. Its behaviour is different from the pyboard
Re: repl on the BBC:Microbit
I see the source of your confusion now!
You can't just copy files onto the fake mass storage device that micro:bit appears as -- this is only for flashing the hex files. Basically, anything you copy there will be flashed as firmware. It's not a real disk, it's just a hack to make it easy to flash firmware.
In order to create files on micro:bit's internal filesystem, you either have to run a python program that would create the files there and fill them with content, or use Mu to upload the files.
You can't just copy files onto the fake mass storage device that micro:bit appears as -- this is only for flashing the hex files. Basically, anything you copy there will be flashed as firmware. It's not a real disk, it's just a hack to make it easy to flash firmware.
In order to create files on micro:bit's internal filesystem, you either have to run a python program that would create the files there and fill them with content, or use Mu to upload the files.
Re: repl on the BBC:Microbit
Ah, thanks, I understand now... But this opens up more questions
When I run the code
The file is written to the Microbit's local-persistant-file-system but can I access that file or copy it to the host computer over the USB connection?
When I run the code
Code: Select all
from microbit import *
with open('file.txt', 'w') as f:
f.write('this is a test')
Re: repl on the BBC:Microbit
You can, using the Mu's "files" dialog.
-
- Posts: 168
- Joined: Tue Nov 07, 2017 11:45 pm
Re: repl on the BBC:Microbit
to use REPL under linux you need to be in group dialout, in a terminal type
You will need to log out and bak in for the groups to take effect
Code: Select all
sudo usermod -a -Gdialout user-name
-
- Posts: 168
- Joined: Tue Nov 07, 2017 11:45 pm
Re: repl on the BBC:Microbit
To place persistent files onto a micro:bit you have at least these two options
1)
2) use the Mu ide
I guess your using linux if your doing which will never work. The microbit appearing as though it's a usb drive is a hack to allow drag and drop flashing.
If your using ubuntu/debian linux you may want to read https://ubuntuforums.org/showthread.php?t=2377314
1)
Code: Select all
microfs put filename
I guess your using linux if your doing
Code: Select all
cp my-data /media/xxx/MICROBIT
If your using ubuntu/debian linux you may want to read https://ubuntuforums.org/showthread.php?t=2377314
Re: repl on the BBC:Microbit
Thanks @deshipu. The fake mass storage device makes more sense to me now
https://www.mbed.com/en/platform/hardwa ... -on-kl26z/
https://www.mbed.com/en/platform/hardwa ... -on-kl26z/