Mistaken code in Board Renaming Tutorial?

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
paulw
 
Posts: 9
Joined: Wed Jun 01, 2011 12:00 pm

Mistaken code in Board Renaming Tutorial?

Post by paulw »

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?

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Mistaken code in Board Renaming Tutorial?

Post by mikeysklar »

@paulw,

Are you suggesting that this line be added to the end of our boot.py example?

Code: Select all

 storage.enable_usb_drive()
Are there additional guide changes you are recommending?

https://learn.adafruit.com/welcome-to-c ... 3014813-17

User avatar
paulw
 
Posts: 9
Joined: Wed Jun 01, 2011 12:00 pm

Re: Mistaken code in Board Renaming Tutorial?

Post by paulw »

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!

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Mistaken code in Board Renaming Tutorial?

Post by mikeysklar »

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:

Code: Select all

 storage.enable_usb_drive()

User avatar
paulw
 
Posts: 9
Joined: Wed Jun 01, 2011 12:00 pm

Re: Mistaken code in Board Renaming Tutorial?

Post by paulw »

What I've got:

Code: Select all

import storage

storage.remount("/", readonly=False)

m = storage.getmount("/")
m.label = "CP_M0EXPR"


storage.remount("/", readonly=True)

storage.enable_usb_drive()
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

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Mistaken code in Board Renaming Tutorial?

Post by mikeysklar »

Cool. I updated the guide with your suggestions. Thanks for the walk through.

https://learn.adafruit.com/welcome-to-c ... 3014813-17

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”