Skip to content

Commit 5f257ad

Browse files
authored
MIMXRT1050-EVKB support (eclipse-threadx#152)
1 parent 05a9f68 commit 5f257ad

File tree

416 files changed

+480471
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

416 files changed

+480471
-0
lines changed

.github/workflows/MIMXRT1050-EVKB.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: MIMXRT1050-EVKB
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- 'core/**'
8+
- 'cmake/**'
9+
- 'NXP/MIMXRT1050-EVKB/**'
10+
pull_request:
11+
branches: [ master ]
12+
paths:
13+
- 'core/**'
14+
- 'cmake/**'
15+
- 'NXP/MIMXRT1050-EVKB/**'
16+
17+
defaults:
18+
run:
19+
working-directory: NXP/MIMXRT1050-EVKB
20+
21+
jobs:
22+
build:
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
matrix:
26+
os: [ubuntu-latest, windows-latest]
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v2
31+
with:
32+
submodules: recursive
33+
34+
# Get the ARM GCC compiler
35+
- name: Install tools for linux
36+
if: matrix.os == 'ubuntu-latest'
37+
run: sudo apt install gcc-arm-none-eabi cmake
38+
39+
- name: Install Ninja
40+
uses: seanmiddleditch/gha-setup-ninja@v1
41+
42+
- name: Build project
43+
run: |
44+
cmake -Bbuild -GNinja -DCMAKE_TOOLCHAIN_FILE="../../cmake/arm-gcc-cortex-m7.cmake"
45+
cmake --build build

NOTICE.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,34 @@ THE SOFTWARE.
528528
RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
529529
THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
530530

531+
------------------------------------------------------------------------------
532+
* NXP: EVKB-MIMXRT1050
533+
534+
Copyright (c) 2019 NXP
535+
All rights reserved.
536+
537+
Redistribution and use in source and binary forms, with or without
538+
modification, are permitted provided that the following conditions are met:
539+
* Redistributions of source code must retain the above copyright
540+
notice, this list of conditions and the following disclaimer.
541+
* Redistributions in binary form must reproduce the above copyright
542+
notice, this list of conditions and the following disclaimer in the
543+
documentation and/or other materials provided with the distribution.
544+
* Neither the name of the <organization> nor the
545+
names of its contributors may be used to endorse or promote products
546+
derived from this software without specific prior written permission.
547+
548+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
549+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
550+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
551+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
552+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
553+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
554+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
555+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
556+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
557+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
558+
531559
------------------------------------------------------------------------------
532560
* NXP: EVK-MIMXRT1060
533561

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
{
3+
"name": "ARM GCC Cortex",
4+
"toolchainFile": "${workspaceFolder}/../../cmake/arm-gcc-cortex-m7.cmake"
5+
}
6+
]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "NXP: Local J-Link",
6+
"type": "cortex-debug",
7+
"request": "launch",
8+
"servertype":"jlink",
9+
"runToMain": true,
10+
"executable": "${workspaceFolder}/build/app/mimxrt1050_azure_iot.elf",
11+
"device": "MIMXRT1052xxx6A",
12+
"svdFile": "${workspaceFolder}/.vscode/MIMXRT1052.svd",
13+
},
14+
{
15+
"name": "NXP: Remote",
16+
"type": "cortex-debug",
17+
"executable": "${workspaceFolder}/build/app/mimxrt1050_azure_iot.elf",
18+
"request": "launch",
19+
"servertype": "external",
20+
"gdbTarget": "${input:device.host}",
21+
"runToMain": true,
22+
"device": "MIMXRT1052xxx6A",
23+
"svdFile": "${workspaceFolder}/.vscode/MIMXRT1052.svd",
24+
}
25+
],
26+
"inputs": [
27+
{
28+
"id": "device.host",
29+
"type": "promptString",
30+
"default": "localhost:2331",
31+
"description": "The local hostname with port for GDB to connect to"
32+
}
33+
]
34+
}

