What's new

Entware [SOLUTION] Cross-Compile xxHash Entware Package via Debian Live DVD

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

garycnew

Senior Member
NOTE: After finally being convinced by the Entware & OpenWRT Developers that neither Build Environment was meant to be Compiled Natively on a Router (Neutered C Libraries), I decided to pursue this Cross-Compile xxHash Entware Package via Debian Live DVD solution; which, is presumably a bit slower, but ultimately successful. It wasn't too terrible after finding the right cross-compiling platform and combining a few different build references.

Requirements/Assumptions:

Cross-Compiling Host Machine:
1. Plenty of Physical Memory (RAM)
2. Debian Live (Testing) DVD
3. Flash Drive >= 32GB (Preferably USB 3.0/3.1)

xxHash Installation Machine:
1. An Asuswrt-Merlin Compatible Router (i.e., Asus RT-AC66U)
2. Asuswrt-Merlin Compatible Firmware (i.e., 384.19)
3. Formated JFFS Partition and Enabled JFFS Custom Scripts and Configs
4. Entware installed on USB 3.0 Interface Device via Asuswrt-Merlin Terminal Menu (AMTM) with Swap File created

NOTE: Not sure if it matters... At the time of this writing, Debian Bullseye (Testing) Live DVD contained the same package versions as the current Entware repository, opposed to the Debian Buster (Stable) Live DVD, so we opted to use the Debian Bullseye (Testing) Live DVD.

### Download & Burn Debian Live (Testing) DVD ###
Code:
$ curl -L -O -C - http://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/weekly-live-builds/amd64/iso-hybrid/debian-live-testing-amd64-gnome+nonfree.iso

### Boot Debian Live (Testing) DVD on the Cross-Compiling Host Machine ###
Our Cross-Compiling Host Machine required the [F12] key to be pressed during boot to enter into the Boot Menu and select the Debian Live (Testing) DVD. Make sure you setup and have Internet access on the Cross-Compiling Host Machine.

### Open Terminal ###

### Mount Flash Drive (Repeat after each DVD Boot) ###
Code:
$ sudo -p /media/user/SanDiskSDCZ
$ sudo mount /dev/sdb1 /media/user/SanDiskSDCZ
$ cd /media/user/SanDiskSDCZ/

### Download & Install Build System (Repeat after each DVD Boot) ###
Code:
$ sudo apt-get update
$ sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip gawk zlib1g-dev
$ sudo apt-get install python2 wget

### Clone, Setup, & Make Entware Build Env ###
Code:
$ git clone https://github.com/Entware/Entware.git
$ cd Entware

# Update OpenWRT Feeds
$ ./scripts/feeds update -a

# Symlink Packages (Repeat after each DVD Boot)
$ make package/symlinks

# Copy the config specific to your Architecture and Kernel versions
$ cp configs/armv7-2.6.config .config

$ make tools/install && make toolchain/install && make target/compile
or
#$ make -j1 V=sc tools/install
#$ make -j1 V=sc toolchain/install
#$ make -j1 V=sc target/compile

### Download, Prepare, & Compile Test Package from OpenWRT Feed ###
Code:
#$ ./scripts/feeds install screen
or
$ make -j1 V=sc package/screen/download
$ make -j1 V=sc package/screen/check
$ find package/ -iname "*screen*"
package/feeds/packages/screen

$ make -j1 V=sc package/screen/prepare
$ make -j1 V=sc package/screen/compile
#$ make -j1 V=sc package/screen/install
#$ make package/index

$ find bin/ -iname "*screen*"
bin/targets/armv7-2.6/generic-glibc/packages/screen_4.8.0-2_armv7-2.6.ipk

### Download & Prepare OpenWRT Feed Package modified for Entware (When Available) ###
Code:
#$ ./scripts/feeds install xxhash
or
$ make -j1 V=sc package/feeds/packages/xxhash/download
$ make -j1 V=sc package/feeds/packages/xxhash/check
$ find package/ -iname "*xxhash*"
package/feeds/packages/xxhash

