Skip to content

Create gitpod workspace #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 80 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
ee941c7
Initial gitpod support and readme button
Oct 9, 2021
dafcc70
I want zephyr to be imported into the example
Oct 9, 2021
892cc69
Fix file name
Oct 9, 2021
f40a8ae
remove incorect file name
Oct 9, 2021
92ee93c
Could have swore I had a dot in the name
Oct 9, 2021
36737af
Try using alternate syntax for referencing env var
Oct 9, 2021
9365fb1
Ugh
Oct 9, 2021
bb9cdfa
Adjust apt calls to work around docker cache quirk
Oct 9, 2021
5473545
ENV var arleady set in base image
Oct 9, 2021
8c753fc
Init west in the root of the example
Oct 9, 2021
b9c9243
GITPOD_REPO_ROOT not set yet move to .gitpod.yml
Oct 9, 2021
b6f0505
add west completion and ZEPHYR_BASE to init session
Oct 9, 2021
a8c247d
Remove running of west completion script
Oct 9, 2021
5a0a0d3
Stray single quote
Oct 9, 2021
ee446e2
goliothctl not absolutely necessarry
Oct 10, 2021
1484bcf
very supersticious
Oct 10, 2021
fc8d1bf
simplify
Oct 10, 2021
e99385a
Flailing
Oct 10, 2021
aa4caa8
flailing2
Oct 10, 2021
054c9b9
next flail
Oct 10, 2021
d6f481b
switch back to modifying .bashrc
Oct 10, 2021
9bcd729
add west before completion
Oct 10, 2021
3f268f5
fix west completion command
Oct 10, 2021
8bb820d
Oh thats what export does
Oct 10, 2021
f9238c6
simplify
Oct 10, 2021
8aaa63f
Playing around
Oct 10, 2021
b0a43f1
Fix gitlink
Oct 10, 2021
2c84247
remove init since the repository is pre-initialized
Oct 10, 2021
ccd61c9
Try out envirnment task
Oct 10, 2021
04c5787
use gp env instead
Oct 10, 2021
9b7f2dc
| ! \
Oct 10, 2021
e1c58e0
update .gitignore
Oct 12, 2021
9d01f5e
pin zephyr version
Oct 12, 2021
c72c593
Did I do this or did west build?
Oct 12, 2021
8da447a
Update container, remove now redundant env var
Oct 12, 2021
4ce07f7
revert to manually updating env var
Oct 12, 2021
54a3985
Remove west update
Oct 12, 2021
cb9a07c
open ports for gsb on localhost
Oct 12, 2021
084d9e3
New container didn't negate need for install dir
Oct 13, 2021
c140c0b
Move gitpod specific items under .gitpod/
Oct 13, 2021
d0a12f1
Re add install dir
Oct 13, 2021
4b72bf2
strip out application pieces specific to custom_plank target
vancefarren Oct 13, 2021
6231772
remove port specification
vancefarren Oct 13, 2021
e528c7a
update gitignore to track launch.json in .vscode folder
vancefarren Oct 13, 2021
8fb781d
Merge branch 'zephyrproject-rtos:main' into gitpod
Oct 14, 2021
217a177
remove zephyr sdk env var
Oct 14, 2021
5b5db8e
Add back zephyr sdk env var
Oct 14, 2021
a1eb146
Add toolchain to path
Oct 14, 2021
37ec091
Install libncurses5
Oct 14, 2021
322e6be
Install libncuses5 as root
Oct 14, 2021
acb909f
Add golioth zephyr sdk as a dependency
Oct 18, 2021
740e791
Try west updating just golioth
Oct 18, 2021
c8469ec
Try west update again
Oct 21, 2021
848a28a
West init in dockerfile
Oct 21, 2021
da9644b
create workspace directory
Oct 21, 2021
737da4a
expoeriment
Oct 21, 2021
cf0bb6a
create workspace dir as root
Oct 21, 2021
e22d815
sudo
Oct 21, 2021
a9f0bc3
remove west update
Oct 21, 2021
20ca1ab
example applicaiton
Oct 21, 2021
793cd77
Merge branch 'gitpod' of https://github.com/golioth/example-applicati…
Oct 21, 2021
1739f03
sudo
Oct 21, 2021
5a6d95a
workspace directory
Oct 21, 2021
b55cfca
West init in workdir
Oct 21, 2021
ffe6b5d
why is zephyr base set?
Oct 22, 2021
cad8efd
workaround
Oct 22, 2021
8c61ff7
init from workaround
Oct 22, 2021
7bff143
use clone approach
Oct 22, 2021
056cef1
give gitpod ownership of /workaround
Oct 22, 2021
5c7420d
lowercase cd
Oct 22, 2021
0c2348c
west update from within example
Oct 22, 2021
eb9a7f5
cd twice
Oct 22, 2021
0093faf
sudo
Oct 22, 2021
3b4ae15
fix git clone
Oct 22, 2021
26fc162
Copy in zephyr then west update
Oct 22, 2021
f6e6cdb
Fix path
Oct 22, 2021
400deab
sudo
Oct 22, 2021
bb22110
sudo
Oct 22, 2021
56a3c14
copy in more
Oct 22, 2021
b9b9f82
create directory as gitpod user
Oct 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# editors
.vscode
*.swp
*~

Expand All @@ -8,3 +7,8 @@

# build
/build*

# zephyr
/zephyr*

/modules*
31 changes: 31 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
image:
file: .gitpod/.gitpod.Dockerfile

#Initialize west workspace inside of the repository cloned by gitpod
tasks:
- name: West Init
init: |
sudo cp -R /workaround/zephyr/ $GITPOD_REPO_ROOT/
sudo cp -R /workaround/modules/ $GITPOD_REPO_ROOT/
sudo cp -R /workaround/golioth/ $GITPOD_REPO_ROOT/
sudo west update


