Ошибка при выполнении кросс-компилированной программы для openwrt

Я пытаюсь экспортировать программное обеспечение в openwrt, и я могу сгенерировать ipk, но скомпилированный файл всегда дает мне эту ошибку

-ash: scanReportProbe: не найдено

Я пробовал все, но я не могу заставить его работать. Чтобы быть полным, это то, что я сделал для подготовки среды:

git clone git://github.com/openwrt/openwrt.git
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make prereq
make menuconfig
    [here i selected the package with the M and saved the configuration]
make tools/install
make toolchain/install
make package/scanReport_probe/compile

Я понятия не имею, как исправить эту ошибку, поэтому мне нужен намек на решение.

Я не думаю, что ошибка в коде, но в случае необходимости это моя программа: файловая структура

scanReport_probe
├── LICENSE
├── Makefile
├── README.md
└── src
    ├── data
    │   └── THIS IS FOR DATA FILES.txt
    ├── runScript
    │   └── scanReportProbe
    ├── scanReport_probe
    │   ├── a.c
    │   └── makefile
    └── scanReport_probe.conf

мейкфайл для openwrt

include $(TOPDIR)/rules.mk

# name of package
# version number of the sources you're using
# how many times you've released a package based on the above version number
PKG_NAME:=scanReport_probe
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_LICENSE:=MIT

# sources will be unpacked into this directory (you shouldn't need to change this)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

#needed 
include $(INCLUDE_DIR)/package.mk


# Metadata; information about what the package is for the ipkg listings
# to keep things simple, a number of fields have been left at their defaults
# and are not shown here.
define Package/scanReport_probe
    SECTION:=utils
    CATEGORY:=Utilities
    TITLE:=scanReport_probe
    URL:=https://github.com/luigiDB/scan-report_probe
    TITLE:=Scan in monitor mode probe over wifi channel with periodic report to a server through http post.
    MAINTAINER:=Please refer to github repository page
endef

define Package/scanReport_probe/description
    This is the best tool ever. 
    Scan probe over wifi and at regualar interval send results via http post.
endef


define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef


CONFIGURE_VARS+= \
    CC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC)"


define Build/Compile
    $(MAKE) -C $(PKG_BUILD_DIR)/scanReport_probe $(TARGET_CONFIGURE_OPTS)
endef

# We'll use the OpenWrt defaults to configure and compile the package. Otherwise we'd need to define
# Build/Configure - commands to invoke a configure (or similar) script
# Build/Compile - commands used to run make or otherwise build the source

define Package/scanReport_probe/install
    # Now that we have the source compiled (magic huh?) we need to copy files out of the source
    # directory and into our ipkg file. These are shell commands, so make sure you start the lines
    # with a TAB. $(1) here represents the root filesystem on the router.
    # INSTALL_DIR, INSTALL_BIN, INSTALL_DATA are used for creating a directory, copying an executable, 
    # or a data file. +x is set on the target file for INSTALL_BIN, independent of it's mode on the host.

    # make a directory for the config
    $(INSTALL_DIR) $(1)/etc/scanReport_probe/

    # copy the config
    $(INSTALL_CONF) $(PKG_BUILD_DIR)/scanReport_probe.conf $(1)/etc/scanReport_probe

    # make a directory for some random data files required by scanReport_probe
    $(INSTALL_DIR) $(1)/usr/share/scanReport_probe

    # copy the data files
    $(INSTALL_DATA) $(PKG_BUILD_DIR)/data/* $(1)/usr/share/scanReport_probe

    #make directory bin
    $(INSTALL_DIR) $(1)/bin

    # copy the binary
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/scanReport_probe/scanReportProbe $(1)/bin

    #make the directory init.d in case isn't present
    $(INSTALL_DIR) $(1)/etc/init.d

    #copy script to init.d
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/runScript/scanReportProbe $(1)/etc/init.d    
endef


#runned post installation call the enable on the service
define Package/scanReport_probe/postinst
    #!/bin/sh
    # check if we are on real system
    if [ -z "$${IPKG_INSTROOT}" ]; then
        echo "Enabling rc.d symlink for scanReportProbe"
        /etc/init.d/scanReportProbe enable
    fi
    exit 0
endef


#runned pre uninstallation call the disable on the service
define Package/scanReport_probe/prerm
    #!/bin/sh
    # check if we are on real system
    if [ -z "$${IPKG_INSTROOT}" ]; then
        echo "Removing rc.d symlink for scanReportProbe"
        /etc/init.d/scanReportProbe disable
    fi
    exit 0
endef

$(eval $(call BuildPackage,scanReport_probe))

a.c

#include <stdio.h>
int main(void)
{
        printf("Hello World\n");
        return 0;
}

makefile для программы c

PROFILE = -O2 -s
CFLAGS = $(PROFILE)
LDFLAGS = 

all: main

# build it
main: a.o
    $(CC) $(LDFLAGS) a.o -o scanReportProbe

a.o: a.c
    $(CC) $(CFLAGS) -c a.c

# clean it
clean:
    rm *.o a

person LuigiDB    schedule 17.08.2016    source источник
comment
Вы уверены, что выбрали правильную архитектуру в menuconfig? Что говорит file build_dir/target-*/scanReport_probe*/scanReportProbe? Сравните его с двоичным файлом с вашего устройства openwrt (например, скопируйте /bin/busybox на хост-компьютер и запустите на нем file).   -  person Vasily G    schedule 23.08.2016
comment
Кроме того, попробуйте удалить предложение define Build/Compile и назначение CONFIGURE_VARS — значения по умолчанию должны вам подойти.   -  person Vasily G    schedule 23.08.2016
comment
Все настроено правильно. Я не знаю почему, но компиляция этого репозитория git://git.openwrt.org/15.05/openwrt.git вместо транка решила проблему.   -  person LuigiDB    schedule 26.08.2016


Ответы (1)


Для -ash, IIRC, ash — это [загрузочная] оболочка. Пишет, что не может найти конкретную команду.

Итак, это может быть один из:

(1) В разделе сценария rc вы делаете /etc/init.d/scanReportProbe enable, но пакет, который вы создаете, использует scanReport_probe. Таким образом, вам может понадобиться добавить или удалить _ здесь или там и/или некоторые другие переименования, чтобы все совпадало.

(2) Если указанная вами файловая структура является окончательной, я не уверен, что скрипт находится в правильном каталоге.

(3) Верны ли права доступа к сценарию (т. е. выполняется ли он)?

person Craig Estey    schedule 17.08.2016
comment
После установки каждый файл находится в правильном каталоге, и я также проверил без сценария init.d, чтобы быть уверенным. Исполняемый файл в папке bin имеет разрешение на выполнение -rwxr-xr-x 1 root root 1527 Aug 17 17:15 scanReportProbe, но также и с /bin/scanReportProbe я получаю ту же ошибку. Я также тестирую другой репозиторий, который я нашел в Интернете, и все выдают ту же ошибку. - person LuigiDB; 18.08.2016