├── .gitignore ├── README.md ├── builder.sh └── download.sh /.gitignore: -------------------------------------------------------------------------------- 1 | 1806 2 | 1907 3 | packages 4 | qsdk53 5 | *.ipk 6 | build_log.txt 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenWRT SDK for GL.iNet devices 2 | 3 | OpenWRT SDK for GL.iNet devices. The OpenWRT SDK is a pre-compiled environment suitable for creating custom packages without having to compile the entire OpenWRT build environment. 4 | 5 | ![:!:](https://openwrt.org/lib/images/smileys/icon_exclaim.gif) Do everything as normal user, don't use root user or sudo! 6 | 7 | ![:!:](https://openwrt.org/lib/images/smileys/icon_exclaim.gif) Do not build in a directory that has spaces in its full path 8 | 9 | ## System requirements 10 | 11 | - x86_64 platform 12 | - Ubuntu or another linux distro 13 | 14 | Compiling under Windows can be done using the Windows Subsystem For Linux (WSL) with Ubuntu installed to it. Follow the guide bellow, installing Ubuntu 18.04 LTS from the Microsoft Store: 15 | 16 | https://docs.microsoft.com/en-us/windows/wsl/install-win10 17 | 18 | ## Preparing your build environment 19 | 20 | To use the SDK on your system will usually require you to install some extra packages. 21 | 22 | For **Ubuntu 18.04 LTS**, run the following commands to install the required packages: 23 | 24 | ``` 25 | $ sudo apt update && sudo apt upgrade -y 26 | ``` 27 | ``` 28 | $ sudo apt install asciidoc bash bc binutils bzip2 fastjar flex gawk gcc genisoimage gettext git intltool jikespg libgtk2.0-dev libncurses5-dev libssl1.0-dev make mercurial patch perl-modules python2.7-dev rsync ruby sdcc subversion unzip util-linux wget xsltproc zlib1g-dev zlib1g-dev -y 29 | ``` 30 | 31 | # Downloads 32 | 33 | ``` 34 | $ git clone https://github.com/gl-inet/sdk.git 35 | ``` 36 | 37 | The SDK requires a "case sensitive" system, Windows is unfortunately not. To run the SDK in WSL you **MUST** clone the repo to the linux folder tree, ie: `/home//` or any other folder you choose. This is required, you **CAN NOT** run it from `/mnt/c/` or any other windows native drive mounted in WSL. Running the SDK from a Windows mounted disk will result in a failed build with cryptic messages. 38 | 39 | For ease of use, We store the SDK separately. You can download the specified SDK by the following command. 40 | 41 | ``` 42 | $ ./download.sh 43 | Usage: 44 | ./download.sh [target] # Download the appropriate SDK 45 | 46 | All available target list: 47 | ar71xx-1806 # usb150/ar150/ar300m16/mifi/ar750/ar750s/x750/x1200 48 | ath79-1907 # usb150/ar150/ar300m/mifi/ar750/ar750s/x750/x300b/xe300/e750/x1200 openwrt-19.07.7 ath79 target 49 | ramips-1806 # mt300n-v2/mt300a/mt300n/n300/vixmini 50 | ramips-1907 # mt1300 mt300n-v2/mt300a/mt300n/n300/vixmini 51 | ipq806x-qsdk53 # b1300/s1300 52 | ipq_ipq40xx-qsdk11 # b1300/s1300/ap1300/b2200 (version 3.201 and above) 53 | ipq_ipq60xx-qsdk11 # ax1800 54 | mvebu-1907 # mv1000 55 | siflower-1806 # sf1200/sft1200 56 | ipq807x-2102 # ax1800/axt1800 (version 4.x and above) 57 | ``` 58 | 59 | # Compiling 60 | 61 | ## Official compilation method 62 | 63 | Place your package in `sdk///package/`, then run: 64 | 65 | ``` 66 | $ cd sdk/// 67 | $ make package//compile V=s 68 | ``` 69 | 70 | For example, to compile the OpenSSL package for the `ar71xx` target, it will look like this: 71 | 72 | ``` 73 | $ cd sdk/1806/ar71xx 74 | $ make package/openssl/{clean,compile} V=s 75 | ``` 76 | 77 | The compiled package will be in the `sdk///bin/` folder 78 | 79 | It is recommended that you use the `V=s` flag at the end of the `make` command, but it is not required. The compiler will print all messages and show if there are any errrors. If you know the packages are all correct, you can omit it for a more clean output. 80 | 81 | Some packages require other packages to compile. If your package gives warnings like this: 82 | 83 | ``` 84 | WARNING: Makefile 'package/ddserver/Makefile' has a dependency on 'uclibcxx', which does not exist 85 | ``` 86 | 87 | Before the compilation begins, or when compiling with the `V=s` flag you get an error towards the end like this: 88 | 89 | ``` 90 | Package ddserver is missing dependencies for the following libraries: 91 | libuClibc++.so.0 92 | ``` 93 | 94 | You will need to install the dependency before compiling your package. To do that run: 95 | 96 | ``` 97 | $ ./scripts/feeds update -f 98 | ``` 99 | 100 | This will update the package lists, then run: 101 | 102 | ``` 103 | $ ./scripts/feeds install 104 | ``` 105 | 106 | For the example above, it required the uClibc++ library, so we install it: 107 | 108 | ``` 109 | $ ./scripts/feeds install uclibcxx 110 | ``` 111 | 112 | Re-run the `make package//compile V=s` command and your package should compile without issues. 113 | 114 | ------ 115 | 116 | ``` 117 | To make a custom package from any program you can follow the guides here: 118 | ``` 119 | 120 | https://github.com/mwarning/openwrt-examples 121 | 122 | ``` 123 | And read about the OpenWRT package structure here: 124 | ``` 125 | 126 | https://openwrt.org/docs/guide-developer/packages 127 | 128 | ## GL.iNet Util compilation method 129 | 130 | We provide a script to compile all software packages with all targets SDK or compile all software packages with a single target SDK. You are freely and quickly compile packages for each platform. 131 | 132 | ``` 133 | $ ./builder.sh 134 | Usage: 135 | ./builder.sh [option] 136 | command: 137 | [-a] # Compile all software packages with all targets. 138 | [-t] [target] # Compile packages with single targets. 139 | [-d] [package_path] # Package path. 140 | [-v] # Enable compile log. 141 | 142 | All available target list: 143 | ar71xx-1806 # usb150/ar150/ar300m16/mifi/ar750/ar750s/x750/x1200 144 | ath79-1907 # usb150/ar150/ar300m/mifi/ar750/ar750s/x750/x300b/xe300/e750/x1200 openwrt-19.07.7 ath79 target 145 | ramips-1806 # mt300n-v2/mt300a/mt300n/n300/vixmini 146 | ramips-1907 # mt1300 mt300n-v2/mt300a/mt300n/n300/vixmini 147 | ipq806x-qsdk53 # b1300/s1300 148 | mvebu-1907 # mv1000 149 | siflower-1806 # sf1200/sft1200 150 | ipq807x-2102 # ax1800/axt1800 (version 4.x and above) 151 | ``` 152 | 153 | You can put all your packages to a folder, then run the following command to compile packages for the specified platform, 154 | 155 | ``` 156 | $ ./builder.sh -d [packages_path] -t [target] 157 | ``` 158 | 159 | Or run the following command to compile packages for all platform, 160 | 161 | ``` 162 | $ ./builder.sh -d [packages_path] -a 163 | ``` 164 | 165 | # Installing 166 | 167 | Once the package has been compiled, you can transfer the package via SSH to the GL-iNet device following the guides here: 168 | 169 | https://docs.gl-inet.com/en/3/app/ssh/ 170 | 171 | Then running: 172 | 173 | ``` 174 | $ opkg install .ipk 175 | ``` 176 | 177 | Will install the package on the device without internet. 178 | -------------------------------------------------------------------------------- /builder.sh: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env bash 2 | 3 | set -e 4 | 5 | work_dir="$PWD" 6 | sdk_dir="sdk" 7 | targets="ar71xx-1806 ath79-1907 ramips-1806 ramips-1907 ipq806x-qsdk53 ipq_ipq40xx-qsdk11 ipq_ipq60xx-qsdk11 mvebu-1907 siflower-1806 ipq807x-2102" 8 | dl_dir="/data/dl" 9 | build_log="build_log.txt" 10 | 11 | usage() { 12 | cat <<-EOF 13 | Usage: 14 | ./builder.sh [option] 15 | command: 16 | [-a] # Compile all software packages with all targets. 17 | [-t] [target] # Compile packages with single targets. 18 | [-d] [package_path] # Package path. 19 | [-v] # Enable compile log. 20 | 21 | All available target list: 22 | ar71xx-1806 # usb150/ar150/ar300m16/mifi/ar750/ar750s/x750/x1200 23 | ath79-1907 # usb150/ar150/ar300m/mifi/ar750/ar750s/x750/x300b/xe300/e750/x1200 openwrt-19.07.7 ath79 target 24 | ramips-1806 # mt300n-v2/mt300a/mt300n/n300/vixmini 25 | ramips-1907 # mt1300 mt300n-v2/mt300a/mt300n/n300/vixmini 26 | ipq806x-qsdk53 # b1300/s1300/ap1300/b2200 27 | ipq_ipq40xx-qsdk11 # b1300/s1300/ap1300/b2200 (version 3.201 and above) 28 | ipq_ipq60xx-qsdk11 # ax1800 29 | mvebu-1907 # mv1000 30 | siflower-1806 # sf1200/sft1200 31 | ipq807x-2102 # ax1800/axt1800 (version 4.x and above) 32 | 33 | EOF 34 | exit 0 35 | } 36 | 37 | check_target_valid() { 38 | 39 | for target in $targets; do 40 | [ "$target" = "$COMPILE_TARGET" ] && return 1 41 | done 42 | 43 | return 0 44 | } 45 | 46 | check_package_valid() { 47 | local pkg_name 48 | 49 | [ ! -f "$1/Makefile" ] && return 0 50 | 51 | pkg_name=$(cat $1/Makefile|grep PKG_NAME) 52 | [ -n "$pkg_name" ] && return 1 53 | return 0 54 | } 55 | 56 | compile_all_target() { 57 | 58 | time=$(date '+%Y-%m-%d %T') 59 | 60 | local packages_dir=$(cd $COMPILE_DIR; pwd; cd ..) 61 | [ "${packages_dir: -1}" = "/" ] && packages_dir=${packages_dir%/*} # 如果var变量最后一个字符是/,需先去掉 62 | 63 | local packages_name="${packages_dir##*/}" 64 | local sdk_exist=0 65 | for target in $targets; do 66 | version="${target#*-}" 67 | target="${target%-*}" 68 | 69 | [ -d "$sdk_dir/$version/$target" ] && { 70 | echo "$time===========>> Compile '$sdk_dir/$version/$target' packages START <<===========" >> $build_log 71 | [ ! -e "$sdk_dir/$version/$target/package/$packages_name" ] && ln -sf $packages_dir $sdk_dir/$version/$target/package/$packages_name 72 | pushd $sdk_dir/$version/$target > /dev/null 73 | make $MAKE_PARAMETER 74 | popd > /dev/null 75 | echo "$time===========>> Compile '$sdk_dir/$version/$target' packages END <<===========" >> $build_log 76 | sdk_exist=1 77 | } 78 | done 79 | [ $sdk_exist = 0 ] && { 80 | printf "\nError: SDK not found. You need to download SDK first through download.sh script.\n\n" 81 | } 82 | exit 0 83 | } 84 | 85 | compile_single_target() { 86 | 87 | time=$(date '+%Y-%m-%d %T') 88 | 89 | local packages_dir=$(cd $COMPILE_DIR; pwd; cd ..) 90 | [ "${packages_dir: -1}" = "/" ] && packages_dir=${packages_dir%/*} # 如果var变量最后一个字符是/,需先去掉 91 | 92 | local packages_name="${packages_dir##*/}" 93 | local sdk_exist=0 94 | 95 | version="${COMPILE_TARGET#*-}" 96 | target="${COMPILE_TARGET%-*}" 97 | [ -d "$sdk_dir/$version/$target" ] && { 98 | echo "$time===========>> Compile '$sdk_dir/$version/$target' packages START <<===========" >> $build_log 99 | [ ! -e "$sdk_dir/$version/$target/package/$packages_name" ] && ln -sf $packages_dir $sdk_dir/$version/$target/package/$packages_name 100 | pushd $sdk_dir/$version/$target > /dev/null 101 | if [ $(check_package_valid "package/$packages_name"; echo $?) = 1 ]; then 102 | make package/$packages_name/{clean,compile} $MAKE_PARAMETER 103 | else 104 | make $MAKE_PARAMETER 105 | fi 106 | popd > /dev/null 107 | echo "$time===========>> Compile '$sdk_dir/$version/$target' packages END <<===========" >> $build_log 108 | sdk_exist=1 109 | } 110 | [ $sdk_exist = 0 ] && { 111 | printf "\nError: SDK not found. You need to download SDK first through download.sh script.\n\n" 112 | } 113 | exit 0 114 | } 115 | 116 | export COMFILE_ALL=0 117 | export COMPILE_TARGET="" 118 | export COMPILE_DIR="" 119 | export COMPILE_VERBOSE=0 120 | export MAKE_PARAMETER="" 121 | 122 | while getopts "t:p:d:av" arg; do #字符后边有':'则表示有参数 123 | case "$arg" in 124 | a) export COMFILE_ALL=1;; 125 | t) export COMPILE_TARGET=$OPTARG;; 126 | d) export COMPILE_DIR=$OPTARG;; 127 | v) export COMPILE_VERBOSE=1;; 128 | \?) usage;; 129 | esac 130 | done 131 | 132 | [ $COMPILE_VERBOSE = 1 ] && export MAKE_PARAMETER="V=s" 133 | 134 | [ -f "$build_log" ] && rm $build_log 135 | [ -z "$1" ] && usage 136 | [ -z "$COMPILE_DIR" ] && { 137 | printf "\nError: Please use '-d' parameter to set COMPILE_DIR.\n\n" 138 | usage 139 | } 140 | 141 | [ $COMFILE_ALL = 1 ] && compile_all_target 142 | 143 | [ -z "$COMPILE_TARGET" ] && { 144 | printf "\nError: Please use '-t' parameter to set COMPILE_TARGET.\n\n" 145 | usage 146 | } 147 | 148 | [ $(check_target_valid; echo $?) = 0 ] && { 149 | printf "\nError: Target doesn't exist. Please select target from available target list.\n\n" 150 | usage 151 | } 152 | 153 | [ $COMFILE_ALL = 0 ] && compile_single_target 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /download.sh: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env bash 2 | # set -e 3 | 4 | work_dir="$PWD" 5 | sdk_dir="sdk" 6 | targets="ar71xx-1806 ath79-1907 ramips-1806 ramips-1907 ipq806x-qsdk53 ipq_ipq40xx-qsdk11 ipq_ipq60xx-qsdk11 mvebu-1907 siflower-1806 ipq807x-2102" 7 | 8 | gl_inet_imagebuilder_url="https://github.com/gl-inet-builder" 9 | 10 | usage() { 11 | cat <<-EOF 12 | Usage: 13 | ./download.sh [target] # Download the appropriate SDK 14 | 15 | All available target list: 16 | ar71xx-1806 # usb150/ar150/ar300m16/mifi/ar750/ar750s/x750/x1200 17 | ath79-1907 # usb150/ar150/ar300m/mifi/ar750/ar750s/x750/x300b/xe300/e750/x1200 openwrt-19.07.7 ath79 target 18 | ramips-1806 # mt300n-v2/mt300a/mt300n/n300/vixmini 19 | ramips-1907 # mt1300/mt300n-v2/mt300a/mt300n/n300/vixmini 20 | ipq806x-qsdk53 # b1300/s1300/ap1300/b2200 21 | ipq_ipq40xx-qsdk11 # b1300/s1300/ap1300/b2200 (version 3.201 and above) 22 | ipq_ipq60xx-qsdk11 # ax1800 23 | mvebu-1907 # mv1000 24 | siflower-1806 # sf1200/sft1200 25 | ipq807x-2102 # ax1800/axt1800 (version 4.x and above) 26 | 27 | EOF 28 | exit 0 29 | } 30 | 31 | [ -z "$1" ] && usage 32 | 33 | sdk_name=$1 34 | 35 | download_sdk() { 36 | for i in $targets; do 37 | [ "$i" != "$sdk_name" ] && continue 38 | 39 | echo "Download $i SDK" 40 | version="${sdk_name#*-}" 41 | target="${sdk_name%-*}" 42 | 43 | # Download/Update OpenWrt SDK 44 | if [ ! -d "$sdk_dir/$version/$target" ]; then 45 | git clone $gl_inet_imagebuilder_url/openwrt-sdk-$sdk_name.git $sdk_dir/$version/$target 46 | [ "$target" != "ipq806x" ] && { 47 | pushd $sdk_dir/$version/$target > /dev/null 48 | ./scripts/feeds update 49 | ./scripts/feeds install uci curl libubus libubox libiwinfo libsqlite3 mqtt fcgi #install default depends packages 50 | make defconfig 51 | popd > /dev/null 52 | printf "\nUse 'builder.sh script to compile all your packages.\nRun './builder.sh' to get more help.\n\n" 53 | } 54 | else 55 | pushd $sdk_dir/$version/$target > /dev/null 56 | git pull 57 | popd > /dev/null 58 | fi 59 | exit 0 60 | done 61 | } 62 | download_sdk 63 | printf "\nError: Can't found '$sdk_name' target. Please check available target list again!\n\n" && usage 64 | --------------------------------------------------------------------------------