要在Androidq下编译efr32mg21,花了2天时间,分享下
拿到源码后,先在linux的环境下编译成功
sudo apt-get install libreadline-dev
sudo apt-get install libncurses5-dev
cd app/builder/Z3GatewayHost
make clean
make
编译成功后,把源码放在external/efr32mg21/下,结构如下
参考app/builder/Z3GatewayHost/Makefile,创建Android.bp文件,内容如下
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
cc_binary {
name: "efr32mg21",
include_dirs: [
"external/efr32mg21/protocol/zigbee/app/framework",
"external/efr32mg21/protocol/zigbee/app/framework/../..",
"external/efr32mg21/protocol/zigbee/app/framework/../../stack",
"external/efr32mg21/protocol/zigbee/app/framework/../util",
"external/efr32mg21/protocol/zigbee/app/framework/../util/common",
"external/efr32mg21/protocol/zigbee/app/framework/../util/ezsp",
"external/efr32mg21/protocol/zigbee/app/framework/../util/serial",
"external/efr32mg21/protocol/zigbee/app/framework/../util/zigbee-framework",
"external/efr32mg21/protocol/zigbee/app/framework/cli",
"external/efr32mg21/protocol/zigbee/app/framework/include",
"external/efr32mg21/protocol/zigbee/app/framework/security",
"external/efr32mg21/protocol/zigbee/app/framework/util",
"external/efr32mg21/platform/base/hal",
"external/efr32mg21/platform/base/hal/plugin",
"external/efr32mg21/platform/base/hal/..",
"external/efr32mg21/platform/base/hal/micro/generic",
"external/efr32mg21/platform/base/hal/micro/unix/host",
"external/efr32mg21/platform/base/hal/micro/unix/host/board",
"external/efr32mg21/util/plugin/plugin-common/mbedtls",
"external/efr32mg21/util/third_party/mbedtls",
"external/efr32mg21/util/third_party/mbedtls/include",
"external/efr32mg21/util/third_party/mbedtls/include/mbedtls",
"external/efr32mg21/util/third_party/mbedtls/sl_crypto/include",
"external/efr32mg21/app/builder/Z3GatewayHost",
],
cflags: [
"-Wno-unused-parameter",
"-Wno-missing-braces",
"-Wno-unused-function",
"-Wno-unused-variable",
"-Wno-date-time",
"-Wno-uninitialized",
"-DUNIX",
"-DUNIX_HOST",
"-DPHY_NULL",
"-DCONFIGURATION_HEADER=\"util/config.h\"",
"-DEZSP_HOST",
"-DGATEWAY_APP",
"-DZA_GENERATED_HEADER=\"Z3GatewayHost.h\"",
"-DATTRIBUTE_STORAGE_CONFIGURATION=\"Z3GatewayHost_endpoint_config.h\"",
"-DPLATFORM_HEADER=\"micro/unix/compiler/gcc.h\"",
"-DBOARD_HOST",
"-DBOARD_HEADER=\"Z3GatewayHost_board.h\"",
"-DEM_AF_TEST_HARNESS_CODE",
"-DEM_AF_LINK_M",
"-DEM_AF_LINK_PTHREAD",
"-DEMBER_AF_API_EMBER_TYPES=\"stack/include/ember-types.h\"",
"-DEMBER_AF_API_DEBUG_PRINT=\"app/framework/util/print.h\"",
"-DEMBER_AF_API_AF_HEADER=\"app/framework/include/af.h\"",
"-DEMBER_AF_API_AF_SECURITY_HEADER=\"app/framework/security/af-security.h\"",
"-DEMBER_AF_API_NEIGHBOR_HEADER=\"stack/include/stack-info.h\"",
"-DEMBER_STACK_ZIGBEE",
"-DEZSP_ASH",
"-DMBEDTLS_CONFIG_FILE=\"mbedtls-config-generated.h\"",
"-DFNDELAY=\"O_NDELAY\"",
"-DNO_READLINE",
],
srcs: [
"app/builder/Z3GatewayHost/znet-bookkeeping.c",
"app/builder/Z3GatewayHost/call-command-handler.c",
"app/builder/Z3GatewayHost/callback-stub.c",
"app/builder/Z3GatewayHost/stack-handler-stub.c",
"app/builder/Z3GatewayHost/znet-cli.c",
"app/builder/Z3GatewayHost/Z3GatewayHost_callbacks.c",
"protocol/zigbee/app/framework/../util/common/library.c",
"protocol/zigbee/app/framework/../util/serial/command-interpreter2.c",
"protocol/zigbee/app/framework/../util/zigbee-framework/zigbee-device-common.c",
"protocol/zigbee/app/framework/../util/zigbee-framework/zigbee-device-host.c",
"protocol/zigbee/app/framework/../../stack/framework/event-control.c",
"platform/base/hal/micro/generic/led-stub.c",
"platform/base/hal/micro/generic/mem-util.c",
"platform/base/hal/plugin/antenna-stub/antenna-stub.c",
"platform/base/hal/plugin/buzzer-stub/buzzer-stub.c",
"protocol/zigbee/app/framework/plugin/address-table/address-table.c",
"protocol/zigbee/app/framework/plugin/address-table/address-table-cli.c",
"protocol/zigbee/app/framework/plugin/basic/basic.c",
"protocol/zigbee/app/framework/plugin/color-control-server/color-control-server.c",
"protocol/zigbee/app/framework/plugin/concentrator/concentrator-support.c",
"protocol/zigbee/app/framework/plugin/concentrator/concentrator-support-cli.c",
"protocol/zigbee/app/framework/plugin/counters/counters-cli.c",
"protocol/zigbee/app/framework/plugin/counters/counters-ota-host.c",
"protocol/zigbee/app/framework/plugin/counters/counters-host.c",
"protocol/zigbee/app/framework/plugin/ezmode-commissioning/ez-mode.c",
"protocol/zigbee/app/framework/plugin/ezmode-commissioning/ez-mode-cli.c",
"protocol/zigbee/app/util/ezsp/ezsp-callbacks.c",
"protocol/zigbee/app/util/ezsp/ezsp-enum-decode.c",
"protocol/zigbee/app/util/ezsp/ezsp-frame-utilities.c",
"protocol/zigbee/app/util/ezsp/ezsp.c",
"protocol/zigbee/app/ezsp-host/ezsp-host-io.c",
"protocol/zigbee/app/ezsp-host/ezsp-host-queues.c",
"protocol/zigbee/app/ezsp-host/ezsp-host-ui.c",
"protocol/zigbee/app/util/ezsp/serial-interface-uart.c",
"protocol/zigbee/app/ezsp-host/ash/ash-host-ui.c",
"protocol/zigbee/app/ezsp-host/ash/ash-host.c",
"platform/base/hal/micro/generic/ash-common.c",
"protocol/zigbee/app/framework/plugin-host/file-descriptor-dispatch/file-descriptor-dispatch.c",
"protocol/zigbee/app/framework/plugin-host/gateway/gateway-support.c",
"protocol/zigbee/app/framework/plugin-host/gateway/backchannel-support.c",
"protocol/zigbee/app/framework/plugin-host/gateway/gateway-support-cli.c",
"protocol/zigbee/app/framework/plugin/green-power-client/green-power-client.c",
"protocol/zigbee/app/framework/plugin/green-power-client/green-power-client-cli.c",
"protocol/zigbee/app/framework/plugin/green-power-common/green-power-common.c",
"protocol/zigbee/stack/gp/gp-util.c",
"protocol/zigbee/app/framework/plugin/heartbeat/heartbeat.c",
"protocol/zigbee/app/framework/plugin/ias-zone-client/ias-zone-client.c",
"protocol/zigbee/app/framework/plugin/ias-zone-client/ias-zone-client-cli.c",
"protocol/zigbee/app/framework/plugin/identify/identify.c",
"protocol/zigbee/app/framework/plugin/identify/identify-cli.c",
"protocol/zigbee/app/framework/plugin/identify-feedback/identify-feedback.c",
"protocol/zigbee/app/framework/plugin/level-control/level-control.c",
"util/plugin/plugin-common/linked-list/linked-list.c",
"util/third_party/mbedtls/library/aes.c",
"util/third_party/mbedtls/library/aesni.c",
"util/third_party/mbedtls/library/arc4.c",
"util/third_party/mbedtls/library/asn1parse.c",
"util/third_party/mbedtls/library/asn1write.c",
"util/third_party/mbedtls/library/base64.c",
"util/third_party/mbedtls/library/bignum.c",
"util/third_party/mbedtls/library/blowfish.c",
"util/third_party/mbedtls/library/camellia.c",
"util/third_party/mbedtls/library/ccm.c",
"util/third_party/mbedtls/library/certs.c",
"util/third_party/mbedtls/library/cipher.c",
"util/third_party/mbedtls/library/cipher_wrap.c",
"util/third_party/mbedtls/library/cmac.c",
"util/third_party/mbedtls/library/ctr_drbg.c",
"util/third_party/mbedtls/library/debug.c",
"util/third_party/mbedtls/library/des.c",
"util/third_party/mbedtls/library/dhm.c",
"util/third_party/mbedtls/library/ecdh.c",
"util/third_party/mbedtls/library/ecdsa.c",
"util/third_party/mbedtls/library/ecjpake.c",
"util/third_party/mbedtls/library/ecp.c",
"util/third_party/mbedtls/library/ecp_curves.c",
"util/third_party/mbedtls/library/entropy.c",
"util/third_party/mbedtls/library/entropy_poll.c",
"util/third_party/mbedtls/library/error.c",
"util/third_party/mbedtls/library/gcm.c",
"util/third_party/mbedtls/library/havege.c",
"util/third_party/mbedtls/library/hmac_drbg.c",
"util/third_party/mbedtls/library/md.c",
"util/third_party/mbedtls/library/md2.c",
"util/third_party/mbedtls/library/md4.c",
"util/third_party/mbedtls/library/md5.c",
"util/third_party/mbedtls/library/md_wrap.c",
"util/third_party/mbedtls/library/memory_buffer_alloc.c",
"util/third_party/mbedtls/library/net_sockets.c",
"util/third_party/mbedtls/library/oid.c",
"util/third_party/mbedtls/library/padlock.c",
"util/third_party/mbedtls/library/pem.c",
"util/third_party/mbedtls/library/pk.c",
"util/third_party/mbedtls/library/pk_wrap.c",
"util/third_party/mbedtls/library/pkcs11.c",
"util/third_party/mbedtls/library/pkcs12.c",
"util/third_party/mbedtls/library/pkcs5.c",
"util/third_party/mbedtls/library/pkparse.c",
"util/third_party/mbedtls/library/pkwrite.c",
"util/third_party/mbedtls/library/ripemd160.c",
"util/third_party/mbedtls/library/rsa.c",
"util/third_party/mbedtls/library/rsa_internal.c",
"util/third_party/mbedtls/library/sha1.c",
"util/third_party/mbedtls/library/sha256.c",
"util/third_party/mbedtls/library/sha512.c",
"util/third_party/mbedtls/library/ssl_cache.c",
"util/third_party/mbedtls/library/ssl_ciphersuites.c",
"util/third_party/mbedtls/library/ssl_cli.c",
"util/third_party/mbedtls/library/ssl_cookie.c",
"util/third_party/mbedtls/library/ssl_srv.c",
"util/third_party/mbedtls/library/ssl_ticket.c",
"util/third_party/mbedtls/library/ssl_tls.c",
"util/third_party/mbedtls/library/threading.c",
"util/third_party/mbedtls/library/timing.c",
"util/third_party/mbedtls/library/version.c",
"util/third_party/mbedtls/library/version_features.c",
"util/third_party/mbedtls/library/x509.c",
"util/third_party/mbedtls/library/x509_create.c",
"util/third_party/mbedtls/library/x509_crl.c",
"util/third_party/mbedtls/library/x509_crt.c",
"util/third_party/mbedtls/library/x509_csr.c",
"util/third_party/mbedtls/library/x509write_crt.c",
"util/third_party/mbedtls/library/x509write_csr.c",
"util/third_party/mbedtls/library/xtea.c",
"protocol/zigbee/app/framework/plugin-host/ncp-configuration/ncp-configuration.c",
"protocol/zigbee/app/framework/plugin/network-creator/network-creator.c",
"protocol/zigbee/app/framework/plugin/network-creator/network-creator-cli.c",
"protocol/zigbee/app/framework/plugin/network-creator-security/network-creator-security.c",
"protocol/zigbee/app/framework/plugin/network-creator-security/network-creator-security-cli.c",
"protocol/zigbee/app/framework/plugin/network-steering/network-steering.c",
"protocol/zigbee/app/framework/plugin/network-steering/network-steering-cli.c",
"protocol/zigbee/app/framework/plugin/network-steering/network-steering-v2.c",
"protocol/zigbee/app/framework/plugin/network-steering/network-steering-host.c",
"protocol/zigbee/app/framework/plugin/on-off/on-off.c",
"protocol/zigbee/app/framework/plugin/ota-common/ota-common.c",
"protocol/zigbee/app/framework/plugin/ota-server/ota-server.c",
"protocol/zigbee/app/framework/plugin/ota-server/ota-server-page-request.c",
"protocol/zigbee/app/framework/plugin/ota-server/ota-server-cli.c",
"protocol/zigbee/app/framework/plugin/ota-server/ota-server-dynamic-block-period.c",
"protocol/zigbee/app/framework/plugin/ota-server-policy/ota-server-policy.c",
"protocol/zigbee/app/framework/plugin/ota-storage-common/ota-storage-common.c",
"protocol/zigbee/app/framework/plugin/ota-storage-common/ota-storage-common-cli.c",
"protocol/zigbee/app/framework/plugin/ota-storage-posix-filesystem/ota-storage-linux.c",
"protocol/zigbee/app/framework/plugin/poll-control-client/poll-control-client.c",
"protocol/zigbee/app/framework/plugin/poll-control-client/poll-control-client-cli.c",
"protocol/zigbee/app/framework/plugin/reporting/reporting.c",
"protocol/zigbee/app/framework/plugin/reporting/reporting-cli.c",
"protocol/zigbee/app/framework/plugin/reporting/reporting-default-configuration.c",
"protocol/zigbee/app/framework/plugin/scan-dispatch/scan-dispatch.c",
"protocol/zigbee/app/util/ezsp/secure-ezsp-stub.c",
"protocol/zigbee/app/framework/plugin/simple-main/simple-main.c",
"protocol/zigbee/app/framework/plugin/simple-metering-client/simple-metering-client.c",
"protocol/zigbee/app/framework/plugin/simple-metering-client/simple-metering-client-cli.c",
"protocol/zigbee/app/framework/plugin/stack-diagnostics/stack-diagnostics.c",
"protocol/zigbee/app/framework/plugin/test-harness/test-harness.c",
"protocol/zigbee/app/framework/plugin/test-harness/read-write-attributes.c",
"protocol/zigbee/app/framework/plugin/test-harness/test-harness-host.c",
"protocol/zigbee/app/framework/plugin/time-server/time-server.c",
"protocol/zigbee/app/framework/plugin/trust-center-nwk-key-update-broadcast/trust-center-nwk-key-update-broadcast.c",
"protocol/zigbee/app/framework/plugin/trust-center-nwk-key-update-periodic/trust-center-nwk-key-update-periodic.c",
"protocol/zigbee/app/framework/plugin/trust-center-nwk-key-update-unicast/trust-center-nwk-key-update-unicast.c",
"platform/base/hal/micro/generic/crc.c",
"platform/base/hal/micro/generic/endian.c",
"platform/base/hal/micro/generic/random.c",
"platform/base/hal/micro/generic/system-timer.c",
"platform/base/hal/micro/unix/host/micro.c",
"platform/base/hal/micro/unix/host/token-def-unix.c",
"platform/base/hal/micro/unix/host/token.c",
"platform/base/hal/plugin/serial/ember-printf-convert.c",
"protocol/zigbee/app/util/serial/linux-serial.c",
"protocol/zigbee/app/framework/plugin/update-tc-link-key/update-tc-link-key.c",
"protocol/zigbee/app/framework/plugin/update-tc-link-key/update-tc-link-key-cli.c",
"protocol/zigbee/app/framework/cli/core-cli.c",
"protocol/zigbee/app/framework/cli/network-cli.c",
"protocol/zigbee/app/framework/cli/option-cli.c",
"protocol/zigbee/app/framework/cli/plugin-cli.c",
"protocol/zigbee/app/framework/cli/security-cli.c",
"protocol/zigbee/app/framework/cli/zcl-cli.c",
"protocol/zigbee/app/framework/cli/zdo-cli.c",
"protocol/zigbee/app/framework/security/af-node.c",
"protocol/zigbee/app/framework/security/af-security-common.c",
"protocol/zigbee/app/framework/security/af-trust-center.c",
"protocol/zigbee/app/framework/security/crypto-state.c",
"protocol/zigbee/app/framework/util/af-event.c",
"protocol/zigbee/app/framework/util/af-main-common.c",
"protocol/zigbee/app/framework/util/attribute-size.c",
"protocol/zigbee/app/framework/util/attribute-storage.c",
"protocol/zigbee/app/framework/util/attribute-table.c",
"protocol/zigbee/app/framework/util/client-api.c",
"protocol/zigbee/app/framework/util/message.c",
"protocol/zigbee/app/framework/util/multi-network.c",
"protocol/zigbee/app/framework/util/print.c",
"protocol/zigbee/app/framework/util/print-formatter.c",
"protocol/zigbee/app/framework/util/process-cluster-message.c",
"protocol/zigbee/app/framework/util/process-global-message.c",
"protocol/zigbee/app/framework/util/service-discovery-common.c",
"protocol/zigbee/app/framework/util/time-util.c",
"protocol/zigbee/app/framework/util/util.c",
"protocol/zigbee/app/framework/util/af-main-host.c",
"protocol/zigbee/app/framework/util/service-discovery-host.c",
],
}
然后mmm external/efr32mg21/ -j40进行编译,编译有报错,修改如下
运行后会报错,修改
运行结果如下
采用J-link仿真器与Simplicity Commander软件连接升级固件步骤
https://www.sekorm.com/news/69217622.html
注意芯片的复位脚不能被拉低,会引起无法下载