Simple interface for Mbed Cloud Client
Embed:
(wiki syntax)
Show/hide line numbers
pal_configuration.h
Go to the documentation of this file.
00001 /******************************************************************************* 00002 * Copyright 2016, 2017 ARM Ltd. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 *******************************************************************************/ 00016 00017 00018 #ifndef _PAL_COFIGURATION_H 00019 #define _PAL_COFIGURATION_H 00020 #include "limits.h" 00021 00022 00023 #ifdef PAL_USER_DEFINED_CONFIGURATION 00024 #include PAL_USER_DEFINED_CONFIGURATION 00025 #else 00026 #include "sotp_fs.h" 00027 #endif 00028 00029 00030 /*! \brief If needed any board specific configuration please set this define 00031 */ 00032 #ifdef PAL_BOARD_SPECIFIC_CONFIG 00033 #include PAL_BOARD_SPECIFIC_CONFIG 00034 #endif 00035 00036 00037 /*! \brief let the user choose its platform configuration file. 00038 \note if the user does not specify a platform configuration file, 00039 \note PAL uses a default configuration set that can be found at \b Configs/pal_config folder 00040 */ 00041 00042 #ifdef PAL_PLATFORM_DEFINED_CONFIGURATION 00043 #include PAL_PLATFORM_DEFINED_CONFIGURATION 00044 #elif defined(__LINUX__) 00045 #include "Linux_default.h" 00046 #elif defined(__FREERTOS__) 00047 #include "FreeRTOS_default.h" 00048 #elif defined(__MBED__) 00049 #include "mbedOS_default.h" 00050 #else 00051 #error "Please specify the platform PAL_PLATFORM_DEFINED_CONFIGURATION" 00052 #endif 00053 00054 /*! \file pal_configuration.h 00055 * \brief PAL Configuration. 00056 * This file contains PAL configuration information including the following: 00057 * 1. The flags to enable or disable features. 00058 * 2. The configuration of the number of objects provided by PAL (such as the number of threads supported) or their sizes. 00059 * 3. The configuration of supported cipher suites. 00060 * 4. The configuration for flash memory usage. 00061 * 5. The configuration for the root of trust. 00062 */ 00063 00064 00065 /* 00066 * Network configuration 00067 */ 00068 //! PAL configuration options 00069 #ifndef PAL_NET_TCP_AND_TLS_SUPPORT 00070 #define PAL_NET_TCP_AND_TLS_SUPPORT true/* Add PAL support for TCP. */ 00071 #endif 00072 00073 #ifndef PAL_NET_ASYNCHRONOUS_SOCKET_API 00074 #define PAL_NET_ASYNCHRONOUS_SOCKET_API true/* Add PAL support for asynchronous sockets. */ 00075 #endif 00076 00077 #ifndef PAL_NET_DNS_SUPPORT 00078 #define PAL_NET_DNS_SUPPORT true/* Add PAL support for DNS lookup. */ 00079 #endif 00080 00081 //values for PAL_NET_DNS_IP_SUPPORT 00082 #define PAL_NET_DNS_ANY 0 /* if PAL_NET_DNS_IP_SUPPORT is set to PAL_NET_DNS_ANY pal_getAddressInfo will return the first available IPV4 or IPV6 address*/ 00083 #define PAL_NET_DNS_IPV4_ONLY 2 /* if PAL_NET_DNS_IP_SUPPORT is set to PAL_NET_DNS_IPV4_ONLY pal_getAddressInfo will return the first available IPV4 address*/ 00084 #define PAL_NET_DNS_IPV6_ONLY 4 /* if PAL_NET_DNS_IP_SUPPORT is set to PAL_NET_DNS_IPV6_ONLY pal_getAddressInfo will return the first available IPV6 address*/ 00085 00086 #ifndef PAL_NET_DNS_IP_SUPPORT 00087 #define PAL_NET_DNS_IP_SUPPORT 0 /* sets the type of IP addresses returned by pal_getAddressInfo*/ 00088 #endif 00089 00090 //! The maximum number of interfaces that can be supported at a time. 00091 #ifndef PAL_MAX_SUPORTED_NET_INTERFACES 00092 #define PAL_MAX_SUPORTED_NET_INTERFACES 10 00093 #endif 00094 00095 //!< Stack size for thread created when calling pal_getAddressInfoAsync 00096 #ifndef PAL_NET_ASYNC_DNS_THREAD_STACK_SIZE 00097 #define PAL_NET_ASYNC_DNS_THREAD_STACK_SIZE (1024 * 2) 00098 #endif 00099 00100 00101 //! If you want PAL Not to perform a rollback/cleanup although main PAL init failed, please set this flag to `false` 00102 #ifndef PAL_CLEANUP_ON_INIT_FAILURE 00103 #define PAL_CLEANUP_ON_INIT_FAILURE true 00104 #endif 00105 00106 /* 00107 * RTOS configuration 00108 */ 00109 //! This flag determines if PAL moudles are thread safe. 1 - thread safety is enabled, 0 - thread safety is disabled 00110 #ifndef PAL_THREAD_SAFETY 00111 #define PAL_THREAD_SAFETY 1 00112 #endif 00113 00114 #ifndef PAL_IGNORE_UNIQUE_THREAD_PRIORITY 00115 #define PAL_UNIQUE_THREAD_PRIORITY true 00116 #endif 00117 00118 //! initial time until thread stack cleanup (mbedOs only). This is the amount of time we wait before checking that a thread has completed so we can free it's stack. 00119 #ifndef PAL_RTOS_THREAD_CLEANUP_TIMER_MILISEC 00120 #define PAL_RTOS_THREAD_CLEANUP_TIMER_MILISEC 200 00121 #endif 00122 00123 //! This define is used to determine the size of the initial random buffer (in bytes) held by PAL for random the algorithm. 00124 #ifndef PAL_INITIAL_RANDOM_SIZE 00125 #define PAL_INITIAL_RANDOM_SIZE 48 00126 #endif 00127 00128 #ifndef PAL_RTOS_WAIT_FOREVER 00129 #define PAL_RTOS_WAIT_FOREVER UINT_MAX 00130 #endif 00131 00132 /* 00133 * TLS configuration 00134 */ 00135 //! The the maximum number of TLS contexts supported. 00136 #ifndef PAL_MAX_NUM_OF_TLS_CTX 00137 #define PAL_MAX_NUM_OF_TLS_CTX 1 00138 #endif 00139 00140 //! The maximum number of supported cipher suites. 00141 #ifndef PAL_MAX_ALLOWED_CIPHER_SUITES 00142 #define PAL_MAX_ALLOWED_CIPHER_SUITES 1 00143 #endif 00144 00145 //! This value is in milliseconds. 1000 = 1 second. 00146 #ifndef PAL_DTLS_PEER_MIN_TIMEOUT 00147 #define PAL_DTLS_PEER_MIN_TIMEOUT 1000 00148 #endif 00149 00150 //! The debug threshold for TLS API. 00151 #ifndef PAL_TLS_DEBUG_THRESHOLD 00152 #define PAL_TLS_DEBUG_THRESHOLD 5 00153 #endif 00154 00155 //! 32 or 48 (depends on the curve) bytes for the X,Y coordinates and 1 for the normalized/non-normalized 00156 #ifndef PAL_CERT_ID_SIZE 00157 #define PAL_CERT_ID_SIZE 33 00158 #endif 00159 00160 00161 #ifndef PAL_ENABLE_PSK 00162 #define PAL_ENABLE_PSK 0 00163 #endif 00164 00165 #ifndef PAL_ENABLE_X509 00166 #define PAL_ENABLE_X509 1 00167 #endif 00168 00169 //! Define the cipher suites for TLS (only one cipher suite per device available). 00170 #define PAL_TLS_PSK_WITH_AES_128_CBC_SHA256_SUITE 0x01 00171 #define PAL_TLS_PSK_WITH_AES_128_CCM_8_SUITE 0x02 00172 #define PAL_TLS_PSK_WITH_AES_256_CCM_8_SUITE 0x04 00173 #define PAL_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8_SUITE 0x08 00174 #define PAL_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_SUITE 0x10 00175 #define PAL_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_SUITE 0x20 00176 00177 00178 //! Use the default cipher suite for TLS/DTLS operations 00179 #if (PAL_ENABLE_X509 == 1) 00180 #ifndef PAL_TLS_CIPHER_SUITE 00181 #define PAL_TLS_CIPHER_SUITE PAL_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8_SUITE 00182 #endif 00183 #elif (PAL_ENABLE_PSK == 1) 00184 #ifndef PAL_TLS_CIPHER_SUITE 00185 #define PAL_TLS_CIPHER_SUITE PAL_TLS_PSK_WITH_AES_128_CCM_8_SUITE 00186 #endif 00187 #endif 00188 00189 #ifndef PAL_CMAC_SUPPORT 00190 #define PAL_CMAC_SUPPORT true 00191 #endif 00192 00193 //! Enable the CMAC functionality (This flag was targeted to let the bootloader to be compiled without CMAC) 00194 #ifndef PAL_CMAC_SUPPORT 00195 #define PAL_CMAC_SUPPORT 1 00196 #endif //PAL_CMAC_SUPPORT 00197 00198 /* 00199 * UPDATE configuration 00200 */ 00201 00202 #define PAL_UPDATE_USE_FLASH 1 00203 #define PAL_UPDATE_USE_FS 2 00204 00205 #ifndef PAL_UPDATE_IMAGE_LOCATION 00206 #define PAL_UPDATE_IMAGE_LOCATION PAL_UPDATE_USE_FS //!< Choose the storage correct Storage option, File System or Flash 00207 #endif 00208 00209 //! Certificate date validation in Unix time format. 00210 #ifndef PAL_CRYPTO_CERT_DATE_LENGTH 00211 #define PAL_CRYPTO_CERT_DATE_LENGTH sizeof(uint64_t) 00212 #endif 00213 00214 /* 00215 * FS configuration 00216 */ 00217 00218 /* !\brief file system configurations 00219 * PAL_NUMBER_OF_PARTITIONS 00220 * 0 - Default behavior for the platform (Described by either 1 or 2 below). 00221 * 1 - There is a single partition in which the ARM client applications create and remove files (but do not format it). 00222 * 2 - There are two partitions in which ARM client applications may format or create and remove files, 00223 * depending on PAL_PRIMARY_PARTITION_PRIVATE and PAL_SECONDARY_PARTITION_PRIVATE 00224 */ 00225 #ifndef PAL_NUMBER_OF_PARTITIONS 00226 #define PAL_NUMBER_OF_PARTITIONS 1 // Default partitions 00227 #endif 00228 00229 #if (PAL_NUMBER_OF_PARTITIONS > 2) 00230 #error "PAL_NUMBER_OF_PARTITIONS cannot be more then 2" 00231 #endif 00232 00233 // PAL_PRIMARY_PARTITION_PRIVATE 00234 // 1 if the primary partition is exclusively dedicated to the ARM client applications. 00235 // 0 if the primary partition is used for storing other files as well. 00236 #ifndef PAL_PRIMARY_PARTITION_PRIVATE 00237 #define PAL_PRIMARY_PARTITION_PRIVATE 0 00238 #endif 00239 00240 //! PAL_SECONDARY_PARTITION_PRIVATE 00241 //! 1 if the secondary partition is exclusively dedicated to the ARM client applications. 00242 //! 0 if the secondary partition is used for storing other files as well. 00243 #ifndef PAL_SECONDARY_PARTITION_PRIVATE 00244 #define PAL_SECONDARY_PARTITION_PRIVATE 0 00245 #endif 00246 00247 //! This define is the location of the primary mount point for the file system 00248 #ifndef PAL_FS_MOUNT_POINT_PRIMARY 00249 #define PAL_FS_MOUNT_POINT_PRIMARY "" 00250 #endif 00251 00252 //! This define is the location of the secondary mount point for the file system 00253 #ifndef PAL_FS_MOUNT_POINT_SECONDARY 00254 #define PAL_FS_MOUNT_POINT_SECONDARY "" 00255 #endif 00256 00257 // Update 00258 00259 #ifndef PAL_UPDATE_FIRMWARE_MOUNT_POINT 00260 #define PAL_UPDATE_FIRMWARE_MOUNT_POINT PAL_FS_MOUNT_POINT_PRIMARY 00261 #endif 00262 //! The location of the firmware update folder 00263 #ifndef PAL_UPDATE_FIRMWARE_DIR 00264 #define PAL_UPDATE_FIRMWARE_DIR PAL_UPDATE_FIRMWARE_MOUNT_POINT "/firmware" 00265 #endif 00266 00267 /*\brief If flash existed set to 1 else 0, the flash is used for none volatile backup*/ 00268 #ifndef PAL_USE_INTERNAL_FLASH 00269 #define PAL_USE_INTERNAL_FLASH 0 00270 #endif 00271 00272 #ifndef PAL_INT_FLASH_NUM_SECTIONS 00273 #define PAL_INT_FLASH_NUM_SECTIONS 0 00274 #endif 00275 00276 #ifndef PAL_USE_HW_ROT 00277 #define PAL_USE_HW_ROT 1 00278 #endif 00279 00280 #ifndef PAL_USE_HW_RTC 00281 #define PAL_USE_HW_RTC 1 00282 #endif 00283 00284 #ifndef PAL_USE_HW_TRNG 00285 #define PAL_USE_HW_TRNG 1 00286 #endif 00287 00288 //! The number of valid priorities limits the number of concurrent running threads. 00289 #ifndef PAL_MAX_NUMBER_OF_THREADS 00290 #if PAL_USE_HW_TRNG 00291 #define PAL_MAX_NUMBER_OF_THREADS 9 00292 #else 00293 #define PAL_MAX_NUMBER_OF_THREADS 8 00294 #endif 00295 #endif 00296 00297 #if PAL_USE_HW_TRNG 00298 //! Delay for TRNG noise collecting thread used between calls to TRNG 00299 #ifndef PAL_NOISE_TRNG_THREAD_DELAY_MILLI_SEC 00300 #define PAL_NOISE_TRNG_THREAD_DELAY_MILLI_SEC (1000 * 60) // one minute 00301 #endif 00302 //! Stack size for TRNG noise collecting thread 00303 #ifndef PAL_NOISE_TRNG_THREAD_STACK_SIZE 00304 #define PAL_NOISE_TRNG_THREAD_STACK_SIZE 1536 // 1.5K 00305 #endif 00306 #endif 00307 00308 #ifndef PAL_USE_SECURE_TIME 00309 #define PAL_USE_SECURE_TIME 1 00310 #endif 00311 00312 #ifndef PAL_DEVICE_KEY_DERIVATION_BACKWARD_COMPATIBILITY_CALC 00313 #define PAL_DEVICE_KEY_DERIVATION_BACKWARD_COMPATIBILITY_CALC 0 00314 #endif 00315 00316 /*\brief Starting Address for section 1 Minimum requirement size is 1KB and section must be consecutive sectors*/ 00317 #ifndef PAL_INTERNAL_FLASH_SECTION_1_ADDRESS 00318 #define PAL_INTERNAL_FLASH_SECTION_1_ADDRESS 0 00319 #endif 00320 /*\brief Starting Address for section 2 Minimum requirement size is 1KB and section must be consecutive sectors*/ 00321 #ifndef PAL_INTERNAL_FLASH_SECTION_2_ADDRESS 00322 #define PAL_INTERNAL_FLASH_SECTION_2_ADDRESS 0 00323 #endif 00324 /*\brief Size for section 1*/ 00325 #ifndef PAL_INTERNAL_FLASH_SECTION_1_SIZE 00326 #define PAL_INTERNAL_FLASH_SECTION_1_SIZE 0 00327 #endif 00328 /*\brief Size for section 2*/ 00329 #ifndef PAL_INTERNAL_FLASH_SECTION_2_SIZE 00330 #define PAL_INTERNAL_FLASH_SECTION_2_SIZE 0 00331 #endif 00332 00333 #ifndef PAL_SIMULATOR_TEST_ENABLE 00334 #define PAL_SIMULATOR_TEST_ENABLE 0 00335 #endif 00336 00337 00338 00339 #if (PAL_SIMULATOR_TEST_ENABLE == 1) 00340 00341 #undef PAL_SIMULATE_RTOS_REBOOT 00342 #define PAL_SIMULATE_RTOS_REBOOT 1 00343 00344 #undef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 00345 #define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 1 00346 00347 /*\brief overwrite format command with remove all file and directory only for Linux*/ 00348 #undef PAL_SIMULATOR_FS_RM_INSTEAD_OF_FORMAT 00349 #define PAL_SIMULATOR_FS_RM_INSTEAD_OF_FORMAT 1 00350 #endif //PAL_SIMULATOR_TEST_ENABLE 00351 00352 #ifndef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 00353 #define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 0 00354 #endif 00355 00356 00357 00358 #if PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 00359 00360 00361 #undef PAL_USE_INTERNAL_FLASH 00362 #define PAL_USE_INTERNAL_FLASH 1 00363 00364 #undef PAL_INT_FLASH_NUM_SECTIONS 00365 #define PAL_INT_FLASH_NUM_SECTIONS 2 00366 00367 #ifndef PAL_SIMULATOR_SOTP_AREA_SIZE 00368 #define PAL_SIMULATOR_SOTP_AREA_SIZE 4096 /*\brief must be power of two the can be divded to page size without reminder and must be a multiple of sector size*/ 00369 #endif 00370 00371 #ifndef SIMULATE_FLASH_SECTOR_SIZE 00372 #define SIMULATE_FLASH_SECTOR_SIZE 4096 /*\brief Flash Sector size*/ 00373 #endif 00374 00375 #ifndef SIMULATE_FLASH_DIR 00376 #define SIMULATE_FLASH_DIR "" /*\brief Directory that holds the flash simulator file*/ 00377 #endif 00378 00379 #ifndef SIMULATE_FLASH_FILE_NAME 00380 #define SIMULATE_FLASH_FILE_NAME SIMULATE_FLASH_DIR"/flashSim" /*\brief File name and path to the flash simulator file*/ 00381 #endif 00382 00383 #ifndef SIMULATE_FLASH_PAGE_SIZE 00384 #define SIMULATE_FLASH_PAGE_SIZE 8 /*\brief Minumum writing uint to flash (2, 4, 8, 16)*/ 00385 #endif 00386 00387 #if PAL_SIMULATOR_SOTP_AREA_SIZE < 4096 00388 #error Minimum Size of 4K 00389 #endif 00390 00391 /*\brief Note - In simulator mode all flash areas are overriden with the simulation sizes and address*/ 00392 00393 #undef PAL_INTERNAL_FLASH_SECTION_1_SIZE 00394 /*\brief Size for section 1*/ 00395 #define PAL_INTERNAL_FLASH_SECTION_1_SIZE PAL_SIMULATOR_SOTP_AREA_SIZE 00396 00397 #undef PAL_INTERNAL_FLASH_SECTION_2_SIZE 00398 /*\brief Size for section 2*/ 00399 #define PAL_INTERNAL_FLASH_SECTION_2_SIZE PAL_SIMULATOR_SOTP_AREA_SIZE 00400 00401 #undef PAL_INTERNAL_FLASH_SECTION_1_ADDRESS 00402 /*\brief Starting Address for section 1 Minimum requirement size is 1KB and section must be consecutive sectors*/ 00403 #define PAL_INTERNAL_FLASH_SECTION_1_ADDRESS 0 00404 00405 #undef PAL_INTERNAL_FLASH_SECTION_2_ADDRESS 00406 /*\brief Starting Address for section 2 Minimum requirement size is 1KB and section must be consecutive sectors*/ 00407 #define PAL_INTERNAL_FLASH_SECTION_2_ADDRESS PAL_INTERNAL_FLASH_SECTION_1_SIZE 00408 00409 #endif //PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 00410 00411 00412 #define VALUE_TO_STRING(x) #x 00413 #define VALUE(x) VALUE_TO_STRING(x) 00414 #define VAR_NAME_VALUE(var) #var " = " VALUE(var) 00415 00416 #if ((!PAL_USE_INTERNAL_FLASH && (!PAL_USE_HW_ROT || !PAL_USE_HW_RTC || !PAL_USE_HW_TRNG)) \ 00417 || ((PAL_INT_FLASH_NUM_SECTIONS == 1) && PAL_USE_INTERNAL_FLASH && (!PAL_USE_HW_RTC || !PAL_USE_HW_TRNG)) \ 00418 || ((PAL_INT_FLASH_NUM_SECTIONS == 2) && PAL_USE_INTERNAL_FLASH && !PAL_USE_HW_TRNG)) 00419 #pragma message(VAR_NAME_VALUE(PAL_USE_INTERNAL_FLASH)) 00420 #pragma message(VAR_NAME_VALUE(PAL_USE_HW_ROT)) 00421 #pragma message(VAR_NAME_VALUE(PAL_USE_HW_RTC)) 00422 #pragma message(VAR_NAME_VALUE(PAL_USE_HW_TRNG)) 00423 #pragma message(VAR_NAME_VALUE(PAL_INT_FLASH_NUM_SECTIONS)) 00424 #error Minimum configuration setting does not meet the requirements 00425 #endif 00426 00427 #if (((PAL_ENABLE_PSK == 1) && (PAL_ENABLE_X509 == 1)) && !(defined(__LINUX__))) 00428 #error "Please select only one option PSK/X509" 00429 #endif 00430 00431 #if ((PAL_ENABLE_PSK == 0) && (PAL_ENABLE_X509 == 0)) 00432 #error "Please select one option PSK/X509" 00433 #endif 00434 00435 00436 00437 #if ((PAL_ENABLE_PSK == 1) && (PAL_USE_SECURE_TIME == 1)) 00438 #error "PSK feature cannot be configured along with secure time" 00439 #endif 00440 00441 00442 00443 //! Delay (in milliseconds) between calls to TRNG random buffer in case only partial data (PAL_ERR_RTOS_TRNG_PARTIAL_DATA) was generated for the function call 00444 #ifndef PAL_TRNG_COLLECT_DELAY_MILLI_SEC 00445 #define PAL_TRNG_COLLECT_DELAY_MILLI_SEC 1000 00446 #endif // !PAL_TRNG_COLLECT_DELAY_MILLI_SEC 00447 00448 //! define the number of images 00449 #ifndef IMAGE_COUNT_MAX 00450 #define IMAGE_COUNT_MAX 1 00451 #endif 00452 00453 #define PAL_NOISE_SIZE_BYTES 48 // max number of bytes for noise 00454 #define PAL_NOISE_SIZE_BITS (PAL_NOISE_SIZE_BYTES * CHAR_BIT) // max number of bits for noise 00455 #define PAL_NOISE_BUFFER_LEN (PAL_NOISE_SIZE_BYTES / sizeof(int32_t)) // length of the noise buffer 00456 00457 #endif //_PAL_COFIGURATION_H
Generated on Tue Jul 12 2022 19:01:35 by 1.7.2