diff --git a/.github/dev/Dockerfile b/.github/dev/Dockerfile index 690dab77..57c3d5f7 100644 --- a/.github/dev/Dockerfile +++ b/.github/dev/Dockerfile @@ -15,6 +15,7 @@ RUN apt-get update -y && \ libssl-dev \ dos2unix \ sudo \ + sshpass \ unzip \ wget \ g++-aarch64-linux-gnu \ diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 2f0fe14b..9f60ac8e 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -137,6 +137,10 @@ jobs: echo "${{ env.GIT_VERSION }}" > pr-info/version echo "${{ env.JOB_START }}" > pr-info/job_start echo "$(date +%s)" > pr-info/job_end + echo basic-build >> pr-info/artifacts + echo extended-build >> pr-info/artifacts + echo basic-devel-build >> pr-info/artifacts + echo extended-devel-build >> pr-info/artifacts - name: Upload PR info if: github.event_name == 'pull_request' diff --git a/.github/workflows/pull_request_comment.yaml b/.github/workflows/pull_request_comment.yaml index 646ac649..632b1d70 100644 --- a/.github/workflows/pull_request_comment.yaml +++ b/.github/workflows/pull_request_comment.yaml @@ -46,7 +46,8 @@ jobs: run_id: runId }); - const buildArtifacts = artifacts.artifacts.filter(a => a.name !== 'pr-info'); + const artifactNames = fs.readFileSync('pr-info/artifacts', 'utf8').trim().split('\n'); + const buildArtifacts = artifacts.artifacts.filter(a => artifactNames.includes(a.name)); const artifactLines = buildArtifacts.map(a => { const url = `https://github.com/${{ github.repository }}/actions/runs/${runId}/artifacts/${a.id}`; const size = (a.size_in_bytes / 1024 / 1024).toFixed(2); diff --git a/Makefile b/Makefile index 599973fd..7ca6ec7f 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ all: tools # ================= Build Tools ================= OUTPUT_FILE := firmware/firmware.bin +BUILD_DIR ?= tmp/firmware ifneq (,$(PROFILE)) PROFILE_MAIN := $(patsubst %-devel,%,$(PROFILE)) @@ -26,7 +27,7 @@ else ifeq (,$(filter $(PROFILE_MAIN),$(PROFILES))) @echo "Invalid profile '$(PROFILE_MAIN)'. Available profiles are: $(PROFILES)." @exit 1 endif - ./scripts/create_firmware.sh $< tmp/firmware $@ $(OVERLAYS) + ./scripts/create_firmware.sh $< $(BUILD_DIR) $@ $(OVERLAYS) .PHONY: build build: $(OUTPUT_FILE) diff --git a/dev.sh b/dev.sh index c38207fc..0a94eff8 100755 --- a/dev.sh +++ b/dev.sh @@ -13,6 +13,6 @@ fi TTY_FLAG="" [[ -t 0 ]] && TTY_FLAG="-it" -ENV_FLAGS="-e GIT_VERSION -e CI" +ENV_FLAGS="-e GIT_VERSION -e CI -e PASSWORD" exec docker run --rm $TTY_FLAG $ENV_FLAGS --cap-add=SYS_ADMIN -w "$PWD" -v "$PWD:$PWD" "$IMAGE_NAME" "$@" diff --git a/docs/development.md b/docs/development.md index 1df290d5..f99b6876 100644 --- a/docs/development.md +++ b/docs/development.md @@ -186,6 +186,26 @@ To extract and examine the base firmware: Output: `tmp/extracted/` +## Upgrade Firmware + +To build and deploy firmware directly to a connected printer: + +```bash +./dev.sh ./scripts/dev/upgrade-firmware.sh root@ +``` + +Example: + +```bash +./dev.sh ./scripts/dev/upgrade-firmware.sh root@192.168.1.100 extended +``` + +By default, the script uses `snapmaker` as the SSH password. To use a different password: + +```bash +PASSWORD=mypassword ./dev.sh ./scripts/dev/upgrade-firmware.sh root@192.168.1.100 extended +``` + ## Release Process The project uses GitHub Actions for automated releases: diff --git a/scripts/dev/upgrade-firmware.sh b/scripts/dev/upgrade-firmware.sh index ee1bdbc3..0a44b82d 100755 --- a/scripts/dev/upgrade-firmware.sh +++ b/scripts/dev/upgrade-firmware.sh @@ -9,9 +9,11 @@ SSH_HOST="$1" PROFILE="$2" shift 2 +PASSWORD="${PASSWORD:-snapmaker}" +SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + set -xe -rm -rf "firmware/firmware_$PROFILE.bin" "tmp/firmware" -make build OUTPUT_FILE=firmware/firmware_$PROFILE.bin PROFILE="$PROFILE" -scp "tmp/firmware/update.img" "$SSH_HOST:/tmp/" -ssh "$SSH_HOST" /home/lava/bin/systemUpgrade.sh upgrade soc /tmp/update.img \ No newline at end of file +make build OUTPUT_FILE=firmware/firmware_$PROFILE.bin PROFILE="$PROFILE" OVERWRITE=1 +sshpass -p "$PASSWORD" scp $SSH_OPTS "tmp/firmware/update.img" "$SSH_HOST:/tmp/" +sshpass -p "$PASSWORD" ssh $SSH_OPTS "$SSH_HOST" /home/lava/bin/systemUpgrade.sh upgrade soc /tmp/update.img diff --git a/scripts/helpers/pack_firmware.sh b/scripts/helpers/pack_firmware.sh index 9c291e09..212b0685 100755 --- a/scripts/helpers/pack_firmware.sh +++ b/scripts/helpers/pack_firmware.sh @@ -12,7 +12,7 @@ if [[ ! -d "$1" ]]; then exit 1 fi -if [[ -f "$2" ]]; then +if [[ -f "$2" ]] && [[ -z "$OVERWRITE" ]]; then echo "Error: Output file $2 already exists." exit 1 fi