User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Have I missed something...

Fri Jan 22, 2021 3:36 pm

Do you really have to replug the USB every time to reload your code ?
If so I can see a lot of broken usb sockets in the near future...
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28358
Joined: Sat Jul 30, 2011 7:41 pm

Re: Have I missed something...

Fri Jan 22, 2021 3:39 pm

You need to power down in some way = could be by unplugging. Hold the BOOTSEL button down when powering back up and you will go in to MSD mode.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: Have I missed something...

Fri Jan 22, 2021 3:41 pm

jamesh wrote:
Fri Jan 22, 2021 3:39 pm
You need to power down in some way
:roll: Really ... This is 2021 you know, not 1980...
Seems like you've spoilt an otherwise fine product with a totally inappropriate download scheme...
I'll wait until you've come up with something appropriate before going any further with this....
Very dissapointed :-(
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2548
Joined: Thu Jul 11, 2013 2:37 pm

Re: Have I missed something...

Fri Jan 22, 2021 3:44 pm

No, you don't.

https://github.com/raspberrypi/picotool

This is a command-line tool that interacts with the bootloader. Note the "reboot" command.

Edit: it's installed by default if you have installed the SDK correctly.
Rockets are loud.
https://astro-pi.org

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28358
Joined: Sat Jul 30, 2011 7:41 pm

Re: Have I missed something...

Fri Jan 22, 2021 3:47 pm

PeterO wrote:
Fri Jan 22, 2021 3:41 pm
jamesh wrote:
Fri Jan 22, 2021 3:39 pm
You need to power down in some way
:roll: Really ... This is 2021 you know, not 1980...
Seems like you've spoilt an otherwise fine product with a totally inappropriate download scheme...
I'll wait until you've come up with something appropriate before going any further with this....
Very dissapointed :-(
PeterO
Come on Peter, you should know better than that.

You can use the debugger, you'll never need to turn it off again. I use a bench top power supply, it has a switch. You can use Picotool.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: Have I missed something...

Fri Jan 22, 2021 3:51 pm

jamesh wrote:
Fri Jan 22, 2021 3:47 pm
Come on Peter, you should know better than that.
You can use the debugger, you'll never need to turn it off again. I use a bench top power supply, it has a switch. You can use Picotool.
I'm working my way through the "getting started" manual.... No mention of debuggers yet and all I wanted to do was flash the led slower...
I asked "Do you really have to replug the USB every time to reload your code ?"
You didn't say anything about debuggers in your reply, so I find your ""Come on Peter" comment to be highly insulting ! :twisted:
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
aallan
Raspberry Pi Trading Employee & Forum Moderator
Raspberry Pi Trading Employee & Forum Moderator
Posts: 125
Joined: Mon Feb 09, 2015 11:30 am
Location: Exeter, UK
Contact: Website Twitter

Re: Have I missed something...

Fri Jan 22, 2021 3:55 pm

PeterO wrote:
Fri Jan 22, 2021 3:51 pm
I'm working my way through the "getting started" manual.... No mention of debuggers yet and all I wanted to do was flash the led slower...

Chapter 5, "Getting started with Raspberry Pi Pico" and onwards..?
Technical Documentation Manager
Raspberry Pi (Trading) Limited
About me, http://alasdairallan.com

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: Have I missed something...

Fri Jan 22, 2021 3:57 pm

jdb wrote:
Fri Jan 22, 2021 3:44 pm
No, you don't.

https://github.com/raspberrypi/picotool

This is a command-line tool that interacts with the bootloader. Note the "reboot" command.

Edit: it's installed by default if you have installed the SDK correctly.
Nothing about this in https://datasheets.raspberrypi.org/pico ... h_pico.pdf
TBH the documentation I've read so far is verbose but not very well though out...
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: Have I missed something...

Fri Jan 22, 2021 4:00 pm

aallan wrote:
Fri Jan 22, 2021 3:55 pm
Chapter 5, "Getting started with Raspberry Pi Pico" and onwards..?
Repeated plugging becomes an issue in Chapter 3, so why is it not mentioned there ? As I said, I'm finding the docs are poorly thought out.... :(
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: Have I missed something...

Fri Jan 22, 2021 4:08 pm

jamesh wrote:
Fri Jan 22, 2021 3:39 pm
You need to power down in some way = could be by unplugging. Hold the BOOTSEL button down when powering back up and you will go in to MSD mode.
I can only assume that you designed and built this product without anyone who has used an Arduino saying "Hold on, this download method is a crock !"
:(
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
dickon
Posts: 1886
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: Have I missed something...

Fri Jan 22, 2021 4:13 pm

https://www.amazon.co.uk/dp/B08D92G7TF/ref=dp_prsubs_1

Been using these on Pis and ESP32 dev boards for a couple of years.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2548
Joined: Thu Jul 11, 2013 2:37 pm

Re: Have I missed something...

Fri Jan 22, 2021 4:15 pm

Tedious negging aside...

Ah, turns out there are a few gotchas with picotool. It only interacts with a RP2040 in the USB bootloader mode, so only if BOOTSEL was pressed when the chip came out of reset. Most code downloads will automatically reboot into the SPI flash code after completing, so unless they also expose the bootloader interface over USB, picotool won't do anything.

Resetting the chip is all that is required to re-run the ROM and sample the BOOTSEL pin. Unplug isn't (but unplugging implies power-on reset).

Use the RUN pin (pin 30) to reset the RP2040 without un-powering the board. Force low to reset the chip, press BOOTSEL, and disconnect to "run". See the Pico datasheet:

https://datasheets.raspberrypi.org/pico ... asheet.pdf
Rockets are loud.
https://astro-pi.org

papatrexasgre
Posts: 25
Joined: Thu Nov 13, 2014 2:52 pm

Re: Have I missed something...

Fri Jan 22, 2021 4:38 pm

Thick alert... You've been warned....
Maybe because it's Friday and I can't wait to leave.....


So... I have a raspberry pi and a PICO locked in a box... The only thing that comes out of that box is an ethernet cable that gives me ssh access and access to a samba share on the raspberry. There is a usb cable connecting the raspberry and the pico...
Without fitting relays and air pistons pressing down on BSEL buttons... can I or can I not program and reprogram the PICO via ssh...?
thanks, sorry and have a nice weekend :)

RoyLongbottom
Posts: 385
Joined: Fri Apr 12, 2013 9:27 am
Location: Essex, UK
Contact: Website

Re: Have I missed something...

Fri Jan 22, 2021 4:49 pm

PeterO wrote:
Fri Jan 22, 2021 3:36 pm
Do you really have to replug the USB every time to reload your code ?
If so I can see a lot of broken usb sockets in the near future...
PeterO
I have a 5 inch male to female USB extension cable stapled to my desktop. My main worry at the time was reinserting the main cable sometimes dislodged the monitor cable and I was doing this a few times a minute developing C programs.

PiGraham
Posts: 4484
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Have I missed something...

Fri Jan 22, 2021 4:50 pm

jdb wrote:
Fri Jan 22, 2021 4:15 pm
Use the RUN pin (pin 30) to reset the RP2040 without un-powering the board. Force low to reset the chip, press BOOTSEL, and disconnect to "run". See the Pico datasheet:

https://datasheets.raspberrypi.org/pico ... asheet.pdf
I was just about to ask about the run pin to do this. That seems like a good option. Two pins away from a GND so a push button could probably fitted to the board to make this easy in development.

User avatar
dickon
Posts: 1886
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: Have I missed something...

Fri Jan 22, 2021 4:51 pm

papatrexasgre wrote:
Fri Jan 22, 2021 4:38 pm
So... I have a raspberry pi and a PICO locked in a box... The only thing that comes out of that box is an ethernet cable that gives me ssh access and access to a samba share on the raspberry. There is a usb cable connecting the raspberry and the pico...
Without fitting relays and air pistons pressing down on BSEL buttons... can I or can I not program and reprogram the PICO via ssh...?
This might be a really, really bad idea, but I don't immediately see why you couldn't tie a Pi GPIO to TP4 and one to pin 30 on the Pico, to simulate pressing the button (which seems to be tied to the flash chipselect, which is neat) and reset the uC.

[Edit: I misread the schematic. It is, as has been pointed out, TP6, not TP4. Apologies.]
Last edited by dickon on Mon Jan 25, 2021 7:02 pm, edited 1 time in total.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

User avatar
joan
Posts: 15378
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Have I missed something...

Fri Jan 22, 2021 4:57 pm

Just used the quickstart instructions to build the SDK on my Linux laptop. It complained at the end about some missing packages.

Code: Select all

The following packages have unmet dependencies.
 code:armhf : Depends: libnss3:armhf (>= 2:3.26) but it is not installable
              Depends: apt:armhf but it is not installable
              Depends: libxkbfile1:armhf but it is not installable
              Depends: libsecret-1-0:armhf but it is not installable
              Depends: libgtk-3-0:armhf (>= 3.10.0) but it is not installable
              Depends: libxss1:armhf but it is not installable
              Depends: libgbm1:armhf but it is not installable
E: Unable to correct problems, you have held broken packages.
Anyhow cmake works from the command line and my LED blinks much faster now!

BMS Doug
Posts: 4422
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Have I missed something...

Sun Jan 24, 2021 8:45 am

dickon wrote:
Fri Jan 22, 2021 4:51 pm
This might be a really, really bad idea, but I don't immediately see why you couldn't tie a Pi GPIO to TP4 and one to pin 30 on the Pico, to simulate pressing the button (which seems to be tied to the flash chipselect, which is neat) and reset the uC.
Doesn't the run pin (pin 30) and TP4 serve a functionally similar process?
Both would restart the Pico when brought low.
nope, see Peter O's post (below).
TP6 is the BOOTSET, holding that and pin 30 low, then releasing TP6 shortly after releasing pin30 should have the desired effect.
Last edited by BMS Doug on Sun Jan 24, 2021 9:17 am, edited 1 time in total.
Doug.
Building Management Systems Engineer.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: Have I missed something...

Sun Jan 24, 2021 9:07 am

TP4 changes the regulator between Pulse Width and Frequency control to provide best efficiency, it does not turn off the 3V3 supply.
I seems several people have now worked out that the boot/load process is a weak point and are looking at similar solutions.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

BMS Doug
Posts: 4422
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Have I missed something...

Sun Jan 24, 2021 9:21 am

PeterO wrote:
Sun Jan 24, 2021 9:07 am
It seems several people have now worked out that the boot/load process is a weak point and are looking at similar solutions.
PeterO
It's not likely to bother me much, I only started looking at it out of academic interest, because people were asking.

Seems like they thought about it during design and provided both hardware (TP6) and software solution options.

Very nice piece of engineering.
Doug.
Building Management Systems Engineer.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: Have I missed something...

Sun Jan 24, 2021 9:24 am

BMS Doug wrote:
Sun Jan 24, 2021 9:21 am
Very nice piece of engineering.
I don't agree.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

BMS Doug
Posts: 4422
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Have I missed something...

Sun Jan 24, 2021 10:01 am

PeterO wrote:
Sun Jan 24, 2021 9:24 am
I don't agree.
PeterO
Fair enough.

But to return to your original question in this thread:
PeterO wrote: Do you really have to replug the USB every time to reload your code ?
PeterO
No, the pico can be readied for new code by either software or hardware.

Your software would need to be compiled with PICO_ENTER_USB_BOOT_ON_EXIT then a condition that ends the main loop will set the Pico back, ready to load new software.

A hardware solution would be to reset the Pico by pulling the run pin (pin 30) low and either hold the BOOTSET button down when releasing pin 30 or pulling down TP6 until after pin 30 is released.
Having a single physical button that sets the Pico into a Boot ready mode would risk occasional accidental boot conditions, something that would receive a lot of criticism I'm sure.

Software solution, hardware solution.

All that is lacking is the clarity of documentation (which I'm sure will improve).
It's not always easy to remember that the other person doesn't know it already when writing documentation, so stuff does get missed, or need a re-write to clarify.
Doug.
Building Management Systems Engineer.

User avatar
joan
Posts: 15378
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Have I missed something...

Sun Jan 24, 2021 10:03 am

I just pull the USB plug at the laptop end.

cleverca22
Posts: 2888
Joined: Sat Aug 18, 2012 2:33 pm

Re: Have I missed something...

Sun Jan 24, 2021 11:45 am

joan wrote:
Sun Jan 24, 2021 10:03 am
I just pull the USB plug at the laptop end.
the usb ports on my desktop have been getting a bit loose lately, they still work but i can feel the wear

to avoid making things worse, ive taken the reset switch out of an old x86 pc case, and plugged it into the RUN header on my pi0, so i can just hard-reset it with a simple button

the RP2040 datasheet says it also has a RUN pin, so its just a matter of knowing which TP or pin its routed to

edit:
ah, and there it is, pin 30 on the main set of pins
Last edited by cleverca22 on Sun Jan 24, 2021 11:50 am, edited 1 time in total.

User avatar
B.Goode
Posts: 11190
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Have I missed something...

Sun Jan 24, 2021 11:49 am

cleverca22 wrote:
Sun Jan 24, 2021 11:45 am
joan wrote:
Sun Jan 24, 2021 10:03 am
I just pull the USB plug at the laptop end.
the usb ports on my desktop have been getting a bit loose lately, they still work but i can feel the wear

to avoid making things worse, ive taken the reset switch out of an old x86 pc case, and plugged it into the RUN header on my pi0, so i can just hard-reset it with a simple button

the RP2040 datasheet says it also has a RUN pin, so its just a matter of knowing which TP or pin its routed to



" its just a matter of knowing which TP or pin its routed to"


From earlier in this same thread... viewtopic.php?f=144&t=299746#p1801991

Return to “General”