So I've got about half a dozen circuitpython boards for robotics workshop I'm teaching, and I've started losing track of which one is which. I followed instructions from <https://learn.adafruit.com/welcome-to-c ... -circuitpy> to rename my boards, and the Linux command-line version worked OK, but the circuit-python boot.py version did not work well. I consistently ended up with a board that was read-only to Mu. (And when I miscounted the characters in the label, the board ended up read-protected to the OS as well: "WARNING: device write-protected, mounted read-only." Luckily, unmount/relabel/remount by command line got the board back.)
What does seem to work more effectively is adding another line: "storage.enable_usb_drive()" to the code in boot.py. Is there a process for revising the tutorial?
Mistaken code in Board Renaming Tutorial?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Mistaken code in Board Renaming Tutorial?
@paulw,
Are you suggesting that this line be added to the end of our boot.py example?
Are there additional guide changes you are recommending?
https://learn.adafruit.com/welcome-to-c ... 3014813-17
Are you suggesting that this line be added to the end of our boot.py example?
Code: Select all
storage.enable_usb_drive()
https://learn.adafruit.com/welcome-to-c ... 3014813-17
- paulw
- Posts: 9
- Joined: Wed Jun 01, 2011 12:00 pm
Re: Mistaken code in Board Renaming Tutorial?
Yes. (I've tested it with the boards I've got, which are M0 Express, Itsy Bitsy M4 and RP 2040, and Makerpi 2040, and it seems to work...) I think also perhaps in the text for "Renaming CIRCUITPY through CircuitPython" it would be good to reiterate the warning about name length. Something like "Be absolutely sure the name you choose is not too long; an error in boot.py could render your board unusable until you fix the name with one of the other methods."
(Or perhaps that's too much handholding -- not everyone is as heedless as I am...)
thanks!
(Or perhaps that's too much handholding -- not everyone is as heedless as I am...)
thanks!
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Mistaken code in Board Renaming Tutorial?
I wonder if the device name length could be a problem when using different operating systems? We state the 11 character limit near the top so I'll add that lower down as a warning in the renaming section.
Can you post your working boot.py. I wanted to see where you placed this line:
Can you post your working boot.py. I wanted to see where you placed this line:
Code: Select all
storage.enable_usb_drive()
- paulw
- Posts: 9
- Joined: Wed Jun 01, 2011 12:00 pm
Re: Mistaken code in Board Renaming Tutorial?
What I've got:
Mu-editor has some issues with this if it's running when the device is renamed (especially if it's got a file that thinks it lives on the old name of the drive), but that's another kettle of fish. (Mostly mu may think it's just met a micropython board, but as long as you tell it to stay in circuitpython mode and make sure the dropdown bottom right says circuitpython everything works.)
hope that helps
Code: Select all
import storage
storage.remount("/", readonly=False)
m = storage.getmount("/")
m.label = "CP_M0EXPR"
storage.remount("/", readonly=True)
storage.enable_usb_drive()
hope that helps
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Mistaken code in Board Renaming Tutorial?
Cool. I updated the guide with your suggestions. Thanks for the walk through.
https://learn.adafruit.com/welcome-to-c ... 3014813-17
https://learn.adafruit.com/welcome-to-c ... 3014813-17
Please be positive and constructive with your questions and comments.