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_FILE_SYSTEM_OVER_RAM
107
#define PAL_SIMULATOR_FILE_SYSTEM_OVER_RAM 0
108
#endif
109
110
#ifndef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
111
#define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 0
112
#endif
113
114
#ifndef PAL_USE_INTERNAL_FLASH
115
#define PAL_USE_INTERNAL_FLASH 0
116
#endif
117
118
/*
119
* Network configuration
120
*/
121
// PAL configuration options
122
#ifndef PAL_NET_TCP_AND_TLS_SUPPORT
123
#define PAL_NET_TCP_AND_TLS_SUPPORT true
124
#endif
125
126
#ifndef PAL_NET_DNS_SUPPORT
127
#define PAL_NET_DNS_SUPPORT true
128
#endif
129
130
#if (PAL_NET_DNS_SUPPORT == true) && !(defined(PAL_DNS_API_VERSION))
131
#define PAL_DNS_API_VERSION 0
132
#endif
133
134
#ifndef PAL_NET_SERVER_SOCKET_API
135
#define PAL_NET_SERVER_SOCKET_API true
136
#endif
137
138
#ifndef PAL_SUPPORT_IP_V4
139
#define PAL_SUPPORT_IP_V4 true
140
#endif
141
#ifndef PAL_SUPPORT_IP_V6
142
#define PAL_SUPPORT_IP_V6 true
143
#endif
144
145
//values for PAL_NET_DNS_IP_SUPPORT
146
#define PAL_NET_DNS_ANY 0
147
#define PAL_NET_DNS_IPV4_ONLY 2
148
#define PAL_NET_DNS_IPV6_ONLY 4
149
150
#ifndef PAL_NET_DNS_IP_SUPPORT
151
#if PAL_SUPPORT_IP_V6 == true && PAL_SUPPORT_IP_V4 == true
152
#define PAL_NET_DNS_IP_SUPPORT 0
153
#elif PAL_SUPPORT_IP_V6 == true
154
#define PAL_NET_DNS_IP_SUPPORT 4
155
#else
156
#define PAL_NET_DNS_IP_SUPPORT 2
157
#endif
158
#endif
159
161
#ifndef PAL_MAX_SUPORTED_NET_INTERFACES
162
#define PAL_MAX_SUPORTED_NET_INTERFACES 1
163
#endif
164
166
#ifndef PAL_NET_ASYNC_DNS_THREAD_STACK_SIZE
167
#define PAL_NET_ASYNC_DNS_THREAD_STACK_SIZE (1024 * 2)
168
#endif
169
171
#ifndef PAL_CLEANUP_ON_INIT_FAILURE
172
#define PAL_CLEANUP_ON_INIT_FAILURE true
173
#endif
174
175
/*
176
* RTOS configuration
177
*/
178
184
#ifndef PAL_THREAD_SAFETY
185
#define PAL_THREAD_SAFETY 1
186
#endif
187
192
#ifndef PAL_RTOS_THREAD_CLEANUP_TIMER_MILISEC
193
#define PAL_RTOS_THREAD_CLEANUP_TIMER_MILISEC 200
194
#endif
195
197
#ifndef PAL_INITIAL_RANDOM_SIZE
198
#define PAL_INITIAL_RANDOM_SIZE 48
199
#endif
200
201
#ifndef PAL_RTOS_WAIT_FOREVER
202
#define PAL_RTOS_WAIT_FOREVER UINT_MAX
203
#endif
204
205
/*
206
* TLS configuration
207
*/
208
210
#ifndef PAL_MAX_ALLOWED_CIPHER_SUITES
211
#define PAL_MAX_ALLOWED_CIPHER_SUITES 1
212
#endif
213
215
216
/*
217
* /def PAL_DTLS_PEER_MIN_TIMEOUT
218
* /brief Define the DTLS peer minimum timeout value.
219
*/
220
221
#ifndef PAL_DTLS_PEER_MIN_TIMEOUT
222
#define PAL_DTLS_PEER_MIN_TIMEOUT 10000
223
#endif
224
226
#ifndef PAL_TLS_DEBUG_THRESHOLD
227
#define PAL_TLS_DEBUG_THRESHOLD 5
228
#endif
229
231
#ifndef PAL_CERT_ID_SIZE
232
#define PAL_CERT_ID_SIZE 33
233
#endif
234
235
#ifndef PAL_ENABLE_PSK
236
#define PAL_ENABLE_PSK 0
237
#endif
238
239
#ifndef PAL_ENABLE_X509
240
#define PAL_ENABLE_X509 1
241
#endif
242
243
// Defines the cipher suites for TLS. Only one cipher suite per device available.
244
#define PAL_TLS_PSK_WITH_AES_128_CCM_8_SUITE 0x01
245
#define PAL_TLS_PSK_WITH_AES_256_CCM_8_SUITE 0x02
246
#define PAL_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8_SUITE 0x04
247
#define PAL_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_SUITE 0x08
248
#define PAL_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_SUITE 0x10
249
#define PAL_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256_SUITE 0x20
250
252
#if (PAL_ENABLE_X509 == 1)
253
#ifndef PAL_TLS_CIPHER_SUITE
254
#define PAL_TLS_CIPHER_SUITE PAL_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8_SUITE
255
#endif
256
#elif (PAL_ENABLE_PSK == 1)
257
#ifndef PAL_TLS_CIPHER_SUITE
258
#define PAL_TLS_CIPHER_SUITE PAL_TLS_PSK_WITH_AES_128_CCM_8_SUITE
259
#endif
260
#endif
261
263
#ifndef PAL_CMAC_SUPPORT
264
#define PAL_CMAC_SUPPORT 1
265
#endif //PAL_CMAC_SUPPORT
266
267
/*
268
* UPDATE configuration
269
*/
270
271
#define PAL_UPDATE_USE_FLASH 1
272
#define PAL_UPDATE_USE_FS 2
273
274
#ifndef PAL_UPDATE_IMAGE_LOCATION
275
#define PAL_UPDATE_IMAGE_LOCATION PAL_UPDATE_USE_FS
276
#endif
277
279
#ifndef PAL_CRYPTO_CERT_DATE_LENGTH
280
#define PAL_CRYPTO_CERT_DATE_LENGTH sizeof(uint64_t)
281
#endif
282
283
/*
284
* File system configuration
285
*/
286
287
293
#ifndef PAL_USE_FILESYSTEM
294
#define PAL_USE_FILESYSTEM 1
295
#endif
296
303
#ifndef PAL_NUMBER_OF_PARTITIONS
304
#define PAL_NUMBER_OF_PARTITIONS 1 // Default partitions
305
#endif
306
307
#if (PAL_NUMBER_OF_PARTITIONS > 2)
308
#error "PAL_NUMBER_OF_PARTITIONS cannot be more then 2"
309
#endif
310
316
#ifndef PAL_PRIMARY_PARTITION_PRIVATE
317
#define PAL_PRIMARY_PARTITION_PRIVATE 0
318
#endif
319
325
#ifndef PAL_SECONDARY_PARTITION_PRIVATE
326
#define PAL_SECONDARY_PARTITION_PRIVATE 0
327
#endif
328
330
#ifndef PAL_FS_MOUNT_POINT_PRIMARY
331
#define PAL_FS_MOUNT_POINT_PRIMARY ""
332
#endif
333
335
#ifndef PAL_FS_MOUNT_POINT_SECONDARY
336
#define PAL_FS_MOUNT_POINT_SECONDARY ""
337
#endif
338
339
// Update
340
341
#ifndef PAL_UPDATE_FIRMWARE_MOUNT_POINT
342
#define PAL_UPDATE_FIRMWARE_MOUNT_POINT PAL_FS_MOUNT_POINT_PRIMARY
343
#endif
344
346
#ifndef PAL_UPDATE_FIRMWARE_DIR
347
#define PAL_UPDATE_FIRMWARE_DIR PAL_UPDATE_FIRMWARE_MOUNT_POINT "/firmware"
348
#endif
349
350
#ifndef PAL_INT_FLASH_NUM_SECTIONS
351
#define PAL_INT_FLASH_NUM_SECTIONS 0
352
#endif
353
354
#if PAL_USE_HW_TRNG
355
#ifndef PAL_NOISE_TRNG_THREAD_DELAY_MILLI_SEC
357
#define PAL_NOISE_TRNG_THREAD_DELAY_MILLI_SEC (1000 * 60) // one minute
358
#endif
359
#ifndef PAL_NOISE_TRNG_THREAD_STACK_SIZE
361
#define PAL_NOISE_TRNG_THREAD_STACK_SIZE 1536 // 1.5K
362
#endif
363
#endif
364
365
#ifndef PAL_DEVICE_KEY_DERIVATION_BACKWARD_COMPATIBILITY_CALC
366
#define PAL_DEVICE_KEY_DERIVATION_BACKWARD_COMPATIBILITY_CALC 0
367
#endif
368
373
#ifndef PAL_INTERNAL_FLASH_SECTION_1_ADDRESS
374
#define PAL_INTERNAL_FLASH_SECTION_1_ADDRESS 0
375
#endif
376
379
#ifndef PAL_INTERNAL_FLASH_SECTION_2_ADDRESS
380
#define PAL_INTERNAL_FLASH_SECTION_2_ADDRESS 0
381
#endif
382
#ifndef PAL_INTERNAL_FLASH_SECTION_1_SIZE
384
#define PAL_INTERNAL_FLASH_SECTION_1_SIZE 0
385
#endif
386
#ifndef PAL_INTERNAL_FLASH_SECTION_2_SIZE
388
#define PAL_INTERNAL_FLASH_SECTION_2_SIZE 0
389
#endif
390
391
#ifndef PAL_SIMULATOR_TEST_ENABLE
392
#define PAL_SIMULATOR_TEST_ENABLE 0
393
#endif
394
395
#if (PAL_SIMULATOR_TEST_ENABLE == 1)
396
397
#undef PAL_SIMULATE_RTOS_REBOOT
398
#define PAL_SIMULATE_RTOS_REBOOT 1
399
400
#undef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
401
#define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 1
402
404
#undef PAL_SIMULATOR_FS_RM_INSTEAD_OF_FORMAT
405
#define PAL_SIMULATOR_FS_RM_INSTEAD_OF_FORMAT 1
406
#endif //PAL_SIMULATOR_TEST_ENABLE
407
408
#ifndef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
409
#define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 0
410
#endif
411
412
#if PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
413
414
#undef PAL_USE_INTERNAL_FLASH
415
#define PAL_USE_INTERNAL_FLASH 1
416
417
#undef PAL_INT_FLASH_NUM_SECTIONS
418
#define PAL_INT_FLASH_NUM_SECTIONS 2
419
420
#ifndef PAL_SIMULATOR_SOTP_AREA_SIZE
421
#define PAL_SIMULATOR_SOTP_AREA_SIZE 4096
422
#endif
423
424
#ifndef SIMULATE_FLASH_SECTOR_SIZE
425
#define SIMULATE_FLASH_SECTOR_SIZE 4096
426
#endif
427
428
#ifndef SIMULATE_FLASH_DIR
429
#define SIMULATE_FLASH_DIR ""
430
#endif
431
432
#ifndef SIMULATE_FLASH_FILE_NAME
433
#define SIMULATE_FLASH_FILE_NAME SIMULATE_FLASH_DIR"/flashSim"
434
#endif
435
436
#ifndef SIMULATE_FLASH_PAGE_SIZE
437
#define SIMULATE_FLASH_PAGE_SIZE 8
438
#endif
439
440
#if PAL_SIMULATOR_SOTP_AREA_SIZE < 4096
441
#error Minimum Size of 4K
442
#endif
443
444
/* Note - In simulator mode all flash areas are overrided with the simulation sizes and address*/
445
446
/* \brief Size for section 1
447
*
448
* Minimum required size is 1KB and section must be consecutive sectors
449
*/
450
#undef PAL_INTERNAL_FLASH_SECTION_1_SIZE
451
#define PAL_INTERNAL_FLASH_SECTION_1_SIZE PAL_SIMULATOR_SOTP_AREA_SIZE
452
453
#undef PAL_INTERNAL_FLASH_SECTION_2_SIZE
454
458
#define PAL_INTERNAL_FLASH_SECTION_2_SIZE PAL_SIMULATOR_SOTP_AREA_SIZE
459
460
#undef PAL_INTERNAL_FLASH_SECTION_1_ADDRESS
461
#define PAL_INTERNAL_FLASH_SECTION_1_ADDRESS 0
463
464
#undef PAL_INTERNAL_FLASH_SECTION_2_ADDRESS
465
#define PAL_INTERNAL_FLASH_SECTION_2_ADDRESS PAL_INTERNAL_FLASH_SECTION_1_SIZE
467
468
#endif //PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
469
470
#define VALUE_TO_STRING(x) #x
471
#define VALUE(x) VALUE_TO_STRING(x)
472
#define VAR_NAME_VALUE(var) #var " = " VALUE(var)
473
474
#if (((!PAL_USE_INTERNAL_FLASH && (!PAL_USE_HW_ROT || !PAL_USE_HW_RTC || !PAL_USE_HW_TRNG)) \
475
|| ((PAL_INT_FLASH_NUM_SECTIONS == 1) && PAL_USE_INTERNAL_FLASH && (!PAL_USE_HW_RTC || !PAL_USE_HW_TRNG))) \
476
&& !defined MBED_CONF_MBED_CLOUD_CLIENT_EXTERNAL_SST_SUPPORT)
477
#pragma message(VAR_NAME_VALUE(PAL_USE_INTERNAL_FLASH))
478
#pragma message(VAR_NAME_VALUE(PAL_USE_HW_ROT))
479
#pragma message(VAR_NAME_VALUE(PAL_USE_HW_RTC))
480
#pragma message(VAR_NAME_VALUE(PAL_USE_HW_TRNG))
481
#pragma message(VAR_NAME_VALUE(PAL_INT_FLASH_NUM_SECTIONS))
482
#error Minimum configuration setting does not meet the requirements
483
#endif
484
485
#if (((PAL_ENABLE_PSK == 1) && (PAL_ENABLE_X509 == 1)) && !(defined(__LINUX__)))
486
#error "Please select only one option: PSK or X509"
487
#endif
488
489
#if ((PAL_ENABLE_PSK == 0) && (PAL_ENABLE_X509 == 0))
490
#error "Please select one option: PSK or X509"
491
#endif
492
493
#if ((PAL_ENABLE_PSK == 1) && (PAL_USE_SECURE_TIME == 1))
494
#error "PSK feature cannot be configured when using secure time"
495
#endif
496
498
#ifndef PAL_TRNG_COLLECT_DELAY_MILLI_SEC
499
#define PAL_TRNG_COLLECT_DELAY_MILLI_SEC 1000
500
#endif // PAL_TRNG_COLLECT_DELAY_MILLI_SEC
501
503
#ifndef IMAGE_COUNT_MAX
504
#define IMAGE_COUNT_MAX 1
505
#endif
506
507
#define PAL_NOISE_SIZE_BYTES 48
508
#define PAL_NOISE_SIZE_BITS (PAL_NOISE_SIZE_BYTES * CHAR_BIT)
509
#define PAL_NOISE_BUFFER_LEN (PAL_NOISE_SIZE_BYTES / sizeof(int32_t))
510
511
// SSL session resume is enabled by default
512
#ifndef PAL_USE_SSL_SESSION_RESUME
513
#define PAL_USE_SSL_SESSION_RESUME 1
514
#endif
515
516
// Sanity check for using static memory buffer with mbedtls.
517
#ifdef PAL_USE_STATIC_MEMBUF_FOR_MBEDTLS
518
519
#if !defined(PAL_STATIC_MEMBUF_SIZE_FOR_MBEDTLS)
520
#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."
521
#endif
522
523
#endif // #ifdef PAL_USE_STATIC_MEMBUF_FOR_MBEDTLS
524
525
#endif //_PAL_COFIGURATION_H