Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose nfc_tag_mf1_is_detection_enable and fix compilation on newer ARM compilator versions #15

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion firmware/application/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
# keep every function in a separate section, this allows linker to discard unused ones
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
CFLAGS += -fno-builtin -fshort-enums
# fix newer compilator versions
CFLAGS += -Wno-error=array-bounds
CFLAGS += -Wno-error=sizeof-array-div

# C++ flags common to all targets
CXXFLAGS += $(OPT)
Expand Down Expand Up @@ -381,10 +384,20 @@ flash_softdevice:
nrfjprog -f nrf52 --program $(SDK_ROOT)/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex --sectorerase
nrfjprog -f nrf52 --reset

# Flash with ST-Link + OpenOCD
flash_stlink:
@echo Generating settings...
nrfutil settings generate --family NRF52840 --application $(OUTPUT_DIRECTORY)/application.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 $(OUTPUT_DIRECTORY)/settings.hex
@echo Merging required files
mergehex --merge $(OUTPUT_DIRECTORY)/bootloader.hex $(OUTPUT_DIRECTORY)/settings.hex --output $(OUTPUT_DIRECTORY)/bootloader_settings.hex
mergehex --merge $(OUTPUT_DIRECTORY)/bootloader_settings.hex $(OUTPUT_DIRECTORY)/application.hex $(SDK_ROOT)/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex --output $(OUTPUT_DIRECTORY)/project.hex
@echo Flashing...
openocd -f interface/stlink.cfg -f target/nrf52.cfg -c "program $(OUTPUT_DIRECTORY)/project.hex verify reset ; shutdown"

erase:
nrfjprog -f nrf52 --eraseall

SDK_CONFIG_FILE := ./${PROJ_DIR}/sdk_config.h
CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
config:
java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)
java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)
10 changes: 10 additions & 0 deletions firmware/application/src/app_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,15 @@ data_frame_tx_t* cmd_processor_set_mf1_detection_enable(uint16_t cmd, uint16_t s
return data_frame_make(cmd, status, 0, NULL);
}

data_frame_tx_t* cmd_processor_get_mf1_detection_status(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
if (nfc_tag_mf1_is_detection_enable()) {
status = 1;
} else {
status = 0;
}
return data_frame_make(cmd, STATUS_DEVICE_SUCCESS, 1, (uint8_t*)&status);
}

data_frame_tx_t* cmd_processor_get_mf1_detection_count(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
uint32_t count = nfc_tag_mf1_detection_log_count();
if (count == 0xFFFFFFFF) {
Expand Down Expand Up @@ -538,6 +547,7 @@ static cmd_data_map_t m_data_cmd_map[] = {

{ DATA_CMD_SET_EM410X_EMU_ID, NULL, cmd_processor_set_em410x_emu_id, NULL },

{ DATA_CMD_GET_MF1_DETECTION_STATUS, NULL, cmd_processor_get_mf1_detection_status, NULL },
{ DATA_CMD_SET_MF1_DETECTION_ENABLE, NULL, cmd_processor_set_mf1_detection_enable, NULL },
{ DATA_CMD_GET_MF1_DETECTION_COUNT, NULL, cmd_processor_get_mf1_detection_count, NULL },
{ DATA_CMD_GET_MF1_DETECTION_RESULT, NULL, cmd_processor_get_mf1_detection_log, NULL },
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/src/app_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/////////////////////////////////////////////////////////////////////
#define DARKSIDE_CANT_FIXED_NT (0x20) // Darkside,无法固定随机数,这个情况可能出现在UID卡上
#define DARKSIDE_LUCK_AUTH_OK (0x21) // Darkside,直接验证成功了,可能刚好密钥是空的
#define DARKSIDE_NACK_NO_SNED (0x22) // Darkside,卡片不响应nack,可能是一张修复了nack逻辑漏洞的卡片
#define DARKSIDE_NACK_NO_SEND (0x22) // Darkside,卡片不响应nack,可能是一张修复了nack逻辑漏洞的卡片
#define DARKSIDE_TAG_CHANGED (0x23) // Darkside,在运行darkside的过程中出现了卡片切换,可能信号问题,或者真的是两张卡迅速切换了
#define NESTED_TAG_IS_STATIC (0x24) // Nested,检测到卡片应答的随机数是固定的
#define NESTED_TAG_IS_HARD (0x25) // Nested,检测到卡片应答的随机数是不可预测的
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/src/data_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@
#define DATA_CMD_SET_MF1_DETECTION_ENABLE (5003)
#define DATA_CMD_GET_MF1_DETECTION_COUNT (5004)
#define DATA_CMD_GET_MF1_DETECTION_RESULT (5005)

#define DATA_CMD_GET_MF1_DETECTION_STATUS (5006)

#endif
4 changes: 2 additions & 2 deletions firmware/application/src/rfid/reader/hf/mf1_toolbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ uint8_t Darkside_Recover_Key(uint8_t targetBlk, uint8_t targetTyp,
par++;
if (par == 0) { // tried all 256 possible parities without success. Card doesn't send NACK.
NRF_LOG_INFO("Card doesn't send NACK.\r\n");
return DARKSIDE_NACK_NO_SNED;
return DARKSIDE_NACK_NO_SEND;
}
} else {
// Why this?
Expand Down Expand Up @@ -542,7 +542,7 @@ void Atenna_Switch_Delay(uint32_t delay_ms) {
* @retval : 如果支持,返回 HF_TAG_OK,如果不支持,
* 返回检测过程中发生异常的结果码:
* 1、DARKSIDE_CANT_FIXED_NT
* 2、DARKSIDE_NACK_NO_SNED
* 2、DARKSIDE_NACK_NO_SEND
* 3、DARKSIDE_TAG_CHANGED
* 或者其他的卡片相关的通信错误,最常见的是丢失卡片 HF_TAG_NO
*
Expand Down
2 changes: 2 additions & 0 deletions firmware/bootloader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
# keep every function in a separate section, this allows linker to discard unused ones
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
CFLAGS += -fno-builtin -fshort-enums
# fix newer compilator versions
CFLAGS += -Wno-error=array-bounds

# C++ flags common to all targets
CXXFLAGS += $(OPT)
Expand Down