Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
db19633
Delete src/main.c
Ash6414 Jun 8, 2026
3a7f566
Add files via upload
Ash6414 Jun 8, 2026
ab5f80b
Add files via upload
Ash6414 Jun 8, 2026
a5efaca
Update README.md
Ash6414 Jun 8, 2026
d4689de
Create build-audiomoth-bin.yml
Ash6414 Jun 8, 2026
39ca3ec
Update espbridge.c
Ash6414 Jun 8, 2026
85219b9
Use fork source directly in AudioMoth firmware build
Ash6414 Jun 8, 2026
ffa0ad5
Add one-time firmware identity patch workflow
Ash6414 Jun 8, 2026
1894abc
Set firmware identity to AudioMoth Basic
github-actions[bot] Jun 8, 2026
ec9a3d9
Update main.c
Ash6414 Jun 8, 2026
12c90e0
Add one-time ESP time-wait patch workflow
Ash6414 Jun 8, 2026
74c79fe
Fix ESP time-wait patch workflow YAML
Ash6414 Jun 8, 2026
4b87391
Fix ESP bridge patch workflow and trigger source patch
Ash6414 Jun 9, 2026
64f0807
Fix workflow YAML indentation for bridge patch
Ash6414 Jun 9, 2026
bd2de16
Fix ESP bridge startup time sync
github-actions[bot] Jun 9, 2026
5a81f5a
Remove temporary ESP bridge patch workflow
Ash6414 Jun 9, 2026
98f9743
Refine permanent AudioMoth bin build workflow
Ash6414 Jun 9, 2026
21227c9
Install newlib headers in firmware bin workflow
Ash6414 Jun 9, 2026
08a1678
Add one-time ESP time-wait patch workflow
Ash6414 Jun 9, 2026
612e895
Remove obsolete patch workflow
Ash6414 Jun 9, 2026
e78d4fe
Fix ESP time-wait patch workflow YAML
Ash6414 Jun 9, 2026
c43f288
Add temporary ESPBridge fix and build workflow
Ash6414 Jun 9, 2026
78540d5
Add temporary request-aware bridge patch workflow
Ash6414 Jun 9, 2026
9c4e433
Service ESP bridge when request is active
github-actions[bot] Jun 9, 2026
1ab0980
Fix ESP bridge patch workflow and trigger source patch
Ash6414 Jun 9, 2026
c9a587c
Fix workflow YAML indentation for bridge patch
Ash6414 Jun 9, 2026
089673c
Update espbridge.h
Ash6414 Jun 9, 2026
d369e03
Keep ESP bridge service alive while requested
Ash6414 Jun 9, 2026
c2bd1d3
Enter bridge service when uploads become allowed
Ash6414 Jun 9, 2026
46d2f87
Answer ESP bridge request when BUSY drops
Ash6414 Jun 9, 2026
f930b13
Match Basic firmware name in docs
Ash6414 Jun 9, 2026
76b3ef2
Merge pull request #1 from Ash6414/codex/bridge-service-window-prototype
Ash6414 Jun 9, 2026
86fc022
Delete .github/workflows/temp-request-aware-bridge-patch.yml
Ash6414 Jun 9, 2026
15c1c23
Delete .github/workflows/temp-fix-and-build-espbridge.yml
Ash6414 Jun 9, 2026
8c1d515
Delete .github/workflows/patch-firmware-identity-once.yml
Ash6414 Jun 9, 2026
de9e85f
Delete .github/workflows/patch-esp-time-wait-once.yml
Ash6414 Jun 9, 2026
aff7e46
Bound bridge service loop cleanly
Ash6414 Jun 9, 2026
7365ff0
Fix AudioMoth bin builder to use current repo files
Ash6414 Jun 9, 2026
d1cfd16
Route ESPBridge over UART1 header pins
Ash6414 Jun 9, 2026
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
172 changes: 172 additions & 0 deletions .github/workflows/build-audiomoth-bin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Build AudioMoth firmware bin

on:
workflow_dispatch:
inputs:
audiomoth_project_ref:
description: AudioMoth-Project branch or tag to use as the build framework
required: false
default: master
push:
branches:
- master
paths:
- 'src/**'
- 'inc/**'
- '.github/workflows/build-audiomoth-bin.yml'
pull_request:
paths:
- 'src/**'
- 'inc/**'
- '.github/workflows/build-audiomoth-bin.yml'

