1
\$\begingroup\$

I am busy trying to write some firmware for a system with a whole lot of digitally controlled hydraulic components, and it's a complex system so there is a lot of tweaking of the algorithm and debugging.

I having a problem in that whenever I compile code and upload it to the board via ST-Link, all the pins float/go high, which causes the whole system to go haywire (pumps turning on and valves opening - erratically), and I am also wasting a lot of water/other fluids.

I am using the System Workbenh IDE. Is there any setting I can flick to set all pins low during firmware upload?

I'm sick of forgetting to flick the power switch to all of the hydraulics before uploading.

\$\endgroup\$
3
  • \$\begingroup\$ What the datasheet is telling about the pins state at the reset/programming time? Is it really High or perhaps high-impedance state? In the latter case you should pull them down. Otherwise you will need to revise your FW updating procedure and power down the system during the process. \$\endgroup\$
    – Eugene Sh.
    Commented Feb 8, 2017 at 17:34
  • \$\begingroup\$ It's floating high-z. My problem is that I can't use pulldowns, as I need to pull the pump/valve pins up to 5V, due to the controllers I'm using requiring 5V PWM and logic. Hmmm. Maybe I have to use level shifters. Or perhaps I can turn off the entire system with a relay triggered by the reset pin. \$\endgroup\$
    – makepeace
    Commented Feb 8, 2017 at 17:40
  • \$\begingroup\$ you better just to turn it off manually. Really, not such a big deal. \$\endgroup\$
    – Eugene Sh.
    Commented Feb 8, 2017 at 17:44

1 Answer 1

3
\$\begingroup\$

Conceptually you want to halt the board, put all of the pins in a safe state by writing to the GPIO registers over JTAG/SWD, and then rewrite the flash. The default you're seeing is probably either halting the board in an arbitrary state and then reflashing it or resetting and halting it before reflashing it, neither of which gives you any control over the pins.

With something like OpenOCD, you could script it with tcl to write to the GPIO registers after reset but before reflashing. I'm not sure what customization you can do with an ST-Link through ST/System Workbench's tooling, but OpenOCD can also be used with the ST-Link hardware.

You could also write your own bootloader to control the process - that would also let you ensure that the pins stay in a safe state until the the new firmware is loaded.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks! That's the response I was looking for. Am currently using OpenOCD, so will have a look at what I can do with that. It's currently in the experimental stages, so I don't want to commit time to a bootloader just yet - but it's a valid option. Thanks! \$\endgroup\$
    – makepeace
    Commented Feb 8, 2017 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.