16
© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9 , 12. March 2014 Page 1 STM32-SDR Firmware Loading Instructions Figure 1: Front View of STM32-SDR Board, with Pin 1 of SWD Interface Noted Revision 0.9 12 March, 2014 Dave Miller, VE7PKE, [email protected] John P. Toscano, WØJT/5, [email protected]

STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf · For people who are curious about the source code, want to look at it casually, perhaps explore how it

Embed Size (px)

Citation preview

Page 1: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 1

STM32-SDRFirmware Loading Instructions

Figure 1: Front View of STM32-SDR Board, with Pin 1 of SWD Interface Noted

Revision 0.912 March, 2014Dave Miller, VE7PKE, [email protected] P. Toscano, WØJT/5, [email protected]

Page 2: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 2

What is covered in this manual

This manual will give information on how to program firmware into your STM32-SDR board. Your board will come pre-programmed with a version of firmware that was current at the time of assembly, but it’s very likely that you will want to either update what was shipped or install your own version. The software is Open Source, so you can customize it. That will not be covered in this manual. The hard part is creating a .hex file that actually works. Loading the software is the easy part.

The Open Source software is available on GitHub. Go to:https://github.com/STM32-SDR

From the main page, click on the link to STM32-SDR. This will take you to:https://github.com/STM32-SDR/STM32-SD

For people who are curious about the source code, want to look at it casually, perhaps explore how it works, etc., then the easiest way to get the source code from the next page is to download a zip file archive and extract the file onto a local drive of yours. For serious development work, you will want to use the GIT Repository approach which is an SCCS (source code control system), so that each of thecollaborators' modifications can be coordinated with the efforts which are being made by the rest of the developers before being committed to mainstream code.

This document will assume that you are in the first group, namely those who are interested in casual review of the source code by downloading the zip archive and extracting it locally. Code collaborators will get separate instructions on how to connect properly to the GIT repository.

Note that shortly we will also cover the case of the more typical user who has no interest in the source code, but just wants to update the firmware in their SDR to the most current version.

Page 3: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 3

On this web page, near the bottom right corner, look for a link entitled “Download Zip”. This will download a zipfile (archive) with all of the source code, to your chosen download directory. You can use any of a number of archive utilities, like PKZIP, 7-ZIP, AR, etc., to extract the files and sub-directories contained in the zipfile.

Page 4: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 4

Occasionally, the version posted on GitHub may lag behind the latest available version. If that is the case, and if you absolutely must have the latest and greatest source code, you will have to request that version from one of the members of the development team. If you don’t happen to be one of the development team members, the best approach is to send an email to [email protected] and request the latest stable version. Please try to keep these requests to a minimum, so the developers can concentrate on developing, i.e., improving the firmware by fixing errors and adding new features.

Most people don't need or want to inspect the source code, but instead will just want to obtain the firmware in complied form. When the developers prepare a new version, they will compile it into a HEX file and announce its availability on the Yahoo Group web page. Look in the “Conversations” linkfor a message announcing a new version of the software in compiled (HEX file) form.

https://groups.yahoo.com/neo/groups/stm32-sdr/info

This is the opening web page of the Yahoo interest group, with arrows pointing to both the “Conversations” link and the “Files” link.

The Conversations page on the Yahoo web site looks like this:https://groups.yahoo.com/neo/groups/stm32-sdr/conversations/messages

Page 5: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 5

If there is a new compiled firmware program is announced on the “Conversations” page, it should be available by going to the “Files” link from the main page:

https://groups.yahoo.com/neo/groups/stm32-sdr/filesFrom the Files page, you are looking for “Working Hex Files”, as shown below:

Page 6: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 6

What you need to program the STM32-SDR

Hardware: Programmer and Cable

The pre-compiled firmware is distributed in a hex file format. In order to load updated firmware into the STM32-SDR board, you need a “programmer”. Not the kind who eats pizza and only works after the sun goes down, but rather an adapter that connects between the 6-pin SWD header on the board and a personal computer’s USB port. You also may have to make a cable, as described below.

