This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
forked from Atmosic/openair
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Atmosic Open Source Zephyr Applications
- Loading branch information
Showing
20 changed files
with
399 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.. _atmsdk: | ||
|
||
Atmosic Zephyr SDK | ||
######################################### | ||
|
||
Overview | ||
******** | ||
This is the top-level repository for the Atmosic SDK. It contains the west manifest for the SDK dependencies as well as applications developed by Atmosic showcasing its extreme low-power SoC solutions. | ||
|
||
Supported Platforms | ||
******************* | ||
|
||
* ATM33xx_ | ||
|
||
.. _ATM33xx: https://github.com/Atmosic/zephyr/blob/HEAD/boards/arm/atm33evk/doc/index.rst | ||
|
||
Creating a Workspace | ||
******************** | ||
|
||
To create an Atmosic SDK workspace, first follow the instructions_ from the official Zephyr documentation on setting up the tooling for your host operating system. Then use ``west init`` and ``west update`` as follows:: | ||
|
||
west init -m git@github.com:Atmosic/apps zephyrproject | ||
cd zephyrproject | ||
west update | ||
|
||
.. _instructions: https://docs.zephyrproject.org/latest/develop/getting_started/index.html | ||
|
||
Refer to the `Supported Platforms`_ documentation for details on how to build and program an application. For example, see the section on `programming and debugging an ATM33xx <https://github.com/Atmosic/zephyr/blob/HEAD/boards/arm/atm33evk/doc/index.rst#programming-and-debugging>`_ EVK. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(hci_vendor) | ||
|
||
target_sources(app PRIVATE src/main.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
.. _hci_vendor: | ||
|
||
Bluetooth: Atmosic HCI vendor sample | ||
#################################### | ||
|
||
Overview | ||
******** | ||
|
||
Expose the Zephyr Bluetooth controller support over UART to another device/CPU | ||
using the H:4 HCI transport protocol (requires HW flow control from the UART). | ||
|
||
Requirements | ||
************ | ||
|
||
* A board with BLE support | ||
|
||
Default UART settings | ||
********************* | ||
|
||
By default the controller builds use the following settings: | ||
|
||
* Baudrate: 460800 bit/s | ||
* 8 bits, no parity, 1 stop bit | ||
* Hardware Flow Control (RTS/CTS) enabled | ||
|
||
Building and Running | ||
******************** | ||
|
||
This sample is built as a Atmosic HCI vendor application. | ||
For more details about the state machine tables, please refer to the | ||
application note. | ||
|
||
Debug log | ||
********* | ||
|
||
By default, the log feature was enabled by setting prj.conf file | ||
P33 is the UART1_TX pin for output the log. 115200 is the default baud rate. | ||
Monitor the console output with a favorite terminal program. | ||
|
||
Run time enable feature of HCI_vendor | ||
******************************************** | ||
|
||
By default, the run time enable HCI vendor was disabled. The sample can be | ||
configured to enable feature: | ||
* add CONFIG_RUNTIME_EN_HCI_VENDOR=y to configuration file. | ||
* west build command with -DCONFIG_RUNTIME_EN_HCI_VENDOR=y | ||
|
||
Build and Run | ||
************* | ||
|
||
atm33evk | ||
-------- | ||
|
||
The atm33evk family of boards are based on ARM® Cortex® M33 with TrustZone | ||
support, which require a SPE to be programmed in addition to the application. | ||
DFU also requires MCUboot adding up to a total of three images to be built. | ||
MCUboot and the signed, merged application have to be programmed separately. | ||
In the case of this HID keyboard application, a fixed BLE controller image may | ||
also be needed, thereby requiring up to three images to be programmed. The | ||
default configuration uses the fixed BLE controller image. Refer to the README | ||
in modules/hal/atmosic/ATM33xx-5/drivers/ble for information on the controller | ||
images and library options. | ||
|
||
A convenient support script is provided in the Zephyr repository to build and | ||
program this application. Please refer to:: | ||
|
||
zephyr/boards/arm/atm33evk/doc/index.rst | ||
|
||
Below are the steps for building and programming this application without | ||
MCUBoot using ``west build`` and ``west flash`` directly. | ||
|
||
Shell environment setup:: | ||
|
||
APP=apps/hci_vendor | ||
BOARD=<chip> | ||
JLINK_SN=<"serial number"> | ||
SPE=modules/hal/atmosic/ATM33xx-5/examples/spe | ||
WEST_TOPDIR=$PWD | ||
|
||
Build commands: | ||
west build -p -s ${SPE} -b ${BOARD} -d build/${BOARD}/${SPE} | ||
west build -p -s ${HCI_UART} -b ${BOARD}_ns \ | ||
-d build/${BOARD}_ns/${HCI_UART} \ | ||
-- -DCONFIG_SPE_PATH=\"build/${BOARD}/${SPE}\" | ||
|
||
Program commands: | ||
west flash --skip-rebuild --verify --device=${JLINK_SN} --jlink \ | ||
-d build/${BOARD}/${SPE} --noreset | ||
west flash --skip-rebuild --verify --device=${JLINK_SN} --jlink \ | ||
-d build/${BOARD}_ns/${HCI_UART} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright (c) 2024 Atmosic | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
&uart0 { | ||
status = "okay"; | ||
current-speed = <460800>; | ||
hw-flow-control; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CONFIG_SERIAL=y | ||
CONFIG_UART_INTERRUPT_DRIVEN=y | ||
CONFIG_BT=y | ||
CONFIG_LOG=y | ||
CONFIG_LOG_BACKEND_SHOW_COLOR=n | ||
CONFIG_LOG_MODE_IMMEDIATE=y | ||
CONFIG_BT_HCI_RAW=y | ||
CONFIG_BT_HCI_RAW_H4=y | ||
CONFIG_BT_HCI_RAW_H4_ENABLE=y | ||
CONFIG_BT_HCI_RAW_CMD_EXT=y | ||
|
||
# For ATM vendor | ||
CONFIG_BT_BUF_CMD_TX_SIZE=140 | ||
CONFIG_ATM_VENDOR=y | ||
# Disable BLE driver sleep mode, so the radio won't power down and lose settings | ||
# from tools. | ||
CONFIG_ATM_BLE_DRIVER_SLEEP=n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sample: | ||
description: Atmosic HCI vendor sample | ||
name: Atmosic HCI vendor sample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
******************************************************************************* | ||
* | ||
* @file main.c | ||
* | ||
* @brief main | ||
* | ||
* Copyright (C) Atmosic 2024 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <errno.h> | ||
#include <stddef.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <zephyr/kernel.h> | ||
#include <zephyr/logging/log.h> | ||
#include "arch.h" | ||
#include "atm_vendor.h" | ||
|
||
#define LOG_HCI_VENDOR_MODULE_NAME hci_vendor | ||
LOG_MODULE_REGISTER(LOG_HCI_VENDOR_MODULE_NAME, CONFIG_ATM_LOG_DEFAULT_LEVEL); | ||
|
||
void hci_vendor_init(void) | ||
{ | ||
#ifdef CONFIG_RUNTIME_EN_HCI_VENDOR | ||
if (!atm_vendor_get_hci_vendor_en()) { | ||
atm_vendor_enter_hci_vendor_mode(); | ||
} | ||
#endif | ||
atm_vendor_init(); | ||
} | ||
|
||
int main(void) | ||
{ | ||
hci_vendor_init(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(nsc_hello_world) | ||
|
||
target_sources(app PRIVATE src/main.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.. _nsc_hello_world: | ||
|
||
NSC Hello World | ||
############### | ||
|
||
Overview | ||
******** | ||
|
||
Application demonstrating how to extend the secure processing environment with | ||
arbitrary non-secure callable functions. | ||
|
||
Building and Running | ||
******************** | ||
|
||
This sample relies on building the SPE with `CONFIG_ATM_ENABLE_NSC_EXAMPLE=y` | ||
which will compile an additional function into the SPE and provide a NS | ||
gateway for the non-secure application to call into it. | ||
|
||
Sample Output | ||
============= | ||
|
||
.. code-block:: console | ||
Hello from Secure World! atm33_evk | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONFIG_ZTEST=y | ||
CONFIG_ZTEST_NEW_API=y | ||
CONFIG_ATM_ENABLE_NSC_EXAMPLE=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sample: | ||
description: Sample demonstrating adding NS-callable functions | ||
name: NSC hello world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024 Atmosic | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/ztest.h> | ||
#include <stdio.h> | ||
#include "cust_sec_func.h" | ||
#include <stdbool.h> | ||
|
||
ZTEST(nsc_hello_world_test, test_nsc_call) | ||
{ | ||
#define BUF_SIZE 256 | ||
// make sure there is always a NULL term. | ||
char buffer[BUF_SIZE + 1] = {0}; | ||
uint32_t buffer_size = BUF_SIZE; | ||
bool ret = nsc_hello_world(&buffer[0], &buffer_size); | ||
zassert_true(ret, "Failed to execute non-secure callable function properly"); | ||
zassert_true((buffer_size == strlen(buffer)), "Bytes written does not equal string length"); | ||
printf("%.*s! %s\n", buffer_size, buffer, CONFIG_BOARD); | ||
} | ||
|
||
ZTEST_SUITE(nsc_hello_world_test, NULL, NULL, NULL, NULL, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
This directory can contain additional west manifest files. Any files | ||
in this directory will be included in the main west.yml file sorted by | ||
filename. | ||
|
||
See zephyr/example.yaml.sample for an example. | ||
|
||
For more details about how this works, see this part of the west | ||
documentation: | ||
|
||
https://docs.zephyrproject.org/latest/guides/west/manifest.html#example-2-2-downstream-with-directory-of-manifest-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(uart_passthrough) | ||
|
||
target_sources(app PRIVATE src/main.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.. _uart_passthrough: | ||
|
||
UART Passthrough | ||
################ | ||
|
||
Overview | ||
******** | ||
|
||
A simple sample that echos what is sent to UART0 over UART1 and what is sent to UART1 over UART0. | ||
|
||
For ATM33 EVK's UART1 RX is not always connected to the JLINK-OB. | ||
In order to work around this the UART1 RX pin was changed to P17, while UART1 TX was left as P27. | ||
Both were connected from the 50 pin header to an external USB to Serial board. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (c) 2024 Atmosic | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
&uart0 { | ||
status = "okay"; | ||
}; | ||
|
||
&uart1 { | ||
// This is Pin 9 on the 50 pin header | ||
rx-pin = <17>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_SERIAL=y | ||
CONFIG_UART_INTERRUPT_DRIVEN=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sample: | ||
description: UART0 to UART1 Passthrough | ||
name: UART Passthrough sample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2024 Atmosic | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/device.h> | ||
#include <zephyr/drivers/uart.h> | ||
|
||
static const struct device *const uart1_dev = DEVICE_DT_GET(DT_NODELABEL(uart1)); | ||
static const struct device *const uart0_dev = DEVICE_DT_GET(DT_NODELABEL(uart0)); | ||
|
||
void uart_cb(const struct device *dev, void *user_data) | ||
{ | ||
if (!uart_irq_update(dev) || !uart_irq_rx_ready(dev)) { | ||
return; | ||
} | ||
|
||
const struct device *dest_dev = (const struct device *)user_data; | ||
|
||
/* read until FIFO empty */ | ||
uint8_t buf[16]; | ||
// `len` is first evaluated and then `len > 0` is used for conditional | ||
for (int len; len = uart_fifo_read(dev, buf, sizeof(buf)), len > 0;) { | ||
// UART1 TX | ||
for (int i = 0; i < len; i++) { | ||
uart_poll_out(dest_dev, buf[i]); | ||
} | ||
} | ||
} | ||
|
||
int main(void) | ||
{ | ||
if (!device_is_ready(uart1_dev) || !device_is_ready(uart0_dev)) { | ||
printk("UART device not ready\n"); | ||
return 0; | ||
} | ||
|
||
/* configure interrupt and callback to receive data */ | ||
int ret = uart_irq_callback_user_data_set(uart1_dev, uart_cb, (void *)uart0_dev); | ||
|
||
if (ret < 0) { | ||
printk("Error setting UART1 callback: %d\n", ret); | ||
return 0; | ||
} | ||
|
||
ret = uart_irq_callback_user_data_set(uart0_dev, uart_cb, (void *)uart1_dev); | ||
|
||
if (ret < 0) { | ||
printk("Error setting UART0 callback: %d\n", ret); | ||
return 0; | ||
} | ||
|
||
uart_irq_rx_enable(uart1_dev); | ||
uart_irq_rx_enable(uart0_dev); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.