1 parent
a82c6e4fe9
commit
fc2fcc890c
3 files changed
+38
-7
No files matched your search
@@ -107,6 +107,12 @@ else
|
|||||||
SRC_FPC =
|
SRC_FPC =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring WITH_BWM_FORWARD,$(APP_CFLAGS)))
|
||||||
|
SRC_BWM = bwm_uart_at32.c bwm_forward.c
|
||||||
|
else
|
||||||
|
SRC_BWM =
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq (,$(findstring WITH_HITAG,$(APP_CFLAGS)))
|
ifneq (,$(findstring WITH_HITAG,$(APP_CFLAGS)))
|
||||||
SRC_HITAG = hitag2_crypto.c hitag_common.c hitag2.c hitagS.c hitagu.c hitag2_crack.c
|
SRC_HITAG = hitag2_crypto.c hitag_common.c hitag2.c hitagS.c hitagu.c hitag2_crack.c
|
||||||
APP_CFLAGS += -I../common/hitag2
|
APP_CFLAGS += -I../common/hitag2
|
||||||
@@ -163,6 +169,7 @@ THUMBSRC = start.c \
|
|||||||
$(SRC_FLASH) \
|
$(SRC_FLASH) \
|
||||||
$(SRC_SMARTCARD) \
|
$(SRC_SMARTCARD) \
|
||||||
$(SRC_FPC) \
|
$(SRC_FPC) \
|
||||||
|
$(SRC_BWM) \
|
||||||
$(SRC_HITAG) \
|
$(SRC_HITAG) \
|
||||||
$(SRC_EM4x50) \
|
$(SRC_EM4x50) \
|
||||||
$(SRC_EM4x70) \
|
$(SRC_EM4x70) \
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
|
|
||||||
#include "sys_apis.h"
|
#include "sys_apis.h"
|
||||||
#include "usb_cdc_apis.h"
|
#include "usb_cdc_apis.h"
|
||||||
|
#ifdef WITH_BWM_FORWARD
|
||||||
|
#include "bwm_uart_at32.h"
|
||||||
|
#endif
|
||||||
#include "proxmark3_arm.h"
|
#include "proxmark3_arm.h"
|
||||||
#include "dbprint.h"
|
#include "dbprint.h"
|
||||||
#include "pmflash.h"
|
#include "pmflash.h"
|
||||||
@@ -1077,6 +1080,12 @@ static void SendCapabilities(void) {
|
|||||||
if (g_reply_via_fpc)
|
if (g_reply_via_fpc)
|
||||||
capabilities.baudrate = g_usart_baudrate;
|
capabilities.baudrate = g_usart_baudrate;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef WITH_BWM_FORWARD
|
||||||
|
// BWM link runs at a fixed baud; report it so the client's timeout math
|
||||||
|
// (communication_delay: 12000000 / uart_speed) doesn't divide by zero.
|
||||||
|
if (g_reply_via_fpc)
|
||||||
|
capabilities.baudrate = BWM_UART_BAUD;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef RDV4
|
#ifdef RDV4
|
||||||
capabilities.is_rdv4 = true;
|
capabilities.is_rdv4 = true;
|
||||||
@@ -4254,6 +4263,10 @@ void __attribute__((noreturn)) AppMain(void) {
|
|||||||
bwm_detect_and_init(); // probe BWM + apply charge config, off the pre-USB path
|
bwm_detect_and_init(); // probe BWM + apply charge config, off the pre-USB path
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_BWM_FORWARD
|
||||||
|
bwm_uart_init(); // AT32 UART4 <-> BWM app_com link; AFTER usb_enable()
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_BWM_CHARGERKICK
|
#ifdef WITH_BWM_CHARGERKICK
|
||||||
BWM_ChargerKick();
|
BWM_ChargerKick();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+18
-7
@@ -17,6 +17,9 @@
|
|||||||
#include "usb_cdc_apis.h"
|
#include "usb_cdc_apis.h"
|
||||||
#include "usb_read_ng.h"
|
#include "usb_read_ng.h"
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
|
#ifdef WITH_BWM_FORWARD
|
||||||
|
#include "bwm_forward.h"
|
||||||
|
#endif
|
||||||
#include "crc16.h"
|
#include "crc16.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "BigBuf.h"
|
#include "BigBuf.h"
|
||||||
@@ -49,7 +52,7 @@ int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_FPC_USART_HOST
|
#if defined(WITH_FPC_USART_HOST) || defined(WITH_BWM_FORWARD)
|
||||||
int resultfpc = PM3_EUNDEF;
|
int resultfpc = PM3_EUNDEF;
|
||||||
#endif
|
#endif
|
||||||
int resultusb = PM3_EUNDEF;
|
int resultusb = PM3_EUNDEF;
|
||||||
@@ -60,7 +63,9 @@ int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const v
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g_reply_via_fpc) {
|
if (g_reply_via_fpc) {
|
||||||
#ifdef WITH_FPC_USART_HOST
|
#if defined(WITH_BWM_FORWARD)
|
||||||
|
resultfpc = bwm_fwd_writebuffer_sync((uint8_t *)&txcmd, sizeof(PacketResponseOLD));
|
||||||
|
#elif defined(WITH_FPC_USART_HOST)
|
||||||
resultfpc = usart_writebuffer_sync((uint8_t *)&txcmd, sizeof(PacketResponseOLD));
|
resultfpc = usart_writebuffer_sync((uint8_t *)&txcmd, sizeof(PacketResponseOLD));
|
||||||
#else
|
#else
|
||||||
return PM3_EDEVNOTSUPP;
|
return PM3_EDEVNOTSUPP;
|
||||||
@@ -68,7 +73,7 @@ int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const v
|
|||||||
}
|
}
|
||||||
// we got two results, let's prioritize the faulty one and USB over FPC.
|
// we got two results, let's prioritize the faulty one and USB over FPC.
|
||||||
if (g_reply_via_usb && (resultusb != PM3_SUCCESS)) return resultusb;
|
if (g_reply_via_usb && (resultusb != PM3_SUCCESS)) return resultusb;
|
||||||
#ifdef WITH_FPC_USART_HOST
|
#if defined(WITH_FPC_USART_HOST) || defined(WITH_BWM_FORWARD)
|
||||||
if (g_reply_via_fpc && (resultfpc != PM3_SUCCESS)) return resultfpc;
|
if (g_reply_via_fpc && (resultfpc != PM3_SUCCESS)) return resultfpc;
|
||||||
#endif
|
#endif
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
@@ -113,7 +118,7 @@ static int reply_ng_internal(uint16_t cmd, int8_t status, uint8_t reason, const
|
|||||||
}
|
}
|
||||||
txBufferNGLen = sizeof(PacketResponseNGPreamble) + len + sizeof(PacketResponseNGPostamble);
|
txBufferNGLen = sizeof(PacketResponseNGPreamble) + len + sizeof(PacketResponseNGPostamble);
|
||||||
|
|
||||||
#ifdef WITH_FPC_USART_HOST
|
#if defined(WITH_FPC_USART_HOST) || defined(WITH_BWM_FORWARD)
|
||||||
int resultfpc = PM3_EUNDEF;
|
int resultfpc = PM3_EUNDEF;
|
||||||
#endif
|
#endif
|
||||||
int resultusb = PM3_EUNDEF;
|
int resultusb = PM3_EUNDEF;
|
||||||
@@ -127,7 +132,9 @@ static int reply_ng_internal(uint16_t cmd, int8_t status, uint8_t reason, const
|
|||||||
// TODO DXL 测试阶段,暂时通过SPI应答
|
// TODO DXL 测试阶段,暂时通过SPI应答
|
||||||
// resultusb = cep_spi_write_sync((uint8_t *)&txBufferNG, txBufferNGLen);
|
// resultusb = cep_spi_write_sync((uint8_t *)&txBufferNG, txBufferNGLen);
|
||||||
|
|
||||||
#ifdef WITH_FPC_USART_HOST
|
#if defined(WITH_BWM_FORWARD)
|
||||||
|
resultfpc = bwm_fwd_writebuffer_sync((uint8_t *)&txBufferNG, txBufferNGLen);
|
||||||
|
#elif defined(WITH_FPC_USART_HOST)
|
||||||
resultfpc = usart_writebuffer_sync((uint8_t *)&txBufferNG, txBufferNGLen);
|
resultfpc = usart_writebuffer_sync((uint8_t *)&txBufferNG, txBufferNGLen);
|
||||||
#else
|
#else
|
||||||
return PM3_EDEVNOTSUPP;
|
return PM3_EDEVNOTSUPP;
|
||||||
@@ -138,7 +145,7 @@ static int reply_ng_internal(uint16_t cmd, int8_t status, uint8_t reason, const
|
|||||||
return resultusb;
|
return resultusb;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_FPC_USART_HOST
|
#if defined(WITH_FPC_USART_HOST) || defined(WITH_BWM_FORWARD)
|
||||||
if (g_reply_via_fpc && (resultfpc != PM3_SUCCESS)) {
|
if (g_reply_via_fpc && (resultfpc != PM3_SUCCESS)) {
|
||||||
return resultfpc;
|
return resultfpc;
|
||||||
}
|
}
|
||||||
@@ -274,7 +281,11 @@ int receive_ng(PacketCommandNG *rx) {
|
|||||||
// return receive_ng_internal(rx, cep_spi_read_ng, false, true); // TODO DXL 临时用fpc这种标志
|
// return receive_ng_internal(rx, cep_spi_read_ng, false, true); // TODO DXL 临时用fpc这种标志
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#ifdef WITH_FPC_USART_HOST
|
#if defined(WITH_BWM_FORWARD)
|
||||||
|
// De-frame inbound BWM app_com DATA_FORWARD packets into a raw NG stream.
|
||||||
|
if (bwm_fwd_rxdata_available() > 0)
|
||||||
|
return receive_ng_internal(rx, bwm_read_ng, false, true);
|
||||||
|
#elif defined(WITH_FPC_USART_HOST)
|
||||||
// Check if there is a FPC packet available
|
// Check if there is a FPC packet available
|
||||||
if (usart_rxdata_available() > 0)
|
if (usart_rxdata_available() > 0)
|
||||||
return receive_ng_internal(rx, usart_read_ng, false, true);
|
return receive_ng_internal(rx, usart_read_ng, false, true);
|
||||||
|
|||||||
Reference in new issue
Block a user