As for the physical interface electronics (USB to SWD), there are several options that have been tested and known to work, though there may be others that we have not tested. They range in price from less than $10 USD to about $34 USD at time of this writing. All four tested programming optionsuse the same software tools for transferring new firmware into the STM32-SDR board.

We will now discuss the programming hardware, and the connection cables that will be needed. Note that you will need to connect your programmer (ST-LINK/V2 or Discovery Board) to a personal computer running the Windows operating system. ST Microsystems does not support either native Macintosh or Linux operating systems.

Option 1: ST-Link/V2Manufacturer’s Part Number: S T -LINK/V2Digi-Key Part Number: 497-10484-ND, $21.25 USD as of February 2014

The ST-Link/V2 is nicely packaged and protected, and might be a good choice if you are going to be reprogramming frequently, or developing your own software.

Figure 2: ST-Link/V2 Kit

Option 2: STM32F407 Discovery BoardManufacturer’s Part Number: STM32F4DISCOVE R YDigiKey Part Number: 497-11455-ND, $14.90 USD asof February 2014

This board was the inspiration for the STM32-SDR project. The STM32F407 CPU on this board is the same as the CPU on the STM32-SDR board.

Figure 3: STM32F407 Discovery Board

Page 7: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 7

Option 3: STM32F0 Discovery BoardManufacturer’s Part Number: STM32F0DISCOVE R YDigiKey Part Number: 497-12876-ND, $8.86 USD as of February 2014

This, by the way, is the least expensive of all the options listed here for a programming tool for the STM32-SDR board.

Figure 4: STM32F0 Discovery Board

Option 4: STM32F29 Discovery BoardManufacturer’s Part Number: STM32F429I-DISCOVERYDigiKey Part Number: 497-13898-ND, $33.60 USD asof February 2014

This is the most expensive of the four options presented. It has a faster CPU, twice as much flash memory, and an LCD display that is not compatible with the LCD used on the STM32-SDR board. Therefore, these extra features are superfluous to theSTM32-SDR project, but they may come in handy if you want to use this Discovery board for other purposes when it is not busy being used to load a new program into the STM32-SDR board.

Figure 5: STM32F29 Discovery Board

It may seem a bit wasteful to buy a complete Discovery Board simply to provide the ST-Link interface,but these board are very inexpensive options, and you could also experiment with the Discovery board in other projects when it is not busy being used to program the STM32-SDR board. All four options are made by ST Microsystems , the fine people that make the DSP chip that is used in this project. There are many sources for these programming hardware tools. Last time I checked, the vendor that provides the LCD display also sells at least two of the options. I have found that a distributor like Digi-Key usually delivers faster and may have a better price. You can search the vendors’ web sites using the part numbers listed above.

If you go with options 2, 3, or 4, you will need a USB-A Male to Micro USB-B Female cable to connectbetween your PC and the Discovery board. (Option 1 includes such a cable.) For Option 1, you will need a cable to go from the 20-pin header on the ST-Link/V2 device to the 6-pin SWD header on the SDR board. As discussed below, there is an alternative, using an accessory board and a pair of female connectors, which eliminates the need for this cable. For options 2, 3, or 4, you will need a cable with a six-position female connector on each end, to go between the Discovery board and the STM32-SDR board. Both boards have a 6-pin single-row male header with pins spaced 0.1” apart. You will need to make or buy a cable to connect any of the four programmers to the STM32-SDR board’s SWD connector. I have found that an old IDE disk drive cable, even though it has more pin

Page 8: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 8

