cross compiling to Beagle Bone Black (Angstrom Linux)

2,008 views
Skip to first unread message

Daniel

unread,
Jun 19, 2013, 11:48:17 AM6/19/13
to automatak...@googlegroups.com
Hi,

I would like to evaluate OpenDNP3 with the TI arm cortex A8 processor (BeagleBone Black).

I have managed to compile and install the DNP3 libraries on the BeagleBone Black (BBB), but I couldn't test if it is working it yet. I installed the boost 1.53 libraries from the packagemanager and compiled the DNP3 libraries directly on the BBB and it all when fine. I have found that when simply running ./configure, the libraries would not compile although I have boost 1.53 installed. When running ./configure CXXFLAGS=-DOPENDNP3_BOOST_TIMER_PATCH then the libraries installed correctly.

However, I get an error when I try to compile dnp3test (using make check). When doing "make check", it runs for a while and ends with:

libtool: link: g++ -I/usr/include -DBOOST_TEST_DYN_LINK -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_REGEX_NO_LIB -D_GLIBCXX_USE_NANOSLEEP -I./cpp/include -DOPENDNP3_BOOST_TIMER_PATCH -std=gnu++11 -o .libs/dnp3test cpp/tests/dnp3test-AppLayerTest.o cpp/tests/dnp3test-AsyncPhysBaseTest.o cpp/tests/dnp3test-AsyncPhysTestObject.o cpp/tests/dnp3test-AsyncSerialTestObject.o cpp/tests/dnp3test-AsyncTestObjectASIO.o cpp/tests/dnp3test-AsyncTestObject.o cpp/tests/dnp3test-BufferHelpers.o cpp/tests/dnp3test-BufferTestObject.o cpp/tests/dnp3test-ComparingDataObserver.o cpp/tests/dnp3test-FlexibleDataObserver.o cpp/tests/dnp3test-DNPHelpers.o cpp/tests/dnp3test-LinkLayerRouterTest.o cpp/tests/dnp3test-LinkLayerTest.o cpp/tests/dnp3test-LogTester.o cpp/tests/dnp3test-LoopbackPhysicalLayerAsync.o cpp/tests/dnp3test-LowerLayerToPhysAdapter.o cpp/tests/dnp3test-MockAppLayer.o cpp/tests/dnp3test-MockAppUser.o cpp/tests/dnp3test-MockExecutor.o cpp/tests/dnp3test-MockFrameSink.o cpp/tests/dnp3test-MockLowerLayer.o cpp/tests/dnp3test-MockPhysicalLayerAsync.o cpp/tests/dnp3test-MockPhysicalLayerMonitor.o cpp/tests/dnp3test-MockUpperLayer.o cpp/tests/dnp3test-PhysicalLayerWrapper.o cpp/tests/dnp3test-PhysLoopback.o cpp/tests/dnp3test-RandomizedBuffer.o cpp/tests/dnp3test-SlaveTestObject.o cpp/tests/dnp3test-StopWatch.o cpp/tests/dnp3test-TestAPDU.o cpp/tests/dnp3test-TestAPDUWriting.o cpp/tests/dnp3test-TestAppLayer.o cpp/tests/dnp3test-TestASIO.o cpp/tests/dnp3test-TestASIOThreadPool.o cpp/tests/dnp3test-TestCastLongLongDouble.o cpp/tests/dnp3test-TestChangeBuffer.o cpp/tests/dnp3test-TestCommandTypes.o cpp/tests/dnp3test-TestCRC.o cpp/tests/dnp3test-TestDatabase.o cpp/tests/dnp3test-TestEnhancedVtoRouter.o cpp/tests/dnp3test-TestEventBufferBase.o cpp/tests/dnp3test-TestEventBuffers.o cpp/tests/dnp3test-TestLinkFrameDNP.o cpp/tests/dnp3test-TestLinkLayer.o cpp/tests/dnp3test-TestLinkLayerRouter.o cpp/tests/dnp3test-TestLinkReceiver.o cpp/tests/dnp3test-TestLinkRoute.o cpp/tests/dnp3test-TestLog.o cpp/tests/dnp3test-TestMisc.o cpp/tests/dnp3test-TestObjects.o cpp/tests/dnp3test-TestPackingUnpacking.o cpp/tests/dnp3test-TestParsing.o cpp/tests/dnp3test-TestPhysicalLayerAsyncBase.o cpp/tests/dnp3test-TestPhysicalLayerAsyncSerial.o cpp/tests/dnp3test-TestPhysicalLayerAsyncTCP.o cpp/tests/dnp3test-TestPhysicalLayerLoopback.o cpp/tests/dnp3test-TestPhysicalLayerMonitor.o cpp/tests/dnp3test-TestShiftableBuffer.o cpp/tests/dnp3test-TestSlave.o cpp/tests/dnp3test-TestSlaveEventBuffer.o cpp/tests/dnp3test-TestStartBoostUTF.o cpp/tests/dnp3test-TestTime.o cpp/tests/dnp3test-TestTimers.o cpp/tests/dnp3test-TestTransportLayer.o cpp/tests/dnp3test-TestTransportLoopback.o cpp/tests/dnp3test-TestTransportScalability.o cpp/tests/dnp3test-TestTypes.o cpp/tests/dnp3test-TestUtil.o cpp/tests/dnp3test-TestVtoInterface.o cpp/tests/dnp3test-TestVtoRouter.o cpp/tests/dnp3test-TestVtoWriter.o cpp/tests/dnp3test-Timeout.o cpp/tests/dnp3test-TransportIntegrationStack.o cpp/tests/dnp3test-TransportLoopbackTestObject.o cpp/tests/dnp3test-TransportScalabilityTestObject.o cpp/tests/dnp3test-TransportStackPair.o cpp/tests/dnp3test-TransportTestObject.o cpp/tests/dnp3test-WrappedTcpPipe.o cpp/tests/dnp3test-TestAsyncTask.o cpp/tests/dnp3test-IntegrationTest.o cpp/tests/dnp3test-TestDNP3Manager.o cpp/tests/dnp3test-VtoIntegrationTestBase.o cpp/tests/dnp3test-TestIntegration.o cpp/tests/dnp3test-MasterTestObject.o cpp/tests/dnp3test-ResponseLoaderTestObject.o cpp/tests/dnp3test-TestCommandHelpers.o cpp/tests/dnp3test-TestCommandTask.o cpp/tests/dnp3test-TestMaster.o cpp/tests/dnp3test-TestResponseLoader.o cpp/tests/dnp3test-MockTimeSource.o  -L/usr/lib ./.libs/libopendnp3.so /usr/lib/libstdc++.so -lm -lboost_system -lboost_unit_test_framework
/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.7.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: cpp/tests/dnp3test-AsyncPhysTestObject.o: undefined reference to symbol 'pthread_getspecific@@GLIBC_2.4'
/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.7.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: note: 'pthread_getspecific@@GLIBC_2.4' is defined in DSO //lib/libpthread.so.0 so try adding it to the linker command line
//lib/libpthread.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[1]: *** [dnp3test] Error 1
make[1]: Leaving directory `/home/root/dnp3'
make: *** [check-am] Error 2
root@beaglebone:~/dnp3# 

Any advice?

J Adam Crain

unread,
Jun 21, 2013, 2:21:52 PM6/21/13
to automatak...@googlegroups.com
Hi Daniel,

I think you are really close. Add the following to your configure step:

./configure LDFLAGS=-lpthread

I think your toolchain isn't linking pthread by default.

Please let me know if this helps, and let me know if you get this running on BeagleBone!

thanks,
Adam

Daniel

unread,
Jun 22, 2013, 5:25:20 AM6/22/13
to automatak...@googlegroups.com
Hi Adam,

Thanks! I am compiling on the BBB itself and will give feedback once it's done (it takes a while). I prefer the BBB over the RPi since the arm cortex process on the BBB is commercially available from TI (with documentation) and the BBB has all the peripherals already on board without having to add additional capes or "shields". So this makes a nice starting point to demo the capabilities and communications of the embedded device before integrating into other products. 

I have tried to cross compile as well, but without success. I managed to cross compile the libraries but I was unable to compile the test suite. So I could not test the libs on the BBB yet. I will include the flag in the cross compilation as well and let you know if it works (cross compiler installed on different pc so will have to test that later). 

Then on another topic. Do you have bindings for python? I see the original project has bindings for python via swig. I am playing with the two branches but this one seems to be working better so far. The original project gets halfway through the compilation on the BBB and then runs out of space and I had difficulty getting it to cross compile as well. Anyway, would be nice if I could use python as well.

Regards
Daniel

J Adam Crain

unread,
Jun 22, 2013, 9:39:38 AM6/22/13
to automatak...@googlegroups.com
Hi Daniel,

This missing "-lpthread" has come up in enough environments that I think I need to change it to be included by default... or at least understand why some *nix environments do it automatically and others do not.

So, here's the story on the bindings...

The original project used Swig for both, but also did a poor job for both.  While I never used the python bindings myself, I suffered while using the old java bindings considerably.. The problem is that Swig was never intended to wrap a complex library like this that has bi-directional calls from  Java <=> C++.   It resulted in a lot of crazy thread generation and insane garbage collection pitfalls and seg-faults if you did anything wrong.   When I forked the projects, I dumped Swig and hand-coded the JNI bindings to get rid of all of these issues.

This branch is intended to be a high-reliability "reboot" of the other branch:  better interfaces, better performance, better docs, etc.

So, sadly, there are no Python bindings for this branch. They could be written by hand, but I have very limited Python experience.  If anyone is willing to take this on, I could assist with input on the interface and required tests, but they'd have to be on par with the Java bindings in terms of docs, uniformity, etc to be accepted.

-Adam

Daniel

unread,
Jun 23, 2013, 3:15:13 AM6/23/13
to automatak...@googlegroups.com
Hi Adam,

Ok, the libs compiled (make) and installed (make install) correctly, or so it seems. The test suite also compiled (make check), but, when I run dnp3test it terminates with an error:

root@beaglebone:~/Downloads/dnp3# ./dnp3test
Running 460 test cases...
pure virtual method called
terminate called without an active exception
pure virtual method called
terminate called recursively
unknown location(0): fatal error in "CleanConstructionDestruction": signal: SIGABRT (application abort requested)
Aborted

Regards

J Adam Crain

unread,
Jun 23, 2013, 1:24:55 PM6/23/13
to automatak...@googlegroups.com
Ugh. When I have gotten something like this in the past, it usually means I had a broken build... In the past a clean and recompilation has fixed it. I can't promise this will work though, it's just a hunch.

Have you tried running the demo programs? (demo-master & demo-outstation)

This would give you another indication besides the tests whether things are OK.

What's the toolchain and Linux distro on the BB? Does BB run GCC >= 4.7.x?

-Adam

J Adam Crain

unread,
Jun 23, 2013, 1:33:31 PM6/23/13
to automatak...@googlegroups.com
Another bit of advice... If all else fails, try compiling with CXXFLAGS=-g. We might get more info from debug mode.

The test programs also accepts arguments since it's the boost unit test framework:


--show_progress
--log_level

These two parameters will hopefully allow you to further figure out what's going on.

-Adam

Daniel

unread,
Jun 24, 2013, 5:41:46 AM6/24/13
to automatak...@googlegroups.com
Hi Adam,

I have compiled and installed the libraries with -lpthread. It didn't produce any error that I am aware of and the libopendnp3 libraries are present in /usr/lib

The test suite continues to fail when executed.

I have compiled the outstation demo and it also fails when executed, see below:

root@beaglebone:~/Downloads/dnp3_automatak_compiled_naweek/cpp/demos/outstation# autoreconf -f -i
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux'.
libtoolize: copying file `build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `../../../m4'.
libtoolize: copying file `../../../m4/libtool.m4'
libtoolize: copying file `../../../m4/ltoptions.m4'                                                                                  
libtoolize: copying file `../../../m4/ltsugar.m4'                                                                                    
libtoolize: copying file `../../../m4/ltversion.m4'                                                                                  
libtoolize: copying file `../../../m4/lt~obsolete.m4'                                                                                

