This project tries to run OpenDNP3 on a Texas Instruments MSP432P401R Launchpad acting as an outstation. This merely a test, but the code is shared here in response to this issue.
CMake is used to generate the makefile this project. The project uses the GCC compiler, because I couldn't make it compile with TI's compiler. Since it involves cross-compiling, it is a bit more complicated to use. Follow these steps and you should be fine.
- Download and install the latest GCC Package for the MSP432 from TI's website. Be sure to download the MSP432 package, not the MSP430.
- Download the latest GNU ARM Embedded Toolchain and extract it in the
arm_compiler
directory inside the TI package directory. - Clone this repository using
git clone --recursive https://github.com/emgre/opendnp3msp432.git
. The recursive flag is mandatory in order to download OpenDNP3. - Create a
build
directory,cd
into it, then runcmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE="../msp432-toolchain.cmake" -DTI_INSTALL_DIR="/path/to/TI/msp432_gcc/" ..
where you change the path to the TI folder for the appropriate one, and change the generator according to your platform (this code was only tested on a Windows machine, that's why the generator is a MingW makefile. On a Unix system, "Unix Makefiles" should be the right generator). If CMake complains about not finding the make program (if you haven't set it in your PATH variables), you can specify it by adding-DCMAKE_MAKE_PROGRAM="path/to/make"
. - Run the
make
in the build directory to compile the executable.
To debug, follow the steps in the doc file available from TI. Briefly, it involes doing:
- Installing the required drivers for the MSP432 Launchpad.
- Connecting the MSP432 Launchpad to the computer.
- Run
gdb_agent_console -f MSP432 xds110_msp432_jtag.dat
fromINSTALL_DIR/emulation/common/uscif
. - Run
arm-none-eabi-gdb "path/to/OpenDNP3.out"
. - In GDB, run
target remote :55000
,load
(this takes a while...),monitor reset
. Then, you're good to go. The standard GDB commands are available.
Note that the GDB agent made by TI does not specify the memory map. Therefore, placing breakpoints will fail because the code is executed from the Flash and GDB tries to insert software breakpoints. In order to force it using hardware breakpoints, you can do mem 0 0 ro
to specify that all the memory is read-only. A proper memory map could help you modify variables at runtime.
Simply build and flash the MSP432, then connect a master DNP3 on serial port COMx (mine is COM3) with a baudrate of 9600 and standard UART settings. The master link layer address is 1 and the outstation link layer address is 1024. I personnaly used the master demo of OpenDNP3 and modified 2-3 lines to get it running with the desired settings.