Olimex STM-H103 + ARM-USB-OCD + codesourcery + ubuntu

I’m struggling to get a skeleton project together that will work with Olimex’ STM-H103, without using eclipse.

I have the toolchain built, but for the life of me I can’t seem to get a base project put together that will just flash that one singular LED on the board. I will admit that this is my first foray into the ARM land, as I’ve been really, really spoiled with AVR Studio and the beautiful tools there. I can’t believe how painful it has been so far just carving my own wheel out of stone with these primitive stone age tools (in comparison only, I’m sure that eventually I’ll cease to be a philistine).

Can anyone help? This just seems to be beyond my comprehension, for the past 3 weeks. :frowning:

Hi!

I’m using this setup… please hang in there, I can put together a very simple

skeleton and post it when I get to work on monday… I’m chasing toddlers around today.

Getting the jtag working was a lot of work, then getting the right compile and link options set up was also a lot of work. But once you have that first makefile set up right, it just works.

Where are you stuck right now… are you talking to the chip with openocd?

Hang in there… I’ll have a nice example for you by the end of Monday PST.

I’m very interested in having a functional development community using Linux as the host sytem.

cheers,

Alex

Glad to hear from someone who has gotten this working faveluka. I also will be very interested in your setup. I’ve only had my ‘toys’ for about 4 days. I don’t think I’ve gotten as far as lcdintegration.

Some random info:

interface is Olimex arm-usb-ocd (functions somewhat on xp with supplied cd)

kernel 2.6.27.14-generic (amd64)

libftdi.so.1.12.0

openocd 0.0_r655-1ubuntu1

openocd -f arm-usb-ocd.cfg -f lpc2148a.cfg

Open On-Chip Debugger 1.0 (2008-06-22-10:54) svn:unknown

$URL: http://svn.berlios.de/svnroot/repos/ope … /openocd.c $

Error: ft2232.c:1516 ft2232_init_libftdi(): unable to open ftdi device: device not found

partial output of dmesg:

[ 3685.904011] usb 3-1: new full speed USB device using uhci_hcd and address 2

[ 3686.102274] usb 3-1: configuration #1 chosen from 1 choice

[ 3686.546360] usbcore: registered new interface driver usbserial

[ 3686.548482] usbserial: USB Serial support registered for generic

[ 3686.549089] usbcore: registered new interface driver usbserial_generic

[ 3686.549093] usbserial: USB Serial Driver core

[ 3686.580803] usbserial: USB Serial support registered for FTDI USB Serial Device

[ 3686.581531] ftdi_sio: Ignoring serial port reserved for JTAG

[ 3686.582020] ftdi_sio 3-1:1.1: FTDI USB Serial Device converter detected

[ 3686.582613] ftdi_sio: Detected FT2232C

[ 3686.583103] usb 3-1: FTDI USB Serial Device converter now attached to ttyUSB0

[ 3686.583658] usbcore: registered new interface driver ftdi_sio

[ 3686.583662] ftdi_sio: v1.4.3:USB FTDI Serial Converters Driver

Maybe I need latest openocd?

Regards,

-Hugh

Hello hsutherl,

JTAG… what fun.

I’d upgrade the openocd. I’m not sure the Ubuntu package is recent enough… you might try to ask that question here… There were major changes to openocd I think in late 08.

I am using

–Open On-Chip Debugger 1.0 (2009-02-04-14:20) svn:1366–

I pulled it off their svn and compiled it.

There’s a lot of idiosyncracies… for example, I can’t get it to load a file

~/main.bin… I have to reference the path /home/faveluka/main.bin.

My arm-usb-ocd shows up as 15ba:0003 from a

ubuntu>lsusb

The vendor and product id numbers are in used in the cfg file for openocd to find the pod in a line: ft2232_vid_pid 0x15ba 0x0003

I had a heck of a time figuring out a cfg file becuase the examples I could find were for an older version of openocd.

Here is my .cfg file:

#my stm32 programming file, olimex arm-usb-ocd with STM32F103
#all flat here...
#source [find interface/olimex-arm-usb-ocd.cfg]
#----here's the stuff from the interface/olimex-arm-usb-ocd.cfg:----------
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG"
ft2232_layout olimex-jtag
ft2232_vid_pid 0x15ba 0x0003
#-------------------------------------------------------------------------
#-----here's the stuff from  board/olimexboardupdated.cfg-----------------
#from http://forum.sparkfun.com/viewtopic.php?t=10548
#they upgraded something...
jtag_khz 100
#jtag_khz 1000  seemed to make 0 difference in programming speed.

ft2232 latency 20
jtag_nsrst_delay 200
jtag_ntrst_delay 200

reset_config trst_and_srst

#jtag_device 4 0x1 0xf 0xe
jtag newtap stm32 cortexm3 -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x3ba00477
#jtag_device 5 0x1 0x1 0x1e
jtag newtap stm32 boundary -irlen 5 -ircapture 0x1 -irmask 0x1 -expected-id 0x16410041 

target create stm32.cortexm3 cortex_m3 -endian little -chain-position stm32.cortexm3


stm32.cortexm3	configure -work-area-virt 0 -work-area-phys 0x20000000 -work-area-size 16384 -work-area-backup 0

flash bank stm32x 0x08000000 0x00010000 0 0 0
#last number here is target number.. but I thought we refered to targets as names???

init
reset halt


#target cortex_m3 little reset_halt 0

#run_and_halt_time 0 30

#flash bank stm32x 0x08000000 0x00010000 0 0 0 
#-------------------------------------------------------------------------

puts [format "hello there, from openocd\n" ]