root@beaglebone:~/Downloads/dnp3_automatak_compiled_naweek/cpp/demos/outstation# ./configure LDFLAGS=-lpthread CXXFLAGS=-g           
checking for a BSD-compatible install... /usr/bin/install -c                                                                         
checking whether build environment is sane... yes                                                                                    
checking for a thread-safe mkdir -p... /bin/mkdir -p                                                                                 
checking for gawk... gawk                                                                                                            
checking whether make sets $(MAKE)... yes                                                                                            
checking for style of include used by make... GNU                                                                                    
checking for g++... g++                                                                                                              
checking whether the C++ compiler works... yes                                                                                       
checking for C++ compiler default output file name... a.out                                                                          
checking for suffix of executables...                                                                                                
checking whether we are cross compiling... no                                                                                        
checking for suffix of object files... o                                                                                             
checking whether we are using the GNU C++ compiler... yes                                                                            
checking whether g++ accepts -g... yes                                                                                               
checking dependency style of g++... gcc3                                                                                             
checking whether g++ supports C++11 features by default... no                                                                        
checking whether g++ supports C++11 features with -std=gnu++11... yes                                                                
checking for pthread_create in -lpthread... yes                                                                                      
checking for boostlib >= 1.45.0... yes                                                                                               
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking build system type... armv7l-unknown-linux-gnueabi
checking whether the Boost::System library is available... yes
checking for exit in -lboost_system... yes
checking whether the Boost::ASIO library is available... yes
checking whether the Boost::Unit_Test_Framework library is available... yes
checking host system type... armv7l-unknown-linux-gnueabi
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/arm-angstrom-linux-gnueabi/bin/ld
checking if the linker (/usr/arm-angstrom-linux-gnueabi/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 32768
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert armv7l-unknown-linux-gnueabi file names to armv7l-unknown-linux-gnueabi format... func_convert_file_noop
checking how to convert armv7l-unknown-linux-gnueabi file names to toolchain format... func_convert_file_noop
checking for /usr/arm-angstrom-linux-gnueabi/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/arm-angstrom-linux-gnueabi/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/arm-angstrom-linux-gnueabi/bin/ld
checking if the linker (/usr/arm-angstrom-linux-gnueabi/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/arm-angstrom-linux-gnueabi/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/arm-angstrom-linux-gnueabi/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
configure: --with-lcov=no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
config.status: executing libtool commands
root@beaglebone:~/Downloads/dnp3_automatak_compiled_naweek/cpp/demos/outstation# make
depbase=`echo DemoMain.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
g++ -DPACKAGE_NAME=\"opendnp3demos\" -DPACKAGE_TARNAME=\"opendnp3demos\" -DPACKAGE_VERSION=\"1.1.0\" -DPACKAGE_STRING=\"opendnp3demos\ 1.1.0\" -DPACKAGE_BUGREPORT=\"x...@automatak.com\" -DPACKAGE_URL=\"\" -DPACKAGE=\"opendnp3demos\" -DVERSION=\"1.1.0\" -DHAVE_LIBPTHREAD=1 -DHAVE_BOOST=/\*\*/ -DHAVE_BOOST_SYSTEM=/\*\*/ -DHAVE_BOOST_ASIO=/\*\*/ -DHAVE_BOOST_UNIT_TEST_FRAMEWORK=/\*\*/ -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I.    -lopendnp3 -g -std=gnu++11 -MT DemoMain.o -MD -MP -MF $depbase.Tpo -c -o DemoMain.o DemoMain.cpp &&\
mv -f $depbase.Tpo $depbase.Po
/bin/sh ./libtool --tag=CXX   --mode=link g++ -lopendnp3 -g -std=gnu++11 -L/usr/lib -lpthread -o outstationdemo DemoMain.o -lboost_system -lpthread 
libtool: link: g++ -g -std=gnu++11 -o outstationdemo DemoMain.o  /usr/lib/libopendnp3.so -L/usr/lib /usr/lib/libstdc++.so -lm -lboost_system -lpthread

root@beaglebone:~/Downloads/dnp3_automatak_compiled_naweek/cpp/demos/outstation# ./outstationdemo
Segmentation fault

root@beaglebone:~/Downloads/dnp3_automatak_compiled_naweek/cpp/demos/outstation# 

Daniel

unread,
Jun 24, 2013, 5:43:14 AM6/24/13
to automatak...@googlegroups.com
Also,

here is the output for the masterdemo:

root@beaglebone:~/Downloads/dnp3_automatak_compiled_naweek/cpp/demos/master# autoreconf -f -i
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux'.
libtoolize: copying file `build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `../../../m4'.
libtoolize: copying file `../../../m4/libtool.m4'
libtoolize: copying file `../../../m4/ltoptions.m4'
libtoolize: copying file `../../../m4/ltsugar.m4'
libtoolize: copying file `../../../m4/ltversion.m4'
libtoolize: copying file `../../../m4/lt~obsolete.m4'

root@beaglebone:~/Downloads/dnp3_automatak_compiled_naweek/cpp/demos/master# ./configure
root@beaglebone:~/Downloads/dnp3_automatak_compiled_naweek/cpp/demos/master# make
depbase=`echo DemoMain.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
g++ -DPACKAGE_NAME=\"opendnp3masterdemo\" -DPACKAGE_TARNAME=\"opendnp3masterdemo\" -DPACKAGE_VERSION=\"1.1.0\" -DPACKAGE_STRING=\"opendnp3masterdemo\ 1.1.0\" -DPACKAGE_BUGREPORT=\"xxxatautomatak.com\" -DPACKAGE_URL=\"\" -DPACKAGE=\"opendnp3masterdemo\" -DVERSION=\"1.1.0\" -DHAVE_LIBPTHREAD=1 -DHAVE_BOOST=/\*\*/ -DHAVE_BOOST_SYSTEM=/\*\*/ -DHAVE_BOOST_ASIO=/\*\*/ -DHAVE_BOOST_UNIT_TEST_FRAMEWORK=/\*\*/ -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I.    -lopendnp3 -g -O2 -std=gnu++11 -MT DemoMain.o -MD -MP -MF $depbase.Tpo -c -o DemoMain.o DemoMain.cpp &&\
mv -f $depbase.Tpo $depbase.Po
DemoMain.cpp: In function 'int main(int, char**)':
DemoMain.cpp:101:29: error: aggregate 'std::promise<opendnp3::CommandResponse> selectResult' has incomplete type and cannot be defined
make: *** [DemoMain.o] Error 1

root@beaglebone:~/Downloads/dnp3_automatak_compiled_naweek/cpp/demos/master# 
g++ -DPACKAGE_NAME=\"opendnp3demos\" -DPACKAGE_TARNAME=\"opendnp3demos\" -DPACKAGE_VERSION=\"1.1.0\" -DPACKAGE_STRING=\"opendnp3demos\ 1.1.0\" -DPACKAGE_BUGREPORT=\"xxx@automatak.com\" -DPACKAGE_URL=\"\" -DPACKAGE=\"opendnp3demos\" -DVERSION=\"1.1.0\" -DHAVE_LIBPTHREAD=1 -DHAVE_BOOST=/\*\*/ -DHAVE_BOOST_SYSTEM=/\*\*/ -DHAVE_BOOST_ASIO=/\*\*/ -DHAVE_BOOST_UNIT_TEST_FRAMEWORK=/\*\*/ -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I.    -lopendnp3 -g -std=gnu++11 -MT DemoMain.o -MD -MP -MF $depbase.Tpo -c -o DemoMain.o DemoMain.cpp &&\

J Adam Crain

unread,
Jun 25, 2013, 11:28:44 AM6/25/13
to automatak...@googlegroups.com
Hi Daniel,

I saw your post hit the opendnp3 mailing list here:


Does this mean you have resolved the issue?

Adam
g++ -DPACKAGE_NAME=\"opendnp3demos\" -DPACKAGE_TARNAME=\"opendnp3demos\" -DPACKAGE_VERSION=\"1.1.0\" -DPACKAGE_STRING=\"opendnp3demos\ 1.1.0\" -DPACKAGE_BUGREPORT=\"x...@automatak.com\" -DPACKAGE_URL=\"\" -DPACKAGE=\"opendnp3demos\" -DVERSION=\"1.1.0\" -DHAVE_LIBPTHREAD=1 -DHAVE_BOOST=/\*\*/ -DHAVE_BOOST_SYSTEM=/\*\*/ -DHAVE_BOOST_ASIO=/\*\*/ -DHAVE_BOOST_UNIT_TEST_FRAMEWORK=/\*\*/ -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I.    -lopendnp3 -g -std=gnu++11 -MT DemoMain.o -MD -MP -MF $depbase.Tpo -c -o DemoMain.o DemoMain.cpp &&\

Daniel

unread,
Jun 25, 2013, 2:09:16 PM6/25/13
to automatak...@googlegroups.com
Hi Adam,

I re-flashed the BeagleBone to ensure that there is no mixup with the libraries from the original project. I managed to successfully compile and install the libraries, but the same problem persist as previously mentioned when compiling the test suite. Here is the output when running "make check" (with ./configure LDFLAGS=-lpthread). I am now recompiling with debug mode (CXXFLAGS=-g) and will post the output.


libtool: link: g++ -I/usr/include -DBOOST_TEST_DYN_LINK -DBOOST_ASIO_ENABLE_CANC
ELIO -DBOOST_REGEX_NO_LIB -D_GLIBCXX_USE_NANOSLEEP -I./cpp/include -g -O2 -std=g
nu++11 -o .libs/dnp3test cpp/tests/dnp3test-AppLayerTest.o cpp/tests/dnp3test-As
yncPhysBaseTest.o cpp/tests/dnp3test-AsyncPhysTestObject.o cpp/tests/dnp3test-As
yncSerialTestObject.o cpp/tests/dnp3test-AsyncTestObjectASIO.o cpp/tests/dnp3tes
t-AsyncTestObject.o cpp/tests/dnp3test-BufferHelpers.o cpp/tests/dnp3test-Buffer
TestObject.o cpp/tests/dnp3test-ComparingDataObserver.o cpp/tests/dnp3test-Flexi
bleDataObserver.o cpp/tests/dnp3test-DNPHelpers.o cpp/tests/dnp3test-LinkLayerRo
uterTest.o cpp/tests/dnp3test-LinkLayerTest.o cpp/tests/dnp3test-LogTester.o cpp
/tests/dnp3test-LoopbackPhysicalLayerAsync.o cpp/tests/dnp3test-LowerLayerToPhys
Adapter.o cpp/tests/dnp3test-MockAppLayer.o cpp/tests/dnp3test-MockAppUser.o cpp
/tests/dnp3test-MockExecutor.o cpp/tests/dnp3test-MockFrameSink.o cpp/tests/dnp3
test-MockLowerLayer.o cpp/tests/dnp3test-MockPhysicalLayerAsync.o cpp/tests/dnp3
test-MockPhysicalLayerMonitor.o cpp/tests/dnp3test-MockUpperLayer.o cpp/tests/dn
p3test-PhysicalLayerWrapper.o cpp/tests/dnp3test-PhysLoopback.o cpp/tests/dnp3te
st-RandomizedBuffer.o cpp/tests/dnp3test-SlaveTestObject.o cpp/tests/dnp3test-St
opWatch.o cpp/tests/dnp3test-TestAPDU.o cpp/tests/dnp3test-TestAPDUWriting.o cpp
/tests/dnp3test-TestAppLayer.o cpp/tests/dnp3test-TestASIO.o cpp/tests/dnp3test-
TestASIOThreadPool.o cpp/tests/dnp3test-TestCastLongLongDouble.o cpp/tests/dnp3t
est-TestChangeBuffer.o cpp/tests/dnp3test-TestCommandTypes.o cpp/tests/dnp3test-
TestCRC.o cpp/tests/dnp3test-TestDatabase.o cpp/tests/dnp3test-TestEnhancedVtoRo
uter.o cpp/tests/dnp3test-TestEventBufferBase.o cpp/tests/dnp3test-TestEventBuff
ers.o cpp/tests/dnp3test-TestLinkFrameDNP.o cpp/tests/dnp3test-TestLinkLayer.o c
pp/tests/dnp3test-TestLinkLayerRouter.o cpp/tests/dnp3test-TestLinkReceiver.o cp
p/tests/dnp3test-TestLinkRoute.o cpp/tests/dnp3test-TestLog.o cpp/tests/dnp3test
-TestMisc.o cpp/tests/dnp3test-TestObjects.o cpp/tests/dnp3test-TestPackingUnpac
king.o cpp/tests/dnp3test-TestParsing.o cpp/tests/dnp3test-TestPhysicalLayerAsyn
cBase.o cpp/tests/dnp3test-TestPhysicalLayerAsyncSerial.o cpp/tests/dnp3test-Tes
tPhysicalLayerAsyncTCP.o cpp/tests/dnp3test-TestPhysicalLayerLoopback.o cpp/test
s/dnp3test-TestPhysicalLayerMonitor.o cpp/tests/dnp3test-TestShiftableBuffer.o c
pp/tests/dnp3test-TestSlave.o cpp/tests/dnp3test-TestSlaveEventBuffer.o cpp/test
s/dnp3test-TestStartBoostUTF.o cpp/tests/dnp3test-TestTime.o cpp/tests/dnp3test-
TestTimers.o cpp/tests/dnp3test-TestTransportLayer.o cpp/tests/dnp3test-TestTran
sportLoopback.o cpp/tests/dnp3test-TestTransportScalability.o cpp/tests/dnp3test
-TestTypes.o cpp/tests/dnp3test-TestUtil.o cpp/tests/dnp3test-TestVtoInterface.o
 cpp/tests/dnp3test-TestVtoRouter.o cpp/tests/dnp3test-TestVtoWriter.o cpp/tests
/dnp3test-Timeout.o cpp/tests/dnp3test-TransportIntegrationStack.o cpp/tests/dnp
3test-TransportLoopbackTestObject.o cpp/tests/dnp3test-TransportScalabilityTestO
bject.o cpp/tests/dnp3test-TransportStackPair.o cpp/tests/dnp3test-TransportTest
Object.o cpp/tests/dnp3test-WrappedTcpPipe.o cpp/tests/dnp3test-TestAsyncTask.o
cpp/tests/dnp3test-IntegrationTest.o cpp/tests/dnp3test-TestDNP3Manager.o cpp/te
sts/dnp3test-VtoIntegrationTestBase.o cpp/tests/dnp3test-TestIntegration.o cpp/t
ests/dnp3test-MasterTestObject.o cpp/tests/dnp3test-ResponseLoaderTestObject.o c
pp/tests/dnp3test-TestCommandHelpers.o cpp/tests/dnp3test-TestCommandTask.o cpp/
tests/dnp3test-TestMaster.o cpp/tests/dnp3test-TestResponseLoader.o cpp/tests/dn
p3test-MockTimeSource.o  -L/usr/lib ./.libs/libopendnp3.so -lpthread /usr/lib/li
bstdc++.so -lm -lboost_system -lboost_unit_test_framework
make[1]: Leaving directory `/home/root/Downloads/automatak/dnp3'
make  check-TESTS
make[1]: Entering directory `/home/root/Downloads/automatak/dnp3'

Running 460 test cases...
pure virtual method called
terminate called without an active exception
unknown location(0): fatal error in "CleanConstructionDestruction": signal: SIGA
BRT (application abort requested)
pure virtual method called
terminate called recursively
unknown location(0): fatal error in "CleanConstructionDestruction": signal: SIGA
BRT (application abort requested)
/bin/sh: line 5: 11860 Aborted                 ${dir}$tst
FAIL: dnp3test
=========================================
1 of 1 test failed
Please report to jadam...@automatak.com
=========================================
make[1]: *** [check-TESTS] Error 1
make[1]: Leaving directory `/home/root/Downloads/automatak/dnp3'

make: *** [check-am] Error 2
root@beaglebone:~/Downloads/automatak/dnp3#

Daniel

unread,
Jun 25, 2013, 3:56:28 PM6/25/13
to automatak...@googlegroups.com
Hi,

I could not gather more information from the debug output. I have boost version 1.53 installed, if that might give a clue.

Regards

J Adam Crain

unread,
Jun 25, 2013, 4:21:26 PM6/25/13
to automatak...@googlegroups.com
Hi Daniel,

Does the Angstrom Linux distribution support GDB? This would be my next step.

From the little bit of searching I've done, it appears this failure can occur when one calls a virtual method from a constructor/destructor. It's odd that it isn't happening on other platforms, but such is life...

Anyone want to put a Beagle Bone Black in the mail? Pretty please? =)

-Adam

Daniel

unread,
Jun 26, 2013, 4:47:19 AM6/26/13
to automatak...@googlegroups.com
Hi Adam,

Yes, GDB (GNU Debugger) comes pre-installed on the Ångström BeagleBone Image. Ok I have found why dgb would not work, I need to specify the executable testdnp3 in the ./libs directory and not in the project root.

Before using GDB, be sure to install libc6-dbg:
# opkg install libc6-dbg

Here is the output:
0xb6d50938 in boost::unit_test::traverse_test_tree(boost::unit_test::test_suite const&, boost::unit_test::test_tree_visitor&) () from /usr/lib/libboost_unit_test_framework.so.1.53.0
(gdb) nexti
0xb6d5093c in boost::unit_test::traverse_test_tree(boost::unit_test::test_suite const&, boost::unit_test::test_tree_visitor&) () from /usr/lib/libboost_unit_test_framework.so.1.53.0
(gdb) nexti
0xb6d50940 in boost::unit_test::traverse_test_tree(boost::unit_test::test_suite const&, boost::unit_test::test_tree_visitor&) () from /usr/lib/libboost_unit_test_framework.so.1.53.0
(gdb) nexti
0xb6d50944 in boost::unit_test::traverse_test_tree(boost::unit_test::test_suite const&, boost::unit_test::test_tree_visitor&) () from /usr/lib/libboost_unit_test_framework.so.1.53.0
(gdb) nexti
0xb6d50934 in boost::unit_test::traverse_test_tree(boost::unit_test::test_suite const&, boost::unit_test::test_tree_visitor&) () from /usr/lib/libboost_unit_test_framework.so.1.53.0
(gdb) nexti
0xb6d50938 in boost::unit_test::traverse_test_tree(boost::unit_test::test_suite const&, boost::unit_test::test_tree_visitor&) () from /usr/lib/libboost_unit_test_framework.so.1.53.0
(gdb) nexti
0xb6d5093c in boost::unit_test::traverse_test_tree(boost::unit_test::test_suite const&, boost::unit_test::test_tree_visitor&) () from /usr/lib/libboost_unit_test_framework.so.1.53.0
(gdb) nexti
[New Thread 0xb6afb460 (LWP 20465)]
[New Thread 0xb62fb460 (LWP 20466)]
[New Thread 0xb5afb460 (LWP 20467)]
[New Thread 0xb52fb460 (LWP 20468)]
pure virtual method called
terminate called without an active exception
[Thread 0xb62fb460 (LWP 20466) exited]

Program received signal SIGABRT, Aborted.
[Switching to Thread 0xb52fb460 (LWP 20468)]
0xb6b28df8 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:66
66        int res = INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) nexti
[Thread 0xb52fb460 (LWP 20468) exited]
[Thread 0xb5afb460 (LWP 20467) exited]
[Thread 0xb6afb460 (LWP 20465) exited]

