Skip to content

Commit

Permalink
MIMXRT1050-EVKB support (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwinter authored Oct 14, 2020
1 parent 05a9f68 commit 5f257ad
Show file tree
Hide file tree
Showing 416 changed files with 480,471 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/MIMXRT1050-EVKB.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: MIMXRT1050-EVKB

on:
push:
branches: [ master ]
paths:
- 'core/**'
- 'cmake/**'
- 'NXP/MIMXRT1050-EVKB/**'
pull_request:
branches: [ master ]
paths:
- 'core/**'
- 'cmake/**'
- 'NXP/MIMXRT1050-EVKB/**'

defaults:
run:
working-directory: NXP/MIMXRT1050-EVKB

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive

# Get the ARM GCC compiler
- name: Install tools for linux
if: matrix.os == 'ubuntu-latest'
run: sudo apt install gcc-arm-none-eabi cmake

- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@v1

- name: Build project
run: |
cmake -Bbuild -GNinja -DCMAKE_TOOLCHAIN_FILE="../../cmake/arm-gcc-cortex-m7.cmake"
cmake --build build
28 changes: 28 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,34 @@ THE SOFTWARE.
RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.

------------------------------------------------------------------------------
* NXP: EVKB-MIMXRT1050

Copyright (c) 2019 NXP
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

------------------------------------------------------------------------------
* NXP: EVK-MIMXRT1060

Expand Down
6 changes: 6 additions & 0 deletions NXP/MIMXRT1050-EVKB/.vscode/cmake-kits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"name": "ARM GCC Cortex",
"toolchainFile": "${workspaceFolder}/../../cmake/arm-gcc-cortex-m7.cmake"
}
]
34 changes: 34 additions & 0 deletions NXP/MIMXRT1050-EVKB/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "NXP: Local J-Link",
"type": "cortex-debug",
"request": "launch",
"servertype":"jlink",
"runToMain": true,
"executable": "${workspaceFolder}/build/app/mimxrt1050_azure_iot.elf",
"device": "MIMXRT1052xxx6A",
"svdFile": "${workspaceFolder}/.vscode/MIMXRT1052.svd",
},
{
"name": "NXP: Remote",
"type": "cortex-debug",
"executable": "${workspaceFolder}/build/app/mimxrt1050_azure_iot.elf",
"request": "launch",
"servertype": "external",
"gdbTarget": "${input:device.host}",
"runToMain": true,
"device": "MIMXRT1052xxx6A",
"svdFile": "${workspaceFolder}/.vscode/MIMXRT1052.svd",
}
],
"inputs": [
{
"id": "device.host",
"type": "promptString",
"default": "localhost:2331",
"description": "The local hostname with port for GDB to connect to"
}
]
}
24 changes: 24 additions & 0 deletions NXP/MIMXRT1050-EVKB/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
set(CMAKE_C_STANDARD 99)

set(GSG_BASE_DIR ${CMAKE_SOURCE_DIR}/../..)
set(CORE_SRC_DIR ${GSG_BASE_DIR}/core/src)
set(CORE_LIB_DIR ${GSG_BASE_DIR}/core/lib)

# Set the toolchain if not defined
if(NOT CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "${GSG_BASE_DIR}/cmake/arm-gcc-cortex-m7.cmake")
endif()

include(${GSG_BASE_DIR}/cmake/utilities.cmake)

# Define the Project
project(mimxrt1050_azure_iot C ASM)

add_subdirectory(${CORE_SRC_DIR} core_src)
add_subdirectory(lib)
add_subdirectory(app)

42 changes: 42 additions & 0 deletions NXP/MIMXRT1050-EVKB/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

