Getting started - Partial success - what next?

STM32F103 Nucleo boards e.g. STM Nucleo F103RB
User avatar
sheepdoll
Posts: 236
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex
Contact:

Getting started - Partial success - what next?

Post by sheepdoll » Sat May 23, 2015 2:26 am

This is sort of a continuation from my introduction post.

The good news is that the Arduino_STM core and example repository I downloaded on this posting date works. I was able to successfully verify and download the blink sketch to my STM32F103 Nucleo.

The LED2 indicator does not blink, but the download completes with

Code: Select all

 ...
  5/5 pages written2015-05-22T18:47:49 INFO src/stlink-common.c: Flash written and verified! jolly good!
Since I use macports for installs I had to create a link from ln /opt/local/lib/libusb-1.0.0.dylib /usr/local/lib/libusb-1.0.0.dylib. I chose this method as I am not ready to hack the scripts yet. There is some code in the scripts to look for parts of the dfu-utils in both paths, but not libusb. This was documented in the installation wiki, so thanks to whomever did that. It is nice when an install just simply works.

I suspect that the LED does not blink, as the Nucleo is only "Arduino" in that it can physically mate to some shields.

Since these forums are young, I seem to be missing the postings by @madias relating on how to set up basic serial. (I have plenty of FTDI bridges if needed) Perhaps the instructions of what traces/jumpers were in a PM or on another forum. I have no problems sending a PM, I suspect others may want to use these boards too. I did download the graphic of the pin layout from the other thread, but am not quite sure how to use it

At this point I am open to suggestions as to what to do next?

-julie

User avatar
RogerClark
Posts: 7452
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Getting started - Partial success - what next?

Post by RogerClark » Sat May 23, 2015 11:45 pm

This probably wont be much help.

But we originally started as a thread on the Arduino.cc forum

http://forum.arduino.cc/index.php?topic=265904.0

However the thread ended up being too big to handle, so I setup this forum.

Normally Matthias would have probably get back to you, but I know he is busy with family things at the moment.
However if you PM @madias he may be able to find time to help

User avatar
sheepdoll
Posts: 236
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex
Contact:

Re: Getting started - Partial success - what next?

Post by sheepdoll » Sun May 24, 2015 1:02 am

That is the thread that lead me here 175 or so pages!

This is a big holiday weekend here in the states. So a lot of people are off enjoying life.

I have been fiddling with the setup, Still have no luck getting the LED to blink. I re-read some of the STM stuff, but I quickly get lost in areas that I do not have time for.

Turned on the verbose as per the blog posting on your web site under the F103 generic blink example. According to documentation on the Nucleo The LED is connected to D13 which is PA5 which may be on pin 21 or 34 according. I tried putting all these numbers into a copy of the blink sketch, I do not get errors on the compile/verify and it seems to upload. Seems what ever text I put in this field does not generate an error.

The upload completes and the stlink io led lashes red green and stays green.

I did download the fimware from the STM site. I was going to see if I could reload the demo. can not seem to get MBED to upload to this board. (Forgot the board was MBED compatible) Attempts to connect just give me build system down errors.

The firmare from the ST site is *.hex and the Arduino/hardware/Arduino_STM32/tools/macosx/stlink_upload seems to call with a bin file. Was looking for parameters to stlink_upload which lead me back here.

I have no Idea why I have so much trouble with ARM. I have been using AVR for over 15 years and never had any trouble getting things to work.

At this point I would just like to see if I can get stlink to flash a generic hex file such as the demo app.

-julie

User avatar
Rick Kimball
Posts: 1056
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Getting started - Partial success - what next?

Post by Rick Kimball » Sun May 24, 2015 1:29 am

What OS/X are you running. I have no hope of ever running this stuff on my 2009 iMac with 10.6.8 .. as it doesn't support the required drivers (cdc acm tty drivers). However I can use an FTDI USB-Serial device (alluding to why you might have been able to use avr stuff successfully) because there is an FTDI driver for my version of OS/X. I guess I could upgrade the OS/X on my iMac but I just run linux (granted not a normal usage).
-rick
-rick

User avatar
Rick Kimball
Posts: 1056
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Getting started - Partial success - what next?

Post by Rick Kimball » Sun May 24, 2015 1:48 am

