Компиляция пользовательского пакета для среды разработки Linux Embedded (LEDE) (аналогично OpenWRT)
Hi all,
Платформа: x86_64
Я успешно установил Linux Embedded Development Environment (LEDE) x86/64 (так же, как OpenWRT) на свою виртуальную машину.
Я разработал специальный пакет "Hello World" для среды разработки встраиваемых систем Linux (LEDE) с SDK и скомпилировал его. Затем проверил его на моей виртуальной машине, и это сработало. Но затем у меня есть собственный код для переноса, то есть для необработанного анализатора пакетов в c, и я хочу портировать этот код. Итак, я скопировал тот же код в тот же файл, который использовал для "Hello world" (helloworld.c). Я снова успешно скомпилировал новый двоичный файл "*.ipk format", затем отправил его на свою виртуальную машину LEDE и сделал opkg install xxxxxx.ipk
, Он установлен, но тот же вывод. Я имею в виду "Привет, мир".
Я не знаю как Потому что код изменился на этот раз. Затем снова для тестирования написал простой факторный код и снова. Во время тестирования на виртуальной машине. Я обнаружил, что это не сработало, потому что опять тот же вывод, то есть "Hello world".
Документация: Привет, мир, пакет для LEDE с использованием LEDE Source. Я разрабатываю с использованием SDK вместо source.I следовал всем пунктам в документации, за исключением компиляции исходного кода и всего.
Документация для SDK: скомпилируйте пользовательский пакет, используя SDK
Makefile для Hello World код:
include $(TOPDIR)/rules.mk
# Name, version and release number
# The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1
# Source settings (i.e. where to find the source codes)
# This is a custom variable, used below
SOURCE_DIR:=/home/buildbot/helloworld
include $(INCLUDE_DIR)/package.mk
# Package definition; instructs on how and where our package will appear in the overall configuration menu ('make menuconfig')
define Package/helloworld
SECTION:=examples
CATEGORY:=Examples
TITLE:=Hello, World!
endef
# Package description; a more verbose description on what our package does
define Package/helloworld/description
A simple "Hello, world!" -application.
endef
# Package preparation instructions; create the build directory and copy the source code.
# The last command is necessary to ensure our preparation instructions remain compatible with the patching system.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
$(Build/Patch)
endef
# Package build instructions; invoke the target-specific compiler to first compile the source file, and then to link the file into the final executable
define Build/Compile
$(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_DIR)/helloworld.c
$(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/helloworld.o
endef
# Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder
define Package/helloworld/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
endef
# This command is always the last, it uses the definitions and variables we give above in order to get the job done
$(eval $(call BuildPackage,helloworld))
2 ответа
Я снова скомпилировал тот же код и протестировал его LinkIt Smart 7688
и все работает как положено. Итак, я думаю, что-то пошло не так с той виртуальной машиной LEDE, которую я создал для тестирования.
LinkIt Smart 7688: это открытая плата для разработчиков, основанная на дистрибутиве OpenWrt Linux и MT7688. Платформа также предлагает варианты создания приложений для устройств на языке программирования Python, Node.js и C.
Итак, я думаю, что это одна из лучших досок для вещей IoT в пределах 12,90 долларов США.
Я успешно добавил пользовательский пакет в openwrt, и это мой Makefile, надеюсь, это поможет вам
include $(TOPDIR)/rules.mk
PKG_NAME:=viva
PKG_VERSION:=1.4
PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_MAINTAINER:=Vishal <yourname@domain.for.your.name>
PKG_LICENSE:=ISC
include $(INCLUDE_DIR)/package.mk
define Package/viva/default
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=Webpage for package creation
endef
define Package/viva
$(Package/viva/default)
DEPENDS:=+uhttpd
endef
define Package/viva/description
A web page used for illustrating package creation
endef
define Package/viva/install
$(CP) ./files/* $(1)/
endef
define Build/Compile
true
endef
$(eval $(call BuildPackage,viva))