diff --git a/Tools/IoTConnectionTools/analog-in/CMakeLists.txt b/Tools/IoTConnectionTools/analog-in/CMakeLists.txt new file mode 100644 index 0000000000..a87627701d --- /dev/null +++ b/Tools/IoTConnectionTools/analog-in/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required (VERSION 3.0) + +# Set default build type to RelWithDebInfo if not specified +if (NOT CMAKE_BUILD_TYPE) + message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") + set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE + STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" + FORCE) +endif() + +# Set language standard +set(CMAKE_CXX_STANDARD "11") + +project (ANALOG-IN) + +# OS checks +if(WIN32) + message(FATAL_ERROR, "This sample cannot be compiled natively on Windows OS.") +endif() + +# Dependency checks +find_package(PkgConfig) +pkg_search_module (MRAA REQUIRED mraa) + +add_subdirectory(cpp) diff --git a/Tools/IoTConnectionTools/analog-in/License.txt b/Tools/IoTConnectionTools/analog-in/License.txt new file mode 100644 index 0000000000..2f3a9835da --- /dev/null +++ b/Tools/IoTConnectionTools/analog-in/License.txt @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * This program and the accompanying materials are made available under the + * terms of the The MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + */ \ No newline at end of file diff --git a/Tools/IoTConnectionTools/analog-in/README.md b/Tools/IoTConnectionTools/analog-in/README.md new file mode 100644 index 0000000000..8025fce8d4 --- /dev/null +++ b/Tools/IoTConnectionTools/analog-in/README.md @@ -0,0 +1,37 @@ +# Analog In + +## Introduction +This is a simple sample you could use for a quick test of an analog input. + +## What it is +This project demonstrates how to read an analog value from an input pin using the Eclipse* MRAA library. + +## Hardware requirements +A board with an accessible GPIO input pin. +Some analog input device or sensor such as the Rotary Angle Sensor, Light Sensor, Sound Sensor, Temperature Sensor in Starter Kits. + +## Supported boards +This sample has been tested on +- [UP Squared\* AI Vision Kit](https://software.intel.com/en-us/iot/hardware/up-squared-ai-vision-dev-kit) + +The sample might need minor modifications depending on the board and shield you are using. + +## Software requirements +This sample is supported on Linux systems only. + +This version of the sample has been tested on Ubuntu Linux. It requires the [Eclipse* MRAA library](https://github.com/intel-iot-devkit/mraa). + +This sample requires additional system configuration when using Ubuntu OS with the UP series boards. Instructions on how to install the custom provided Linux kernel with the required drivers can be [found here](https://wiki.up-community.org/Ubuntu#Ubuntu_18.04_installation_and_configuration). + +In order to enable the ADC on Intel® Atom based UP boards, refer to the following [download](https://downloads.up-community.org/download/how-to-access-adc-for-up-squared-atom/). + +## Setup +Create a new project using this sample in Eclipse* IDE and after installing the Intel® oneAPI IoT Toolkit. +Connect the input device to an analog input pin on your IoT board. + +## Note +Accessing device sensors, including LEDs, requires MRAA I/O operations. Mraa I/O operations require permissions to UNIX character devices and sysfs classes not commonly granted to normal users by default. +To learn how to use I/O devices from user space with the UP series boards refer to [this link](https://wiki.up-community.org/Ubuntu#Enable_the_HAT_functionality_from_userspace). + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. diff --git a/Tools/IoTConnectionTools/analog-in/cpp/CMakeLists.txt b/Tools/IoTConnectionTools/analog-in/cpp/CMakeLists.txt new file mode 100644 index 0000000000..0901e072a1 --- /dev/null +++ b/Tools/IoTConnectionTools/analog-in/cpp/CMakeLists.txt @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MRAA_CFLAGS}") +add_executable (analog-in analog-in.cpp) +add_custom_target (run ./analog-in) +target_link_libraries(analog-in ${MRAA_LDFLAGS}) diff --git a/Tools/IoTConnectionTools/analog-in/cpp/analog-in.cpp b/Tools/IoTConnectionTools/analog-in/cpp/analog-in.cpp new file mode 100644 index 0000000000..72ce2dba26 --- /dev/null +++ b/Tools/IoTConnectionTools/analog-in/cpp/analog-in.cpp @@ -0,0 +1,97 @@ +/* ============================================================== + * Copyright (c) 2015 - 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * ============================================================= */ + +/* Analog input + * Read values from a gpio analog input pin. + */ + +#include + +#include +#include + +// Define the following if using a Grove Pi Shield +#define USING_GROVE_PI_SHIELD +using namespace std; +using namespace mraa; + +// leave warning/error message in console and wait for user to press Enter +void consoleMessage(const string& str) { + cerr << str << endl; + sleep(10); +} + +// check if running as root +void checkRoot(void) { + int euid = geteuid(); + if (euid) { + consoleMessage( + "This project uses Mraa I/O operations that may require\n" + "'root' privileges, but you are running as non - root user.\n" + "Passwordless keys(RSA key pairs) are recommended \n" + "to securely connect to your target with root privileges. \n" + "See the project's Readme for more info.\n\n"); + } + return; +} + +// set pin values depending on the current board (platform) +void initPlatform(int& gpioPin) { + // check which board we are running on + Platform platform = getPlatformType(); + switch (platform) { + case INTEL_UP2: +#ifdef USING_GROVE_PI_SHIELD + gpioPin = 2 + 512; // A2 Connector (512 offset needed for the shield) + break; +#endif + default: + string unknownPlatformMessage = + "This sample uses the MRAA/UPM library for I/O access, " + "you are running it on an unrecognized platform.\n" + "You may need to modify the MRAA/UPM initialization code to " + "ensure it works properly on your platform.\n"; + consoleMessage(unknownPlatformMessage); + } + return; +} + +int main() { + // Check access permissions for the current user + // Can be commented out for targets with user level I/O access enabled + checkRoot(); + + int gpioPin = 2; + initPlatform(gpioPin); + +#ifdef USING_GROVE_PI_SHIELD + addSubplatform(GROVEPI, "0"); +#endif + // create an analog input object from MRAA using the pin + Aio* a_pin = new Aio(gpioPin); + if (a_pin == NULL) { + consoleMessage("Can't create mraa::Aio object, exiting"); + return MRAA_ERROR_UNSPECIFIED; + } + + // loop forever printing the input value every second + for (;;) { + uint16_t pin_value; + try { + // read the current input voltage + pin_value = a_pin->read(); + } catch (const invalid_argument& readExc) { + // if incorrect voltage value input + cerr << "Invalid argument, exception thrown: " << readExc.what() << endl; + consoleMessage("MRAA cannot read pin value!"); + return MRAA_ERROR_INVALID_PARAMETER; + } + cout << "analog input value " << pin_value << endl; + sleep(1); + } + + return SUCCESS; +} diff --git a/Tools/IoTConnectionTools/analog-in/sample.json b/Tools/IoTConnectionTools/analog-in/sample.json new file mode 100644 index 0000000000..72f4b69792 --- /dev/null +++ b/Tools/IoTConnectionTools/analog-in/sample.json @@ -0,0 +1,22 @@ +{ + "guid": "EEED3DAC-8D4E-4F4B-9C15-2B73CF0AC718", + "name": "Analog Input", + "categories": ["Toolkit/Intel® oneAPI IoT Toolkit/IoT Connection Tools"], + "description": "Demonstrate how to read an analog voltage value from an input pin using the Eclipse* MRAA library.", + "dependencies": ["pkg|mraa|https://mraa.io"], + "languages": [{"cpp":{}}], + "os": ["linux"], + "ciTests": { + "linux": [ + { "id": "analog-in", + "env": [], + "steps": [ + "mkdir build", + "cd build", + "cmake ..", + "make" + ] + } + ] + } +} diff --git a/Tools/IoTConnectionTools/azure-iothub-telemetry/CMakeLists.txt b/Tools/IoTConnectionTools/azure-iothub-telemetry/CMakeLists.txt new file mode 100644 index 0000000000..a7c5d78793 --- /dev/null +++ b/Tools/IoTConnectionTools/azure-iothub-telemetry/CMakeLists.txt @@ -0,0 +1,53 @@ +cmake_minimum_required(VERSION 2.8.11) +project(azure-iothub-telemetry) + +if (CMAKE_VERSION VERSION_LESS "3.1") + if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") + set (CMAKE_C_FLAGS "--std=c99 ${CMAKE_C_FLAGS}") + if (NOT IN_OPENWRT) + set (CMAKE_CXX_FLAGS "--std=c++11 ${CMAKE_CXX_FLAGS}") + endif() + endif() +else() + set (CMAKE_C_STANDARD 99) + set (CMAKE_CXX_STANDARD 11) +endif() + +set(iothub_c_files + cpp/iothub_ll_telemetry_sample.c +) + +if(${use_sample_trusted_cert}) + add_definitions(-DSET_TRUSTED_CERT_IN_SAMPLES) + include_directories(certs) + set(iothub_c_files certs/certs.c) +endif() + +set(AZUREIOT_INC_FOLDER "." "/usr/include/azureiot" "/usr/include/azureiot/inc") + +include_directories(${AZUREIOT_INC_FOLDER}) + +add_executable(azure-iothub-telemetry ${iothub_c_files}) +target_link_libraries(azure-iothub-telemetry + iothub_client_mqtt_transport + iothub_client_amqp_transport + iothub_client_http_transport + iothub_client + umqtt + prov_auth_client + hsm_security_client + uhttp + aziotsharedutil + parson + uuid + pthread + curl + ssl + crypto + m +) + +add_subdirectory(cpp) + +add_custom_target (run ./azure-iothub-telemetry) + diff --git a/Tools/IoTConnectionTools/azure-iothub-telemetry/License.txt b/Tools/IoTConnectionTools/azure-iothub-telemetry/License.txt new file mode 100644 index 0000000000..9f1185a1af --- /dev/null +++ b/Tools/IoTConnectionTools/azure-iothub-telemetry/License.txt @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * This program and the accompanying materials are made available under the + * terms of the The MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + */ diff --git a/Tools/IoTConnectionTools/azure-iothub-telemetry/README.md b/Tools/IoTConnectionTools/azure-iothub-telemetry/README.md new file mode 100644 index 0000000000..e4a9182209 --- /dev/null +++ b/Tools/IoTConnectionTools/azure-iothub-telemetry/README.md @@ -0,0 +1,33 @@ +# Azure IoTHub Telemetry + +## Introduction +This is a simple sample you could use for a quick test of Azure cloud services. + +## What it is +This project demonstrates how to send messages from a single device to Microsoft Azure IoT Hub via chosen protocol. + +## Hardware requirements +The minimum requirements are for the device platform to support can be [found here](https://github.com/Azure/azure-iot-sdk-c). + +## Software requirements +This sample is supported on Linux systems only. + +This version of the sample has been tested on Ubuntu Linux. This sample requires additional system configuration when using Ubuntu OS. Instructions on how to install the custom provided all dependency libraries for Linux can be [found here](https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/ubuntu_apt-get_sample_setup.md). + +## Setup +Create and configure Azure IoTHub on [Microsoft Azure page](https://portal.azure.com/#home). +Detailed instructions are on [Microsoft website](https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-create-through-portal). + +Paste the Device Connection String into the following line: +`static const char* connectionString = "[device connection string]"` + +Choose one of the protocols to connect: MQTT over websockets, AMQP, AMQP over websockets or HTTP by uncommenting one of the following strings (MQTT protocol is chosen by default): +`//#define SAMPLE_MQTT_OVER_WEBSOCKETS` +`//#define SAMPLE_AMQP` +`//#define SAMPLE_AMQP_OVER_WEBSOCKETS` +`//#define SAMPLE_HTTP` + +Build and run the sample. + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. diff --git a/Tools/IoTConnectionTools/azure-iothub-telemetry/certs/certs.c b/Tools/IoTConnectionTools/azure-iothub-telemetry/certs/certs.c new file mode 100644 index 0000000000..d1e3475f8e --- /dev/null +++ b/Tools/IoTConnectionTools/azure-iothub-telemetry/certs/certs.c @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/* This file contains certs needed to communicate with Azure (IoT) + For latest values, look here : https://github.com/Azure/azure-iot-sdk-c/blob/master/certs/certs.c +*/ + +#include "certs.h" +/* Note: for devices with limited resources, only one cert should be loaded. + #defines are used to reduce memory footprint of certificates. + For DE and CN regions, please build with -DUSE_MICROSOFTAZURE_DE_CERT or -DUSE_PORTAL_AZURE_CN_CERT, respectively, + if you wish to load ONLY those certs. +*/ +#if !defined(USE_BALTIMORE_CERT) && !defined(USE_MICROSOFTAZURE_DE_CERT) && !defined(USE_PORTAL_AZURE_CN_CERT) +// For legacy, if no certificates were explicitly selected then include all of them +#define USE_BALTIMORE_CERT +#define USE_MICROSOFTAZURE_DE_CERT +#define USE_PORTAL_AZURE_CN_CERT +#endif + +const char certificates[] = +#if defined(USE_BALTIMORE_CERT) +/* DigiCert Baltimore Root --Used Globally--*/ +// This cert should be used when connecting to Azure IoT on the Azure Cloud available globally. When in doubt, use this cert. +// For latest values, look here : https://github.com/Azure/azure-iot-sdk-c/blob/master/certs/certs.c +"-----BEGIN CERTIFICATE-----\r\n" +"MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\r\n" +"RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\r\n" +"VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\r\n" +"DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\r\n" +"ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\r\n" +"VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\r\n" +"mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\r\n" +"IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\r\n" +"mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\r\n" +"XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\r\n" +"dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\r\n" +"jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\r\n" +"BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\r\n" +"DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\r\n" +"9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\r\n" +"jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\r\n" +"Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\r\n" +"ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\r\n" +"R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\r\n" +"-----END CERTIFICATE-----\r\n" +#endif /* BALTIMORE_CERT */ + +#if defined(USE_PORTAL_AZURE_CN_CERT) +/* DigiCert Global Root CA */ +// This cert should be used when connecting to Azure IoT on the https://portal.azure.cn Cloud address. +// For latest values, look here : https://github.com/Azure/azure-iot-sdk-c/blob/master/certs/certs.c +"-----BEGIN CERTIFICATE-----\r\n" +"MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\r\n" +"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\r\n" +"d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\r\n" +"QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\r\n" +"MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\r\n" +"b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMI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) +/* D-TRUST Root Class 3 CA 2 2009 */ +// This cert should be used when connecting to Azure IoT on the https://portal.microsoftazure.de Cloud address. +// For latest values, look here : https://github.com/Azure/azure-iot-sdk-c/blob/master/certs/certs.c +"-----BEGIN CERTIFICATE-----\r\n" +"MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF\r\n" +"MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD\r\n" +"bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NTha\r\n" +"ME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMM\r\n" +"HkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIwDQYJKoZIhvcNAQEB\r\n" +"BQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOADER03\r\n" +"UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42\r\n" +"tSHKXzlABF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9R\r\n" +"ySPocq60vFYJfxLLHLGvKZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsM\r\n" +"lFqVlNpQmvH/pStmMaTJOKDfHR+4CS7zp+hnUquVH+BGPtikw8paxTGA6Eian5Rp\r\n" +"/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUCAwEAAaOCARowggEWMA8G\r\n" +"A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ4PGEMA4G\r\n" +"A1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVj\r\n" +"dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUy\r\n" +"MENBJTIwMiUyMDIwMDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRl\r\n" +"cmV2b2NhdGlvbmxpc3QwQ6BBoD+GPWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3Js\r\n" +"L2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAwOS5jcmwwDQYJKoZIhvcNAQEL\r\n" +"BQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm2H6NMLVwMeni\r\n" +"acfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0\r\n" +"o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4K\r\n" +"zCUqNQT4YJEVdT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8\r\n" +"PIWmawomDeCTmGCufsYkl4phX5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3Y\r\n" +"Johw1+qRzT65ysCQblrGXnRl11z+o+I=\r\n" +"-----END CERTIFICATE-----\r\n" +#endif /* MICROSOFTAZURE_DE_CERT */ + +; diff --git a/Tools/IoTConnectionTools/azure-iothub-telemetry/certs/certs.h b/Tools/IoTConnectionTools/azure-iothub-telemetry/certs/certs.h new file mode 100644 index 0000000000..144adc9ce5 --- /dev/null +++ b/Tools/IoTConnectionTools/azure-iothub-telemetry/certs/certs.h @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#ifndef CERTS_H +#define CERTS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + extern const char certificates[]; + +#ifdef __cplusplus +} +#endif + +#endif /* CERTS_H */ diff --git a/Tools/IoTConnectionTools/azure-iothub-telemetry/cpp/CMakeLists.txt b/Tools/IoTConnectionTools/azure-iothub-telemetry/cpp/CMakeLists.txt new file mode 100644 index 0000000000..6f45473dac --- /dev/null +++ b/Tools/IoTConnectionTools/azure-iothub-telemetry/cpp/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 2.8.11) +project(azure-iothub-telemetry) + +# Use the Intel C++ Compiler when available +find_program(ICPC NAMES icpc icl) +if(ICPC) + set(CMAKE_CXX_COMPILER ${ICPC}) + message(STATUS "Switching to the Intel(R) C++ Compiler from: ${ICPC}") +else() + message("-- Could not find the Intel(R) C++ Compiler on the system path. Did you setup the compiler environment?") +endif() + + +set(iothub_c_files + iothub_ll_telemetry_sample.c + ../certs/certs.c +) + +add_definitions(-DUSE_HTTP) +add_definitions(-DUSE_AMQP) +add_definitions(-DUSE_MQTT) + +add_definitions(-DSET_TRUSTED_CERT_IN_SAMPLES) +include_directories("../certs") + + + diff --git a/Tools/IoTConnectionTools/azure-iothub-telemetry/cpp/iothub_ll_telemetry_sample.c b/Tools/IoTConnectionTools/azure-iothub-telemetry/cpp/iothub_ll_telemetry_sample.c new file mode 100644 index 0000000000..eb008853f3 --- /dev/null +++ b/Tools/IoTConnectionTools/azure-iothub-telemetry/cpp/iothub_ll_telemetry_sample.c @@ -0,0 +1,191 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// CAVEAT: This sample is to demonstrate azure IoT client concepts only and is not a guide design principles or style +// Checking of return codes and error values shall be omitted for brevity. Please practice sound engineering practices +// when writing production code. + +#include +#include + +#include "iothub.h" +#include "iothub_device_client_ll.h" +#include "iothub_client_options.h" +#include "iothub_message.h" +#include "azure_c_shared_utility/threadapi.h" +#include "azure_c_shared_utility/crt_abstractions.h" +#include "azure_c_shared_utility/shared_util_options.h" + +#ifdef SET_TRUSTED_CERT_IN_SAMPLES +#include "certs.h" +#endif // SET_TRUSTED_CERT_IN_SAMPLES + +/* This sample uses the _LL APIs of iothub_client for example purposes. +Simply changing the using the convenience layer (functions not having _LL) +and removing calls to _DoWork will yield the same results. */ + +// The protocol you wish to use should be uncommented +// +#define SAMPLE_MQTT +//#define SAMPLE_MQTT_OVER_WEBSOCKETS +//#define SAMPLE_AMQP +//#define SAMPLE_AMQP_OVER_WEBSOCKETS +//#define SAMPLE_HTTP + +#ifdef SAMPLE_MQTT + #include "iothubtransportmqtt.h" +#endif // SAMPLE_MQTT +#ifdef SAMPLE_MQTT_OVER_WEBSOCKETS + #include "iothubtransportmqtt_websockets.h" +#endif // SAMPLE_MQTT_OVER_WEBSOCKETS +#ifdef SAMPLE_AMQP + #include "iothubtransportamqp.h" +#endif // SAMPLE_AMQP +#ifdef SAMPLE_AMQP_OVER_WEBSOCKETS + #include "iothubtransportamqp_websockets.h" +#endif // SAMPLE_AMQP_OVER_WEBSOCKETS +#ifdef SAMPLE_HTTP + #include "iothubtransporthttp.h" +#endif // SAMPLE_HTTP + + +/* Paste in the your iothub connection string */ +static const char* connectionString = "[device connection string]"; +#define MESSAGE_COUNT 5 +static bool g_continueRunning = true; +static size_t g_message_count_send_confirmations = 0; + +static void send_confirm_callback(IOTHUB_CLIENT_CONFIRMATION_RESULT result, void* userContextCallback) +{ + (void)userContextCallback; + // When a message is sent this callback will get envoked + g_message_count_send_confirmations++; + (void)printf("Confirmation callback received for message %lu with result %s\r\n", (unsigned long)g_message_count_send_confirmations, MU_ENUM_TO_STRING(IOTHUB_CLIENT_CONFIRMATION_RESULT, result)); +} + +static void connection_status_callback(IOTHUB_CLIENT_CONNECTION_STATUS result, IOTHUB_CLIENT_CONNECTION_STATUS_REASON reason, void* user_context) +{ + (void)reason; + (void)user_context; + // This sample DOES NOT take into consideration network outages. + if (result == IOTHUB_CLIENT_CONNECTION_AUTHENTICATED) + { + (void)printf("The device client is connected to iothub\r\n"); + } + else + { + (void)printf("The device client has been disconnected\r\n"); + } +} + +int main(void) +{ + IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol; + IOTHUB_MESSAGE_HANDLE message_handle; + size_t messages_sent = 0; + const char* telemetry_msg = "test_message"; + + // Select the Protocol to use with the connection +#ifdef SAMPLE_MQTT + protocol = MQTT_Protocol; +#endif // SAMPLE_MQTT +#ifdef SAMPLE_MQTT_OVER_WEBSOCKETS + protocol = MQTT_WebSocket_Protocol; +#endif // SAMPLE_MQTT_OVER_WEBSOCKETS +#ifdef SAMPLE_AMQP + protocol = AMQP_Protocol; +#endif // SAMPLE_AMQP +#ifdef SAMPLE_AMQP_OVER_WEBSOCKETS + protocol = AMQP_Protocol_over_WebSocketsTls; +#endif // SAMPLE_AMQP_OVER_WEBSOCKETS +#ifdef SAMPLE_HTTP + protocol = HTTP_Protocol; +#endif // SAMPLE_HTTP + + // Used to initialize IoTHub SDK subsystem + (void)IoTHub_Init(); + + IOTHUB_DEVICE_CLIENT_LL_HANDLE device_ll_handle; + + (void)printf("Creating IoTHub Device handle\r\n"); + // Create the iothub handle here + device_ll_handle = IoTHubDeviceClient_LL_CreateFromConnectionString(connectionString, protocol); + if (device_ll_handle == NULL) + { + (void)printf("Failure createing Iothub device. Hint: Check you connection string.\r\n"); + } + else + { + // Set any option that are neccessary. + // For available options please see the iothub_sdk_options.md documentation + +#ifndef SAMPLE_HTTP + // Can not set this options in HTTP + bool traceOn = true; + IoTHubDeviceClient_LL_SetOption(device_ll_handle, OPTION_LOG_TRACE, &traceOn); +#endif + +#ifdef SET_TRUSTED_CERT_IN_SAMPLES + // Setting the Trusted Certificate. This is only necessary on system with without + // built in certificate stores. + IoTHubDeviceClient_LL_SetOption(device_ll_handle, OPTION_TRUSTED_CERT, certificates); +#endif // SET_TRUSTED_CERT_IN_SAMPLES + +#if defined SAMPLE_MQTT || defined SAMPLE_MQTT_WS + //Setting the auto URL Encoder (recommended for MQTT). Please use this option unless + //you are URL Encoding inputs yourself. + //ONLY valid for use with MQTT + //bool urlEncodeOn = true; + //IoTHubDeviceClient_LL_SetOption(iothub_ll_handle, OPTION_AUTO_URL_ENCODE_DECODE, &urlEncodeOn); +#endif + + // Setting connection status callback to get indication of connection to iothub + (void)IoTHubDeviceClient_LL_SetConnectionStatusCallback(device_ll_handle, connection_status_callback, NULL); + + do + { + if (messages_sent < MESSAGE_COUNT) + { + // Construct the iothub message from a string or a byte array + message_handle = IoTHubMessage_CreateFromString(telemetry_msg); + //message_handle = IoTHubMessage_CreateFromByteArray((const unsigned char*)msgText, strlen(msgText))); + + // Set Message property + /*(void)IoTHubMessage_SetMessageId(message_handle, "MSG_ID"); + (void)IoTHubMessage_SetCorrelationId(message_handle, "CORE_ID"); + (void)IoTHubMessage_SetContentTypeSystemProperty(message_handle, "application%2fjson"); + (void)IoTHubMessage_SetContentEncodingSystemProperty(message_handle, "utf-8");*/ + + // Add custom properties to message + (void)IoTHubMessage_SetProperty(message_handle, "property_key", "property_value"); + + (void)printf("Sending message %d to IoTHub\r\n", (int)(messages_sent + 1)); + IoTHubDeviceClient_LL_SendEventAsync(device_ll_handle, message_handle, send_confirm_callback, NULL); + + // The message is copied to the sdk so the we can destroy it + IoTHubMessage_Destroy(message_handle); + + messages_sent++; + } + else if (g_message_count_send_confirmations >= MESSAGE_COUNT) + { + // After all messages are all received stop running + g_continueRunning = false; + } + + IoTHubDeviceClient_LL_DoWork(device_ll_handle); + ThreadAPI_Sleep(1); + + } while (g_continueRunning); + + // Clean up the iothub sdk handle + IoTHubDeviceClient_LL_Destroy(device_ll_handle); + } + // Free all the sdk subsystem + IoTHub_Deinit(); + + printf("Press any key to continue"); + (void)getchar(); + + return 0; +} diff --git a/Tools/IoTConnectionTools/azure-iothub-telemetry/sample.json b/Tools/IoTConnectionTools/azure-iothub-telemetry/sample.json new file mode 100644 index 0000000000..07cb897101 --- /dev/null +++ b/Tools/IoTConnectionTools/azure-iothub-telemetry/sample.json @@ -0,0 +1,22 @@ +{ + "guid": "F8F830DE-3660-4478-B2FA-22EE492D7120", + "name": "Azure IoTHub Telemetry", + "categories": ["Toolkit/Intel® oneAPI IoT Toolkit/IoT Connection Tools"], + "description": "Demonstrate how to send messages from a single device to Microsoft Azure IoT Hub via chosen protocol.", + "dependencies": ["azure-iot-sdk-c|https://github.com/Azure/azure-iot-sdk-c"], + "languages": [{"cpp":{}}], + "os": ["linux"], + "ciTests": { + "linux": [ + { "id": "azure-iothub-telemetry", + "env": [], + "steps": [ + "mkdir build", + "cd build", + "cmake ..", + "make" + ] + } + ] + } +} diff --git a/Tools/IoTConnectionTools/digital-in/CMakeLists.txt b/Tools/IoTConnectionTools/digital-in/CMakeLists.txt new file mode 100644 index 0000000000..adbd151f7a --- /dev/null +++ b/Tools/IoTConnectionTools/digital-in/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required (VERSION 3.0) + +# Set default build type to RelWithDebInfo if not specified +if (NOT CMAKE_BUILD_TYPE) + message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") + set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE + STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" + FORCE) +endif() + +# Set language standard +set(CMAKE_CXX_STANDARD "11") + +project (DIGITAL-IN) + +# OS checks +if(WIN32) + message(FATAL_ERROR, "This sample cannot be compiled natively on Windows OS.") +endif() + +# Dependency checks +find_package(PkgConfig) +pkg_search_module (MRAA REQUIRED mraa) + +add_subdirectory(cpp) diff --git a/Tools/IoTConnectionTools/digital-in/License.txt b/Tools/IoTConnectionTools/digital-in/License.txt new file mode 100644 index 0000000000..2f3a9835da --- /dev/null +++ b/Tools/IoTConnectionTools/digital-in/License.txt @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * This program and the accompanying materials are made available under the + * terms of the The MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + */ \ No newline at end of file diff --git a/Tools/IoTConnectionTools/digital-in/README.md b/Tools/IoTConnectionTools/digital-in/README.md new file mode 100644 index 0000000000..05f5d33bc9 --- /dev/null +++ b/Tools/IoTConnectionTools/digital-in/README.md @@ -0,0 +1,36 @@ +# Digital In + +## Introduction +This is a simple sample you could use for a quick test of digital input. + +## What it is +This project demonstrates how to read a digital value from an input pin using the MRAA library. + +## Hardware requirements +A board with an accessible GPIO input pin. +A digital input device or sensor such as the 'Button' or 'Touch Sensor' in Starter Kits. + +## Supported boards +This sample has been tested on +- [UP Squared\* AI Vision Kit](https://software.intel.com/en-us/iot/hardware/up-squared-ai-vision-dev-kit) +- [IEI\* Tank AIoT Developer Kit](https://software.intel.com/en-us/iot/hardware/iei-tank-dev-kit-core) + +The sample might need minor modifications depending on the board and shield you are using. + +## Software requirements +This sample is supported on Linux systems only. + +This version of the sample has been tested on Ubuntu Linux. It requires the [Eclipse* MRAA library](https://github.com/intel-iot-devkit/mraa). + +This sample requires additional system configuration when using Ubuntu OS with the UP series boards. Instructions on how to install the custom provided Linux kernel with the required drivers can be [found here](https://wiki.up-community.org/Ubuntu#Ubuntu_18.04_installation_and_configuration). + +## Setup +Create a new project using the Eclipse* IDE and the after installing the Intel® oneAPI IoT Toolkit. +Connect the input device to a digital input pin on your IoT board. + +## Note +Accessing device sensors, including LEDs, requires MRAA I/O operations. Mraa I/O operations require permissions to UNIX character devices and sysfs classes not commonly granted to normal users by default. +To learn how to use I/O devices from user space with the UP series boards refer to [this link](https://wiki.up-community.org/Ubuntu#Enable_the_HAT_functionality_from_userspace). + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. diff --git a/Tools/IoTConnectionTools/digital-in/cpp/CMakeLists.txt b/Tools/IoTConnectionTools/digital-in/cpp/CMakeLists.txt new file mode 100644 index 0000000000..2e1efd0cbb --- /dev/null +++ b/Tools/IoTConnectionTools/digital-in/cpp/CMakeLists.txt @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MRAA_CFLAGS}") +add_executable (digital-in digital-in.cpp) +add_custom_target (run ./digital-in) +target_link_libraries(digital-in ${MRAA_LDFLAGS}) diff --git a/Tools/IoTConnectionTools/digital-in/cpp/digital-in.cpp b/Tools/IoTConnectionTools/digital-in/cpp/digital-in.cpp new file mode 100644 index 0000000000..e1b8939056 --- /dev/null +++ b/Tools/IoTConnectionTools/digital-in/cpp/digital-in.cpp @@ -0,0 +1,112 @@ +/* ============================================================== + * Copyright (c) 2015 - 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * ============================================================= */ + +/* Digital input + * Read values from a gpio digital input pin. + */ + +#include + +#include +#include + +// Define the following if using a Grove Pi Shield +#define USING_GROVE_PI_SHIELD +using namespace std; +using namespace mraa; + +// leave warning/error message in console and wait for user to press Enter +void consoleMessage(const string& str) { + cerr << str << endl; + sleep(10); +} + +// check if running as root +void checkRoot(void) { + int euid = geteuid(); + if (euid) { + consoleMessage( + "This project uses Mraa I/O operations that may require\n" + "'root' privileges, but you are running as non - root user.\n" + "Passwordless keys(RSA key pairs) are recommended \n" + "to securely connect to your target with root privileges. \n" + "See the project's Readme for more info.\n\n"); + } + return; +} + +// set pin values depending on the current board (platform) +void initPlatform(int& gpioPin) { + // check which board we are running on + Platform platform = getPlatformType(); + switch (platform) { + case INTEL_UP2: +#ifdef USING_GROVE_PI_SHIELD + gpioPin = 4 + 512; // D4 Connector (512 offset needed for the shield) + break; +#endif + case INTEL_UP: + case INTEL_EDISON_FAB_C: + case INTEL_GALILEO_GEN2: + break; + case INTEL_MINNOWBOARD_MAX: // Same for Minnowboard Turbot + gpioPin = 104; + break; + case INTEL_JOULE_EXPANSION: + gpioPin = 101; + break; + case IEI_TANK: + gpioPin = 0; + break; + default: + string unknownPlatformMessage = + "This sample uses the MRAA/UPM library for I/O access, " + "you are running it on an unrecognized platform.\n " + "You may need to modify the MRAA/UPM initialization code to " + "ensure it works properly on your platform.\n"; + consoleMessage(unknownPlatformMessage); + } + return; +} + +int main() { + // Check access permissions for the current user + // Can be commented out for targets with user level I/O access enabled + checkRoot(); + + int gpioPin = 13; + initPlatform(gpioPin); +#ifdef USING_GROVE_PI_SHIELD + addSubplatform(GROVEPI, "0"); +#endif + + // create a GPIO object from MRAA for the pin + Gpio* d_pin = new Gpio(gpioPin); + if (d_pin == NULL) { + consoleMessage("Can't create mraa::Gpio object, exiting"); + return MRAA_ERROR_UNSPECIFIED; + } + + // set the pin as input + if (d_pin->dir(DIR_IN) != SUCCESS) { + consoleMessage("Can't set digital pin as input, exiting"); + return MRAA_ERROR_UNSPECIFIED; + } + + // loop forever printing the digital input value every second + for (;;) { + uint16_t pin_value = d_pin->read(); + // if incorrect value input + if (pin_value == UINT16_MAX) { + consoleMessage("MRAA cannot read pin value!"); + return MRAA_ERROR_INVALID_PARAMETER; + } + cout << "value " << pin_value << endl; + sleep(1); + } + + return SUCCESS; +} diff --git a/Tools/IoTConnectionTools/digital-in/sample.json b/Tools/IoTConnectionTools/digital-in/sample.json new file mode 100644 index 0000000000..a7bd441988 --- /dev/null +++ b/Tools/IoTConnectionTools/digital-in/sample.json @@ -0,0 +1,22 @@ +{ + "guid": "8BBEBD41-DD09-4EFE-9156-694DC5D2DE6A", + "name": "Digital Input", + "categories": ["Toolkit/Intel® oneAPI IoT Toolkit/IoT Connection Tools"], + "description": "Demonstrate how to read a digital value from an input pin using the Eclipse* MRAA library.", + "dependencies": ["pkg|mraa|https://mraa.io"], + "languages": [{"cpp":{}}], + "os": ["linux"], + "ciTests": { + "linux": [ + { "id": "digital-in", + "env": [], + "steps": [ + "mkdir build", + "cd build", + "cmake ..", + "make" + ] + } + ] + } +} diff --git a/Tools/IoTConnectionTools/digital-out/CMakeLists.txt b/Tools/IoTConnectionTools/digital-out/CMakeLists.txt new file mode 100644 index 0000000000..4022e61783 --- /dev/null +++ b/Tools/IoTConnectionTools/digital-out/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required (VERSION 3.0) + +# Set default build type to RelWithDebInfo if not specified +if (NOT CMAKE_BUILD_TYPE) + message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") + set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE + STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" + FORCE) +endif() + +# Set language standard +set(CMAKE_CXX_STANDARD "11") + +project (DIGITAL-OUT) + +# OS checks +if(WIN32) + message(FATAL_ERROR, "This sample cannot be compiled natively on Windows OS.") +endif() + +# Dependency checks +find_package(PkgConfig) +pkg_search_module (MRAA REQUIRED mraa) + +add_subdirectory(cpp) diff --git a/Tools/IoTConnectionTools/digital-out/License.txt b/Tools/IoTConnectionTools/digital-out/License.txt new file mode 100644 index 0000000000..2f3a9835da --- /dev/null +++ b/Tools/IoTConnectionTools/digital-out/License.txt @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * This program and the accompanying materials are made available under the + * terms of the The MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + */ \ No newline at end of file diff --git a/Tools/IoTConnectionTools/digital-out/README.md b/Tools/IoTConnectionTools/digital-out/README.md new file mode 100644 index 0000000000..4dd920661c --- /dev/null +++ b/Tools/IoTConnectionTools/digital-out/README.md @@ -0,0 +1,37 @@ +# Digital Out + +## Introduction +This is a simple sample you could use for a quick test of digital output. + +## What it is + +This project demonstrates how to write a value to an output pin using the Eclipse* MRAA library. + +## Hardware requirements +A board with an accessible GPIO output pin. +A digital output device or sensor such as a 'Relay' or 'LED' in Starter Kits. + +## Supported boards +This sample has been tested on +- [UP Squared\* AI Vision Kit](https://software.intel.com/en-us/iot/hardware/up-squared-ai-vision-dev-kit) +- [IEI\* Tank AIoT Developer Kit](https://software.intel.com/en-us/iot/hardware/iei-tank-dev-kit-core) + +The sample might need minor modifications depending on the board and shield you are using. + +## Software requirements +This sample is supported on Linux systems only. + +This version of the sample has been tested on Ubuntu Linux. It requires the [Eclipse* MRAA library](https://github.com/intel-iot-devkit/mraa). + +This sample requires additional system configuration when using Ubuntu OS with the UP series boards. Instructions on how to install the custom provided Linux kernel with the required drivers can be [found here](https://wiki.up-community.org/Ubuntu#Ubuntu_18.04_installation_and_configuration). + +## Setup +Create a new project using this sample in Eclipse* IDE and after installing the Intel® oneAPI IoT Toolkit. +Connect the output device to a digital output pin on your IoT board. + +## Note +Accessing device sensors, including LEDs, requires MRAA I/O operations. Mraa I/O operations require permissions to UNIX character devices and sysfs classes not commonly granted to normal users by default. +To learn how to use I/O devices from user space with the UP series boards refer to [this link](https://wiki.up-community.org/Ubuntu#Enable_the_HAT_functionality_from_userspace). + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. diff --git a/Tools/IoTConnectionTools/digital-out/cpp/CMakeLists.txt b/Tools/IoTConnectionTools/digital-out/cpp/CMakeLists.txt new file mode 100644 index 0000000000..66f18251c3 --- /dev/null +++ b/Tools/IoTConnectionTools/digital-out/cpp/CMakeLists.txt @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MRAA_CFLAGS}") +add_executable (digital-out digital-out.cpp) +add_custom_target (run ./digital-out) +target_link_libraries(digital-out ${MRAA_LDFLAGS}) diff --git a/Tools/IoTConnectionTools/digital-out/cpp/digital-out.cpp b/Tools/IoTConnectionTools/digital-out/cpp/digital-out.cpp new file mode 100644 index 0000000000..6116e564ef --- /dev/null +++ b/Tools/IoTConnectionTools/digital-out/cpp/digital-out.cpp @@ -0,0 +1,114 @@ +/* ============================================================== + * Copyright (c) 2015 - 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * ============================================================= */ + +/* Digital output + * Write values to a gpio digital output pin. + */ + +#include + +#include +#include + +// Define the following if using a Grove Pi Shield +#define USING_GROVE_PI_SHIELD +using namespace std; +using namespace mraa; + +// leave warning/error message in console and wait for user to press Enter +void consoleMessage(const string& str) { + std::cerr << str << std::endl << "Press Enter to continue..." << std::endl; + sleep(10); +} + +// check if running as root +void checkRoot(void) { + int euid = geteuid(); + if (euid) { + consoleMessage( + "This project uses Mraa I/O operations that may require\n" + "'root' privileges, but you are running as non - root user.\n" + "Passwordless keys(RSA key pairs) are recommended \n" + "to securely connect to your target with root privileges. \n" + "See the project's Readme for more info.\n\n"); + } + return; +} + +// set pin values depending on the current board (platform) +void initPlatform(int& gpioPin) { + // check which board we are running on + Platform platform = getPlatformType(); + switch (platform) { + case INTEL_UP2: +#ifdef USING_GROVE_PI_SHIELD + gpioPin = 4 + 512; // D4 Connector (512 offset needed for the shield) + break; +#endif + case INTEL_UP: + case INTEL_EDISON_FAB_C: + case INTEL_GALILEO_GEN2: + break; + case INTEL_MINNOWBOARD_MAX: // Same for Minnowboard Turbot + gpioPin = 104; + break; + case INTEL_JOULE_EXPANSION: + gpioPin = 101; + break; + case IEI_TANK: + gpioPin = 1; + break; + default: + string unknownPlatformMessage = + "This sample uses the MRAA/UPM library for I/O access, " + "you are running it on an unrecognized platform. " + "You may need to modify the MRAA/UPM initialization code to " + "ensure it works properly on your platform.\n"; + consoleMessage(unknownPlatformMessage); + } + return; +} + +int main() { + // Check access permissions for the current user + // Can be commented out for targets with user level I/O access enabled + checkRoot(); + + int gpioPin = 13; + initPlatform(gpioPin); + +#ifdef USING_GROVE_PI_SHIELD + addSubplatform(GROVEPI, "0"); +#endif + + // create a GPIO object from MRAA for the pin + Gpio* d_pin = new Gpio(gpioPin); + if (d_pin == NULL) { + consoleMessage("MRAA couldn't initialize GPIO, exiting."); + return MRAA_ERROR_UNSPECIFIED; + } + // set the pin as output + if (d_pin->dir(DIR_OUT) != SUCCESS) { + consoleMessage("Can't set digital pin as output, exiting"); + return MRAA_ERROR_UNSPECIFIED; + } + + // loop forever toggling the digital output every second + for (;;) { + if (d_pin->write(0) != SUCCESS) { + consoleMessage("MRAA cannot write pin value!"); + return MRAA_ERROR_UNSPECIFIED; + } + sleep(1); + if (d_pin->write(1) != SUCCESS) { + consoleMessage("MRAA cannot write pin value!"); + return MRAA_ERROR_UNSPECIFIED; + } + sleep(1); + } + + return SUCCESS; +} diff --git a/Tools/IoTConnectionTools/digital-out/sample.json b/Tools/IoTConnectionTools/digital-out/sample.json new file mode 100644 index 0000000000..0675ebad19 --- /dev/null +++ b/Tools/IoTConnectionTools/digital-out/sample.json @@ -0,0 +1,22 @@ +{ + "guid": "A544224A-B5C0-462C-95F6-7C266A1DB2EB", + "name": "Digital Output", + "categories": ["Toolkit/Intel® oneAPI IoT Toolkit/IoT Connection Tools"], + "description": "Demonstrate how to write a digital value to an output pin using the Eclipse* MRAA library.", + "dependencies": ["pkg|mraa|https://mraa.io"], + "languages": [{"cpp":{}}], + "os": ["linux"], + "ciTests": { + "linux": [ + { "id": "digital-out", + "env": [], + "steps": [ + "mkdir build", + "cd build", + "cmake ..", + "make" + ] + } + ] + } +} diff --git a/Tools/IoTConnectionTools/hello-iot-world/CMakeLists.txt b/Tools/IoTConnectionTools/hello-iot-world/CMakeLists.txt new file mode 100644 index 0000000000..01e1d2d1dc --- /dev/null +++ b/Tools/IoTConnectionTools/hello-iot-world/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required (VERSION 3.0) +project (HELLO-IOT-WORLD CXX) + +# Use the Intel C++ Compiler when available +find_program(ICPC NAMES icpc icl) +if(ICPC) + set(CMAKE_CXX_COMPILER ${ICPC}) + message(STATUS "Switching to the Intel(R) C++ Compiler from: ${ICPC}") +else() + message("-- Could not find the Intel(R) C++ Compiler on the system path. Did you setup the compiler environment?") +endif() + +# Set default build type to RelWithDebInfo if not specified +if (NOT CMAKE_BUILD_TYPE) + message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") + set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE + STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" + FORCE) +endif() + +# Set language standard +set(CMAKE_CXX_STANDARD "11") + +add_subdirectory(cpp) diff --git a/Tools/IoTConnectionTools/hello-iot-world/License.txt b/Tools/IoTConnectionTools/hello-iot-world/License.txt new file mode 100644 index 0000000000..2f3a9835da --- /dev/null +++ b/Tools/IoTConnectionTools/hello-iot-world/License.txt @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * This program and the accompanying materials are made available under the + * terms of the The MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + */ \ No newline at end of file diff --git a/Tools/IoTConnectionTools/hello-iot-world/README.md b/Tools/IoTConnectionTools/hello-iot-world/README.md new file mode 100644 index 0000000000..0f67510975 --- /dev/null +++ b/Tools/IoTConnectionTools/hello-iot-world/README.md @@ -0,0 +1,54 @@ +# Hello IoT World + +## Introduction +This is a simple sample you could use for a quick compiler test. + +## What it is +This project outputs the classic "Hello World" message along with the compiler identification string. + +## Hardware requirements +Any Intel® CPU + +## Software requirements +Intel® C++ Compiler + +## How to build and run +### Linux CLI +Use the `oneapi-cli` utility from a terminal to download and create the sample at a location of your choice. +Source the `setvars.sh` script distributed with oneAPI to configure the compiler. By default this can be found under +`/opt/intel/inteloneapi`. +Use the following commands to build and run the sample: +``` +mkdir build +cd build +cmake .. +make +make run +``` +### Windows CLI +Use the `oneapi-cli.exe` utility from a `Developer Command Prompt for VS` to download and create the sample at a location of your choice. + +*Note:* On Windows systems you will need "MSBuild Tools", "Windows 10 SDK" and "C++ CMake tools for Windows" as part of your installed Visual Studio components. + +Source the `setvars.bat` script distributed with oneAPI to configure the compiler. By default this can be found under +`"C:\Program Files (x86)\IntelOneAPI\inteloneapi"`. +Use the following commands to build and run the sample: +``` +mkdir build +cd build +cmake -G "NMake Makefiles" .. +nmake +nmake run +``` +### IDE +Use the Samples Plugin for Eclipse or Visual Studio to create and run the sample. + +You may need to source the `setvars` script distributed with oneAPI before launching the IDE to use the Intel® C++ Compiler or make it available as a toolchain in the IDE. + +### Additional Links +Access the Getting Started Guides with the following links: + * [Linux\*](https://software.intel.com/en-us/get-started-with-intel-oneapi-linux-get-started-with-the-intel-oneapi-iot-toolkit) + * [Windows\*](https://software.intel.com/en-us/get-started-with-intel-oneapi-windows-get-started-with-the-intel-oneapi-iot-toolkit) + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. diff --git a/Tools/IoTConnectionTools/hello-iot-world/cpp/CMakeLists.txt b/Tools/IoTConnectionTools/hello-iot-world/cpp/CMakeLists.txt new file mode 100644 index 0000000000..9f061f3f69 --- /dev/null +++ b/Tools/IoTConnectionTools/hello-iot-world/cpp/CMakeLists.txt @@ -0,0 +1,6 @@ +add_executable (hello-iot-world hello-iot-world.cpp) +if(WIN32) + add_custom_target (run hello-iot-world.exe) +else() + add_custom_target (run ./hello-iot-world) +endif() diff --git a/Tools/IoTConnectionTools/hello-iot-world/cpp/hello-iot-world.cpp b/Tools/IoTConnectionTools/hello-iot-world/cpp/hello-iot-world.cpp new file mode 100644 index 0000000000..5d2c4164ed --- /dev/null +++ b/Tools/IoTConnectionTools/hello-iot-world/cpp/hello-iot-world.cpp @@ -0,0 +1,22 @@ +/* ============================================================== + * Copyright (c) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * ============================================================== + */ + +#include + +using namespace std; + +int main() { + cout << "Hello, Internet of Things World!" << endl; +#ifdef __INTEL_COMPILER + cout << "The Intel(R) C++ Compiler was used for compiling this sample." + << endl; +#else + cout << "The Intel(R) C++ Compiler was not used for compiling this sample." + << endl; +#endif + return 0; +} diff --git a/Tools/IoTConnectionTools/hello-iot-world/sample.json b/Tools/IoTConnectionTools/hello-iot-world/sample.json new file mode 100644 index 0000000000..f236b3add8 --- /dev/null +++ b/Tools/IoTConnectionTools/hello-iot-world/sample.json @@ -0,0 +1,35 @@ +{ + "guid": "8EBFB820-A80C-4CC5-97DB-09B6161DDE1F", + "name": "Hello IoT World", + "categories": ["Toolkit/Intel® oneAPI IoT Toolkit/Intel® C++ Compiler"], + "description": "This is a basic sample that outputs the classic 'Hello World' message along with the compiler identification string.", + "os": ["linux", "windows"], + "toolchain": ["icc", "gcc"], + "languages": [{"cpp":{}}], + "ciTests": { + "linux": [ + { "id": "hello-iot-world", + "env": [], + "steps": [ + "mkdir build", + "cd build", + "cmake ..", + "make", + "make run" + ] + } + ], + "windows": [ + { "id": "hello-iot-world", + "env": [], + "steps": [ + "mkdir build", + "cd build", + "cmake -G \"NMake Makefiles\" ..", + "nmake", + "nmake run" + ] + } + ] + } +} diff --git a/Tools/IoTConnectionTools/interrupt/CMakeLists.txt b/Tools/IoTConnectionTools/interrupt/CMakeLists.txt new file mode 100644 index 0000000000..fde9f4671c --- /dev/null +++ b/Tools/IoTConnectionTools/interrupt/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required (VERSION 3.0) + +# Set default build type to RelWithDebInfo if not specified +if (NOT CMAKE_BUILD_TYPE) + message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") + set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE + STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" + FORCE) +endif() + +# Set language standard +set(CMAKE_CXX_STANDARD "11") + +project (INTERRUPT) + +# OS checks +if(WIN32) + message(FATAL_ERROR, "This sample cannot be compiled natively on Windows OS.") +endif() + +# Dependency checks +find_package(PkgConfig) +pkg_search_module (MRAA REQUIRED mraa) + +add_subdirectory(cpp) diff --git a/Tools/IoTConnectionTools/interrupt/License.txt b/Tools/IoTConnectionTools/interrupt/License.txt new file mode 100644 index 0000000000..2f3a9835da --- /dev/null +++ b/Tools/IoTConnectionTools/interrupt/License.txt @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * This program and the accompanying materials are made available under the + * terms of the The MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + */ \ No newline at end of file diff --git a/Tools/IoTConnectionTools/interrupt/README.md b/Tools/IoTConnectionTools/interrupt/README.md new file mode 100644 index 0000000000..d8e5fcff27 --- /dev/null +++ b/Tools/IoTConnectionTools/interrupt/README.md @@ -0,0 +1,37 @@ +# ISR + +## Introduction +This is a simple sample you could use for a quick test of an Interrupt Service Routine (ISR). + +## What it is +Demonstrate how to react on an external event with an ISR (Interrupt Service Routine), which will run independently of the main program flow using the Eclipse* MRAA library. + +## Hardware requirements +Use a platform with GPIO interrupt capabilities. +Any digital input or sensor that can generate a voltage transition from ground to Vcc or vice versa can be used with this example code. + +## Supported boards +This sample has been tested on +- [UP Squared\* AI Vision Kit](https://software.intel.com/en-us/iot/hardware/up-squared-ai-vision-dev-kit) +- [IEI\* Tank AIoT Developer Kit](https://software.intel.com/en-us/iot/hardware/iei-tank-dev-kit-core) + +The sample might need minor modifications depending on the board, pin and shield you are using. +*Note:* This sample does not work for the GPIO pins on the GrovePi+* shield. + +## Software requirements +This sample is supported on Linux systems only. + +This version of the sample has been tested on Ubuntu Linux. It requires the [Eclipse* MRAA library](https://github.com/intel-iot-devkit/mraa). + +This sample requires additional system configuration when using Ubuntu OS with the UP series boards. Instructions on how to install the custom provided Linux kernel with the required drivers can be [found here](https://wiki.up-community.org/Ubuntu#Ubuntu_18.04_installation_and_configuration). + +## Setup +Create a new project using this sample in Eclipse* IDE and after installing the Intel® oneAPI IoT Toolkit. +Connect the input device to a GPIO pin on your IoT board (pin 13 is used by default on most boards). + +## Note +Accessing device sensors, including LEDs, requires MRAA I/O operations. Mraa I/O operations require permissions to UNIX character devices and sysfs classes not commonly granted to normal users by default. +To learn how to use I/O devices from user space with the UP series boards refer to [this link](https://wiki.up-community.org/Ubuntu#Enable_the_HAT_functionality_from_userspace). + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. diff --git a/Tools/IoTConnectionTools/interrupt/cpp/CMakeLists.txt b/Tools/IoTConnectionTools/interrupt/cpp/CMakeLists.txt new file mode 100644 index 0000000000..0da869b4af --- /dev/null +++ b/Tools/IoTConnectionTools/interrupt/cpp/CMakeLists.txt @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MRAA_CFLAGS}") +add_executable (interrupt interrupt.cpp) +add_custom_target (run ./interrupt) +target_link_libraries(interrupt ${MRAA_LDFLAGS}) diff --git a/Tools/IoTConnectionTools/interrupt/cpp/interrupt.cpp b/Tools/IoTConnectionTools/interrupt/cpp/interrupt.cpp new file mode 100644 index 0000000000..c928c11dfa --- /dev/null +++ b/Tools/IoTConnectionTools/interrupt/cpp/interrupt.cpp @@ -0,0 +1,117 @@ +/* ============================================================== + * Copyright (c) 2015 - 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * ============================================================= */ + +/** + * Demonstrate how to react on an external event with an ISR (Interrupt Service + * Routine), which will run independently of the main program flow using the + * MRAA library. + * Any button or sensor that can generate a voltage transition from ground to + * Vcc or viceversa can be used with this example code. + * Suitable ones in the Grove Starter Kit are the Button and Touch Sensor, + * connected to a digital pin + * + * Use a platform with GPIO Interrupt capabilities + */ + +#include + +#include +#include + +using namespace std; +using namespace mraa; + +// counter that will be updated by the interrupt routine +static volatile int counter = 0; + +// ISR, update the value of the counter +void interrupt(void* args) { ++counter; } + +// leave warning/error message in console and wait for user to press Enter +void inputEnter(const string& str) { + cerr << str << endl << "Press Enter to continue..." << endl; + cin.get(); +} + +// check if running as root +void checkRoot(void) { + int euid = geteuid(); + if (euid) { + inputEnter( + "This project uses Mraa I/O operations that may require\n" + "'root' privileges, but you are running as non - root user.\n" + "Passwordless keys(RSA key pairs) are recommended \n" + "to securely connect to your target with root privileges. \n" + "See the project's Readme for more info.\n\n"); + } + return; +} + +// set pin values depending on the current board (platform) +void initPlatform(int& gpioPin) { + // check which board we are running on + Platform platform = getPlatformType(); + switch (platform) { + case INTEL_MINNOWBOARD_MAX: // Same for Minnowboard Turbot + case INTEL_JOULE_EXPANSION: + gpioPin = 26; + break; + case IEI_TANK: + gpioPin = 0; + break; + case UNKNOWN_PLATFORM: { + string unknownPlatformMessage = + "This sample uses the MRAA/UPM library for I/O access, " + "you are running it on an unrecognized platform. " + "You may need to modify the MRAA/UPM initialization code to " + "ensure it works properly on your platform.\n"; + inputEnter(unknownPlatformMessage); + break; + } + default: + break; + } + return; +} + +int main() { + // Check access permissions for the current user + // Can be commented out for targets with user level I/O access enabled + checkRoot(); + + int gpioPin = 13; + initPlatform(gpioPin); +#ifdef USING_GROVE_PI_SHIELD + addSubplatform(GROVEPI, "0"); +#endif + + // create a GPIO object from MRAA for the pin + Gpio* d_pin = new Gpio(gpioPin); + if (d_pin == NULL) { + inputEnter("Can't create mraa::Gpio object, exiting"); + return MRAA_ERROR_UNSPECIFIED; + } + + // set the pin as input + if (d_pin->dir(DIR_IN) != SUCCESS) { + inputEnter("Can't set digital pin as input, exiting"); + return MRAA_ERROR_UNSPECIFIED; + } + + // set the ISR, it will be executed on both edges + if (d_pin->isr(EDGE_BOTH, interrupt, NULL) != SUCCESS) { + inputEnter("Can't assign ISR to pin, exiting"); + return ERROR_UNSPECIFIED; + } + + // loop forever printing the counter value every second + for (;;) { + cout << "counter value " << counter << endl; + sleep(1); + } + + return SUCCESS; +} diff --git a/Tools/IoTConnectionTools/interrupt/sample.json b/Tools/IoTConnectionTools/interrupt/sample.json new file mode 100644 index 0000000000..29288d8ed9 --- /dev/null +++ b/Tools/IoTConnectionTools/interrupt/sample.json @@ -0,0 +1,22 @@ +{ + "guid": "E2BDAFFF-FF3F-4C83-B31A-D79DB6F091D9", + "name": "Interrupt service routine (ISR)", + "categories": ["Toolkit/Intel® oneAPI IoT Toolkit/IoT Connection Tools"], + "description": "Demonstrates how to react on an Eclipse* MRAA digital pin event with an ISR (Interrupt Service Routine), which will run independently of the main program flow.", + "dependencies": ["pkg|mraa|https://mraa.io"], + "languages": [{"cpp":{}}], + "os": ["linux"], + "ciTests": { + "linux": [ + { "id": "interrupt", + "env": [], + "steps": [ + "mkdir build", + "cd build", + "cmake ..", + "make" + ] + } + ] + } +} diff --git a/Tools/IoTConnectionTools/onboard-blink/CMakeLists.txt b/Tools/IoTConnectionTools/onboard-blink/CMakeLists.txt new file mode 100644 index 0000000000..5629999558 --- /dev/null +++ b/Tools/IoTConnectionTools/onboard-blink/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required (VERSION 3.0) + +# Set default build type to RelWithDebInfo if not specified +if (NOT CMAKE_BUILD_TYPE) + message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") + set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE + STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" + FORCE) +endif() + +# Set language standard +set(CMAKE_CXX_STANDARD "11") + +project (ONBOARD-BLINK) + +# OS checks +if(WIN32) + message(FATAL_ERROR, "This sample cannot be compiled natively on Windows OS.") +endif() + +# Dependency checks +find_package(PkgConfig) +pkg_search_module (MRAA REQUIRED mraa) + +add_subdirectory(cpp) diff --git a/Tools/IoTConnectionTools/onboard-blink/License.txt b/Tools/IoTConnectionTools/onboard-blink/License.txt new file mode 100644 index 0000000000..2f3a9835da --- /dev/null +++ b/Tools/IoTConnectionTools/onboard-blink/License.txt @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * This program and the accompanying materials are made available under the + * terms of the The MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + */ \ No newline at end of file diff --git a/Tools/IoTConnectionTools/onboard-blink/README.md b/Tools/IoTConnectionTools/onboard-blink/README.md new file mode 100644 index 0000000000..b4d6d31530 --- /dev/null +++ b/Tools/IoTConnectionTools/onboard-blink/README.md @@ -0,0 +1,34 @@ +# Onboard Blink + +## Introduction +This is a simple sample you could use for a quick IoT board test. + +## What it is +A blink sample, it turns the on-board LED on for one second, then off for one second, repeatedly. + +## Hardware requirements +A board with an on-board LED or an accessible GPIO pin (connected to a LED). + +## Supported boards +This sample has been tested on +- [UP Squared\* AI Vision Kit](https://software.intel.com/en-us/iot/hardware/up-squared-ai-vision-dev-kit) +- [IEI\* Tank AIoT Developer Kit](https://software.intel.com/en-us/iot/hardware/iei-tank-dev-kit-core) + +The sample might need minor modifications depending on the board, pin and shield you are using. + +## Software requirements +This sample is supported on Linux systems only. + +This version of the sample has been tested on Ubuntu Linux. It requires the [Eclipse* MRAA library](https://github.com/eclipse/mraa). + +This sample requires additional system configuration when using Ubuntu OS with the UP series boards. Instructions on how to install the custom provided Linux kernel with the required drivers can be [found here](https://wiki.up-community.org/Ubuntu#Ubuntu_18.04_installation_and_configuration). + +## Setup +Create a new project using the Eclipse* IDE and after installing the Intel® oneAPI IoT Toolkit. Make sure the on-board LED or the external LED is connected to the board. + +## Note +Accessing device sensors, including LEDs, requires MRAA I/O operations. Mraa I/O operations require permissions to UNIX character devices and sysfs classes not commonly granted to normal users by default. +To learn how to use I/O devices from user space with the UP series boards refer to [this link](https://wiki.up-community.org/Ubuntu#Enable_the_HAT_functionality_from_userspace). + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. diff --git a/Tools/IoTConnectionTools/onboard-blink/cpp/CMakeLists.txt b/Tools/IoTConnectionTools/onboard-blink/cpp/CMakeLists.txt new file mode 100644 index 0000000000..b80382828a --- /dev/null +++ b/Tools/IoTConnectionTools/onboard-blink/cpp/CMakeLists.txt @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MRAA_CFLAGS}") +add_executable (blink blink.cpp) +add_custom_target (run ./blink) +target_link_libraries(blink ${MRAA_LDFLAGS}) diff --git a/Tools/IoTConnectionTools/onboard-blink/cpp/blink.cpp b/Tools/IoTConnectionTools/onboard-blink/cpp/blink.cpp new file mode 100644 index 0000000000..1e852b759e --- /dev/null +++ b/Tools/IoTConnectionTools/onboard-blink/cpp/blink.cpp @@ -0,0 +1,117 @@ +/* ============================================================== + * Copyright (c) 2015 - 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * ============================================================= */ + +/* On-board LED Blink + * Turns the on-board LED on for one second, then off for one second, + * repeatedly. + */ + +#include + +#include +#include +#include + +// Define the following if using a Grove Pi Shield +#define USING_GROVE_PI_SHIELD +using namespace std; +using namespace mraa; + +// leave warning/error message in console and wait for user to press Enter +void consoleMessage(const string& str) { + cerr << str << endl; + sleep(10); +} + +// check if running as root +void checkRoot(void) { + int euid = geteuid(); + if (euid) { + consoleMessage( + "This project uses Mraa I/O operations that may require\n" + "'root' privileges, but you are running as non - root user.\n" + "Passwordless keys(RSA key pairs) are recommended \n" + "to securely connect to your target with root privileges. \n" + "See the project's Readme for more info.\n\n"); + } + return; +} + +// set pin values depending on the current board (platform) +void initPlatform(int& gpioPin) { + // check which board we are running on + Platform platform = getPlatformType(); + switch (platform) { + case INTEL_UP2: +#ifdef USING_GROVE_PI_SHIELD + gpioPin = 4 + 512; // D4 Connector (512 offset needed for the shield) + break; +#endif + case INTEL_UP: + case INTEL_EDISON_FAB_C: + case INTEL_GALILEO_GEN2: + break; + case INTEL_MINNOWBOARD_MAX: // Same for Minnowboard Turbot + gpioPin = 104; + break; + case INTEL_JOULE_EXPANSION: + gpioPin = 101; + break; + case IEI_TANK: + gpioPin = 1; + break; + default: + string unknownPlatformMessage = + "This sample uses the MRAA/UPM library for I/O access, " + "you are running it on an unrecognized platform. " + "You may need to modify the MRAA/UPM initialization code to " + "ensure it works properly on your platform.\n"; + consoleMessage(unknownPlatformMessage); + } + return; +} + +int main() { + // Check access permissions for the current user + // Can be commented out for targets with user level I/O access enabled + checkRoot(); + + int gpioPin = 13; + initPlatform(gpioPin); + +#ifdef USING_GROVE_PI_SHIELD + addSubplatform(GROVEPI, "0"); +#endif + + // create the pin object + Gpio* d_pin = new Gpio(gpioPin); + if (d_pin == NULL) { + consoleMessage("MRAA couldn't initialize GPIO, exiting."); + return MRAA_ERROR_UNSPECIFIED; + } + + // set the pin as output + if (d_pin->dir(DIR_OUT) != SUCCESS) { + consoleMessage("Can't set digital pin as output, exiting."); + return MRAA_ERROR_UNSPECIFIED; + } + + // loop forever toggling the on board LED every second + for (;;) { + if (d_pin->write(0) != SUCCESS) { + consoleMessage("MRAA cannot write pin value!"); + return MRAA_ERROR_UNSPECIFIED; + } + sleep(1); + if (d_pin->write(1) != SUCCESS) { + consoleMessage("MRAA cannot write pin value!"); + return MRAA_ERROR_UNSPECIFIED; + } + sleep(1); + } + + return SUCCESS; +} diff --git a/Tools/IoTConnectionTools/onboard-blink/sample.json b/Tools/IoTConnectionTools/onboard-blink/sample.json new file mode 100644 index 0000000000..12b9bedfad --- /dev/null +++ b/Tools/IoTConnectionTools/onboard-blink/sample.json @@ -0,0 +1,22 @@ +{ + "guid": "892964F4-89DC-4E48-8511-8FCF6AE1A8D6", + "name": "On-Board LED Blink", + "categories": ["Toolkit/Intel® oneAPI IoT Toolkit/IoT Connection Tools"], + "description": "Demonstrates how to blink the on board LED, by writing a digital value to an output pin using the Eclipse* MRAA library", + "dependencies": ["pkg|mraa|https://mraa.io"], + "languages": [{"cpp":{}}], + "os": ["linux"], + "ciTests": { + "linux": [ + { "id": "onboard-blink", + "env": [], + "steps": [ + "mkdir build", + "cd build", + "cmake ..", + "make" + ] + } + ] + } +} diff --git a/Tools/IoTConnectionTools/pwm/CMakeLists.txt b/Tools/IoTConnectionTools/pwm/CMakeLists.txt new file mode 100644 index 0000000000..634a3ccef3 --- /dev/null +++ b/Tools/IoTConnectionTools/pwm/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required (VERSION 3.0) + +# Set default build type to RelWithDebInfo if not specified +if (NOT CMAKE_BUILD_TYPE) + message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") + set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE + STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" + FORCE) +endif() + +# Set language standard +set(CMAKE_CXX_STANDARD "11") + +project (PWM) + +# OS checks +if(WIN32) + message(FATAL_ERROR, "This sample cannot be compiled natively on Windows OS.") +endif() + +# Dependency checks +find_package(PkgConfig) +pkg_search_module (MRAA REQUIRED mraa) + +add_subdirectory(cpp) diff --git a/Tools/IoTConnectionTools/pwm/License.txt b/Tools/IoTConnectionTools/pwm/License.txt new file mode 100644 index 0000000000..2f3a9835da --- /dev/null +++ b/Tools/IoTConnectionTools/pwm/License.txt @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * This program and the accompanying materials are made available under the + * terms of the The MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + */ \ No newline at end of file diff --git a/Tools/IoTConnectionTools/pwm/README.md b/Tools/IoTConnectionTools/pwm/README.md new file mode 100644 index 0000000000..07e08a1895 --- /dev/null +++ b/Tools/IoTConnectionTools/pwm/README.md @@ -0,0 +1,38 @@ +# PWM + +## Introduction +This is a simple sample you could use for a quick test of PWM output. + +## What it is +This project demonstrates how to write a value to an output pin using the Eclipse* MRAA library. +If the output is connected to a led, its intensity, as perceived by the human eye, will vary depending on the duty cycle. + +## Hardware requirements +A board with an accessible PWM pin. +Some output device that can accept voltage variations such as an 'LED' or 'Speaker' from Starter Kits. + +## Supported boards +This sample has been tested on +- [UP Squared\* AI Vision Kit](https://software.intel.com/en-us/iot/hardware/up-squared-ai-vision-dev-kit) +- [IEI\* Tank AIoT Developer Kit](https://software.intel.com/en-us/iot/hardware/iei-tank-dev-kit-core) + +The sample might need minor modifications depending on the board, pin and shield you are using. + +## Software requirements +This sample is supported on Linux systems only. + +This version of the sample has been tested on Ubuntu Linux. It requires the [Eclipse* MRAA library](https://github.com/intel-iot-devkit/mraa). + +This sample requires additional system configuration when using Ubuntu OS with the UP series boards. Instructions on how to install the custom provided Linux kernel with the required drivers can be [found here](https://wiki.up-community.org/Ubuntu#Ubuntu_18.04_installation_and_configuration). + +## Setup +Create a new project using this sample in Eclipse* IDE and after installing the Intel® oneAPI IoT Toolkit. +Connect the output device to a valid PWM pin on your IoT board. To find a PWM pin refer to your board's +specifications document. + +## Note +Accessing device sensors, including LEDs, requires MRAA I/O operations. Mraa I/O operations require permissions to UNIX character devices and sysfs classes not commonly granted to normal users by default. +To learn how to use I/O devices from user space with the UP series boards refer to [this link](https://wiki.up-community.org/Ubuntu#Enable_the_HAT_functionality_from_userspace). + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. diff --git a/Tools/IoTConnectionTools/pwm/cpp/CMakeLists.txt b/Tools/IoTConnectionTools/pwm/cpp/CMakeLists.txt new file mode 100644 index 0000000000..82cc7d3e44 --- /dev/null +++ b/Tools/IoTConnectionTools/pwm/cpp/CMakeLists.txt @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MRAA_CFLAGS}") +add_executable (pwm pwm.cpp) +add_custom_target (run ./pwm) +target_link_libraries(pwm ${MRAA_LDFLAGS}) diff --git a/Tools/IoTConnectionTools/pwm/cpp/pwm.cpp b/Tools/IoTConnectionTools/pwm/cpp/pwm.cpp new file mode 100644 index 0000000000..1563f8d9d5 --- /dev/null +++ b/Tools/IoTConnectionTools/pwm/cpp/pwm.cpp @@ -0,0 +1,110 @@ +/* ============================================================== + * Copyright (c) 2015 - 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * ============================================================= */ + +/* PWM + * Write values to a gpio digital output pin. + */ + +#include + +#include +#include + +#define USING_GROVE_PI_SHIELD +using namespace std; +using namespace mraa; + +// leave warning/error message in console and wait for user to press Enter +void consoleMessage(const string& str) { + cerr << str << endl; + sleep(10); +} + +// check if running as root +void checkRoot(void) { + int euid = geteuid(); + if (euid) { + consoleMessage( + "This project uses Mraa I/O operations that may require\n" + "'root' privileges, but you are running as non - root user.\n" + "Passwordless keys(RSA key pairs) are recommended \n" + "to securely connect to your target with root privileges. \n" + "See the project's Readme for more info.\n\n"); + } + return; +} + +// set pin values depending on the current board (platform) +void initPlatform(int& pwmPin) { + // check which board we are running on + Platform platform = getPlatformType(); + switch (platform) { + case INTEL_UP2: +#ifdef USING_GROVE_PI_SHIELD + pwmPin = 5 + 512; // D5 works as PWM on Grove PI Shield + break; +#endif + break; + default: + string unknownPlatformMessage = + "This sample uses the MRAA/UPM library for I/O access, " + "you are running it on an unrecognized platform. " + "You may need to modify the MRAA/UPM initialization code to " + "ensure it works properly on your platform.\n\n"; + consoleMessage(unknownPlatformMessage); + } + return; +} + +int main() { + // Check access permissions for the current user + // Can be commented out for targets with user level I/O access enabled + checkRoot(); + + int pwmPin = 33; + initPlatform(pwmPin); + +#ifdef USING_GROVE_PI_SHIELD + addSubplatform(GROVEPI, "0"); +#endif + + // note that not all digital pins can be used for PWM, the available ones + // are usually marked with a ~ on the board's silk screen + Pwm* pwm_pin = new Pwm(pwmPin); + if (pwm_pin == NULL) { + consoleMessage("Can't create mraa::Pwm object, exiting"); + return MRAA_ERROR_UNSPECIFIED; + } + + // enable PWM on the selected pin + if (pwm_pin->enable(true) != SUCCESS) { + consoleMessage("Cannot enable PWM on mraa::PWM object, exiting"); + return MRAA_ERROR_UNSPECIFIED; + } + + // PWM duty_cycle value, 0.0 == 0%, 1.0 == 100% + float duty_cycle = 0.0; + + // select a pulse width period of 1ms + int period = 1; + + // loop forever increasing the PWM duty cycle from 0% to 100%, + // a full cycle will take ~5 seconds + for (;;) { + pwm_pin->pulsewidth_ms(period); + if (pwm_pin->write(duty_cycle) != SUCCESS) { + consoleMessage("MRAA cannot write duty cycle!"); + return ERROR_UNSPECIFIED; + } + usleep(50000); + duty_cycle += 0.01; + if (duty_cycle > 1.0) { + duty_cycle = 0.0; + } + } + + return SUCCESS; +} diff --git a/Tools/IoTConnectionTools/pwm/sample.json b/Tools/IoTConnectionTools/pwm/sample.json new file mode 100644 index 0000000000..269b762e82 --- /dev/null +++ b/Tools/IoTConnectionTools/pwm/sample.json @@ -0,0 +1,22 @@ +{ + "guid": "A377C93A-6D81-4030-B2AD-BE85B6CE8450", + "name": "Pulse Width Modulation (PWM)", + "categories": ["Toolkit/Intel® oneAPI IoT Toolkit/IoT Connection Tools"], + "description": "Demonstrate how to use PWM with an output pin using the Eclipse* MRAA library. If the output is connected to a led, its brightness will vary depending on the duty cycle.", + "dependencies": ["pkg|mraa|https://mraa.io"], + "languages": [{"cpp":{}}], + "os": ["linux"], + "ciTests": { + "linux": [ + { "id": "pwm", + "env": [], + "steps": [ + "mkdir build", + "cd build", + "cmake ..", + "make" + ] + } + ] + } +} diff --git a/Tools/IoTConnectionTools/up2-leds/CMakeLists.txt b/Tools/IoTConnectionTools/up2-leds/CMakeLists.txt new file mode 100644 index 0000000000..40fcc52845 --- /dev/null +++ b/Tools/IoTConnectionTools/up2-leds/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required (VERSION 3.0) + +# Set default build type to RelWithDebInfo if not specified +if (NOT CMAKE_BUILD_TYPE) + message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info") + set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE + STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" + FORCE) +endif() + +# Set language standard +set(CMAKE_CXX_STANDARD "11") + +project (UP2-LEDS) + +# OS checks +if(WIN32) + message(FATAL_ERROR, "This sample cannot be compiled natively on Windows OS.") +endif() + +# Dependency checks +find_package(PkgConfig) +pkg_search_module (MRAA REQUIRED mraa) + +add_subdirectory(cpp) diff --git a/Tools/IoTConnectionTools/up2-leds/License.txt b/Tools/IoTConnectionTools/up2-leds/License.txt new file mode 100644 index 0000000000..2f3a9835da --- /dev/null +++ b/Tools/IoTConnectionTools/up2-leds/License.txt @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * This program and the accompanying materials are made available under the + * terms of the The MIT License which is available at + * https://opensource.org/licenses/MIT. + * + * SPDX-License-Identifier: MIT + */ \ No newline at end of file diff --git a/Tools/IoTConnectionTools/up2-leds/README.md b/Tools/IoTConnectionTools/up2-leds/README.md new file mode 100644 index 0000000000..b8ed88f5d4 --- /dev/null +++ b/Tools/IoTConnectionTools/up2-leds/README.md @@ -0,0 +1,35 @@ +# UP Squared* Built-in LEDs + +## Introduction +This is a simple sample that can be used to blink the built-in LEDs on the UP Squared board. + +## What it is +The main purpose of this sample is to showcase the new LED class and APIs added to the Eclipse* MRAA library. + +## Hardware requirements +An [UP Squared](http://www.up-board.org/) board. No additional hardware required. + +## Supported boards +This sample is intended for the [UP Squared](http://www.up-board.org/) board. + +This sample has been tested on +- [UP Squared\* AI Vision Kit](https://software.intel.com/en-us/iot/hardware/up-squared-ai-vision-dev-kit) + +With minor modifications, it will run on any Linux board that exposes built-in LEDs using the gpio-leds +Linux kernel driver. + +## Software requirements +This version of the sample has been tested on Ubuntu Linux but should be compatible with Ubilinux for the UP Squared as well. +It requires the [Eclipse* MRAA library](https://github.com/intel-iot-devkit/mraa) version 1.9.0 or newer. + +This sample requires additional system configuration when using Ubuntu OS with the UP series boards. Instructions on how to install the custom provided Linux kernel with the required drivers can be [found here](https://wiki.up-community.org/Ubuntu#Ubuntu_18.04_installation_and_configuration). + +## Setup +Create a new project using this sample in Eclipse* IDE and after installing the Intel® oneAPI IoT Toolkit. Run it on the UP Squared board using a TCF connection. + +## Note +Accessing device sensors, including LEDs, requires MRAA I/O operations. Mraa I/O operations require permissions to UNIX character devices and sysfs classes not commonly granted to normal users by default. +To learn how to use I/O devices from user space with the UP series boards refer to [this link](https://wiki.up-community.org/Ubuntu#Enable_the_HAT_functionality_from_userspace). + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. diff --git a/Tools/IoTConnectionTools/up2-leds/c/CMakeLists.txt b/Tools/IoTConnectionTools/up2-leds/c/CMakeLists.txt new file mode 100644 index 0000000000..30ae409981 --- /dev/null +++ b/Tools/IoTConnectionTools/up2-leds/c/CMakeLists.txt @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MRAA_CFLAGS}") +add_executable (up2-leds up2-leds.c) +add_custom_target (run ./up2-leds) +target_link_libraries(up2-leds ${MRAA_LDFLAGS}) diff --git a/Tools/IoTConnectionTools/up2-leds/c/up2-leds.c b/Tools/IoTConnectionTools/up2-leds/c/up2-leds.c new file mode 100644 index 0000000000..d86db66d3d --- /dev/null +++ b/Tools/IoTConnectionTools/up2-leds/c/up2-leds.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2018 - 2020 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include + +//#include "mraa/common.hpp" +//#include "mraa/led.hpp" + +// Define min and max brightness +#define LED_ON 255 +#define LED_OFF 0 + +// This boolean controls the main loop +volatile bool should_run = true; + +// Interrupt signal handler function +void sig_handler(int signum) +{ + if (signum == SIGINT) { + printf("Exiting...\n"); + should_run = false; + } +} + +// leave warning/error message in console and wait for user to press Enter +void consoleMessage(char* str) +{ + printf("%s\n", str); + sleep(10); +} + +// check if running as root +void checkRoot(void) +{ + int euid = geteuid(); + if (euid) { + fprintf(stderr, "This project uses Mraa I/O operations that may require\n" + "'root' privileges, but you are running as non - root user.\n" + "Passwordless keys(RSA key pairs) are recommended \n" + "to securely connect to your target with root privileges. \n" + "See the project's Readme for more info.\n\n"); + } + return; +} + +// Main function +int main() +{ + //Check access permissions for the current user + //Can be commented out for targets with user level I/O access enabled + checkRoot(); + + // Perform a basic platform and version check + if (mraa_get_platform_type() != MRAA_UP2) { + fprintf(stderr, "This example is meant for the UP Squared board.\n" + "Running it on different platforms will likely require code changes!\n"); + } + + if (strcmp(mraa_get_version(), "v1.9.0") < 0) { + fprintf(stderr,"You need MRAA version 1.9.0 or newer to run this sample!\n"); + return 1; + } + + // Register handler for keyboard interrupts + signal(SIGINT, sig_handler); + + // Define our LEDs + const int led_no = 4; + char led_names[4][7] = {"red", "green", "yellow", "blue"}; + mraa_led_context leds[led_no]; + + // Initialize them + for (int i = 0; i < led_no; ++i) { + leds[i] = mraa_led_init_raw(led_names[i]); + } + + // Blink them in order and pause in-between + while (should_run) { + for (int i = 0; i < led_no; i++) { + mraa_led_set_brightness(leds[i],LED_ON); + usleep(200000); + mraa_led_set_brightness(leds[i],LED_OFF); + } + usleep(200000); + } + + // Cleanup and exit + for (int i = 0; i < led_no; i++) { + free(leds[i]); + } + return 0; +} diff --git a/Tools/IoTConnectionTools/up2-leds/cpp/CMakeLists.txt b/Tools/IoTConnectionTools/up2-leds/cpp/CMakeLists.txt new file mode 100644 index 0000000000..3887d5c5fe --- /dev/null +++ b/Tools/IoTConnectionTools/up2-leds/cpp/CMakeLists.txt @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MRAA_CFLAGS}") +add_executable (up2-leds up2-leds.cpp) +add_custom_target (run ./up2-leds) +target_link_libraries(up2-leds ${MRAA_LDFLAGS}) diff --git a/Tools/IoTConnectionTools/up2-leds/cpp/up2-leds.cpp b/Tools/IoTConnectionTools/up2-leds/cpp/up2-leds.cpp new file mode 100644 index 0000000000..93b6371222 --- /dev/null +++ b/Tools/IoTConnectionTools/up2-leds/cpp/up2-leds.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2018 - 2020 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include + +#include +#include + +#include "mraa/common.hpp" +#include "mraa/led.hpp" + +// Define min and max brightness +#define LED_ON 255 +#define LED_OFF 0 + +// This boolean controls the main loop +volatile bool should_run = true; + +// Interrupt signal handler function +void sig_handler(int signum) { + if (signum == SIGINT) { + std::cout << "Exiting..." << std::endl; + should_run = false; + } +} + +// leave warning/error message in console and wait for user to press Enter +void consoleMessage(const std::string& str) { + std::cerr << str << std::endl; + sleep(10); +} + +// check if running as root +void checkRoot(void) { + int euid = geteuid(); + if (euid) { + consoleMessage( + "This project uses Mraa I/O operations that may require\n" + "'root' privileges, but you are running as non - root user.\n" + "Passwordless keys(RSA key pairs) are recommended \n" + "to securely connect to your target with root privileges. \n" + "See the project's Readme for more info.\n\n"); + } + return; +} + +// Main function +int main() { + // Check access permissions for the current user + // Can be commented out for targets with user level I/O access enabled + checkRoot(); + + // Perform a basic platform and version check + if (mraa::getPlatformType() != mraa::INTEL_UP2) { + consoleMessage( + "This example is meant for the UP Squared board.\n" + "Running it on different platforms will likely require code changes!"); + } + + if (mraa::getVersion().compare("v1.9.0") < 0) { + consoleMessage("You need MRAA version 1.9.0 or newer to run this sample!"); + return 1; + } + + // Register handler for keyboard interrupts + signal(SIGINT, sig_handler); + + // Define our LEDs + std::string led_names[] = {"red", "green", "yellow", "blue"}; + int led_no = sizeof(led_names) / sizeof(led_names[0]); + mraa::Led** leds = new mraa::Led*[led_no]; + + // Initialize them + for (int i = 0; i < led_no; i++) { + leds[i] = new mraa::Led(led_names[i].c_str()); + } + + // Blink them in order and pause in-between + while (should_run) { + for (int i = 0; i < led_no; i++) { + leds[i]->setBrightness(LED_ON); + usleep(200000); + leds[i]->setBrightness(LED_OFF); + } + usleep(200000); + } + + // Cleanup and exit + for (int i = 0; i < led_no; i++) { + delete leds[i]; + } + delete[] leds; + return 0; +} diff --git a/Tools/IoTConnectionTools/up2-leds/sample.json b/Tools/IoTConnectionTools/up2-leds/sample.json new file mode 100644 index 0000000000..78afe7510d --- /dev/null +++ b/Tools/IoTConnectionTools/up2-leds/sample.json @@ -0,0 +1,22 @@ +{ + "guid": "F8E69741-0BE3-4CB7-BC17-2F63563D80C5", + "name": "UP Squared Built-in LEDs", + "categories": ["Toolkit/Intel® oneAPI IoT Toolkit/IoT Connection Tools"], + "description": "This sample shows how to use the LED class and APIs of the Eclipse* MRAA library. It is intended to run on the UP Squared board, and will utilize the 4 built-in color LEDs located under the Ethernet ports. No additional hardware is required.", + "dependencies": ["pkg|mraa|https://mraa.io"], + "languages": [{"cpp":{}}], + "os": ["linux"], + "ciTests": { + "linux": [ + { "id": "up2-leds", + "env": [], + "steps": [ + "mkdir build", + "cd build", + "cmake ..", + "make" + ] + } + ] + } +} diff --git a/Tools/SystemDebug/system_debug_sample/License.txt b/Tools/SystemDebug/system_debug_sample/License.txt new file mode 100644 index 0000000000..65315c87a4 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample/License.txt @@ -0,0 +1,8 @@ +Copyright 2020 Intel Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/Tools/SystemDebug/system_debug_sample/README.md b/Tools/SystemDebug/system_debug_sample/README.md new file mode 100644 index 0000000000..9a6695e9b8 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample/README.md @@ -0,0 +1,47 @@ +# `Intel® System Debugger` Samples + + +| Optimized for | Description +|:--- |:--- +| OS | Linux* Ubuntu* 18.04, Windows 10 +| Hardware | Aaeon UpXtreme +| Software | Intel® oneAPI System Debugger + +## Purpose + +This sample relates to the basic usage of components of the Intel System Debugger. + +As a first step, please checkout the following git repository: + +```git clone https://github.com/intel/IoTKit-code-samples``` + +The folder `system_debug_build` contains both source and documentation for how to use these components. + + These are the following: + +`efi_application` : example efi application that can be used to demo the functionality of source level debugging. + +`docs` : RST documentation for tutorials of components. + +`python` : Python code making use of the component python interfaces (if applicable). + + +### Docs + +`EFIAppliction.rst` : Documentation of how to build and flash the EFI application. + +`WinDbgSample.rst` : Sample of how to use the `Intel® Debugger Extension for WinDbg` to debug a real bios. + +`TCASample.rst` : Sample of how to use the `Intel® System Debugger` to connect to a real target. + +`SysTraceSample.rst` : Sample of how to use the `Intel® System Debugger for System Trace` to work with a precollected trace file. + +`SysDbgSample.rst` : Sample of how to use the `Intel® System Debugger for System Debug` to work with the example UEFI application provided to debug bare metal applications. + +## Licence + +This code sample is licensed under MIT license. + + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. diff --git a/Tools/SystemDebug/system_debug_sample/sample.json b/Tools/SystemDebug/system_debug_sample/sample.json new file mode 100644 index 0000000000..8cf7083a88 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample/sample.json @@ -0,0 +1,27 @@ +{ + "guid": "668A3FF9-12C3-4559-8AF4-54B6792122D3", + "name": "Intel System Debugger Tutorial (Overview)", + "categories": ["Toolkit/Intel® oneAPI IoT Toolkit/System Debugger"], + "description": "Demonstrate basic functionality of the Intel System Debugger.", + "os": ["linux", "windows"], + "languages": [{"python":{},"cpp":{}}], + "ciTests": { + "linux": [ + { "id": "system_debug_sample", + "env": [], + "steps": [ + "[[ -f README.md ]]" + ] + } + ], + "windows": [ + { "id": "system_debug_sample", + "env": [], + "steps": [ + "if exist README.md ( exit /b 0 ) else ( exit /b 1 )" + ] + } + ] + } +} + diff --git a/Tools/SystemDebug/system_debug_sample_build/License.txt b/Tools/SystemDebug/system_debug_sample_build/License.txt new file mode 100644 index 0000000000..65315c87a4 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/License.txt @@ -0,0 +1,8 @@ +Copyright 2020 Intel Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/EFIApplication.rst b/Tools/SystemDebug/system_debug_sample_build/docs/EFIApplication.rst new file mode 100644 index 0000000000..2e46b2385f --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/docs/EFIApplication.rst @@ -0,0 +1,297 @@ +########################### +``EFI Application`` Sample +########################### + +============================ +Building the EFI Application +============================ + ++-----------------+-----------------------------------------------------------------------------+ +| Optimized for | Description | ++=================+=============================================================================+ +| OS | Linux\* Ubuntu\* 18.04, Windows 10, Fedora 32, MacOS 10.15 | ++-----------------+-----------------------------------------------------------------------------+ +| Hardware | Any machine which has an EFI based bios (UpXtreme detailed here) | ++-----------------+-----------------------------------------------------------------------------+ +| Software | Intel® oneAPI C++ Compiler (beta), Visual Studio, GCC-9, GCC-10, Clang-10 | ++-----------------+-----------------------------------------------------------------------------+ + +License +------- + +This code sample is licensed under MIT license. + +Hardware +------------ + +For this sample, we recommend you use the `Aaeon Upxtreme `_. + +This is a Whiskeylake based design. + + +To perform source level debugging, you will have to flash the debug bios on the device. + +This can be done by downloading the debug firmware package `Here `_. + +Then, put these files to a USB stick, boot the UpXtreme to an EFI shell (more detailed instructions detailed on above link), and run the GO_entire.nsh script. + +Now - reboot the target and press F2 to go into the bios settings. You will see a password page. + +Please enter the default password **upassw0rd** + +First, lets change the boot order to boot from USB first. Go to the **BOOT** section in the bios, and change *Boot Option #1* to your desired USB stick. + + +Then, to enable debugging, go to **CRB Setup** -> **CRB Advanced** -> **Debug Settings** + +Then, enable the following: + +**Platform Debug Consent** - change this to *Enabled (usb3 Dbc)* + +Then, go to Advanced Debug Settings: + +Make sure **CPU Run Control** is enabled. And enable processor trace memory allocation to **128MB**. Then set **Processor Trace** to enabled. +Then, finally make sure **Processor Trace output Scheme** is set to **Single Range Output**. + +Now, go back (by pressing esc) to the CRB main menu. Go to **CRB Save & Exit** and click **Save Changes and Exit**. + +Now, you can plug the DbC cable into your Host and the UpXtreme. The DBC cable is a Usb 3 cable, with no power pins. You can buy a cable +`from Design in Tools `_. + + + + + +Toolchains +-------------- + +for this, we assume you have a toolchain correctly installed. + +On windows, we have tested with the Visual Studio 2019 compiler, and the +Intel®C compiler, included with OneAPI. + +On linux, icc , clang and gcc are all supported. + +Mac OS +^^^^^^ + +To build on mac OS - you will require a cross compiler to build the elf +binaries (as mach-o binaries are not easily convertable to efi pe32+ +format), and the debugger does not support MachO symbols. ma + +The easiest way of getting this, is to use homebrew (https://brew.sh/) +and install the x86\_64-elf-gcc formula. + +``brew install x86_64-elf-gcc`` + +build Process +-------------- + +To build the efi applcation, please clone the repository. + +``git clone https://github.com/intel/IoTKit-code-samples`` + +Then cd to the location of the efi application. + +``cd system_debug_sample_build/efi_application/`` + +Then - clone all of the submodules + +``git submodule update --init`` + +Edk2 basetools +^^^^^^^^^^^^^^^^ + +On windows, you will either need to build edk2 basetools, or get the +prebuilt binaries. + +The easiest way to get the prebuilt binaries is to clone the git repo. + +| ``cd /system_debugger/efi_application/efi/BaseTools/Bin`` + +| ``git clone https://github.com/tianocore/edk2-BaseTools-win32.git Win32`` + +Alternatively, you can build the basetools yourself. For this, you will +need to have visual studio installed, and python. + +First, you will have to add nmake to your PATH environment variable. +NMAKE is located in the visual studio directory. + + +| Then, install the edk2-pytool-library with + +``pip install edk2-pytool-library`` + +Then, change to the edk2 basetools directory. + +``cd /system_debugger/efi_application/edk2/BaseTools`` + +Then update all of the edk2 submodules. + +``git submodule update --init --recursive`` + +Now, run the basetools build command. This is as follows: + +``python Edk2ToolsBuild.py -t vs2019`` + +Where vs2019 is the visual studio 2019 compiler - For vs2017 the command +would be: + +``python Edk2ToolsBuild.py -t vs2017`` + +If there are any errors, the build logs can be seen in: + +``\system_debugger\efi_application\edk2\BaseTools\BaseToolsBuild\`` + + +Building +^^^^^^^^^^^^^^^^ + +Now - make the cmake project, making sure to specify it is a 64 bit +architecture. + +``mkdir build`` + +``cd build`` + +To build the efi application, we use the ``cmake`` build system to +generate the build system. + +We do this with: + +``cmake ..`` + +then - on windows you will see a Visual Studio solution in the ``build`` +directory, uxdbgapp.sln, on POSIX systems you will see a MakeFile in the +build folder. + +You can then build this by issuing the following command: + +``cmake --build .`` + +Or, + +on Windows, you can open the visual studio solution, and build the +uxdbgapp target. + +On POSIX, you can run the makefile with ``make -j``. + +windows builders +^^^^^^^^^^^^^^^^ +On windows, the output will be in the ``Debug`` folder in the build +directory. + + +output files +------------ + +This will output the following files: + +Universal +^^^^^^^^^ + +``uxdbgapp.efi`` - this is the efi appication we need to flash to the +device + +linux builders +^^^^^^^^^^^^^^ + +``uxdbgapp.so`` - this is the file containing the DWARF debug symbols on +linux + +mac builders +^^^^^^^^^^^^ +``uxdbgapp.dylib`` - this is the *ELF* file containing the DWARF debug +symbols on mac OS. + + +Windows Builders +^^^^^^^^^^^^^^^^ + +``uxdbgapp.pdb`` - this is the file containing the CodeView debug +symbols on windows + +``uxdbgapp-te.efi`` - this is the efi image in TERSE executable format + +``uxdbgapp-te.pdb`` - this is the file containing the CodeView debug +symbols on windows for the Terse executable + + +Flashing the EFI Application to a USB +------------------------------------------ + +Linux and Mac +^^^^^^^^^^^^^^ + +Copy the ``uxdbgapp.efi`` file into the ``tools`` folder. + +Open a terminal, ``cd`` to the tools folder, and execute the script as +follows: + +``./make_boot_media.sh uxdbgapp.efi `` + + +NOTE +---- + +if you have issues with permissions, you might have to make the script +executable. + +you can do this by issueing the following command in terminal: + +``chmod +x make_boot_media.sh`` + +you can find information on the disks by using the following: + +mac OS +-------- + +``diskutil list`` + +linux +-------- + +``sudo fdisk -l`` + +Windows +------------ + +Start the powershell script, from a powershell prompt. + +If required, accept the access request for admin rights. + +Then, select the .efi file using the file browser. + +Next, select the usb device you would like to flash to. + +Example Steps (Linux) +------------------------ + +:: + + mkdir build + cd build + cmake .. + cmake --build . + chmod +x make_boot_media.sh + ../make_boot_media.sh uxdbgapp.efi /dev/sdb + +if you recieve execution errors +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You might have to change your powershell execution policy. This can be +done with the following comman in powershell: +``Set-ExecutionPolicy Unrestricted`` + +Disclaimer +---------- + +IMPORTANT NOTICE: This software is sample software. It is not designed +or intended for use in any medical, life-saving or life-sustaining +systems, transportation systems, nuclear systems, or for any other +mission-critical application in which the failure of the system could +lead to critical injury or death. The software may not be fully tested +and may contain bugs or errors; it may not be intended or suitable for +commercial release. No regulatory approvals for the software have been +obtained, and therefore software may not be certified for use in certain +countries or environments. diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/SystemDebugger.rst b/Tools/SystemDebug/system_debug_sample_build/docs/SystemDebugger.rst new file mode 100644 index 0000000000..d9ad137f1d --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/docs/SystemDebugger.rst @@ -0,0 +1,241 @@ + +``Intel® System Debugger - System Debug`` Basic Usage Sample +============================================================= + ++---------------+------------------------------------+ +| Optimized for | Description | ++===============+====================================+ +| OS | Linux\* Ubuntu\* 18.04, Windows 10 | ++---------------+------------------------------------+ +| Hardware | Aaeon UpXtreme | ++---------------+------------------------------------+ +| Software | Intel® oneAPI System Debugger | ++---------------+------------------------------------+ + +What it is +---------- + +This project demonstrates how you would use the Intel® system debugger +for system debug to find a bug in an example EFI application. + +Licence +------- + +This code sample is licensed under MIT license. + +Software requirements +--------------------- + +This sample works on both Linux and Windows. + +This sample has been tested on Windows 10, and requires a working OneAPI +IOT or OneAPI System Bring up installed. + +Creating a bug +-------------- + +Lets make a simple “bug”. This, of course, isn’t really a bug - but will +be a write to an io port, that we will use the debugger to “catch”. + +We can do this by using the efi application described +`here. <./EFIApplication.ipynb>`__. + +To write to this IO port - we need to build the efi app with the cmake +option BAD=ON. + +``cmake .. -DBAD=ON`` + +Flash the resulting ``uxdbgapp.efi`` to a USB stick, using the provided +tools (described `here. <./EFIApplication.ipynb>`__ ) and boot from this +on the upxtreme target. + +Basics of the Intel® System Debugger +------------------------------------ + +So, lets use Intel® System Studio to connect to the target. This is +explained in section `Connection with TCA <./TCA.ipynb>`__. +``intel.sysdbg.connect()`` Once we are connected, we should see the +following: |firstview| + +Now, we can halt the target using the |halt| button. + +``target.suspend()`` + +We can then load the sources, of the binary that is currently running on +the target. This is done using the |loadthis| button + +``threads[0].symbols.load_this()`` + +.. raw:: html + + + +.. raw:: html + + + +We can then evaluate the value of a symbol |variables| + +``threads[0].frames[0].symbols.find("x")[0].value().string()`` + +To go to the next instruction, we can perform step operations. There are +three types of *step*: + +Step into |stepin| continue execution into the function that is +currently shown (not applicable in disasssembly). + +``threads[0].runcontrol.step()`` + +step over |stepover| continue execution until the next line. + +Source Lines: +``threads[0].runcontrol.step(stepType=tcf.services.runcontrol.RM_STEP_OVER_LINE)`` + +Instructions: +``threads[0].runcontrol.step(stepType=tcf.services.runcontrol.RM_STEP_OVER)`` + +Note- if we want to step in assembly, we should use instruction stepping +mode - this is denoted with |istep|. + +step out: |stepout| continue execution until we leave the current +function. + +``threads[0].runcontrol.step(stepType=tcf.services.runcontrol.RM_STEP_OUT)`` + +Using the system Debugger to find the bug +----------------------------------------- + +Let’s ensure the target is in the state we want it to be. + +We do this by setting a reset breakpoint: |bpadd| |resetbut| + +``threads[0].breakpoints.add(condition="Reset")`` + +Then we reset the target using |resetbut|. The target should then halt at +the reset vector. + +``target.platform.reset()`` + +Now, lets set the IO breakpoint. The *BAD* cmake option in the efi +application writes to port ``0x90``. + +This breakpoint can be set like this: |addbp| |iobp| + +``threads[0].breakpoints.add(condition="io_port:0x90")`` + +Lets use Instruction Tracing to track the targets execution. + +We do this by going to \*Window-> Show View -> Instruction Trace View + +You should see the following window. |itraceempty| + +To enable trace, please click the configure button |itraceconfig| + +Now, select *LBR* from the configuration menu. |itraceselect| + +and then enable the trace with |itraceenable| + +Now, lets resume the target using the |resume| button. The target should +then stop where the IO write happens. + +``target.resume()`` + +After the target halts, the instruction trace should be shown in the +instruction trace view. + +``threads[0].lbr.read(0, 100)`` + +From here we can use the debugger features to figure out what went wrong +in our code. + +##Using an Int1 to Communicate with the debugger + +Instead of using the IO port write, we can also use an Int1 exception to +communicate with the debugger. + +This is what the ``notify_debugger_int(int value)`` function does in the +``main.c`` file in the ``uxdbgapp``. + +This is the default method to communicate with the debugger. + +This can be set using the following + +|addbp| +|int1bp| + +``threads[0].breakpoints.add(condition="Int1")`` + +Note +~~~~ + +Some targets don’t behave well with the Int1 instruction, while other +targets don’t behave properly with the IO port write. Knowing which one +to use depends on the machine. + +Disclaimer +---------- + +IMPORTANT NOTICE: This software is sample software. It is not designed +or intended for use in any medical, life-saving or life-sustaining +systems, transportation systems, nuclear systems, or for any other +mission-critical application in which the failure of the system could +lead to critical injury or death. The software may not be fully tested +and may contain bugs or errors; it may not be intended or suitable for +commercial release. No regulatory approvals for the software have been +obtained, and therefore software may not be certified for use in certain +countries or environments. + +.. |firstview| image:: ./_sysdbgimages/firstview.png +.. |halt| image:: ./_sysdbgimages/halt.png +.. |loadthis| image:: ./_sysdbgimages/loadthis.png +.. |variables| image:: ./_sysdbgimages/variables.png +.. |stepin| image:: ./_sysdbgimages/stepin.png +.. |stepover| image:: ./_sysdbgimages/stepover.png +.. |istep| image:: ./_sysdbgimages/istep.png +.. |stepout| image:: ./_sysdbgimages/stepout.png +.. |resetbp| image:: ./_sysdbgimages/bpadd.png +.. |resetbut| image:: ./_sysdbgimages/resetbut.png +.. |iobp| image:: ./_sysdbgimages/iobp.png +.. |itraceempty| image:: ./_sysdbgimages/itraceempty.png +.. |itraceconfig| image:: ./_sysdbgimages/itraceconfig.png +.. |itraceselect| image:: ./_sysdbgimages/itraceselect.png +.. |itraceenable| image:: ./_sysdbgimages/itraceenable.png +.. |resume| image:: ./_sysdbgimages/resume.png +.. |addbp| image:: ./_sysdbgimages/addbp.png +.. |int1bp| image:: ./_sysdbgimages/int1bp.png + +.. code:: ipython3 + + #!/usr/bin/env python3 + ''' + ============================================================== + Copyright © 2019 Intel Corporation + + SPDX-License-Identifier: MIT + ============================================================== + ''' + + ''' + OneApi System Debug example. Use System debugger for source level debugging + ''' + import intel.sysdbg + + intel.sysdbg.connect() + + threads = intel.sysdbg.threads + target = intel.sysdbg.target + + target.suspend() + threads[0].symbols.load_this() + threads[0].symbols.load_dxe() + + threads[0].frames[0].symbols.find("x")[0].value().string() + + threads[0].breakpoints.add(condition="Reset") + + target.platform.reset() + + target.resume() diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/SystemTrace.rst b/Tools/SystemDebug/system_debug_sample_build/docs/SystemTrace.rst new file mode 100644 index 0000000000..24a41da8de --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/docs/SystemTrace.rst @@ -0,0 +1,207 @@ +oneAPI Trace Example +==================== + +Introduction +------------ + +The ISD component of oneAPI includes a python-based command line +interface for capturing/decoding system trace called TraceCLI. +Developers can use the TraceCLI python package for automating trace +capture and the ISD trace UI for development and manual trace capture. + +What it is +---------- + +This project demonstrates decoding a trace file using the two methods +mentioned above (trace UI and TraceCLI). + +Software requirements +--------------------- + +This sample works on both Linux and Windows. + +This sample has been tested on Windows 10, and requires a working OneAPI +IOT Kit or OneAPI System Bring up installed. + +Using the ISD Trace UI +---------------------- + +oneAPI is shipped with the Intel® System Debugger which provides an +Eclipse-based UI for capturing/decoding system trace. + +Decoding an example trace .bin file offline with ISD +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Launch the IDE +.............. + +Windows + +.. code-block:: console + + > isd_eclipse-launcher.bat + +Linux + +.. code-block:: console + + > isd_eclipse-launcher.sh + +Opening System Trace perspective +................................ + +.. figure:: ./_traceimages/image-20200417112519429.png + :alt: image-20200417112519429 + +Use the System Trace wizard +........................... + +.. figure:: ./_traceimages/image-20200417112603072.png + :alt: image-20200417112603072 + +Enter a project name +.................... + +.. figure:: ./_traceimages/image-20200417115209456.png + :alt: image-20200417115209456 + +Select a connection +................... + +.. figure:: ./_traceimages/image-20200417115225732.png + :alt: image-20200417115225732 + +Select '10th Gen Intel® Core Processor (Comet Lake) ...' and 'Intel(R) DCI USB Debug Class' +......................................................................................... + +.. figure:: ./_traceimages/image-20200417115253978.png + :alt: image-20200417115253978 + +Since this is a file decode, uncheck 'Update provider configuration for current connection' as well as 'Connect on finish' +.......................................................................................................................... + +.. figure:: ./_traceimages/image-20200417115316277.png + :alt: image-20200417115316277 + +Provide a trace configuration name +.................................. + +.. figure:: ./_traceimages/image-20200417115329153.png + :alt: image-20200417115329153 + +Import a trace capture +...................... + +.. figure:: ./_traceimages/image-20200417115423377.png + :alt: image-20200417115423377 + +Select an example bin file (\system_trace\examples\input\mipi_aet_fake_trace.bin.bin) +.................................................... + +.. figure:: ./_traceimages/image-20200417115643548.png + :alt: image-20200417115643548 + +Select the imported capture for decoding +........................................ + +.. figure:: ./_traceimages/image-20200417115806272.png + :alt: image-20200417115806272 + +CMP General decode + +.. figure:: ./_traceimages/image-20200417115848009.png + :alt: image-20200417115848009 + +A 'MessageView001' will open showing decoded trace +.................................................. + +.. figure:: ./_traceimages/image-20200417115934739.png + :alt: image-20200417115934739 + :width: 150 % + +Using the TraceCLI +------------------ + +TraceCLI has three usage models (console, file decode, and streaming) + + +.. code-block:: console + + > intel_tracecli --help + usage: intel_tracecli [-h] [-v] [--pvss PVSS] [--target TARGET] + [--usecase USECASE] [--transport TRANSPORT] + {console,decode,stream} ... + + Intel TraceCLI Version 1.2003.826.200 + Copyright Intel Corporation All rights reserved + + positional arguments: + {console,decode,stream} + console Run interactive mode + decode Decode a trace capture file + stream Capture and decode traces + +Running the example +^^^^^^^^^^^^^^^^^^^ + +.. code-block:: console + + %ISS_PYTHON3_BIN% tracecli_example.py + + > $ISS_PYTHON3_BIN/tracecli_example.py + Intel TraceCLI Version 1.2015.469.100 + Copyright Intel Corporation All rights reserved + + Using installation at C:\Program Files (x86)\inteloneapi\system_debugger\2021.1-beta06\\system_trace + + + + Basic usage guideline for file decode: + 1. session = trace.filedecode_session() + 2. session.interactive_setup() + 3. session.decode_file('ipc_trace_test.bin') + + Basic usage guideline for streaming: + 1. session = trace.stream_session() + 2. session.interactive_setup() + 3. session.start_stream_capture() + 4. session.enable_trace() + 5. session.disable_trace() + 6. session.stop_stream_capture() + + Other options (Examples): + - session.set_decoder_parameter('MIPI_Decoder', 'startAtAsync', 'false') + - session.csv_columns.extend(['MasterID','ChannelID','payload','Summary','PacketType']) + + Info: MIPI STP Decoder Trace Statistics [instance: mipi] + | Master | Channel | Packets | Protocol | + | 0| 0| 0| TSCU| + | 24| 0| 662486| UNDEFINED| + | 24| 1| 285638|AET_CORE_0_THREAD_0| + | 24| 2| 284187|AET_CORE_0_THREAD_1| + | 24| 3| 284861|AET_CORE_1_THREAD_0| + | 24| 4| 284333|AET_CORE_1_THREAD_1| + | 24| 5| 283629|AET_CORE_2_THREAD_0| + | 24| 6| 284214|AET_CORE_2_THREAD_1| + | 24| 7| 283199|AET_CORE_3_THREAD_0| + Trace does not contain sync packet + End of MIPI STP Decoder Trace Statistics + + "Time","Source","Summary" + "[000]0000:00:00.000000000000","AET_CORE_0_THREAD_1","Power Entry (C0,GV) due to OTHER_THD" + "[000]0000:00:00.000211333333","AET_CORE_1_THREAD_1","Power Exit (Ratio=0x17)" + "[000]0000:00:00.000328583333","AET_CORE_1_THREAD_0","INT(0xEF)" + "[000]0000:00:00.000450208333","AET_CORE_2_THREAD_0","Exception(#DE)" + "[000]0000:00:00.000609458333","AET_CORE_0_THREAD_0","INT(0x30)" + "[000]0000:00:00.000731958333","AET_CORE_0_THREAD_0","Exception(#DE)" + "[000]0000:00:00.000850083333","AET_CORE_1_THREAD_1","IN(0x00000021)" + "[000]0000:00:00.000927083333","AET_CORE_0_THREAD_1","IN(0x00000021)=0x000000EA" + "[000]0000:00:00.000984833333","AET_CORE_3_THREAD_0","OUT(0x00000021)=0x000000EB" + "[000]0000:00:00.001046958333","AET_CORE_0_THREAD_1","OUT(0x00000020)=0x00000060" + "[000]0000:00:00.001783833333","AET_CORE_1_THREAD_0","IRET" + "[000]0000:00:00.001792916667","AET_CORE_1_THREAD_0","IRET" + "[000]0000:00:00.001800791667","AET_CORE_0_THREAD_0","IRET" + "[000]0000:00:00.001804875000","AET_CORE_2_THREAD_1","Exception(#DE)" + "[000]0000:00:00.001811000000","AET_CORE_2_THREAD_0","IRET" + "[000]0000:00:00.001815250000","AET_CORE_2_THREAD_0","Exception(#DE)" + ... diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/TCA.rst b/Tools/SystemDebug/system_debug_sample_build/docs/TCA.rst new file mode 100644 index 0000000000..2600d79999 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/docs/TCA.rst @@ -0,0 +1,389 @@ + +Intel Target Connection Assistant Basic Usage Sample +==================================================== + ++---------------+------------------------------------+ +| Optimized for | Description | ++===============+====================================+ +| OS | Linux\* Ubuntu\* 18.04, Windows 10 | ++---------------+------------------------------------+ +| Hardware | Aaeon UpXtreme | ++---------------+------------------------------------+ +| Software | Intel® oneAPI System Debugger | ++---------------+------------------------------------+ + +What it is +---------- + +This project demonstrates the recommended way of connecting to the +target for debug and trace. + +Licence +------- + +This code sample is licensed under MIT license. + +Software requirements +--------------------- + +This sample works on both Linux and Windows. + +This sample has been tested on Windows 10, and requires a working OneAPI +IOT Kit or OneAPI System Bring up installed. + +Open the TCA connection wizard +------------------------------ + +- Physically connect your target to the host and start Eclipse\* IDE + +- Click on **New Connection** in the tool bar + +.. figure:: ./_tcaimages/new_connection.png + :alt: image + + image + +- In the launched wizard, select **New Connection for System Debug & + Trace** + +.. figure:: ./_tcaimages/select_connection_wizard.png + :alt: image + + image + +Using Auto-detection (Recommended) +---------------------------------- + +TCA utilizes OpenIPC SmartStart feature to detect the connected target +automatically without need to manually select it. This is the +recommended approach. + +1) Click on the radio button **Detect and connect to target**, then + click on the **Next** button. + +2) TCA will try to auto detect and connect to your target. The list of + possible targets detected will be shown in the next page. + +.. figure:: ./_tcaimages/detect_or_select.png + :alt: image + + image + +3) Select your target from the list. + +.. figure:: ./_tcaimages/detect.png + :alt: image + + image + +4) Click on the **Next** button to go to the connection summary page. + +5) Check the pre-configured settings. You can see the following data: + +.. + + :: + + * Detected target information and supported features + + :: + + * IPC provider version + +.. + + :: + + * Path to the IPC provider + +.. figure:: ./_tcaimages/detect_overview.png + :alt: image + + image + +6) Click on **Finish** to create the connection. + +Manual configuration (Advanced) +------------------------------- + +If you need more flexibility in configuring connection, you can always +create a connection manually, without using auto detection. + +1) In the first wizard page click on **Manually select target** and + select required target directly from the list. You can use the search + field to easily find your target in the list. + +.. figure:: ./_tcaimages/select_target.png + :alt: image + + image + +2) Click on the **Next** button to go to the connection configuration + selection. A connection configuration bundles all information + together required to establish a target connection. + +3) Choose the connection configuration which fits to your connection + method and target. + +.. figure:: ./_tcaimages/select_connection_configuration.png + :alt: image + + image + +4) Click on the **Next** button to go to the connection summary page. + +5) Check the pre-configured settings. You can see the following data: + +.. + + :: + + * Detected target information and supported features + + :: + + * IPC provider version + +.. + + :: + + * Path to the IPC provider + +.. figure:: ./_tcaimages/select_overview.png + :alt: image + + image + +If required, you can also choose your own version OpenIPC or Intel(R) +DAL and/or customize provider configuration. + +**WARNING**: Using custom configurations can lead to non-functional +connection, use on your own risk + +6) To check if your connection configuration is working you can click on + the **Verify Connected Target** button. + +7) Click on **Finish** to create the connection. + +To connect or disconnect your target use the buttons in the tool bar +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. figure:: ./_tcaimages/connect_disconnect_button.png + :alt: image + + image + +Using the Command Line +---------------------- + +Open the Intel System Debugger Shell +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- Open a command line, CMD Prompt on windows and terminal on Linux/Mac + +- Change directory to the installation directory and source the file + *iss_env.bat* or rather *iss_env.sh* on Linux/Mac + +.. figure:: ./_tcaimagescli/source_iss_env.png + :alt: image + + image + +- Enter **“isd_cli”** to start the Intel System Debugger Shell + +.. figure:: ./_tcaimagescli/isd_shell.png + :alt: image + + image + +Connecting to the Target +------------------------ + +This chapter describes the recommended way of connecting to the target +for debug and trace using the Intel Target Connection Assistant Python +Client. + +.. _using-auto-detection-recommended-1: + +Using Auto-detection (Recommended) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +TCA utilizes OpenIPC SmartStart feature to detect the connected target +automatically without need to manually select it. This is the +recommended approach. + +1) Enter **“profile = tca.select()”** to start creating a connection + profile. After successful creation, the profile will be stored in the + variable named **profile** + +.. figure:: ./_tcaimagescli/detect_or_select.png + :alt: image + + image + +2) Enter **“d”** to select auto detection. Intel Target Connection + Assistant will try to detect your connected target. + +.. figure:: ./_tcaimagescli/detect_or_select.png + :alt: image + + image + +3) Select your target from the list. Enter the number in front of the + target. + +.. figure:: ./_tcaimagescli/detect.png + :alt: image + + image + +4) Enter **“u”** to use the detected connection configuration. + +.. figure:: ./_tcaimagescli/detected_connection_configuration.png + :alt: image + + image + +5) To set the created profile as active profile, you need to load it + with the command **“tca.load(profile)”** + +.. figure:: ./_tcaimagescli/load_profile_detected.png + :alt: image + + image + +.. _manual-configuration-advanced-1: + +Manual configuration (Advanced) +------------------------------- + +If you need more flexibility in configuring connection, you can always +create a connection manually, without using auto detection. + +1) Enter **“profile = tca.select()”** to start creating a connection + profile. After successful creation, the profile will be stored in the + variable named **profile** + +.. figure:: ./_tcaimagescli/detect_or_select.png + :alt: image + + image + +2) Enter **“c”** to select auto detection. Intel Target Connection + Assistant will try to detect your connected target. + +.. figure:: ./_tcaimagescli/select_target_option.png + :alt: image + + image + +3) Select your target from the list. Enter the number in front of the + target. + +.. figure:: ./_tcaimagescli/select_target.png + :alt: image + + image + +4) Enter **“s”** to select a connection configuration. A connection + configuration bundles all information together required to establish + a target connection. + +.. figure:: ./_tcaimagescli/select_connection_configuration_option.png + :alt: image + + image + +5) Select the connection configuration which fits to your setup. Enter + the number in front of the configuration. + +.. figure:: ./_tcaimagescli/select_connection_configuration.png + :alt: image + + image + +6) Enter **“u”** to use the detected connection configuration. + +.. figure:: ./_tcaimagescli/use_connection_configuration.png + :alt: image + + image + +7) To set the created profile as active profile, you need to load it + with the command **“tca.load(profile)”** + +.. figure:: ./_tcaimagescli/load_profile_manual.png + :alt: image + + image + +Connect or disconnect target +---------------------------- + +To connect your target use the command **“tca.connect()”** and +**“tca.disconnect()”** to disconnect your target. + +.. figure:: ./_tcaimagescli/connect.png + :alt: image + + image + +Disclaimer +---------- + +IMPORTANT NOTICE: This software is sample software. It is not designed +or intended for use in any medical, life-saving or life-sustaining +systems, transportation systems, nuclear systems, or for any other +mission-critical application in which the failure of the system could +lead to critical injury or death. The software may not be fully tested +and may contain bugs or errors; it may not be intended or suitable for +commercial release. No regulatory approvals for the software have been +obtained, and therefore software may not be certified for use in certain +countries or environments. + +.. code:: ipython3 + + #!/usr/bin/env python3 + ''' + ============================================================== + Copyright © 2019 Intel Corporation + + SPDX-License-Identifier: MIT + ============================================================== + ''' + + ''' + OneApi TCA example. Use tca to connect to a target + ''' + + import intel.tca as tca + + target = tca.get_target(id="whl_u_cnp_lp") + components = [(c.component, tca.latest(c.steppings)) + for c in target.components] + component_config = tca.ComponentWithSelectedSteppingList() + for comp in components: + config_tmp = tca.ComponentWithSelectedStepping() + config_tmp.component, config_tmp.stepping = comp + supported_connections = target.get_supported_connection_configurations( + component_config) + + + def conn_filter(conn: tca.ConnectionConfiguration) -> bool: + if conn.type != tca.ConnectionType_IPC: + return False + if "CCA" not in conn.ipc_configuration.selection: + return False + return True + + + connection_config = next(filter(conn_filter, supported_connections)) + profile = tca.Profile() + profile.name = "My TCA profile" + profile.target = target + profile.component_configuration = component_config + profile.connection_configuration = connection_config + tca.load(profile) + tca.connect() + diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/Windbg.rst b/Tools/SystemDebug/system_debug_sample_build/docs/Windbg.rst new file mode 100644 index 0000000000..f1fa225f63 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/docs/Windbg.rst @@ -0,0 +1,156 @@ + +Windbg over DCI Basic Usage Sample +================================== + ++---------------+------------------------------------+ +| Optimized for | Description | ++===============+====================================+ +| OS | Windows 10 | ++---------------+------------------------------------+ +| Hardware | Aaeon UpXtreme | ++---------------+------------------------------------+ +| Software | Intel® oneAPI Beta Windbg over DCI | ++---------------+------------------------------------+ + +What it is +---------- + +This project demonstrates how you would use Windbg over DCI to connect +to a target and loading kernel symbols. + +Licence +------- + +This code sample is licensed under MIT license. + +Software requirements +--------------------- + +This sample works with Windows 10 Host/Target Systems only. For a list +of system requirements matching your configuration, see the Intel® +System Debugger Release Notes. In case you need assistance installing or +running this product, please visit our Get Help page at +http://software.intel.com/en-us/support for support options. + +Starting the Intel® Debug Extensions for *WinDbg* for IA JTAG debugging +----------------------------------------------------------------------- + +**WinDbg** must have access to kernel symbols for the connection to +succeed. + +Thus, you must set the symbol file path beforehand. + +Launch **WinDbg** (not by using the batch script, as this will perform a +connection) and set the symbol file path by selecting File > Symbol File +Path… and adding: + +``srv*C:Symbols*http://msdl.microsoft.com/download/symbols`` + +to the path or by setting the ``_NT_symbol_path`` global environment +variable with a corresponding value. Save the workspace by selecting +File -> Save Workspace, and then closing WinDbg. + +######Note You need to do this only once before the first use. Connect +the host system to the target one with the **Intel® In-Target Probe +(Intel® ITP)** or the **Intel® Direct Connect Interface (Intel® DCI)**. + +###Launching Windbg + +*Intel® Debug Extensions for WinDbg* can be launched as follows: + +Click the desktop icon or open the Start Menu and click *Intel® Debug +Extensions* for WinDbg\* under **Intel® System Studio oneAPI.** + +Run ``windbg_iajtag_console.bat`` located at: + +``C:Program Files (x86)inteloneapisystem_debuggerwindbg_iajtag_console.bat`` + +Another way to launch windbg over DCI would be to use the **iss_shell**. +Launch iss_shell.bat, that is located in the root installation +directory: + +``C:Program Files (x86)inteloneapisystem_debuggeriss_shell.bat`` + +From *iss_shell* run ``windbg_dci`` to invoke WinDbg. + +At this point, two Python objects are available for debugging: + +**itp** - Intel® ITP interface + +**itpkd** - wrapper over WinDbg\* and kernel debug console + +.. figure:: ./_windbgimages/console.PNG + :alt: img + + img + +Execute windbg() to halt the target and run a **WinDbg** session. After +that, **WinDbg** starts connecting to the target. + +.. figure:: ./_windbgimages/windbg.png + :alt: img + + img + +From now on, u could use windbg commands to interact with taret, for +example set a breakpoints: + +.. figure:: ./_windbgimages/windbg_break.png + :alt: img + + img + +debugging drivers: |img| + +get pcitree: |img| + +Note +~~~~ + +Connecting to the target can take several minutes. Do not enter any +commands until the connection is fully established and the connection +confirmation message is displayed (Target initialization succeeded). If +the connection fails, you see an exception in the console. Check the +network connection if KDVersionBlock is not found. Run the target for a +while if the kernel is not found. + +Using Intel® Debug Extensions for *WinDbg* with *WinDbg Preview* +---------------------------------------------------------------- + +System Requirements +~~~~~~~~~~~~~~~~~~~ + +- Microsoft WinDbg Preview. For download and installation instructions, + see the Windows\* Debugging Tools documentation. +- Windows 10 version 14257.0 or higher + +Starting Windbg Preview +~~~~~~~~~~~~~~~~~~~~~~~ + +To start using Intel® Debug Extensions for **WinDbg** with **WinDbg +Preview** follow the steps below: + +1. Connect to the target. +2. Launch iss_shell.bat located in the installation root directory. +3. Execute the windbg_preview command to start **WinDbg Preview**. + +.. figure:: ./_windbgimages/windbg_prev.png + :alt: img + + img + +Disclaimer +---------- + +IMPORTANT NOTICE: This software is sample software. It is not designed +or intended for use in any medical, life-saving or life-sustaining +systems, transportation systems, nuclear systems, or for any other +mission-critical application in which the failure of the system could +lead to critical injury or death. The software may not be fully tested +and may contain bugs or errors; it may not be intended or suitable for +commercial release. No regulatory approvals for the software have been +obtained, and therefore software may not be certified for use in certain +countries or environments. + +.. |img| image:: ./_windbgimages/_dbg_driver.PNG +.. |img| image:: ./_windbgimages/windbg_2.png diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/addbp.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/addbp.png new file mode 100644 index 0000000000..be140873b1 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/addbp.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/bpadd.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/bpadd.png new file mode 100644 index 0000000000..540cbd1d33 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/bpadd.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/firstview.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/firstview.png new file mode 100644 index 0000000000..58582bc7c0 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/firstview.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/halt.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/halt.png new file mode 100644 index 0000000000..fc1cae901e Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/halt.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/hex_upxtreme.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/hex_upxtreme.png new file mode 100644 index 0000000000..e57ee55c8c Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/hex_upxtreme.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/int1bp.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/int1bp.png new file mode 100644 index 0000000000..a95c277f4b Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/int1bp.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/iobp.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/iobp.png new file mode 100644 index 0000000000..426e1a9340 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/iobp.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/istep.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/istep.png new file mode 100644 index 0000000000..fdacdd1d5d Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/istep.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceconfig.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceconfig.png new file mode 100644 index 0000000000..9268b87b99 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceconfig.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceempty.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceempty.png new file mode 100644 index 0000000000..2e119aec99 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceempty.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceenable.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceenable.png new file mode 100644 index 0000000000..024b4543d0 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceenable.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceselect.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceselect.png new file mode 100644 index 0000000000..13e50ce0ba Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/itraceselect.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/loaddxe.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/loaddxe.png new file mode 100644 index 0000000000..c32124136d Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/loaddxe.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/loadthis.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/loadthis.png new file mode 100644 index 0000000000..42a13621d4 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/loadthis.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/resetbut.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/resetbut.png new file mode 100644 index 0000000000..e3877ac190 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/resetbut.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/resume.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/resume.png new file mode 100644 index 0000000000..b717e4195d Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/resume.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/stepin.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/stepin.png new file mode 100644 index 0000000000..4fd16328bc Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/stepin.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/stepout.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/stepout.png new file mode 100644 index 0000000000..695d7cbc78 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/stepout.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/stepover.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/stepover.png new file mode 100644 index 0000000000..1f1230e071 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/stepover.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/variables.png b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/variables.png new file mode 100644 index 0000000000..4eed12d40f Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_sysdbgimages/variables.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/connect_disconnect_button.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/connect_disconnect_button.png new file mode 100644 index 0000000000..0b4ac4cd3b Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/connect_disconnect_button.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/connection_editor.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/connection_editor.png new file mode 100644 index 0000000000..ef1a3e27f4 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/connection_editor.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/detect.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/detect.png new file mode 100644 index 0000000000..fc771c7754 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/detect.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/detect_or_select.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/detect_or_select.png new file mode 100644 index 0000000000..af151040ac Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/detect_or_select.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/detect_overview.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/detect_overview.png new file mode 100644 index 0000000000..bcf476a106 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/detect_overview.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/new_connection.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/new_connection.png new file mode 100644 index 0000000000..b6cca9835e Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/new_connection.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_connection_configuration.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_connection_configuration.png new file mode 100644 index 0000000000..10c6ebd876 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_connection_configuration.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_connection_wizard.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_connection_wizard.png new file mode 100644 index 0000000000..5a220219e3 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_connection_wizard.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_overview.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_overview.png new file mode 100644 index 0000000000..9fcd86557d Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_overview.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_target.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_target.png new file mode 100644 index 0000000000..e554858ef0 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimages/select_target.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/connect.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/connect.png new file mode 100644 index 0000000000..83bb2f39d2 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/connect.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/detect.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/detect.png new file mode 100644 index 0000000000..30bf54cfec Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/detect.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/detect_or_select.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/detect_or_select.png new file mode 100644 index 0000000000..67adda9891 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/detect_or_select.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/detected_connection_configuration.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/detected_connection_configuration.png new file mode 100644 index 0000000000..15cabcc378 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/detected_connection_configuration.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/isd_shell.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/isd_shell.png new file mode 100644 index 0000000000..2d60219f14 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/isd_shell.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/load_profile_detected.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/load_profile_detected.png new file mode 100644 index 0000000000..05b56bdd89 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/load_profile_detected.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/load_profile_manual.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/load_profile_manual.png new file mode 100644 index 0000000000..8d388ca96f Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/load_profile_manual.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_connection_configuration.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_connection_configuration.png new file mode 100644 index 0000000000..a1cead3512 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_connection_configuration.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_connection_configuration_option.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_connection_configuration_option.png new file mode 100644 index 0000000000..39970c5d14 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_connection_configuration_option.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_target.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_target.png new file mode 100644 index 0000000000..dfd9397218 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_target.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_target_option.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_target_option.png new file mode 100644 index 0000000000..f4a3bebf4b Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/select_target_option.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/source_iss_env.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/source_iss_env.png new file mode 100644 index 0000000000..e1e1745e5d Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/source_iss_env.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/use_connection_configuration.png b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/use_connection_configuration.png new file mode 100644 index 0000000000..87da8159fd Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_tcaimagescli/use_connection_configuration.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417112519429.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417112519429.png new file mode 100644 index 0000000000..e01cd8790e Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417112519429.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417112603072.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417112603072.png new file mode 100644 index 0000000000..92ff592ce9 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417112603072.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115209456.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115209456.png new file mode 100644 index 0000000000..24009bbe25 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115209456.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115225732.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115225732.png new file mode 100644 index 0000000000..7df81a18bd Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115225732.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115253978.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115253978.png new file mode 100644 index 0000000000..61ddf5e03e Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115253978.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115316277.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115316277.png new file mode 100644 index 0000000000..1eb50aa49d Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115316277.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115329153.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115329153.png new file mode 100644 index 0000000000..e48e5d46a4 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115329153.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115423377.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115423377.png new file mode 100644 index 0000000000..0b2c1a6b06 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115423377.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115643548.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115643548.png new file mode 100644 index 0000000000..62512b30c6 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115643548.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115806272.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115806272.png new file mode 100644 index 0000000000..0c70e52f4f Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115806272.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115848009.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115848009.png new file mode 100644 index 0000000000..8e99c9295c Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115848009.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115934739.png b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115934739.png new file mode 100644 index 0000000000..01e30f3944 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_traceimages/image-20200417115934739.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/_dbg_driver.PNG b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/_dbg_driver.PNG new file mode 100644 index 0000000000..11f2bcbddb Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/_dbg_driver.PNG differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/console.PNG b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/console.PNG new file mode 100644 index 0000000000..cd7e6e5ed7 Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/console.PNG differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg.png b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg.png new file mode 100644 index 0000000000..90352ad76b Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg_2.png b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg_2.png new file mode 100644 index 0000000000..98d9c772bd Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg_2.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg_break.png b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg_break.png new file mode 100644 index 0000000000..146a9f8ead Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg_break.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg_prev.png b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg_prev.png new file mode 100644 index 0000000000..abe155a35e Binary files /dev/null and b/Tools/SystemDebug/system_debug_sample_build/docs/_windbgimages/windbg_prev.png differ diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/CMakeLists.txt b/Tools/SystemDebug/system_debug_sample_build/efi_application/CMakeLists.txt new file mode 100644 index 0000000000..d7cc4a238c --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/CMakeLists.txt @@ -0,0 +1,186 @@ +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent + + +# Allow this CMakeLists.txt to be used a a top-level file +cmake_minimum_required(VERSION 3.7) +project(uxdbgapp LANGUAGES C) +if(APPLE) # Use crosscompiler toolchain + + set(CMAKE_C_COMPILER x86_64-elf-gcc) + set(CMAKE_CXX_COMPILER x86_64-elf-g++) + + # check for crosscompilers on Mac OS + find_program(AR x86_64-elf-ar) + find_program(RANLIB x86_64-elf-ranlib) + + if(NOT AR OR NOT RANLIB) + message(FATAL_ERROR "elf tools not found! Please install x86_64-elf-binutils") + endif() + + SET(CMAKE_AR ${AR}) + SET(CMAKE_RANLIB ${RANLIB}) + SET(MAKE_PREFIX x86_64-elf-) + + set(CREATE_ELF_HEADER ln -f -s /usr/local/include/elf.h .) + set(CMAKE_C_COMPILER_WORKS 1) + set(CMAKE_CXX_COMPILER_WORKS 1) + set(CMAKE_C_COMPILER_ID GNU) + set(CMAKE_CXX_COMPILER_ID GNU) +endif() + +if (NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +endif () + +if (NOT DEFINED TOOLS_INSTALL_PREFIX) + set(TOOLS_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) +endif () + +set(EFI_APP_NAME ${CMAKE_PROJECT_NAME}) +# Installation folder for the EFI application binaries +set(EFI_APP_INSTALL_DIR ${TOOLS_INSTALL_PREFIX}/efi) + +set(HAVE_EFI FALSE) +if (NOT DEFINED EDK2_ROOT) + set(EDK2_ROOT ${CMAKE_SOURCE_DIR}/edk2) +endif () + +# Required for Windows (MSVC is multi-config but Ninja is not) +get_property(MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + +if (CMAKE_HOST_UNIX) + set(EFI_APP_AR ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${EFI_APP_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(EFI_APP_SO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${EFI_APP_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(EFI_APP_EFI ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${EFI_APP_NAME}.efi) + set(EFI_APP_DBG ${EFI_APP_SO}) + + set(EFI_ARCH x86_64) + + set(EFI_DIR ${CMAKE_SOURCE_DIR}/gnu-efi-code) + set(EDK_INC_DIR ${EDK2_ROOT}/MdePkg/Include) + set(EFI_INC_DIR ${EFI_DIR}/inc) + set(EFI_INC_DIRS ${EDK_INC_DIR} ${EDK_INC_DIR}/X64 ${EFI_INC_DIR} ${EFI_INC_DIR}/${EFI_ARCH}) + if (EXISTS ${EFI_INC_DIR} AND IS_DIRECTORY ${EFI_INC_DIR}) + set(HAVE_EFI TRUE) + else() + message(FATAL_ERROR "Please clone gnuefi submodule") + endif() + + set(EFI_LIB_DIR ${EFI_DIR}/${EFI_ARCH}/lib) + set(EFI_LIB_DIR_GNU ${EFI_DIR}/gnuefi) + + set(EFI_CRT ${EFI_LIB_DIR_GNU}/crt0-efi-${EFI_ARCH}.o) + + set(libefifile ${EFI_LIB_DIR_GNU}/libefi.a) + add_custom_command(OUTPUT ${libefifile} + COMMAND ${CREATE_ELF_HEADER} + COMMAND make prefix=${MAKE_PREFIX} -j + WORKING_DIRECTORY ${EFI_DIR}) + add_custom_target(libefi DEPENDS ${libefifile}) + + set(libgnuefifile ${EFI_LIB_DIR}libgnuefi.a) + add_custom_command(OUTPUT ${libgnuefifile} + COMMAND ${CREATE_ELF_HEADER} + COMMAND make prefix=${MAKE_PREFIX} + WORKING_DIRECTORY ${EFI_LIB_DIR_GNU}) + add_custom_target(libgnuefi DEPENDS ${libgnuefifile}) + if (CMAKE_C_COMPILER_ID MATCHES "Intel") + set(EFI_CFLAGS -debug -ffreestanding -O0 -c -fPIC -fno-stack-protector -fshort-wchar -mno-red-zone ) + else () + set(EFI_CFLAGS -g -ffreestanding -Og -fPIC -fno-stack-protector -fshort-wchar -mno-red-zone) + endif() + if (CMAKE_C_COMPILER_ID MATCHES "Clang") + # setjmp is a builtin for Clang but present in the EFI lib headers... + set(EFI_CFLAGS ${EFI_CFLAGS} -Wno-error=incompatible-library-redeclaration) + endif () + set(EFI_APP_DEFS -DGNU_EFI -DEDK2_LIN) + set(EFI_LDS ${EFI_DIR}/gnuefi/elf_${EFI_ARCH}_efi.lds) + set(EFI_LDFLAGS -nostdlib -znocombreloc -T${EFI_LDS} -shared -Bsymbolic -L${EFI_LIB_DIR} -L${EFI_LIB_DIR_GNU}) + + set(EFI_LDLIBS -lefi -lgnuefi) + + set(OBJCOPY_OPTS_EFI --target=efi-app-${EFI_ARCH} -j .text -j .sdata -j .data + -j .dynamic -j .dynsym -j .rel -j .rela -j .reloc -j .eh_frame) + +elseif (CMAKE_HOST_WIN32) + + if (NOT CMAKE_GENERATOR_PLATFORM MATCHES X64) + message(FATAL_ERROR "ERROR: Only 64 bit builds are supported. Please build with -AX64 ${CMAKE_GENERATOR_PLATFORM}" ) + endif() + set(EFI_ARCH X64) + + if (NOT DEFINED EDK2_TOOLS) + set(EDK2_TOOLS ${CMAKE_SOURCE_DIR}/edk2/BaseTools/Win32) + endif () + + set(EFI_APP_DEFS -DEDK2) + # Name of the app in its TE (Terse Executable incarnation) + set(EFI_APP_TE_NAME ${EFI_APP_NAME}-te) + + if (MULTI_CONFIG) + set(EFI_APP_AR ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/$/${EFI_APP_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) + + set(EFI_APP_SO ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$/${EFI_APP_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(EFI_APP_DBG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$/${EFI_APP_NAME}.pdb) + set(EFI_APP_EFI ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$/${EFI_APP_NAME}.efi) + + set(EFI_APP_TE_SO ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$/${EFI_APP_TE_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(EFI_APP_TE_DBG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$/${EFI_APP_TE_NAME}.pdb) + set(EFI_APP_TE_EFI ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$/${EFI_APP_TE_NAME}.efi) + else () + set(EFI_APP_AR ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${EFI_APP_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) + + set(EFI_APP_SO ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EFI_APP_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(EFI_APP_DBG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EFI_APP_NAME}.pdb) + set(EFI_APP_EFI ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EFI_APP_NAME}.efi) + + set(EFI_APP_TE_SO ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EFI_APP_TE_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(EFI_APP_TE_DBG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EFI_APP_TE_NAME}.pdb) + set(EFI_APP_TE_EFI ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EFI_APP_TE_NAME}.efi) + endif () + + set(GENFW GenFw.exe) + file(TO_NATIVE_PATH ${EFI_APP_EFI} EFI_NATIVE_PATH) + file(TO_NATIVE_PATH ${EFI_APP_SO} SO_NATIVE_PATH) + file(TO_NATIVE_PATH ${EFI_APP_TE_EFI} TE_EFI_NATIVE_PATH) + file(TO_NATIVE_PATH ${EFI_APP_TE_SO} TE_SO_NATIVE_PATH) + + set(EFI_INC_DIR ${EDK2_ROOT}/MdePkg/Include) + set(EFI_INC_DIRS ${EFI_INC_DIR} ${EFI_INC_DIR}/${EFI_ARCH}) + + if (NOT (EXISTS ${EFI_INC_DIR} AND IS_DIRECTORY ${EFI_INC_DIR})) + message(FATAL_ERROR "ERROR: ${EFI_INC_DIR} folder not found, please set EDK2_ROOT.") + elseif (NOT EXISTS ${EDK2_TOOLS}/${GENFW}) + message(FATAL_ERROR "ERROR: ${GENFW} not found, please set EDK2_TOOLS.") + else () + set(HAVE_EFI TRUE) + # Remove C runtime library support, enable debug info, disable optimizations and buffer security + # disable cf guard, as this plays havoc without runtime library + set(EFI_CFLAGS /Zl /Zi /Od /GS- /Oy- /guard:cf-) + set(EFI_LDFLAGS /machine:${EFI_ARCH} /entry:efi_main /dll /ignore:4001 /debug /nodefaultlib) + + #ignore edk2 errors when headers are used in cpp context + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4804 /wd4005") + string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + + + endif () + +endif() + +if (HAVE_EFI) + option(BAD "Set if the efi application should be badly behaved" OFF) + + + if (BAD) + set(EFI_APP_DEFS ${EFI_APP_DEFS} -DBADLY_BEHAVED) + endif() + + add_subdirectory(${CMAKE_SOURCE_DIR}/src) + + +endif () diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/README.md b/Tools/SystemDebug/system_debug_sample_build/efi_application/README.md new file mode 100644 index 0000000000..bab4467395 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/README.md @@ -0,0 +1,191 @@ +# `EFI Application` Sample + +##Building the EFI Application + + + +| Optimized for | Description +|:--- |:--- +| OS | Linux* Ubuntu* 18.04, Windows 10, Fedora 32, MacOS 10.15 +| Hardware | Any machine which has an EFI based bios +| Software | Intel® oneAPI C++ Compiler (beta), Visual Studio, GCC-9, GCC-10, Clang-10 + +## License +This code sample is licensed under MIT license. + + + +### Toolchains + +for this, we assume you have a toolchain correctly installed. + +On windows, we have tested with the Visual Studio 2019 compiler, and the Intel®C compiler, included with OneAPI. + +On linux, icc , clang and gcc are all supported. + +#### Mac OS + +To build on mac OS - you will require a cross compiler to build the elf binaries (as mach-o binaries are not easily convertable to efi pe32+ format), and the debugger does not support MachO symbols. ma + +The easiest way of getting this, is to use homebrew (https://brew.sh/) and install the x86_64-elf-gcc formula. + +```brew install x86_64-elf-gcc``` + + +###build Process +To build the efi applcation, please clone the repository. + +```git clone https://github.com/intel/IoTKit-code-samples``` + +Then - clone all of the submodules + +```git submodule update --init``` + +Now - make the cmake project, making sure to specify it is a 64 bit architecture. + +```mkdir build``` + +```cd build``` + +To build the efi application, we use the `cmake` build system to generate the build system. + +We do this with: + +```cmake ..``` + +then - on windows you will see a Visual Studio solution in the `build` directory, uxdbgapp.sln, on POSIX systems you will see a MakeFile in the build folder. + +You can then build this by issuing the following command: + + +```cmake --build .``` + +Or, + +on Windows, you can open the visual studio solution, and build the uxdbgapp target. + +On POSIX, you can run the makefile with `make -j`. + + +##### windows builders + +On windows, the output will be in the `Debug` folder in the build directory. + + +#### Edk2 basetools + +On windows, you will either need to build edk2 basetools, or get the prebuilt binaries. + +The easiest way to get the prebuilt binaries is to clone the git repo. + +``` cd /system_debugger/efi_application/efi/BaseTools/Bin``` +``` git clone https://github.com/tianocore/edk2-BaseTools-win32.git Win32 ``` + +Alternatively, you can build the basetools yourself. For this, you will need to have visual studio installed, and python. + +First, you will have to add nmake to your PATH environment variable. NMAKE is located in the visual studio directory. +Then, install the edk2-pytool-library with + +```pip install edk2-pytool-library``` + +Then, change to the edk2 basetools directory. + +```cd /system_debugger/efi_application/edk2/BaseTools``` + +Then update all of the edk2 submodules. + +```git submodule update --init --recursive``` + +Now, run the basetools build command. This is as follows: + +```python Edk2ToolsBuild.py -t vs2019``` + +Where vs2019 is the visual studio 2019 compiler - For vs2017 the command would be: + + +```python Edk2ToolsBuild.py -t vs2017``` + +If there are any errors, the build logs can be seen in: + +```\system_debugger\efi_application\edk2\BaseTools\BaseToolsBuild\``` + +#### output files +This will output the following files: + + +##### Universal +`uxdbgapp.efi` - this is the efi appication we need to flash to the device + + +##### linux builders +`uxdbgapp.so` - this is the file containing the DWARF debug symbols on linux + +##### mac builders +`uxdbgapp.dylib` - this is the *ELF* file containing the DWARF debug symbols on mac OS. + + +##### Windows Builders +`uxdbgapp.pdb` - this is the file containing the CodeView debug symbols on windows + +`uxdbgapp-te.efi` - this is the efi image in TERSE executable format + +`uxdbgapp-te.pdb` - this is the file containing the CodeView debug symbols on windows for the Terse executable + + +## Flashing the EFI Application to a USB + +### Linux and Mac + +Copy the `uxdbgapp.efi` file into the `tools` folder. + +Open a terminal, `cd` to the tools folder, and execute the script as follows: + +`./make_boot_media.sh uxdbgapp.efi ` + +##### NOTE + +if you have issues with permissions, you might have to make the script executable. + +you can do this by issueing the following command in terminal: + +```chmod +x make_boot_media.sh``` + +you can find information on the disks by using the following: + +#### mac OS +```diskutil list``` + +#### linux +```sudo fdisk -l``` + + +#### Windows + +Start the powershell script, from a powershell prompt. + +If required, accept the access request for admin rights. + +Then, select the .efi file using the file browser. + +Next, select the usb device you would like to flash to. + + + +### Example Steps (Linux) + +``` +mkdir build +cd build +cmake .. +cmake --build . +chmod +x make_boot_media.sh +../make_boot_media.sh uxdbgapp.efi /dev/sdb +``` + +##### if you recieve execution errors +You might have to change your powershell execution policy. This can be done with the following comman in powershell: `Set-ExecutionPolicy Unrestricted ` + +## Disclaimer +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. + + diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/src/CMakeLists.txt b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/CMakeLists.txt new file mode 100644 index 0000000000..6fc8107e13 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/CMakeLists.txt @@ -0,0 +1,62 @@ +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent + + +file(GLOB EFI_APP_SOURCES *.c) + +if (CMAKE_HOST_WIN32) + enable_language(ASM_MASM) + set(ASMUTILS_OBJ "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/asmutils.obj") + set(ASMUTILS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/asmutils.asm") + add_custom_command(OUTPUT ${ASMUTILS_OBJ} + COMMAND ${CMAKE_ASM_MASM_COMPILER} /nologo /Fo"${ASMUTILS_OBJ}" /c /w "${ASMUTILS_SRC}") +endif(CMAKE_HOST_WIN32) + +file(TO_NATIVE_PATH ${EFI_APP_EFI} EFI_NATIVE_PATH) +# HACK: On Unix, because we cannot choose the linker invoked by CMake (which by default invokes +# the CMAKE_C_COMPILER and not ld), we need an extra step. We first create a STATIC library +# to make sure we gathered/compiled all the sources/objects and then we call the ld manually +# with the right parameters. On Windows, for consistency and readability, we do the same. +add_library(${EFI_APP_NAME} STATIC ${EFI_APP_SOURCES} ${ASMUTILS_OBJ}) + +set_target_properties(${EFI_APP_NAME} PROPERTIES PREFIX "") +target_include_directories(${EFI_APP_NAME} PRIVATE ${EFI_INC_DIRS}) + +target_compile_options(${EFI_APP_NAME} PRIVATE ${EFI_APP_DEFS} ${EFI_CFLAGS}) + +# Prevent the GenFw from erasing the .pdata / .rdata (containing the unwind info) +set(GENFW_OPTS --keepexceptiontable --keepoptionalheader -e APPLICATION) +set(GENFW_TE_OPTS --keepexceptiontable --keepoptionalheader -t) +if (CMAKE_HOST_UNIX) + + if (APPLE) + find_program(LINKER x86_64-elf-ld DOC "The elf linker") + find_program(OBJCOPY x86_64-elf-objcopy DOC "elf objcopy") + if(NOT LINKER OR NOT OBJCOPY) + message(FATAL_ERROR "elf tools not found! Please install x86_64-elf-binutils") + endif() + else() + find_program(LINKER ld DOC "The elf linker") + find_program(OBJCOPY objcopy DOC "elf objcopy") + if(NOT LINKER) + message(FATAL_ERROR "ld not found! Please install it") + endif() + if(NOT OBJCOPY) + message(FATAL_ERROR "objcopy not found! Please install it") + endif() + endif(APPLE) + add_custom_command(TARGET ${EFI_APP_NAME} POST_BUILD + COMMAND ${LINKER} ${EFI_LDFLAGS} -o ${EFI_APP_SO} ${EFI_CRT} + --whole-archive ${EFI_APP_AR} ${EFI_LDLIBS} + COMMAND ${OBJCOPY} ${OBJCOPY_OPTS_EFI} ${EFI_APP_SO} ${EFI_APP_EFI} + DEPENDS ${EFI_APP_AR}) + add_dependencies(${EFI_APP_NAME} libefi libgnuefi) +elseif (CMAKE_HOST_WIN32) + add_custom_command(TARGET ${EFI_APP_NAME} POST_BUILD + COMMAND link ${EFI_LDFLAGS} /out:${EFI_APP_SO} ${EFI_APP_AR} + COMMAND link ${EFI_LDFLAGS} /out:${EFI_APP_TE_SO} /filealign:4096 ${EFI_APP_AR} + COMMAND ${CMAKE_COMMAND} -E copy ${EDK2_TOOLS}/${GENFW} ${GENFW} + COMMAND ${GENFW} ${GENFW_OPTS} -o ${EFI_NATIVE_PATH} ${SO_NATIVE_PATH} + COMMAND ${GENFW} ${GENFW_TE_OPTS} -o ${TE_EFI_NATIVE_PATH} ${TE_SO_NATIVE_PATH} + DEPENDS ${EFI_APP_AR}) +endif() \ No newline at end of file diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/src/asmutils.asm b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/asmutils.asm new file mode 100644 index 0000000000..8a5f682e62 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/asmutils.asm @@ -0,0 +1,93 @@ +; Copyright (c) 2020, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent + +_TEXT SEGMENT + +PUBLIC write_r10 +PUBLIC write_r11 +PUBLIC read_r11 +PUBLIC probe_mode_redirect +PUBLIC _mwait +PUBLIC _hlt + +write_r10 PROC + mov r10, rcx + ret +write_r10 ENDP + + +write_r11 PROC + mov r11, rcx + ret +write_r11 ENDP + + +read_r11 PROC + mov rax, r11 + ret +read_r11 ENDP + +read_msr PROC + rdmsr + shl rdx, 32 + or rax, rdx + ret +read_msr ENDP + + + +write_io PROC + mov ax, dx + mov dx, cx + out dx, ax + ret +write_io ENDP + +probe_mode_redirect PROC + byte 0f1h + ret +probe_mode_redirect ENDP + +_cpuid PROC + push rbx + mov eax, ecx + push rax ; save Index on stack + push rdx + cpuid + test r9, r9 + jz one + mov [r9], ecx +one: + pop rcx + jrcxz two + mov [rcx], eax +two: + mov rcx, r8 + jrcxz three + mov [rcx], ebx +three: + mov rcx, [rsp+38h] + jrcxz four + mov [rcx], edx +four: + pop rax ; restore Index to rax as return value + pop rbx + ret +_cpuid ENDP + +_mwait PROC + ; opcode of MWAIT is 0f 01 c9 + db 15 + db 1 + db 201 + ret +_mwait ENDP + +_hlt PROC + hlt + ret +_hlt ENDP + +_TEXT ENDS + +END diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/src/asmutils.h b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/asmutils.h new file mode 100644 index 0000000000..3c51189834 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/asmutils.h @@ -0,0 +1,155 @@ +/** + * @file asmutils.h + * @brief Assembly-related utilities. + * + Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + */ + +#ifndef ASMUTILS_H +#define ASMUTILS_H + +#include "dbgapp.h" + +#ifdef _MSC_VER + +/** + * Write to the R10 register. + */ +extern void write_r10(uint64_t val); + +/** + * Write to the R11 register. + */ +extern void write_r11(uint64_t val); + +/** + * Read the R11 register. + */ +extern uint64_t read_r11(void); + +/** + * Read the MSR at the specified address + */ +extern uint64_t read_msr(uint32_t addr); + +/** + * Trigger a probe mode redirect (halt the current HW thread). + */ +extern void probe_mode_redirect(void); + +/** + * run the cpuid command + */ +extern void _cpuid(uint32_t index, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx); + +/** + * Write a value to the IO port at the specified address + */ +extern void write_io(uint16_t val, uint16_t addr); + +/** + * Execute the HLT (halt) instruction + */ +extern void _hlt(); + +/** + * Execute the MWAIT instruction. + */ +extern void _mwait(); + +#elif defined(__GNUC__) + +static inline void write_r10(uint64_t val) { + __asm__("movq %0, %%r10" :: "r"(val)); +} + +static inline void write_r11(uint64_t val) { + __asm__("movq %0, %%r11" :: "r"(val)); +} + +static inline uint64_t read_r11(void) { + uint64_t ret; + __asm__("movq %%r11, %0" : "=r"(ret)); + return ret; +} + +static inline uint64_t read_msr(uint32_t addr) { + uint64_t ret; + __asm__( + "movl %1, %%ecx \n" + "rdmsr \n" + "shl $32, %%rdx \n" + "or %%rdx, %%rax \n" + "movq %%rax, %0" + + : "=r"(ret) + : "r"(addr) + ); + return ret; +} + + + +static inline void write_io(uint16_t addr, uint16_t val) { + __asm__( + "mov %0, %%ax \n" + "mov %1, %%dx \n" + "out %%ax, %%dx" + + :: "r"(val), "r"(addr) + ); +} + +static inline void _cpuid(uint32_t index, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx) { +__asm__ volatile( + " movl %0, %%eax\n" + " cpuid\n" + " mov %%rcx, %%r9\n" + " movq %1, %%rcx\n" + " jrcxz 1f\n" + " movq %%rax, (%%rcx)\n" + "1: \n" + " movq %2, %%rcx\n" + " jecxz 2f\n" + " movq %%rbx, (%%rcx)\n" + "2: \n" + " mov %%r9,%%rax\n" + " movq %3, %%rcx\n" + " jrcxz 3f\n" + " movq %%rax, (%%rcx)\n" + "3: \n" + " movq %4, %%rcx\n" + " jrcxz 4f\n" + " movq %%rdx, (%%rcx)\n" + "4: \n" + " movl %0, %%eax" + : + :"m"(index), "m"(eax), "m"(ebx), "m"(ecx), "m"(edx) + :"memory","rsi", "rdi", "rcx" + +); +} + +static inline void probe_mode_redirect(void) { + __asm__(".byte 0xf1" ::); +} + +static inline void _hlt() { + __asm__("hlt" ::); +} + +static inline void _mwait() { + __asm__("mwait" ::); +} + +#endif + +/** + * Write a POST code to the 0x80 IO port + */ +static inline void post(uint16_t val) { + write_io(0x80, val); +} + +#endif /* ASMUTILS_H */ diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/src/dbgapp.h b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/dbgapp.h new file mode 100644 index 0000000000..71c206daa0 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/dbgapp.h @@ -0,0 +1,45 @@ + +/** @file +dbgapp library functions. + + +Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef DBGAPP_H +#define DBGAPP_H +#include + + +#if defined(EDK2) +#include +#include +#include +#elif defined(GNU_EFI) +#include +#endif + +/* On a native MSABI compiler, the wrapper is not needed. */ +#ifdef uefi_call_wrapper +#define uefi(func, count, ...) uefi_call_wrapper(func, count, __VA_ARGS__) +#else +#define uefi(func, count, ...) func(__VA_ARGS__) +#endif + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + + +typedef void (* test_func)(); + +/** + * Notify the debugger via a probe mode redirect and exchange data with it. + * @param to_dbg Data to be "sent" to the debugger. + * @return Data "received" from the debugger. + */ +uint64_t notify_debugger(uint64_t to_dbg); +void print_str(CHAR16 *str); + +#endif /* DBGAPP_H */ diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/src/debugchecker.c b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/debugchecker.c new file mode 100644 index 0000000000..6f669b1c3e --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/debugchecker.c @@ -0,0 +1,121 @@ +/** + * @file debugchecker.c + * @brief functinos to check if debugging is enabled + * + * +Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + */ + +#include "debugchecker.h" +#include "dbgapp.h" +#include "asmutils.h" +#include "functions.h" + + +UINT32 gCPU_Family; +UINT32 gCPU_Model; + +// Call-to-action variables +UINT8 u8Run_Control; +UINT8 u8Processor_Trace; +UINT8 u8Three_Strike; +UINT16 u16SelectedIndex; + +/** +// Display Processor Version Information +*/ +static void ProcessorVersionInfo() { + CPUID_VERSION_INFO_EAX Eax; + _cpuid(CPUID_VERSION_INFO, &Eax.Uint32, 0, 0, + 0); + + gCPU_Family = Eax.Bits.FamilyId; + gCPU_Model = Eax.Bits.Model; + if (Eax.Bits.FamilyId == 0x06 || Eax.Bits.FamilyId == 0x0F) { + gCPU_Model |= (Eax.Bits.ExtendedModelId << 4); + } + + print_str(L"Family:"); + print_uint64((uint64_t) gCPU_Family); + print_str(L"Model:"); + print_uint64((uint64_t) gCPU_Model); + print_str(L"Stepping:"); + print_uint64((uint64_t) Eax.Bits.SteppingId); + +} + +static void CheckRunControl() { + UINT64 u64Debug = read_msr(DEBUG_PRIVACY_MSR); + u8Run_Control = u64Debug & 0x1; + + print_str(L"Phase-2: Platform Debug Enabling checking" ); + + if (u8Run_Control) { + print_str(L"Run Control is enabled"); + } else { + print_str(L"Run Control is disabled"); + } +} + +static void CheckProcessorTrace() { + UINT64 u64Debug = read_msr(IA32_RTIT_CTL); + u8Processor_Trace = u64Debug & 0x1; + + print_str(L"Phase-3: Intel(r) Process Trace Enabling checking" ); + + if (u8Processor_Trace) { + print_str(L"Intel(R) Processor Trace is enabled"); + } else { + print_str(L"Intel(R) Processor Trace is disabled"); + } +} + +VOID CheckThreeStrike() { + UINT64 u64Debug = read_msr(THREE_STRIKE_DISABLE); + u8Three_Strike = (u64Debug & 0x0080) ? 1 : 0; // 0000 1000 0000 0000 - bit 11 + + print_str(L"Phase-4: Crash Log configuration checking" ); + if (u8Three_Strike) { + print_str(L"Three Strike is enabled"); + } else { + print_str(L"Three Strike is disabled"); + } +} + +static void checkDCIStatus(UINT32 u32Enabling_Status) { + + print_str(L"Phase-1: Host-Target connectivity checking" ); + + if (u32Enabling_Status) { + print_str(L"Platform Debug Consent is enabled."); + } else { + print_str(L"Platform Debug Consent is disabled."); + } +} + +void getDbgInfo() { + + UINT32 u32ECTRL_register; + UINT32 u32ECTRL_register_address; + + // First, gather the information about this processor. + ProcessorVersionInfo(); + + // With processor info, different models have the ECTRL register at different + // addresses. + if (gCPU_Model > 0x86) { + u32ECTRL_register_address = 0xFDB80004; + } else { + u32ECTRL_register_address = 0xD0A80004; + } + + u32ECTRL_register = MmioReadEfi(u32ECTRL_register_address); + + UINT32 u32Enabling_Status = (u32ECTRL_register & BIT_MASK_HDCIEN) >> 4; + checkDCIStatus(u32Enabling_Status); + CheckRunControl(); + CheckProcessorTrace(); + CheckThreeStrike(); + +} \ No newline at end of file diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/src/debugchecker.h b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/debugchecker.h new file mode 100644 index 0000000000..8fb3038750 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/debugchecker.h @@ -0,0 +1,50 @@ +/** @file +debugchecker library functions. + + +Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef DEBUG_CHECKER_H +#define DEBUG_CHECKER_H + +#if defined(EDK2) +#include + +#include +#include +#include +#include +#include +#include +#include + +#elif defined(GNU_EFI) +#include +#endif + +#if defined(EDK2_LIN) || defined(EDK2) +#include +#endif + +// Bit 4 of DCI Control Register +#define BIT_MASK_HDCIEN (1 << 4) + +#define DEBUG_PRIVACY_MSR (0xC80) +#define IA32_RTIT_CTL (0x570) +#define THREE_STRIKE_DISABLE (0x1A4) + +// CPU ID information +extern UINT32 gCPU_Family; +extern UINT32 gCPU_Model; + +// Call-to-action variables +extern UINT8 u8Run_Control; +extern UINT8 u8Processor_Trace; +extern UINT8 u8Three_Strike; +extern UINT16 u16SelectedIndex; + +void getDbgInfo(); + +#endif // DEBUG_CHECKER_H_ diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/src/functions.c b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/functions.c new file mode 100644 index 0000000000..271872afc1 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/functions.c @@ -0,0 +1,252 @@ + + /** + * + * @file functions.c + * @brief helper functions for efi application +Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + */ + +#include "functions.h" + +static unsigned fibo(unsigned n) { /* step_into_result marker */ + unsigned ret; + + if (n <= 1) { + return 1; /* calls_test_breakpoint marker */ + } + + ret = fibo(n - 1) + fibo(n - 2); + + return ret; +} + + +void trigger_smm() { + write_io(0xd2, 1); +} + +static int test_print_count = 0; +static void test_print() { + if (test_print_count<5) { + print_str(L"test print !!! "); + } + if (test_print_count > 30000) { test_print_count = 0; } + test_print_count++; +} + +inline void test_inline() { + /* Check callstack: + -> The stackframe on thread 0 should display the following: + [dbgapp.efi] test_inline():... + [dbgapp.efi] efi_main():... + */ + + /* Check local variables: Open "Variables" view and step into the instructions below + -> Variables are declared with proper types and values, values of a change accordingly to instructions + */ + unsigned int a = 5; + char c = 'c'; + a++; + a--; + c++; + c--; + + /* Step Into: Click on "Step Into (F5)". Perform multiple Step Into to return inside this function + -> pointer moves inside the print_str() function + */ + print_str(L"inline test ! "); + + /* Step Over: Click on "Step Over (F6)" + -> pointer moves to line below without entering the function below + */ + print_str(L"Step over this"); + + /* Run until caller: Click on "Run until caller (F7)" + -> Pointer exits this function and comes back to efi_main() function + */ +} + +static void test_primitive_types(unsigned int int1, char char1) { + unsigned char uc = 'u'; + char c = 'c'; + signed char sc = -2; + unsigned int ui = 2; + signed int si =-3; + int t[4]={0,1,3,3}; + bool b = true; + float f = 3.14e+0f; + double d = 3.14444466666; + volatile int vi = 5; + uc++; /* variable_test1_breakpoint marker */ + uc--; + c = (char) (char1 + 10); + sc = (char) (c + sc); + t[2]=(int)ui; + ui = (unsigned int)uc + int1; + si *= t[2]; + b = t[0] && b; + f = (float) (f*5); + d *= vi; +} /* variable_test2_breakpoint marker */ + + +/** + Used to serialize load and store operations. + + All loads and stores that proceed calls to this function are guaranteed to be + globally visible when this function returns. + +**/ +VOID +EFIAPI +MemoryFence ( + VOID + ) +{ + return; +} + + + +UINT32 +EFIAPI +MmioReadEfi (UINTN Address) +{ + UINT32 Value; + MemoryFence (); + Value = *(volatile UINT32*)Address; + MemoryFence (); + + return Value; +} + + + +/* Print a 64-bit value in hexadecimal. */ +void print_uint64(uint64_t x) { + CHAR16 str[] = L"0000000000000000"; + + for (unsigned i = 15; x && (i < ARRAY_SIZE(str)); i--) { + const int digit = x & 0xf; + str[i] = (CHAR16)(digit > 9 ? (L'a' + digit - 0xa) : (L'0' + digit)); + x >>= 4; + } + + print_str(str); +} + +/** + * Get the image base virtual address. + */ +uint64_t get_image_base(EFI_HANDLE img) { + EFI_LOADED_IMAGE *loaded = NULL; + EFI_STATUS ret = EFI_SUCCESS; + EFI_GUID prot = LOADED_IMAGE_PROTOCOL; + uint64_t base; + + ret = uefi(g_st->BootServices->HandleProtocol, 3, img, &prot, &loaded); + if (ret != EFI_SUCCESS) { + print_str(L"Failed to get the image base address"); + return 0; + } + + if (!loaded) { + print_str(L"LOADED_IMAGE_PROTOCOL returned NULL"); + return 0; + } + + base = (uint64_t)loaded->ImageBase; + return base; +} + +uint64_t notify_debugger(uint64_t to_dbg) { + uint64_t r11; + static const uint16_t contract_io_port = 0x90; + static const uint16_t contract_io_value = 0xcafe; + + /* Write the data to be consumed by the debugger. */ + write_r11(to_dbg); + /* Give control to the debugger. */ +#ifdef BADLY_BEHAVED + probe_mode_redirect(); +#else + write_io(contract_io_port, contract_io_value); + /* Get the data from the debugger. */ +#endif + r11 = read_r11(); + + return r11; +} + +void print_banner(uint64_t base) { + print_str(L"\r\nIntel System Studio test application\r\n"); + print_str(L"Built on " __DATE__ " at " __TIME__); + print_str(L"Toolchain: " TOOLCHAIN); + print_str(L"Framework: " EFI_FRAMEWORK); + print_str(L"EFI image base address:"); + print_uint64(base); +} + +void print_str(CHAR16 *str) { + print_str_out(str, 1); +} + +/** + * Free a buffer allocated with malloc(). + */ +inline void efi_free(void *buf, unsigned size) { + if (!buf) + return; + + const unsigned pages = size2pages(size); + + uefi(g_st->BootServices->FreePages, 2, (EFI_PHYSICAL_ADDRESS)buf, pages); +} + +/* Check if an address is in the memory range of a given buffer. */ +inline int in_buffer(EFI_VIRTUAL_ADDRESS addr, const void *buf, unsigned size) { + const EFI_VIRTUAL_ADDRESS b = (EFI_VIRTUAL_ADDRESS)buf; + + return (b <= addr) && (addr < (b + size)); +} + + +unsigned int cpu_dead_loop() +{ + post(0xdead); + + volatile unsigned int wait = 1; + volatile unsigned long dummy = 0; + while (wait) { /* hardware_breakpoint marker */ + dummy += 0xcafe; + } + + return wait; +} + + +int +d(void) +{ + return 4711; +} + +int +c(int z) +{ + return z * d(); +} + +int +b(int y, int z) +{ + return y * c(z); +} + +int +callstack(int x, int y, int z) +{ + return x * b(y, z); +} + diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/src/functions.h b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/functions.h new file mode 100644 index 0000000000..8f8d302144 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/functions.h @@ -0,0 +1,136 @@ +/** + * @file main.c + * @brief Main file (entry point) for the debugger EFI test app (inferior). +Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + */ +#ifndef FUNCTIONS_H +#define FUNCTIONS_H + +#include "asmutils.h" +#include "dbgapp.h" +#include + + + +#if defined(__clang__) +#define TOOLCHAIN L"LLVM Clang" +#elif defined(__GNUC__) +#define TOOLCHAIN L"GCC" +#elif defined(_MSC_VER) +#define TOOLCHAIN L"Microsoft Visual C++" +// Needed for Visual Studio linker +#endif + +#if defined(GNU_EFI) +#define EFI_FRAMEWORK "GNU EFI" +#elif defined(EDK2) +#define EFI_FRAMEWORK "EDK2" +#else +#define EFI_FRAMEWORK "UNKNOWN" +#endif + +#ifndef PAGE_SIZE +#define PAGE_SIZE (1 << 12) +#endif + +#define IA32_SYSENTER_EIP 0x176 + + +extern const EFI_SYSTEM_TABLE *g_st; + +inline unsigned size2pages(unsigned size) { + return (size / PAGE_SIZE) + ((size % PAGE_SIZE) ? 1 : 0); +} + +/** + * Allocate a memory buffer that can be also used to store UEFI app code. + * @param size Size of the buffer in bytes. + * @return A pointer to the newly allocated buffer (virtual address). + */ +inline void * efi_malloc(unsigned size) { + EFI_PHYSICAL_ADDRESS phys = 0; + EFI_STATUS ret; + const unsigned pages = size2pages(size); + + ret = uefi(g_st->BootServices->AllocatePages, 4, + AllocateAnyPages, EfiLoaderCode, pages, &phys); + + /* We are running in with identity mapping (virt == phys). */ + return ret == EFI_SUCCESS ? (void *)phys : NULL; +} + + +/** + * Print a single (wide) string on the console. default ends with NewLine + */ +static inline void print_str_out(CHAR16 *str, int endWithNewLine) { + SIMPLE_TEXT_OUTPUT_INTERFACE *out = g_st->ConOut; + static CHAR16 crlf[] = L"\r\n"; + + if (!out) { + return; + } + uefi(out->OutputString, 2, out, str); + + if (endWithNewLine) { + uefi(out->OutputString, 2, out, crlf); + } +} + +/** + * Runs an infinite deadloop for the cpu + */ +unsigned int cpu_dead_loop(); + +/** + * Print a single (wide) string on the console + */ +void print_str(CHAR16 *str); + +/** + * Print a sing unsigned int to the console + */ +void print_uint64(uint64_t x); + +/** + * Get the image base virtual address. + */ +uint64_t get_image_base(EFI_HANDLE img); + + +/** + * Write a value to r11, and notify the debugger by writing to io port 0x90 + * @param to_dbg value to write to r1q1 + */ +uint64_t notify_debugger(uint64_t to_dbg); + + +/** + * Print the banner to the efi console + * + */ +void print_banner(uint64_t base); + +/** + * Function to simulate callstack behaviour + * + */ +int +callstack(int x, int y, int z); + +/** + * Triggers smm entry using an io port write + * + */ +void trigger_smm(); + +/** + * Function to simulate callstack behaviour + * + */ +UINT32 +EFIAPI +MmioReadEfi (UINTN Address); + +#endif \ No newline at end of file diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/src/main.c b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/main.c new file mode 100644 index 0000000000..6605194b60 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/src/main.c @@ -0,0 +1,50 @@ +/** + * @file main.c + * @brief Main file (entry point) for the debugger EFI test app (inferior). + * + * +Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + */ + +#include "asmutils.h" +#include "dbgapp.h" +#include "functions.h" +#include "debugchecker.h" +#include + +const EFI_SYSTEM_TABLE *g_st; + +int var = 0; + +EFI_STATUS EFIAPI efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *st) { + static const uint32_t msr_addr = IA32_SYSENTER_EIP; + + volatile unsigned app_size = 0; + void *app_buf = NULL; + uint64_t base; + if (!st) { + return EFI_INVALID_PARAMETER; + } + g_st = st; + + + print_str(L"Welcome to the test application"); + base = get_image_base(image); + print_banner(base); + getDbgInfo(); + + + +#ifdef BADLY_BEHAVED + notify_debugger(15); +#else + notify_debugger(12); +#endif + + int x = var, y = 3, z = 5; + callstack(x, y, z); + cpu_dead_loop(); + + return EFI_SUCCESS; +} diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/tools/make_boot_media.ps1 b/Tools/SystemDebug/system_debug_sample_build/efi_application/tools/make_boot_media.ps1 new file mode 100644 index 0000000000..7a598704e5 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/tools/make_boot_media.ps1 @@ -0,0 +1,238 @@ +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent + + +#Following code taken off https://docs.microsoft.com/en-us/archive/blogs/virtual_pc_guy/a-self-elevating-powershell-script +$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent() +$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID) + +# Get the security principal for the Administrator role +$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator + + # Check to see if we are currently running "as Administrator" + if (-Not $myWindowsPrincipal.IsInRole($adminRole)) + { + # We are not running "as Administrator" - so relaunch as administrator + + # Create a new process object that starts PowerShell + $newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell"; + + # Specify the current script path and name as a parameter + $newProcess.Arguments = $myInvocation.MyCommand.Definition + $args; + + # Indicate that the process should be elevated + $newProcess.Verb = "runas"; + # Start the new process + [System.Diagnostics.Process]::Start($newProcess); + # Exit from the current, unelevated, process + exit + } + + +Add-Type -AssemblyName System.Windows.Forms +$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ + InitialDirectory = [Environment]::GetFolderPath('Desktop') + Title = 'Select EFI Application to flash' +} +$null = $FileBrowser.ShowDialog() + +$EFI = $FileBrowser.FileName; + +if ([string]::IsNullOrWhitespace($EFI)) { + Write-Error "Error: no file selected" + exit +} +$Results = Get-Disk | +Where-Object BusType -eq USB | +Out-GridView -Title 'Select USB Drive to Format' -OutputMode Single | +Clear-Disk -RemoveData -PassThru | +New-Partition -UseMaximumSize -GptType "{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}" -AssignDriveLetter | +Format-Volume -NewFileSystemLabel "EFI" -FileSystem FAT32 -Force + +if ([string]::IsNullOrWhitespace($Results.DriveLetter)) { + Write-Error "Error: no file selected" + exit +} +$USBDrive = ($Results.DriveLetter + ':\') + +$RelativePath = "\\EFI\\Boot" +$DestPath = $USBDrive + $RelativePath +New-Item -ItemType Directory -Path $DestPath -Force +Copy-Item $EFI -Destination $DestPath\\bootx64.efi +if(-not $?) { + Write-Warning "Copy Failed" +} +else { + Write-Host "Operation has Completed Successfully" +} + +# SIG # Begin signature block +# MIIfZQYJKoZIhvcNAQcCoIIfVjCCH1ICAQExDzANBglghkgBZQMEAgEFADB5Bgor +# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDsfhbAQztu4CX8 +# Idbfo0oY+iGN5brAUXdHD8z4Qvppi6CCDTkwggXoMIID0KADAgECAhNWAAAJIdwC +# 4/0t9Fa0AAAAAAkhMA0GCSqGSIb3DQEBCwUAMHMxCzAJBgNVBAYTAlVTMQswCQYD +# VQQIEwJDQTEUMBIGA1U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VjByLGDBFkM0a136QGiZEK8wzId+kwDLCWz9SbD1Dg/scl +# tvwzvgRNqlJhTzwwT8LFKz+uCHZYse2PcA== +# SIG # End signature block diff --git a/Tools/SystemDebug/system_debug_sample_build/efi_application/tools/make_boot_media.sh b/Tools/SystemDebug/system_debug_sample_build/efi_application/tools/make_boot_media.sh new file mode 100644 index 0000000000..d5142e062d --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/efi_application/tools/make_boot_media.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent + +# Create a bootable USB thumb drive loaded with a given EFI application. +# +# WARNING WARNING WARNING!!! This will erase the USB drive + +if [ $# -ne 2 ] ; then + echo "USAGE: make-boot-media.sh <.efi file> " + exit 1 +fi + +EFI=$1 +DEV=$2 + +set -e +set -x +sync + +if [ "$(uname)" == "Darwin" ]; then + NAME="TEST" + sudo gpt destroy /dev/disk2 + sudo gpt create /dev/disk2 + sudo gpt add -i 1 -b 2048 -s 2095104 -t efi $DEV + sudo newfs_msdos -v $NAME /dev/disk2s1 + sudo diskutil mount /dev/disk2s1 + + BOOTDIR=/Volumes/$NAME/EFI/boot + sudo mkdir -p $BOOTDIR + + sudo cp -v $EFI $BOOTDIR/bootx64.efi + sync + sudo diskutil unmountDisk $DEV + +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + sudo parted -s -a minimal $DEV -- \ + mklabel gpt \ + mkpart EFI FAT32 1MiB 1024MiB \ + toggle 1 boot + + sync + sudo mkfs.vfat "$DEV"1 + + sudo parted $DEV -s print + + MOUNTDIR=$(mktemp -d --suffix=_mount_point) + sudo mount -o umask=000,dmask=000 "$DEV"1 $MOUNTDIR + + BOOTDIR=$MOUNTDIR/EFI/boot + mkdir -p $BOOTDIR + + cp -v $EFI $BOOTDIR/bootx64.efi + + sync + sudo umount $MOUNTDIR + + rm -rfv $MOUNTDIR + +else + echo "Only Mac OS and Linux are supported" +fi diff --git a/Tools/SystemDebug/system_debug_sample_build/python/sysdbg.py b/Tools/SystemDebug/system_debug_sample_build/python/sysdbg.py new file mode 100644 index 0000000000..d11cf1c512 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/python/sysdbg.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +''' +============================================================== + Copyright © 2019 Intel Corporation + + SPDX-License-Identifier: MIT +============================================================== +''' + +import intel.sysdbg + +intel.sysdbg.connect() + +threads = intel.sysdbg.threads +target = intel.sysdbg.target + +target.suspend() +threads[0].symbols.load_this() +threads[0].symbols.load_dxe() + +threads[0].frames[0].symbols.find("x")[0].value().string() + +threads[0].breakpoints.add(condition="Reset") + +target.platform.reset() + +target.resume() \ No newline at end of file diff --git a/Tools/SystemDebug/system_debug_sample_build/python/tca.py b/Tools/SystemDebug/system_debug_sample_build/python/tca.py new file mode 100644 index 0000000000..e2115b0532 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/python/tca.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +''' +============================================================== + Copyright © 2019 Intel Corporation + + SPDX-License-Identifier: MIT +============================================================== +''' + +import intel.tca as tca + +target = tca.get_target(id="whl_u_cnp_lp") +components = [(c.component, tca.latest(c.steppings)) + for c in target.components] +component_config = tca.ComponentWithSelectedSteppingList() +for comp in components: + config_tmp = tca.ComponentWithSelectedStepping() + config_tmp.component, config_tmp.stepping = comp +supported_connections = target.get_supported_connection_configurations( + component_config) + + +def conn_filter(conn: tca.ConnectionConfiguration) -> bool: + if conn.type != tca.ConnectionType_IPC: + return False + if "CCA" not in conn.ipc_configuration.selection: + return False + return True + + +connection_config = next(filter(conn_filter, supported_connections)) +profile = tca.Profile() +profile.name = "My TCA profile" +profile.target = target +profile.component_configuration = component_config +profile.connection_configuration = connection_config +tca.load(profile) +tca.connect() diff --git a/Tools/SystemDebug/system_debug_sample_build/python/trace.py b/Tools/SystemDebug/system_debug_sample_build/python/trace.py new file mode 100644 index 0000000000..fbeb60c3a6 --- /dev/null +++ b/Tools/SystemDebug/system_debug_sample_build/python/trace.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 + +''' +============================================================== + Copyright © 2019 Intel Corporation + + SPDX-License-Identifier: MIT +============================================================== +''' + + +''' +OneApi tracecli example. Decode AET data to csv. +''' + +import os +from intel.tracecli import TraceAPI +from intel.tracecli.session.sessionconfiguration import \ + init_session_configuration, get_session_configuration + + +def main(npk_root: str): + ''' + Simple main to decode an trace binary containing AET data using the + TraceCLI. + :param npk_root: Full path to an NPK_ROOT directory + ''' + + # Path to trace bin file + file_bin = f"{npk_root}/examples/input/mipi_aet_fake_trace.bin" + + # Initialize the session config + init_session_configuration(npk_root) + session_config = get_session_configuration() + + # Set the PVSS + pvss = "CMP:H:A0:green" + session_config._set_target_by_pvss(pvss) + trace = TraceAPI(root_dir=npk_root) + + # Create the session + session = trace.filedecode_session() + + # Start decode immediately (no need to wait for async) + session.set_decoder_parameter("MIPI_Decoder", 'startAtAsync', 'false') + session.pvss = pvss + + # General decode (vs. raw packet decode) + session.usecase = "CMP General decode" + + # Start the decode + session.decode_file(file_bin) + + # Print the csv to stdout + session.show_output() + + +if __name__ == "__main__": + # Assume an NPK_ROOT envar, else use the current directory + main(os.getenv("NPK_ROOT", './'))