With the NUCLEO board, it should show up as a Disk Drive on the mac. You can use the Arduino IDE to compile .. then find the sketchname.bin file in the temp directory and just drag and drop it on the "Nucleo Drive" (I have no idea what name it shows up as on a mac).. When you drag and drop a binary on the Nucelo drive it will flash that code on your f103 chip.
Last edited by Rick Kimball on Sun May 24, 2015 3:23 am, edited 1 time in total.
-rick

User avatar
sheepdoll
Posts: 236
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex
Contact:

Re: Getting started - Partial success - what next?

Post by sheepdoll » Sun May 24, 2015 3:11 am

Hi Rick;

This computer is still running 10.7 due to my need to access MIDI through quicklook. My other ones are running Yosemite.

As far as I can tell the Arduino_STM slink is flashing the 103. I was wanting to reload the demo code which I would either have to compile or figure out how to use stmlink to flash the .hex file. I forgot and had the 104 Nucleo connected and the arduino IDE erased the flash on it also, So I am pretty confident the Arduino_STM is installed an running. I just do not have a sketch that lets the 103 do anything useful like blink a LED or send back through the USB serial port.

Just for fun I attempted to drag the .hex file onto the Nucleo drive. This created a fail.txt file. Draging the bin from Arduino makes the stlink light blink then go red. The mac also complains I did not eject the disc correctly (given that MD util is probably attempting to write spotlight index files on it.)

If I get really frustrated I can drag out an XP laptop which has all the ST stuff loaded on it, but I think the payware demo compilers are outdated.

User avatar
RogerClark
Posts: 7452
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Getting started - Partial success - what next?

Post by RogerClark » Sun May 24, 2015 4:12 am

@sheepdoll

Does it look like the STLink is uploading from the IDE

BTW. Enable verbose in your prefs.

the other test you can do is go into /tools/maxosx/stlink and run st-flash from a terminal

I think it will tell you if stlink can connect to the board.

Edit

try ./st-util from the terminal.

I just tested it and one of my STLink devices was recognized but the other (a Nucleo F3) was not recognized.

I plugged my F3 nucleo into a PC (Win 7) and it did connect using STM's own STLink tool and showed version
V2.J20.M4 STM32 Debug+Mass storage
and have the option to update to
V2.J23.M7
which I thought may fix the problem, but didn't seem to :-(

