Skip to content
Open
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
252 changes: 252 additions & 0 deletions .github/actions/setup-zephyr/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
name: Setup Zephyr project
description: Setup a Zephyr base project using west and downloading the Zephyr SDK

inputs:
app-path:
description: |
Application code path, should contain a west.yml file if
"manifest-file-name" is not specified, cannot contain multiple
directories (use base-path instead)
required: true

base-path:
description: |
Application base path, should contain the app-path. Defaults to "." if
unspecified
required: false
default: .

ccache-max-size:
description: |
Maximum size of the files stored in the compiler cache (ccache). Defaults to 512MB.
required: false
default: 512MB

enable-ccache:
description: |
Enable caching/restoring of compiler cache (ccache) files between invocations.
Defaults to 'true'.
required: false
default: true

ccache-cache-key:
description: |
An additional string used in the ccache cache key, use it to identify the
cache in a way that makes sense for compiled object cache reuse between
different build workflows. Default to "default".
required: false
default: default

manifest-file-name:
description: Name of the west workspace manifest file name in "app-path"
required: false
default: west.yml

sdk-version:
description: Zephyr SDK version to use or "auto" to detect automatically
required: false
default: auto

sdk-base:
description: Base URL of the Zephyr SDK
required: false
default: https://github.com/zephyrproject-rtos/sdk-ng/releases/download

toolchains:
description: List of toolchains to install, colon separated
required: false
default: arm-zephyr-eabi

west-project-filter:
description: West project filter
required: false
default: ""

west-group-filter:
description: West group filter
required: false
default: ""

west-version:
description: West version to install, latest if omitted
required: false
default: ""

runs:
using: "composite"
steps:
- name: Install dependencies
shell: bash
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
python.exe -m pip install -U pip
fi

pip3 install -U pip wheel

if [ -n "${{ inputs.west-version }}" ]; then
pip3 install west==${{ inputs.west-version }}
else
pip3 install west
fi

if [ "${{ runner.os }}" = "Linux" ]; then
sudo rm -f /var/lib/man-db/auto-update
sudo apt-get update -y
sudo apt-get install -y ninja-build ccache gperf
if [ "${{ runner.arch }}" = "X64" ]; then
sudo apt-get install -y libc6-dev-i386 g++-multilib
fi
elif [ "${{ runner.os }}" = "macOS" ]; then
brew install ninja ccache qemu dtc gperf
elif [ "${{ runner.os }}" = "Windows" ]; then
choco feature enable -n allowGlobalConfirmation
choco install ninja wget gperf
fi

- name: Initialize
working-directory: ${{ inputs.base-path }}
shell: bash
run: |
west init -l ${{ inputs.app-path }} --mf ${{ inputs.manifest-file-name }}
if [ -n "${{ inputs.west-group-filter }}" ]; then
west config manifest.group-filter -- ${{ inputs.west-group-filter }}
fi
if [ -n "${{ inputs.west-project-filter }}" ]; then
west config manifest.project-filter -- ${{ inputs.west-project-filter }}
fi
west update -o=--depth=1 -n

- name: Environment setup
working-directory: ${{ inputs.base-path }}
id: env-setup
shell: bash
run: |
runner="${{ runner.os }}-${{ runner.arch }}"
if [ "$runner" = "Linux-X64" ]; then
sdk_variant="linux-x86_64"
elif [ "$runner" = "Linux-ARM64" ]; then
sdk_variant="linux-aarch64"
elif [ "$runner" = "macOS-X64" ]; then
sdk_variant="macos-x86_64"
elif [ "$runner" = "macOS-ARM64" ]; then
sdk_variant="macos-aarch64"
elif [ "$runner" = "Windows-X64" ]; then
sdk_variant="windows-x86_64"
else
echo "Unsupported runner platform: $runner"
fi