positions than needed, will work just fine, once you get it plugged in correctly. Note from Figure 1 which end of the 6-pin header is considered to be Pin 1. The wiring of this cable is shown in Figure 6, below, although it is extremely straightforward. You need two 6-position female housings, Digi-Key P/N A26967-ND, and twelve compatible pins, Digi-Key P/N 2-87195-6-ND. Crimp and/or solder a pin to each end of 6 wires, and insert the 6 wires into each of the two housings to make one cable. See Figures 6 and 7 below.

Figure 6: One of two 6-position female housings and corresponding pins for SWD cable

Figure 7: 6-Pin to 6-Pin Cable for Discovery to STM32-SDR Programming

If you use Option 1 (the ST-Link/V2), you will need a different cable. One end will be the same as is used by the Discovery Board option (Figures 6 and 7), but the other end needs a 2x10 position female housing instead. You will only need 7 pins for the 20-position connector, however, not all 20 pins. The housing is Digi-Key P/N 952-2027-ND and the pins it uses are Digi-Key P/N 952-2159-ND. See Figure 9 below. One end of the cable has 6 pins crimped and/or soldered onto 6 wires and inserted into the 6-pin housing. The other end of the cable has 7 pins crimped and/or soldered onto the 6 wires and inserted into 7 specific positions of the 20-position connector, as shown in the wiring diagram below (Figure 10). (One wire from the 6-pin SWD connector end goes to two sockets on the ST-Link/V2 20-conductor socket end.)

Figure 9: 20-Pin Connector Shell and Corresponding Female Pins For ST-Link/V2

Page 9: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 9

Figure 10: ST-Link/V2 Programmer to SWD Connector Cable

There is another option if you plan to use the ST-Link/V2. There is an accessory PC board available that eliminates the need to build this cable. The accessory board mounts a 2x10 female header, like Digi-Key P/N S6106-ND on one side, which plugs into the ST-Link/V2 programmer, and a 1x6 female header, like Digi-Key P/N S7039-ND or 1212-1186-ND on the other side, which plugs into the SWD pins on the STM32-SDR board. With this accessory board, no cable is needed between the ST-Link/V2 programmer and the STM32-SDR board.

Figure 11: 10x2 and two styles of 6x1 Connectors for ST-Link Accessory Board

Figure 12: Building the Accessory Board for the ST-Link/V2

Page 10: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 10

Figure 13: Attaching the Accessory Board to the ST-Link/V2

Figure 12 shows how the accessory board is built. Figure 13 shows how the accessory board plugs into the ST-Link/V2 device. Figure 14 shows how the ST-Link/V2 plus the accessory board plug into the STM32-SDR board.

Figure 14: Attaching the ST-Link/V2 and Accessory Board to the STM32-SDR

Connect the SWD port of the STM32-SDR board to the ST-Link/V2 programmer (Option 1), or via a cable to the SWD port on the Discovery board (Options 2, 3, or 4). For Options 2, 3, or 4, remove both jumpers on CN3 on the Discovery board, as shown in Figure 15. This allows the Discovery Board to act as a programmer for the STM32-SDR board. If you fail to remove the jumpers, you would be loading the hex file into the Discovery board instead of into the STM32-SDR board!

Figure 15: CN3Jumpers

Page 11: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 11

Software

To load firmware into the STM32-SDR board, we use the STM32 ST Link Utility. You will need both the Windows USB-to-SWD device driver, and the utility program. Both of these programs require a computer running a modern copy of Windows. I have not tried to see if they work using any form of virtualization. If you have success, please let me know and I will update the documents. I do most of my programming on my Macbook Pro, Boot Camped into Windows 7. Dropping a note to ST might encourage them to support other options such as OSX or Linux.

Links to software tools for programming ST microcontrollers:ST-Link USB Driver for Windows 7, Windows Vista, and Windows XP ST-Link USB Driver for Windows 8ST-Link Utility

If those links don’t work, go to ST.com, and do a search for the files, because they may have been moved since this manual was written. Follow the directions associated with the file downloads to set up your programmer.

