mbed os with nrf51 internal bandgap enabled to read battery level

Dependents:   BLE_file_test BLE_Blink ExternalEncoder

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elessair 0:f269e3021894 1 #!/bin/sh
elessair 0:f269e3021894 2 #
elessair 0:f269e3021894 3 # This file is part of mbed TLS (https://tls.mbed.org)
elessair 0:f269e3021894 4 #
elessair 0:f269e3021894 5 # Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
elessair 0:f269e3021894 6 #
elessair 0:f269e3021894 7 # Purpose
elessair 0:f269e3021894 8 #
elessair 0:f269e3021894 9 # Comments and uncomments #define lines in the given configuration header file
elessair 0:f269e3021894 10 # to configure the file for use in mbed OS.
elessair 0:f269e3021894 11 #
elessair 0:f269e3021894 12 # Usage: adjust-config.sh [path to config script] [path to config file]
elessair 0:f269e3021894 13 #
elessair 0:f269e3021894 14 set -eu
elessair 0:f269e3021894 15
elessair 0:f269e3021894 16 if [ $# -ne 2 ]; then
elessair 0:f269e3021894 17 echo "Usage: $0 path/to/config.pl path/to/config.h" >&2
elessair 0:f269e3021894 18 exit 1
elessair 0:f269e3021894 19 fi
elessair 0:f269e3021894 20
elessair 0:f269e3021894 21 SCRIPT=$1
elessair 0:f269e3021894 22 FILE=$2
elessair 0:f269e3021894 23
elessair 0:f269e3021894 24 conf() {
elessair 0:f269e3021894 25 $SCRIPT -f $FILE $@
elessair 0:f269e3021894 26 }
elessair 0:f269e3021894 27
elessair 0:f269e3021894 28 add_code() {
elessair 0:f269e3021894 29 MATCH_PATTERN="$1"
elessair 0:f269e3021894 30 shift
elessair 0:f269e3021894 31 CODE=$(IFS=""; printf "%s" "$*")
elessair 0:f269e3021894 32
elessair 0:f269e3021894 33 perl -i -pe \
elessair 0:f269e3021894 34 "s/$MATCH_PATTERN/$MATCH_PATTERN$CODE/igs" \
elessair 0:f269e3021894 35 "$FILE"
elessair 0:f269e3021894 36 }
elessair 0:f269e3021894 37
elessair 0:f269e3021894 38 # add an #ifndef to include config-no-entropy.h when the target does not have
elessair 0:f269e3021894 39 # an entropy source we can use.
elessair 0:f269e3021894 40 add_code \
elessair 0:f269e3021894 41 "#ifndef MBEDTLS_CONFIG_H\n" \
elessair 0:f269e3021894 42 "\n" \
elessair 0:f269e3021894 43 "#include \"platform\/inc\/platform_mbed.h\"\n" \
elessair 0:f269e3021894 44 "\n" \
elessair 0:f269e3021894 45 "\/*\n" \
elessair 0:f269e3021894 46 " * Only use features that do not require an entropy source when\n" \
elessair 0:f269e3021894 47 " * DEVICE_ENTROPY_SOURCE is not defined in mbed OS.\n" \
elessair 0:f269e3021894 48 " *\/\n" \
elessair 0:f269e3021894 49 "#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && !defined(MBEDTLS_TEST_NULL_ENTROPY)\n" \
elessair 0:f269e3021894 50 "#include \"mbedtls\/config-no-entropy.h\"\n" \
elessair 0:f269e3021894 51 "\n" \
elessair 0:f269e3021894 52 "#if defined(MBEDTLS_USER_CONFIG_FILE)\n" \
elessair 0:f269e3021894 53 "#include MBEDTLS_USER_CONFIG_FILE\n" \
elessair 0:f269e3021894 54 "#endif\n" \
elessair 0:f269e3021894 55 "\n" \
elessair 0:f269e3021894 56 "#else\n"
elessair 0:f269e3021894 57
elessair 0:f269e3021894 58 add_code \
elessair 0:f269e3021894 59 "#include \"check_config.h\"\n" \
elessair 0:f269e3021894 60 "\n" \
elessair 0:f269e3021894 61 "#endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY *\/\n" \
elessair 0:f269e3021894 62 "\n" \
elessair 0:f269e3021894 63 "#if defined(MBEDTLS_TEST_NULL_ENTROPY)\n" \
elessair 0:f269e3021894 64 "#warning \"MBEDTLS_TEST_NULL_ENTROPY has been enabled. This \" \\\\\n" \
elessair 0:f269e3021894 65 " \"configuration is not secure and is not suitable for production use\"\n" \
elessair 0:f269e3021894 66 "#endif\n" \
elessair 0:f269e3021894 67 "\n" \
elessair 0:f269e3021894 68 "#if defined(MBEDTLS_SSL_TLS_C) && !defined(MBEDTLS_TEST_NULL_ENTROPY) && \\\\\n" \
elessair 0:f269e3021894 69 " !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)\n" \
elessair 0:f269e3021894 70 "#error \"No entropy source was found at build time, so TLS \" \\\\\n" \
elessair 0:f269e3021894 71 " \"functionality is not available\"\n" \
elessair 0:f269e3021894 72 "#endif\n"
elessair 0:f269e3021894 73
elessair 0:f269e3021894 74 # not supported on mbed OS, nor used by mbed Client
elessair 0:f269e3021894 75 conf unset MBEDTLS_NET_C
elessair 0:f269e3021894 76 conf unset MBEDTLS_TIMING_C
elessair 0:f269e3021894 77
elessair 0:f269e3021894 78 # not supported on all targets with mbed OS, nor used by mbed Client
elessair 0:f269e3021894 79 conf unset MBEDTLS_HAVE_TIME_DATE
elessair 0:f269e3021894 80 conf unset MBEDTLS_FS_IO
elessair 0:f269e3021894 81 conf set MBEDTLS_NO_PLATFORM_ENTROPY
elessair 0:f269e3021894 82
elessair 0:f269e3021894 83 conf unset MBEDTLS_CIPHER_MODE_CFB
elessair 0:f269e3021894 84 conf unset MBEDTLS_CIPHER_MODE_CTR
elessair 0:f269e3021894 85 conf unset MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS
elessair 0:f269e3021894 86 conf unset MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN
elessair 0:f269e3021894 87 conf unset MBEDTLS_CIPHER_PADDING_ZEROS
elessair 0:f269e3021894 88 conf unset MBEDTLS_ECP_DP_SECP192R1_ENABLED
elessair 0:f269e3021894 89 conf unset MBEDTLS_ECP_DP_SECP224R1_ENABLED
elessair 0:f269e3021894 90 conf unset MBEDTLS_ECP_DP_SECP521R1_ENABLED
elessair 0:f269e3021894 91 conf unset MBEDTLS_ECP_DP_SECP192K1_ENABLED
elessair 0:f269e3021894 92 conf unset MBEDTLS_ECP_DP_SECP224K1_ENABLED
elessair 0:f269e3021894 93 conf unset MBEDTLS_ECP_DP_SECP256K1_ENABLED
elessair 0:f269e3021894 94 conf unset MBEDTLS_ECP_DP_BP256R1_ENABLED
elessair 0:f269e3021894 95 conf unset MBEDTLS_ECP_DP_BP384R1_ENABLED
elessair 0:f269e3021894 96 conf unset MBEDTLS_ECP_DP_BP512R1_ENABLED
elessair 0:f269e3021894 97 conf unset MBEDTLS_PK_PARSE_EC_EXTENDED
elessair 0:f269e3021894 98
elessair 0:f269e3021894 99 conf unset MBEDTLS_AESNI_C
elessair 0:f269e3021894 100 conf unset MBEDTLS_ARC4_C
elessair 0:f269e3021894 101 conf unset MBEDTLS_BLOWFISH_C
elessair 0:f269e3021894 102 conf unset MBEDTLS_CAMELLIA_C
elessair 0:f269e3021894 103 conf unset MBEDTLS_DES_C
elessair 0:f269e3021894 104 conf unset MBEDTLS_DHM_C
elessair 0:f269e3021894 105 conf unset MBEDTLS_GENPRIME
elessair 0:f269e3021894 106 conf unset MBEDTLS_MD5_C
elessair 0:f269e3021894 107 conf unset MBEDTLS_PADLOCK_C
elessair 0:f269e3021894 108 conf unset MBEDTLS_PEM_WRITE_C
elessair 0:f269e3021894 109 conf unset MBEDTLS_PKCS5_C
elessair 0:f269e3021894 110 conf unset MBEDTLS_PKCS12_C
elessair 0:f269e3021894 111 conf unset MBEDTLS_RIPEMD160_C
elessair 0:f269e3021894 112 conf unset MBEDTLS_SHA1_C
elessair 0:f269e3021894 113 conf unset MBEDTLS_XTEA_C
elessair 0:f269e3021894 114
elessair 0:f269e3021894 115 conf unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
elessair 0:f269e3021894 116
elessair 0:f269e3021894 117 conf unset MBEDTLS_X509_CSR_PARSE_C
elessair 0:f269e3021894 118 conf unset MBEDTLS_X509_CREATE_C
elessair 0:f269e3021894 119 conf unset MBEDTLS_X509_CRT_WRITE_C
elessair 0:f269e3021894 120 conf unset MBEDTLS_X509_CSR_WRITE_C
elessair 0:f269e3021894 121
elessair 0:f269e3021894 122 conf unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
elessair 0:f269e3021894 123 conf unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
elessair 0:f269e3021894 124 conf unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
elessair 0:f269e3021894 125 conf unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
elessair 0:f269e3021894 126 conf unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
elessair 0:f269e3021894 127 conf unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
elessair 0:f269e3021894 128 conf unset MBEDTLS_SSL_FALLBACK_SCSV
elessair 0:f269e3021894 129 conf unset MBEDTLS_SSL_CBC_RECORD_SPLITTING
elessair 0:f269e3021894 130 conf unset MBEDTLS_SSL_PROTO_TLS1
elessair 0:f269e3021894 131 conf unset MBEDTLS_SSL_PROTO_TLS1_1
elessair 0:f269e3021894 132 conf unset MBEDTLS_SSL_TRUNCATED_HMAC
elessair 0:f269e3021894 133
elessair 0:f269e3021894 134 conf unset MBEDTLS_PLATFORM_TIME_TYPE_MACRO
elessair 0:f269e3021894 135