permissions:
contents: read

concurrency:
group: audiomoth-firmware-build-${{ github.ref }}
cancel-in-progress: true

env:
AUDIOMOTH_PROJECT_REF: ${{ github.event.inputs.audiomoth_project_ref || 'master' }}

jobs:
build-bin:
runs-on: ubuntu-latest

steps:
- name: Check out firmware source at workflow ref
uses: actions/checkout@v4
with:
path: firmware
fetch-depth: 1

- name: Show and validate source revision
shell: bash
run: |
set -euo pipefail
echo "Repository: ${GITHUB_REPOSITORY}"
echo "Workflow ref: ${GITHUB_REF}"
echo "Ref name: ${GITHUB_REF_NAME}"
echo "Commit: $(git -C firmware rev-parse HEAD)"
echo "AudioMoth-Project ref: ${AUDIOMOTH_PROJECT_REF}"

required_files=(
firmware/src/main.c
firmware/src/espbridge.c
firmware/src/audioconfig.c
firmware/src/digitalfilter.c
firmware/src/gps.c
firmware/inc/espbridge.h
firmware/inc/audioconfig.h
firmware/inc/digitalfilter.h
firmware/inc/gps.h
)

for file in "${required_files[@]}"; do
test -f "$file" || { echo "Missing required firmware file: $file" >&2; exit 1; }
done

grep -F 'static uint8_t firmwareVersion[AM_FIRMWARE_VERSION_LENGTH] = {1, 12, 0};' firmware/src/main.c
grep -F 'static uint8_t firmwareDescription[AM_FIRMWARE_DESCRIPTION_LENGTH] = "AudioMoth-Firmware-Basic";' firmware/src/main.c
grep -F '#define ESPBRIDGE_DEFAULT_BAUD 115200' firmware/inc/espbridge.h
grep -F 'sendLine("OK BRIDGE_READY")' firmware/src/espbridge.c
grep -F 'sendLine("OK PONG")' firmware/src/espbridge.c

- name: Install ARM GCC and build tools
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
git \
make \
gcc-arm-none-eabi \
binutils-arm-none-eabi \
libnewlib-arm-none-eabi
arm-none-eabi-gcc --version
arm-none-eabi-objcopy --version

- name: Clone AudioMoth build framework
shell: bash
run: |
set -euo pipefail
git clone --depth 1 --branch "${AUDIOMOTH_PROJECT_REF}" https://github.com/OpenAcousticDevices/AudioMoth-Project.git project
echo "AudioMoth-Project commit: $(git -C project rev-parse HEAD)"
test -f project/build/Makefile
test -f project/build/audiomoth.ld

- name: Overlay this repository into AudioMoth-Project
shell: bash
run: |
set -euo pipefail
find firmware/src -maxdepth 1 -type f -name '*.c' -print -exec cp -f {} project/src/ \;
find firmware/inc -maxdepth 1 -type f -name '*.h' -print -exec cp -f {} project/inc/ \;

cmp -s firmware/src/main.c project/src/main.c
cmp -s firmware/src/espbridge.c project/src/espbridge.c
cmp -s firmware/inc/espbridge.h project/inc/espbridge.h

echo "Overlay bridge snippets:"
grep -n 'ESPBRIDGE_DEFAULT_BAUD' project/inc/espbridge.h
grep -n 'OK BRIDGE_READY\|OK PONG\|OK DONE' project/src/espbridge.c

- name: Configure AudioMoth Makefile for CI
shell: bash
run: |
set -euo pipefail
makefile=project/build/Makefile
sed -i 's|^TOOLCHAIN_PATH =.*|TOOLCHAIN_PATH = /usr|' "$makefile"
sed -i 's|^TOOLCHAIN_VERSION =.*|TOOLCHAIN_VERSION = |' "$makefile"
sed -i 's|^INC =.*|INC = ../cmsis ../device/inc ../emlib/inc ../emusb/inc ../drivers/inc ../fatfs/inc ../gps/inc ../inc|' "$makefile"
sed -i 's|^SRC =.*|SRC = ../device/src ../emlib/src ../emusb/src ../drivers/src ../fatfs/src ../gps/src ../src|' "$makefile"
grep -n '^TOOLCHAIN_PATH\|^TOOLCHAIN_VERSION\|^INC =\|^SRC =' "$makefile"