After you install the STLINK USB Driver (Discovery Board must be plugged in), go to the Windows Device Manager to ensure that the software driver and the Programmer are operating properly, as shown in Figure 16. Look under the Universal Serial Bus Controllers list. If your chosen programmerdevice (Discovery Board or ST-Link/V2) isnot there, or if it is showing a question mark or a red X, you have to fix it, reinstall it, etc...

Note: the STM32 Link Utility version changesregularly. These screen captures were from Version 2.4.

Figure 16: Device Manager view of programmerunder Windows 7

A few points based on feedback from some of the early users of this document. The comments related to using a STM32F4 Discovery Board and may make your life easier.

From Tom, VE7DID:

1. First, follow the instructions on the "Getting Started" information sheet which is packaged with the STM32F4-Discovery, to get the Discovery Board working.

2. Once the Discovery board is verified (LEDs flash, etc.), power down the board and remove the 2 jumpers on CN3.

3. Connect the cable as shown in Figure 7, to connect up the Discovery board to the STM32-SDR board.

Thanks, Tom.

Page 12: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 12

Don’t forget to get a copy of the hex file you want to use. The first section of this manual explains where you might locate a copy of the hex file.

Once the hardware and cabling have been attached, and the .hex firmware file has been obtained, it is time to program. The STM32-SDR must be powered up (5V) and the 6-pin connector attached to SWD, carefully noting which end of the connector is the Pin 1 position. When you plug in the programmer to your PC, it may ask you to update its firmware. Follow any on-screen directions.

Sample programming session

Step 1: Launch the program as shown in Figure 17. You should see the opening screen shown in Figure 18.

Figure 17, Launch the ST-Link Utility Program

Figure 18: ST-Link Utility Start-Up Screen

Step 2: Open the Hex File (Menu toolbar: File | Open file…)

Figure 19: File | Open File Dialog to open a hex file

Page 13: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 13

Step 3: Select the proper Hex file, and click on the Open button.

Figure 20: Selecting which hex file to open

After hitting Open, look in the status window. You should see something like:

That means you have the file open.

Step 4: Tell the software to logically connect to the STM32-SDR board using the (Target | Connect) command from the top toolbar.

Figure 21: Issuing the Target | Connect command

Page 14: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 14

If you have done everything correctly to this step, you will see (in the status window) the blue message, “Connected via SWD”

.

Figure 22: Acknowledgment of software connectionto STM32-SDR board

In the future, you may skip Step 4, and just continue on to the programming step. But this time, ensure that you have everything correct.

Step 5: On the menu toolbar, select (Target | Program & Verify).

Figure 23: Initiating the downloading of the hex file to the STM32-SDR board

Page 15: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 15

You should see this screen:

Figure 24: Download ready to begin

Step 6: Hit the Start button to begin the process

You should see this:

Figure 25: Download of firmware underway

After programming, verification is performed. You should see a screen similar to this:

Figure 26: Verification of uploaded firmware underway

Page 16: STM32-SDRstm32-sdr.com/resources/STM32-SDR-Firmware-Loading-Manual.pdf ·  For people who are curious about the source code, want to look at it casually, perhaps explore how it

© 2014 by Dave Miller, VE7PKE, STM32-SDR Firmware Installation Manual, Revision 0.9, 12. March 2014 Page 16

After successful verification, you will see a screenlike this:

Figure 27: Verification was successful

Once it is all done, the program returns to the screen shown in Figure 28, and the message in the status box tells you that program uploading is done and that the upload has been verified. The success indication is seen in the green text in Figure 28, below.

Figure 28: Status screen after successful firmware upload and verification

Since the “Reset after programming” checkbox was selected (see Figure 24), the STM32-SDR board performs a hardware reset, which causes the STM32-SDR welcome screen to appear, proving that you have been successful. Now, you can disconnect the programmer and start using the radio.

Refer to the STM32-SDR User Manual for assistance with what to do next, namely how to OPERATEthe radio!