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-2020 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__) || defined(__LINUX__)
63
#include "Linux_default.h"
64
#elif defined(__FREERTOS__)
65
#include "FreeRTOS_default.h"
66
#elif defined(__NXP_FREERTOS__)
67
#include "NXP_default.h"
68
#elif defined(__RENESAS_EK_RA6M3__)
69
#include "Renesas/Renesas_default.h"
70
#elif defined(__RENESAS_RX65N_CK__)
71
#include "Renesas/Renesas_RX65N-CK_default.h"
72
#elif defined(__MBED__)
73
#include "mbedOS_default.h"
74
#elif defined(__SXOS__)
75
#include "sxos_default.h"
76
#elif defined(__RTX)
77
#include "RTX_MW_default.h"
78
#else
79
#error "Please specify the platform PAL_PLATFORM_DEFINED_CONFIGURATION"
80
#endif
81
86
#ifndef PAL_USE_HW_ROT
87
#define PAL_USE_HW_ROT 1
88
#endif
89
94
#ifndef PAL_USE_HW_RTC
95
#define PAL_USE_HW_RTC 1
96
#endif
97
102
#ifndef PAL_USE_HW_TRNG
103
#define PAL_USE_HW_TRNG 1
104
#endif
105
110
#ifndef PAL_USE_SECURE_TIME
111
#define PAL_USE_SECURE_TIME 1
112
#endif
113
114
#ifndef PAL_SIMULATOR_FILE_SYSTEM_OVER_RAM
115
#define PAL_SIMULATOR_FILE_SYSTEM_OVER_RAM 0
116
#endif
117
118
#ifndef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
119
#define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 0
120
#endif
121
122
#ifndef PAL_USE_INTERNAL_FLASH
123
#define PAL_USE_INTERNAL_FLASH 0
124
#endif
125
126
/*
127
* Network configuration
128
*/
129
// PAL configuration options
130
#ifndef PAL_NET_TCP_AND_TLS_SUPPORT
131
#define PAL_NET_TCP_AND_TLS_SUPPORT true
132
#endif
133
134
#ifndef PAL_NET_DNS_SUPPORT
135
#define PAL_NET_DNS_SUPPORT true
136
#endif
137
138
#if (PAL_NET_DNS_SUPPORT == true) && !(defined(PAL_DNS_API_VERSION))
139
#define PAL_DNS_API_VERSION 0
140
#endif
141
142
#ifndef PAL_NET_SERVER_SOCKET_API
143
#define PAL_NET_SERVER_SOCKET_API true
144
#endif
145
146
#ifndef PAL_SUPPORT_IP_V4
147
#define PAL_SUPPORT_IP_V4 1
148
#endif
149
#ifndef PAL_SUPPORT_IP_V6
150
#define PAL_SUPPORT_IP_V6 1
151
#endif
152
153
//values for PAL_NET_DNS_IP_SUPPORT
154
#define PAL_NET_DNS_ANY 0
155
#define PAL_NET_DNS_IPV4_ONLY 2
156
#define PAL_NET_DNS_IPV6_ONLY 4
157
158
#ifndef PAL_NET_DNS_IP_SUPPORT
159
#if (PAL_SUPPORT_IP_V6 == 1) && (PAL_SUPPORT_IP_V4 == 1)
160
#define PAL_NET_DNS_IP_SUPPORT 0
161
#elif (PAL_SUPPORT_IP_V6 == 1)
162
#define PAL_NET_DNS_IP_SUPPORT 4
163
#else
164
#define PAL_NET_DNS_IP_SUPPORT 2
165
#endif
166
#endif
167
169
#ifndef PAL_MAX_SUPORTED_NET_INTERFACES
170
#define PAL_MAX_SUPORTED_NET_INTERFACES 1
171
#endif
172
174
#ifndef PAL_NET_ASYNC_DNS_THREAD_STACK_SIZE
175
#define PAL_NET_ASYNC_DNS_THREAD_STACK_SIZE (1024 * 2)
176
#endif
177
179
#ifndef PAL_CLEANUP_ON_INIT_FAILURE
180
#define PAL_CLEANUP_ON_INIT_FAILURE true
181
#endif
182
183
/*
184
* RTOS configuration
185
*/
186
192
#ifndef PAL_THREAD_SAFETY
193
#define PAL_THREAD_SAFETY 1
194
#endif
195
200
#ifndef PAL_RTOS_THREAD_CLEANUP_TIMER_MILISEC
201
#define PAL_RTOS_THREAD_CLEANUP_TIMER_MILISEC 200
202
#endif
203
205
#ifndef PAL_INITIAL_RANDOM_SIZE
206
#define PAL_INITIAL_RANDOM_SIZE 48
207
#endif
208
209
#ifndef PAL_RTOS_WAIT_FOREVER
210
#define PAL_RTOS_WAIT_FOREVER UINT_MAX
211
#endif
212
213
/*
214
* TLS configuration
215
*/
216
218
#ifndef PAL_MAX_ALLOWED_CIPHER_SUITES
219
#define PAL_MAX_ALLOWED_CIPHER_SUITES 1
220
#endif
221
223
225
#ifndef PAL_TLS_DEBUG_THRESHOLD
226
#define PAL_TLS_DEBUG_THRESHOLD 5
227
#endif
228
230
#ifndef PAL_CERT_ID_SIZE
231
#define PAL_CERT_ID_SIZE 33
232
#endif
233
234
#ifndef PAL_ENABLE_PSK
235
#define PAL_ENABLE_PSK 0
236
#endif
237
238
#ifndef PAL_ENABLE_X509
239
#define PAL_ENABLE_X509 1
240
#endif
241
242
// Defines the cipher suites for TLS. Only one cipher suite per device available.
243
#define PAL_TLS_PSK_WITH_AES_128_CCM_8_SUITE 0x01
244
#define PAL_TLS_PSK_WITH_AES_256_CCM_8_SUITE 0x02
245
#define PAL_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8_SUITE 0x04
246
#define PAL_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_SUITE 0x08
247
#define PAL_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_SUITE 0x10
248
#define PAL_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256_SUITE 0x20
249
251
#if (PAL_ENABLE_X509 == 1)
252
#ifndef PAL_TLS_CIPHER_SUITE
253
#define PAL_TLS_CIPHER_SUITE PAL_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8_SUITE
254
#endif
255
#elif (PAL_ENABLE_PSK == 1)
256
#ifndef PAL_TLS_CIPHER_SUITE
257
#define PAL_TLS_CIPHER_SUITE PAL_TLS_PSK_WITH_AES_128_CCM_8_SUITE
258
#endif
259
#endif
260
262
#ifndef PAL_CMAC_SUPPORT
263
#define PAL_CMAC_SUPPORT 1
264
#endif //PAL_CMAC_SUPPORT
265
266
/*
267
* UPDATE configuration
268
*/
269
270
#define PAL_UPDATE_USE_FLASH 1
271
#define PAL_UPDATE_USE_FS 2
272
273
#ifndef PAL_UPDATE_IMAGE_LOCATION
274
#define PAL_UPDATE_IMAGE_LOCATION PAL_UPDATE_USE_FS
275
#endif
276
278
#ifndef PAL_CRYPTO_CERT_DATE_LENGTH
279
#define PAL_CRYPTO_CERT_DATE_LENGTH sizeof(uint64_t)
280
#endif
281
282
/*
283
* File system configuration
284
*/
285
286
292
#ifndef PAL_USE_FILESYSTEM
293
#define PAL_USE_FILESYSTEM 0
294
#endif
295
302
#ifndef PAL_NUMBER_OF_PARTITIONS
303
#define PAL_NUMBER_OF_PARTITIONS 1 // Default partitions
304
#endif
305
306
#if (PAL_NUMBER_OF_PARTITIONS > 2)
307
#error "PAL_NUMBER_OF_PARTITIONS cannot be more then 2"
308
#endif
309
315
#ifndef PAL_PRIMARY_PARTITION_PRIVATE
316
#define PAL_PRIMARY_PARTITION_PRIVATE 0
317
#endif
318
324
#ifndef PAL_SECONDARY_PARTITION_PRIVATE
325
#define PAL_SECONDARY_PARTITION_PRIVATE 0
326
#endif
327
329
#ifndef PAL_FS_MOUNT_POINT_PRIMARY
330
#define PAL_FS_MOUNT_POINT_PRIMARY ""
331
#endif
332
334
#ifndef PAL_FS_MOUNT_POINT_SECONDARY
335
#define PAL_FS_MOUNT_POINT_SECONDARY ""
336
#endif
337
338
// Update
339
340
#ifndef PAL_UPDATE_FIRMWARE_MOUNT_POINT
341
#define PAL_UPDATE_FIRMWARE_MOUNT_POINT PAL_FS_MOUNT_POINT_PRIMARY
342
#endif
343
345
#ifndef PAL_UPDATE_FIRMWARE_DIR
346
#ifdef __NANOSIMULATOR__
347
#define PAL_UPDATE_FIRMWARE_DIR "/firmware"
348
#else
349
#define PAL_UPDATE_FIRMWARE_DIR PAL_UPDATE_FIRMWARE_MOUNT_POINT "/firmware"
350
#endif
351
#endif
352
353
#ifndef PAL_INT_FLASH_NUM_SECTIONS
354
#define PAL_INT_FLASH_NUM_SECTIONS 0
355
#endif
356
357
#if PAL_USE_HW_TRNG
358
#ifndef PAL_NOISE_TRNG_THREAD_DELAY_MILLI_SEC
360
#define PAL_NOISE_TRNG_THREAD_DELAY_MILLI_SEC (1000 * 60) // one minute
361
#endif
362
#ifndef PAL_NOISE_TRNG_THREAD_STACK_SIZE
364
#define PAL_NOISE_TRNG_THREAD_STACK_SIZE 1536 // 1.5K
365
#endif
366
#endif
367
368
#ifndef PAL_DEVICE_KEY_DERIVATION_BACKWARD_COMPATIBILITY_CALC
369
#define PAL_DEVICE_KEY_DERIVATION_BACKWARD_COMPATIBILITY_CALC 0
370
#endif
371
376
#ifndef PAL_INTERNAL_FLASH_SECTION_1_ADDRESS
377
#define PAL_INTERNAL_FLASH_SECTION_1_ADDRESS 0
378
#endif
379
382
#ifndef PAL_INTERNAL_FLASH_SECTION_2_ADDRESS
383
#define PAL_INTERNAL_FLASH_SECTION_2_ADDRESS 0
384
#endif
385
#ifndef PAL_INTERNAL_FLASH_SECTION_1_SIZE
387
#define PAL_INTERNAL_FLASH_SECTION_1_SIZE 0
388
#endif
389
#ifndef PAL_INTERNAL_FLASH_SECTION_2_SIZE
391
#define PAL_INTERNAL_FLASH_SECTION_2_SIZE 0
392
#endif
393
394
#ifndef PAL_SIMULATOR_TEST_ENABLE
395
#define PAL_SIMULATOR_TEST_ENABLE 0
396
#endif
397
398
#if (PAL_SIMULATOR_TEST_ENABLE == 1)
399
400
#undef PAL_SIMULATE_RTOS_REBOOT
401
#define PAL_SIMULATE_RTOS_REBOOT 1
402
403
#undef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
404
#define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 1
405
407
#undef PAL_SIMULATOR_FS_RM_INSTEAD_OF_FORMAT
408
#define PAL_SIMULATOR_FS_RM_INSTEAD_OF_FORMAT 1
409
#endif //PAL_SIMULATOR_TEST_ENABLE
410
411
#ifndef PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
412
#define PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM 0
413
#endif
414
415
#if PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
416
417
#undef PAL_USE_INTERNAL_FLASH
418
#define PAL_USE_INTERNAL_FLASH 1
419
420
#undef PAL_INT_FLASH_NUM_SECTIONS
421
#define PAL_INT_FLASH_NUM_SECTIONS 2
422
423
#ifndef PAL_SIMULATOR_SOTP_AREA_SIZE
424
#define PAL_SIMULATOR_SOTP_AREA_SIZE 4096
425
#endif
426
427
#ifndef SIMULATE_FLASH_SECTOR_SIZE
428
#define SIMULATE_FLASH_SECTOR_SIZE 4096
429
#endif
430
431
#ifndef SIMULATE_FLASH_DIR
432
#define SIMULATE_FLASH_DIR ""
433
#endif
434
435
#ifndef SIMULATE_FLASH_FILE_NAME
436
#define SIMULATE_FLASH_FILE_NAME SIMULATE_FLASH_DIR"/flashSim"
437
#endif
438
439
#ifndef SIMULATE_FLASH_PAGE_SIZE
440
#define SIMULATE_FLASH_PAGE_SIZE 8
441
#endif
442
443
#if PAL_SIMULATOR_SOTP_AREA_SIZE < 4096
444
#error Minimum Size of 4K
445
#endif
446
447
/* Note - In simulator mode all flash areas are overrided with the simulation sizes and address*/
448
449
/* \brief Size for section 1
450
*
451
* Minimum required size is 1KB and section must be consecutive sectors
452
*/
453
#undef PAL_INTERNAL_FLASH_SECTION_1_SIZE
454
#define PAL_INTERNAL_FLASH_SECTION_1_SIZE PAL_SIMULATOR_SOTP_AREA_SIZE
455
456
#undef PAL_INTERNAL_FLASH_SECTION_2_SIZE
457
461
#define PAL_INTERNAL_FLASH_SECTION_2_SIZE PAL_SIMULATOR_SOTP_AREA_SIZE
462
463
#undef PAL_INTERNAL_FLASH_SECTION_1_ADDRESS
464
#define PAL_INTERNAL_FLASH_SECTION_1_ADDRESS 0
466
467
#undef PAL_INTERNAL_FLASH_SECTION_2_ADDRESS
468
#define PAL_INTERNAL_FLASH_SECTION_2_ADDRESS PAL_INTERNAL_FLASH_SECTION_1_SIZE
470
471
#endif //PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM
472
473
#define VALUE_TO_STRING(x) #x
474
#define VALUE(x) VALUE_TO_STRING(x)
475
#define VAR_NAME_VALUE(var) #var " = " VALUE(var)
476
477
#if (((!PAL_USE_INTERNAL_FLASH && (!PAL_USE_HW_ROT || !PAL_USE_HW_RTC || !PAL_USE_HW_TRNG)) \
478
|| ((PAL_INT_FLASH_NUM_SECTIONS == 1) && PAL_USE_INTERNAL_FLASH && (!PAL_USE_HW_RTC || !PAL_USE_HW_TRNG))) \
479
&& !defined MBED_CONF_MBED_CLOUD_CLIENT_EXTERNAL_SST_SUPPORT)
480
#pragma message(VAR_NAME_VALUE(PAL_USE_INTERNAL_FLASH))
481
#pragma message(VAR_NAME_VALUE(PAL_USE_HW_ROT))
482
#pragma message(VAR_NAME_VALUE(PAL_USE_HW_RTC))
483
#pragma message(VAR_NAME_VALUE(PAL_USE_HW_TRNG))
484
#pragma message(VAR_NAME_VALUE(PAL_INT_FLASH_NUM_SECTIONS))
485
#error Minimum configuration setting does not meet the requirements
486
#endif
487
488
#if (((PAL_ENABLE_PSK == 1) && (PAL_ENABLE_X509 == 1)) && !(defined(__linux__) || defined(__LINUX__)))
489
#error "Please select only one option: PSK or X509"
490
#endif
491
492
#if ((PAL_ENABLE_PSK == 0) && (PAL_ENABLE_X509 == 0))
493
#error "Please select one option: PSK or X509"
494
#endif
495
496
#if ((PAL_ENABLE_PSK == 1) && (PAL_USE_SECURE_TIME == 1))
497
#error "PSK feature cannot be configured when using secure time"
498
#endif
499
501
#ifndef PAL_TRNG_COLLECT_DELAY_MILLI_SEC
502
#define PAL_TRNG_COLLECT_DELAY_MILLI_SEC 1000
503
#endif // PAL_TRNG_COLLECT_DELAY_MILLI_SEC
504
506
#ifndef IMAGE_COUNT_MAX
507
#define IMAGE_COUNT_MAX 1
508
#endif
509
510
#define PAL_NOISE_SIZE_BYTES 48
511
#define PAL_NOISE_SIZE_BITS (PAL_NOISE_SIZE_BYTES * CHAR_BIT)
512
#define PAL_NOISE_BUFFER_LEN (PAL_NOISE_SIZE_BYTES / sizeof(int32_t))
513
514
// This requires Mbed TLS 2.19.0d1 or later.
515
#ifndef PAL_USE_SSL_SESSION_RESUME
516
#define PAL_USE_SSL_SESSION_RESUME 0
517
#endif
518
519
// Sanity check for using static memory buffer with mbedtls.
520
#ifdef PAL_USE_STATIC_MEMBUF_FOR_MBEDTLS
521
522
#if !defined(PAL_STATIC_MEMBUF_SIZE_FOR_MBEDTLS)
523
#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."
524
#endif
525
526
#endif // #ifdef PAL_USE_STATIC_MEMBUF_FOR_MBEDTLS
527
528
// For platforms that do not support dynamic fetching of network stagger (pal_getStaggerEstimate()), this default value will be used.
529
// This parameter is relevant when large number of clients is expected to connect through a single constrained backbone connection.
530
// As of now dynamic implementation exists only for Mbed OS Wi-SUN stack.
531
#ifndef PAL_DEFAULT_STAGGER_ESTIMATE
532
#define PAL_DEFAULT_STAGGER_ESTIMATE 0
533
#endif
534
535
// For platforms that do not support dynamic fetching of network stagger (pal_getRttEstimate()), this default value will be used.
536
// This value controls network latency related parameters and represents the expected packet round-trip total times.
537
// This value is used to control client retransmission timers and DTLS timers.
538
#ifndef PAL_DEFAULT_RTT_ESTIMATE
539
#define PAL_DEFAULT_RTT_ESTIMATE 10
540
#endif
541
542
#if PAL_DEFAULT_RTT_ESTIMATE < 1
543
#error "PAL_DEFAULT_RTT_ESTIMATE must be at least 1"
544
#endif
545
546
#endif //_PAL_COFIGURATION_H