feat(ci): firmware and RTOS fixtures for the nightly scan regression (#313) #326
No files matched your search
@@ -121,6 +121,16 @@ jobs:
|
||||
env:
|
||||
RUSTC_WRAPPER: ""
|
||||
|
||||
# The upstream Zephyr example application, at a pinned commit so the
|
||||
# result does not drift with upstream main. codeload zips are not
|
||||
# byte-stable, so the commit pin (not a checksum) is the guarantee.
|
||||
- name: Fetch the Zephyr example application
|
||||
run: |
|
||||
curl -fsSL -o /tmp/zephyr-example.zip \
|
||||
"https://codeload.github.com/zephyrproject-rtos/example-application/zip/38a6d9b276ed434454900130cacc87d058d3ac62"
|
||||
env:
|
||||
RUSTC_WRAPPER: ""
|
||||
|
||||
- name: Wait for the agent
|
||||
run: |
|
||||
for i in $(seq 1 90); do
|
||||
@@ -137,6 +147,7 @@ jobs:
|
||||
env:
|
||||
NIGHTLY_AGENT_URL: http://agent:3001
|
||||
NIGHTLY_CODESYS_SAMPLE: /tmp/csv-blackbox.projectarchive
|
||||
NIGHTLY_ZEPHYR_EXAMPLE: /tmp/zephyr-example.zip
|
||||
NIGHTLY_BLESS: ${{ inputs.bless && '1' || '0' }}
|
||||
|
||||
# upload-artifact is a Node action and the Rust image has no node.
|
||||
|
||||
@@ -181,7 +181,7 @@ fn ingest_blob(
|
||||
let working_path = if extract {
|
||||
let dest = blob::work_dir(base, ctx.target_id, &artifact.id);
|
||||
match blob::extract_zip(&stored, &dest) {
|
||||
Ok(()) => dest,
|
||||
Ok(()) => project_root(dest),
|
||||
Err(e) => {
|
||||
// Not a zip container — this is a single uploaded file (e.g. a
|
||||
// `.st`/`.xml` PLC project or a `.tar.gz`). The content-addressed
|
||||
@@ -220,6 +220,28 @@ fn ingest_blob(
|
||||
})
|
||||
}
|
||||
|
||||
/// The project root of an extracted archive. GitHub's "Download ZIP" and most
|
||||
/// tools wrap the project in a single top-level folder (`repo-<sha>/`), and
|
||||
/// build-system detection only looks at the root, so a wrapper made a Zephyr
|
||||
/// app read as "no build system". Descend while the directory holds nothing
|
||||
/// but one folder (a macOS `__MACOSX` sidecar does not count).
|
||||
fn project_root(mut dir: PathBuf) -> PathBuf {
|
||||
loop {
|
||||
let Ok(entries) = std::fs::read_dir(&dir) else {
|
||||
return dir;
|
||||
};
|
||||
let entries: Vec<_> = entries
|
||||
.filter_map(Result::ok)
|
||||
.filter(|e| e.file_name() != "__MACOSX")
|
||||
.collect();
|
||||
match entries.as_slice() {
|
||||
// `file_type` does not follow symlinks, so this never leaves `dir`.
|
||||
[only] if only.file_type().is_ok_and(|t| t.is_dir()) => dir = only.path(),
|
||||
_ => return dir,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy a stored blob into `dest`/`name`, returning `dest`. Used when an
|
||||
/// "extractable" artifact turns out to be a single file rather than an archive.
|
||||
fn materialize_single(stored: &Path, dest: &Path, name: &str) -> Result<PathBuf, AgentError> {
|
||||
@@ -439,6 +461,25 @@ mod tests {
|
||||
assert_eq!(set.working_paths().len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_single_wrapper_folder_is_unwrapped() {
|
||||
let scratch = Scratch::new();
|
||||
let root = scratch.0.join("extracted");
|
||||
let app = root.join("example-application-38a6d9b").join("app");
|
||||
std::fs::create_dir_all(&app).expect("mkdir");
|
||||
std::fs::create_dir_all(root.join("__MACOSX")).expect("mkdir");
|
||||
std::fs::write(app.join("prj.conf"), "").expect("write");
|
||||
std::fs::write(root.join("example-application-38a6d9b/west.yml"), "").expect("write");
|
||||
|
||||
// Wrapper plus sidecar: descend to the folder that holds the project.
|
||||
assert_eq!(
|
||||
project_root(root.clone()),
|
||||
root.join("example-application-38a6d9b")
|
||||
);
|
||||
// A directory with several entries is already the root.
|
||||
assert_eq!(project_root(app.clone()), app);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn credentials_prefer_artifact_auth() {
|
||||
let mut artifact = Artifact::git_repo("https://git/x", "main");
|
||||
|
||||
@@ -33,9 +33,18 @@ pub fn is_firmware_target(target_type: TargetType) -> bool {
|
||||
}
|
||||
|
||||
/// Build SBOM entries for a firmware target from its source tree. Prefers a full
|
||||
/// reproducible build (sealed lock); falls back to analysis-only. Returns an
|
||||
/// empty vector when Firmwerk cannot even form a build plan.
|
||||
pub async fn firmware_sbom_entries(path: &Path, repo_id: &str, exec: ExecPolicy) -> Vec<SbomEntry> {
|
||||
/// reproducible build (sealed lock); falls back to analysis-only.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Why no firmware SBOM could be formed (no supported build system, a failed
|
||||
/// analysis, a timeout), for recording on the scan run instead of completing
|
||||
/// as if the firmware simply had no components.
|
||||
pub async fn firmware_sbom_entries(
|
||||
path: &Path,
|
||||
repo_id: &str,
|
||||
exec: ExecPolicy,
|
||||
) -> Result<Vec<SbomEntry>, String> {
|
||||
let p = path.to_path_buf();
|
||||
let repo = repo_id.to_string();
|
||||
let allow_build = exec.untrusted_code_allowed();
|
||||
@@ -44,26 +53,36 @@ pub async fn firmware_sbom_entries(path: &Path, repo_id: &str, exec: ExecPolicy)
|
||||
// that hangs must not wedge the scan (the orphaned task is abandoned).
|
||||
let handle = tokio::task::spawn_blocking(move || build_sbom_blocking(&p, &repo, allow_build));
|
||||
match tokio::time::timeout(std::time::Duration::from_secs(900), handle).await {
|
||||
Ok(Ok(entries)) => entries,
|
||||
Ok(Ok(result)) => result,
|
||||
Ok(Err(e)) => {
|
||||
tracing::warn!(repo_id, error = %e, "Firmware SBOM: task join error");
|
||||
Vec::new()
|
||||
Err(format!("firmware analysis stopped unexpectedly: {e}"))
|
||||
}
|
||||
Err(_) => {
|
||||
tracing::warn!(repo_id, "Firmware SBOM: build exceeded 15m; skipping");
|
||||
Vec::new()
|
||||
Err("firmware analysis took longer than 15 minutes".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn build_sbom_blocking(path: &Path, repo_id: &str, allow_build: bool) -> Vec<SbomEntry> {
|
||||
fn build_sbom_blocking(
|
||||
path: &Path,
|
||||
repo_id: &str,
|
||||
allow_build: bool,
|
||||
) -> Result<Vec<SbomEntry>, String> {
|
||||
let repo = firmwerk_core::Repo::new(path);
|
||||
let plan = match firmwerk_core::provider::analyze(&repo) {
|
||||
Ok(Some(bp)) => bp,
|
||||
Ok(None) => return Vec::new(),
|
||||
Ok(None) => {
|
||||
return Err(
|
||||
"no supported firmware build system found (Make, CMake, Zephyr, ESP-IDF, \
|
||||
PlatformIO, Arduino, embedded Rust, or recognisable SDK headers)"
|
||||
.to_string(),
|
||||
)
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!(repo_id, error = %e, "Firmware SBOM: firmwerk analyze failed");
|
||||
return Vec::new();
|
||||
return Err(format!("firmware analysis failed: {e}"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -93,7 +112,7 @@ fn build_sbom_blocking(path: &Path, repo_id: &str, allow_build: bool) -> Vec<Sbo
|
||||
count = entries.len(),
|
||||
"Firmware SBOM: sealed reproducible build"
|
||||
);
|
||||
return entries;
|
||||
return Ok(entries);
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!(repo_id, error = %e, "Firmware SBOM: reproducible build failed; falling back to analysis-only")
|
||||
@@ -107,7 +126,17 @@ fn build_sbom_blocking(path: &Path, repo_id: &str, allow_build: bool) -> Vec<Sbo
|
||||
}
|
||||
|
||||
// Phase 1 fallback: analysis-only (toolchain + resolvable libraries).
|
||||
analysis_entries(&plan, repo_id)
|
||||
let entries = analysis_entries(&plan, repo_id);
|
||||
if entries.is_empty() {
|
||||
// Detection worked but nothing resolved without a build: say so, so an
|
||||
// empty SBOM is not read as "this firmware has no components".
|
||||
return Err(format!(
|
||||
"{} build detected, but no components could be resolved without building it; \
|
||||
import a Firmwerk bundle for a complete firmware SBOM",
|
||||
plan.provider
|
||||
));
|
||||
}
|
||||
Ok(entries)
|
||||
}
|
||||
|
||||
/// Map a rendered [`firmwerk_sbom::Sbom`] (primary firmware + components) into
|
||||
@@ -169,3 +198,37 @@ fn analysis_entries(bp: &firmwerk_core::BuildPlan, repo_id: &str) -> Vec<SbomEnt
|
||||
}
|
||||
entries
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::expect_used, clippy::unwrap_used)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn fixture(name: &str) -> std::path::PathBuf {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../fixtures/nightly/firmware")
|
||||
.join(name)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_tree_without_a_supported_build_system_says_why() {
|
||||
let reason = firmware_sbom_entries(&fixture("yocto-layer"), "t", ExecPolicy::default())
|
||||
.await
|
||||
.expect_err("a Yocto layer forms no build plan");
|
||||
assert!(
|
||||
reason.contains("no supported firmware build system"),
|
||||
"{reason}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_make_project_yields_its_toolchain() {
|
||||
let entries = firmware_sbom_entries(&fixture("make"), "t", ExecPolicy::default())
|
||||
.await
|
||||
.expect("make forms a build plan");
|
||||
assert!(
|
||||
entries.iter().any(|e| e.package_manager == "toolchain"),
|
||||
"{entries:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -567,10 +567,15 @@ impl PipelineOrchestrator {
|
||||
new_count += n;
|
||||
}
|
||||
Some(_) => {
|
||||
tracing::warn!(
|
||||
target_id = %target_id,
|
||||
"Unified pipeline: source-archive scanning not yet wired; skipping"
|
||||
);
|
||||
// Recorded, not just logged, so an archive upload does not read as
|
||||
// "scanned, nothing found" (#325).
|
||||
self.skip_stage(
|
||||
scan_run_id,
|
||||
"code_scan",
|
||||
"SAST, secret and package-SBOM scanning run on git repositories only; \
|
||||
uploaded source archives are not scanned yet",
|
||||
)
|
||||
.await;
|
||||
}
|
||||
None => {
|
||||
// No code to scan (a migrated DAST target). Firmware/mobile static
|
||||
@@ -1076,16 +1081,24 @@ impl PipelineOrchestrator {
|
||||
// Analysis-based firmware SBOM: for embedded targets, derive components
|
||||
// (resolved libraries + cross-toolchain) from Firmwerk's build-plan
|
||||
// analysis over the already-ingested source — no build, no binary
|
||||
// upload. Best-effort; empty when no build plan forms.
|
||||
// upload. When no build plan forms (e.g. a Yocto layer), the run says
|
||||
// so rather than completing as if the firmware had no components.
|
||||
if crate::pipeline::firmware_sbom::is_firmware_target(target.target_type) {
|
||||
if let Some(code) = target.code_artifact() {
|
||||
if let Some(path) = working_paths.get(&code.id) {
|
||||
let entries = crate::pipeline::firmware_sbom::firmware_sbom_entries(
|
||||
let entries = match crate::pipeline::firmware_sbom::firmware_sbom_entries(
|
||||
path,
|
||||
target_id,
|
||||
compliance_core::ExecPolicy::from_env(self.config.app_env),
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
{
|
||||
Ok(entries) => entries,
|
||||
Err(reason) => {
|
||||
self.skip_stage(scan_run_id, "firmware_sbom", &reason).await;
|
||||
Vec::new()
|
||||
}
|
||||
};
|
||||
if !entries.is_empty() {
|
||||
// Only the firmware entries: a rescan with no new
|
||||
// commits skips the SBOM stage, so deleting everything
|
||||
|
||||
@@ -84,15 +84,22 @@ impl Agent {
|
||||
self.call(reqwest::Method::POST, path, Some(body)).await
|
||||
}
|
||||
|
||||
/// Upload one file artifact the way the dashboard does (multipart).
|
||||
/// Upload one file artifact the way the dashboard does (multipart). A
|
||||
/// directory is zipped first, so source-tree fixtures stay reviewable as
|
||||
/// plain files in the repository.
|
||||
async fn upload(&self, target_id: &str, a: &DemoArtifact, path: &Path) -> Result<(), String> {
|
||||
let bytes = tokio::fs::read(path)
|
||||
.await
|
||||
.map_err(|e| format!("reading {}: {e}", path.display()))?;
|
||||
let filename = path
|
||||
let name = path
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy().into_owned())
|
||||
.unwrap_or_default();
|
||||
let (bytes, filename) = if path.is_dir() {
|
||||
(zip_dir(path)?, format!("{name}.zip"))
|
||||
} else {
|
||||
let bytes = tokio::fs::read(path)
|
||||
.await
|
||||
.map_err(|e| format!("reading {}: {e}", path.display()))?;
|
||||
(bytes, name)
|
||||
};
|
||||
let mut form = reqwest::multipart::Form::new()
|
||||
.text("kind", serde_name(&a.kind))
|
||||
.part(
|
||||
@@ -150,6 +157,32 @@ fn text(v: &Value, key: &str) -> String {
|
||||
v[key].as_str().unwrap_or_default().to_string()
|
||||
}
|
||||
|
||||
/// Zip a fixture directory in memory, entries in a stable order.
|
||||
fn zip_dir(dir: &Path) -> Result<Vec<u8>, String> {
|
||||
use std::io::Write;
|
||||
|
||||
let mut files: Vec<PathBuf> = walkdir::WalkDir::new(dir)
|
||||
.into_iter()
|
||||
.filter_map(Result::ok)
|
||||
.filter(|e| e.file_type().is_file())
|
||||
.map(|e| e.into_path())
|
||||
.collect();
|
||||
files.sort();
|
||||
let mut zip = zip::ZipWriter::new(std::io::Cursor::new(Vec::new()));
|
||||
let options: zip::write::SimpleFileOptions = Default::default();
|
||||
for file in files {
|
||||
let rel = file
|
||||
.strip_prefix(dir)
|
||||
.map_err(|e| e.to_string())?
|
||||
.to_string_lossy()
|
||||
.replace('\\', "/");
|
||||
zip.start_file(rel, options).map_err(|e| e.to_string())?;
|
||||
let body = std::fs::read(&file).map_err(|e| format!("{}: {e}", file.display()))?;
|
||||
zip.write_all(&body).map_err(|e| e.to_string())?;
|
||||
}
|
||||
Ok(zip.finish().map_err(|e| e.to_string())?.into_inner())
|
||||
}
|
||||
|
||||
/// The wire name of a snake_case enum (`plc_project`, `project_archive`).
|
||||
fn serde_name<T: Serialize>(value: &T) -> String {
|
||||
serde_json::to_value(value)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan"
|
||||
],
|
||||
"sbom": [
|
||||
"toolchain:arduino-cli@"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan"
|
||||
],
|
||||
"sbom": [
|
||||
"toolchain:rustc@"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan"
|
||||
],
|
||||
"sbom": [
|
||||
"toolchain:arm-none-eabi-gcc@"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan"
|
||||
],
|
||||
"sbom": [
|
||||
"toolchain:esp-idf-toolchain@"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan"
|
||||
],
|
||||
"sbom": [
|
||||
"toolchain:arm-none-eabi-gcc@"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan"
|
||||
],
|
||||
"sbom": [
|
||||
"toolchain:arm-none-eabi-gcc@"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan"
|
||||
],
|
||||
"sbom": [
|
||||
"toolchain:arm-none-eabi-gcc@"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan",
|
||||
"firmware_sbom"
|
||||
],
|
||||
"sbom": [],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan",
|
||||
"firmware_sbom"
|
||||
],
|
||||
"sbom": [],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan"
|
||||
],
|
||||
"sbom": [
|
||||
"toolchain:zephyr-sdk@"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"code_scan"
|
||||
],
|
||||
"sbom": [
|
||||
"toolchain:zephyr-sdk@"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [],
|
||||
"registry_rules": []
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
# Firmware fixtures for the nightly scan regression (#313)
|
||||
|
||||
Each directory is uploaded as a source archive (the harness zips it) and
|
||||
exercises one Firmwerk build-system provider. Most are copied from Firmwerk's
|
||||
own provider tests (`crates/firmwerk-core/tests/fixtures`, Firmwerk v0.4.2),
|
||||
extended with the manifests a real project carries (marked "+"), so the
|
||||
baselines show when those start to reach the SBOM (#317):
|
||||
|
||||
| Directory | Firmwerk fixture | Provider |
|
||||
|---|---|---|
|
||||
| `make` | `make` | Make |
|
||||
| `cmake` | `cmake` | CMake with a toolchain file |
|
||||
| `arduino` | `arduino` | Arduino (`sketch.yaml`) |
|
||||
| `platformio` | `platformio-real` | PlatformIO (pinned platform, + `lib_deps`) |
|
||||
| `cargo-embedded` | `cargo_embedded` | embedded Rust (+ pinned `rust-toolchain.toml`) |
|
||||
| `espidf` | `espidf` | ESP-IDF (+ `main/idf_component.yml`) |
|
||||
| `zephyr-pinned` | `zephyr-pinned` | Zephyr (`west.yml`, pinned revision, + module imports) |
|
||||
| `freertos-cmake` | (ours) | CMake pulling the FreeRTOS kernel with `FetchContent` at a pinned tag |
|
||||
| `freertos-lostbuild` | `lostbuild` | source archaeology: no build system, FreeRTOS found from its headers |
|
||||
| `yocto-layer` | (ours) | none: Yocto is not analysed yet, so the scan must record it |
|
||||
|
||||
When Firmwerk's detection changes on purpose, refresh the copy and re-bless.
|
||||
@@ -0,0 +1,11 @@
|
||||
// Classic Arduino blink. No main() -- the Arduino core supplies it, Arduino.h, and prototypes.
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
delay(500);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
delay(500);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
profiles:
|
||||
default:
|
||||
fqbn: arduino:avr:uno
|
||||
default_profile: default
|
||||
@@ -0,0 +1,2 @@
|
||||
[build]
|
||||
target = "thumbv7em-none-eabihf"
|
||||
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "blinky"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
cortex-m = "0.7"
|
||||
cortex-m-rt = "0.7"
|
||||
@@ -0,0 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "1.82.0"
|
||||
targets = ["thumbv7em-none-eabihf"]
|
||||
@@ -0,0 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/toolchain.cmake)
|
||||
project(firmware C)
|
||||
add_executable(firmware src/main.c)
|
||||
@@ -0,0 +1,4 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_C_FLAGS "-mcpu=cortex-m4 -mthumb")
|
||||
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(hello_world)
|
||||
@@ -0,0 +1 @@
|
||||
idf_component_register(SRCS "main.c" INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,4 @@
|
||||
dependencies:
|
||||
idf: ">=5.1.2"
|
||||
espressif/led_strip: "==2.5.3"
|
||||
espressif/mdns: "^1.2.0"
|
||||
@@ -0,0 +1 @@
|
||||
void app_main(void) {}
|
||||
@@ -0,0 +1,2 @@
|
||||
CONFIG_IDF_TARGET="esp32c3"
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/arm-none-eabi.cmake)
|
||||
project(pump_rtos C ASM)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(freertos_kernel
|
||||
GIT_REPOSITORY https://github.com/FreeRTOS/FreeRTOS-Kernel.git
|
||||
GIT_TAG V11.1.0
|
||||
)
|
||||
add_library(freertos_config INTERFACE)
|
||||
target_include_directories(freertos_config SYSTEM INTERFACE include)
|
||||
set(FREERTOS_HEAP "4" CACHE STRING "" FORCE)
|
||||
set(FREERTOS_PORT "GCC_ARM_CM4F" CACHE STRING "" FORCE)
|
||||
FetchContent_MakeAvailable(freertos_kernel)
|
||||
|
||||
add_executable(pump_rtos src/main.c)
|
||||
target_link_libraries(pump_rtos freertos_kernel freertos_config)
|
||||
@@ -0,0 +1,5 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_C_FLAGS_INIT "-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard")
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configCPU_CLOCK_HZ 168000000
|
||||
#define configTICK_RATE_HZ 1000
|
||||
#define configMAX_PRIORITIES 5
|
||||
#define configMINIMAL_STACK_SIZE 128
|
||||
#define configTOTAL_HEAP_SIZE (32 * 1024)
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
static void pump_task(void *arg) {
|
||||
(void)arg;
|
||||
for (;;) {
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
xTaskCreate(pump_task, "pump", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
|
||||
vTaskStartScheduler();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#ifndef APP_CONFIG_H
|
||||
#define APP_CONFIG_H
|
||||
#define APP_TICK_HZ 1000
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
/* Motor controller firmware. Target: STM32F407VG. Build system lost in handover. */
|
||||
#include <stdint.h>
|
||||
#include "core_cm4.h"
|
||||
#include "stm32f4xx.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "app_config.h"
|
||||
|
||||
int main(void) {
|
||||
for (;;) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
CC = arm-none-eabi-gcc
|
||||
CFLAGS = -mcpu=cortex-m4 -mthumb -Wall -Og
|
||||
TARGET = firmware.elf
|
||||
|
||||
$(TARGET): src/main.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
@@ -0,0 +1,6 @@
|
||||
[com-esp32]
|
||||
platform = ${com.esp32_platform}
|
||||
|
||||
[env:esp32dev]
|
||||
extends = com-esp32
|
||||
board = esp32dev
|
||||
@@ -0,0 +1,14 @@
|
||||
[platformio]
|
||||
extra_configs =
|
||||
environments.ini
|
||||
|
||||
; Global defaults shared by every environment.
|
||||
[env]
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
bblanchon/ArduinoJson@7.0.4
|
||||
knolleary/PubSubClient@2.8
|
||||
|
||||
; Pinned platform versions, referenced by name below (like a real project's [com] section).
|
||||
[com]
|
||||
esp32_platform = espressif32@6.5.0
|
||||
@@ -0,0 +1,7 @@
|
||||
# Nightly fixture (#313): a minimal Yocto layer. Yocto builds are not analysed
|
||||
# yet, so the scan must record that instead of completing silently.
|
||||
BBPATH .= ":${LAYERDIR}"
|
||||
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb"
|
||||
BBFILE_COLLECTIONS += "pruefwerk-fixture"
|
||||
BBFILE_PATTERN_pruefwerk-fixture = "^${LAYERDIR}/"
|
||||
LAYERSERIES_COMPAT_pruefwerk-fixture = "scarthgap"
|
||||
@@ -0,0 +1,7 @@
|
||||
SUMMARY = "Pump controller daemon (nightly fixture)"
|
||||
LICENSE = "CLOSED"
|
||||
SRC_URI = "file://pump-ctl.c"
|
||||
DEPENDS = "openssl"
|
||||
do_compile() {
|
||||
${CC} ${CFLAGS} ${LDFLAGS} ${WORKDIR}/pump-ctl.c -o pump-ctl -lssl -lcrypto
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(blinky)
|
||||
target_sources(app PRIVATE src/main.c)
|
||||
@@ -0,0 +1,2 @@
|
||||
CONFIG_GPIO=y
|
||||
CONFIG_PRINTK=y
|
||||
@@ -0,0 +1,13 @@
|
||||
manifest:
|
||||
remotes:
|
||||
- name: zephyrproject
|
||||
url-base: https://github.com/zephyrproject-rtos
|
||||
projects:
|
||||
- name: zephyr
|
||||
remote: zephyrproject
|
||||
revision: v3.6.0
|
||||
import:
|
||||
name-allowlist:
|
||||
- cmsis
|
||||
- hal_nordic
|
||||
- mbedtls
|
||||
@@ -93,6 +93,140 @@
|
||||
"plc_format": "project_archive"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-make",
|
||||
"name": "Firmware · Make",
|
||||
"target_type": "firmware_bare_metal",
|
||||
"description": "Bare-metal Make project (Firmwerk make provider): cross toolchain from the Makefile.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/make"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-cmake",
|
||||
"name": "Firmware · CMake",
|
||||
"target_type": "firmware_bare_metal",
|
||||
"description": "Bare-metal CMake project with a toolchain file (Firmwerk cmake provider).",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/cmake"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-arduino",
|
||||
"name": "Firmware · Arduino",
|
||||
"target_type": "firmware_bare_metal",
|
||||
"description": "Arduino sketch with sketch.yaml (Firmwerk arduino provider).",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/arduino"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-platformio",
|
||||
"name": "Firmware · PlatformIO",
|
||||
"target_type": "firmware_bare_metal",
|
||||
"description": "PlatformIO project with extra_configs, a pinned platform and lib_deps (Firmwerk platformio provider).",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/platformio"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-cargo-embedded",
|
||||
"name": "Firmware · embedded Rust",
|
||||
"target_type": "firmware_bare_metal",
|
||||
"description": "Embedded Rust crate with a cross target in .cargo/config.toml and a pinned rust-toolchain.toml (Firmwerk cargo_embedded provider).",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/cargo-embedded"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-espidf",
|
||||
"name": "Firmware · ESP-IDF",
|
||||
"target_type": "firmware_rtos",
|
||||
"description": "ESP-IDF project with component-manager dependencies in main/idf_component.yml (Firmwerk espidf provider).",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/espidf"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-zephyr-pinned",
|
||||
"name": "Firmware · Zephyr (pinned west.yml)",
|
||||
"target_type": "firmware_rtos",
|
||||
"description": "Zephyr application whose west.yml pins zephyr at v3.6.0 and imports three modules (Firmwerk zephyr provider).",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/zephyr-pinned"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-freertos-cmake",
|
||||
"name": "Firmware · FreeRTOS via CMake FetchContent",
|
||||
"target_type": "firmware_rtos",
|
||||
"description": "CMake project that pulls the FreeRTOS kernel with FetchContent at a pinned tag (V11.1.0), the common FreeRTOS integration.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/freertos-cmake"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-freertos-lostbuild",
|
||||
"name": "Firmware · FreeRTOS, build system lost",
|
||||
"target_type": "firmware_rtos",
|
||||
"description": "No build system at all: Firmwerk's source archaeology must still recognise FreeRTOS and the STM32 SDK from the headers.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/freertos-lostbuild"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-yocto-layer",
|
||||
"name": "Firmware · Yocto layer (unsupported)",
|
||||
"target_type": "embedded_linux_yocto",
|
||||
"description": "A Yocto layer. Not analysed yet, so the run must record a skipped firmware_sbom stage with the reason instead of completing as if there were no components.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/firmware/yocto-layer"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "fw-zephyr-example-pinned",
|
||||
"name": "Firmware · Zephyr example-application (pinned source)",
|
||||
"target_type": "firmware_rtos",
|
||||
"description": "The upstream Zephyr example application as a source archive at a pinned commit, so the result does not drift with upstream main. Not committed: the nightly job downloads it into NIGHTLY_ZEPHYR_EXAMPLE; skipped where that is unset.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload_env": "NIGHTLY_ZEPHYR_EXAMPLE",
|
||||
"optional": true,
|
||||
"pin": "38a6d9b276ed434454900130cacc87d058d3ac62"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user