From be8d343da3b3407b813e9fc22cb5955210ce0c8e Mon Sep 17 00:00:00 2001 From: Vitaly Domnikov Date: Wed, 22 Nov 2023 22:39:12 -0800 Subject: [PATCH] cm4 port --- .github/workflows/build.yml | 12 ++++++------ readme.md | 11 +++++++++-- src/gpio.rs | 28 ++++++++++++++-------------- src/main.rs | 27 +++++++++++++++++++-------- src/service.rs | 2 +- 5 files changed, 49 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 205dfdb..ca96334 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,10 +60,10 @@ jobs: ./install.sh ./upico.service ./upico - outPath: upico_${{ github.ref_name }}.riscv64gc.tar.gz - - name: Copy CM4/A-04/A-06 binary + outPath: upico_${{ github.ref_name }}.r01.tar.gz + - name: Copy CM4 binary run : cp -f ./target/armv7-unknown-linux-musleabihf/release/upico upico - - name: Compress CM4/A-04/A-06 Build + - name: Compress CM4 Build uses: a7ul/tar-action@v1.1.0 with: command: c @@ -74,7 +74,7 @@ jobs: ./install.sh ./upico.service ./upico - outPath: upico_${{ github.ref_name }}.armv7.tar.gz + outPath: upico_${{ github.ref_name }}.cm4.tar.gz - name: Upload Build Artifacts uses: actions/upload-artifact@v3 with: @@ -86,5 +86,5 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: files: | - upico_${{ github.ref_name }}.riscv64gc.tar.gz - upico_${{ github.ref_name }}.armv7.tar.gz + upico_${{ github.ref_name }}.r01.tar.gz + upico_${{ github.ref_name }}.cm4.tar.gz diff --git a/readme.md b/readme.md index 3b50caa..16501bd 100644 --- a/readme.md +++ b/readme.md @@ -26,10 +26,10 @@ Second project name is `atto`, cause 10−6 * 10-12 = 10 Command { let mount_arg = arg!(mount: -m "Mount Pico disk"); let dev_arg = arg!(-d "Path to Pico disk device").default_value("/dev/sda1"); - let line_arg = arg!( "Power line") - .value_parser([ + let line_arg = arg!( "Power line").required(true); + let line_arg = if cfg!(any(target_arch = "arm", target_arch = "aarch64")) { + line_arg.value_parser([PossibleValue::new("vdd"), PossibleValue::new("usb")]) + } else { + line_arg.value_parser([ PossibleValue::new("aux"), PossibleValue::new("vdd"), PossibleValue::new("usb"), ]) - .required(true); + }; + Command::new("upico") .about("uPico control app") .version(env!("CARGO_PKG_VERSION")) @@ -64,10 +68,13 @@ fn cli() -> Command { .about("Install firmware to Pico") .arg_required_else_help(true) .arg(arg!( "Path to UF2 firmware file").required(true)) - .arg( + .arg(if cfg!(any(target_arch = "arm", target_arch = "aarch64")) { + arg!(-p "Path to mounted Pico disk") + .default_value("/media/pi/RPI-RP2") + } else { arg!(-p "Path to mounted Pico disk") - .default_value("/media/cpi/RPI-RP2"), - ) + .default_value("/media/cpi/RPI-RP2") + }) .arg(mount_arg) .arg(dev_arg), ) @@ -79,7 +86,11 @@ fn cli() -> Command { .subcommand(Command::new("on").about("Power on").arg(line_arg.clone())) .subcommand(Command::new("off").about("Power off").arg(line_arg.clone())) .subcommand(Command::new("cycle").about("Power cycle").arg(line_arg)) - .subcommand(Command::new("status").about("Power status")), + .subcommand( + Command::new("status") + .about("Power status") + .hide(cfg!(any(target_arch = "arm", target_arch = "aarch64"))), + ), ) .subcommand(Command::new("pinout").about("Print pinout diagram")) } @@ -179,7 +190,7 @@ fn run() -> AppResult { let line = parse_power_line(cmd)?; Service::send(Request::PowerCycle(line))?; } - Some(("status", _)) => { + Some(("status", _)) if cfg!(not(any(target_arch = "arm", target_arch = "aarch64"))) => { if let Response::PowerReport(report) = Service::send(Request::PowerStatus)? { print_power_state("AUX", report.aux); print_power_state("VDD", report.vdd); diff --git a/src/service.rs b/src/service.rs index 2429b38..16fb9cb 100644 --- a/src/service.rs +++ b/src/service.rs @@ -101,7 +101,7 @@ impl Service { let packet = to_vec(&req).unwrap(); stream.write(&packet).map_err(AppError::IoError)?; - thread::sleep(Duration::from_millis(250)); + thread::sleep(Duration::from_millis(300)); let mut scratch = [0; 64]; let n = stream.read(&mut scratch).map_err(AppError::ServiceError)?;