10512 questions

12517 answers

19444 comments

22040 members

0 votes
108 views 18 comments
by
Hi,

I have to write simple service in C which will run on Teltonika device. The service will get some data from webAPI on remote server and program connected device using Modbus/TCP. How should I approach with setting up my environment? I started to develop it on my debian host, but it is no a good idea I suppose - the differences between both architectures are too significant. Development directly on the device would be cumbersome as well due to filesystem limitations. It came to my mind to setup openWRT on VMWare with x86 kernel, do all development there and then build binary for ARM target and test it on TRB device. Do you think it is the right aproach?

Kal
by

Hi, 

I've tried to build simple Hello World style application using OpenWrt tutorial for that, but I cannot complete the compilation. I get the following output when I try to run make package/vtscd/compile:

WARNING: Makefile 'package/utils/busybox/Makefile' has a build dependency on 'libpam', which does not exist

WARNING: Makefile 'package/libs/glib2/Makefile' has a build dependency on 'libffi/host', which does not exist

WARNING: Makefile 'package/lang/python/python3/Makefile' has a build dependency on 'expat/host', which does not exist

WARNING: Makefile 'package/lang/python/python3/Makefile' has a build dependency on 'libffi/host', which does not exist

WARNING: Makefile 'package/network/utils/ulogd/Makefile' has a build dependency on 'libnetfilter-acct', which does not exist

make[1]: Entering directory '/home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl'

make[2]: Entering directory '/home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/package/libs/toolchain'

echo "libc" >> /home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/pkginfo/toolchain.default.install

echo "libgcc" >> /home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/pkginfo/toolchain.default.install

echo "libatomic" >> /home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/pkginfo/toolchain.default.install

echo "libpthread" >> /home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/pkginfo/toolchain.default.install

echo "librt" >> /home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/pkginfo/toolchain.default.install

make[2]: Leaving directory '/home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/package/libs/toolchain'

time: package/libs/toolchain/compile#0.10#0.02#0.13

make[2]: Entering directory '/home/kal800/Projects/vtscloudd/packages/vtscd'

touch /home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/vtscd-0.01/.prepared_4dde9d7b4b37735922bf06521f73f774_6664517399ebbbc92a37c5bb081b5c53_check

mkdir -p /home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/vtscd-0.01

cp /home/kal800/Projects/vtscloudd/* /home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/vtscd-0.01

cp: -r not specified; omitting directory '/home/kal800/Projects/vtscloudd/modpoll'

cp: -r not specified; omitting directory '/home/kal800/Projects/vtscloudd/packages'

cp: -r not specified; omitting directory '/home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl'

make[2]: *** [Makefile:42: /home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/vtscd-0.01/.prepared_4dde9d7b4b37735922bf06521f73f774_6664517399ebbbc92a37c5bb081b5c53] Error 1

make[2]: Leaving directory '/home/kal800/Projects/vtscloudd/packages/vtscd'

time: package/feeds/vtspackages/vtscd/compile#0.09#0.18#0.28

    ERROR: package/feeds/vtspackages/vtscd failed to build.

make[1]: *** [package/Makefile:126: package/feeds/vtspackages/vtscd/compile] Error 1

make[1]: Leaving directory '/home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl'

make: *** [/home/kal800/Projects/vtscloudd/rutos-mdm9x07-trb1-gpl/include/toplevel.mk:234: package/vtscd/compile] Error 2

Package was visible on menuconfig and I was able to add it. 

by

Try make -j 1 V=sc package/vtscd/compile and post the result.

by
Result is above. I used verbose output when I first received make error
by
No obvious error except maybe the cp -r indication.

Could you post the Makefile ?
by
include $(TOPDIR)/rules.mk
 
PKG_NAME:=vtscd
PKG_VERSION:=0.01
PKG_RELEASE:=1
 
SOURCE_DIR:=/home/kal800/Projects/vtscloudd
 
include $(INCLUDE_DIR)/package.mk
 
define Package/vtscd
SECTION:=vtscd
CATEGORY:=vtscd
TITLE:=VTS Cloud Daemon
endef
 
define Package/vtscd/description
Service to configure VTS installations
endef
 
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
$(Build/Patch)
endef
 
define Build/Compile
$(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/vtscd.o -c $(PKG_BUILD_DIR)/vtscd.c
$(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/vtscd.o
endef
 
define Package/vtscd/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/vtscd $(1)/usr/bin
endef
 
$(eval $(call BuildPackage,vtscd))
by
==> cp -r $(SOURCE_DIR)/* $(PKG_BUILD_DIR)

Formatting issues ?
by
Well, it worked after all. The reason behind this, was that the directory with SDK was inside project folder which I tried to copy as the result. I moved my files to the separate folder and pointed it in the makefile.

1 Answer

0 votes
by

Hello,

It would be much easier to use the SDK for your device: https://wiki.teltonika-networks.com/view/Software_Development_Kit

You will have all the symbols / libraries checked at build time, you'll only have to transfer your package to the TRB and install / test it.

Regards,

by

One more thing - I’m using the following libs:

  • libcurl
  • json-c
  • libmodbus
  • mqttclient
If everything is to work they needed to be linked and targets should match. I guess those libs should be in SDK. Is it workable? How can I check? 
by
Look in packages/ and/or feeds/ for the libraries/utilities you need. This should be workable.
by
I added dependencies, and two of them were downloaded and included - lib curl and libjson-c, other ones are still missing. Do you think they can be added somehow?

Kal
by
For libmodbus: ./scripts/feeds install libmodbus, and enable it via make menuconfig.

For mqttclient: ?. What do you need exactly ? Which functions / classes ?
by
Well, for modbus I managed to find Makefile for a OpenWrt. Added it and compiled.

There is no OpenWrt package for Paho Mqtt Client - there is only one version - for Python. I decided to switch to libmosquitto which is fully supported.