Program terminated with signal SIGABRT, Aborted.
The program no longer exists.
(gdb) 

In the meanwhile, I will remove boost-test1.53 and install boost-test1.49 and see if that makes a difference.

Regards

Daniel

unread,
Jun 26, 2013, 7:23:51 AM6/26/13
to automatak...@googlegroups.com
Hi,

Ok I removed all Boost 1.53 packages and libraries and installed Boost 1.49. Same problem persists when running dnp3test:

0xb6afad14 in boost::unit_test::traverse_test_tree(boost::unit_test::test_suite const&, boost::unit_test::test_tree_visitor&) () from /usr/lib/libboost_unit_test_framework.so.1.49.0
(gdb) nexti

0xb6afad18 in boost::unit_test::traverse_test_tree(boost::unit_test::test_suite const&, boost::unit_test::test_tree_visitor&) () from /usr/lib/libboost_unit_test_framework.so.1.49.0

(gdb) nexti

[New Thread 0xb689b460 (LWP 32110)]
[New Thread 0xb609b460 (LWP 32111)]

[New Thread 0xb589b460 (LWP 32112)]
[New Thread 0xb509b460 (LWP 32113)]
pure virtual method called
terminate called without an active exception

[Thread 0xb609b460 (LWP 32111) exited]
[Thread 0xb689b460 (LWP 32110) exited]
[Thread 0xb589b460 (LWP 32112) exited]


