Skip to content

Commit

Permalink
Action for new SMC.BIN artifact (#20)
Browse files Browse the repository at this point in the history
* Use Stefan's compact version of OneButton.

* Enable Perixx keyboard; set numlock at power on

* Remove activity LED debug code.

* Move mouse and keyboard initialization state machine to START_RESET after reset.

* Reset mouse PS2 state machine when powering off.

* Pull x16community/main

* Add firmware versioning

* Update to origin main

* Fix bootloader start address

* Comment out community16 pins

* Implementing Github action that makes SMC.BIN file

---------

Co-authored-by: jburks <[email protected]>
  • Loading branch information
stefan-b-jakobsson and jburks authored Oct 18, 2023
1 parent e24f696 commit 5a14287
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 4 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@ jobs:

- name: Build PlatformIO Project
run: pio run

- name: Install IntelHex library
run: pip install intelhex

- name: Make SMC.BIN file
run: python make_bin.py .pio/build/**/firmware.*

- name: Archive firmwares results
uses: actions/upload-artifact@v3
with:
name: SMC Firmwares
path: .pio/build/**/firmware.*
path: .pio/build/**/firmware.*

- name: Archive SMC.BIN file
uses: actions/upload-artifact@v3
with:
name: SMC.BIN file
path: .build/SMC*.BIN
62 changes: 62 additions & 0 deletions make_bin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import sys
import os
from intelhex import IntelHex

# Table of compatible Kernal versions (negative value is pre-release)
kernal_versions = {-44, -45, 45, -46}

# Init header output buffer
buf = [0] * 32

# Get SMC firmware version from C++ header file
version_major = 0
version_minor = 0
version_patch = 0

smc_version = open("version.h", "r")

lines = smc_version.readlines()
for l in lines:
parts = l.split()
if parts[0] == "#define":
if parts[1] == "version_major":
version_major = int(parts[2])
buf[0] = version_major
elif parts[1] == "version_minor":
version_minor = int(parts[2])
buf[1] = version_minor
elif parts[1] == "version_patch":
version_patch = int(parts[2])
buf[2] = version_patch

smc_version.close()

# Add supported Kernal versions to output buffer
i = 32 - len(kernal_versions)
for v in kernal_versions:
buf[i] = v
i = i + 1

# Read firmware file
ih = IntelHex()
ih.loadfile(sys.argv[2], format="hex")
firmware = ih.tobinarray()

# Create output folder, if not exist
try:
os.mkdir(".build")
except:
pass

# Create SMC.BIN file
smc = open(".build/SMC-" + str(version_major) + "." + str(version_minor) + "." + str(version_patch) + ".BIN", "wb")
i = 0
for v in buf:
if i < 3:
is_signed = False
else:
is_signed = True
smc.write(v.to_bytes(1, byteorder=sys.byteorder, signed=is_signed))
i = i + 1
smc.write(firmware)
smc.close()
4 changes: 1 addition & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ include_dir = .
; common settings
platform = [email protected]
framework = arduino
; libraries common to all
lib_deps =
mathertel/[email protected]

; exclude source files in the tests folder meant for cx16
build_src_filter = +<*> -<tests/*>

Expand Down

0 comments on commit 5a14287

Please sign in to comment.