### Edit the Makefile to use the /opt directory prefix ###
Code:
$ diff package/feeds/packages/xxhash/Makefile.orig package/feeds/packages/xxhash/Makefile
53,58c53,58
<     $(INSTALL_DIR) $(1)/usr/include
<     $(CP) $(PKG_BUILD_DIR)/*.h $(1)/usr/include
<     $(INSTALL_DIR) $(1)/usr/lib
<     $(CP) $(PKG_BUILD_DIR)/libxxhash.so $(1)/usr/lib
<     $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
<     $(CP) $(PKG_BUILD_DIR)/libxxhash.pc.in $(1)/usr/lib/pkgconfig
---
>     $(INSTALL_DIR) $(1)/opt/include
>     $(CP) $(PKG_BUILD_DIR)/*.h $(1)/opt/include
>     $(INSTALL_DIR) $(1)/opt/lib
>     $(CP) $(PKG_BUILD_DIR)/libxxhash.so $(1)/opt/lib
>     $(INSTALL_DIR) $(1)/opt/lib/pkgconfig
>     $(CP) $(PKG_BUILD_DIR)/libxxhash.pc.in $(1)/opt/lib/pkgconfig
62,65c62,65
<     $(INSTALL_DIR) $(1)/usr/lib
<     $(CP) $(PKG_BUILD_DIR)/libxxhash.so* $(1)/usr/lib
<     $(INSTALL_DIR) $(1)/usr/bin
<     $(INSTALL_BIN) $(PKG_BUILD_DIR)/xxh*sum $(1)/usr/bin/
---
>     $(INSTALL_DIR) $(1)/opt/lib
>     $(CP) $(PKG_BUILD_DIR)/libxxhash.so* $(1)/opt/lib
>     $(INSTALL_DIR) $(1)/opt/bin
>     $(INSTALL_BIN) $(PKG_BUILD_DIR)/xxh*sum $(1)/opt/bin/

### Select xxhash for [M]odular inclusion under the SECTION => CATEGORY => SUBMENU of menuconfig ###
Code:
$ make menuconfig
define Package/xxhash/Default
SECTION:=utils
CATEGORY:=Utilities
URL:=http://www.xxhash.com
endef

define Package/xxhash
$(call Package/xxhash/Default)
TITLE:=Extremely fast hash algorithm
#DEPENDS:=+make +gcc
endef

### Compile OpenWRT Feed Package modified for Entware ###
Code:
$ make -j1 V=sc package/feeds/packages/xxhash/prepare
$ make -j1 V=sc package/feeds/packages/xxhash/compile
#$ make -j1 V=sc package/feeds/packages/xxhash/install
#$ make package/index

$ find bin/ -iname "*xxhash*"
bin/targets/armv7-2.6/generic-glibc/packages/xxhash_0.8.1-1_armv7-2.6.ipk

### SFTP & SSH xxhash Package to xxHash Installation Machine(s) ###
Code:
$ cd bin/targets/armv7-2.6/generic-glibc/packages/
$ sftp admin@192.168.0.1
sftp> cd /tmp/mnt/SanDiskSDHC/
sftp> put xxhash_0.8.1-1_armv7-2.6.ipk

$ ssh admin@192.168.0.1
# cd /tmp/mnt/SanDiskSDHC/
# opkg install ./xxhash_0.8.1-1_armv7-2.6.ipk

# opkg list-installed|grep -i xxhash
xxhash - 0.8.1-1

# opkg files xxhash
Package xxhash (0.8.1-1) is installed on root and has the following files:
/opt/bin/xxhsum
/opt/bin/xxh64sum
/opt/bin/xxh128sum
/opt/bin/xxh32sum
/opt/lib/libxxhash.so.0
/opt/lib/libxxhash.so
/opt/lib/libxxhash.so.0.8.1

# opkg info xxhash
Package: xxhash
Version: 0.8.1-1
Depends: libc, libssp, librt, libpthread
Status: install user installed
Architecture: armv7-2.6
Installed-Time: 1643162375

# /opt/bin/xxhsum -h
xxhsum 0.8.1 by Yann Collet
Print or verify checksums using fast non-cryptographic algorithm xxHash

# /bin/echo "Non-Cryptographic" | /opt/bin/xxhsum
a437783b51578b0f  stdin

Congratulations! You've Cross-Compiled a xxHash Entware Package via Debian Live (Testing) DVD! The Possibilities are Endless with Good-Times Ahead!

References:
Code:
http://bin.entware.net/armv7sf-k2.6/
http://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/weekly-live-builds/amd64/iso-hybrid/
https://packages.debian.org/search?keywords=search
https://oldwiki.archive.openwrt.org/about/toolchain
https://oldwiki.archive.openwrt.org/doc/howto/buildroot.exigence
https://oldwiki.archive.openwrt.org/doc/howto/build.a.package
https://github.com/Entware/Entware/wiki/How-to-add-a-new-package
https://github.com/Entware/Entware-ng/wiki/Using-gcc-%28native-compilation%29
https://github.com/Cyan4973/xxHash
https://src.fedoraproject.org/rpms/xxhash/blob/f33/f/xxhash.spec

### Full Edited xxhash Makefile ###
Code:
$ cat feeds/packages/utils/xxhash/Makefile
#
# Copyright (C) 2006-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=xxhash
PKG_VERSION:=0.8.1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/Cyan4973/xxHash/archive/v$(PKG_VERSION)
PKG_HASH:=3bb6b7d6f30c591dd65aaaff1c8b7a5b94d81687998ca9400082c739a690436c

# The source for the library (xxhash.c and xxhash.h) is BSD
# The source for the command line tool (xxhsum.c) is GPLv2+
PKG_MAINTAINER:=https://github.com/Cyan4973/xxHash
PKG_LICENSE:=BSD and GPLv2+
PKG_LICENSE_FILES:=COPYING

include $(INCLUDE_DIR)/package.mk

define Package/xxhash/Default
  SECTION:=utils
  CATEGORY:=Utilities
  URL:=http://www.xxhash.com
endef

define Package/xxhash
  $(call Package/xxhash/Default)
  TITLE:=Extremely fast hash algorithm
  #DEPENDS:=+make +gcc
endef

define Package/xxhash/description
xxHash is an Extremely fast Hash algorithm, running at RAM speed
limits. It successfully completes the SMHasher test suite which
evaluates collision, dispersion and randomness qualities of hash
functions. Code is highly portable, and hashes are identical on all
platforms (little / big endian).
endef

define Build/Prepare
    rm -rf $(PKG_BUILD_DIR)/
    mkdir -p $(PKG_BUILD_DIR)/
    $(TAR) -xzf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR) --strip 1
endef

define Build/InstallDev
    $(INSTALL_DIR) $(1)/opt/include
    $(CP) $(PKG_BUILD_DIR)/*.h $(1)/opt/include
    $(INSTALL_DIR) $(1)/opt/lib
    $(CP) $(PKG_BUILD_DIR)/libxxhash.so $(1)/opt/lib
    $(INSTALL_DIR) $(1)/opt/lib/pkgconfig
    $(CP) $(PKG_BUILD_DIR)/libxxhash.pc.in $(1)/opt/lib/pkgconfig
endef

define Package/xxhash/install
    $(INSTALL_DIR) $(1)/opt/lib
    $(CP) $(PKG_BUILD_DIR)/libxxhash.so* $(1)/opt/lib
    $(INSTALL_DIR) $(1)/opt/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/xxh*sum $(1)/opt/bin/
endef

$(eval $(call BuildPackage,xxhash))
 

Attachments

  • xxhash_0.8.1-1_armv7-2.6.txt
    196.6 KB · Views: 102
Last edited:

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top