Debugging MicroRusEFI, can't connect openocd

Hardware inside and outside of the ECU
Post Reply
evarady
Posts: 7
Joined: Tue Apr 20, 2021 10:38 pm

Debugging MicroRusEFI, can't connect openocd

Post by evarady »

I've been tasked with connecting a debugger to the MicroRusEFI that my team has purchased to step through the firmware. I'm able to flash the firmware, but when I try to connect a debugger using openocd I recieve the error

Code: Select all

Error: Error connecting DP: cannot read IDR
I'm connecting to the SWD connection broken out near the USB, using the adafruit FT232 breakout. I'm using the SWD resistor hack described here, with a value of 320 Ohmshttps://github.com/arduino/OpenOCD/blob/master/tcl/interface/ftdi/swd-resistor-hack.cfg. My openocd invocation is

Code: Select all

sudo openocd -f interface/ftdi/ft232h-module-swd.cfg -f target/stm32f4x.cfg -c init -c "$_TARGETNAME config -rtos ChibiOS" 
I'm trying to figure out what mistake I'm making, but I can't pin it down further. I've tried this setup in both DFU mode and just letting it run. The 5v line on the FTDI board seems to power the device. Is the issue in the interface? The trick with the resistor feels like it could be the problem but I have no way to be sure with the available tools. Would this setup and command work if the debugger were properly connected, or is there an issue with my invocation or physical setup.
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: Debugging MicroRusEFI, can't connect openocd

Post by mck1117 »

Nobody has tried with an FT232, only actual stlink (and copy thereof) hardware, so you're firmly in uncharted territory.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Debugging MicroRusEFI, can't connect openocd

Post by AndreyB »

but whhhhhhhhyyyyyy?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
evarady
Posts: 7
Joined: Tue Apr 20, 2021 10:38 pm

Re: Debugging MicroRusEFI, can't connect openocd

Post by evarady »

That's kind of what I figured. Unfortunately this was the only thing my boss had on hand, and he's already asking me for results. At a high level it should behave the same, but this appears not to be the case. Would this approach work if I connected an ST-Link to these pins and changed the invocation to reflect this. I wouldn't be surprised if the issue was in the debugger, I just want to make sure before I tell my boss. Also is it intended behavior to power the board off of the debugger's rails?

as for the why, I don't have much choice, my boss wanted some analysis doneby another engineer, so now I have to do this. I think he was trying to record a CAN signal without anything connected, and wasn't seeing any signals, which he thought might be a firmware issue, although I'm not sure. Now my boss wants the other engineer to be able to step through the code to try and understand this I think. But I'm the only person on the team who's done any work with embedded systems, so I was given the FTDI chip and told to get a gdb instance running. I agree, this probably isn't the best way to approach this. Literally any help anyone can give me would be huge though. I've been trying really hard to get some embedded engineering work on my team so I'm really trying not to return empty handed
Last edited by evarady on Wed Apr 21, 2021 2:29 am, edited 1 time in total.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Debugging MicroRusEFI, can't connect openocd

Post by AndreyB »

That's getting more and more interesting, what are trying to debug on microRusEFI what is the big picture?

Where are you from?

Not even a discovery board to borrow ST-Link from Discovery or Nucleo?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
evarady
Posts: 7
Joined: Tue Apr 20, 2021 10:38 pm

Re: Debugging MicroRusEFI, can't connect openocd

Post by evarady »

There might be a discovery board, that's a really good idea, I'm not in office right now but I can check tomorrow.

I work at a small contractor in Honolulu of all places.

It's not my project so I"m a bit fuzzy on the details, but I think they're working on building simulations of the various car components and they want to connect the simulated car the the microRusEFI. This is more long term though, right now I think they're just trying to get the microRusEFI working. I think they expect some sort of periodic task to send CAN signals out on the big TE connector on the back even in the absence of any devices, so when they didn't see that they tried to modify the periodic task they thought was responsible for this CAN signal to blink a light, and when it didn't do that, I was handed this FTDI breakout and told to get a gdb server running so the other engineer could try and figure out what was going on.

Edit: This is the periodic task that the other engineer was looking at. I think the expectation was that dashboard data would be transmitted even if nothing was connected.
https://github.com/rusefi/rusefi/blob/d9713c84a48920d20b362a788aa321ff01a79dad/firmware/controllers/can/can_tx.cpp
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Debugging MicroRusEFI, can't connect openocd

Post by AndreyB »

Dashboard would only be transmitting if a specific dashboard is selected. It needs to know if you want to send BMW Mazda or VW. Did anyone configure which one it is?

While I hear that Honolulu is a bit weird I am assuming it's not so bad?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
evarady
Posts: 7
Joined: Tue Apr 20, 2021 10:38 pm

Re: Debugging MicroRusEFI, can't connect openocd

Post by evarady »

The weather is nice, I can't complain.

I managed to reach the other engineer who was working on this. I don't think he configured a dashboard. I have an oscilloscope, I could try to do this and probe the output. Are there instructions to do this? I'm not so familiar with the project, sorry if this is an obvious question.

Edit: I stand corrected, he used tunerstudio to set the dash to both miata and BMW
evarady
Posts: 7
Joined: Tue Apr 20, 2021 10:38 pm

Re: Debugging MicroRusEFI, can't connect openocd

Post by evarady »

Ok, I've gotten a nucleo board at work, and it has an embedded STLink. Will there be issues connecting it to the microRiusEFI? My concern is that when I was using the ftdi breakout, its vdd sat at 5V and could power the microRusEFI target. However the actual STLink is at 3v3, and can't power the board. Do I need a level shifter? Or can I just connect the two boards.
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: Debugging MicroRusEFI, can't connect openocd

Post by mck1117 »

Power the microRusEFI over its own USB port. Just connect ground, SWDIO, and SWCLK between the discovery and MRE, no power.
evarady
Posts: 7
Joined: Tue Apr 20, 2021 10:38 pm

Re: Debugging MicroRusEFI, can't connect openocd

Post by evarady »

ok, thanks so much. Is it helpful to connect SWO and NRESET?
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: Debugging MicroRusEFI, can't connect openocd

Post by mck1117 »

SWO not used, nreset I guess is optional. Won't hurt to connect it.
evarady
Posts: 7
Joined: Tue Apr 20, 2021 10:38 pm

Re: Debugging MicroRusEFI, can't connect openocd

Post by evarady »

awesome, I'll get the second cable and let you know how it goes. I really appreciate you taking the time to help me with this. I realize my questions are mostly obvious
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Debugging MicroRusEFI, can't connect openocd

Post by AndreyB »

Please clarify what software have you used to view and change parameters in this rusEFI unit.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Post Reply