Pages

01/08/2017

Flashing MMDVM on an STM32 Nucleo using OS X


As you may already know from a previous post, I've been experimenting with MMDVM (Multi Mode Digital Voice Modem), software that can be used to operate a DMR radio hotspot or repeater. Historically I've been using a DVMega hotspot 'shield' on a Raspberry Pi, however I'm now taking it up a notch and building a 'proof of concept' DMR repeater.

The MMDVM Modem is made up of several components-

  • The interface board - Interfaces with the radios and performs the necessary filtering and amplification of the Tx and Rx Signals
  • The Modem - an embedded microcontroller for doing the analog to digital and digital to analog conversion and sampling.
  • The Host - usually a Raspberry Pi. Manages the modem and performs actions such as relaying DMR frames to the network.

The MMDVM software will run on several different platforms including the Arduino Due, the Teensy's, and the STM32 Nucleo. The DUE's are EoL, and the Teensy's are expensive, which left the STM32 as the logical option.

This guide is aimed at flashing the STM32 Nucleo board (STM32F446RE) for use with one of F0DEI's highly recommended MMDVM boards using MAC OS X. If you're using another MMDVM board, you may need to tweak the Config.h file accordingly.

I've not used an STM32 Nucleo before, so I had to do some research to figure out how to flash it. I've written up my findings below.


If you're using Windows I recommend F5UII's blog post here

The STM32 Nucleo


F0DEI's MMDVM Board

Install the required tools

Its assumed you've already got the Homebrew package manager installed on your Mac. If you haven't, you can find the instructions here

Once Homebrew is up and running its time to install the ARM tool chain. Open up a terminal and run the following commands-
brew tap PX4/homebrew-px4
brew update
brew install gcc-arm-none-eabi

You can then install st-link, a utility for working with the STM32-
brew install stlink

Clone the MMDVM repository

mkdir ~/Documents/Devel
cd ~/Documents/Devel
git clone https://github.com/g4klx/MMDVM.git

Get the ST library

You can download a modified version of the ST Library from here. Credit to CA6JAU for the library. Once downloaded, extract it into the MMDVM directory-
cd MMDVM
git clone https://github.com/juribeparada/STM32F4XX_Lib.git

Edit the configuration

Before flashing the STM32 its necessary to edit the default configuration. The config below is for one of F0DEI's boards, but should work for others with some minor edits. First of all, open the file for editing-

nano Config.h

Comment out the following line-
// For the ZUM V1.0 and V1.0.1 boards pin layout
#define ARDUINO_DUE_ZUM_V10

So it looks like this-
// For the ZUM V1.0 and V1.0.1 boards pin layout
// #define ARDUINO_DUE_ZUM_V10

Then uncomment the following line-
// For ST Nucleo-64 STM32F446RE board
// #define STM32F4_NUCLEO_MORPHO_HEADER

So it looks like this-
// For ST Nucleo-64 STM32F446RE board
#define STM32F4_NUCLEO_MORPHO_HEADER

If you're using the RSSI reporting feature or a Nextion display, you can also uncomment the following-
// Pass RSSI information to the host
// #define SEND_RSSI_DATA

// Use the modem as a serial repeater for Nextion displays
// #define SERIAL_REPEATER

Compile the software

Now the configuration is updated, its time to compile the software-
make nucleo

The files should then appear in the bin/ directory-

~/Documents/Devel/MMDVM$ ls bin/
outp.bin outp.elf outp.hex

Flash the STM32

Put the STM32 Nucelo into flash mode by pulling the Boot0 pin high. You can do this by using a jumper to link it to the 3.3v pin This seems unnecessary. 

Flash the .bin file-

st-flash write bin/outp.bin 0x08000000

You should see the following-

st-flash 1.4.0
2017-07-01T23:41:36 INFO src/common.c: Loading device parameters....
2017-07-01T23:41:36 INFO src/common.c: Device connected is: F446 device, id 0x10006421
2017-07-01T23:41:36 INFO src/common.c: SRAM size: 0x20000 bytes (128 KiB), Flash: 0x80000 bytes (512 KiB) in pages of 131072 bytes
2017-07-01T23:41:36 INFO src/common.c: Attempting to write 55716 (0xd9a4) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x0800c000 erasedEraseFlash - Sector:0x3 Size:0x4000
2017-07-01T23:41:38 INFO src/common.c: Finished erasing 4 pages of 16384 (0x4000) bytes
2017-07-01T23:41:38 INFO src/common.c: Starting Flash write for F2/F4/L4
2017-07-01T23:41:38 INFO src/flash_loader.c: Successfully loaded flash loader in sram
enabling 32-bit flash writes
size: 32768
size: 22948
2017-07-01T23:41:39 INFO src/common.c: Starting verification of write complete
2017-07-01T23:41:39 INFO src/common.c: Flash written and verified! jolly good!

Acknowledgements

With thanks to-
  • F0DEI - Designed the MMDVM board, provided support. To purchase one you can email him on- f...@orange.fr
  • F5UII  - This blog post greatly assisted with flashing the STM32
  • G4KLX - Author of MMDVM and MMDVMHost
  • CA6JAU - Heavily involved with development of MMDVM on the STM32 Platform
  • VE2GZI - Heavily involved with development of MMDVM on the STM32 Platform
  • And everyone else involved with the MMDVM project

3 comments:

  1. Thank you Matthew for this blog post about STM32F4 and MMDVM. All my developments are on macOS too. Regarding the STM32 Library, the updated source is in my GitHub:

    https://github.com/juribeparada/STM32F4XX_Lib

    There are also more information (a little outdated) in the MMDVM yahoo groups files sections (mmdvm_stm32_build_v2.pdf), and a copy of the STM32F4 Lib too.

    Regards,
    Andy CA6JAU.

    ReplyDelete
    Replies
    1. Hi Andy, thanks. I was planning on contacting you to see if the library was on github. I guess I should of searched! I will update the files shortly.

      Thanks for your help and contributions

      Delete
  2. This is the perfect thing and I hope that I will be able to assemble it easily. Thanks for sharing the guidelines in details.

    ReplyDelete