set(LINKER_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/startup/MIMXRT1052xxxxx_flexspi_nor.ld")

set(SOURCES
startup/startup_MIMXRT1052.S
startup/tx_initialize_low_level.S

azure_config.h
nx_client.c
mqtt.c
board_init.c
console.c
main.c
)

add_executable(${PROJECT_NAME} ${SOURCES})

target_link_libraries(${PROJECT_NAME}
PUBLIC
azrtos::threadx
azrtos::netxduo

app_common
jsmn
MIMXRT1050-evk
netx_driver
)

target_link_options(${PROJECT_NAME}
PRIVATE
-T${LINKER_SCRIPT} -Wl,-Map=${PROJECT_NAME}.map)

set_target_properties(${PROJECT_NAME}
PROPERTIES
LINK_DEPENDS ${LINKER_SCRIPT}
SUFFIX ".elf"
)

create_bin_output(${PROJECT_NAME})
firmware_size(${PROJECT_NAME})
33 changes: 33 additions & 0 deletions NXP/MIMXRT1050-EVKB/app/azure_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Copyright (c) Microsoft Corporation.
Licensed under the MIT License. */

#ifndef _AZURE_CONFIG_H
#define _AZURE_CONFIG_H

// ----------------------------------------------------------------------------
// Azure IoT Hub Connection Transport
// Define this to use MQTT, else Azure RTOS SDK for Azure IoT
// ----------------------------------------------------------------------------
#define ENABLE_MQTT

// ----------------------------------------------------------------------------
// Azure IoT Dynamic Provisioning Service
// Define this to use the DPS service, otherwise direct IoT Hub
// ----------------------------------------------------------------------------
//#define ENABLE_DPS

// ----------------------------------------------------------------------------
// Azure IoT Hub config
// ----------------------------------------------------------------------------
#define IOT_HUB_HOSTNAME ""
#define IOT_DEVICE_ID ""
#define IOT_PRIMARY_KEY ""

// ----------------------------------------------------------------------------
// Azure IoT DPS config
// ----------------------------------------------------------------------------
#define IOT_DPS_ENDPOINT "global.azure-devices-provisioning.net"
#define IOT_DPS_ID_SCOPE ""
#define IOT_DPS_REGISTRATION_ID ""

#endif // _AZURE_CONFIG_H
15 changes: 15 additions & 0 deletions NXP/MIMXRT1050-EVKB/app/board_init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Copyright (c) Microsoft Corporation.
Licensed under the MIT License. */

#include "board_init.h"

#include "board.h"
#include "pin_mux.h"

void board_init()
{
BOARD_ConfigMPU();
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
}
11 changes: 11 additions & 0 deletions NXP/MIMXRT1050-EVKB/app/board_init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Copyright (c) Microsoft Corporation.
Licensed under the MIT License. */

#ifndef _BOARD_INIT_H
#define _BOARD_INIT_H

#include "nx_api.h"

void board_init();

#endif // _BOARD_INIT_H
27 changes: 27 additions & 0 deletions NXP/MIMXRT1050-EVKB/app/console.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright (c) Microsoft Corporation.
Licensed under the MIT License. */

#include "fsl_debug_console.h"

int _read(int file, char *ptr, int len);
int _write(int file, char *ptr, int len);

int _read(int file, char *ptr, int len)
{
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
*ptr++ = GETCHAR();
}
return len;
}

int _write(int file, char *ptr, int len)
{
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
PUTCHAR(*ptr++);
}
return len;
}
96 changes: 96 additions & 0 deletions NXP/MIMXRT1050-EVKB/app/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Copyright (c) Microsoft Corporation.
Licensed under the MIT License. */

#include <stdio.h>
#include <time.h>

#include "nx_driver_imxrt10xx.h"
#include "tx_api.h"

#include "board_init.h"
#include "networking.h"
#include "sntp_client.h"

#include "mqtt.h"
#include "nx_client.h"

#include "azure_config.h"

#define AZURE_THREAD_STACK_SIZE 4096
#define AZURE_THREAD_PRIORITY 4

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

void azure_thread_entry(ULONG parameter);
void tx_application_define(void* first_unused_memory);

void azure_thread_entry(ULONG parameter)
{
UINT status;

printf("\r\nStarting Azure thread\r\n\r\n");

// Initialize the network
if (!network_init(nx_driver_imx))
{
printf("Failed to initialize the network\r\n");
return;
}

// Start the SNTP client
status = sntp_start();
if (status != NX_SUCCESS)
{
printf("Failed to start the SNTP client (0x%02x)\r\n", status);
return;
}

// Wait for an SNTP sync
status = sntp_sync_wait();
if (status != NX_SUCCESS)
{
printf("Failed to start sync SNTP time (0x%02x)\r\n", status);
return;
}

#ifdef ENABLE_MQTT
if ((status = azure_iot_mqtt_entry(&nx_ip, &nx_pool, &nx_dns_client, sntp_time_get)))
#else
if ((status = azure_iot_nx_client_entry(&nx_ip, &nx_pool, &nx_dns_client, sntp_time)))
#endif
{
printf("Failed to run Azure IoT (0x%04x)\r\n", status);
return;
}
}

void tx_application_define(void* first_unused_memory)
{
// Initialise the board
board_init();

// Create Azure SDK thread.
UINT status = tx_thread_create(&azure_thread,
"Azure Thread",
azure_thread_entry,
0,
azure_thread_stack,
AZURE_THREAD_STACK_SIZE,
AZURE_THREAD_PRIORITY,
AZURE_THREAD_PRIORITY,
TX_NO_TIME_SLICE,
TX_AUTO_START);

if (status != TX_SUCCESS)
{
printf("Azure IoT application failed, please restart\r\n");
}
}

int main(void)
{
tx_kernel_enter();

return 0;
}
Loading

0 comments on commit 5f257ad

Please sign in to comment.