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

Re: Have I missed something...

Sun Jan 24, 2021 11:51 am

B.Goode wrote:
Sun Jan 24, 2021 11:49 am
" 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
*doh*, need to read the thread closer, lol

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 6061
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Have I missed something...

Sun Jan 24, 2021 12:32 pm

A "method" not yet mentioned is to make use of a USB hub with "switchable" ports:
https://www.cpmspectrepi.uk/raspberry_p ... B_hub_port
However, once programmed I prefer a powerbank (many of which have on/off switches).
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
nick.mccloud
Posts: 1145
Joined: Sat Feb 04, 2012 4:18 pm

Re: Have I missed something...

Sun Jan 24, 2021 1:04 pm

Once I get my hands on a physical one (or two or more, I do like to see what colour the magic smoke is) I have a scheme:

For development purposes, stick a push button or some other mechanism that can talk to the code inside.

In the super loop or an interrupt or similar, either 'quit' aka return from main or just a call to reset the board.

So when you want to get it in to program mode, press your button and all should be good.

qf PICO_ENTER_USB_BOOT_ON_EXIT and viewtopic.php?f=145&t=299767
Pico/RP2040 ≠ Arduino
Pico = hot rod kit car, Arduino = hot rod kit car wrapped in cotton wool with buoyancy aids & parachute

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

Re: Have I missed something...

Sun Jan 24, 2021 1:43 pm

None of this messing about with hubs, extra wires to GPIO pins or the like is needed on other microcontroller boards.
The PICO is a step backwards in usability which will make it harder to use in educational environments for example.
"Spoilt for a ha’p’orth of tar" comes to mind.
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
nick.mccloud
Posts: 1145
Joined: Sat Feb 04, 2012 4:18 pm

Re: Have I missed something...

Sun Jan 24, 2021 7:22 pm

PeterO wrote:
Sun Jan 24, 2021 1:43 pm
None of this messing about with hubs, extra wires to GPIO pins or the like is needed on other microcontroller boards.
The AdaFruit Feather STM32F405 on my desk begs to differ
Pico/RP2040 ≠ Arduino
Pico = hot rod kit car, Arduino = hot rod kit car wrapped in cotton wool with buoyancy aids & parachute

artag
Posts: 24
Joined: Wed Nov 02, 2011 10:51 am

Re: Have I missed something...

Sun Jan 24, 2021 7:34 pm