if [ "${{ runner.os }}" = "Linux" ]; then
pip_cache_path="~/.cache/pip"
ccache_path="$HOME/.cache/ccache"
sdk_ext="tar.xz"
setup_file="./setup.sh"
setup_opt="-"
elif [ "${{ runner.os }}" = "macOS" ]; then
pip_cache_path="~/Library/Caches/pip"
ccache_path="$HOME/Library/Caches/ccache"
sdk_ext="tar.xz"
setup_file="./setup.sh"
setup_opt="-"
elif [ "${{ runner.os }}" = "Windows" ]; then
pip_cache_path="~/AppData/Local/pip/Cache"
ccache_path="$HOME/AppData/Local/ccache/Cache"
sdk_ext="7z"
setup_file="./setup.cmd"
setup_opt="//"
fi

if [ "${{ inputs.sdk-version }}" = "auto" ]; then
zephyr_path="zephyr"
if west list -f '{abspath}' zephyr; then
zephyr_path="$( west list -f '{abspath}' zephyr )"
fi

if [ -f "${zephyr_path}/SDK_VERSION" ]; then
echo "Reading SDK version from ${zephyr_path}/SDK_VERSION"
sdk_version=$( cat ${zephyr_path}/SDK_VERSION )
else
echo "Cannot find ${zephyr_path}/SDK_VERSION"
exit 1
fi
else
sdk_version="${{ inputs.sdk-version }}"
fi

echo "SDK_VERSION=${sdk_version}" >> $GITHUB_ENV
echo "SDK_FILE=zephyr-sdk-${sdk_version}_${sdk_variant}_minimal.${sdk_ext}" >> $GITHUB_ENV
echo "PIP_CACHE_PATH=${pip_cache_path}" >> $GITHUB_ENV
echo "CCACHE_TIMESTAMP=$(date +%s)" >> $GITHUB_ENV
echo "CCACHE_DIR=${ccache_path}" >> $GITHUB_ENV
echo "CCACHE_IGNOREOPTIONS=-specs=* --specs=*" >> $GITHUB_ENV
echo "SETUP_FILE=${setup_file}" >> $GITHUB_ENV
echo "SETUP_OPT=${setup_opt}" >> $GITHUB_ENV

- name: Cache Python packages
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ env.PIP_CACHE_PATH }}
key: pip-${{ runner.os }}-${{ hashFiles(format('{0}/zephyr/scripts/requirements*.txt', inputs.base-path)) }}

- name: Install Python packages
working-directory: ${{ inputs.base-path }}
shell: bash
# The direct use of pip3 should be removed after zephyr 4.1 has been phased out, and the west
# command should only be used instead.
run: |
west packages pip --install --ignore-venv-check || pip3 install -r zephyr/scripts/requirements.txt

- name: Cache Zephyr SDK
id: cache-toolchain
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ inputs.base-path }}/zephyr-sdk
key: ${{ env.SDK_FILE }}-${{ github.event.repository.name }}-${{ inputs.toolchains }}

- if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' }}
working-directory: ${{ inputs.base-path }}
name: Download Zephyr SDK
shell: bash
run: |
wget --progress=dot:giga ${{ inputs.sdk-base }}/v${SDK_VERSION}/${SDK_FILE}
rm -rf zephyr-sdk
if [ "${{ runner.os }}" = "Windows" ]; then
7z x $SDK_FILE
mv zephyr-sdk-${SDK_VERSION} zephyr-sdk
else
mkdir zephyr-sdk
tar xvf $SDK_FILE -C zephyr-sdk --strip-components=1
fi
rm -f $SDK_FILE

- name: Setup Zephyr SDK
working-directory: ${{ inputs.base-path }}/zephyr-sdk
shell: bash
run: |
IFS=":"
TOOLCHAINS="${{ inputs.toolchains }}"
for toolchain in $TOOLCHAINS; do
${SETUP_FILE} ${SETUP_OPT}t $toolchain
done
if [ ! -d sysroots ]; then
${SETUP_FILE} ${SETUP_OPT}h
fi
${SETUP_FILE} ${SETUP_OPT}c

- name: Cache ccache data
if: inputs.enable-ccache == 'true' && runner.os != 'Windows'
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ inputs.ccache-cache-key }}-${{ env.CCACHE_TIMESTAMP }}
restore-keys: ccache-${{ inputs.ccache-cache-key }}-

- name: Set up ccache
if: inputs.enable-ccache == 'true' && runner.os != 'Windows'
shell: bash
run: |
mkdir -p ${{ env.CCACHE_DIR }}
ccache -M ${{ inputs.ccache-max-size }}
ccache -p
ccache -z -s -vv
41 changes: 7 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,12 @@ jobs:
with:
python-version: 3.12

