FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
770 views 18 comments
by anonymous
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 anonymous

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 anonymous

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

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

Could you post the Makefile ?
by anonymous
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 anonymous
==> cp -r $(SOURCE_DIR)/* $(PKG_BUILD_DIR)

Formatting issues ?
by anonymous
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 anonymous

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 anonymous

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 anonymous
Look in packages/ and/or feeds/ for the libraries/utilities you need. This should be workable.
by anonymous
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 anonymous
For libmodbus: ./scripts/feeds install libmodbus, and enable it via make menuconfig.

For mqttclient: ?. What do you need exactly ? Which functions / classes ?
by anonymous
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.