From 80a14a13921c9059af6539b2a91823a83adcd1c1 Mon Sep 17 00:00:00 2001 From: turbocool3r Date: Wed, 19 Jun 2024 21:55:13 +0300 Subject: [PATCH] Fix factory initialization for MF0/NTAG. --- .../src/rfid/nfctag/hf/nfc_mf0_ntag.c | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/firmware/application/src/rfid/nfctag/hf/nfc_mf0_ntag.c b/firmware/application/src/rfid/nfctag/hf/nfc_mf0_ntag.c index ad069784..55c19b8c 100644 --- a/firmware/application/src/rfid/nfctag/hf/nfc_mf0_ntag.c +++ b/firmware/application/src/rfid/nfctag/hf/nfc_mf0_ntag.c @@ -617,6 +617,9 @@ bool nfc_tag_mf0_ntag_data_factory(uint8_t slot, tag_specific_type_t tag_type) { nfc_tag_mf0_ntag_information_max_t ntag_tmp_information; nfc_tag_mf0_ntag_information_t *p_ntag_information; p_ntag_information = (nfc_tag_mf0_ntag_information_t *)&ntag_tmp_information; + + memset(p_ntag_information, 0, sizeof(nfc_tag_mf0_ntag_information_max_t)); + int block_max = get_nr_pages_by_tag_type(tag_type); for (int block = 0; block < block_max; block++) { switch (block) { @@ -635,6 +638,27 @@ bool nfc_tag_mf0_ntag_data_factory(uint8_t slot, tag_specific_type_t tag_type) { } } + int first_cfg_page = get_first_cfg_page_by_tag_type(tag_type); + if (first_cfg_page != 0) { + p_ntag_information->memory[first_cfg_page][CONF_AUTH0_BYTE] = 0xFF; // set AUTH to 0xFF + *(uint32_t *)p_ntag_information->memory[first_cfg_page + CONF_PWD_PAGE_OFFSET] = 0xFFFFFFFF; // set PWD to FFFFFFFF + + switch (tag_type) { + case TAG_TYPE_MF0UL11: + case TAG_TYPE_MF0UL21: + p_ntag_information->memory[first_cfg_page + 1][1] = 0x05; // set VCTID to 0x05 + break; + case TAG_TYPE_NTAG_213: + case TAG_TYPE_NTAG_215: + case TAG_TYPE_NTAG_216: + p_ntag_information->memory[first_cfg_page][0] = 0x04; // set MIRROR to 0x04 (STRG_MOD_EN to 1) + break; + default: + ASSERT(false); + break; + } + } + // default ntag auto ant-collision res p_ntag_information->res_coll.atqa[0] = 0x44; p_ntag_information->res_coll.atqa[1] = 0x00;