Commit Graph
100 Commits
Author SHA1 Message Date
Philippe Teuwen 4747d3884d Merge branch 'wip_protocol_refresh'
* wip_protocol_refresh: (38 commits)
  CI for releases
  changelog
  build_firmware.yml: fetch depth=0 to be able to build proper version strings
  Deduce APP_FW_VER from git tag
  bump app version
  style
  colors
  Increase initial button wakeup from 4 to 8 seconds
  Adding MIFARE Ultralight reading, wip
  hf14a_raw: use @expect_response and fix tests
  Fix shadow mode not being preserved. Breaking change: nfc_tag_mf1_write_mode_t has one new mode SHADOW_REQ. Client can set SHADOW or SHADOW_REQ, internally it will be transformed to SHADOW_REQ. When it's time to save data, if SHADOW_REQ, the fw will change it to SHADOW and still allow to save the data before acting as shadow. Breaking: when client reads back MF1 write mode just after settings SHADOW and before saving config, it will receive SHADOW_REQ and must be ready to handle this new enum value.
  MF1_DETECT_SUPPORT: remove redundant data
  Breaking change: DATA_CMD_GET_DEVICE_MODEL to match chameleon_device_type_t
  hw 14a raw: closer to pm3 syntax, removed bit_frame,...
  use field LED also in reader mode
  fix changelog
  new tag_specific_type_t enum, new slotConfig struct. FW will take care of existing slots. Disruptive changes: see below
  Implemented hf 14a raw
  Fixed initialization bugs and added raw command implementation functions.
  Update the table of MFC attack support levels.
  ...
2023-09-26 09:51:25 +02:00
Philippe Teuwen 099fb6b912 CI for releases 2023-09-26 09:51:15 +02:00
Philippe Teuwen b9e5c95480 changelog 2023-09-26 08:42:31 +02:00
Philippe Teuwen b03ef3ec21 build_firmware.yml: fetch depth=0 to be able to build proper version strings 2023-09-26 00:47:58 +02:00
Philippe Teuwen 963d4d62f1 Deduce APP_FW_VER from git tag 2023-09-25 23:32:01 +02:00
Philippe Teuwen 2b4e8b2940 bump app version 2023-09-25 17:30:54 +02:00
Philippe Teuwen 372cfead0c style 2023-09-25 00:51:43 +02:00
Philippe Teuwen e23ad695e6 colors 2023-09-24 23:49:49 +02:00
Philippe Teuwen 7903993504 Adding MIFARE Ultralight reading, wip 2023-09-24 22:30:57 +02:00
Philippe Teuwen 313d772a99 hf14a_raw: use @expect_response and fix tests 2023-09-24 22:30:50 +02:00
Philippe Teuwen 1dc8891e1b Fix shadow mode not being preserved. Breaking change:
nfc_tag_mf1_write_mode_t has one new mode SHADOW_REQ.
Client can set SHADOW or SHADOW_REQ, internally it will be transformed to SHADOW_REQ.
When it's time to save data, if SHADOW_REQ, the fw will change it to SHADOW and still allow to save the data before acting as shadow.
Breaking: when client reads back MF1 write mode just after settings SHADOW and before saving config, it will receive SHADOW_REQ and must be ready to handle this new enum value.
2023-09-24 19:01:20 +02:00
Philippe Teuwen 941d42561a MF1_DETECT_SUPPORT: remove redundant data
cf https://github.com/RfidResearchGroup/ChameleonUltra/pull/147#issuecomment-1732338315
2023-09-24 01:49:26 +02:00
Philippe Teuwen 867ee7bf9b Breaking change: DATA_CMD_GET_DEVICE_MODEL to match chameleon_device_type_t
cf https://github.com/RfidResearchGroup/ChameleonUltra/pull/147#pullrequestreview-1637478473
2023-09-24 01:27:48 +02:00
Philippe Teuwen f7db6d0fb3 hw 14a raw: closer to pm3 syntax, removed bit_frame,...
Now data length is always in bits
Option -o => -a and only needed to turn field on without select or data
Reorganize pcd_14a_reader_raw_cmd
Some more checks
2023-09-24 01:02:30 +02:00
Philippe Teuwen 234b22c48a use field LED also in reader mode 2023-09-24 00:32:48 +02:00
Philippe Teuwen 25f7a91941 fix changelog 2023-09-23 21:38:17 +02:00
Philippe Teuwen 7da58bbce8 new tag_specific_type_t enum, new slotConfig struct. FW will take care of existing slots. Disruptive changes: see below
Disruptive changes:
- tag types are 2-byte long with new values
- GET_SLOT_INFO returns 32 bytes as tag types are now 2-byte long
- "enable" is not common to one slot anymore but bound to the HF or LF part
- GET_ENABLED_SLOTS returns 16 bytes as we get "enabled_hf" and "enabled_lf" for each slot
- SET_SLOT_ENABLE needs 3 bytes slot_number|sense_type|enable as we need to specify to enable HF or LF
- slotConfig changed a lot but this is internal to the fw and its flash and a function does the format conversion on first boot after flash
  so slot data is preserved on fw upgrade, but if one downgrades to a previous version, data will be erased.