Program received signal SIGABRT, Aborted.
[Switching to Thread 0xb509b460 (LWP 32113)]
0xb68c8df8 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:66
66        int res = INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) nexti
[Thread 0xb509b460 (LWP 32113) exited]

Program terminated with signal SIGABRT, Aborted.
The program no longer exists.
(gdb) nexti

Daniel

unread,
Jun 26, 2013, 7:42:53 AM6/26/13
to automatak...@googlegroups.com
Compiling the outstationdemo with boost1.49 and running GDB:

opendnp3::IOServiceThreadPool::IOServiceThreadPool(opendnp3::Logger*, unsigned int, std::function<void ()>, std::function<void ()>) (this=0x1b988, apLogger=0x1b938, aConcurrency=1, onThreadStart=..., onThreadExit=...) at cpp/src/opendnp3/IOServiceThreadPool.cpp:57
57              if(aConcurrency == 0) {
(gdb) next
61              mInfiniteTimer.expires_at(timer_clock::time_point::max());
(gdb) next

62              mInfiniteTimer.async_wait(bind(&IOServiceThreadPool::OnTimerExpiration, this, placeholders::_1));
(gdb) next


63              for(uint32_t i = 0; i < aConcurrency; ++i) {
(gdb) next

64                      mThreads.push_back(new thread(bind(&IOServiceThreadPool::Run, this)));
(gdb) next

[New Thread 0xb6951460 (LWP 2673)]
pure virtual method called
terminate called without an active exception

Program received signal SIGABRT, Aborted.
[Switching to Thread 0xb6951460 (LWP 2673)]
0xb697edf8 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:66
66        int res = INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) next
[Thread 0xb6951460 (LWP 2673) exited]

Program terminated with signal SIGABRT, Aborted.
The program no longer exists.
(gdb) 


J Adam Crain

unread,
Jun 26, 2013, 9:39:55 PM6/26/13
to automatak...@googlegroups.com
This may be enough of a trace to offer a clue. 

=>  mThreads.push_back(new thread(bind(&IOServiceThreadPool::Run, this)));

This line is where the thread pool that drives the opendnp3 stack gets created:


Notice that the threads get created and immediately start calling ::Run().  Run is not virtual (no vtable at all), but it does depend on some stuff in the inherited class Loggable perhaps that is called from Run().

Can you put a break-point here? I need to know if the failure happens on the thread that is launched or it happens on that line.


I need to figure out what "method" being called is causing the failure.  I suspect that it is in ::Run() somewhere, but it might also be in the new thread() constructor or something weird if the C++11 stdlib support is screwed up on Angstromg.

Also, try running the following tests on their own:


These are isolated unit tests that the thread pool behaves as expected. We need to get it working properly on Angstrom before we can get anything else to run. This test suite can be run on its own with:

./dnp3test --run_test=ASIOThreadPoolTestSuite

You can run individual tests in the suite with:

./dnp3test --run_test=ASIOThreadPoolTestSuite/<testname>

thanks,
Adam

Daniel

unread,
Jun 30, 2013, 2:45:30 PM6/30/13
to automatak...@googlegroups.com
Hi Adam,

Thanks. I will add some break points and see if I can narrow it down.

Regards
Message has been deleted

Cornel Verster

unread,
Jul 26, 2013, 8:48:30 AM7/26/13
to automat...@googlegroups.com, automatak...@googlegroups.com
Hey Guys

I ran ./configure on both the RPi and the Beaglebone (the opendnp3 libraries run on the RPi but not on the Beaglebone) and found the following differences:

BBB:
=======
1.checking whether g++ supports C++11 features with -std=gnu++11... yes
2. checking build system type... armv7l-unknown-linux-gnueabi
3. checking host system type... armv7l-unknown-linux-gnueabi
4. checking for mt... no
5. checking if gcc static flag -static works... no
6. checking if g++ static flag -static works... no

RPi:
=======
1.checking whether g++ supports C++11 features with -std=gnu++11... no
  checking whether g++ supports C++11 features with -std=gnu++0x... yes
2.checking build system type... armv6l-unknown-linux-gnueabihf
3. checking host system type... armv6l-unknown-linux-gnueabihf
4. checking for mt... mt
5. checking if gcc static flag -static works... yes
6. checking if g++ static flag -static works... yes

J Adam Crain

unread,
Jul 26, 2013, 9:40:06 AM7/26/13
to automat...@googlegroups.com, automatak...@googlegroups.com
Hi Cornel,

It looks like you're hitting the exact same run-time failure that Daniel Tomlinson was seeing. I'll buy a beer for the person that resolves this issue with a fix at the first industry conference we both attend.

Options for debugging:

1) Carefully identify which virtual method is being called (and where) using GDB and give me that info.

