diff --git a/CHANGELOG.md b/CHANGELOG.md index 11afeb013..4153d5358 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Changed PM5 FPGA image - `client/resources/fpga_pm5.bin` is now built from the repo sources (`make -C fpga fpga_pm5_release`) and replaces the vendor built `PM5_FPGA_fix_loedge_bug.bin` (@iceman1001) - Changed `hf mf info`, `hf mfu info`, `hf mfdes info`, `hf felica info`, `hf 14b info`, `hf calypso info` and `hf 14a info` - identify transit cards by keys, AIDs, system codes or data, show card number / balance where free to read and hint at the full decode (@iceman1001) - Fixed PM5 `hf mf sim` and other 14a sims - the RSSI ADC was reset and recalibrated before every listen, missing fast reader frames such as the auth nR/aR (@iceman1001) - Added `hf mf sam` and `hf mfdes sam` - read PACS from MIFARE Classic SE and DESFire EV1/EV2 through a HID SAM, as Seader does (@iceman1001) diff --git a/client/cmdscripts/update_fpga.cmd b/client/cmdscripts/update_fpga.cmd index 81b3f8b30..fd177b5cf 100755 --- a/client/cmdscripts/update_fpga.cmd +++ b/client/cmdscripts/update_fpga.cmd @@ -1,4 +1,4 @@ #!/usr/bin/env -S pm3 -s -hw fpga config -f PM5_FPGA_fix_loedge_bug.bin +hw fpga config -f fpga_pm5.bin hf 14a read --drop diff --git a/client/cmdscripts/update_fpga_and_bwm.cmd b/client/cmdscripts/update_fpga_and_bwm.cmd index 2c09b8f83..8705e55ce 100755 --- a/client/cmdscripts/update_fpga_and_bwm.cmd +++ b/client/cmdscripts/update_fpga_and_bwm.cmd @@ -1,5 +1,5 @@ #!/usr/bin/env -S pm3 -s -hw fpga config -f PM5_FPGA_fix_loedge_bug.bin +hw fpga config -f fpga_pm5.bin hf 14a read --drop hw bwm setcap --cap 500 diff --git a/client/resources/PM5_FPGA_fix_loedge_bug.bin b/client/resources/PM5_FPGA_fix_loedge_bug.bin deleted file mode 100644 index 66fd907e5..000000000 Binary files a/client/resources/PM5_FPGA_fix_loedge_bug.bin and /dev/null differ diff --git a/client/resources/PM5_FPGA_fix_loedge_bug.sha512.txt b/client/resources/PM5_FPGA_fix_loedge_bug.sha512.txt deleted file mode 100644 index b4faa5ce4..000000000 --- a/client/resources/PM5_FPGA_fix_loedge_bug.sha512.txt +++ /dev/null @@ -1 +0,0 @@ -b3536cfe80eac23aca5e75c393406faf083a74980d5bdd14264f7ca0b4ca45976038ce3a1aea212f014364c8a4647608c13b89e597118c95fd87e7eb06fa627b PM5_FPGA_fix_loedge_bug.bin diff --git a/client/resources/fpga_pm5.bin b/client/resources/fpga_pm5.bin new file mode 100644 index 000000000..a19f4a6ff Binary files /dev/null and b/client/resources/fpga_pm5.bin differ diff --git a/client/resources/fpga_pm5.sha512.txt b/client/resources/fpga_pm5.sha512.txt new file mode 100644 index 000000000..93ed793f1 --- /dev/null +++ b/client/resources/fpga_pm5.sha512.txt @@ -0,0 +1 @@ +e335489c8ee9e348c93f6141f6c063857acd12dbc5265d39839351dbe9bd2f737d704100f84355dd895ad4a7bae1b38a0c4c7a45a69e11e98c34a20bffc00160 fpga_pm5.bin diff --git a/doc/md/PM5_Start_Here/Getting_Started_With_PM5.md b/doc/md/PM5_Start_Here/Getting_Started_With_PM5.md index 5cc76e8cd..fdc9d6e5d 100644 --- a/doc/md/PM5_Start_Here/Getting_Started_With_PM5.md +++ b/doc/md/PM5_Start_Here/Getting_Started_With_PM5.md @@ -87,6 +87,18 @@ For more options, look [here](#Build-Extras) script run update_fpga ``` +This writes `client/resources/fpga_pm5.bin` to the FPGA flash. + +### Build the FPGA image from source +The PM5 bitstream is built with the open source toolchain (yosys, nextpnr-himbaechel, apicula) from [oss-cad-suite](https://github.com/YosysHQ/oss-cad-suite-build/releases). Use the release pinned in `.github/workflows/fpga-pm5.yml`: older yosys builds give images with a weaker antenna drive. Unpack it next to the repository (`../oss-cad-suite`) or point `OSS_CAD_SUITE` at it. + +``` +make -C fpga pm5 # builds fpga/fpga_pm5.bin +make -C fpga fpga_pm5_release # also copies it to client/resources +``` + +The build is reproducible: the same sources and toolchain give the same bytes as the CI artifact. To try an image without touching the FPGA flash, load it into SRAM with `hw fpga config -s -f fpga/fpga_pm5.bin`. A power cycle returns to the image in flash. + ## I Have A BWM Now What ### Install the BWM diff --git a/fpga/Makefile b/fpga/Makefile index f34fe80f2..18e98c338 100644 --- a/fpga/Makefile +++ b/fpga/Makefile @@ -9,6 +9,7 @@ # make - every PM3 image # make pm3 - same # make pm5 - the PM5 bitstream +# make fpga_pm5_release - the PM5 bitstream, copied to client/resources # make - routed by name, e.g. fpga_pm3_hf, fpga_pm3_ult_lf, fpga_pm5 # make clean - both platforms # make help - both target lists @@ -59,6 +60,7 @@ help: @echo "#" @echo "# make - every PM3 image (Xilinx ISE)" @echo "# make pm5 - the PM5 bitstream (yosys/nextpnr-himbaechel)" + @echo "# make fpga_pm5_release - same, copied to client/resources" @echo "# make - routed by name, e.g. fpga_pm3_hf, fpga_pm5" @echo "# make clean - both platforms" @echo "################################################################" diff --git a/fpga/proxmark5_fpga.mk b/fpga/proxmark5_fpga.mk index 853a3b265..bf369f64f 100644 --- a/fpga/proxmark5_fpga.mk +++ b/fpga/proxmark5_fpga.mk @@ -69,7 +69,7 @@ endif PM5_BUILD_HDL = $(addprefix ../,$(PM5_HDL)) PM5_DEFS = $(foreach d,$(PM5_DEFINES),-D $(d)) -.PHONY: all clean help check-tools smoke $(PM5_NAME) +.PHONY: all clean help check-tools smoke $(PM5_NAME) $(PM5_NAME)_release all: $(PM5_NAME) @@ -84,6 +84,16 @@ $(PM5_NAME).fs: $(PM5_OUT)/$(PM5_NAME).fs $(PM5_NAME).bin: $(PM5_OUT)/$(PM5_NAME).bin $(Q)$(CP) $< . +# Ship the bitstream to the client resources, where `hw fpga config` and the +# update_fpga scripts find it. Kept apart from `all` so a local test build does +# not replace the released image by accident. +PM5_RELEASE_DIR = ../client/resources + +$(PM5_NAME)_release: $(PM5_NAME).bin + $(info [=] RELEASE $(PM5_RELEASE_DIR)/$(PM5_NAME).bin) + $(Q)cp $(PM5_NAME).bin $(PM5_RELEASE_DIR)/$(PM5_NAME).bin + $(Q)cd $(PM5_RELEASE_DIR) && $(OC_ENV) $(OC_PYTHON) -c "import hashlib; n = '$(PM5_NAME).bin'; print(hashlib.sha512(open(n, 'rb').read()).hexdigest() + ' ' + n)" > $(PM5_NAME).sha512.txt + # The pin constraints are board specific and are not part of the repository. $(PM5_CST): $(error [!] missing $@ -- fill in the PM5 pin constraints, then rerun) @@ -162,6 +172,7 @@ help: @echo "#" @echo "# $(PM5_NAME) - Builds the PM5 bitstream into $(PM5_NAME).fs/.bin" @echo "# all - same as $(PM5_NAME)" + @echo "# $(PM5_NAME)_release - Also copies the bitstream to $(PM5_RELEASE_DIR)" @echo "# clean - Keeps the bitstream but cleans intermediate build files" @echo "#" @echo "# Device: $(PM5_PART) (family $(PM5_FAMILY))"