mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Merge branch 'main' into rework_st_delete
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# This is just a placeholder while the whole PyInstaller thing gets figured out
|
||||
name: Client build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
checkout-sha:
|
||||
required: false
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
build_client:
|
||||
name: Build client
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- name: windows
|
||||
os: windows-latest
|
||||
pre_command: |
|
||||
? .
|
||||
bundle_command: |
|
||||
Compress-Archive -Path software\* -DestinationPath client-windows.zip
|
||||
- name: linux
|
||||
os: ubuntu-latest
|
||||
pre_command: |
|
||||
true
|
||||
bundle_command: |
|
||||
(cd software && zip -r "$OLDPWD/client-linux.zip" .)
|
||||
- name: macos
|
||||
os: macos-latest
|
||||
pre_command: |
|
||||
true
|
||||
bundle_command: |
|
||||
(cd software && zip -r "$OLDPWD/client-macos.zip" .)
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ inputs.checkout-sha == null && github.sha || inputs.checkout-sha }}
|
||||
- name: Run OS specific setup
|
||||
run: ${{ matrix.pre_command }}
|
||||
- name: Upload built client
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: client-${{ matrix.name }}
|
||||
path: software/*
|
||||
- name: Zip up client for release
|
||||
run: ${{ matrix.bundle_command }}
|
||||
- name: Upload release artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: release-artifacts
|
||||
path: client-${{ matrix.name }}.zip
|
||||
@@ -1,18 +1,11 @@
|
||||
name: Firmware build
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'resource/**'
|
||||
- 'hardware/**'
|
||||
- 'software/**'
|
||||
- '*.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'resource/**'
|
||||
- 'hardware/**'
|
||||
- 'software/**'
|
||||
- '*.md'
|
||||
workflow_call:
|
||||
inputs:
|
||||
checkout-sha:
|
||||
required: false
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
build_fw_builder:
|
||||
@@ -28,6 +21,8 @@ jobs:
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ inputs.checkout-sha == null && github.sha || inputs.checkout-sha }}
|
||||
- name: ghcr.io login
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
@@ -59,6 +54,8 @@ jobs:
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ inputs.checkout-sha == null && github.sha || inputs.checkout-sha }}
|
||||
- name: Build firmware
|
||||
env:
|
||||
repo: ${{ github.repository }}
|
||||
@@ -72,59 +69,22 @@ jobs:
|
||||
- name: Unzip dfu images
|
||||
run: |
|
||||
sudo chown -R $USER:$USER firmware/objects
|
||||
mkdir firmware/objects/dfu-app
|
||||
mkdir firmware/objects/dfu-full
|
||||
unzip firmware/objects/dfu-app.zip -d firmware/objects/dfu-app
|
||||
unzip firmware/objects/dfu-full.zip -d firmware/objects/dfu-full
|
||||
mkdir firmware/objects/${{ matrix.device_type }}-dfu-app
|
||||
mkdir firmware/objects/${{ matrix.device_type }}-dfu-full
|
||||
unzip firmware/objects/${{ matrix.device_type }}-dfu-app.zip -d firmware/objects/${{ matrix.device_type }}-dfu-app
|
||||
unzip firmware/objects/${{ matrix.device_type }}-dfu-full.zip -d firmware/objects/${{ matrix.device_type }}-dfu-full
|
||||
- name: Upload dfu app image
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.device_type }}-dfu-app
|
||||
path: firmware/objects/dfu-app/*
|
||||
path: firmware/objects/${{ matrix.device_type }}-dfu-app/*
|
||||
- name: Upload dfu full image
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.device_type }}-dfu-full
|
||||
path: firmware/objects/dfu-full/*
|
||||
create_release:
|
||||
permissions:
|
||||
contents: write
|
||||
name: Create Pre-Release with dfu app images
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main'
|
||||
needs:
|
||||
- build_fw
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v3
|
||||
- name: Download Ultra DFU
|
||||
uses: actions/download-artifact@v3
|
||||
path: firmware/objects/${{ matrix.device_type }}-dfu-full/*
|
||||
- name: Upload release artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ultra-dfu-app
|
||||
path: ultra-dfu-app
|
||||
- name: Compress Ultra DFU package
|
||||
run: |
|
||||
zip --junk-paths -0 -r ./ultra-dfu-app.zip ./ultra-dfu-app/*
|
||||
- name: Download Lite DFU
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: lite-dfu-app
|
||||
path: lite-dfu-app
|
||||
- name: Compress Lite DFU package
|
||||
run: |
|
||||
zip --junk-paths -0 -r ./lite-dfu-app.zip ./lite-dfu-app/*
|
||||
- name: Upload to dev release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
body: |
|
||||
Auto-Generated DFU packages from latest `main` commit.
|
||||
For development purposes only.
|
||||
These are not tested, here be dragons.
|
||||
Built from commit ${{ github.sha }}
|
||||
tag_name: dev
|
||||
name: Development release
|
||||
draft: false
|
||||
prerelease: true
|
||||
target_commitish: main
|
||||
generate_release_notes: true
|
||||
files: ./*-dfu-app.zip
|
||||
name: release-artifacts
|
||||
path: firmware/objects/*.zip
|
||||
@@ -0,0 +1,44 @@
|
||||
name: PR handler
|
||||
on:
|
||||
pull_request_target:
|
||||
|
||||
jobs:
|
||||
firmware_pipeline:
|
||||
name: Build Firmware
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
uses: ./.github/workflows/build_firmware.yml
|
||||
with:
|
||||
checkout-sha: "${{ github.event.pull_request.merge_commit_sha }}"
|
||||
client_pipeline:
|
||||
name: Build Firmware
|
||||
uses: ./.github/workflows/build_client.yml
|
||||
with:
|
||||
checkout-sha: "${{ github.event.pull_request.merge_commit_sha }}"
|
||||
comment:
|
||||
runs-on: ubuntu-latest
|
||||
name: Comment on PR
|
||||
needs:
|
||||
- firmware_pipeline
|
||||
- client_pipeline
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: marocchino/sticky-pull-request-comment@v2
|
||||
with:
|
||||
message: |
|
||||
# Built artifacts for commit ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
## Firmware
|
||||
|
||||
- [Ultra APP DFU Package](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/ultra-dfu-app.zip)
|
||||
- [Ultra binaries](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/ultra-firmware.zip)
|
||||
- [Lite APP DFU Package](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/lite-dfu-app.zip)
|
||||
- [Lite binaries](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/lite-firmware.zip)
|
||||
|
||||
## Client
|
||||
|
||||
- [Linux](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/client-linux.zip)
|
||||
- [macOS](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/client-macos.zip)
|
||||
- [Windows](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/client-windows.zip)
|
||||
@@ -0,0 +1,51 @@
|
||||
name: Push handler
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
firmware_pipeline:
|
||||
name: Build Firmware
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
uses: ./.github/workflows/build_firmware.yml
|
||||
client_pipeline:
|
||||
name: Build Firmware
|
||||
uses: ./.github/workflows/build_client.yml
|
||||
create_release:
|
||||
permissions:
|
||||
contents: write
|
||||
name: Create dev pre-release with artifacts
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main'
|
||||
needs:
|
||||
- firmware_pipeline
|
||||
- client_pipeline
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v3
|
||||
- name: Download release artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: release-artifacts
|
||||
path: release-artifacts
|
||||
- name: Upload to dev release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
body: |
|
||||
Auto-Generated DFU packages from latest `main` commit.
|
||||
For development purposes only.
|
||||
These are not tested, here be dragons.
|
||||
Built from commit ${{ github.sha }}
|
||||
tag_name: dev
|
||||
name: Development release
|
||||
draft: false
|
||||
prerelease: true
|
||||
target_commitish: ${{ github.sha }}
|
||||
generate_release_notes: true
|
||||
files: release-artifacts/*
|
||||
- name: Fix up release tag
|
||||
run: |
|
||||
git tag -f dev
|
||||
git push --tags -f
|
||||
@@ -4,6 +4,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Changed `hw slot delete`, now it can always delete from slot. (@augustozanellato)
|
||||
- Refactor CI pipeline. (@augustozanellato)
|
||||
- Added offline copy EM card uid for btnpress.(@nemanjan00)
|
||||
- Added offline copy ic card uid for btnpress.(@xianglin1998)
|
||||
- Added `hw settings btnpress` to get and set button press function.(@xianglin1998)
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ ARG NRF_CLT_URL=https://nsscprodmedia.blob.core.windows.net/prod/software-and-ot
|
||||
RUN set -xe; \
|
||||
DEBIAN_FRONTEND=noninteractive; \
|
||||
apt update -q; \
|
||||
apt install -qy --no-install-recommends ca-certificates curl xz-utils make git; \
|
||||
apt install -qy --no-install-recommends ca-certificates curl xz-utils make git zip; \
|
||||
git config --global --add safe.directory /workdir; \
|
||||
curl -sLo /usr/bin/nrfutil https://developer.nordicsemi.com/.pc-tools/nrfutil/x64-linux/nrfutil; \
|
||||
curl -sLo /tmp/nrf-clt.deb $NRF_CLT_URL; \
|
||||
|
||||
@@ -471,44 +471,82 @@ static void cycle_slot(bool dec) {
|
||||
|
||||
#if defined(PROJECT_CHAMELEON_ULTRA)
|
||||
|
||||
static void offline_status_blink_color(uint8_t blink_color) {
|
||||
uint8_t slot = tag_emulation_get_slot();
|
||||
|
||||
uint8_t color = get_color_by_slot(slot);
|
||||
|
||||
uint32_t* p_led_array = hw_get_led_array();
|
||||
|
||||
set_slot_light_color(blink_color);
|
||||
|
||||
for (uint8_t i = 0; i < RGB_LIST_NUM; i++) {
|
||||
if(i == slot) {
|
||||
continue;
|
||||
}
|
||||
nrf_gpio_pin_set(p_led_array[i]);
|
||||
bsp_delay_ms(10);
|
||||
nrf_gpio_pin_clear(p_led_array[i]);
|
||||
bsp_delay_ms(10);
|
||||
}
|
||||
|
||||
set_slot_light_color(color);
|
||||
}
|
||||
|
||||
static void offline_status_error(void) {
|
||||
offline_status_blink_color(0);
|
||||
}
|
||||
|
||||
static void offline_status_ok(void) {
|
||||
offline_status_blink_color(1);
|
||||
}
|
||||
|
||||
// fast detect a 14a tag uid to sim
|
||||
static void btn_fn_copy_ic_uid(void) {
|
||||
// get 14a tag res buffer;
|
||||
uint8_t slot_now = tag_emulation_get_slot();
|
||||
tag_specific_type_t tag_type[2];
|
||||
tag_emulation_get_specific_type_by_slot(slot_now, tag_type);
|
||||
tag_data_buffer_t* buffer = get_buffer_by_tag_type(tag_type[0]);
|
||||
|
||||
nfc_tag_14a_coll_res_entity_t* antres;
|
||||
|
||||
if(tag_type[1] == TAG_TYPE_EM410X) {
|
||||
uint8_t status;
|
||||
|
||||
bool is_reader_mode_now = get_device_mode() == DEVICE_MODE_READER;
|
||||
// first, we need switch to reader mode.
|
||||
if (!is_reader_mode_now) {
|
||||
// enter reader mode
|
||||
reader_mode_enter();
|
||||
bsp_delay_ms(8);
|
||||
NRF_LOG_INFO("Start reader mode to offline copy.")
|
||||
}
|
||||
|
||||
uint8_t id_buffer[5] = { 0x00 };
|
||||
status = PcdScanEM410X(id_buffer);
|
||||
|
||||
if(status == LF_TAG_OK) {
|
||||
tag_data_buffer_t* buffer = get_buffer_by_tag_type(TAG_TYPE_EM410X);
|
||||
memcpy(buffer->buffer, id_buffer, LF_EM410X_TAG_ID_SIZE);
|
||||
tag_emulation_load_by_buffer(TAG_TYPE_EM410X, false);
|
||||
|
||||
// keep reader mode or exit reader mode.
|
||||
}
|
||||
|
||||
if (!is_reader_mode_now) {
|
||||
tag_mode_enter();
|
||||
}
|
||||
bool is_reader_mode_now = get_device_mode() == DEVICE_MODE_READER;
|
||||
// first, we need switch to reader mode.
|
||||
if (!is_reader_mode_now) {
|
||||
// enter reader mode
|
||||
reader_mode_enter();
|
||||
bsp_delay_ms(8);
|
||||
NRF_LOG_INFO("Start reader mode to offline copy.")
|
||||
}
|
||||
|
||||
switch(tag_type[1]) {
|
||||
case TAG_TYPE_EM410X:
|
||||
uint8_t status;
|
||||
uint8_t id_buffer[5] = { 0x00 };
|
||||
status = PcdScanEM410X(id_buffer);
|
||||
|
||||
if(status == LF_TAG_OK) {
|
||||
tag_data_buffer_t* buffer = get_buffer_by_tag_type(TAG_TYPE_EM410X);
|
||||
memcpy(buffer->buffer, id_buffer, LF_EM410X_TAG_ID_SIZE);
|
||||
tag_emulation_load_by_buffer(TAG_TYPE_EM410X, false);
|
||||
NRF_LOG_INFO("Offline LF uid copied")
|
||||
offline_status_ok();
|
||||
// no need to check for HF tag if we already cloned a LF tag
|
||||
goto exit;
|
||||
} else {
|
||||
NRF_LOG_INFO("No LF tag found");
|
||||
offline_status_error();
|
||||
}
|
||||
break;
|
||||
case TAG_TYPE_UNKNOWN:
|
||||
// empty LF slot, nothing to do, move on to HF
|
||||
break;
|
||||
default:
|
||||
NRF_LOG_ERROR("Unsupported LF tag type")
|
||||
offline_status_error();
|
||||
}
|
||||
|
||||
tag_data_buffer_t* buffer = get_buffer_by_tag_type(tag_type[0]);
|
||||
switch(tag_type[0]) {
|
||||
case TAG_TYPE_MIFARE_Mini:
|
||||
case TAG_TYPE_MIFARE_1024:
|
||||
@@ -527,23 +565,22 @@ static void btn_fn_copy_ic_uid(void) {
|
||||
break;
|
||||
}
|
||||
|
||||
case TAG_TYPE_UNKNOWN:
|
||||
// empty HF slot, nothing to do
|
||||
goto exit;
|
||||
|
||||
default:
|
||||
NRF_LOG_ERROR("Unsupported tag type")
|
||||
return;
|
||||
NRF_LOG_ERROR("Unsupported HF tag type")
|
||||
offline_status_error();
|
||||
goto exit;
|
||||
}
|
||||
|
||||
bool is_reader_mode_now = get_device_mode() == DEVICE_MODE_READER;
|
||||
// first, we need switch to reader mode.
|
||||
if (!is_reader_mode_now) {
|
||||
// enter reader mode
|
||||
reader_mode_enter();
|
||||
bsp_delay_ms(8);
|
||||
// finish HF reader initialization
|
||||
pcd_14a_reader_reset();
|
||||
pcd_14a_reader_antenna_on();
|
||||
bsp_delay_ms(8);
|
||||
NRF_LOG_INFO("Start reader mode to offline copy.")
|
||||
}
|
||||
|
||||
// select a tag
|
||||
picc_14a_tag_t tag;
|
||||
uint8_t status;
|
||||
@@ -556,11 +593,13 @@ static void btn_fn_copy_ic_uid(void) {
|
||||
memcpy(antres->atqa, tag.atqa, 2);
|
||||
// copy sak
|
||||
antres->sak[0] = tag.sak;
|
||||
NRF_LOG_INFO("Offline uid copied")
|
||||
NRF_LOG_INFO("Offline HF uid copied")
|
||||
offline_status_ok();
|
||||
} else {
|
||||
NRF_LOG_INFO("No tag found: %d", status);
|
||||
NRF_LOG_INFO("No HF tag found");
|
||||
offline_status_error();
|
||||
}
|
||||
|
||||
exit:
|
||||
// keep reader mode or exit reader mode.
|
||||
if (!is_reader_mode_now) {
|
||||
tag_mode_enter();
|
||||
|
||||
@@ -54,6 +54,9 @@ void tag_mode_enter(void) {
|
||||
|
||||
nrf_gpio_cfg_output(HF_ANT_SEL);
|
||||
nrf_gpio_pin_set(HF_ANT_SEL); // hf ant switch to emulation mode
|
||||
// give time for fields to shutdown, else we get spurious LF detection triggered in LF emul
|
||||
// need at least about 30ms on dev kit
|
||||
bsp_delay_ms(60);
|
||||
#endif
|
||||
|
||||
// to run tag emulation
|
||||
|
||||
+18
-7
@@ -33,31 +33,42 @@ set -xe
|
||||
|
||||
(
|
||||
cd objects
|
||||
|
||||
cp ../nrf52_sdk/components/softdevice/${softdevice}/hex/${softdevice}_nrf52_${softdevice_version}_softdevice.hex softdevice.hex
|
||||
|
||||
nrfutil nrf5sdk-tools pkg generate \
|
||||
--hw-version $hw_version \
|
||||
--bootloader bootloader.hex --bootloader-version $bootloader_version --key-file ../../resource/dfu_key/chameleon.pem \
|
||||
--application application.hex --application-version $application_version --app-boot-validation NO_VALIDATION \
|
||||
--softdevice ../nrf52_sdk/components/softdevice/${softdevice}/hex/${softdevice}_nrf52_${softdevice_version}_softdevice.hex --sd-req ${softdevice_id} --sd-id ${softdevice_id} --sd-boot-validation NO_VALIDATION \
|
||||
dfu-full.zip
|
||||
--application application.hex --application-version $application_version\
|
||||
--softdevice softdevice.hex \
|
||||
--sd-req ${softdevice_id} --sd-id ${softdevice_id} \
|
||||
${device_type}-dfu-full.zip
|
||||
|
||||
nrfutil nrf5sdk-tools pkg generate \
|
||||
--hw-version $hw_version --key-file ../../resource/dfu_key/chameleon.pem \
|
||||
--application application.hex --application-version $application_version --app-boot-validation NO_VALIDATION \
|
||||
--application application.hex --application-version $application_version \
|
||||
--sd-req ${softdevice_id} \
|
||||
dfu-app.zip
|
||||
${device_type}-dfu-app.zip
|
||||
|
||||
nrfutil nrf5sdk-tools settings generate \
|
||||
--family NRF52840 \
|
||||
--application application.hex --application-version $application_version \
|
||||
--softdevice softdevice.hex \
|
||||
--bootloader-version $bootloader_version --bl-settings-version 2 \
|
||||
settings.hex
|
||||
mergehex \
|
||||
--merge \
|
||||
settings.hex \
|
||||
application.hex \
|
||||
--output application.hex
|
||||
rm settings.hex
|
||||
|
||||
mergehex \
|
||||
--merge \
|
||||
bootloader.hex \
|
||||
settings.hex \
|
||||
application.hex \
|
||||
../nrf52_sdk/components/softdevice/${softdevice}/hex/${softdevice}_nrf52_${softdevice_version}_softdevice.hex \
|
||||
softdevice.hex \
|
||||
--output fullimage.hex
|
||||
|
||||
zip ${device_type}-binaries.zip *.hex
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user