Skip to content

Commit 8bf815f

Browse files
authored
v6.0.2 update for Azure RTOS (#138)
* update tls_setup to allocation space for server certificates. * move azure_iot_preview to beta3 * disable ASC * dont use second ram bank for 475
1 parent e529328 commit 8bf815f

File tree

10 files changed

+64
-21
lines changed

10 files changed

+64
-21
lines changed

MXChip/AZ3166/app/main.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#include "tx_api.h"
77

88
#include "board_init.h"
9+
#include "cmsis_utils.h"
910
#include "screen.h"
1011
#include "sntp_client.h"
11-
#include "cmsis_utils.h"
1212

1313
#include "mqtt.h"
1414
#include "nx_client.h"
@@ -17,13 +17,13 @@
1717
#include "azure_config.h"
1818

1919
#define AZURE_THREAD_STACK_SIZE 4096
20-
#define AZURE_THREAD_PRIORITY 4
20+
#define AZURE_THREAD_PRIORITY 4
2121

2222
TX_THREAD azure_thread;
2323
ULONG azure_thread_stack[AZURE_THREAD_STACK_SIZE / sizeof(ULONG)];
2424

2525
void azure_thread_entry(ULONG parameter);
26-
void tx_application_define(void *first_unused_memory);
26+
void tx_application_define(void* first_unused_memory);
2727

2828
void azure_thread_entry(ULONG parameter)
2929
{
@@ -66,16 +66,21 @@ void azure_thread_entry(ULONG parameter)
6666
}
6767
}
6868