2) Alternatively, if you're not familiar with GDB, one of you 2 could put a BBB on a publicly accessible port with an SSH account for me to connect and debug.

3) Alternatively, somebody could gift me a BBB! =)

With respect to the ./configure differences, all this really tells me is:

1) You're likely running G++ >= 4.7.x on BBB, and G++ 4.6.x on RPI. This is base on the gnu++11 / gnu++0x differences.

2) The ARM is slightly different.

Let me know how you and Daniel want to go about debugging this.

thanks,
Adam
Message has been deleted

Cornel Verster

unread,
Jul 30, 2013, 9:05:46 AM7/30/13
to automat...@googlegroups.com, automatak...@googlegroups.com

Hey Adam

I put a breakpoint on the first line of IOServiceThreadPool.cpp and found a few errors like the following while stepping through:

(gdb) step
28          first_service_(new Service(o, arg))
(gdb)
posix_mutex (this=0x1bc2c) at /usr/include/boost/asio/detail/impl/posix_mutex.ipp:34
34        int error = ::pthread_mutex_init(&mutex_, 0);
(gdb) step
boost::asio::detail::service_registry::service_registry<boost::asio::detail::task_io_service, unsigned int> (
    this=0x1bc28, o=..., arg=4294967295) at /usr/include/boost/asio/detail/impl/service_registry.hpp:25
