From c62136d23f5e0cdd07a6875843f128e0535a0ab4 Mon Sep 17 00:00:00 2001 From: Bilal Wasim Date: Fri, 23 Oct 2020 02:14:24 +0500 Subject: [PATCH 1/4] Adding test samples and updating west.yml file. Seems the west (even latest version) doesn't yet support "main" branch. So using "master" instead.. Signed-off-by: Bilal Wasim --- samples/blinky/CMakeLists.txt | 7 ++++ samples/blinky/README.rst | 44 ++++++++++++++++++++++++++ samples/blinky/prj.conf | 1 + samples/blinky/sample.yaml | 10 ++++++ samples/blinky/src/main.c | 51 ++++++++++++++++++++++++++++++ samples/hello_world/CMakeLists.txt | 8 +++++ samples/hello_world/README.rst | 33 +++++++++++++++++++ samples/hello_world/prj.conf | 1 + samples/hello_world/sample.yaml | 16 ++++++++++ samples/hello_world/src/main.c | 13 ++++++++ west.yml | 8 +++-- 11 files changed, 189 insertions(+), 3 deletions(-) create mode 100644 samples/blinky/CMakeLists.txt create mode 100644 samples/blinky/README.rst create mode 100644 samples/blinky/prj.conf create mode 100644 samples/blinky/sample.yaml create mode 100644 samples/blinky/src/main.c create mode 100644 samples/hello_world/CMakeLists.txt create mode 100644 samples/hello_world/README.rst create mode 100644 samples/hello_world/prj.conf create mode 100644 samples/hello_world/sample.yaml create mode 100644 samples/hello_world/src/main.c diff --git a/samples/blinky/CMakeLists.txt b/samples/blinky/CMakeLists.txt new file mode 100644 index 0000000..54f8909 --- /dev/null +++ b/samples/blinky/CMakeLists.txt @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.13.1) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(blinky) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/blinky/README.rst b/samples/blinky/README.rst new file mode 100644 index 0000000..96f5720 --- /dev/null +++ b/samples/blinky/README.rst @@ -0,0 +1,44 @@ +.. _blinky-sample: + +Blinky +###### + +Overview +******** + +Blinky is a simple application which blinks an LED forever using the :ref:`GPIO +API `. The source code shows how to configure GPIO pins as outputs, +then turn them on and off. + +See :ref:`pwm-blinky-sample` for a sample which uses the PWM API to blink an +LED. + +.. _blinky-sample-requirements: + +Requirements +************ + +You will see this error if you try to build Blinky for an unsupported board: + +.. code-block:: none + + Unsupported board: led0 devicetree alias is not defined + +The board must have an LED connected via a GPIO pin. These are called "User +LEDs" on many of Zephyr's :ref:`boards`. The LED must be configured using the +``led0`` :ref:`devicetree ` alias. This is usually done in the +:ref:`BOARD.dts file ` or a :ref:`devicetree overlay +`. + +Building and Running +******************** + +Build and flash Blinky as follows, changing ``reel_board`` for your board: + +.. zephyr-app-commands:: + :zephyr-app: samples/basic/blinky + :board: reel_board + :goals: build flash + :compact: + +After flashing, the LED starts to blink. Blinky does not print to the console. diff --git a/samples/blinky/prj.conf b/samples/blinky/prj.conf new file mode 100644 index 0000000..91c3c15 --- /dev/null +++ b/samples/blinky/prj.conf @@ -0,0 +1 @@ +CONFIG_GPIO=y diff --git a/samples/blinky/sample.yaml b/samples/blinky/sample.yaml new file mode 100644 index 0000000..9c8ac6f --- /dev/null +++ b/samples/blinky/sample.yaml @@ -0,0 +1,10 @@ +sample: + name: Blinky Sample +tests: + sample.basic.blinky: + tags: LED gpio + filter: dt_compat_enabled_with_alias("gpio-leds", "led0") + depends_on: gpio + harness: led + integration_platforms: + - frdm_k64f diff --git a/samples/blinky/src/main.c b/samples/blinky/src/main.c new file mode 100644 index 0000000..e2fbfd3 --- /dev/null +++ b/samples/blinky/src/main.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +/* 1000 msec = 1 sec */ +#define SLEEP_TIME_MS 1000 + +/* The devicetree node identifier for the "led0" alias. */ +#define LED0_NODE DT_ALIAS(led0) + +#if DT_NODE_HAS_STATUS(LED0_NODE, okay) +#define LED0 DT_GPIO_LABEL(LED0_NODE, gpios) +#define PIN DT_GPIO_PIN(LED0_NODE, gpios) +#define FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios) +#else +/* A build error here means your board isn't set up to blink an LED. */ +#error "Unsupported board: led0 devicetree alias is not defined" +#define LED0 "" +#define PIN 0 +#define FLAGS 0 +#endif + +void main(void) +{ + const struct device *dev; + bool led_is_on = true; + int ret; + + dev = device_get_binding(LED0); + if (dev == NULL) { + return; + } + + ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS); + if (ret < 0) { + return; + } + + while (1) { + gpio_pin_set(dev, PIN, (int)led_is_on); + led_is_on = !led_is_on; + k_msleep(SLEEP_TIME_MS); + } +} diff --git a/samples/hello_world/CMakeLists.txt b/samples/hello_world/CMakeLists.txt new file mode 100644 index 0000000..3e3d0e8 --- /dev/null +++ b/samples/hello_world/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(hello_world) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/hello_world/README.rst b/samples/hello_world/README.rst new file mode 100644 index 0000000..ce5423d --- /dev/null +++ b/samples/hello_world/README.rst @@ -0,0 +1,33 @@ +.. _hello_world: + +Hello World +########### + +Overview +******** + +A simple sample that can be used with any :ref:`supported board ` and +prints "Hello World" to the console. + +Building and Running +******************** + +This application can be built and executed on QEMU as follows: + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :host-os: unix + :board: qemu_x86 + :goals: run + :compact: + +To build for another board, change "qemu_x86" above to that board's name. + +Sample Output +============= + +.. code-block:: console + + Hello World! x86 + +Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`. diff --git a/samples/hello_world/prj.conf b/samples/hello_world/prj.conf new file mode 100644 index 0000000..b2a4ba5 --- /dev/null +++ b/samples/hello_world/prj.conf @@ -0,0 +1 @@ +# nothing here diff --git a/samples/hello_world/sample.yaml b/samples/hello_world/sample.yaml new file mode 100644 index 0000000..bacc394 --- /dev/null +++ b/samples/hello_world/sample.yaml @@ -0,0 +1,16 @@ +sample: + description: Hello World sample, the simplest Zephyr + application + name: hello world +common: + tags: introduction + integration_platforms: + - native_posix + harness: console + harness_config: + type: one_line + regex: + - "Hello World! (.*)" +tests: + sample.basic.helloworld: + tags: introduction diff --git a/samples/hello_world/src/main.c b/samples/hello_world/src/main.c new file mode 100644 index 0000000..6c5c8a2 --- /dev/null +++ b/samples/hello_world/src/main.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2012-2014 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +void main(void) +{ + printk("Hello World! %s\n", CONFIG_BOARD); +} diff --git a/west.yml b/west.yml index 71aafa4..43f7485 100644 --- a/west.yml +++ b/west.yml @@ -1,13 +1,15 @@ -# The west manifest file for Zephyr based ABC board. - manifest: remotes: - name: zephyrproject-rtos url-base: https://github.com/zephyrproject-rtos - name: ABC-fw url-base: https://github.com/ChrisGammell + defaults: + remote: ABC-fw projects: - name: zephyr remote: zephyrproject-rtos - revision: v2.0.0 + revision: v2.4.0 import: true + self: + path: abc_fw From 43a16118fd5eb97b39d4d40cb4ddfad55522f97b Mon Sep 17 00:00:00 2001 From: Bilal Wasim Date: Fri, 23 Oct 2020 02:39:57 +0500 Subject: [PATCH 2/4] Pointing west to the correct zephyr.. --- west.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/west.yml b/west.yml index 43f7485..5aafc40 100644 --- a/west.yml +++ b/west.yml @@ -1,7 +1,7 @@ manifest: remotes: - name: zephyrproject-rtos - url-base: https://github.com/zephyrproject-rtos + url-base: https://github.com/bwasim - name: ABC-fw url-base: https://github.com/ChrisGammell defaults: @@ -9,7 +9,7 @@ manifest: projects: - name: zephyr remote: zephyrproject-rtos - revision: v2.4.0 + revision: ble-cell import: true self: path: abc_fw From a71a21e09c453fa1e13e20b7bd82e462c8968af1 Mon Sep 17 00:00:00 2001 From: Chris Gammell Date: Thu, 22 Oct 2020 18:05:35 -0500 Subject: [PATCH 3/4] Update west.yml Updating west.yml on master branch, as well --- west.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/west.yml b/west.yml index 5aafc40..7512b5c 100644 --- a/west.yml +++ b/west.yml @@ -3,7 +3,8 @@ manifest: - name: zephyrproject-rtos url-base: https://github.com/bwasim - name: ABC-fw - url-base: https://github.com/ChrisGammell + url-base: https://github.com/ContextualElectronics + defaults: remote: ABC-fw projects: From 42bd7068bdbe58248e698bde17895572de63c329 Mon Sep 17 00:00:00 2001 From: Chris Gammell Date: Tue, 29 Dec 2020 14:20:13 -0600 Subject: [PATCH 4/4] Changed build instructions --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 868b493..d3a5c4c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ # ABC-fw -Firmware for the ABC board +Firmware for the ABC board. + +## Installation and usage + +How to get an ABC board working: + +1. Install Zephyr stuff (steps 1-4): https://buff.ly/3ohvK42 +2. west init -m https://github.com/ContextualElectronics/ABC-fw.git +3. west update +4. west build -p auto -b contextualelectronics_abc abc_fw/samples/blinky/ +5. west flash +6. Revel in an ABC board happily blinking at you + +Note: This can be installed in a "fw" directory at the top level of an "ABC" directory, or similar. A normal directory looks like this + +* ABC + * fw + * hw