69-
void tx_application_define(void *first_unused_memory)
69+
void tx_application_define(void* first_unused_memory)
7070
{
7171
systick_interval_set(TX_TIMER_TICKS_PER_SECOND);
7272

7373
// Create Azure thread
74-
UINT status = tx_thread_create(&azure_thread, "Azure Thread",
75-
azure_thread_entry, 0,
76-
azure_thread_stack, AZURE_THREAD_STACK_SIZE,
77-
AZURE_THREAD_PRIORITY, AZURE_THREAD_PRIORITY,
78-
TX_NO_TIME_SLICE, TX_AUTO_START);
74+
UINT status = tx_thread_create(&azure_thread,
75+
"Azure Thread",
76+
azure_thread_entry,
77+
0,
78+
azure_thread_stack,
79+
AZURE_THREAD_STACK_SIZE,
80+
AZURE_THREAD_PRIORITY,
81+
AZURE_THREAD_PRIORITY,
82+
TX_NO_TIME_SLICE,
83+
TX_AUTO_START);
7984

8085
if (status != TX_SUCCESS)
8186
{

MXChip/AZ3166/lib/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ set(TX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/threadx/tx_user.h" CACHE STRING "Ena
1212
set(NX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/netxduo/nx_user.h" CACHE STRING "Enable NX user configuration")
1313
set(NXD_ENABLE_FILE_SERVERS OFF CACHE BOOL "Disable fileX dependency by netxduo")
1414

15+
# Disable ASC
16+
set(NX_AZURE_DISABLE_IOT_SECURITY_MODULE ON CACHE BOOL "Disable ASC")
17+
18+
# Core libraries
1519
add_subdirectory(${CORE_LIB_DIR}/threadx threadx)
1620
add_subdirectory(${CORE_LIB_DIR}/netxduo netxduo)
1721
add_subdirectory(${CORE_LIB_DIR}/azure-iot-preview/nx_cloud nx_cloud)

Microchip/ATSAME54-XPRO/lib/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ set(TX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/threadx/tx_user.h" CACHE STRING "Ena
1212
set(NX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/netxduo/nx_user.h" CACHE STRING "Enable NX user configuration")
1313
set(NXD_ENABLE_FILE_SERVERS OFF CACHE BOOL "Disable fileX dependency by netxduo")
1414

15+
# Disable ASC
16+
set(NX_AZURE_DISABLE_IOT_SECURITY_MODULE ON CACHE BOOL "Disable ASC")
17+
1518
# Core libraries
1619
add_subdirectory(${CORE_LIB_DIR}/threadx threadx)
1720
add_subdirectory(${CORE_LIB_DIR}/netxduo netxduo)

NXP/MIMXRT1060-EVK/app/mqtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ UINT azure_iot_mqtt_entry(NX_IP* ip_ptr, NX_PACKET_POOL* pool_ptr, NX_DNS* dns_p
129129
sntp_time_get,
130130
IOT_DPS_ENDPOINT,
131131
IOT_DPS_ID_SCOPE,
132-
IOT_DEVICE_ID,
132+
IOT_DPS_REGISTRATION_ID,
133133
IOT_PRIMARY_KEY,
134134
IOT_MODEL_ID);
135135
#else

NXP/MIMXRT1060-EVK/lib/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ set(TX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/threadx/tx_user.h" CACHE STRING "Ena
1212
set(NX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/netxduo/nx_user.h" CACHE STRING "Enable NX user configuration")
1313
set(NXD_ENABLE_FILE_SERVERS OFF CACHE BOOL "Disable fileX dependency by netxduo")
1414

15-
# Azure RTOS
15+
# Disable ASC
16+
set(NX_AZURE_DISABLE_IOT_SECURITY_MODULE ON CACHE BOOL "Disable ASC")
17+
18+
# Core libraries
1619
add_subdirectory(${CORE_LIB_DIR}/threadx threadx)
1720
add_subdirectory(${CORE_LIB_DIR}/netxduo netxduo)
1821
add_subdirectory(${CORE_LIB_DIR}/azure-iot-preview/nx_cloud nx_cloud)

STMicroelectronics/STM32L4_L4+/app/startup/STM32L475VGTx_FLASH.ld

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ ENTRY(Reset_Handler)
3636
_estack = 0x20018000; /* end of RAM */
3737

3838
/* Generate a link error if heap and stack don't fit into RAM */
39-
_Min_Heap_Size = 0x7000; /* required amount of heap */
40-
_Min_Stack_Size = 0x1000; /* required amount of stack */
39+
_Min_Heap_Size = 0x400; /* required amount of heap */
40+
_Min_Stack_Size = 0x800; /* required amount of stack */
4141

4242
/* Set the RAM segment used end for threadx */
4343
__RAM_segment_used_end__ = 0;
@@ -170,9 +170,7 @@ SECTIONS
170170
. = . + _Min_Heap_Size;
171171
. = . + _Min_Stack_Size;
172172
. = ALIGN(8);
173-
} >RAM2
174-
175-
173+
} >RAM
176174

177175
/* Remove information from the standard libraries */
178176
/DISCARD/ :

STMicroelectronics/STM32L4_L4+/lib/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ set(TX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/threadx/tx_user.h" CACHE STRING "Ena
1212
set(NX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/netxduo/nx_user.h" CACHE STRING "Enable NX user configuration")
1313
set(NXD_ENABLE_FILE_SERVERS OFF CACHE BOOL "Disable fileX dependency by netxduo")
1414

15+
# Disable ASC
16+
set(NX_AZURE_DISABLE_IOT_SECURITY_MODULE ON CACHE BOOL "Disable ASC")
17+
18+
# Core libraries
1519
add_subdirectory(${CORE_LIB_DIR}/threadx threadx)
1620
add_subdirectory(${CORE_LIB_DIR}/azure-iot-preview/nx_cloud nx_cloud)
1721
add_subdirectory(${CORE_LIB_DIR}/azure-iot-preview/azure_iot azure_iot)

core/lib/azure-iot-preview

core/src/azure_iot_mqtt/azure_iot_mqtt.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,27 @@ UINT tls_setup(NXD_MQTT_CLIENT* client,
103103
sizeof(azure_iot_mqtt->tls_metadata_buffer));
104104
if (status != NX_SUCCESS)
105105
{
106-
printf("Failed to create TLS session status: %d\r\n", status);
106+
printf("Failed to create TLS session status (0x%04x)\r\n", status);
107+
return status;
108+
}
109+
110+
status = nx_secure_tls_remote_certificate_allocate(tls_session,
111+
&azure_iot_mqtt->mqtt_remote_certificate,
112+
azure_iot_mqtt->mqtt_remote_cert_buffer,
113+
sizeof(azure_iot_mqtt->mqtt_remote_cert_buffer));
114+
if (status != NX_SUCCESS)
115+
{
116+
printf("Failed to create remote certificate buffer (0x%04x)\r\n", status);
117+
return status;
118+
}
119+
120+
status = nx_secure_tls_remote_certificate_allocate(tls_session,
121+
&azure_iot_mqtt->mqtt_remote_issuer,
122+
azure_iot_mqtt->mqtt_remote_issuer_buffer,
123+
sizeof(azure_iot_mqtt->mqtt_remote_issuer_buffer));
124+
if (status != NX_SUCCESS)
125+
{
126+
printf("Failed to create remote issuer buffer (0x%04x)\r\n", status);
107127
return status;
108128
}
109129

@@ -118,14 +138,14 @@ UINT tls_setup(NXD_MQTT_CLIENT* client,
118138
NX_SECURE_X509_KEY_TYPE_NONE);
119139
if (status != NX_SUCCESS)
120140
{
121-
printf("Unable to initialize CA certificate (0x%02x)\r\n", status);
141+
printf("Unable to initialize CA certificate (0x%04x)\r\n", status);
122142
return status;
123143
}
124144

125145
status = nx_secure_tls_trusted_certificate_add(tls_session, trusted_cert);
126146
if (status != NX_SUCCESS)
127147
{
128-
printf("Unable to add CA certificate to trusted store (0x%02x)\r\n", status);
148+
printf("Unable to add CA certificate to trusted store (0x%04x)\r\n", status);
129149
return status;
130150
}
131151

core/src/azure_iot_mqtt/azure_iot_mqtt.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
#define AZURE_IOT_MQTT_DIRECT_COMMAND_RID_SIZE 6
2424

2525
#define AZURE_IOT_MQTT_CLIENT_STACK_SIZE 4096
26+
#define AZURE_IOT_MQTT_CERT_BUFFER_SIZE 4096
2627

27-
#define TLS_PACKET_BUFFER (5 * 1024)
28+
#define TLS_PACKET_BUFFER 4096
2829

2930
#define MQTT_QOS_0 0 // QoS 0 - Deliver at most once
3031
#define MQTT_QOS_1 1 // QoS 1 - Deliver at least once
@@ -77,6 +78,11 @@ struct AZURE_IOT_MQTT_STRUCT
7778
ULONG tls_metadata_buffer[NX_AZURE_IOT_TLS_METADATA_BUFFER_SIZE / sizeof(ULONG)];
7879
UCHAR tls_packet_buffer[TLS_PACKET_BUFFER];
7980

81+
NX_SECURE_X509_CERT mqtt_remote_certificate;
82+
NX_SECURE_X509_CERT mqtt_remote_issuer;
83+
UCHAR mqtt_remote_cert_buffer[AZURE_IOT_MQTT_CERT_BUFFER_SIZE];
84+
UCHAR mqtt_remote_issuer_buffer[AZURE_IOT_MQTT_CERT_BUFFER_SIZE];
85+
8086
func_ptr_direct_method cb_ptr_mqtt_invoke_direct_method;
8187
func_ptr_c2d_message cb_ptr_mqtt_c2d_message;
8288
func_ptr_device_twin_desired_prop cb_ptr_mqtt_device_twin_desired_prop_callback;

0 commit comments

Comments
 (0)