NXP/MIMXRT1050-EVKB/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
5+
set(CMAKE_C_STANDARD 99)
6+
7+
set(GSG_BASE_DIR ${CMAKE_SOURCE_DIR}/../..)
8+
set(CORE_SRC_DIR ${GSG_BASE_DIR}/core/src)
9+
set(CORE_LIB_DIR ${GSG_BASE_DIR}/core/lib)
10+
11+
# Set the toolchain if not defined
12+
if(NOT CMAKE_TOOLCHAIN_FILE)
13+
set(CMAKE_TOOLCHAIN_FILE "${GSG_BASE_DIR}/cmake/arm-gcc-cortex-m7.cmake")
14+
endif()
15+
16+
include(${GSG_BASE_DIR}/cmake/utilities.cmake)
17+
18+
# Define the Project
19+
project(mimxrt1050_azure_iot C ASM)
20+
21+
add_subdirectory(${CORE_SRC_DIR} core_src)
22+
add_subdirectory(lib)
23+
add_subdirectory(app)
24+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
set(LINKER_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/startup/MIMXRT1052xxxxx_flexspi_nor.ld")
5+
6+
set(SOURCES
7+
startup/startup_MIMXRT1052.S
8+
startup/tx_initialize_low_level.S
9+
10+
azure_config.h
11+
nx_client.c
12+
mqtt.c
13+
board_init.c
14+
console.c
15+
main.c
16+
)
17+
18+
add_executable(${PROJECT_NAME} ${SOURCES})
19+
20+
target_link_libraries(${PROJECT_NAME}
21+
PUBLIC
22+
azrtos::threadx
23+
azrtos::netxduo
24+
25+
app_common
26+
jsmn
27+
MIMXRT1050-evk
28+
netx_driver
29+
)
30+
31+
target_link_options(${PROJECT_NAME}
32+
PRIVATE
33+
-T${LINKER_SCRIPT} -Wl,-Map=${PROJECT_NAME}.map)
34+
35+
set_target_properties(${PROJECT_NAME}
36+
PROPERTIES
37+
LINK_DEPENDS ${LINKER_SCRIPT}
38+
SUFFIX ".elf"
39+
)
40+
41+
create_bin_output(${PROJECT_NAME})
42+
firmware_size(${PROJECT_NAME})
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* Copyright (c) Microsoft Corporation.
2+
Licensed under the MIT License. */
3+
4+
#ifndef _AZURE_CONFIG_H
5+
#define _AZURE_CONFIG_H
6+
7+
// ----------------------------------------------------------------------------
8+
// Azure IoT Hub Connection Transport
9+
// Define this to use MQTT, else Azure RTOS SDK for Azure IoT
10+
// ----------------------------------------------------------------------------
11+
#define ENABLE_MQTT
12+
13+
// ----------------------------------------------------------------------------
14+
// Azure IoT Dynamic Provisioning Service
15+
// Define this to use the DPS service, otherwise direct IoT Hub
16+
// ----------------------------------------------------------------------------
17+
//#define ENABLE_DPS
18+
19+
// ----------------------------------------------------------------------------
20+
// Azure IoT Hub config
21+
// ----------------------------------------------------------------------------
22+
#define IOT_HUB_HOSTNAME ""
23+
#define IOT_DEVICE_ID ""
24+
#define IOT_PRIMARY_KEY ""
25+
26+
// ----------------------------------------------------------------------------
27+
// Azure IoT DPS config
28+
// ----------------------------------------------------------------------------
29+
#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net"
30+
#define IOT_DPS_ID_SCOPE ""
31+
#define IOT_DPS_REGISTRATION_ID ""
32+
33+
#endif // _AZURE_CONFIG_H

NXP/MIMXRT1050-EVKB/app/board_init.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* Copyright (c) Microsoft Corporation.
2+
Licensed under the MIT License. */
3+
4+
#include "board_init.h"
5+
6+
#include "board.h"
7+
#include "pin_mux.h"
8+
9+
void board_init()
10+
{
11+
BOARD_ConfigMPU();
12+
BOARD_InitPins();
13+
BOARD_BootClockRUN();
14+
BOARD_InitDebugConsole();
15+
}

NXP/MIMXRT1050-EVKB/app/board_init.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* Copyright (c) Microsoft Corporation.
2+
Licensed under the MIT License. */
3+
4+
#ifndef _BOARD_INIT_H
5+
#define _BOARD_INIT_H
6+
7+
#include "nx_api.h"
8+
9+
void board_init();
10+
11+
#endif // _BOARD_INIT_H

NXP/MIMXRT1050-EVKB/app/console.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Copyright (c) Microsoft Corporation.
2+
Licensed under the MIT License. */
3+
4+
#include "fsl_debug_console.h"
5+
6+
int _read(int file, char *ptr, int len);
7+
int _write(int file, char *ptr, int len);
8+
9+
int _read(int file, char *ptr, int len)
10+
{
11+
int DataIdx;
12+
for (DataIdx = 0; DataIdx < len; DataIdx++)
13+
{
14+
*ptr++ = GETCHAR();
15+
}
16+
return len;
17+
}
18+
19+
int _write(int file, char *ptr, int len)
20+
{
21+
int DataIdx;
22+
for (DataIdx = 0; DataIdx < len; DataIdx++)
23+
{
24+
PUTCHAR(*ptr++);
25+
}
26+
return len;
27+
}

NXP/MIMXRT1050-EVKB/app/main.c

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/* Copyright (c) Microsoft Corporation.
2+
Licensed under the MIT License. */
3+
4+
#include <stdio.h>
5+
#include <time.h>
6+
7+
#include "nx_driver_imxrt10xx.h"
8+
#include "tx_api.h"
9+
10+
#include "board_init.h"
11+
#include "networking.h"
12+
#include "sntp_client.h"
13+
14+
#include "mqtt.h"
15+
#include "nx_client.h"
16+
17+
#include "azure_config.h"
18+
19+
#define AZURE_THREAD_STACK_SIZE 4096
20+
#define AZURE_THREAD_PRIORITY 4
21+
22+
TX_THREAD azure_thread;
23+
ULONG azure_thread_stack[AZURE_THREAD_STACK_SIZE / sizeof(ULONG)];
24+
25+
void azure_thread_entry(ULONG parameter);
26+
void tx_application_define(void* first_unused_memory);
27+
28+
void azure_thread_entry(ULONG parameter)
29+
{
30+
UINT status;
31+
32+
printf("\r\nStarting Azure thread\r\n\r\n");
33+
34+
// Initialize the network
35+
if (!network_init(nx_driver_imx))
36+
{
37+
printf("Failed to initialize the network\r\n");
38+
return;
39+
}
40+
41+
// Start the SNTP client
42+
status = sntp_start();
43+
if (status != NX_SUCCESS)
44+
{
45+
printf("Failed to start the SNTP client (0x%02x)\r\n", status);
46+
return;
47+
}
48+
49+
// Wait for an SNTP sync
50+
status = sntp_sync_wait();
51+
if (status != NX_SUCCESS)
52+
{
53+
printf("Failed to start sync SNTP time (0x%02x)\r\n", status);
54+
return;
55+
}
56+
57+
#ifdef ENABLE_MQTT
58+
if ((status = azure_iot_mqtt_entry(&nx_ip, &nx_pool, &nx_dns_client, sntp_time_get)))
59+
#else
60+
if ((status = azure_iot_nx_client_entry(&nx_ip, &nx_pool, &nx_dns_client, sntp_time)))
61+
#endif
62+
{
63+
printf("Failed to run Azure IoT (0x%04x)\r\n", status);
64+
return;
65+
}
66+
}
67+
68+
void tx_application_define(void* first_unused_memory)
69+
{
70+
// Initialise the board
71+
board_init();
72+
73+
// Create Azure SDK thread.
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);
84+
85+
if (status != TX_SUCCESS)
86+
{
87+
printf("Azure IoT application failed, please restart\r\n");
88+
}
89+
}
90+
91+
int main(void)
92+
{
93+
tx_kernel_enter();
94+
95+
return 0;
96+
}

0 commit comments

Comments
 (0)