OpenWrt port to LingYun IGKboards
guowenxue
2026-05-20 d2b7f71166609c2ca9bed4e7a431f8a6de4b4c2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash
 
# board
BOARD=igkboard-rk3576
 
# openwrt branch
BRANCH=openwrt-25.12
 
#openwrt url
GITURL=https://github.com/openwrt/openwrt.git
 
# this project absolute path
PRJ_PATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
 
# binaries build prefix install path
PRFX_PATH=$PRJ_PATH/install
 
# binaries finally install path if needed
#INST_PATH=/tftp
 
# config file path
CONF_FILE=$PRJ_PATH/config.json
 
# shell script will exit once get command error
set -e
 
#+-------------------------+
#| Shell script functions  |
#+-------------------------+
 
function pr_error() {
    echo -e "\033[40;31m $1 \033[0m"
}
 
function pr_warn() {
    echo -e "\033[40;33m $1 \033[0m"
}
 
function pr_info() {
    echo -e "\033[40;32m $1 \033[0m"
}
 
# decompress a packet to destination path
function do_unpack()
{
    tarball=$1
    dstpath=`pwd`
 
    if [[ $# == 2 ]] ; then
        dstpath=$2
    fi
 
    pr_info "decompress $tarball => $dstpath"
 
    mkdir -p $dstpath
    case $tarball in
        *.tar.gz)
            tar -xzf $tarball -C $dstpath
            ;;
 
        *.tar.bz2)
            tar -xjf $tarball -C $dstpath
            ;;
 
        *.tar.xz)
            tar -xJf $tarball -C $dstpath
            ;;
 
        *.tar.zst)
            tar -I zstd -xf $tarball -C $dstpath
            ;;
 
        *.tar)
            tar -xf $tarball -C $dstpath
            ;;
 
        *.zip)
            unzip -qo $tarball -d $dstpath
            ;;
 
        *)
            pr_error "decompress Unsupport packet: $tarball"
            return 1;
            ;;
    esac
}
 
# parser configure file and export environment variable
function do_export()
{
    export SDK=$BRANCH
}
 
function do_fetch()
{
    cd $PRJ_PATH
 
    if [ -f $SDK/Makefile ] ; then
        pr_info "$SDK source code fetched already"
        return 0;
    fi
 
    pr_info "start fetch source code"
    git clone $GITURL -b $BRANCH $SDK --depth=1
 
    cd $SDK && pwd
 
    sed -i 's#https://git.openwrt.org/feed/#https://github.com/openwrt/#g' feeds.conf.default
    sed -i 's#https://git.openwrt.org/project/#https://github.com/openwrt/#g' feeds.conf.default
    sed -i 's#https://git.openwrt.org/#https://github.com/openwrt/#g' feeds.conf.default
 
    pr_info "start feeds update and install "
    ./scripts/feeds update -a
    ./scripts/feeds install -a
 
}
 
function do_patch()
{
    PATCH_FILE=$PRJ_PATH/patch/${BRANCH}-${BOARD}.patch
 
    cd $PRJ_PATH/$SDK
 
    if [ ! -f patched.tag ] ; then
        pr_info "do patch $(basename $PATCH_FILE)"
        patch -p1 < $PATCH_FILE
    fi
}
 
function do_build()
{
    DEF_CONFIG=.${BOARD}.defconfig
 
    IMAGE_PATH=bin/targets/*/*/
 
    cd $PRJ_PATH/$SDK
 
    pr_info "make defconfig: $DEF_CONFIG"
    cp $DEF_CONFIG .config
 
    echo ""
    pr_warn "startu build..."
    #make V=s -j$(nproc)
    make -j1
 
    echo ""
    pr_warn "output images path: $IMAGE_PATH"
    ls $IMAGE_PATH
    echo ""
}
 
function do_clean()
{
    cd $WKSP/SDK && pwd
 
    pr_warn "start clean"
    make clean
}
 
#+-------------------------+
#| Shell script body entry |
#+-------------------------+
 
do_export
 
if [[ $# == 1 && $1 == -c ]] ;then
    do_clean
    exit;
fi
 
pr_warn "start build $SDK SDK for ${BOARD}"
 
do_fetch
 
do_patch
 
do_build