Due to high demand expect some shipping delays at this time, orders may not ship for 3-4 business days. On MLK Day no orders will be shipped.
0

Mistaken code in Board Renaming Tutorial?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Mistaken code in Board Renaming Tutorial?

by paulw on Sat Nov 27, 2021 5:32 pm

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-circuitpython/renaming-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?

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

Re: Mistaken code in Board Renaming Tutorial?

by mikeysklar on Mon Nov 29, 2021 7:15 pm

@paulw,

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

Code: Select all | TOGGLE FULL SIZE
 storage.enable_usb_drive()


Are there additional guide changes you are recommending?

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

mikeysklar
 
Posts: 6526
Joined: Mon Aug 01, 2016 8:10 pm

Re: Mistaken code in Board Renaming Tutorial?

by paulw on Mon Nov 29, 2021 8:41 pm

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!

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

Re: Mistaken code in Board Renaming Tutorial?

by mikeysklar on Tue Nov 30, 2021 3:42 pm

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

mikeysklar
 
Posts: 6526
Joined: Mon Aug 01, 2016 8:10 pm

Re: Mistaken code in Board Renaming Tutorial?

by paulw on Tue Nov 30, 2021 10:06 pm

What I've got:

Code: Select all | TOGGLE FULL SIZE
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

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

Re: Mistaken code in Board Renaming Tutorial?

by mikeysklar on Wed Dec 01, 2021 5:35 pm

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

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

mikeysklar
 
Posts: 6526
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.