sdk下载
https://code.aliyun.com/
Ubuntu16.04系统:
sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev unzip texinfo device-tree-compiler
如果是Suse系统:
安装ncurse-devel text-info dtc zlib-devel-static
安装了svn还会提示找不到
Build dependency: Please install the Subversion client
解决:
ln -s /usr/bin/svn ./staging_dir/host/bin/svn
正常步骤
cd openwrt
cp configs/leo_gx8010_ssd_1v_defconfig .config
make defconfig
make V=s -j4
出错问题
/home/zm/下载/guoxin/openwrt/build_dir/host/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c: In function 'get_cert_chain':
/home/zm/下载/guoxin/openwrt/build_dir/host/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c:2482:13: error: dereferencing pointer to incomplete type 'X509 {aka struct x509_st}'
cinf = x->cert_info;
^~
/home/zm/下载/guoxin/openwrt/build_dir/host/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c:2484:30: error: dereferencing pointer to incomplete type 'X509_CINF {aka struct x509_cinf_st}'
j = asn1_object_dump(cinf->signature->algorithm, bufp, CERTBUFFERSIZE);
^~
/home/zm/下载/guoxin/openwrt/build_dir/host/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c:2510:20: error: dereferencing pointer to incomplete type 'EVP_PKEY {aka struct evp_pkey_st}'
switch(pubkey->type) {
针对openwrt编译对上openssl-1.1.x版本出错问题,一种方法就是降openssl版本到1.0,另外一种方法下面讲
1)解决:
到
https://git.openwrt.org/?p=openwrt/openwrt.git;a=tree;f=tools/mkimage/patches;h=ee5e92e913e487f63a5d8a82ebd43ccdd7b0a3f7;hb=70b104f98c0657323b28fce140b73a94bf3eb756
下载210那个patch并放到
tools/mkimage/patchs/210-openssl-1.1.x-compat.patch
2) automake 也会有ssl的编译错误
到
https://git.openwrt.org/?p=openwrt/openwrt.git;a=tree;f=tools/automake/patches;h=dcaa4da7ad8ec755a593b1feba3b88d6b9c64677;hb=92c80f38cff3c20388f9ac13d5196f2745aeaf77
下载
tools_automake_patches_010-automake-port-to-Perl-5.22-and-later.patch
mv ~/download/tools_automake_patches_010-automake-port-to-Perl-5.22-and-later.patch tools/automake/patches/010-automake-port-to-Perl-5.22-and-later.patch
3) 下载新cmake,不用3.6.1这个版本
首先浏览器打开
https://fossies.org/linux/misc/
查看里面最新版的cmake,比如现在是3.11.2
那么就修改 "tools/cmake/Makefile" "PKG_VERSION:=3.6.1"为PKG_VERSION=3.11.2 删除"tools/cmake/patches/110-...", 120-alpine_musl-compat.patch 100-disable_qt_tests.patch, 这几个patch
不删除patch会出现错误:
Applying ./patches/100-disable_qt_tests.patch using plaintext:
patching file Tests/RunCMake/CMakeLists.txt
Hunk #1 succeeded at 284 (offset 65 lines)
修改
PKG_MD5SUM:=d6dd661380adacdb12f41b926ec99545
为
PKG_MD5SUM:=d2d554c05fc07cfae7846d2aa205f12a
这个要跟具体下的包对应,每个版本对应md5值不一样,如果不知道,先不改PKG_MD5SUM然后编译,会提示错误
MD5 sum of the downloaded file does not match (file: d2d554c05fc07cfae7846d2aa205f12a, requested: d6dd661380adacdb12f41b926ec99545) - deleting download.
根据错误就知道怎么改了。
问题:
/home/zm/下载/guoxin/openwrt/build_dir/host/u-boot-2014.10/lib/rsa/rsa-sign.c: In function ‘rsa_get_exponent’:
/home/zm/下载/guoxin/openwrt/build_dir/host/u-boot-2014.10/lib/rsa/rsa-sign.c:279:21: error: dereferencing pointer to incomplete type ‘RSA {aka struct rsa_st}’
这个问题大致可以参考下面这个patch改,patch已经对应不上行号了,自己手动改吧
if (BN_num_bits(key->e) > 64)
make[5]: *** [scripts/Makefile.host:134: tools/lib/rsa/rsa-sign.o] Error 1
diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c
index 5d9716f..2127605 100644
--- a/lib/rsa/rsa-sign.c
+++ b/lib/rsa/rsa-sign.c
@@ -19,6 +19,19 @@
#define HAVE_ERR_REMOVE_THREAD_STATE
#endif
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+void RSA_get0_key(const RSA *r,
+ const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
+{
+ if (n != NULL)
+ *n = r->n;
+ if (e != NULL)
+ *e = r->e;
+ if (d != NULL)
+ *d = r->d;
+}
+#endif
+
static int rsa_err(const char *msg)
{
unsigned long sslErr = ERR_get_error();
@@ -210,7 +223,11 @@ static int rsa_sign_with_key(RSA *rsa, struct checksum_algo *checksum_algo,
ret = rsa_err("Could not obtain signature");
goto err_sign;
}
- EVP_MD_CTX_cleanup(context);
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
+ EVP_MD_CTX_cleanup(context);
+ #else
+ EVP_MD_CTX_reset(context);
+ #endif
EVP_MD_CTX_destroy(context);
EVP_PKEY_free(key);
@@ -268,6 +285,7 @@ static int rsa_get_exponent(RSA *key, uint64_t *e)
{
int ret;
BIGNUM *bn_te;
+ const BIGNUM *key_e;
uint64_t te;
ret = -EINVAL;
@@ -276,17 +294,18 @@ static int rsa_get_exponent(RSA *key, uint64_t *e)
if (!e)
goto cleanup;
- if (BN_num_bits(key->e) > 64)
+ RSA_get0_key(key, NULL, &key_e, NULL);
+ if (BN_num_bits(key_e) > 64)
goto cleanup;
- *e = BN_get_word(key->e);
+ *e = BN_get_word(key_e);
- if (BN_num_bits(key->e) < 33) {
+ if (BN_num_bits(key_e) < 33) {
ret = 0;
goto cleanup;
}
- bn_te = BN_dup(key->e);
+ bn_te = BN_dup(key_e);
if (!bn_te)
goto cleanup;
@@ -316,6 +335,7 @@ int rsa_get_params(RSA *key, uint64_t *exponent, uint32_t *n0_invp,
{
BIGNUM *big1, *big2, *big32, *big2_32;
BIGNUM *n, *r, *r_squared, *tmp;
+ const BIGNUM *key_n;
BN_CTX *bn_ctx = BN_CTX_new();
int ret = 0;
@@ -337,7 +357,8 @@ int rsa_get_params(RSA *key, uint64_t *exponent, uint32_t *n0_invp,
if (0 != rsa_get_exponent(key, exponent))
ret = -1;
- if (!BN_copy(n, key->n) || !BN_set_word(big1, 1L) ||
+ RSA_get0_key(key, NULL, &key_n, NULL);
+ if (!BN_copy(n, key_n) || !BN_set_word(big1, 1L) ||
!BN_set_word(big2, 2L) || !BN_set_word(big32, 32L))
ret = -1;
错误:
./scripts/dtc-version.sh: line 17: dtc: command not found
./scripts/dtc-version.sh: line 18: dtc: command not found
*** Your dtc is too old, please upgrade to dtc 1.4 or newer
解决:
系统中安装dtc命令
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
compilation terminated.
make[7]: *** [Makefile:623: mdct.lo] Error 1
make[7]: Leaving directory '/home/zm/下载/guoxin/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/libvorbis-1.3.5/lib'
需要安装glibc-devel-32bit
问题
[ 19%] Building CXX object Foundation/CMakeFiles/Foundation.dir/src/SignalHandler.cpp.o
checking for LIBUSB... no
configure: error: in `/home/zm/下载/guoxin/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/usbutils-007':
configure: error: The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
Alternatively, you may set the environment variables LIBUSB_CFLAGS
and LIBUSB_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
sudo insmod usb_skeleton.ko
出错
usb_skeleton: version magic '4.12.14-lp150.9-default SMP mod_unload modversions ' should be '4.12.14-lp150.9-default SMP mod_unload modversions retpoline '
解决
//#ifdef RETPOLINE
改成
如下
//#ifdef RETPOLINE
#if 1
#define MODULE_VERMAGIC_RETPOLINE "retpoline "
#else
#define MODULE_VERMAGIC_RETPOLINE ""
#endif
然后重新编译ko再加载
[ 34%] Building C object CMakeFiles/blobmsg_json.dir/blobmsg_json.c.o
/home/zm/下载/guoxin/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/libubox-2016-11-29/blobmsg_json.c:23:24: fatal error: json/json.h: No such file or directory
compilation terminated.
make[6]: *** [CMakeFiles/blobmsg_json.dir/build.make:63: CMakeFiles/blobmsg_json.dir/blobmsg_json.c.o] Error 1
解决:
ln -s `pwd`/staging_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/usr/include/json-c `pwd`/staging_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/usr/include/json
mnist官方的示例 36k pb, 34k pb_with_ckpt模型,跑100次耗时情况,板子30到50ms, pc机i7-7700HQ 34ms
lnet 214k pb, 13M pb_with_ckpt模型
lnet转换成npu模型后为3.5M大小
$ gxnpuc ./lnet.yaml
.........[WARN] Softmax may lead to fp16 data overflow.
Memory allocation info:
Mem0(ops): 1880
Mem1(data): 521504
Mem2(instruction): 3554652
Mem3(in): 1568
Mem4(out): 20
Mem5(tmp content): 802816
Total Memory Size: 4882440
------------------------
https://code.aliyun.com/
Ubuntu16.04系统:
sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev unzip texinfo device-tree-compiler
如果是Suse系统:
安装ncurse-devel text-info dtc zlib-devel-static
安装了svn还会提示找不到
Build dependency: Please install the Subversion client
解决:
ln -s /usr/bin/svn ./staging_dir/host/bin/svn
正常步骤
cd openwrt
cp configs/leo_gx8010_ssd_1v_defconfig .config
make defconfig
make V=s -j4
出错问题
/home/zm/下载/guoxin/openwrt/build_dir/host/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c: In function 'get_cert_chain':
/home/zm/下载/guoxin/openwrt/build_dir/host/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c:2482:13: error: dereferencing pointer to incomplete type 'X509 {aka struct x509_st}'
cinf = x->cert_info;
^~
/home/zm/下载/guoxin/openwrt/build_dir/host/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c:2484:30: error: dereferencing pointer to incomplete type 'X509_CINF {aka struct x509_cinf_st}'
j = asn1_object_dump(cinf->signature->algorithm, bufp, CERTBUFFERSIZE);
^~
/home/zm/下载/guoxin/openwrt/build_dir/host/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c:2510:20: error: dereferencing pointer to incomplete type 'EVP_PKEY {aka struct evp_pkey_st}'
switch(pubkey->type) {
针对openwrt编译对上openssl-1.1.x版本出错问题,一种方法就是降openssl版本到1.0,另外一种方法下面讲
1)解决:
到
https://git.openwrt.org/?p=openwrt/openwrt.git;a=tree;f=tools/mkimage/patches;h=ee5e92e913e487f63a5d8a82ebd43ccdd7b0a3f7;hb=70b104f98c0657323b28fce140b73a94bf3eb756
下载210那个patch并放到
tools/mkimage/patchs/210-openssl-1.1.x-compat.patch
2) automake 也会有ssl的编译错误
到
https://git.openwrt.org/?p=openwrt/openwrt.git;a=tree;f=tools/automake/patches;h=dcaa4da7ad8ec755a593b1feba3b88d6b9c64677;hb=92c80f38cff3c20388f9ac13d5196f2745aeaf77
下载
tools_automake_patches_010-automake-port-to-Perl-5.22-and-later.patch
mv ~/download/tools_automake_patches_010-automake-port-to-Perl-5.22-and-later.patch tools/automake/patches/010-automake-port-to-Perl-5.22-and-later.patch
3) 下载新cmake,不用3.6.1这个版本
首先浏览器打开
https://fossies.org/linux/misc/
查看里面最新版的cmake,比如现在是3.11.2
那么就修改 "tools/cmake/Makefile" "PKG_VERSION:=3.6.1"为PKG_VERSION=3.11.2 删除"tools/cmake/patches/110-...", 120-alpine_musl-compat.patch 100-disable_qt_tests.patch, 这几个patch
不删除patch会出现错误:
Applying ./patches/100-disable_qt_tests.patch using plaintext:
patching file Tests/RunCMake/CMakeLists.txt
Hunk #1 succeeded at 284 (offset 65 lines)
修改
PKG_MD5SUM:=d6dd661380adacdb12f41b926ec99545
为
PKG_MD5SUM:=d2d554c05fc07cfae7846d2aa205f12a
这个要跟具体下的包对应,每个版本对应md5值不一样,如果不知道,先不改PKG_MD5SUM然后编译,会提示错误
MD5 sum of the downloaded file does not match (file: d2d554c05fc07cfae7846d2aa205f12a, requested: d6dd661380adacdb12f41b926ec99545) - deleting download.
根据错误就知道怎么改了。
问题:
/home/zm/下载/guoxin/openwrt/build_dir/host/u-boot-2014.10/lib/rsa/rsa-sign.c: In function ‘rsa_get_exponent’:
/home/zm/下载/guoxin/openwrt/build_dir/host/u-boot-2014.10/lib/rsa/rsa-sign.c:279:21: error: dereferencing pointer to incomplete type ‘RSA {aka struct rsa_st}’
这个问题大致可以参考下面这个patch改,patch已经对应不上行号了,自己手动改吧
if (BN_num_bits(key->e) > 64)
make[5]: *** [scripts/Makefile.host:134: tools/lib/rsa/rsa-sign.o] Error 1
diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c
index 5d9716f..2127605 100644
--- a/lib/rsa/rsa-sign.c
+++ b/lib/rsa/rsa-sign.c
@@ -19,6 +19,19 @@
#define HAVE_ERR_REMOVE_THREAD_STATE
#endif
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+void RSA_get0_key(const RSA *r,
+ const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
+{
+ if (n != NULL)
+ *n = r->n;
+ if (e != NULL)
+ *e = r->e;
+ if (d != NULL)
+ *d = r->d;
+}
+#endif
+
static int rsa_err(const char *msg)
{
unsigned long sslErr = ERR_get_error();
@@ -210,7 +223,11 @@ static int rsa_sign_with_key(RSA *rsa, struct checksum_algo *checksum_algo,
ret = rsa_err("Could not obtain signature");
goto err_sign;
}
- EVP_MD_CTX_cleanup(context);
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
+ EVP_MD_CTX_cleanup(context);
+ #else
+ EVP_MD_CTX_reset(context);
+ #endif
EVP_MD_CTX_destroy(context);
EVP_PKEY_free(key);
@@ -268,6 +285,7 @@ static int rsa_get_exponent(RSA *key, uint64_t *e)
{
int ret;
BIGNUM *bn_te;
+ const BIGNUM *key_e;
uint64_t te;
ret = -EINVAL;
@@ -276,17 +294,18 @@ static int rsa_get_exponent(RSA *key, uint64_t *e)
if (!e)
goto cleanup;
- if (BN_num_bits(key->e) > 64)
+ RSA_get0_key(key, NULL, &key_e, NULL);
+ if (BN_num_bits(key_e) > 64)
goto cleanup;
- *e = BN_get_word(key->e);
+ *e = BN_get_word(key_e);
- if (BN_num_bits(key->e) < 33) {
+ if (BN_num_bits(key_e) < 33) {
ret = 0;
goto cleanup;
}
- bn_te = BN_dup(key->e);
+ bn_te = BN_dup(key_e);
if (!bn_te)
goto cleanup;
@@ -316,6 +335,7 @@ int rsa_get_params(RSA *key, uint64_t *exponent, uint32_t *n0_invp,
{
BIGNUM *big1, *big2, *big32, *big2_32;
BIGNUM *n, *r, *r_squared, *tmp;
+ const BIGNUM *key_n;
BN_CTX *bn_ctx = BN_CTX_new();
int ret = 0;
@@ -337,7 +357,8 @@ int rsa_get_params(RSA *key, uint64_t *exponent, uint32_t *n0_invp,
if (0 != rsa_get_exponent(key, exponent))
ret = -1;
- if (!BN_copy(n, key->n) || !BN_set_word(big1, 1L) ||
+ RSA_get0_key(key, NULL, &key_n, NULL);
+ if (!BN_copy(n, key_n) || !BN_set_word(big1, 1L) ||
!BN_set_word(big2, 2L) || !BN_set_word(big32, 32L))
ret = -1;
错误:
./scripts/dtc-version.sh: line 17: dtc: command not found
./scripts/dtc-version.sh: line 18: dtc: command not found
*** Your dtc is too old, please upgrade to dtc 1.4 or newer
解决:
系统中安装dtc命令
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
compilation terminated.
make[7]: *** [Makefile:623: mdct.lo] Error 1
make[7]: Leaving directory '/home/zm/下载/guoxin/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/libvorbis-1.3.5/lib'
需要安装glibc-devel-32bit
问题
[ 19%] Building CXX object Foundation/CMakeFiles/Foundation.dir/src/SignalHandler.cpp.o
checking for LIBUSB... no
configure: error: in `/home/zm/下载/guoxin/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/usbutils-007':
configure: error: The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
Alternatively, you may set the environment variables LIBUSB_CFLAGS
and LIBUSB_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
sudo insmod usb_skeleton.ko
出错
usb_skeleton: version magic '4.12.14-lp150.9-default SMP mod_unload modversions ' should be '4.12.14-lp150.9-default SMP mod_unload modversions retpoline '
解决
//#ifdef RETPOLINE
改成
如下
//#ifdef RETPOLINE
#if 1
#define MODULE_VERMAGIC_RETPOLINE "retpoline "
#else
#define MODULE_VERMAGIC_RETPOLINE ""
#endif
然后重新编译ko再加载
[ 34%] Building C object CMakeFiles/blobmsg_json.dir/blobmsg_json.c.o
/home/zm/下载/guoxin/openwrt/build_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/libubox-2016-11-29/blobmsg_json.c:23:24: fatal error: json/json.h: No such file or directory
compilation terminated.
make[6]: *** [CMakeFiles/blobmsg_json.dir/build.make:63: CMakeFiles/blobmsg_json.dir/blobmsg_json.c.o] Error 1
解决:
ln -s `pwd`/staging_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/usr/include/json-c `pwd`/staging_dir/target-arm_cortex-a7+neon_glibc-2.22_eabi/usr/include/json
mnist官方的示例 36k pb, 34k pb_with_ckpt模型,跑100次耗时情况,板子30到50ms, pc机i7-7700HQ 34ms
lnet 214k pb, 13M pb_with_ckpt模型
lnet转换成npu模型后为3.5M大小
$ gxnpuc ./lnet.yaml
.........[WARN] Softmax may lead to fp16 data overflow.
Memory allocation info:
Mem0(ops): 1880
Mem1(data): 521504
Mem2(instruction): 3554652
Mem3(in): 1568
Mem4(out): 20
Mem5(tmp content): 802816
Total Memory Size: 4882440
------------------------
Compile OK.
作者:帅得不敢出门