github:
prebuilds:
# enable for the master/default branch (defaults to true)
master: true
# enable for all branches in this repo (defaults to false)
branches: true
# enable for pull requests coming from this repo (defaults to true)
pullRequests: true
# enable for pull requests coming from forks (defaults to false)
pullRequestsFromForks: true
# add a check to pull requests (defaults to true)
addCheck: true
# add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
addComment: false
# add a "Review in Gitpod" button to the pull request's description (defaults to false)
addBadge: true
# add a label once the prebuild is ready to pull requests (defaults to false)
addLabel: true
24 changes: 24 additions & 0 deletions .gitpod/.gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM zephyrprojectrtos/zephyr-build:v0.20.0

USER root

### Gitpod user ###
# https://community.gitpod.io/t/how-to-resolve-password-issue-in-sudo-mode-for-custom-image/2395
#
# '-l': see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod \
# passwordless sudo for users in the 'sudo' group
&& sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers

RUN apt-get update && apt-get install -y libncurses5


USER gitpod
# Zephyr SDK
RUN mkdir /workaround
ENV ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-0.13.1
ENV PATH="/opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/bin:${PATH}"
RUN git clone --branch gitpod https://github.com/golioth/example-application.git /workaround
WORKDIR /workaround
RUN west update
USER root
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb-remote) Debug",
"type": "cortex-debug",
"request": "launch",
"servertype": "external",
"device":"nRF9160_xxAA",
"interface": "swd",
"cwd": "${workspaceRoot}",
"runToMain": true,
"executable": "${workspaceRoot}/build/zephyr/zephyr.elf",
"gdbTarget": "localhost:2331",
}
]
}
7 changes: 7 additions & 0 deletions .west/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[manifest]
path = .
file = app-manifest.west.yml

[zephyr]
base = zephyr

27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/from-referrer/)

----

# Zephyr Example Application

This repository contains a Zephyr example application. The main purpose of this
Expand All @@ -10,25 +15,21 @@ applications. Some of the features demonstrated in this example are:
- Out-of-tree [drivers][drivers]
- Example CI configuration (using Github Actions)

This repository is versioned together with the [Zephyr main tree][zephyr]. This
means that every time that Zephyr is tagged, this repository is tagged as well
with the same version number, and the [manifest](west.yml) entry for `zephyr`
will point to the corresponding Zephyr tag. For example, `example-application`
v2.6.0 will point to Zephyr v2.6.0. Note that the `main` branch will always
point to the development branch of Zephyr, also `main`.

[board_porting]: https://docs.zephyrproject.org/latest/guides/porting/board_porting.html
[bindings]: https://docs.zephyrproject.org/latest/guides/dts/bindings.html
[drivers]: https://docs.zephyrproject.org/latest/reference/drivers/index.html
[zephyr]: https://github.com/zephyrproject-rtos/zephyr

## Getting Started
<br>

Before getting started, make sure you have a proper Zephyr development
environment. You can follow the official
[Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html).
# Getting Started

### Initialization
We reccomend using the provided gitpod workspace template to get started. (Click the button at the top of this readme) Unless of course you are the type of masochist who likes to build houses made from cards.

<br>

# Initialization

The first step is to initialize the workspace folder (``my-workspace``) where
the ``example-application`` and all Zephyr modules will be cloned. You can do
Expand All @@ -42,7 +43,9 @@ cd my-workspace
west update
```

### Build & Run
<br>

# Build & Run

The application can be built by running:

Expand Down
15 changes: 15 additions & 0 deletions app-manifest.west.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

manifest:
projects:
- name: zephyr
revision: v2.7-branch
url: https://github.com/zephyrproject-rtos/zephyr.git
import: true

- name: golioth
revision: main
url: https://github.com/golioth/zephyr-sdk.git
import: true

49 changes: 27 additions & 22 deletions app/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

#include <zephyr.h>
#include <drivers/sensor.h>
//#include <drivers/sensor.h>

#include "app_version.h"

Expand All @@ -14,34 +14,39 @@ LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL);
void main(void)
{
int ret;
const struct device *sensor;
//const struct device *sensor;

printk("Zephyr Example Application %s\n", APP_VERSION_STR);

sensor = DEVICE_DT_GET(DT_NODELABEL(examplesensor0));
if (!device_is_ready(sensor)) {
LOG_ERR("Sensor not ready");
return;
while(1)
{
LOG_ERR("Board Ready");
//wait(100);
}

while (1) {
struct sensor_value val;
// sensor = DEVICE_DT_GET(DT_NODELABEL(examplesensor0));
// if (!device_is_ready(sensor)) {
// LOG_ERR("Sensor not ready");
// return;
// }

ret = sensor_sample_fetch(sensor);
if (ret < 0) {
LOG_ERR("Could not fetch sample (%d)", ret);
return;
}
// while (1) {
// struct sensor_value val;

ret = sensor_channel_get(sensor, SENSOR_CHAN_PROX, &val);
if (ret < 0) {
LOG_ERR("Could not get sample (%d)", ret);
return;
}
// ret = sensor_sample_fetch(sensor);
// if (ret < 0) {
// LOG_ERR("Could not fetch sample (%d)", ret);
// return;
// }

printk("Sensor value: %d\n", val.val1);
// ret = sensor_channel_get(sensor, SENSOR_CHAN_PROX, &val);
// if (ret < 0) {
// LOG_ERR("Could not get sample (%d)", ret);
// return;
// }

k_sleep(K_MSEC(1000));
}
// printk("Sensor value: %d\n", val.val1);

// k_sleep(K_MSEC(1000));
// }
}

16 changes: 0 additions & 16 deletions west.yml

This file was deleted.