Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .Makefile.template
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ clean: $(CLEAN)

HELP_distclean = make clean $(DISTCLEAN)
.PHONY: distclean
distclean: clean $(DISTCLEAN)
distclean: $(DISTCLEAN)

.PHONY: help
help:
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build test

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: build idf image
run: make -C docker idf-image
- name: build idf test project
run: make -C docker idf DOCKEROPTS=--tty=false EXEC="cd test; idf.py build"
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- uses: actions/checkout@v1
- name: build platformio image
run: make -C docker platformio-image
- name: build platformio project
run: make -C docker pio DOCKEROPTS=--tty=false EXEC="pio run"
- name: build idf image
run: make -C docker idf-image
- name: build idf project
run: make -C docker idf DOCKEROPTS=--tty=false EXEC="idf.py build"
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.pio
.vscode
.dev
.dev
build
sdkconfig
sdkconfig.old
67 changes: 0 additions & 67 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(lifesensor)
136 changes: 74 additions & 62 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ VARIABLE+=DEV
HELP_DEV=which device to flash/monitor
DEV?=none

VARIABLE+=PIO_ENV
HELP_PIO_ENV=which platformio environment to use
PIO_ENV?=all
### menuconfig targets ###

ifneq (all,$(PIO_ENV))
PIO_ENV_OPTION=-e $(PIO_ENV)
endif
.PHONY: menuconfig
TARGET += menuconfig
HELP_menuconfig = configures project
menuconfig: | check-docker
@make --no-print-directory -C docker idf EXEC="idf.py menuconfig"

.PHONY: menuconfig-test
TARGET += menuconfig-test
HELP_menuconfig-test = configures test project
menuconfig-test: | check-docker
@make --no-print-directory -C docker idf EXEC="cd test; idf.py menuconfig"

### build targets ###

Expand All @@ -28,19 +34,46 @@ DEFAULT += build
ALL += build
HELP_build = builds project
build: | check-docker
@make --no-print-directory -C docker pio EXEC="pio run $(PIO_ENV_OPTION)"
@make --no-print-directory -C docker idf EXEC="idf.py build"

.PHONY: clean-build
CLEAN += clean-build
HELP_clean-build = let pio clean generated files
HELP_clean-build = let idf clean generated files
clean-build: | check-docker
@make --no-print-directory -C docker pio EXEC="pio run $(PIO_ENV_OPTION) -t clean"
@make --no-print-directory -C docker idf EXEC="idf.py clean"

.PHONY: distclean-build
DISTCLEAN += distclean-build
HELP_distclean-build = removes all generated files by platformio
distclean-build: clean-build
rm -rf .pio
HELP_distclean-build = removes all generated files
distclean-build:
rm -f sdkconfig
rm -rf build

### test targets ###

.PHONY: test
TARGET += test
HELP_test = build test project, flash it, monitor it
test: build-test flash-test monitor-test

.PHONY: build-test
TARGET_build += build-test
HELP_build-test = builds tests
build-test: | check-docker
@make --no-print-directory -C docker idf EXEC="cd test; idf.py build"

.PHONY: clean-test
CLEAN += clean-test
HELP_clean-test: let idf clean generated files of the test build
clean-test: | check-docker
@make --no-print-directory -C docker idf EXEC="cd test; idf.py clean"

.PHONY: distclean-test
DISTCLEAN += distclean-test
HELP_distclean-test = removes all generated files of the test build
distclean-test:
rm -f test/sdkconfig
rm -rf test/build

### flash targets ###

Expand All @@ -49,13 +82,21 @@ TARGET += flash
HELP_flash = flashes project to esp. Use DEV=path to provide path to device or use make dev
flash: | check-flash
@make --no-print-directory -C docker \
pio \
EXEC="sudo chgrp developer $(DEV); pio run --upload-port '$(DEV)' $(PIO_ENV_OPTION) -t upload" DEV="$(DEV)"
idf \
EXEC="sudo chgrp developer $(DEV); idf.py flash -p '$(DEV)'"

.PHONY: flash-test
TARGET_flash += flash-test
HELP_flash-test = flashes tests to esp. Use DEV=path to provide path to device or use make dev
flash-test: | check-flash
@make --no-print-directory -C docker \
idf \
EXEC="sudo chgrp developer $(DEV); cd test; idf.py flash -p '$(DEV)'"

.PHONY: check-flash
CHECK += check-flash
HELP_check-flash = checks env if flashing is possible
check-flash: | check-docker check-dev check-env
check-flash: | check-docker check-dev

### monitor targets ###

Expand All @@ -64,18 +105,21 @@ TARGET += monitor
HELP_monitor = connects to esp32 via serial. Use DEV=path to provide path to device or use make dev
monitor: | check-monitor
@make --no-print-directory -C docker \
pio \
EXEC="sudo chgrp developer $(DEV); \
python3 \
/home/developer/.platformio/packages/framework-espidf/tools/idf_monitor.py \
.pio/build/$(PIO_ENV)/firmware.elf \
--port $(DEV)" \
DEV=$(DEV)
idf \
EXEC="sudo chgrp developer $(DEV); idf.py monitor -p '$(DEV)'"