25      service_registry::service_registry(
(gdb) step
28          first_service_(new Service(o, arg))
(gdb) step
posix_mutex (this=0x1bc2c) at /usr/include/boost/asio/detail/impl/posix_mutex.ipp:34
34        int error = ::pthread_mutex_init(&mutex_, 0);
(gdb) step
36            boost::asio::error::get_system_category());
(gdb) step
get_system_category () at /usr/include/boost/asio/error.hpp:216
216       return boost::system::system_category();

Other than that, it actually does not kick out when I step through but continues along with the program.

When I put breakpoints on line 64 and 97 as you suggested, the program does not stop at one of them, but just kicks out again saying that a pure virtual function has been called.

Regards
Corenl

J Adam Crain

unread,
Jul 30, 2013, 9:29:33 AM7/30/13
to automat...@googlegroups.com, automatak...@googlegroups.com
Hi Cornel,

My BBB arrives today.  I probably wont' get around to testing it until tonight or tomorrow.

Is there anything I should be aware of to get the toolchain set up?

Does the Angstrom distro have autotools and g++ all installed by default?

-Adam
Message has been deleted

Cornel Verster

unread,
Jul 30, 2013, 11:06:28 AM7/30/13
to automat...@googlegroups.com, automatak...@googlegroups.com
Ya I believe it does. I think the only dependency that must be installed is boost