2023-09-23 21:34:15 +02:00
Philippe Teuwen 14bffafb2a style 2023-09-20 01:26:47 +02:00
Philippe Teuwen cd73ac89ee staticnested.c: translate comments, fix typo 2023-09-19 22:09:15 +02:00
Philippe Teuwen ebb77dc938 recode GB18030..UTF-8 staticnested.c 2023-09-19 22:02:49 +02:00
Philippe Teuwen 3889033815 sigh 2023-09-19 21:47:37 +02:00
Philippe Teuwen 52953de927 changelog & typos in protocol 2023-09-19 21:37:56 +02:00
Philippe Teuwen 5a9d49ddb4 Remove unused MF1_DETECT_DARKSIDE, reallocate 2003 to MF1_STATIC_NESTED_ACQUIRE
MF1_DETECT_DARKSIDE was actually runnign the full attack, as there is no quick way to detect Darkside
So if you want to check for Darkside, just run directly MF1_DARKSIDE_ACQUIRE.
2023-09-19 16:03:20 +02:00
Philippe Teuwen 624e96aee9 fix compilation 2023-09-19 13:18:02 +02:00
Philippe Teuwen 42d9f160d9 typo 2023-09-19 10:15:42 +02:00
Philippe Teuwen ff20eb9c68 simplify anticol+ATS, my fault 2023-09-19 01:35:51 +02:00
Philippe Teuwen 6ce61c1720 changelog 2023-09-19 00:38:09 +02:00
Philippe Teuwen 9497ff7eab Add timeout parameter to hw raw 2023-09-18 23:20:18 +02:00
Philippe Teuwen c9261cc6eb Darkside: use LEDs for feedback 2023-09-18 22:44:15 +02:00
Philippe Teuwen 782905f202 fix Darkside 2023-09-18 22:44:15 +02:00
Philippe Teuwen 8499535aad Clarify protocol. Disruptive changes: see below
This huge commit tries to enhance several things related to the fw/cli protocol.
Generally, the idea is to be verbose, explicit and reuse conventions, in order to enhance code maintainability and understandability for the other contributors.

docs/protocol.md got heavily updated

Many commands have been renamed for consistency. you are invited to adapt your client for easier maintenance

Guidelines, also written in docs/protocol.md "New data payloads: guidelines for developers":
- Now protocol data exchanged over USB or BLE are defined in netdata.h as packed structs and values are stored in Network byte order (=Big Endian)
- Command-specific payloads are defined in their respective cmd_processor handler in app_cmd.c and chameleon_cmd.py
- Define C `struct` for cmd/resp data greater than a single byte, use and abuse of `struct.pack`/`struct.unpack` in Python. So one can understand the payload format at a simple glimpse.
- If single byte of data to return, still use a 1-byte `data`, not `status`.
- Use unambiguous types such as `uint16_t`, not `int` or `enum`. Cast explicitly `int` and `enum` to `uint_t` of proper size
- Use Network byte order for 16b and 32b integers
  - Macros `U16NTOHS`, `U32NTOHL` must be used on reception of a command payload.
  - Macros `U16HTONS`, `U32HTONL` must be used on creation of a response payload.
  - In Python, use the modifier `!` with all `struct.pack`/`struct.unpack`
- Concentrate payload parsing in the handlers, avoid further parsing in their callers. This is true for the firmware and the client.
- In cmd_processor handlers: don't reuse input `length`/`data` parameters for creating the response content
- Avoid hardcoding offsets, use `sizeof()`, `offsetof(struct, field)` in C and `struct.calcsize()` in Python
- Use the exact same command and fields names in firmware and in client, use function names matching the command names for their handlers unless there is a very good reason not to do so. This helps grepping around. Names must start with a letter, not a number, because some languages require it (e.g. `14a_scan` not possible in Python)
- Respect commands order in `m_data_cmd_map`, `data_cmd.h` and `chameleon_cmd.py` definitions
- Even if a command is not yet implemented in firmware or in client but a command number is allocated, add it to `data_cmd.h` and `chameleon_cmd.py` with some `FIXME: to be implemented` comment
- Validate data before using it, both when receiving command data in the firmware and when receiving response data in the client.
- Validate response status in client.

