Skip to content

Commit fe138bf

Browse files
committed
build factory app and releases
1 parent a39a3fb commit fe138bf

File tree

12 files changed

+161
-5
lines changed

12 files changed

+161
-5
lines changed

.github/workflows/release.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
# Sequence of patterns matched against refs/tags
6+
tags:
7+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
8+
9+
jobs:
10+
create_release:
11+
name: Create Release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Get version from tag
15+
id: tag_name
16+
run: |
17+
echo "current_version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
18+
shell: bash
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
- name: Login to GitHub Container Registry
22+
uses: docker/login-action@v3
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.repository_owner }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Build and run Dev Container task
28+
uses: devcontainers/ci@v0.3
29+
with:
30+
# Change this to point to your image name
31+
imageName: ghcr.io/${{ github.repository_owner }}/ebbflowcontrol-devcontainer
32+
# Change this to be your CI task/script
33+
runCmd: |
34+
./build_all.sh
35+
36+
## https://github.com/tj-actions/docker-cp
37+
## Copy the build files from the dev container to the host
38+
- name: Copy build files
39+
uses: tj-actions/docker-cp@v1
40+
with:
41+
src: /workspace/build_app/EbbFlowControl.bin
42+
dest: ./workspace/app.bin
43+
container: ebbflowcontrol-devcontainer
44+
- name: Copy build files
45+
uses: tj-actions/docker-cp@v1
46+
with:
47+
src: /workspace/build_factory/EbbFlowControl.bin
48+
dest: ./workspace/factory.bin
49+
container: ebbflowcontrol-devcontainer
50+
51+
- name: Get Changelog Entry
52+
id: changelog_reader
53+
uses: mindsers/changelog-reader-action@v2
54+
with:
55+
validation_level: warn
56+
version: ${{ steps.tag_name.outputs.current_version }}
57+
path: ./CHANGELOG.md
58+
- name: Create Release
59+
id: create_release
60+
uses: softprops/action-gh-release@v2
61+
with:
62+
tag_name: ${{ steps.changelog_reader.outputs.version }}
63+
name: Release ${{ steps.changelog_reader.outputs.version }}
64+
body: ${{ steps.changelog_reader.outputs.changes }}
65+
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
66+
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
67+
token: ${{ secrets.GITHUB_TOKEN }}
68+
artifacts: ./workspace/app.bin,./workspace/factory.bin

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Mkfile.old
5252
dkms.conf
5353

5454
build/
55+
build_factory/
56+
build_app/
5557
sdkconfig
5658
sdkconfig.old
5759
node_modules

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
# CMakeLists in this exact order for cmake to work correctly
55
cmake_minimum_required(VERSION 3.5)
66

7+
set(SDKCONFIG "${CMAKE_BINARY_DIR}/sdkconfig")
8+
79
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
810
project(EbbFlowControl)

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55

66
This repository hold the software for a controller for an automated ebb flow hydroponic grow system. The controller runs on an ESP32 and can be configured via MQTT. The MQTT connection is additionally used to send status information and data for monitoring to an overall system.
77

8+
## Over the Air (OTA) updates
9+
10+
## Factory vs Application
11+
12+
- Build application: `idf.py @profiles/app build`
13+
- Flash application: `idf.py -B build_app flash`
14+
- Build factory: `idf.py @profiles/factory build`
15+
- Flash factory: `idf.py -B build_app flash`
16+
817
## Build and Flash
918

1019
The easiest way to build the software is to run the Docker devcontainer.

build_all.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
# Build script for two apps
4+
5+
set -e
6+
7+
echo "Building Application"
8+
idf.py @profiles/app build || { echo "Application build failed"; exit -1; }
9+
10+
echo "Building Factory"
11+
idf.py @profiles/factory build || { echo "Factory build failed"; exit -1; }
12+
13+
echo "Build finished.."
14+
exit 0

main/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
idf_component_register(SRCS "main.c" INCLUDE_DIRS ".")
1+
if(CONFIG_BUILD_FACTORY)
2+
idf_component_register(SRCS "main_factory.c" INCLUDE_DIRS ".")
3+
else()
4+
idf_component_register(SRCS "main.c" INCLUDE_DIRS ".")
5+
endif()

main/Kconfig.projbuild

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,12 @@ menu "Application Configuration"
2323
help
2424
Set the URI to the MQTT broker.
2525

26+
config BUILD_FACTORY
27+
bool "Build factory firmware"
28+
default n
29+
help
30+
If enabled, the factory firmware will be built instead of the normal application.
31+
This is useful for initial setup or testing purposes.
32+
2633

2734
endmenu

main/main_factory.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include "esp_log.h"
2+
// #include "esp_spiffs.h"
3+
// #include "esp_vfs.h"
4+
#include <esp_err.h>
5+
#include <nvs_flash.h>
6+
#include <stdio.h>
7+
8+
#include "configuration.h"
9+
// #include "data_logging.h"
10+
// #include "mqtt5_connection.h"
11+
// #include "pump_control.h"
12+
// #include "wifi_utils.h"
13+
14+
void initialize_nvs() {
15+
esp_err_t ret = nvs_flash_init();
16+
if (ret == ESP_ERR_NVS_NO_FREE_PAGES ||
17+
ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
18+
ESP_ERROR_CHECK(nvs_flash_erase());
19+
ret = nvs_flash_init();
20+
}
21+
ESP_ERROR_CHECK(ret);
22+
}
23+
24+
void app_main(void) {
25+
// Initialize storage
26+
initialize_nvs();
27+
28+
load_configuration();
29+
30+
// Create Event Loop
31+
// ESP_ERROR_CHECK(esp_event_loop_create_default());
32+
33+
// // Initialize and connect to Wifi
34+
// wifi_utils_init();
35+
// wifi_utils_init_sntp();
36+
// wifi_utils_create_connection_checker_task();
37+
// // MQTT Setup
38+
// mqtt5_conn_init();
39+
// mqtt5_create_connection_checker_task();
40+
// // Data Logging Setup
41+
// create_data_logging_task();
42+
// // Create control tasks
43+
// ESP_ERROR_CHECK(add_notify_for_new_config(create_pump_control_task()));
44+
}

partitions.csv

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# ESP-IDF Partition Table
22
# Name, Type, SubType, Offset, Size, Flags
3-
nvs,data,nvs,0x9000,24K,
4-
phy_init,data,phy,0xf000,4K,
5-
factory,app,factory,0x10000,1M,
6-
storage,data,spiffs,,1M,
3+
nvs, data, nvs, 0x9000, 0x4000,
4+
otadata, data, ota, 0xd000, 0x2000,
5+
phy_init, data, phy, 0xf000, 0x1000,
6+
factory, app, factory, 0x10000, 1M,
7+
ota_0, app, ota_0, , 1M,
8+
ota_1, app, ota_1, , 1M,
9+
storage, data, spiffs, , 900k

profiles/app

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-B build_app -DSDKCONFIG=build_app/sdkconfig -DSDKCONFIG_DEFAULTS="sdkconfig.defaults"

0 commit comments

Comments
 (0)