- name: Build firmware binary
shell: bash
working-directory: project/build
run: |
set -euo pipefail
make clean
make -j"$(nproc)" audiomoth.bin

- name: Verify binary and collect artifacts
shell: bash
run: |
set -euo pipefail
test -s project/build/audiomoth.bin
test -s project/build/audiomoth.hex
test -s project/build/audiomoth.map
test -s project/build/audiomoth.lst

strings project/build/audiomoth.bin | grep -F 'AudioMoth-Firmware-Basic'
strings project/build/audiomoth.bin | grep -F 'OK BRIDGE_READY'
strings project/build/audiomoth.bin | grep -F 'OK PONG'

mkdir -p firmware-artifacts
cp -f project/build/audiomoth.bin firmware-artifacts/audiomoth.bin
cp -f project/build/audiomoth.hex firmware-artifacts/audiomoth.hex
cp -f project/build/audiomoth.map firmware-artifacts/audiomoth.map
cp -f project/build/audiomoth.lst firmware-artifacts/audiomoth.lst

{
echo "source_repository=${GITHUB_REPOSITORY}"
echo "source_ref=${GITHUB_REF}"
echo "source_ref_name=${GITHUB_REF_NAME}"
echo "source_sha=$(git -C firmware rev-parse HEAD)"
echo "audiomoth_project_ref=${AUDIOMOTH_PROJECT_REF}"
echo "audiomoth_project_sha=$(git -C project rev-parse HEAD)"
echo "firmware_description=AudioMoth-Firmware-Basic"
echo "firmware_version=1.12.0"
echo "espbridge_baud=115200"
date -u '+built_at_utc=%Y-%m-%dT%H:%M:%SZ'
} > firmware-artifacts/build-info.txt

ls -lh firmware-artifacts/

- name: Upload firmware artifact
uses: actions/upload-artifact@v4
with:
name: audiomoth-firmware-bin
path: firmware-artifacts/
if-no-files-found: error
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Firmware for AudioMoth devices, used in conjunction with the AudioMoth-Project framework, to produce the standard AudioMoth releases.

This ESPBridge fork intentionally keeps the firmware name `AudioMoth-Firmware-Basic` so the AudioMoth Configuration App treats it like the standard Basic firmware. The ESP bridge changes live in the source files; do not rename the USB firmware description in `src/main.c`.

Compatible with the [AudioMoth Configuration App](https://github.com/OpenAcousticDevices/AudioMoth-Configuration-App). For usage instructions, visit [Open Acoustic Devices](https://www.openacousticdevices.info/getting-started).

### Usage ####
Expand Down
36 changes: 36 additions & 0 deletions inc/espbridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/****************************************************************************
* espbridge.h
* AudioMoth Dev <-> ESP32 bridge for SD-owned-by-AudioMoth uploads
* Drop-in bridge for AudioMoth-Firmware-Basic / AudioMoth-Project.
*
* AudioMoth owns the microSD at all times. The ESP32 requests file chunks
* over UART only while AudioMoth is outside its recording/preparation window.
*****************************************************************************/

#ifndef __ESPBRIDGE_H
#define __ESPBRIDGE_H

#include <stdint.h>
#include <stdbool.h>

#define ESPBRIDGE_DEFAULT_BAUD 115200
#define ESPBRIDGE_MAX_LINE 160
#define ESPBRIDGE_MAX_PATH 96
#define ESPBRIDGE_CHUNK_BYTES 512
#define ESPBRIDGE_UPLOAD_GUARD_SECONDS 300

void ESPBridge_init(void);

/* High means AudioMoth is recording/preparing/doing protected SD work. */
void ESPBridge_setBusy(bool busy);

/* True only when the main scheduler has enough time before the next recording. */
void ESPBridge_setUploadAllowed(bool allowed);

/* Reads the ESP request pin. */
bool ESPBridge_isRequestActive(void);

/* Services UART commands until deadlineUnixSeconds, request pin release, or idle timeout. */
void ESPBridge_serviceUntil(uint32_t deadlineUnixSeconds);

#endif /* __ESPBRIDGE_H */
Loading