gn_efr32_example.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2020 Project CHIP Authors
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # Build script for GN EFT32 examples GitHub workflow.
  18. set -e
  19. if [[ -z "${MATTER_ROOT}" ]]; then
  20. echo "Using default path for Matter root"
  21. CHIP_ROOT="$(dirname "$0")/../.."
  22. else
  23. echo "Using ENV path for Matter root"
  24. CHIP_ROOT="$MATTER_ROOT"
  25. fi
  26. source "$CHIP_ROOT/scripts/activate.sh"
  27. set -x
  28. env
  29. USE_WIFI=false
  30. USAGE="./scripts/examples/gn_efr32_example.sh <AppRootFolder> <outputFolder> <efr32_board_name> [<Build options>]"
  31. if [ "$#" == "0" ]; then
  32. echo "Build script for EFR32 Matter apps
  33. Format:
  34. $USAGE
  35. <AppRootFolder>
  36. Root Location of the app e.g: examples/lighting-app/efr32/
  37. <outputFolder>
  38. Desired location for the output files
  39. <efr32_board_name>
  40. Identifier of the board for which this app is built
  41. Currently Supported :
  42. BRD4161A
  43. BRD4163A
  44. BRD4164A
  45. BRD4166A
  46. BRD4170A
  47. BRD4186A
  48. BRD4187A
  49. BRD4304A
  50. <Build options> - optional noteworthy build options for EFR32
  51. chip_build_libshell
  52. Enable libshell support. (Default false)
  53. chip_logging
  54. Current value (Default true)
  55. chip_openthread_ftd
  56. Use openthread Full Thread Device, else, use Minimal Thread Device. (Default true)
  57. efr32_sdk_root
  58. Location for an alternate or modified efr32 SDK
  59. enable_heap_monitoring
  60. Monitor & log memory usage at runtime. (Default false)
  61. enable_openthread_cli
  62. Enables openthread cli without matter shell. (Default true)
  63. kvs_max_entries
  64. Set the maxium Kvs entries that can be store in NVM (Default 75)
  65. Thresholds: 30 <= kvs_max_entries <= 255
  66. show_qr_code
  67. Enables QR code on LCD for devices with an LCD
  68. setupDiscriminator
  69. Discriminatoor value used for BLE connexion. (Default 3840)
  70. setupPinCode
  71. PIN code for PASE session establishment. (Default 20202021)
  72. enable_sleepy_device
  73. Enable Sleepy end device. (Default false)
  74. Must also set chip_openthread_ftd=false
  75. use_rs911x
  76. Build wifi example with extension board rs911x. (Default false)
  77. use_wf200
  78. Build wifi example with extension board wf200. (Default false)
  79. 'import("//with_pw_rpc.gni")'
  80. Use to build the example with pigweed RPC
  81. OTA_periodic_query_timeout
  82. Periodic query timeout variable for OTA in seconds
  83. rs91x_wpa3_only
  84. Support for WPA3 only mode on RS91x
  85. Presets
  86. --sed
  87. enable sleepy end device, set thread mtd
  88. For minimum consumption, disable openthread cli and qr code
  89. --wifi <wf200 | rs911x>
  90. build wifi example variant for given exansion board
  91. --additional_data_advertising
  92. enable Addition data advertissing and rotating device ID
  93. "
  94. elif [ "$#" -lt "2" ]; then
  95. echo "Invalid number of arguments
  96. Format:
  97. $USAGE"
  98. else
  99. ROOT=$1
  100. OUTDIR=$2
  101. if [ "$#" -gt "2" ]; then
  102. EFR32_BOARD=$3
  103. shift
  104. fi
  105. shift
  106. shift
  107. while [ $# -gt 0 ]; do
  108. case $1 in
  109. --wifi)
  110. if [ -z "$2" ]; then
  111. echo "--wifi requires rs911x or wf200"
  112. exit 1
  113. fi
  114. if [ "$2" = "rs911x" ]; then
  115. optArgs+="use_rs911x=true"
  116. elif [ "$2" = "wf200" ]; then
  117. optArgs+="use_wf200=true"
  118. else
  119. echo "Wifi usage: --wifi rs911x|wf200"
  120. exit 1
  121. fi
  122. USE_WIFI=true
  123. shift
  124. shift
  125. ;;
  126. --sed)
  127. optArgs+="enable_sleepy_device=true chip_openthread_ftd=false "
  128. shift
  129. ;;
  130. --chip_enable_wifi_ipv4)
  131. optArgs+="chip_enable_wifi_ipv4=true "
  132. shift
  133. ;;
  134. --additional_data_advertising)
  135. optArgs+="chip_enable_additional_data_advertising=true chip_enable_rotating_device_id=true "
  136. shift
  137. ;;
  138. *)
  139. if [ "$1" =~ *"use_rs911x=true"* ] || [ "$1" =~ *"use_wf200=true"* ]; then
  140. USE_WIFI=true
  141. fi
  142. optArgs+=$1" "
  143. shift
  144. ;;
  145. esac
  146. done
  147. if [ -z "$EFR32_BOARD" ]; then
  148. echo "EFR32_BOARD not defined"
  149. exit 1
  150. fi
  151. BUILD_DIR=$OUTDIR/$EFR32_BOARD
  152. echo BUILD_DIR="$BUILD_DIR"
  153. if [ "$USE_WIFI" == true ]; then
  154. gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --dotfile="$ROOT"/build_for_wifi_gnfile.gn --args="efr32_board=\"$EFR32_BOARD\" $optArgs" "$BUILD_DIR"
  155. else
  156. # thread build
  157. #
  158. if [ -z "$optArgs" ]; then
  159. gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --args="efr32_board=\"$EFR32_BOARD\"" "$BUILD_DIR"
  160. else
  161. gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --args="efr32_board=\"$EFR32_BOARD\" $optArgs" "$BUILD_DIR"
  162. fi
  163. fi
  164. ninja -v -C "$BUILD_DIR"/
  165. #print stats
  166. arm-none-eabi-size -A "$BUILD_DIR"/*.out
  167. fi