Disruptive changes:
- GET_DEVICE_CAPABILITIES: list of cmds in data are now really Big Endian
  Note: the initial attempt to use macros PP_HTONS were actually considering wrongly that the platform was Big Endian (BYTE_ORDER was actually undefined) while it is actually Little Endian.
- GET_APP_VERSION: response is now a tuple of bytes: major|minor (previously it was in reversed order as a single uint16_t in Little Endian)
- SET_SLOT_TAG_TYPE: tag_type now on 2 bytes, to prepare remapping of its enum
- SET_SLOT_DATA_DEFAULT: tag_type now on 2 bytes, to prepare remapping of its enum
- GET_SLOT_INFO: tag_type now on 2 bytes, to prepare remapping of its enum
- GET_DEVICE_CHIP_ID: now returns its 64b ID following Network byte order (previously, bytes were in the reverse order)
- GET_DEVICE_ADDRESS: now returns its 56b address following Network byte order (previously, bytes were in the reverse order). CLI does not reverse the response anymore so it displays the same value as before.
- MF1_GET_DETECTION_COUNT: now returns its 32b value following Network byte order (previously Little Endian)
- GET_GIT_VERSION response status is now STATUS_DEVICE_SUCCESS
- GET_DEVICE_MODEL response status is now STATUS_DEVICE_SUCCESS
- MF1_READ_EMU_BLOCK_DATA response status is now STATUS_DEVICE_SUCCESS
- GET_DEVICE_CAPABILITIES response status is now STATUS_DEVICE_SUCCESS
- HF14A_SCAN: entirely new response format, room for ATS and multiple tags
- MF1_DETECT_SUPPORT response status is now HF_TAG_OK and support is indicated as bool in 1 byte of data
- MF1_DETECT_PRNG response status is now HF_TAG_OK and prng_type is returned in 1 byte of data with a new enum mf1_prng_type_t == MifareClassicPrngType
- MF1_DETECT_DARKSIDE response status is now HF_TAG_OK and darkside_status is returned in 1 byte of data with a new enum mf1_darkside_status_t == MifareClassicDarksideStatus
- MF1_DARKSIDE_ACQUIRE response status is now HF_TAG_OK and darkside_status is returned in 1 byte of data. If OK, followed by 24 bytes as previously
- MF1_GET_ANTI_COLL_DATA: in case slot does not contain anticoll data, instead of STATUS_PAR_ERR, now it returns STATUS_DEVICE_SUCCESS with empty data
- MF1_SET_ANTI_COLL_DATA and MF1_GET_ANTI_COLL_DATA now use the same data format as HF14A_SCAN

For clients to detect Ultra/Lite with older firmwares, one can issue the GET_APP_VERSION and urge the user to flash his device if needed.
On older firmwares, it will return a status=b'\x00' and data=b'\x00\x01' while up-to-date firmwares will return status=STATUS_DEVICE_SUCCESS and data greater or equal to b'\x01\x00' (v1.0).

Other changes: cf CHANGELOG, and probably a few small changes I forgot about..

