Compare commits
1
Commits
v0.3.2
..
b65658bda0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b65658bda0
|
No files matched your search
@@ -1,31 +0,0 @@
|
|||||||
FROM ghcr.io/rust-cross/cargo-zigbuild:latest
|
|
||||||
|
|
||||||
# The base image may resolve its toolchain through $HOME, which the runner does not preserve for
|
|
||||||
# action containers, so pin it to a fixed path. entrypoint.sh re-exports this because the runner
|
|
||||||
# injects the workflow environment into action containers as well.
|
|
||||||
ENV RUSTUP_HOME=/usr/local/rustup
|
|
||||||
|
|
||||||
RUN if ! rustup default >/dev/null 2>&1; then \
|
|
||||||
rustup toolchain install stable --profile minimal --no-self-update; \
|
|
||||||
rustup default stable; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# The image ships the toolchain, zig, a macOS SDK and cargo-zigbuild, but not the bits the build and
|
|
||||||
# packaging scripts need.
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends ca-certificates zip zstd \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Install every target up front so building needs no network access. `universal2-apple-darwin` is
|
|
||||||
# not a rustc target: cargo-zigbuild builds both architectures and merges them.
|
|
||||||
RUN rustup target install \
|
|
||||||
aarch64-unknown-linux-musl \
|
|
||||||
x86_64-unknown-linux-musl \
|
|
||||||
x86_64-pc-windows-gnu \
|
|
||||||
aarch64-apple-darwin \
|
|
||||||
x86_64-apple-darwin
|
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
|
||||||
RUN chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
name: Build guac CLI
|
|
||||||
description: Cross-compile the guac CLI with cargo-zigbuild and package the artifact
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
target:
|
|
||||||
description: Rust target triple, or universal2-apple-darwin
|
|
||||||
required: true
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: docker
|
|
||||||
image: Dockerfile
|
|
||||||
args:
|
|
||||||
- ${{ inputs.target }}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
target="$1"
|
|
||||||
|
|
||||||
cd "${GITHUB_WORKSPACE:-$(pwd)}"
|
|
||||||
|
|
||||||
# The runner overrides env vars from the workflow for action containers, so re-assert the
|
|
||||||
# toolchain path the image installed to, and keep the registry in the workspace for caching.
|
|
||||||
export RUSTUP_HOME=/usr/local/rustup
|
|
||||||
export CARGO_HOME="${PWD}/.cargo-cache"
|
|
||||||
|
|
||||||
bin=guac-cli
|
|
||||||
case "$target" in
|
|
||||||
*windows*) bin=guac-cli.exe ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
(cd cli && cargo zigbuild --release --target "$target")
|
|
||||||
|
|
||||||
artifact="target/${target}/release/${bin}"
|
|
||||||
if [ ! -f "$artifact" ]; then
|
|
||||||
artifact="cli/${artifact}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p dist
|
|
||||||
zip -j "dist/guac-cli-${target}.zip" "$artifact"
|
|
||||||
@@ -5,6 +5,13 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
|
||||||
|
env:
|
||||||
|
TARGET: thumbv8m.main-none-eabihf
|
||||||
|
# The catthehacker image installs rust here and only symlinks ~/.rustup and ~/.cargo to it.
|
||||||
|
# actions/cache archives the symlink, not its contents, so point at the real paths.
|
||||||
|
RUSTUP_HOME: /usr/share/rust/.rustup
|
||||||
|
CARGO_HOME: /usr/share/rust/.cargo
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
firmware:
|
firmware:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -14,15 +21,8 @@ jobs:
|
|||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
variant: [cs4398, ak4490, evk]
|
variant: [cs4398, ak4490, evk]
|
||||||
# Job-scoped on purpose: the runner also injects workflow env into action containers, where it
|
|
||||||
# would override the cli image's own toolchain paths.
|
|
||||||
env:
|
env:
|
||||||
FEATURES: ${{ matrix.variant }},hid
|
FEATURES: ${{ matrix.variant }},hid
|
||||||
TARGET: thumbv8m.main-none-eabihf
|
|
||||||
# The catthehacker image installs rust here and only symlinks ~/.rustup and ~/.cargo to it.
|
|
||||||
# actions/cache archives the symlink, not its contents, so point at the real paths.
|
|
||||||
RUSTUP_HOME: /usr/share/rust/.rustup
|
|
||||||
CARGO_HOME: /usr/share/rust/.cargo
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -69,6 +69,10 @@ jobs:
|
|||||||
|
|
||||||
cli:
|
cli:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
# Bundles the Rust toolchain, zig and a macOS SDK, which the generic builder images lack;
|
||||||
|
# we cross-compile every target from here with cargo-zigbuild.
|
||||||
|
image: ghcr.io/rust-cross/cargo-zigbuild:latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -77,31 +81,64 @@ jobs:
|
|||||||
- x86_64-pc-windows-gnu
|
- x86_64-pc-windows-gnu
|
||||||
- x86_64-unknown-linux-musl
|
- x86_64-unknown-linux-musl
|
||||||
- universal2-apple-darwin
|
- universal2-apple-darwin
|
||||||
|
env:
|
||||||
|
RUSTUP_HOME: /usr/local/rustup
|
||||||
|
CARGO_HOME: /usr/local/cargo
|
||||||
steps:
|
steps:
|
||||||
|
# JavaScript actions need node, which the rust-cross image does not ship. Install it (and the
|
||||||
|
# rest of the tooling the actions rely on) before anything else, as a shell step.
|
||||||
|
- name: Install Actions tooling
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends ca-certificates curl git zip zstd
|
||||||
|
if ! command -v node > /dev/null; then
|
||||||
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||||
|
apt-get install -y --no-install-recommends nodejs
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Building and packaging both happen in .gitea/actions/cli-build, whose image the runner
|
- name: Cache rustup
|
||||||
# builds from its Dockerfile and keeps in the Docker layer cache. That image carries the
|
|
||||||
# toolchain, zig, the macOS SDK and every target, so none of that is installed per job.
|
|
||||||
- name: Cache cargo registry
|
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: .cargo-cache
|
path: ${{ env.RUSTUP_HOME }}
|
||||||
key: cli-registry-${{ hashFiles('**/Cargo.lock') }}
|
key: rustup-cli-${{ matrix.target }}-${{ runner.os }}
|
||||||
restore-keys: cli-registry-
|
|
||||||
|
|
||||||
- name: Cache build artifacts
|
- name: Install Rust Toolchain
|
||||||
|
run: |
|
||||||
|
rustup target install ${{ matrix.target }}
|
||||||
|
# cargo-zigbuild builds both architectures and merges them for the universal binary.
|
||||||
|
if [[ "${{ matrix.target }}" == universal2-apple-darwin ]]; then
|
||||||
|
rustup target install aarch64-apple-darwin x86_64-apple-darwin
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Cache cargo
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
shared-key: cli-${{ matrix.target }}
|
||||||
|
|
||||||
|
# compiled libc/compiler-rt are per target, so these stay keyed on it
|
||||||
|
- name: Cache zig build artifacts
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: target
|
path: |
|
||||||
key: cli-target-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
~/.cache/zig
|
||||||
restore-keys: cli-target-${{ matrix.target }}-
|
~/.cache/cargo-zigbuild
|
||||||
|
key: zigbuild-cache-${{ matrix.target }}-${{ runner.os }}
|
||||||
|
|
||||||
- name: Build cli (${{ matrix.target }})
|
- name: Build cli (${{ matrix.target }})
|
||||||
uses: ./.gitea/actions/cli-build
|
working-directory: cli
|
||||||
with:
|
run: cargo zigbuild --release --target ${{ matrix.target }}
|
||||||
target: ${{ matrix.target }}
|
|
||||||
|
- name: Package
|
||||||
|
run: |
|
||||||
|
bin=guac-cli
|
||||||
|
[[ "${{ matrix.target }}" == *windows* ]] && bin=guac-cli.exe
|
||||||
|
mkdir -p dist
|
||||||
|
zip -j "dist/guac-cli-${{ matrix.target }}.zip" "target/${{ matrix.target }}/release/$bin"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
|
|||||||
Generated
+2
-2
@@ -952,7 +952,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "guac"
|
name = "guac"
|
||||||
version = "0.3.2"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic",
|
"atomic",
|
||||||
"bbqueue",
|
"bbqueue",
|
||||||
@@ -978,7 +978,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "guac-cli"
|
name = "guac-cli"
|
||||||
version = "0.3.2"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-hid",
|
"async-hid",
|
||||||
"clap",
|
"clap",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "guac-cli"
|
name = "guac-cli"
|
||||||
version = "0.3.2"
|
version = "0.3.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "guac"
|
name = "guac"
|
||||||
version = "0.3.2"
|
version = "0.3.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|||||||
@@ -48,73 +48,6 @@ fn slot_address(index: usize) -> usize {
|
|||||||
config_base() + CONFIG_RESERVED + index * SLOT_SIZE
|
config_base() + CONFIG_RESERVED + index * SLOT_SIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
// The spare page in the reserved area, used to carry a boot request across a reset.
|
|
||||||
const BOOT_REQUEST_MAGIC: u32 = u32::from_le_bytes(*b"BOOT");
|
|
||||||
|
|
||||||
fn boot_request_address() -> usize {
|
|
||||||
config_base() + FLASH_PAGE_SIZE
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Writes a boot request and resets. The next boot hands over to the ROM before configuring
|
|
||||||
/// anything, which is the only way it gets a chip that is still in its reset state.
|
|
||||||
#[cfg(feature = "hid")]
|
|
||||||
pub fn request_bootloader(state: &mut FlashState) -> Result<(), ()> {
|
|
||||||
defmt::info!("config: requesting bootloader");
|
|
||||||
|
|
||||||
cortex_m::interrupt::free(|_| {
|
|
||||||
slow_clock_for_flash();
|
|
||||||
|
|
||||||
let address = boot_request_address();
|
|
||||||
let mut page = [0xffu8; FLASH_PAGE_SIZE];
|
|
||||||
page[..4].copy_from_slice(&BOOT_REQUEST_MAGIC.to_le_bytes());
|
|
||||||
|
|
||||||
if state.flash.erase_page(address / FLASH_PAGE_SIZE).is_err() {
|
|
||||||
defmt::error!("config: boot request erase failed");
|
|
||||||
return Err(());
|
|
||||||
}
|
|
||||||
|
|
||||||
if state
|
|
||||||
.flash
|
|
||||||
.write_native(address, GenericArray::from_slice(&page))
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
defmt::error!("config: boot request write failed");
|
|
||||||
return Err(());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
})?;
|
|
||||||
|
|
||||||
// Let the probe client drain RTT before the reset tears it down.
|
|
||||||
cortex_m::asm::delay(15_000_000);
|
|
||||||
|
|
||||||
cortex_m::peripheral::SCB::sys_reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Consumes a pending boot request, clearing it first so a hand-off that fails to enter ISP cannot
|
|
||||||
/// cause a boot loop.
|
|
||||||
pub fn take_bootloader_request(flash: &mut FlashGordon) -> bool {
|
|
||||||
slow_clock_for_flash();
|
|
||||||
|
|
||||||
let address = boot_request_address();
|
|
||||||
let mut word = [0u8; FLASH_WORD_SIZE];
|
|
||||||
|
|
||||||
if read_flash(address, &mut word).is_err() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if u32::from_le_bytes([word[0], word[1], word[2], word[3]]) != BOOT_REQUEST_MAGIC {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if flash.erase_page(address / FLASH_PAGE_SIZE).is_err() {
|
|
||||||
defmt::error!("config: boot request clear failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
defmt::info!("config: boot request found");
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn config_buf() -> &'static mut [u8; SLOT_SIZE] {
|
fn config_buf() -> &'static mut [u8; SLOT_SIZE] {
|
||||||
// Safety: flash access is not reentrant and the buffer is only borrowed for one operation at a time.
|
// Safety: flash access is not reentrant and the buffer is only borrowed for one operation at a time.
|
||||||
unsafe { &mut *core::ptr::addr_of_mut!(CONFIG_BUF) }
|
unsafe { &mut *core::ptr::addr_of_mut!(CONFIG_BUF) }
|
||||||
|
|||||||
@@ -242,10 +242,7 @@ impl CommandState {
|
|||||||
}
|
}
|
||||||
Action::Bootloader => {
|
Action::Bootloader => {
|
||||||
ack_delay();
|
ack_delay();
|
||||||
|
crate::boot_to_bootloader();
|
||||||
if config::request_bootloader(flash).is_err() {
|
|
||||||
defmt::error!("boot request failed, staying in the application");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Action::Commit => {
|
Action::Commit => {
|
||||||
ack_delay();
|
ack_delay();
|
||||||
|
|||||||
+10
-31
@@ -218,32 +218,17 @@ static PERF: PerfCounters = PerfCounters {
|
|||||||
// fb: AtomicI32::new(0),
|
// fb: AtomicI32::new(0),
|
||||||
};
|
};
|
||||||
|
|
||||||
fn boot_to_isp() -> ! {
|
fn boot_to_bootloader() -> ! {
|
||||||
// Hand the ROM a chip that is still in its reset state, with the ISP pin held low. Peripheral
|
cortex_m::interrupt::disable();
|
||||||
// resets are left alone: holding them asserted stops the ROM's own USB from coming up.
|
|
||||||
let mut syscon = unsafe { hal::Syscon::steal() };
|
|
||||||
let mut iocon = unsafe { hal::Iocon::steal() }.enabled(&mut syscon);
|
|
||||||
let mut gpio = unsafe { hal::Gpio::steal() }.enabled(&mut syscon);
|
|
||||||
let _isp = unsafe { pins::Pio0_5::steal() }
|
|
||||||
.into_gpio_pin(&mut iocon, &mut gpio)
|
|
||||||
.into_output_low();
|
|
||||||
unsafe {
|
|
||||||
(*pac::IOCON::ptr())
|
|
||||||
.pio0_5
|
|
||||||
.modify(|_, w| w.mode().pull_down())
|
|
||||||
};
|
|
||||||
|
|
||||||
// And the boot error counter, in case the pin is not the input the ROM acts on.
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let pmc = &*pac::PMC::ptr();
|
let pmc = &*pac::PMC::ptr();
|
||||||
pmc.aoreg1.modify(|r, w| w.bits(r.bits() | (0xa << 16)));
|
// https://community.nxp.com/t5/LPC-Microcontrollers/Configure-LPC55-to-enter-re-invoke-ROM-Bootloader-from/m-p/966990?profile.language=en
|
||||||
|
// If you write the following register, it will be set to boot from the ROM:
|
||||||
|
// PMC->AOREG1 |= (0x0A << 16); //Set to boot from ROM
|
||||||
|
// NVIC_SystemReset(); //Reset
|
||||||
|
pmc.aoreg1.modify(|r, w| w.bits(r.bits() | (0x0a << 16)));
|
||||||
}
|
}
|
||||||
|
cortex_m::peripheral::SCB::sys_reset()
|
||||||
cortex_m::interrupt::disable();
|
|
||||||
defmt::info!("bootloader: entering ROM from the reset state");
|
|
||||||
cortex_m::asm::delay(15_000_000);
|
|
||||||
|
|
||||||
unsafe { cortex_m::asm::bootload(0x0300_0000 as *const u32) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_telemetry_report<D: Dac<I>, I>(
|
fn build_telemetry_report<D: Dac<I>, I>(
|
||||||
@@ -853,14 +838,6 @@ fn main() -> ! {
|
|||||||
|
|
||||||
debug!("start");
|
debug!("start");
|
||||||
|
|
||||||
// A boot request is honoured before any peripheral or clock is configured beyond what reading
|
|
||||||
// flash requires, so the ROM is entered with the chip still in its reset state.
|
|
||||||
let mut flash = hal::FlashGordon::new(hal.flash.enabled(&mut syscon));
|
|
||||||
|
|
||||||
if config::take_bootloader_request(&mut flash) {
|
|
||||||
boot_to_isp();
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!("iocon");
|
debug!("iocon");
|
||||||
let usb0_vbus_pin = pins::Pio0_22::take()
|
let usb0_vbus_pin = pins::Pio0_22::take()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -911,6 +888,8 @@ fn main() -> ! {
|
|||||||
|
|
||||||
// Flash controller commands require a core clock of at most 100 MHz, so the config is read
|
// Flash controller commands require a core clock of at most 100 MHz, so the config is read
|
||||||
// before the system PLL takes the core to 150 MHz.
|
// before the system PLL takes the core to 150 MHz.
|
||||||
|
let flash = hal.flash.enabled(&mut syscon);
|
||||||
|
let mut flash = hal::FlashGordon::new(flash);
|
||||||
defmt::info!("config: loading");
|
defmt::info!("config: loading");
|
||||||
let (running_config, active_slot) = config::load(&mut flash);
|
let (running_config, active_slot) = config::load(&mut flash);
|
||||||
defmt::info!(
|
defmt::info!(
|
||||||
|
|||||||
Reference in new issue
Block a user