@Antek, please let us continue here. Everything over again:
Get OpenWRT source (in Ubuntu 17.10 64 bit, user andrei):
~/Git$ git clone https://github.com/openwrt/openwrt.git
~/Git/openwrt$ ./scripts/feeds update -a
~/Git/openwrt$ ./scripts/feeds install -a
~/Git/openwrt$ make menuconfig
In make menuconfig change:
a. * for LuCi.
b. Select Ralink Mediatek MIPS / MT7621 / ZBT-WE1326 profile.
Compile source:
~/Git/openwrt$ make prereq
~/Git/openwrt$ make download
~/Git/openwrt$ make check
~/Git/openwrt$ make V=s
Create package helloworld:
~/helloworld$ touch helloworld.c
in helloworld.c:
#include <stdio.h>
int main(void) { printf("\nHello, world!\n\n"); return 0; }
in Makefile (not makefile and replace in it all spaces with tabs):
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/andrei/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))
feed:
~/Git/openwrt$ touch feeds.conf
in feeds.conf: src-link mypackages /home/andrei/mypackages
Install mypackages:
~/Git/openwrt$ ./scripts/feeds update mypackages
~/Git/openwrt$ ./scripts/feeds install -a -p mypackages
~/Git/openwrt$ make menuconfig
in submenu Examples mark helloworld with *.
Compile helloworld package: ~/Git/openwrt$ make package/helloworld/compile
If everything went successfully, we are presented with a brand new package named helloworld_1.0-1_???.ipk in bin/packages/???/mypackages folder.
The steps you take seem correct. If the compilation succeeds, the package should be found from somewhere under ~/Git/openwrt/bin/packages folder.
The final folder structure depends on your target/subtarget/profile selections, so just use find to locate the package. It contains "helloworld_1.0-1" in its name.
If you use make instead of make package/helloworld/compile then you'll be presented with a firmware image that installs helloworld into the directory that you specify in Package/helloworld/install section of the package manifest file.
Now that the package is ready, we can deploy and install it on the target router. The author recommends using a SCP client such as WinSCP in order to transfer the file from the development environment into your router. For installation purposes, you can save the package to the /tmp folder on your router.
Assuming you transferred the package to the /tmp folder, you can use the OPKG tool to install the package using the following command:
~/Git/openwrt$ ssh-keygen -f "/home/andrei/.ssh/known_hosts" -R 192.168.1.1
# Host 192.168.1.1 found: line 1
/home/andrei/.ssh/known_hosts updated.
Original contents retained as /home/andrei/.ssh/known_hosts.old
~/Git/openwrt$ ssh root@192.168.1.1
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
RSA key fingerprint is SHA256:L8HE3xSG7Hfvs0dW28Zq6J9gUMusmHfBmPTlK6nnBGU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.1' (RSA) to the list of known hosts.
BusyBox v1.27.2 () built-in shell (ash)
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt SNAPSHOT, r6067-e2ec3f7550