You're lucky, here in South Africa we wait super long for our BBBs :) unless, ofcourse, you are from South Africa haha

Cornel

J Adam Crain

unread,
Jul 30, 2013, 1:02:21 PM7/30/13
to automat...@googlegroups.com, automatak...@googlegroups.com
Wow, the BBB is so easy to use out of the box with the USB network driver.

I'm compiling the project now. I suspect this takes ~1 hour.

-AC

Cornel Verster

unread,
Jul 31, 2013, 4:22:48 AM7/31/13
to automat...@googlegroups.com, automatak...@googlegroups.com
Hey Adam

Managed to get the tests working finally. Found the following when I put a breakpoint at:

Breakpoint 1, opendnp3::IOServiceThreadPool::OnTimerExpiration (this=0xbeffedf8, ec=...)
    at cpp/src/opendnp3/IOServiceThreadPool.cpp:65
65      }
(gdb) stepi
0xb6e7d778      65      }
(gdb) stepi
pure virtual method called
terminate called without an active exception
0xb6e7d77c in opendnp3::IOServiceThreadPool::OnTimerExpiration (this=0xb589eaf4, ec=...)
    at cpp/src/opendnp3/IOServiceThreadPool.cpp:65
65      }
(gdb) stepi
[New LWP 7047]

Program received signal SIGABRT, Aborted.
[Switching to LWP 7047]
0xb68ccdf8 in raise () from /lib/libc.so.6