I'm not sure I've ended up with a clear idea of whether this is a nuisance (I won't go as far as 'problem') or not when you're using the SWI port.

However, if it's necessary to do a reset in order to get from a crashed program back through a reload and into the debugger again, one convenient way to do that would be to connect not only the pico used as a SWI debugger to SWDIO and SWCLK on the target but also RUN.

SWI connectors do indeed usually have a reset pin, presumably for this reason.However if I've read the above correctly you'd also need access to BOOTSEL which I don't think is on the pad pins.

Old Arduinos do have a PC-controlled reset (via DTR on the serial interface) but many modern ones like the 32U4-based devices and the Teensy rely on having some cooperative code running on the device to make this all transparent - they don't bring reset off-board, and some (Teensy 4, Arduino mini) don't have a reset button either.

Although this could be annoying, 99% of the time the crash isn't bad enough and you can recover with keystrokes alone. Once in a while you need to go through a more fiddly process to get it on track again.

The Teensy is good at this as it has a separate microcontroller to handle code loading and startup. You never reprogram this device. The Arduino mini has a very cunning workaround which almost always works for me : if you reset it twice in rapid succession, it goes into the bootloader instead of running normal code.

I also wonder whether the second M0 can help. If both are looking out for a reset request, then perhaps that further reduces the chances of missing it due to a crash. Is either M0 able to reset the other on demand or is one always 'master' ?

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...

Sun Jan 24, 2021 7:44 pm

artag wrote:
Sun Jan 24, 2021 7:34 pm
I'm not sure I've ended up with a clear idea of whether this is a nuisance (I won't go as far as 'problem') or not when you're using the SWI port.

However, if it's necessary to do a reset in order to get from a crashed program back through a reload and into the debugger again, one convenient way to do that would be to connect not only the pico used as a SWI debugger to SWDIO and SWCLK on the target but also RUN.

SWI connectors do indeed usually have a reset pin, presumably for this reason.However if I've read the above correctly you'd also need access to BOOTSEL which I don't think is on the pad pins.

Old Arduinos do have a PC-controlled reset (via DTR on the serial interface) but many modern ones like the 32U4-based devices and the Teensy rely on having some cooperative code running on the device to make this all transparent - they don't bring reset off-board, and some (Teensy 4, Arduino mini) don't have a reset button either.

Although this could be annoying, 99% of the time the crash isn't bad enough and you can recover with keystrokes alone. Once in a while you need to go through a more fiddly process to get it on track again.

The Teensy is good at this as it has a separate microcontroller to handle code loading and startup. You never reprogram this device. The Arduino mini has a very cunning workaround which almost always works for me : if you reset it twice in rapid succession, it goes into the bootloader instead of running normal code.

I also wonder whether the second M0 can help. If both are looking out for a reset request, then perhaps that further reduces the chances of missing it due to a crash. Is either M0 able to reset the other on demand or is one always 'master' ?
The RP2040 has a watchdog which you can use to reboot a crash device automagically. It is also possible to know on the reboot whether it was caused by a watchdog. Check out the examples for a quick demo.
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.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 341
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Have I missed something...

Sun Jan 24, 2021 8:43 pm

BOOTSEL is required if you want to flash over USB without regard to any software on the device (you can use the drive or picotool)

Any code running on the device could let you do more flashing (e.g. MicroPython, CircutPython let you do this)

If you are developing your own code for the device, you may want to hook up the SWD pins so you can debug anyway (at which point you can flash code from your IDE or gdb without pressing BOOTSEL)

User avatar
LukeW
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 33
Joined: Tue Jul 07, 2015 2:19 pm

Re: Have I missed something...

Sun Jan 24, 2021 11:42 pm

However, if it's necessary to do a reset in order to get from a crashed program back through a reload and into the debugger again, one convenient way to do that would be to connect not only the pico used as a SWI debugger to SWDIO and SWCLK on the target but also RUN.
Yes, you can restart or reset either core via the SWD port, and clear lockup states. Wouldn't be much of a debug port if you couldn't :D

User avatar
Imperf3kt
Posts: 4231
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia
Contact: Twitter

Re: Have I missed something...

Mon Jan 25, 2021 1:26 am

nick.mccloud wrote:
Sun Jan 24, 2021 1:04 pm
Once I get my hands on a physical one (or two or more, I do like to see what colour the magic smoke is)
The magic smoke is green.
jamesh wrote:
Sun Jan 24, 2021 4:15 pm
Everything is green now.
55:55:44:44:4C
52:4C:52:42:41

Rose tinted glasses are difficult to see through.

hippy
Posts: 9173
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Have I missed something...

Mon Jan 25, 2021 8:59 am

PeterO wrote:
Sun Jan 24, 2021 1:43 pm
None of this messing about with hubs, extra wires to GPIO pins or the like is needed on other microcontroller boards.
My ESP32 board needs an external button added to make them usable for code development without power-cycling.

I can agree it would have been nice to fit a Reset button to the board but it's not essential, and it's easy enough to add one.
PeterO wrote:
Sun Jan 24, 2021 1:43 pm
The PICO is a step backwards in usability which will make it harder to use in educational environments for example.
I would expect most educational users and many developers will be using a Base Board or breadboard which has the desired Reset button fitted rather than using just the Pico board itself.

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

Re: Have I missed something...

Mon Jan 25, 2021 9:46 am

nick.mccloud wrote:
Sun Jan 24, 2021 7:22 pm
PeterO wrote:
Sun Jan 24, 2021 1:43 pm
None of this messing about with hubs, extra wires to GPIO pins or the like is needed on other microcontroller boards.
The AdaFruit Feather STM32F405 on my desk begs to differ
Did I say "EVERY other microcontroller" ? :roll:
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
jahboater
Posts: 6695
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Have I missed something...

Mon Jan 25, 2021 10:20 am

hippy wrote:
Mon Jan 25, 2021 8:59 am
I would expect most educational users and many developers will be using a Base Board or breadboard which has the desired Reset button fitted rather than using just the Pico board itself.
Does any know where a breadboard with a Reset button is for sale?
Pi4 8GB (Raspberry Pi OS 64-bit), Pi4 4GB, Pi4 2GB, Pi1 Rev 1 256MB, Pi Zero

hippy
Posts: 9173
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Have I missed something...

Mon Jan 25, 2021 11:18 am

jahboater wrote:
Mon Jan 25, 2021 10:20 am
hippy wrote:
Mon Jan 25, 2021 8:59 am
I would expect most educational users and many developers will be using a Base Board or breadboard which has the desired Reset button fitted rather than using just the Pico board itself.
Does any know where a breadboard with a Reset button is for sale?
If a user cannot figure out how to connect a button to a breadboard they are probably out of their depth with a Pico.

User avatar
Gavinmc42
Posts: 5157
Joined: Wed Aug 28, 2013 3:31 am

Re: Have I missed something...

Mon Jan 25, 2021 11:37 am

Just write a bootloader that does what you want?
Only need to program that once.
2MB of rom, even 64KB should do a decent multi choice bootloader?
So it might take a few extra uS booting?
Build an RTOS into and you have an operating system.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

timost
Posts: 1
Joined: Mon Jan 25, 2021 3:39 pm

Re: Have I missed something...

Mon Jan 25, 2021 5:38 pm

I'm making a simple USB breakout with a switch on the 5v line. Bought a USB female socket, I've got a small switch and many usb printer cables. Take printer cable and cut off the printer end socket. Solder wires to the USB socket with a switch in the 5v line.

Problem solved.

emma1997
Posts: 1386
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Have I missed something...

Tue Jan 26, 2021 7:41 pm

PeterO wrote:
Fri Jan 22, 2021 4:08 pm
Arduino saying "Hold on, this download method is a crock !"
papatrexasgre wrote:
Fri Jan 22, 2021 4:38 pm
Without fitting relays and air pistons pressing down on BSEL buttons... can I or can I not program and reprogram the PICO via ssh...?
I agree that pushing buttons is not for me either in any serious development scenario. For those playing with white plug-boards and fussing over Fritzograms this is not an issue. If you download hundreds of times a day or even an hour then maybe not so sweetness and light.

Scruss just mentioned the Roger/STM-duino story but didn't bring up the whole button vs auto-load fiasco started on Arduino site. I used to plead for adoption of DTR/RTS auto-reset but Roger would have none of that. For some bizarre reason he insisted on the whole reach out and touch me process. When it flopped and later ST came to the rescue that whole button thing quickly vanished.

Unfortunately, as Scruss also hinted, you have to sign over 1st born to download tools. Fortunately I saved the old downloader (one file) and can polish off in one sitting instead of spending all day and wearing out my pinky in the process.

Maybe Pico tools will catch up. That's how I got my 1st, from a disgruntled user, but still holding back myself til sharp edges get sanded off. I do have a Git account but not a big 'ol git' myself and cannot use for hobby anyway. It's young and lots other stuff keeping Pi team busy ATM.

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

Re: Have I missed something...

Tue Jan 26, 2021 8:49 pm

emma1997 wrote:
Tue Jan 26, 2021 7:41 pm
If you download hundreds of times a day or even an hour then maybe not so sweetness and light.

I'm only getting to grips with myself but its seems to me you don't need the bootloader for your hundreds of downloads a day.
You need the bootloader to replace the UF2 file but you can use, say, Thonny, to download your micropython code files as often as you like without a reboot or a BOOTSEL button press.
C/C++ may be different. I haven't looked at that, but it must be possible there as well. A UF2 file that provides a code downloader would avoid BOOTSEL 99.9% of the time.

Comparing to Arduino, you can develop your code without needing to replace the bootloader hundreds of times.

BTW, I mistakenly thought the mounting as a storage device was how to put program code onto this (how codebug did it) but you need to put your .py files into the micropython file system via Thonny or other, not drop them on the mount. I think that is only for UF2 files.

kilograham
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 341
Joined: Fri Apr 12, 2019 11:00 am
Location: austin tx

Re: Have I missed something...

Tue Jan 26, 2021 8:58 pm

* You need to be in BOOTSEL mode to (get into the ROM bootloader to) download code via UF2 (or pictool)
* This is not necessary if using the SWD debug interface, which lets you download code at any point from gdb/IDE etc without pressing BOOTSEL.. If you are using C/C++ you are probably hooked up this way; if not you can still download via UF2
* This is not necessary if the code - actually running - on the device lets you download code in some other way (MicroPython and CircuitPython do this).

picotool will let you do updates from the command line (assuming the RP2040 is in BOOTSEL mode).

The host side has no way to force the RP2040 into bootsel mode if it isn't that way (unless you roll your own). Of course the code running on the RP2040 can choose to boot back into BOOTSEL mode via reset_usb_boot function

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

Re: Have I missed something...

Tue Jan 26, 2021 9:00 pm

Thanks for the clarification. That might save some wear and tear on those buttons.

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...

Tue Jan 26, 2021 9:00 pm

Attach the debugger - that is the only sensible way if you need to download multiple times per hour during development.
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.

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

Re: Have I missed something...

Tue Jan 26, 2021 9:09 pm

jamesh wrote:
Tue Jan 26, 2021 9:00 pm
Attach the debugger - that is the only sensible way if you need to download multiple times per hour during development.
That is surely a sensible way, but is there a downside to the Thonny way? Code, save to host, run, edit, run ...x100, save to Pico, run, edit ... x 100.
Optionally build your code into a UF2 and flash that with the debugger. Don't touch BOOTSEL?

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...

Tue Jan 26, 2021 9:11 pm

PiGraham wrote:
Tue Jan 26, 2021 9:09 pm
jamesh wrote:
Tue Jan 26, 2021 9:00 pm
Attach the debugger - that is the only sensible way if you need to download multiple times per hour during development.
That is surely a sensible way, but is there a downside to the Thonny way? Code, save to host, run, edit, run ...x100, save to Pico, run, edit ... x 100.
Optionally build your code into a UF2 and flash that with the debugger. Don't touch BOOTSEL?
If using Python its fine, if doing C then I'd go with the debugger.
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.

emma1997
Posts: 1386
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Have I missed something...

Tue Jan 26, 2021 9:16 pm

Maybe that's good news. I went through all the PDFs but must admit lost most of the early stuff before even getting through the 1st one. TMI

Some experience with GDB but not good memories because it was all command line back then and very tedious. No Thonny for me and IDEs like Eclipse not on my favorites list either. I do like Geany (except for the teapot logo, lol) and would be nice to adapt that. And don't get me going on UF2 vs Intel Hex.

UART worked fine for me on other ARM like STM etc. No SWM or JTAG or MSD. Although the drag and drop is cool if not productive. Had fun playing in a brief stint with IIRC NXP ARM some time ago which was one of the few chips capable.

With a strong dislike for Python I'm primarily C/Bash for Pi. ASM for others. Not a big fan of pushing buttons, not for coding anyway. Sometimes these are unavoidable but given the choice one key programming cycles are bread and butter for me. Spoiled by decades of old timey toolsets and turned off by all this next-gen online tomfoolery. May have to use it (to make a living) but don't have to like it.

Mostly a matter of time. If Pi is any indication things will surely improve. I need to go through the docs again to see what's being described here and how it can work for me. In no hurry yet.

hippy
Posts: 9173
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Have I missed something...

Wed Jan 27, 2021 3:07 am

emma1997 wrote:
Tue Jan 26, 2021 7:41 pm
Maybe Pico tools will catch up. That's how I got my 1st, from a disgruntled user ...
I'm surprised anyone would be so disgruntled with a Pico to give up on it so soon. Though I am not going to say it's perfect it's been one of the easiest devices I have used when it comes to setting up toolchains and getting code to run on it.

C programming just works, as does MicroPython and CircuitPython, and that was when rushing in without properly reading the documentation.

Return to “General”