I’m working on a open source bootloader project… http://www.sourceforge.net/projects/sloadhost

that talks to the ST chips serial bootloader. But I think you’re better off getting the JTAG working first.

Cheers,

Alex

Hello guys,

Okay, here’s my simple example. No interrupts, sends a msg out USART2. The code is ugly, but simple as possible.

Blinks an LED attached to PC12… (with Morse code if you’ve got a scope)

Very rough. There may be some useful info about openocd in the README. I also put my .cfg file for the H103 board in the source tree.

I’m hoping to come up with sort of a HOWTO at some point.

I only realized just how convoluted a process I went thru to get this going this out when I tried to strip all the unnecessary stuff out of a simple example.

I don’t see how to attach files here, so I stuck the tar.gz file on my site at:

http://www.faveluke.com/interests.html

on the 2009-6-9 entry. File is called Blinky0.1.tar.gz.

Cheers, and good luck.

Alex

Alex,

Between a mother in the hospital and an ill-considered attempt to update during a thunderstorm, it looks like it will be another couple of days before I have any results to report. I do want to say I really appreciate the help and the quick response!

-Hugh

hsutherl:
partial output of dmesg:

[ 3685.904011] usb 3-1: new full speed USB device using uhci_hcd and address 2

[ 3686.102274] usb 3-1: configuration #1 chosen from 1 choice

[ 3686.546360] usbcore: registered new interface driver usbserial

[ 3686.548482] usbserial: USB Serial support registered for generic

[ 3686.549089] usbcore: registered new interface driver usbserial_generic

[ 3686.549093] usbserial: USB Serial Driver core

[ 3686.580803] usbserial: USB Serial support registered for FTDI USB Serial Device

[ 3686.581531] ftdi_sio: Ignoring serial port reserved for JTAG

[ 3686.582020] ftdi_sio 3-1:1.1: FTDI USB Serial Device converter detected

[ 3686.582613] ftdi_sio: Detected FT2232C

[ 3686.583103] usb 3-1: FTDI USB Serial Device converter now attached to ttyUSB0

[ 3686.583658] usbcore: registered new interface driver ftdi_sio

[ 3686.583662] ftdi_sio: v1.4.3:USB FTDI Serial Converters Driver

There's your problem: it thinks your JTAG dongle is a serial port, which it isn't. There should be no driver for the dongle at all.

(Edit)

Aargh. After slogging through all this, I finally take a closer look at Alex’s config file.

You can lead a horse to water… I’ll leave the post for its entertainment value.


Thanks for the replies, Alex and JJ.

I built openocd from 0.1.0 source. For lcdintegration’s benefit I’ll mention that I had to first add intrepid-proposed to my software sources (search the forums for info on missing headers and how to add proposed). Don’t know if jaunty has the same issue. Then I could manually

apt-get install libftdi-dev

All to no avail. Same result.

The arm-usb-ocd is a composite device with both a serial and a jtag port. So, should ftdi_sio register a serial driver for the serial “part” of the composite device, or leave it entirely alone? I was going to ask Alex if he would post what gets logged when he plugs in his device. I see he has already posted his lsusb output in the link he gives above. To my untrained eye it appears his device has a vendor ID of 0403 and device ID of 6001.

Here is my lsusb output.

hfs2@dt-a:~$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 15ba:0003 Olimex Ltd. OpenOCD JTAG
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 046d:c018 Logitech, Inc. Optical Wheel Mouse
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0d49:7350 Maxtor 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

lsusb -v output at http://www.overtracks.com/misc/openocd/ … _0612a.txt

I get the same vendor ID of 0x15ba and product ID of 0x0003 when I look at the device in XP. So it appears that Olimex has begun putting their own vendor and product ID into the arm-usb-ocd devices. (?)

I’ve not started browsing the openocd source files yet. (I didn’t really plan to dig in this deeply.) Or maybe there is a config file option that would handle this? I notice that one of the moderators of the AVR forums is OLIMEX. I wonder if it would be appropriate to post a query in there.

-Hugh

Hi,

I can’t remember if this “made it work” way back when, but I have had to add plugdev file entries to get usb devices working on my Ubuntu.

After I add these files I have to reboot :< I’m sure there’s a way to get the rules to rescan, but I haven’t found it yet. Anyways…

In my /etc/udev/rules.d directory, I’ve got a file named 45-ft2232.rules

faveluka@wanda:/etc/udev/rules.d$ cat 45-ft2232.rules 

BUS!="usb", ACTION!="add", SUBSYSTEM!=="usb_device", GOTO="kcontrol_rules_end"

SYSFS{idProduct}=="0003", SYSFS{idVendor}=="15ba", MODE="664", GROUP="plugdev"

LABEL="kcontrol_rules_end"

LABEL="kcontrol_rules_end"

I’m a member of group “plugdev” which means I have permissions to use the usb device files created when they’re when plugged in. At least I think this is how it works.

Cheers,

Alex

Thanks for taking so much time Alex. The .cfg file you posted helped me a LOT. Puzzling over that finally spurred me to look through the distribution and find the new syntax.

The first hurdle was the " A" at the end of the interface description, which I had copied over from the old .cfg file. Once that was fixed, openocd recognized the interface was there but gave me nothing but comm errors.

adding a line “jtag_khz 500” has made the unit work reliably. It seems to also work at 1000 khz, but not 2000. The same thing is true whether in windows or Linux.

I was able to step through a home-brew blinky prog (changing registers to reduce the #of steps), and flash a .hex file. All seemed well. To take my first baby half-step it seems I still need some assembler help, but I’ll post that in another thread.

Thanks for all the help!

-Hugh