So it seems to be the void IOServiceThreadPool::OnTimerExpiration(const boost::system::error_code& ec) method?

Hope you're having fun with the BBB!
Cornel

J Adam Crain

unread,
Jul 31, 2013, 8:26:38 AM7/31/13
to automat...@googlegroups.com, automatak...@googlegroups.com
Ok. Thanks for the info.

I got boost compiled and everything built yesterday too. The tests compiled and linked.

When they ran, I got the virtual method call error.

I'm going to try to debug this morning.

-adam

Karol

unread,
Aug 24, 2016, 12:05:26 PM8/24/16
to automatak-dnp3, automatak...@googlegroups.com
Hi,
Have you resolved this virtual method call error on the BBB?
I'm asking becouse I have the same error. I'm try to run opendnp3 library on the BBB with yocto developed linux with gcc 4.8.2.
branch 2.0.x commit ID: 445711f015ffc2cf9b1c1966a12be38b7d66fdcd

Error from testasiodnp3:
/prj/libdnp3/dnp3/cpp/tests/asiodnp3tests/src/TestDNP3Manager.cpp:46: FAILED:
due to a fatal error condition:
SIGABRT - Abort (abnormal termination) signal

Adam Crain

unread,
Aug 24, 2016, 3:01:06 PM8/24/16
to automatak-dnp3, automatak...@googlegroups.com
I believe we did. Here's the thread:


It involves adding a bunch of compiler flags, but this shouldn't be hard to do when running cmake for the first time.

-AC
Reply all
Reply to author
Forward
0 new messages