.PHONY: monitor-test
TARGET += monitor-test
HELP_monitor-test = connects to esp32 via serial. Use DEV=path to provide path to device or use make dev
monitor-test: | check-monitor
@make --no-print-directory -C docker \
idf \
EXEC="sudo chgrp developer $(DEV); cd test; idf.py monitor -p '$(DEV)'"

.PHONY: check-monitor
CHECK += check-monitor
HELP_check-monitor = checks env if monitor is possible
check-monitor: | check-docker check-dev check-env
check-monitor: | check-docker check-dev

### dev targets ###

Expand All @@ -95,7 +139,9 @@ dev: | check-dialog
CHECK += check-dev
HELP_check-dev = checks if device is specified
check-dev:
@1>&2 echo -n "checking if device is valid & specified..."
ifeq ($(DEV),none)
@1>&2 echo
@1>&2 echo "##############################"
@1>&2 echo "# FLASH DEVICE NOT SPECIFIED #"
@1>&2 echo "##############################"
Expand All @@ -111,6 +157,7 @@ ifeq ($(DEV),none)
@exit 1
endif
ifeq ($(shell ! test -c $(DEV); echo $$?),0)
@1>&2 echo
@1>&2 echo "#############################"
@1>&2 echo "# FLASH DEVICE IS NOT VALID #"
@1>&2 echo "#############################"
Expand All @@ -127,48 +174,15 @@ ifeq ($(shell ! test -c $(DEV); echo $$?),0)
@1>&2 echo
@exit 1
endif

.PHONY: env
TARGET += env
HELP_env = specifies the platformio environment
env: | check-dialog
export PIO_ENV=$$(python -c "import configparser as cp; ini = cp.ConfigParser(); ini.read('platformio.ini'); print(' '.join([x.split(':')[1]+' \"\"' for x in ini.sections() if ':' in x]))" \
| dialog \
--stdout \
--menu "Choose Platformio Environment" 0 0 0 "all" "use all platformio environments" \
--file /dev/stdin); \
clear; \
exec $(USERSHELL)

.PHONY:
CHECK += check-env
HELP_check-env = checks if environment was specified
check-env:
ifeq (all,$(PIO_ENV))
@1>&2 echo "##################################"
@1>&2 echo "# ALL ENVIRONMENTS ARE SELECTED #"
@1>&2 echo "##################################"
@1>&2 echo
@1>&2 echo "this is fine, as long as you build,"
@1>&2 echo "but needs to be specified if you want to do other things"
@1>&2 echo
@1>&2 echo "specify platformio environment by adding PIO_ENV as parameter"
@1>&2 echo
@1>&2 echo "make $(MAKECMDGOALS) PIO_ENV=environment"
@1>&2 echo
@1>&2 echo "or by running"
@1>&2 echo
@1>&2 echo "make env"
@1>&2 echo
@exit 1
endif

@1>&2 echo "SUCCESS"

.PHONY: check-dialog
CHECK += check-dialog
HELP_check-dialog = checks if dialog is installed
check-dialog:
@1>&2 echo -n "checking if dialog is installed..."
ifeq ($(shell which dialog 2> /dev/null),)
@1>&2 echo
@1>&2 echo "###########################"
@1>&2 echo "# DIALOG IS NOT INSTALLED #"
@1>&2 echo "###########################"
Expand All @@ -183,9 +197,7 @@ ifeq ($(shell which dialog 2> /dev/null),)
@1>&2 echo
@exit 1
endif



@1>&2 echo "SUCCESS"

### docker targets ###

Expand Down
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,53 @@
# LifeSensor -- Esp32-core
ESP32 firmware for the lifesensor project.

This repo is part of the LifeSensor project.
## Components
See [components/README.md](components/README.md) for an overview of features.

## Building

* via Docker
* Run `make help` to see all options
1. Choosing device
* `make dev`
* configures which serial port to use
2. Building
* `make build`
1. creates idf docker image if needed
2. starts idf docker container to build project
3. Flashing
* `make flash`
1. creates idf docker image if needed
2. starts idf docker container to flash project to connected ESP via specified device by `make dev`
4. Monitoring
* `make monitor`
1. creates idf docker image if needed
2. starts idf docker container to connect to ESP via specified device by `make dev`
* via local esd-idf toolchain
1. Building
* `idf.py build`
2. Flashing
* `idf.py flash -p <device>`
3. Monitoring
* `idf.py monitor -p <device>`

## Testing
* via docker
* Run `make help` to see all options
1. `make test`
1. creates idf docker image
2. starts idf docker container to build test project (`make build-test`)
3. starts idf docker container to flash the test project to ESP via specified device by `make dev` (`make flash-test`)
4. starts idf docker container to connect to ESP via specified device by `make dev` (`make monitor-test`)
* via local esd-idf toolchain
1. Change to test project
* `cd test`
2. Building
* `idf.py build`
3. Flashing
* `idf.py flash -p <device>`
4. Monitoring
* `idf.py monitor -p <device>`

## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
Loading