Skip to content

Commit

Permalink
Initial Draft for TLS Hello Server with Zephyr
Browse files Browse the repository at this point in the history
  • Loading branch information
night1rider committed Jun 18, 2024
1 parent 56d5dad commit 177a614
Show file tree
Hide file tree
Showing 32 changed files with 473 additions and 25 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/build
**/__repo__
**/.vscode

Binary file added Images/Import-Menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Plugin-Menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/wolfssl_logo_300px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 91 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,91 @@
# nxp-appcodehub
This Repo is currently a work in progress.
# wolfSSL NXP Application Code Hub

<div style="display: flex; justify-content: space-between; align-items: center;">
<a href="https://www.nxp.com">
<img src="https://mcuxpresso.nxp.com/static/icon/nxp-logo-color.svg" width="100"/>
</a>
<a href="https://www.wolfssl.com/">
<img src="Images/wolfssl_logo_300px.png" width="100"/>
</a>
</div>

This Repo is currently a work in progress and some items are placeholders.

## How to Use
The projects in this repo are intended to be used with NXP's [MCUXpresso for VS-code plugin](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc800-arm-cortex-m0-plus-/mcuxpresso-for-visual-studio-code:MCUXPRESSO-VSC?cid=wechat_iot_303216).

To use a demo project simply use the provided `setup.sh` or `setup.bat` on the given project you want to run.

### 1. Setup

#### Example
MacOS and Linux:
```
cd \path\to\nxp-appcodehub
./setup.sh dm-wolfssl-tls-hello-server-with-zephyr
```
Expected Output:
```
nxp-appcodehub % ./setup.sh dm-wolfssl-tls-hello-server-with-zephyr
Created .vscode directory in dm-wolfssl-tls-hello-server-with-zephyr.
cmake-kits.json created.
cmake-variants.json created.
launch.json created.
mcuxpresso-tools.json created.
settings.json created.
```

This creates the necassary base files that the plugin needs to import the project correctly.

### 2. Import the Project

Assuming you have the necassary software describe in the readme for the given
project, you simple need to go to the MCUXpresso plugin menu and select `Import Project` as seen in the figure below.

[<img src="Images/Plugin-Menu.png" width="200"/>](Images/Plugin-Menu.png)

Once you select `Import Project` select the path for the desired project you want to run. This will then detect the type of Project it. You will need to setup any repositories and SDK's through the plugin options.

In the figure below the imported project is of the type `Zephyr` and this means it needs to point to the Zephyr SDK and Repository. These need can be install via the `Import Repository` and the `MCUXpresso Installer` options seen in the previous menu

[<img src="Images/Import-Menu.png" width="500"/>](Images/Import-Menu.png)

Once you select the `Repository` and `SDK` you want to use with the imported project hit the `Import` button.

## Setting Up wolfSSL, wolfMQTT, and wolfSSH

Currently with the way the projects are setup you will need to add wolfSSL, wolfSSH, wolfMQTT, ect to the `west.yml` file inside the Zephyr Repo thats specified during the importation of the project.

```
manifest:
remotes:
# <your other remotes>
- name: wolfssl
url-base: https://github.com/wolfssl
- name: wolfssh
url-base: https://github.com/wolfssl
- name: wolfmqtt
url-base: https://github.com/wolfssl
projects:
# <your other projects>
- name: wolfssl
path: modules/crypto/wolfssl
revision: master
remote: wolfssl
- name: wolfssh
path: modules/lib/wolfssh
revision: master
remote: wolfssh
- name: wolfmqtt
path: modules/lib/wolfmqtt
revision: master
remote: wolfmqtt
```

