im-tomu / toboot

Bootloader for the EFM32HG Tomu Board
https://tomu.im/
GNU General Public License v3.0
72 stars 28 forks source link

Programming via ST-LinkV2 #13

Open rdpowers opened 7 years ago

rdpowers commented 7 years ago

I was able to flash the bootloader with an STLinkV2, but encountered some issues. I'm exceptionally new to OpenOCD, so it may just be inexperience on my part.

Using OpenOCD and an ST-LinkV2 gives a chip ID error:

Warn : 230 69 hla_interface.c:95 hl_interface_init_target(): UNEXPECTED idcode: 0x0bc11477
Error: 231 69 hla_interface.c:98 hl_interface_init_target(): expected 1 of 1: 0x2ba01477
Debug: 232 69 command.c:628 run_command(): Command failed with error code -4

It seems that the efm32hg309 is not defined and falls through to default (0x2ba01477) From (tcl/target/efm32.cfg):

if { [info exists CPUTAPID] } {
   set _CPUTAPID $CPUTAPID
} else {
   set _CPUTAPID 0x2ba01477
}

Using a very recent build of OpenOCD

$openocd --version
Open On-Chip Debugger 0.10.0+dev-00096-gf605a23 (2017-04-07-09:10)

Workaround - Q&D Modify openocd/tomu.conf to define CPUTAPID

-source [find interface/raspberrypi-native.cfg]
-transport select swd
+set CPUTAPID 0x0bc11477

Then this works: openocd -f interface/stlink-v2.cfg -f ./tomu.conf

Some questions, maybe more OpenOCD related than tomu-bootloader related: Am I building OpenOCD wrong or is the efm32hg309 just not properly supported? Perhaps you were doing development with one of the Cortex M3 or M4 which has the chip ID of 0x2ba01477? Or does transport select swd on the RPi config get the ID right while hla_swd transport supported by STLink somehow get it wrong?

mithro commented 7 years ago

What type of STLink board do you have? Can you attach a picture?

When / Where did you get the board from?

After you make that change does the programming actually work? (IE The board goes into the bootloader fine?)

rdpowers commented 7 years ago

Yes, this ultimately works. I've got the tomu running the blinky example now. I got it off of you at LCA2017.

I'm using some old knock-off ST-LINK-V2 $8 programmer from e-Bay or somewhere. It is running the most recent firmware. It looks something like this.

mithro commented 7 years ago

@rdpowers Would you mind writing up some documentation on using that board with the tomu?

rdpowers commented 7 years ago

Sure mate, I'll see what I can do.

jadeaffenjaeger commented 6 years ago

@mithro I just did more or less the same thing with the ST-Link that comes with STM Discovery Boards. If you're interested, I can document the necessary steps!

mithro commented 6 years ago

That would be awesome!

On 8 Feb. 2018 12:22 pm, "jadeaffenjaeger" notifications@github.com wrote:

@mithro https://github.com/mithro I just did more or less the same thing with the ST-Link that comes with STM Discovery Boards. If you're interested, I can document the necessary steps!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/im-tomu/tomu-bootloader/issues/13#issuecomment-364236768, or mute the thread https://github.com/notifications/unsubscribe-auth/AABS3HhwNVuUwukpinJQI1dCXksui5bSks5tS1eMgaJpZM4M2Zmg .

rdpowers commented 6 years ago

Oh, wow. Sorry @mithro , this completely fell off my radar!! If something isn't together in the next week, I'll promise to pick it back up then.

todbot commented 5 years ago

Hi! Here's what I did to use a $8 ST-Link V2 to program Tomu via SWD https://gist.github.com/todbot/6b8da4bed3545313ae976be6be7ffc40