Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
hotear committed Feb 13, 2021
2 parents 12fbc69 + 77957bb commit b052976
Show file tree
Hide file tree
Showing 54 changed files with 6,632 additions and 3,719 deletions.
146 changes: 146 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: PlatformIO CI

on:
push:

jobs:
job_build_modulecode:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

- name: Set up Python
uses: actions/setup-python@v2

- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Build code for modules
run: pio run --project-dir=./ATTINYCellModule --project-conf=./ATTINYCellModule/platformio.ini

- name: Publish Artifacts 1
uses: actions/upload-artifact@v2
with:
name: DIYBMS-Compiled-Module
path: |
./ATTINYCellModule/.pio/build/V*/*.hex
./ATTINYCellModule/.pio/build/V*/*.elf
if-no-files-found: error


job_build_controller_esp8266:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}

- name: Set up Python
uses: actions/setup-python@v2

- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Build code for controller
run: pio run --project-dir=./ESPController --environment esp8266_d1mini --project-conf=./ESPController/platformio.ini

- name: Publish Artifacts 2
uses: actions/upload-artifact@v2
with:
name: DIYBMS-Compiled-Controller-ESP8266
path: ./ESPController/.pio/build/*/*.bin
if-no-files-found: error

- name: Build File System Image for ESP8266
run: pio run --project-dir=./ESPController --target buildfs --environment esp8266_d1mini

- name: Publish Artifacts 3
uses: actions/upload-artifact@v2
with:
name: DIYBMS-Compiled-Controller-ESP8266
path: ./ESPController/.pio/build/*/*.bin
if-no-files-found: error

job_zip_code:
runs-on: ubuntu-latest
needs: [job_build_modulecode, job_build_controller_esp8266]
steps:
- name: Download artifact DIYBMS-Compiled-Controller-ESP8266
uses: actions/download-artifact@v2
with:
name: DIYBMS-Compiled-Controller-ESP8266

- name: Download artifact DIYBMS-Compiled-Module
uses: actions/download-artifact@v2
with:
name: DIYBMS-Compiled-Module

- name: Display structure of downloaded files
run: ls -R

- name: ZIP output for release
run: |
zip --junk-paths release.zip ./esp8266_d1mini/diybms_controller_firmware_espressif8266_esp8266_d1mini.bin
zip --junk-paths release.zip ./esp8266_d1mini/diybms_controller_filesystemimage_espressif8266_esp8266_d1mini.bin
zip --junk-paths release.zip ./V*/*.hex
- name: Get current date
id: date
run: echo "dt=$(date +'%Y-%m-%d-%H-%M')" >> $GITHUB_ENV

- name: Display structure of downloaded files
run: mv release.zip release_${{ env.dt }}.zip

- name: Create Release Files on MASTER branch only
id: create_release
uses: actions/create-release@v1
if: github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: Tag-${{ env.dt }}
release_name: Release-${{ env.dt }}
body: |
Automatically generated release
draft: false
prerelease: false

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
if: github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release_${{ env.dt }}.zip
asset_name: Compiled_Firmware_${{ env.dt }}.zip
asset_content_type: application/zip
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ ESPControllerCircuit/fp-info-cache

**/.vscode
*.log
ESPController/include/EmbeddedFiles_Integrity.h
ESPController/include/tft_splash_image.h
ESPController/include/AVRFirmware_AutoGenerated_Blobs.h
ESPController/include/AVRFirmware_AutoGenerated.h
*.checksum
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion ATTINYCellModule/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.piolibdeps
.clang_complete
.gcc-flags.json
.pio
.pio
EmbeddedFiles_Defines.h
67 changes: 0 additions & 67 deletions ATTINYCellModule/.travis.yml

This file was deleted.

18 changes: 18 additions & 0 deletions ATTINYCellModule/buildscript.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Import("env")

platform = env.PioPlatform()

#print(env)
#print(platform)

my_flags = env.ParseFlags(env['BUILD_FLAGS'])
#print(my_flags)
defines = {k: v for (k, v) in my_flags.get("CPPDEFINES")}
print(defines.get("DIYBMSMODULEVERSION"))

efuse=hex(int(env.GetProjectOption("board_fuses.efuse"), 2)).upper()[2:4]
hfuse=hex(int(env.GetProjectOption("board_fuses.hfuse"), 2)).upper()[2:4]
lfuse=hex(int(env.GetProjectOption("board_fuses.lfuse"), 2)).upper()[2:4]

env.Replace(PROGNAME="module_fw_%s_%s_%s%s_e%s_h%s_l%s" % (env["PIOENV"],env.get("BOARD"), defines.get("DIYBMSMODULEVERSION"), "_SWAPR19R20" if "SWAPR19R20" in defines else "", efuse, hfuse, lfuse ))

68 changes: 68 additions & 0 deletions ATTINYCellModule/buildscript_versioning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
""" Script for DIYBMS """
import datetime
import subprocess
import os
from os import path

Import("env")

env.Replace(PROGNAME="diybms_controller_firmware_%s_%s" %
(env["PIOPLATFORM"], env["PIOENV"]))

git_sha=None

AreWeInGitHubAction = True if "GITHUB_SHA" in env else False

if (AreWeInGitHubAction):
git_sha=env["GITHUB_SHA"]
else:
if (path.exists('..'+os.path.sep+'.git')):
# Get the latest GIT version header/name
try:
git_sha = subprocess.check_output(['git','log','-1','--pretty=format:%H']).decode('utf-8')
except:
# Ignore any error, user may not have GIT installed
git_sha = None

# print(env.Dump())

include_dir = os.path.join(env.get('PROJECT_DIR'), 'include')

if (os.path.exists(include_dir) == False):
raise Exception("Missing include folder")


with open(os.path.join(include_dir, 'EmbeddedFiles_Defines.h'), 'w') as f:
f.write("// This is an automatically generated file, any changes will be overwritten on compiliation!\n")
f.write("// DO NOT CHECK THIS INTO SOURCE CONTROL\n")
f.write("\n\n#ifndef EmbeddedFiles_Defines_H\n#define EmbeddedFiles_Defines_H\n\n")

f.write("static const char GIT_VERSION[] = \"")
if (git_sha!=None):
f.write(git_sha)
else:
f.write("LocalCompile")
f.write("\";\n\n")

f.write("static const uint16_t GIT_VERSION_B1 = 0x")
if (git_sha!=None):
f.write(git_sha[32:36])
else:
#Default for local compile
f.write("FFFF")
f.write(";\n\n")

f.write("static const uint16_t GIT_VERSION_B2 = 0x")
if (git_sha!=None):
f.write(git_sha[36:])
else:
#Default for local compile
f.write("FFFF")
f.write(";\n\n")


f.write("static const char COMPILE_DATE_TIME[] = \"")
f.write(datetime.datetime.utcnow().isoformat()[:-3]+'Z')
f.write("\";\n\n")

f.write("#endif")
Loading

0 comments on commit b052976

Please sign in to comment.