For more Zephyr Specific examples look at the following README's:
- [wolfSSL](https://github.com/wolfSSL/wolfssl/tree/master/zephyr)
- [wolfSSH](https://github.com/wolfSSL/wolfshh/tree/master/zephyr)
- [wolfMQTT](https://github.com/wolfSSL/wolfmqtt/tree/master/zephyr)

Binary file removed dm-tls-hello-server-with-zephyr/Images/Setup3-3.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(MCXN947-TLS-HelloServer-wolfSSL)

# Check if the symbolic link __repo__ exists
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/__repo__")
# Create a symbolic link from __repo__ to the ZEPHYR_BASE environment variable
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink $ENV{ZEPHYR_BASE}/.. ${CMAKE_SOURCE_DIR}/__repo__
COMMAND_ECHO STDOUT
)
endif()

target_sources(app PRIVATE src/main.c)
target_include_directories(app PRIVATE src)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# NXP Application Code Hub
[<img src="https://mcuxpresso.nxp.com/static/icon/nxp-logo-color.svg" width="100"/>](https://www.nxp.com)
# wolfSSL NXP Application Code Hub

## Zephyr RTOS TLSv1.3 Hello Server FRDM-MCXN947

<div style="display: flex; justify-content: space-between; align-items: center;">
<a href="https://www.nxp.com">
<img src="https://mcuxpresso.nxp.com/static/icon/nxp-logo-color.svg" width="100"/>
</a>
<a href="https://www.wolfssl.com/">
<img src="Images/wolfssl_logo_300px.png" width="100"/>
</a>
</div>

## wolfSSL TLSv1.3 Hello Server using Zephyr RTOS

This demo demostrate capabilities of new FRDM-MCXN947.
There has some variants that are divided on branches in [Application Code Hub](https://github.com/nxp-appcodehub)

### Demo
Creating a simple server using the Zephyr RTOS and wolfSSL to utilize the networking capabilities of the FRDM-MCXN947 through its ethernet port.
Expand All @@ -20,9 +28,10 @@ Creating a simple server using the Zephyr RTOS and wolfSSL to utilize the networ
3. [Setup](#step3)
4. [Verification](#step4)
5. [Project Options](#step5)
6. [FAQs](#step6)
7. [Support](#step7)
8. [Release Notes](#step8)
6. [Project Flow Chart](#step6)
7. [FAQs](#step7)
8. [Support](#step8)
9. [Release Notes](#step9)

## 1. Software<a name="step1"></a>
- [MCUXpresso for VScode 1.5.61 or newer](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc800-arm-cortex-m0-plus-/mcuxpresso-for-visual-studio-code:MCUXPRESSO-VSC?cid=wechat_iot_303216)
Expand Down Expand Up @@ -58,18 +67,13 @@ Creating a simple server using the Zephyr RTOS and wolfSSL to utilize the networ

## 3. Setup<a name="step3"></a>

### 3.1 Step 1
1. Open the MCUXpresso in VS Code.

[<img src="Images/Setup3-1.png" width="600"/>](Images/Setup3-1.png)
### 3.1 Import the Project and build
1. Follow section 1: `Setup` in the top level [README](../README.md)
2. Under the "Projects" tab, right click the project and choose "build selected", this should result in no errors.

2. Under the "QuickStart Panel" Tab select "Application Code Hub". Then search for this example, and select the folder you want to download it to.
[<img src="Images/Setup3-3.png" width="300"/>](Images/Setup3-3.png)

[<img src="Images/Setup3-2.png" width="600"/>](Images/Setup3-2.png)

3. Under the "Projects" tab, right click the project and choose "build selected", this should result in no errors

[<img src="Images/Setup3-3.png" width="600"/>](Images/Setup3-3.png)
The project should be called `dm-wolfssl-tls-hello-server-with-zephyr`.


### 3.2 Connect hardware
Expand Down Expand Up @@ -187,10 +191,38 @@ If you want to change the port from the default `11111`

[<img src="Images/ProjectOptions5-3-4.png" width="600"/>](Images/ProjectOptions5-3-4.png)

## 6. FAQs<a name="step6"></a>

## 6. Project Flowchart<a name="step9"></a>
### Overview

```mermaid
flowchart TD
A[Start Program] --> B[Print Start Message]
B --> C{Start Network}
C -->|Success| D{Start Server}
C -->|Failure| E[Exit with Error]
D -->|Success| F[Run Server Loop]
D -->|Failure| G[Exit with Error]
F --> H{Accept Client Connections}
H -->|Success| I[Handle Client]
H -->|Failure| J[Exit with Error]
I --> K{Read Client Data}
K -->|Success| L[Process Data]
K -->|Failure| M[Exit with Error]
L --> N{Check for Shutdown}
N -->|Yes| O[Shutdown Server]
N -->|No| P[Send Reply to Client]
P --> Q[Close Client Connection]
Q --> H
O --> Q
```



## 7. FAQs<a name="step7"></a>
No FAQs have been identified for this project.

## 7. Support<a name="step7"></a>
## 8. Support<a name="step8"></a>

#### Project Metadata
<!----- Boards ----->
Expand All @@ -211,7 +243,7 @@ Questions regarding the content/correctness of this example can be entered as Is


## 8. Release Notes<a name="step6"></a>
## 9. Release Notes<a name="step9"></a>
| Version | Description / Update | Date |
|:-------:|------------------------------------------------|----------------------------:|
| 1.0 | Initial release on Application Code Hub | TBD|
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

# Enable UART console and shell for testing memfault
CONFIG_UART_CONSOLE=y
CONFIG_COMPILER_OPT="-Werror"

# Clock for time()
CONFIG_CLOCK_CONTROL=y
Expand All @@ -11,7 +10,7 @@ CONFIG_POSIX_CLOCK=y
CONFIG_LOG=y
CONFIG_LOG_PRINTK=n

CONFIG_MAIN_STACK_SIZE=4096
CONFIG_MAIN_STACK_SIZE=32768

CONFIG_ASSERT=y

Expand Down Expand Up @@ -44,4 +43,7 @@ CONFIG_TEST_RANDOM_GENERATOR=y

#ETHERNET
CONFIG_ETH_NXP_ENET_QOS=y
CONFIG_ETH_NXP_ENET_QOS_MAC=y
CONFIG_ETH_NXP_ENET_QOS_MAC=y

# Needed for threading
CONFIG_PTHREAD_IPC=y
File renamed without changes.
File renamed without changes.
140 changes: 140 additions & 0 deletions setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
@echo off
if "%~1"=="" (
echo Usage: %0 [subfolder]
echo Please specify a subfolder path.
pause
exit /b
)

set "subfolder=%~1"
set "baseDir=%~dp0"
set "targetDir=%baseDir%\%subfolder%\.vscode"

if not exist "%baseDir%\%subfolder%\" (
echo The specified subfolder does not exist in the base directory.
pause
exit /b
)

if exist "%targetDir%" (
echo Folder "%targetDir%" already exists.
) else (
mkdir "%targetDir%"
echo .vscode folder created at "%targetDir%"
)

rem Create cmake-kits.json
echo Creating cmake-kits.json...
> "%targetDir%\cmake-kits.json" (
echo [
echo {
echo "name": "Zephyr build tool",
echo "environmentVariables": {
echo "ZEPHYR_BASE": "",
echo "ZEPHYR_SDK_INSTALL_DIR": ""
echo },
echo "cmakeSettings": {
echo "BOARD": "frdm_mcxn947/mcxn947/cpu0"
echo },
echo "keep": true
echo }
echo ]
)
echo cmake-kits.json created.

rem Create cmake-variants.json
echo Creating cmake-variants.json...
> "%targetDir%\cmake-variants.json" (
echo {
echo "build_type": {
echo "default": "debug",
echo "choices": {
echo "debug": {
echo "short": "debug",
echo "buildType": "debug"
echo },
echo "release": {
echo "short": "release",
echo "buildType": "release"
echo }
echo }
echo }
echo }
)
echo cmake-variants.json created.

rem Create launch.json
echo Creating launch.json...
> "%targetDir%\launch.json" (
echo {
echo "configurations": [
echo {
echo "type": "cppdbg",
echo "name": "Debug project configuration",
echo "request": "launch",
echo "cwd": "${workspaceRoot}",
echo "MIMode": "gdb",
echo "setupCommands": [
echo {"text": "set remotetimeout 600"},
echo {"text": "set debug-file-directory"}
echo ],
echo "program": "",
echo "miDebuggerServerAddress": "",
echo "variables": {
echo "mcuxStopAtSymbol": "main",
echo "mcuxSerialNumber": "",
echo "mcuxAttach": "false",
echo "mcuxRemoteProbeType": ""
echo },
echo "logging": {
echo "engineLogging": false
echo }
echo }
echo ]
echo }
)
echo launch.json created.

rem Create mcuxpresso-tools.json
echo Creating mcuxpresso-tools.json...
> "%targetDir%\mcuxpresso-tools.json" (
echo {
echo "version": "1.1",
echo "toolchainPath": "",
echo "toolchainVersion": "",
echo "linkedProjects": [],
echo "trustZoneType": "none",
echo "multicoreType": "none",
echo "debug": {
echo "linkserver": {},
echo "pemicro": {},
echo "segger": {}
echo },
echo "projectType": "zephyr-workspace",
echo "sdk": {
echo "boardId": "frdm_mcxn947/mcxn947/cpu0",
echo "version": "",
echo "path": ""
echo }
echo }
)
echo mcuxpresso-tools.json created.

rem Create settings.json
echo Creating settings.json...
> "%targetDir%\settings.json" (
echo {
echo "cmake.configureOnOpen": false,
echo "C_Cpp.errorSquiggles": "disabled",
echo "cmake.preferredGenerators": [
echo "Ninja",
echo "Unix Makefiles",
echo "MinGW Makefiles"
echo ],
echo "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
echo "cmake.sourceDirectory": "${workspaceFolder}"
echo }
)
echo settings.json created.

pause
Loading

0 comments on commit 177a614

Please sign in to comment.