diff --git a/.github/workflows/usb-input-release.yml b/.github/workflows/usb-input-release.yml index ddb7c051..b2149ee0 100644 --- a/.github/workflows/usb-input-release.yml +++ b/.github/workflows/usb-input-release.yml @@ -12,60 +12,121 @@ concurrency: group: pages cancel-in-progress: true jobs: - preserve: + build: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - - name: Released site before the USB fix - uses: actions/download-artifact@v4 + - uses: actions/setup-python@v5 with: - name: github-pages - run-id: 41724556988 - github-token: ${{ github.token }} - path: build/released - - name: Successfully built and tested fix - uses: actions/download-artifact@v4 - with: - name: github-pages - run-id: 41743635478 - github-token: ${{ github.token }} - path: build/tested - - name: Preserve release bytes, add beta only + python-version: '3.13' + - name: Candidate pin + id: pin run: | python3 - <<'PY' + import json,os,re from pathlib import Path - import tarfile,shutil,json,hashlib m=json.loads(Path('web/USB_INPUT_RELEASE.json').read_text()) - def digest(p):return hashlib.sha256(p.read_bytes()).hexdigest() - def protected(root): - return {p.relative_to(root).as_posix():digest(p) for p in root.rglob('*') if p.is_file() and p.relative_to(root).parts[0]!='preview'} - pages=Path('build/pages');tested=Path('build/tested-site') - pages.mkdir();tested.mkdir() - with tarfile.open('build/released/artifact.tar') as t:t.extractall(pages,filter='data') - with tarfile.open('build/tested/artifact.tar') as t:t.extractall(tested,filter='data') - before=protected(pages) - original=json.loads((pages/'preview/firmware/versions.json').read_text())[0] - original_bytes=(pages/'preview/firmware'/original['file']).read_bytes() - prior_hash=hashlib.sha256(original_bytes).hexdigest() - shutil.rmtree(pages/'preview');shutil.copytree(tested/'preview',pages/'preview') - fw=pages/'preview/firmware';versions=json.loads((fw/'versions.json').read_text()) - assert len(versions)==2 - assert versions[0]['version']==m['version'] - assert digest(fw/versions[0]['file'])==m['sha256'],'tested fix differs' - assert (fw/'SOURCE_COMMIT').read_text().strip()==m['source'] - assert versions[1]['version'].startswith('V10.61-6c48e2a') - (fw/versions[1]['file']).write_bytes(original_bytes) - assert digest(fw/versions[1]['file'])==prior_hash - (fw/'SHA256SUMS').write_text(''.join(digest(p)+' '+p.name+'\n' for p in sorted(fw.glob('felucca-*.fwsc')))) - assert before==protected(pages),'a file outside beta changed' - print('PASS: exact tested USB fix; previous beta byte-identical; all public files and emulator byte-identical to released site') - print('Versions:',[v['version'] for v in versions]) + assert re.fullmatch('[0-9a-f]{40}',m['source']) + assert Path('web/PREVIEW').read_text().strip()==m['source'] + with open(os.environ['GITHUB_OUTPUT'],'a') as f:f.write('source='+m['source']+'\n') PY + - uses: actions/checkout@v4 + with: + ref: ${{ steps.pin.outputs.source }} + path: build/candidate + persist-credentials: false + - name: Frozen published site + uses: actions/download-artifact@v4 + with: + name: github-pages + run-id: 41745149049 + github-token: ${{ github.token }} + path: build/released + - name: JieLi toolchain cache + uses: actions/cache@v4 + with: + path: | + ~/.jieli + ~/fw-AC79_AIoT_SDK/cpu/wl82/tools + key: jieli-ac79-v1.2.1 + - name: Toolchain and SDK + run: | + retry() { for d in 0 5 15 30; do sleep $d; "$@" && return 0; done; return 1; } + T=$HOME/fw-AC79_AIoT_SDK/cpu/wl82/tools + [ -e "$HOME/.jieli/toolchain" ] || retry sh tools/get_toolchain.sh "$HOME/.jieli" + if [ ! -s "$T/uboot.boot" ] || [ ! -s "$T/cfg_tool.bin" ] || [ ! -s "$T/cfg/eq_cfg_hw.bin" ]; then + retry git clone --filter=blob:none --no-checkout https://gitee.com/Jieli-Tech/fw-AC79_AIoT_SDK.git "$HOME/fw-AC79_AIoT_SDK" + cd "$HOME/fw-AC79_AIoT_SDK" + git sparse-checkout set --no-cone /cpu/wl82/tools/uboot.boot /cpu/wl82/tools/cfg_tool.bin /cpu/wl82/tools/cfg/eq_cfg_hw.bin + retry git checkout d179b4484759423312073f5fbb232501aa491047 + fi + test -s "$T/uboot.boot" && test -s "$T/cfg_tool.bin" && test -s "$T/cfg/eq_cfg_hw.bin" + - name: USB input regressions and target build + env: + AC79_SDK: /home/runner/fw-AC79_AIoT_SDK + JIELI_TOOLCHAIN: /home/runner/.jieli/toolchain + run: | + pip install Pillow==12.3.0 numpy==2.3.5 fonttools==4.61.1 + cd build/candidate + python3 tests/uac_input_irq_test.py + for CDC in 0 1; do + cc -O2 -w -DHALF_FRAMES=128 -DT_CDC="$CDC" tests/uac_test.c -lm -o "/tmp/uac-$CDC" + "/tmp/uac-$CDC" + done + python3 tools/build.py + - name: Exact package and beta only + run: | + mkdir -p build/pages + tar -xf build/released/artifact.tar -C build/pages + node --input-type=module - <<'JS' + import fs from 'node:fs';import {Package,crc16} from './web/fm1pkg.js'; + const fw='build/pages/preview/firmware/'; + const oldv=JSON.parse(fs.readFileSync(fw+'versions.json'))[0]; + const old=new Package(fs.readFileSync(fw+oldv.file)); + const p=new Package(fs.readFileSync('build/candidate/build/felucca.fwsc')); + if(p.product!==old.product||p.flashSize!==old.flashSize||p.app.size!==old.app.size||p.sfcEnd>p.flashSize)throw Error('Unexpected package layout'); + if(crc16(p.dec.subarray(p.appOff,p.appOff+p.app.size))!==p.app.dcrc)throw Error('Bad application CRC'); + for(const type of [100,200]){ + const a=p.entries.find(e=>e.type===type),b=old.entries.find(e=>e.type===type); + if(!a||!b||a.size!==b.size||!Buffer.from(p.raw.subarray(a.dataOff+p.skew,a.dataOff+p.skew+a.size)).equals(Buffer.from(old.raw.subarray(b.dataOff+old.skew,b.dataOff+old.skew+b.size))))throw Error('Loader or Bluetooth segment changed'); + } + console.log('PASS package CRC, layout, unchanged loader and Bluetooth'); + JS + python3 - <<'PY' + from pathlib import Path + import hashlib,json,re,shutil,sys + sys.path.insert(0,'web');import make_site + m=json.loads(Path('web/USB_INPUT_RELEASE.json').read_text()) + pages=Path('build/pages');fw=pages/'preview/firmware' + def digest(p):return hashlib.sha256(p.read_bytes()).hexdigest() + def protected(): + return {p.relative_to(pages).as_posix():digest(p) for p in pages.rglob('*') if p.is_file() and p.relative_to(pages).parts[0]!='preview'} + before=protected() + prior=json.loads((fw/'versions.json').read_text()) + old={v['file']:digest(fw/v['file']) for v in prior} + v=re.search(r'^#define FELUCCA_VERSION "([^"]+)"',Path('build/candidate/firmware/src/felucca.c').read_text(),re.M).group(1) + assert m['version']==v+'-'+m['source'][:7]+'-preview' + make_site.main('build/candidate/build/felucca.fwsc',m['version'],'build/new-preview',str(fw)) + shutil.rmtree(pages/'preview');shutil.copytree('build/new-preview',pages/'preview') + fw=pages/'preview/firmware';versions=json.loads((fw/'versions.json').read_text()) + assert len(versions)==3 and versions[0]['version']==m['version'] + for name,h in old.items():assert digest(fw/name)==h,'previous beta package changed' + (fw/'SOURCE_COMMIT').write_text(m['source']+'\n') + (fw/'SHA256SUMS').write_text(''.join(digest(p)+' '+p.name+'\n' for p in sorted(fw.glob('felucca-*.fwsc')))) + assert before==protected(),'a public or emulator file changed' + print('PASS previous beta bytes preserved; every file outside beta preserved') + print('Published versions:',[x['version'] for x in versions]) + print('New package SHA256:',digest(fw/versions[0]['file'])) + PY + - uses: actions/upload-artifact@v4 + with: + name: usb-input-fix2 + path: build/candidate/build/felucca.fwsc - uses: actions/upload-pages-artifact@v3 with: path: build/pages deploy: - needs: preserve + needs: build runs-on: ubuntu-24.04 environment: name: github-pages diff --git a/web/BETA_VERSIONS b/web/BETA_VERSIONS index 1474a500..c86ac734 100644 --- a/web/BETA_VERSIONS +++ b/web/BETA_VERSIONS @@ -1,2 +1,3 @@ -# Previous beta retained for comparison with the USB INPUT fix. -6c48e2a8e7049c31ab77c57b97c3ef6790d24090 # V10.61 before fix codex +# Previous betas retained for USB input comparison. +8b13fcd7a9985fd22801478b5697afaa3637df61 # V10.61-fix-codex +6c48e2a8e7049c31ab77c57b97c3ef6790d24090 # V10.61 diff --git a/web/PREVIEW b/web/PREVIEW index 2ff9e211..a664e01d 100644 --- a/web/PREVIEW +++ b/web/PREVIEW @@ -1 +1 @@ -8b13fcd7a9985fd22801478b5697afaa3637df61 +a87301bb99a689f8f62c289657e63050bedd684b diff --git a/web/USB_INPUT_RELEASE.json b/web/USB_INPUT_RELEASE.json index b8848260..201abfee 100644 --- a/web/USB_INPUT_RELEASE.json +++ b/web/USB_INPUT_RELEASE.json @@ -1,7 +1,5 @@ { - "source": "8b13fcd7a9985fd22801478b5697afaa3637df61", - "version": "V10.61-fix-codex-8b13fcd-preview", - "sha256": "1344edd5e7a90b38c790d38361e4ab5a035d8292829894d11b774134af11567b", - "validated_run": 41743635478, - "released_site_run": 41724556988 + "source": "a87301bb99a689f8f62c289657e63050bedd684b", + "version": "V10.61-fix-codex2-a87301b-preview", + "released_site_run": 41745149049 }