From 70d287c855b6e244332df82fe6f4d17e21e1338b Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Fri, 10 Mar 2023 16:37:08 +0100 Subject: [PATCH] different versioning --- .github/workflows/build.yml | 22 +++++++++++----------- build.sh | 17 +++++++++-------- sw/controller/src/cfg.c | 2 +- sw/controller/src/usb.c | 4 ++-- sw/controller/src/version.c | 10 ++++++---- sw/controller/src/version.h | 2 +- sw/deployer/Cargo.lock | 2 +- sw/deployer/Cargo.toml | 2 +- sw/deployer/src/main.rs | 4 ++-- sw/deployer/src/sc64/mod.rs | 13 +++++++------ 10 files changed, 41 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7995dde..a36b892 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: id: version with: pattern: '\/' - string: '-${{ github.ref_name }}' + string: '${{ github.ref_name }}' replace-with: '-' - name: Build firmware @@ -36,18 +36,18 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v3 with: - name: sc64-pkg${{ steps.version.outputs.replaced }} + name: sc64-pkg-${{ steps.version.outputs.replaced }} path: | - sc64-extra${{ steps.version.outputs.replaced }}.zip - sc64-firmware${{ steps.version.outputs.replaced }}.bin + sc64-extra-${{ steps.version.outputs.replaced }}.zip + sc64-firmware-${{ steps.version.outputs.replaced }}.bin - name: Upload release assets if: github.event_name == 'release' && github.event.action == 'created' uses: softprops/action-gh-release@v0.1.15 with: files: | - sc64-extra${{ steps.version.outputs.replaced }}.zip - sc64-firmware${{ steps.version.outputs.replaced }}.bin + sc64-extra-${{ steps.version.outputs.replaced }}.zip + sc64-firmware-${{ steps.version.outputs.replaced }}.bin build-deployer: strategy: @@ -84,7 +84,7 @@ jobs: id: version with: pattern: '\/' - string: '-${{ github.ref_name }}' + string: '${{ github.ref_name }}' replace-with: '-' - name: Install linux packages @@ -101,18 +101,18 @@ jobs: run: | mkdir package cd target/release - tar ${{ matrix.options }} ../../package/${{ matrix.name }}${{ steps.version.outputs.replaced }}.${{ matrix.extension }} ${{ matrix.executable }} + tar ${{ matrix.options }} ../../package/${{ matrix.name }}-${{ steps.version.outputs.replaced }}.${{ matrix.extension }} ${{ matrix.executable }} working-directory: sw/deployer - name: Upload artifact uses: actions/upload-artifact@v3 with: - name: ${{ matrix.name }}${{ steps.version.outputs.replaced }} - path: sw/deployer/package/${{ matrix.name }}${{ steps.version.outputs.replaced }}.${{ matrix.extension }} + name: ${{ matrix.name }}-${{ steps.version.outputs.replaced }} + path: sw/deployer/package/${{ matrix.name }}-${{ steps.version.outputs.replaced }}.${{ matrix.extension }} - name: Upload release assets if: github.event_name == 'release' && github.event.action == 'created' uses: softprops/action-gh-release@v0.1.15 with: files: | - sw/deployer/package/${{ matrix.name }}${{ steps.version.outputs.replaced }}.${{ matrix.extension }} + sw/deployer/package/${{ matrix.name }}-${{ steps.version.outputs.replaced }}.${{ matrix.extension }} diff --git a/build.sh b/build.sh index 6a0c7c9..9f5b78a 100755 --- a/build.sh +++ b/build.sh @@ -2,13 +2,15 @@ set -e +SC64_VERSION=${SC64_VERSION:-"none"} + PACKAGE_FILE_NAME="sc64-extra" TOP_FILES=( "./fw/ftdi/ft232h_config.xml" "./sw/tools/primer.py" "./sw/tools/requirements.txt" - "./sw/tools/sc64-firmware.bin" + "./sc64-firmware-${SC64_VERSION}.bin" ) FILES=( @@ -85,9 +87,10 @@ build_update () { pushd sw/tools > /dev/null if [ "$FORCE_CLEAN" = true ]; then - rm -f ./sc64-firmware.bin + rm -f ../../sc64-firmware-*.bin fi GIT_INFO="" + if [ ! -z "${SC64_VERSION}" ]; then GIT_INFO+=$'\n'"ver: $SC64_VERSION"; fi if [ ! -z "${GIT_BRANCH}" ]; then GIT_INFO+=$'\n'"branch: $GIT_BRANCH"; fi if [ ! -z "${GIT_TAG}" ]; then GIT_INFO+=$'\n'"tag: $GIT_TAG"; fi if [ ! -z "${GIT_SHA}" ]; then GIT_INFO+=$'\n'"sha: $GIT_SHA"; fi @@ -98,7 +101,7 @@ build_update () { --fpga ../../fw/project/lcmxo2/impl1/sc64_impl1.jed \ --boot ../bootloader/build/bootloader.bin \ --primer ../controller/build/primer/primer.bin \ - sc64-firmware.bin + ../../sc64-firmware-${SC64_VERSION}.bin popd > /dev/null BUILT_UPDATE=true @@ -109,15 +112,13 @@ build_release () { build_update - if [ -e "./${PACKAGE_FILE_NAME}.zip" ]; then - rm -f "./${PACKAGE_FILE_NAME}.zip" + if [ -e "./${PACKAGE_FILE_NAME}-${SC64_VERSION}.zip" ]; then + rm -f ./${PACKAGE_FILE_NAME}-${SC64_VERSION}.zip fi - PACKAGE="./${PACKAGE_FILE_NAME}${SC64_VERSION}.zip" + PACKAGE="./${PACKAGE_FILE_NAME}-${SC64_VERSION}.zip" zip -j -r $PACKAGE ${TOP_FILES[@]} zip -r $PACKAGE ${FILES[@]} - cp sw/tools/sc64-firmware.bin ./sc64-firmware${SC64_VERSION}.bin - BUILT_RELEASE=true } diff --git a/sw/controller/src/cfg.c b/sw/controller/src/cfg.c index 359ac6d..dcc1939 100644 --- a/sw/controller/src/cfg.c +++ b/sw/controller/src/cfg.c @@ -470,7 +470,7 @@ void cfg_process (void) { break; case 'V': - args[0] = version_firmware(); + version_firmware(&args[0], &args[1]); break; case 'c': diff --git a/sw/controller/src/usb.c b/sw/controller/src/usb.c index c0a8e3f..52d531c 100644 --- a/sw/controller/src/usb.c +++ b/sw/controller/src/usb.c @@ -191,8 +191,8 @@ static void usb_rx_process (void) { case 'V': p.rx_state = RX_STATE_IDLE; p.response_pending = true; - p.response_info.data_length = 4; - p.response_info.data[0] = version_firmware(); + p.response_info.data_length = 8; + version_firmware(&p.response_info.data[0], &p.response_info.data[1]); break; case 'R': diff --git a/sw/controller/src/version.c b/sw/controller/src/version.c index fb992ad..082e432 100644 --- a/sw/controller/src/version.c +++ b/sw/controller/src/version.c @@ -1,10 +1,12 @@ #include "version.h" -#define VERSION_MAJOR (2) -#define VERSION_MINOR (12) +#define VERSION_MAJOR (2) +#define VERSION_MINOR (12) +#define VERSION_REVISION (1) -uint32_t version_firmware (void) { - return ((VERSION_MAJOR << 16) | (VERSION_MINOR)); +void version_firmware (uint32_t *version, uint32_t *revision) { + *version = ((VERSION_MAJOR << 16) | (VERSION_MINOR)); + *revision = VERSION_REVISION; } diff --git a/sw/controller/src/version.h b/sw/controller/src/version.h index b5a3c0a..60d54d2 100644 --- a/sw/controller/src/version.h +++ b/sw/controller/src/version.h @@ -5,7 +5,7 @@ #include -uint32_t version_firmware (void); +void version_firmware (uint32_t *version, uint32_t *revision); #endif diff --git a/sw/deployer/Cargo.lock b/sw/deployer/Cargo.lock index 2a7e898..2bd78ad 100644 --- a/sw/deployer/Cargo.lock +++ b/sw/deployer/Cargo.lock @@ -1002,7 +1002,7 @@ dependencies = [ [[package]] name = "sc64deployer" -version = "2.12.2" +version = "2.12.1" dependencies = [ "chrono", "clap", diff --git a/sw/deployer/Cargo.toml b/sw/deployer/Cargo.toml index 00933d1..ba20d41 100644 --- a/sw/deployer/Cargo.toml +++ b/sw/deployer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc64deployer" -version = "2.12.2" +version = "2.12.1" edition = "2021" authors = ["Polprzewodnikowy"] description = "SC64 loader and control software" diff --git a/sw/deployer/src/main.rs b/sw/deployer/src/main.rs index ba197d3..6fb4863 100644 --- a/sw/deployer/src/main.rs +++ b/sw/deployer/src/main.rs @@ -460,12 +460,12 @@ fn handle_dump_command(connection: Connection, args: &DumpArgs) -> Result<(), sc fn handle_info_command(connection: Connection) -> Result<(), sc64::Error> { let mut sc64 = init_sc64(connection, true)?; - let (major, minor) = sc64.check_firmware_version()?; + let (major, minor, revision) = sc64.check_firmware_version()?; let state = sc64.get_device_state()?; let datetime = state.datetime.format("%Y-%m-%d %H:%M:%S %Z"); println!("{}", "SC64 information and current state:".bold()); - println!(" Firmware version: v{}.{}", major, minor); + println!(" Firmware version: v{}.{}.{}", major, minor, revision); println!(" RTC datetime: {}", datetime); println!(" Boot mode: {}", state.boot_mode); println!(" Save type: {}", state.save_type); diff --git a/sw/deployer/src/sc64/mod.rs b/sw/deployer/src/sc64/mod.rs index 6f39c60..4d0b405 100644 --- a/sw/deployer/src/sc64/mod.rs +++ b/sw/deployer/src/sc64/mod.rs @@ -109,20 +109,21 @@ impl SC64 { Ok(data[0..4].try_into().unwrap()) } - fn command_version_get(&mut self) -> Result<(u16, u16), Error> { + fn command_version_get(&mut self) -> Result<(u16, u16, u32), Error> { let data = self.link.execute_command(&Command { id: b'V', args: [0, 0], data: &[], })?; - if data.len() != 4 { + if data.len() != 8 { return Err(Error::new( "Invalid data length received for version get command", )); } let major = u16::from_be_bytes(data[0..2].try_into().unwrap()); let minor = u16::from_be_bytes(data[2..4].try_into().unwrap()); - Ok((major, minor)) + let revision = u32::from_be_bytes(data[4..8].try_into().unwrap()); + Ok((major, minor, revision)) } fn command_state_reset(&mut self) -> Result<(), Error> { @@ -613,8 +614,8 @@ impl SC64 { Ok(()) } - pub fn check_firmware_version(&mut self) -> Result<(u16, u16), Error> { - let (major, minor) = self + pub fn check_firmware_version(&mut self) -> Result<(u16, u16, u32), Error> { + let (major, minor, revision) = self .command_version_get() .map_err(|_| Error::new("Outdated SC64 firmware version, please update firmware"))?; if major != SUPPORTED_MAJOR_VERSION || minor < SUPPORTED_MINOR_VERSION { @@ -622,7 +623,7 @@ impl SC64 { "Unsupported SC64 firmware version, please update firmware", )); } - Ok((major, minor)) + Ok((major, minor, revision)) } pub fn reset_state(&mut self) -> Result<(), Error> {