TODO:
- remap `tag_specific_type_t` enum to allow future tags (e.g. LF tags) without reshuffling enum and affecting users stored cards
- TEST!
2023-09-18 00:53:39 +02:00
Philippe Teuwen 4c43bca906 Merge pull request #150 from taichunmin/taichunmin
Docs: Add sdk.md
2023-09-13 01:51:02 +02:00
Philippe Teuwen 92599df531 Merge pull request #149 from aramova/patch-1
Update nomenclature technical_whitepaper.md
2023-09-13 01:18:36 +02:00
Philippe Teuwen a43f4b96fc Fix get_slot_tag_nick_name in fw: data was deallocated before being sent 2023-09-11 10:02:23 +02:00
Philippe Teuwen 00a0019ef3 protocol note on LRC computations 2023-09-10 12:47:26 +02:00
Philippe Teuwen 930d9f588b Merge pull request #140 from aenigma-es/main
Solved bug that makes hf mf eread command crashes
2023-09-09 23:59:23 +02:00
Philippe Teuwen 0dc83b4f5b troubleshooting 2023-09-08 09:57:22 +02:00
Philippe Teuwen edadfab729 test to rollback to 1st DXL patch... 2023-09-08 09:11:30 +02:00
Philippe Teuwen a793810f59 Merge pull request #132 from Foxushka/simplify-code
block_count can't be more than 0xFF, simplify code
2023-09-08 09:05:55 +02:00
Philippe Teuwen 6a5afb752d Merge pull request #131 from Foxushka/bump-settings
Update cmd_processor_get_settings
2023-09-07 20:04:44 +02:00
Philippe Teuwen e888115d3f build.sh: assoiative arrays are available only since Bash 4 and MacOS is still on some Bash 3... 2023-09-07 19:58:34 +02:00
Philippe Teuwen 922c025bf3 Fix issue #114 2023-09-07 10:47:13 +02:00
Philippe Teuwen 9b1fc863c3 style 2023-09-07 08:46:38 +02:00
Philippe Teuwen bc874f68ef doc 2023-09-07 08:44:03 +02:00
Philippe Teuwen 1bb6840fba Merge pull request #104 from Foxushka/software-capabilities
Get device capabilities
2023-09-07 08:42:19 +02:00
Philippe Teuwen e3d51a4d64 Merge pull request #129 from mitmarcus/patch-7
Update README.md
2023-09-07 00:27:21 +02:00
Philippe Teuwen 47aed37751 Merge pull request #126 from mitmarcus/patch-6
Update README.md
2023-09-05 13:27:06 +02:00
Philippe Teuwen 62946387a8 Merge pull request #125 from mitmarcus/patch-5
Update README.md
2023-09-05 10:56:03 +02:00
Philippe Teuwen e0556857f2 Merge pull request #124 from mitmarcus/patch-4
Update modding.md
2023-09-05 10:35:59 +02:00
Philippe Teuwen cef9efc5f5 Merge pull request #123 from mitmarcus/patch-3
Update troubleshooting.md
2023-09-05 10:34:22 +02:00
Philippe Teuwen 5a9ca62d2a doc 2023-09-04 23:16:19 +02:00
Philippe Teuwen d928ab2285 docs 2023-09-03 15:41:26 +02:00
Philippe Teuwen 76168621b4 style 2023-09-02 22:24:15 +02:00
Philippe Teuwen d50e1437b7 changelog 2023-09-02 22:22:52 +02:00
Philippe Teuwen 7506e64bc8 Mods 2023-09-01 20:17:36 +02:00
Philippe Teuwen f54879b364 Merge pull request #120 from mitmarcus/patch-2
Update chameleonultragui.md
2023-09-01 12:27:55 +02:00
Philippe Teuwen 150666899b Merge pull request #119 from mitmarcus/patch-1
Update firmware.md
2023-09-01 12:24:25 +02:00
Philippe Teuwen 578255a0bf Merge pull request #118 from Foxushka/patch-2
Fix Chameleon crashes in BLE pairing
2023-08-31 01:07:28 +02:00
Philippe Teuwen 5f530ad551 Merge pull request #117 from taichunmin/taichunmin
Docs: protocol.md
2023-08-30 20:20:35 +02:00
Philippe Teuwen 98813ca67e Merge pull request #116 from Foxushka/patch-1
Fix links and correct OS namings
2023-08-30 16:08:03 +02:00
Philippe Teuwen 209867a76c Merge pull request #115 from drego85/patch-1
Added software for macOS
2023-08-30 15:35:46 +02:00
Philippe Teuwen a41322efae Merge pull request #109 from digitalcardboard/patch-1
Update cli.md
2023-08-30 10:18:50 +02:00
Philippe Teuwen c70165fafa bugreport templates 2023-08-30 00:05:50 +02:00
Philippe Teuwen f80e7fe14e doc ble 2023-08-29 13:09:24 +02:00
Philippe Teuwen 58e310c0c7 autopep8: increase line size to 120, else satest style will be reverted again 2023-08-28 09:49:00 +02:00
Philippe Teuwen 4272d7661a Fix GET_DEVICE crash 2023-08-28 09:48:05 +02:00
Philippe Teuwen 845cae95ab Limit max battery info to 100% 2023-08-28 01:07:29 +02:00
Philippe Teuwen 7acc7e93dd #error 2023-08-28 01:07:29 +02:00
Philippe Teuwen bd3961077c CLI now takes into account Lite refusing to enter reader mode 2023-08-28 01:07:27 +02:00
Philippe Teuwen c0876aa11b noconfirm 2023-08-27 13:56:23 +02:00
Philippe Teuwen c56a7cc8bf troubleshooting 2023-08-27 13:53:03 +02:00
Philippe Teuwen 54178eaa89 Merge pull request #101 from szymex73/fix-multicommand
Fix a bug in multiline command implementation
2023-08-26 20:50:23 +02:00
Philippe Teuwen 52d7e7b0e0 Merge pull request #100 from szymex73/fix-argcomplete
Fix argument autocompleter bug (#97)
2023-08-26 20:47:38 +02:00
Philippe Teuwen daa32d0840 Merge pull request #99 from taichunmin/device-address
Fix device address is not the same with APP
2023-08-26 16:19:45 +02:00
Philippe Teuwen f2792c86d9 Merge pull request #98 from uhei/doc-mtools
docs: add links for MTools
2023-08-26 15:54:05 +02:00
Philippe Teuwen 94164093b0 cli doc fix by @GameTec-live 2023-08-26 12:29:05 +02:00
Philippe Teuwen 04741bdc2a autopep8 2023-08-26 12:06:15 +02:00
Philippe Teuwen f008e8bebc Add autopep8 to make_style script 2023-08-26 12:05:18 +02:00
Philippe Teuwen 86fcaa3d56 typos & style 2023-08-26 04:42:40 +02:00
Philippe Teuwen d5d955d2e9 pylance 2023-08-26 02:55:46 +02:00
Philippe Teuwen a596e98bf7 python style 2023-08-26 02:24:08 +02:00
Philippe Teuwen 65368dffff deadbeef 2023-08-26 01:52:40 +02:00
Philippe Teuwen d08c8c4605 Close properly after factory reset, fix typo 2023-08-26 01:48:30 +02:00
Philippe Teuwen 1a1cb5b10e Merge pull request #95 from gentilkiwi/patch-1
Fix multiple Chameleon connected on WSL1
2023-08-26 00:34:58 +02:00
Philippe Teuwen 5c36004e9c doc 2023-08-26 00:16:43 +02:00
Philippe Teuwen 590a45eddc style 2023-08-25 23:55:12 +02:00
Philippe Teuwen c8a2b52982 Merge pull request #94 from gentilkiwi/patch-1
Fix compilation problem error: a label can only be part of a stateme…
2023-08-25 23:53:51 +02:00
Philippe Teuwen 86067576d8 doc 2023-08-25 23:51:51 +02:00
Philippe Teuwen 249cadc736 reorg doc 2023-08-25 23:41:25 +02:00
Philippe Teuwen 6d096df88b readme 2023-08-25 22:55:05 +02:00
Philippe Teuwen 033369e7c0 Merge pull request #89 from GameTec-live/users-guide
Adding a (not so) basic users guide
2023-08-25 22:41:23 +02:00
Philippe Teuwen 591b03e1b3 emojis 2023-08-25 22:37:44 +02:00
Philippe Teuwen c6030c8fdf Remove command ID, there is no 1-1 mapping between cli commands and fw commands and it's more a concern for devs than uers 2023-08-25 22:25:57 +02:00
Philippe Teuwen b4b48fe793 Merge branch 'main' into users-guide 2023-08-25 22:22:13 +02:00
Philippe Teuwen 1a4fcdda01 doc 2023-08-25 22:16:07 +02:00
Philippe Teuwen 05f25e830c More Chinese (auto) translation 2023-08-25 19:51:27 +02:00
Philippe Teuwen 2ba2ca92fd More Chinese (auto) translation 2023-08-25 19:40:46 +02:00
Philippe Teuwen 7ff6a0b3a2 Allow pasting multiple commands at once, as it was with readline 2023-08-25 17:57:12 +02:00
Philippe Teuwen c24e69b44c Allow to interrupt sleep sequence during final animation with a simple button press.
Because otherwise one must wait for sleep animation to finish, then press button then wait for boot animation to finish...

Also, fix saved config CRC after config has been saved
2023-08-25 13:41:23 +02:00
Philippe Teuwen ef46b22d69 Fixed logs corruption and app reset on FDS write, added logs flush on sleep
Bug when NRF_LOG_DEFERRED=0
due to a userland NRF_LOG_INFO after FDS record update was initiated, interrupted by FDS record IRQ handler and its own NRF_LOG_INFO
resulting in
<error> app: Fatal error
<warning> app: System reset

Added a few more NRF_LOG in FDS module as well.
Added NRF_LOG_FLUSH in system_off_enter to not miss last messages.
2023-08-25 13:18:06 +02:00