- name: Install system dependencies
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
sudo rm -f /var/lib/man-db/auto-update
sudo apt-get update -y
sudo apt-get install -y ninja-build ccache gperf
if [ "${{ runner.arch }}" = "X64" ]; then
sudo apt-get install -y libc6-dev-i386 g++-multilib
fi
elif [ "${{ runner.os }}" = "macOS" ]; then
brew install ninja ccache qemu dtc gperf
elif [ "${{ runner.os }}" = "Windows" ]; then
choco feature enable -n allowGlobalConfirmation
choco install ninja wget gperf
fi

- name: Install west
run: |
pip install west

- name: Initialize Zephyr workspace
run: |
west init -l OpenAstroFocuser
west update

- name: Install pip dependencies
run: |
west packages pip --install --ignore-venv-check || pip3 install -r zephyr/scripts/requirements.txt

- name: Install Zephyr SDK
run: |
west sdk install -t arm-zephyr-eabi xtensa-espressif_esp32s3_zephyr-elf
- name: Setup Zephyr project
uses: ./OpenAstroFocuser/.github/actions/setup-zephyr
with:
app-path: OpenAstroFocuser
toolchains: arm-zephyr-eabi:xtensa-espressif_esp32s3_zephyr-elf
ccache-cache-key: ${{ matrix.os }}

- name: Build firmware
working-directory: OpenAstroFocuser
Expand All @@ -79,4 +52,4 @@ jobs:
if [ "${{ runner.os }}" = "Windows" ]; then
EXTRA_TWISTER_FLAGS="--short-build-path -O/tmp/twister-out"
fi
west twister -T tests -v --inline-logs --integration $EXTRA_TWISTER_FLAGS
west twister -T tests -v --inline-logs --integration $EXTRA_TWISTER_FLAGS
1 change: 1 addition & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ target_sources(app PRIVATE
src/FocuserThread.cpp
src/UartHandler.cpp
src/UartThread.cpp
src/Thread.cpp
src/ZephyrStepper.cpp)
12 changes: 0 additions & 12 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@ endmenu

menu "OpenAstroFocuser options"

config FOCUSER_THREAD_STACK_SIZE
int "Focuser thread stack size"
default 2048
help
Stack allocation used by the focuser control thread.

config SERIAL_THREAD_STACK_SIZE
int "Serial thread stack size"
default 2048
help
Stack allocation used by the Moonlite UART handler thread.

endmenu

module = APP
Expand Down
29 changes: 22 additions & 7 deletions app/boards/esp32s3_devkitc_procpu.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@
*/

/ {
aliases {
stepper = &focuser_stepper;
stepper-drv = &focuser_stepper_drv;
chosen {
zephyr,console = &uart1;
zephyr,log-uart = &focuser_log_uarts;
focuser,uart = &uart0;
focuser,stepper = &focuser_stepper;
focuser,stepper-drv = &focuser_stepper_drv;
};

focuser_log_uarts: focuser_log_uarts {
compatible = "zephyr,log-uart";
uarts = <&uart1>;
};

focuser_stepper_drv: focuser_stepper_drv {
Expand All @@ -31,23 +39,30 @@
step-width-ns = <10000>;
status = "okay";
};

zephyr,user {
uart_handler = <&uart1>;
};
};

/**
* Moonlite focuser console UART configuration
*/
&uart0 {
current-speed = <9600>;
status = "okay";
};

/**
* Moonlite focuser control UART configuration.
* Used for
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is incomplete: "Used for" appears to be cut off mid-sentence. Please complete the documentation to explain what uart1 is used for (appears to be for logging and console output based on the chosen nodes).

Suggested change
* Used for
* Used for logging and console output.

Copilot uses AI. Check for mistakes.
*/
&uart1 {
status = "okay";
current-speed = <9600>;
pinctrl-0 = <&moonlite_uart1_default>;
pinctrl-names = "default";
};

/**
* Pin control settings
*/
&pinctrl {
moonlite_uart1_default: moonlite_uart1_default {
group1 {
Expand Down
Loading
Loading