Edge Applications
Device Management
IoT
Contact Us
Login
Documentation
current
v4.12
v4.11
v4.10
v4.9
v4.8
v4.7
v4.6
v4.5
v4.4
v4.3
v4.2
v4.1
v4.0
v3.4
v3.3
Mistake on this page?
Email us
Main Page
Modules
Data Structures
Files
File List
Globals
mbed-cloud-client
mbed-client-pal
Source
PAL-Impl
Services-API
pal_configuration.h
Go to the documentation of this file.
1
// ----------------------------------------------------------------------------
2
// Copyright 2016-2019 ARM Ltd.
3
//
4
// SPDX-License-Identifier: Apache-2.0
5
//
6
// Licensed under the Apache License, Version 2.0 (the "License");
7
// you may not use this file except in compliance with the License.
8
// You may obtain a copy of the License at
9
//
10
// http://www.apache.org/licenses/LICENSE-2.0
11
//
12
// Unless required by applicable law or agreed to in writing, software
13
// distributed under the License is distributed on an "AS IS" BASIS,
14
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
// See the License for the specific language governing permissions and
16
// limitations under the License.
17
// ----------------------------------------------------------------------------
18
19
#ifndef _PAL_COFIGURATION_H
20
#define _PAL_COFIGURATION_H
21
#include "limits.h"
22
23
#if 0
24
// This block is useful when building on new environment and one needs to find out,
25
// how to pass the "include-file.h" macro value via multiple layers of scripts
26
// and different reserved char escaping conventions.
27
#define XSTR(x) STR(x)
28
#define STR(x) #x
29
30
#pragma message "The value of PAL_USER_DEFINED_CONFIGURATION: " XSTR(PAL_USER_DEFINED_CONFIGURATION)
31
#endif
32
33
#ifdef PAL_USER_DEFINED_CONFIGURATION
34
#include PAL_USER_DEFINED_CONFIGURATION
35
#endif
36
49
/* If you need any board-specific configuration, please include this define
50
*/
51
#ifdef PAL_BOARD_SPECIFIC_CONFIG
52
#include PAL_BOARD_SPECIFIC_CONFIG
53
#endif
54
55
/* Lets the user choose the platform configuration file.
56
\note If the user does not specify a platform configuration file,
57
\note PAL uses a default configuration set that can be found at Configs/pal_config folder
58
*/
59
60
#ifdef PAL_PLATFORM_DEFINED_CONFIGURATION
61
#include PAL_PLATFORM_DEFINED_CONFIGURATION
62
#elif defined(__LINUX__)
63
#include "Linux_default.h"
64
#elif defined(__FREERTOS__)
65
#include "FreeRTOS_default.h"
66
#elif defined(__MBED__)
67
#include "mbedOS_default.h"
68
#elif defined(__SXOS__)
69
#include "sxos_default.h"
70
#else
71
#error "Please specify the platform PAL_PLATFORM_DEFINED_CONFIGURATION"
72
#endif
73
78
#ifndef PAL_USE_HW_ROT
79
#define PAL_USE_HW_ROT 1
80
#endif
81
86
#ifndef PAL_USE_HW_RTC
87
#define PAL_USE_HW_RTC 1
88
#endif
89
94
#ifndef PAL_USE_HW_TRNG
95
#define PAL_USE_HW_TRNG 1
96
#endif
97
102
#ifndef PAL_USE_SECURE_TIME
103
#define PAL_USE_SECURE_TIME 1
104
#endif
105
106
#ifndef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
107
#define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 0
108
#endif
109
110
#ifndef PAL_USE_INTERNAL_FLASH
111
#define PAL_USE_INTERNAL_FLASH 0
112
#endif
113
114
/*
115
* Network configuration
116
*/
117
// PAL configuration options
118
#ifndef PAL_NET_TCP_AND_TLS_SUPPORT
119
#define PAL_NET_TCP_AND_TLS_SUPPORT true
120
#endif
121
122
#ifndef PAL_NET_DNS_SUPPORT
123
#define PAL_NET_DNS_SUPPORT true
124
#endif
125
126
#if (PAL_NET_DNS_SUPPORT == true) && !(defined(PAL_DNS_API_VERSION))
127
#define PAL_DNS_API_VERSION 0
128
#endif
129
130
#ifndef PAL_NET_SERVER_SOCKET_API
131
#define PAL_NET_SERVER_SOCKET_API true
132
#endif
133
134
#ifndef PAL_SUPPORT_IP_V4
135
#define PAL_SUPPORT_IP_V4 true
136
#endif
137
#ifndef PAL_SUPPORT_IP_V6
138
#define PAL_SUPPORT_IP_V6 true
139
#endif
140
141
//values for PAL_NET_DNS_IP_SUPPORT
142
#define PAL_NET_DNS_ANY 0
143
#define PAL_NET_DNS_IPV4_ONLY 2
144
#define PAL_NET_DNS_IPV6_ONLY 4
145
146
#ifndef PAL_NET_DNS_IP_SUPPORT
147
#if PAL_SUPPORT_IP_V6 == true && PAL_SUPPORT_IP_V4 == true
148
#define PAL_NET_DNS_IP_SUPPORT 0
149
#elif PAL_SUPPORT_IP_V6 == true
150
#define PAL_NET_DNS_IP_SUPPORT 4
151
#else
152
#define PAL_NET_DNS_IP_SUPPORT 2
153
#endif
154
#endif
155
157
#ifndef PAL_MAX_SUPORTED_NET_INTERFACES
158
#define PAL_MAX_SUPORTED_NET_INTERFACES 1
159
#endif
160
162
#ifndef PAL_NET_ASYNC_DNS_THREAD_STACK_SIZE
163
#define PAL_NET_ASYNC_DNS_THREAD_STACK_SIZE (1024 * 2)
164
#endif
165
167
#ifndef PAL_CLEANUP_ON_INIT_FAILURE
168
#define PAL_CLEANUP_ON_INIT_FAILURE true
169
#endif
170
171
/*
172
* RTOS configuration
173
*/
174
180
#ifndef PAL_THREAD_SAFETY
181
#define PAL_THREAD_SAFETY 1
182
#endif
183
188
#ifndef PAL_RTOS_THREAD_CLEANUP_TIMER_MILISEC
189
#define PAL_RTOS_THREAD_CLEANUP_TIMER_MILISEC 200
190
#endif
191
193
#ifndef PAL_INITIAL_RANDOM_SIZE
194
#define PAL_INITIAL_RANDOM_SIZE 48
195
#endif
196
197
#ifndef PAL_RTOS_WAIT_FOREVER
198
#define PAL_RTOS_WAIT_FOREVER UINT_MAX
199
#endif
200
201
/*
202
* TLS configuration
203
*/
204
206
#ifndef PAL_MAX_ALLOWED_CIPHER_SUITES
207
#define PAL_MAX_ALLOWED_CIPHER_SUITES 1
208
#endif
209
211
212
/*
213
* /def PAL_DTLS_PEER_MIN_TIMEOUT
214
* /brief Define the DTLS peer minimum timeout value.
215
*/
216
217
#ifndef PAL_DTLS_PEER_MIN_TIMEOUT
218
#define PAL_DTLS_PEER_MIN_TIMEOUT 10000
219
#endif
220
222
#ifndef PAL_TLS_DEBUG_THRESHOLD
223
#define PAL_TLS_DEBUG_THRESHOLD 5
224
#endif
225
227
#ifndef PAL_CERT_ID_SIZE
228
#define PAL_CERT_ID_SIZE 33
229
#endif
230
231
#ifndef PAL_ENABLE_PSK
232
#define PAL_ENABLE_PSK 0
233
#endif
234
235
#ifndef PAL_ENABLE_X509
236
#define PAL_ENABLE_X509 1
237
#endif
238
239
// Defines the cipher suites for TLS. Only one cipher suite per device available.
240
#define PAL_TLS_PSK_WITH_AES_128_CCM_8_SUITE 0x01
241
#define PAL_TLS_PSK_WITH_AES_256_CCM_8_SUITE 0x02
242
#define PAL_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8_SUITE 0x04
243
#define PAL_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_SUITE 0x08
244
#define PAL_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_SUITE 0x10
245
#define PAL_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256_SUITE 0x20
246
248
#if (PAL_ENABLE_X509 == 1)
249
#ifndef PAL_TLS_CIPHER_SUITE
250
#define PAL_TLS_CIPHER_SUITE PAL_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8_SUITE
251
#endif
252
#elif (PAL_ENABLE_PSK == 1)
253
#ifndef PAL_TLS_CIPHER_SUITE
254
#define PAL_TLS_CIPHER_SUITE PAL_TLS_PSK_WITH_AES_128_CCM_8_SUITE
255
#endif
256
#endif
257
259
#ifndef PAL_CMAC_SUPPORT
260
#define PAL_CMAC_SUPPORT 1
261
#endif //PAL_CMAC_SUPPORT
262
263
/*
264
* UPDATE configuration
265
*/
266
267
#define PAL_UPDATE_USE_FLASH 1
268
#define PAL_UPDATE_USE_FS 2
269
270
#ifndef PAL_UPDATE_IMAGE_LOCATION
271
#define PAL_UPDATE_IMAGE_LOCATION PAL_UPDATE_USE_FS
272
#endif
273
275
#ifndef PAL_CRYPTO_CERT_DATE_LENGTH
276
#define PAL_CRYPTO_CERT_DATE_LENGTH sizeof(uint64_t)
277
#endif
278
279
/*
280
* File system configuration
281
*/
282
283
289
#ifndef PAL_USE_FILESYSTEM
290
#define PAL_USE_FILESYSTEM 1
291
#endif
292
299
#ifndef PAL_NUMBER_OF_PARTITIONS
300
#define PAL_NUMBER_OF_PARTITIONS 1 // Default partitions
301
#endif
302
303
#if (PAL_NUMBER_OF_PARTITIONS > 2)
304
#error "PAL_NUMBER_OF_PARTITIONS cannot be more then 2"
305
#endif
306
312
#ifndef PAL_PRIMARY_PARTITION_PRIVATE
313
#define PAL_PRIMARY_PARTITION_PRIVATE 0
314
#endif
315
321
#ifndef PAL_SECONDARY_PARTITION_PRIVATE
322
#define PAL_SECONDARY_PARTITION_PRIVATE 0
323
#endif
324
326
#ifndef PAL_FS_MOUNT_POINT_PRIMARY
327
#define PAL_FS_MOUNT_POINT_PRIMARY ""
328
#endif
329
331
#ifndef PAL_FS_MOUNT_POINT_SECONDARY
332
#define PAL_FS_MOUNT_POINT_SECONDARY ""
333
#endif
334
335
// Update
336
337
#ifndef PAL_UPDATE_FIRMWARE_MOUNT_POINT
338
#define PAL_UPDATE_FIRMWARE_MOUNT_POINT PAL_FS_MOUNT_POINT_PRIMARY
339
#endif
340
342
#ifndef PAL_UPDATE_FIRMWARE_DIR
343
#define PAL_UPDATE_FIRMWARE_DIR PAL_UPDATE_FIRMWARE_MOUNT_POINT "/firmware"
344
#endif
345
346
#ifndef PAL_INT_FLASH_NUM_SECTIONS
347
#define PAL_INT_FLASH_NUM_SECTIONS 0
348
#endif
349
350
#if PAL_USE_HW_TRNG
351
#ifndef PAL_NOISE_TRNG_THREAD_DELAY_MILLI_SEC
353
#define PAL_NOISE_TRNG_THREAD_DELAY_MILLI_SEC (1000 * 60) // one minute
354
#endif
355
#ifndef PAL_NOISE_TRNG_THREAD_STACK_SIZE
357
#define PAL_NOISE_TRNG_THREAD_STACK_SIZE 1536 // 1.5K
358
#endif
359
#endif
360
361
#ifndef PAL_DEVICE_KEY_DERIVATION_BACKWARD_COMPATIBILITY_CALC
362
#define PAL_DEVICE_KEY_DERIVATION_BACKWARD_COMPATIBILITY_CALC 0
363
#endif
364
369
#ifndef PAL_INTERNAL_FLASH_SECTION_1_ADDRESS
370
#define PAL_INTERNAL_FLASH_SECTION_1_ADDRESS 0
371
#endif
372
375
#ifndef PAL_INTERNAL_FLASH_SECTION_2_ADDRESS
376
#define PAL_INTERNAL_FLASH_SECTION_2_ADDRESS 0
377
#endif
378
#ifndef PAL_INTERNAL_FLASH_SECTION_1_SIZE
380
#define PAL_INTERNAL_FLASH_SECTION_1_SIZE 0
381
#endif
382
#ifndef PAL_INTERNAL_FLASH_SECTION_2_SIZE
384
#define PAL_INTERNAL_FLASH_SECTION_2_SIZE 0
385
#endif
386
387
#ifndef PAL_SIMULATOR_TEST_ENABLE
388
#define PAL_SIMULATOR_TEST_ENABLE 0
389
#endif
390
391
#if (PAL_SIMULATOR_TEST_ENABLE == 1)
392
393
#undef PAL_SIMULATE_RTOS_REBOOT
394
#define PAL_SIMULATE_RTOS_REBOOT 1
395
396
#undef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
397
#define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 1
398
400
#undef PAL_SIMULATOR_FS_RM_INSTEAD_OF_FORMAT
401
#define PAL_SIMULATOR_FS_RM_INSTEAD_OF_FORMAT 1
402
#endif //PAL_SIMULATOR_TEST_ENABLE
403
404
#ifndef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
405
#define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 0
406
#endif
407
408
#if PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
409
410
#undef PAL_USE_INTERNAL_FLASH
411
#define PAL_USE_INTERNAL_FLASH 1
412
413
#undef PAL_INT_FLASH_NUM_SECTIONS
414
#define PAL_INT_FLASH_NUM_SECTIONS 2
415
416
#ifndef PAL_SIMULATOR_SOTP_AREA_SIZE
417
#define PAL_SIMULATOR_SOTP_AREA_SIZE 4096
418
#endif
419
420
#ifndef SIMULATE_FLASH_SECTOR_SIZE
421
#define SIMULATE_FLASH_SECTOR_SIZE 4096
422
#endif
423
424
#ifndef SIMULATE_FLASH_DIR
425
#define SIMULATE_FLASH_DIR ""
426
#endif
427
428
#ifndef SIMULATE_FLASH_FILE_NAME
429
#define SIMULATE_FLASH_FILE_NAME SIMULATE_FLASH_DIR"/flashSim"
430
#endif
431
432
#ifndef SIMULATE_FLASH_PAGE_SIZE
433
#define SIMULATE_FLASH_PAGE_SIZE 8
434
#endif
435
436
#if PAL_SIMULATOR_SOTP_AREA_SIZE < 4096
437
#error Minimum Size of 4K
438
#endif
439
440
/* Note - In simulator mode all flash areas are overrided with the simulation sizes and address*/
441
442
/* \brief Size for section 1
443
*
444
* Minimum required size is 1KB and section must be consecutive sectors
445
*/
446
#undef PAL_INTERNAL_FLASH_SECTION_1_SIZE
447
#define PAL_INTERNAL_FLASH_SECTION_1_SIZE PAL_SIMULATOR_SOTP_AREA_SIZE
448
449
#undef PAL_INTERNAL_FLASH_SECTION_2_SIZE
450
454
#define PAL_INTERNAL_FLASH_SECTION_2_SIZE PAL_SIMULATOR_SOTP_AREA_SIZE
455
456
#undef PAL_INTERNAL_FLASH_SECTION_1_ADDRESS
457
#define PAL_INTERNAL_FLASH_SECTION_1_ADDRESS 0
459
460
#undef PAL_INTERNAL_FLASH_SECTION_2_ADDRESS
461
#define PAL_INTERNAL_FLASH_SECTION_2_ADDRESS PAL_INTERNAL_FLASH_SECTION_1_SIZE
463
464
#endif //PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
465
466
#define VALUE_TO_STRING(x) #x
467
#define VALUE(x) VALUE_TO_STRING(x)
468
#define VAR_NAME_VALUE(var) #var " = " VALUE(var)
469
470
#if (((!PAL_USE_INTERNAL_FLASH && (!PAL_USE_HW_ROT || !PAL_USE_HW_RTC || !PAL_USE_HW_TRNG)) \
471
|| ((PAL_INT_FLASH_NUM_SECTIONS == 1) && PAL_USE_INTERNAL_FLASH && (!PAL_USE_HW_RTC || !PAL_USE_HW_TRNG))) \
472
&& !defined MBED_CONF_MBED_CLOUD_CLIENT_EXTERNAL_SST_SUPPORT)
473
#pragma message(VAR_NAME_VALUE(PAL_USE_INTERNAL_FLASH))
474
#pragma message(VAR_NAME_VALUE(PAL_USE_HW_ROT))
475
#pragma message(VAR_NAME_VALUE(PAL_USE_HW_RTC))
476
#pragma message(VAR_NAME_VALUE(PAL_USE_HW_TRNG))
477
#pragma message(VAR_NAME_VALUE(PAL_INT_FLASH_NUM_SECTIONS))
478
#error Minimum configuration setting does not meet the requirements
479
#endif
480
481
#if (((PAL_ENABLE_PSK == 1) && (PAL_ENABLE_X509 == 1)) && !(defined(__LINUX__)))
482
#error "Please select only one option: PSK or X509"
483
#endif
484
485
#if ((PAL_ENABLE_PSK == 0) && (PAL_ENABLE_X509 == 0))
486
#error "Please select one option: PSK or X509"
487
#endif
488
489
#if ((PAL_ENABLE_PSK == 1) && (PAL_USE_SECURE_TIME == 1))
490
#error "PSK feature cannot be configured when using secure time"
491
#endif
492
494
#ifndef PAL_TRNG_COLLECT_DELAY_MILLI_SEC
495
#define PAL_TRNG_COLLECT_DELAY_MILLI_SEC 1000
496
#endif // PAL_TRNG_COLLECT_DELAY_MILLI_SEC
497
499
#ifndef IMAGE_COUNT_MAX
500
#define IMAGE_COUNT_MAX 1
501
#endif
502
503
#define PAL_NOISE_SIZE_BYTES 48
504
#define PAL_NOISE_SIZE_BITS (PAL_NOISE_SIZE_BYTES * CHAR_BIT)
505
#define PAL_NOISE_BUFFER_LEN (PAL_NOISE_SIZE_BYTES / sizeof(int32_t))
506
507
// SSL session resume is enabled by default
508
#ifndef PAL_USE_SSL_SESSION_RESUME
509
#define PAL_USE_SSL_SESSION_RESUME 1
510
#endif
511
512
// Sanity check for using static memory buffer with mbedtls.
513
#ifdef PAL_USE_STATIC_MEMBUF_FOR_MBEDTLS
514
515
#if !defined(PAL_STATIC_MEMBUF_SIZE_FOR_MBEDTLS)
516
#error "When using PAL_USE_STATIC_MEMBUF_FOR_MBEDTLS, you must also define the size for the static memory buffer with PAL_STATIC_MEMBUF_SIZE_FOR_MBEDTLS."
517
#endif
518
519
#endif // #ifdef PAL_USE_STATIC_MEMBUF_FOR_MBEDTLS
520
521
#endif //_PAL_COFIGURATION_H