as far as I can tell, STM don't support STLink on OSX, i.e I can't see any downloads on their site for OSX STLink :-( :-(

All the articles I can find that describe how to use STlink on OSX are using Texane-stlink, which is what we use.

I just tried recompiling the latest Texane - STLink and it didn't help

there is also a folder under the st-link src folder for an OSX driver, but I don't think my default you'd have those files (I it depends if you downloaded the zip of the repo or did git clone) called stlinkv1_macosx_driver


See https://github.com/texane/stlink/tree/m ... osx_driver

But I just tried following the instructions but it won't compile on my Mac as it looks like it only works on 10.6 and 10.7 and I'm running a newer version of OSX


I did think that Matthias (@madias) was using a mac, but perhaps he's running a virtual PC eg using parallels.



Just to recap. The STlink does work on OSX for some boards, however it looks like the firmware in the Nucleo which I have (and probably the firmware you have) is not compatible with OSX :-(

You could try posting to the Texane stlink issues on Github (Actually I'll do that)

Now things start to get a bit more interesting / tricky.

I'm not sure how techie you are, but I suspect the best option is to reflash the Stlink co processor on the Nucleo.

However I can't see an easy way for you do do that, unless you want to connect another one of your STM boards eg possibly one of your F4 boards to the F3 to act as a STLink

But its probably not worth going into detail about precisely how do do that unless you want to give it a shot. ;-)

User avatar
sheepdoll
Posts: 236
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex
Contact:

Re: Getting started - Partial success - what next?

Post by sheepdoll » Sun May 24, 2015 6:01 am

Here is what I get from the verbose download. I think everything is working The stlink flickers and stays green after the download.

Code: Select all

Sketch uses 5,772 bytes (5%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,104 bytes of dynamic memory.
/Users/Arethusa/Documents/Arduino/hardware/Arduino_STM32/tools/macosx/stlink_upload cu.usbmodemfd123 1 1EAF:0003 /var/folders/19/rz7506jh8xn7x1006s6s574h0000gn/T/build220135859000651271.tmp/Blinkstmxx.cpp.bin 
2015-05-23T20:04:56 INFO src/stlink-common.c: Loading device parameters....
2015-05-23T20:04:56 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410
2015-05-23T20:04:56 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
2015-05-23T20:04:56 INFO src/stlink-common.c: Attempting to write 5772 (0x168c) bytes to stm32 address: 134217728 (0x8000000)

Flash page at addr: 0x08000000 erased
Flash page at addr: 0x08000400 erased
Flash page at addr: 0x08000800 erased
Flash page at addr: 0x08000c00 erased2015-05-23T20:04:56 INFO src/stlink-common.c: Finished erasing 6 pages of 1024 (0x400) bytes
2015-05-23T20:04:56 INFO src/stlink-common.c: Starting Flash write for VL/F0/F3 core id
2015-05-23T20:04:56 INFO src/stlink-common.c: Successfully loaded flash loader in sram

Flash page at addr: 0x08001000 erased
Flash page at addr: 0x08001400 erased

  0/5 pages written
  1/5 pages written
  2/5 pages written
  3/5 pages written2015-05-23T20:04:56 INFO src/stlink-common.c: Starting verification of write complete

  4/5 pages written
  5/5 pages written2015-05-23T20:04:56 INFO src/stlink-common.c: Flash written and verified! jolly good!

This is the sketch I have tried.

Code: Select all

void setup() {
    // Set up the built-in LED pin as an output:
    pinMode(21, OUTPUT);
}

void loop() {
 digitalWrite(21, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(21, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}
In place of 21 I have used 13,D13,PA5 and 21. All verify and compile with no errors. These according to the STM Pdf are all references to LED2.
I still think the issue is the weird way Arm maps the pins to IO which I have never figured out. That there is some sort of init code that is not being compiled in for the Nucleo.

User avatar
RogerClark
Posts: 7452
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Getting started - Partial success - what next?

Post by RogerClark » Sun May 24, 2015 6:42 am

I'm not entirely sure about the LED etc on that board

In the code the pin numbers are converted to the real port and pin numbers using this enum

Code: Select all

enum {
    PA3, PA2, PA10, PB3, PB5, PB4, PB10, PA8,
    PA9, PC7, PB6, PA7, PA6, PA5, PB9,PB8,
    PA0, PA1, PA4, PB0, PC1, PC0,
    PC10,PC12,PB7,PC13,PC14,PC15,PC2,PC3,PC11,PD2,PC9,PC8,PC6,PC5,PA12,PA11,PB12,PB11,
    PB2,PB1,PB15,PB14,PB13
};
so that pin 0 is PA3, pin 1 is PA2 etc etc

This was the mapping defined by @madias as he was the first person to look at using the Nucleo F103RB

In the doc

http://www.st.com/st-web-ui/static/acti ... 105823.pdf

User LD2
: the green LED is a user LED connected to Arduino signal D13 corresponding to
MCU I/O PA5 (pin 21) or PB13 (pin 34) depending on the STM32 target.
So if the LED is on PA5 it would be on 13 (or you can just refer to it as PA5 (the real name of the pin))
Or try PB13 !

do you have a USB to Serial adaptor?

The first serial port appears to be mapped to pins 2 and 8, I'm not sure why @madias did that

But I recall some issue he had with Serial.

So if you did Serial.begin(115200)

and Serial.println("Hello world");

It should output on Hardware Serial 1 (PA9 and PA10) (Sorry I cant remember off the top of my head which one is RX and which one is TX,so if it doesnt work one way, swap the connections over)

madias
Posts: 813
Joined: Mon Apr 27, 2015 11:26 am
Location: Vienna, Austria

Re: Getting started - Partial success - what next?

Post by madias » Sun May 24, 2015 10:10 am

Just for short:
The nucleo port is almost finished by my side. I don't know if the files in repo are up to date, I've done a lot of changes the last weeks.
There was an issue with usb-serial (I did a private conversation with Roger) so that the serial debug is always "Serial2", the only solution is a to change core code so there is no possibility only changes this in the "variants" folder.
I remapped some serial pins for several reasons it's everything in my written manual. I had to do some minor soldering things to get the nucleo board running with STM32-arduino. A major thing is, that as default the quartz was not connected so no code would run (see again my manual)
Board LED is PA5 / D13 as in my pinout sheet: viewtopic.php?f=29&t=93

Post Reply