Raspberry Pi 4 to Toolboard 1LC with OpenOCD
-
@dc42 Aha! I pulled out an old v1.0 of the 1LC, and had no problem connecting to it with the Pi. Is this related to the
swdclk
pin being used to blink theSTATUS
LED? I would like to be able to flash any version of the 1LC from a Pi. -
@wulfsta said in Raspberry Pi 4 to Toolboard 1LC with OpenOCD:
@dc42 Aha! I pulled out an old v1.0 of the 1LC, and had no problem connecting to it with the Pi. Is this related to the
swdclk
pin being used to blink theSTATUS
LED? I would like to be able to flash any version of the 1LC from a Pi.Yes, probably. On the rare occasions that I use a debugger with Duet boards that connect LEDs to SWCLK and/or SWDIO, I use a Debug build of the firmware, which doesn't drive those LEDs.
-
PS - I see that it is possible to detect whether a debugger is present by reading a register. So in the next firmware version, I will change it not to drive the LEDs when a debugger is detected.
-
@wulfsta I see this a lot with STM32 based control boards that often attach LEDs to the SWD pins. As David mentioned the firmware can detect the debugger and not use the pin (that's what the STM port of RRF does). However there is still the problem of how to get the debug probe actually talking with the board in the first place. If the pins are not being used for other purposes the probe can attach while the mcu is running, it can then use the SWD protocol to reset the board. But if the pin is already being used this may not work and you may need to attach the probe while the board is in reset. On the boards I use there is usually a reset button and if you press this and start the debugger at the same time it is usually able to attach. However I don't think the 1LC has a reset button. You may be able to adjust the openOCD settings to get it to use hardware reset (and connect the reset line on the SWD connector), but as it says in the openOCD documentation, this can be tricky to get it working!
-
@gloomyandy I actually have no idea how to do this, and a cursory look at the docs didn't seem to suggest it's well-known; do you happen to have a reference that I could look at, or example of someone doing this? Or at least, a link to where this is located in the OpenOCD docs?
-
@Wulfsta As I said it can be rather complex and the openocd documentation is perhaps not the best. You will probably need to dig through the configuration files used to setup your Pi4 as an openocd swd probe (I've never used the rPi in this mode, so can't help there sorry). Take a look at https://openocd.org/doc/html/Reset-Configuration.html
-
@gloomyandy Ah yeah, I saw this page, but didn't have a close enough look at it. Thanks for the help though!
-
@dc42 Could you provide a debug build I can use for this purpose? I don't want to set up all the tooling to build RRF...
-
@Wulfsta the debug build configuration I have for the Tool1LC is for running without the bootloader. To use it, you would need to remove the bootloader protection, then write it to flash memory via SWD. Then to use the tool board normally again, you would need to reinstall the bootloader, again via SWD. The only tool I have ever done this with is an Atmel ICE. So unless you already have one, I can't recommend this route.
-
@dc42 said in Raspberry Pi 4 to Toolboard 1LC with OpenOCD:
@Wulfsta the debug build configuration I have for the Tool1LC is for running without the bootloader. To use it, you would need to remove the bootloader protection, then write it to flash memory via SWD. Then to use the tool board normally again, you would need to reinstall the bootloader, again via SWD. The only tool I have ever done this with is an Atmel ICE. So unless you already have one, I can't recommend this route.
Yeah, if I had one I’d just erase the chip using that… I do wonder why I can’t get OpenOCD working - maybe it’s the frequency or pulse width?
Edit: I should mention that I’m trying to connect under reset as the OpenOCD docs suggest, and still no luck.
-
I have it working with the following bash script:
SWCLK=25 SWDIO=24 SRST=18 echo "Exporting SWCLK and SRST pins." echo $SWCLK > /sys/class/gpio/export echo $SRST > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio$SWCLK/direction echo "out" > /sys/class/gpio/gpio$SRST/direction echo "Setting SWCLK low and pulsing SRST." echo "0" > /sys/class/gpio/gpio$SWCLK/value echo "0" > /sys/class/gpio/gpio$SRST/value echo "1" > /sys/class/gpio/gpio$SRST/value echo "Unexporting SWCLK and SRST pins." echo $SWCLK > /sys/class/gpio/unexport echo $SRST > /sys/class/gpio/unexport echo "Ready for OpenOCD." openocd -c "adapter driver bcm2835gpio; \\ bcm2835gpio peripheral_base 0xFE000000; \\ bcm2835gpio speed_coeffs 236181 60; \\ adapter gpio swclk $SWCLK; \\ adapter gpio swdio $SWDIO; \\ adapter gpio srst $SRST; \\ transport select swd; \\ set CHIPNAME samc21; \\ source [find target/at91samdXX.cfg]; \\ reset_config srst_only; \\ adapter speed 276; \\ init; \\ reset; \\ reset; \\ at91samd chip-erase; \\ at91samd bootloader 0; \\ program Duet3Bootloader-SAMC21.elf verify; \\ reset; \\ shutdown" echo "Done."
This is adapted from here.
-
-