From f9463d183a4cea1a0c43307f371cbbb1ba6982bd Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 10 May 2020 14:05:15 +0200 Subject: [PATCH] bootloader: fix missing prototypes and shadowed vars --- bootrom/bootrom.c | 8 ++++++-- common_arm/usb_cdc.c | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/bootrom/bootrom.c b/bootrom/bootrom.c index aa633f448..95fa5d467 100644 --- a/bootrom/bootrom.c +++ b/bootrom/bootrom.c @@ -10,6 +10,7 @@ #include "usb_cdc.h" #include "proxmark3_arm.h" +#define DEBUG 0 struct common_area common_area __attribute__((section(".commonarea"))); unsigned int start_addr, end_addr, bootrom_unlocked; @@ -45,13 +46,15 @@ static int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, return result; } -void DbpString(char *str) { +#if DEBUG +static void DbpString(char *str) { uint8_t len = 0; while (str[len] != 0x00) len++; reply_old(CMD_DEBUG_PRINT_STRING, len, 0, 0, (uint8_t *)str, len); } +#endif static void ConfigClocks(void) { // we are using a 16 MHz crystal as the basis for everything @@ -76,7 +79,7 @@ static void Fatal(void) { for (;;) {}; } -void UsbPacketReceived(uint8_t *packet, int len) { +static void UsbPacketReceived(uint8_t *packet, int len) { int i, dont_ack = 0; PacketCommandOLD *c = (PacketCommandOLD *)packet; @@ -235,6 +238,7 @@ static void flash_mode(void) { } } +void BootROM(void); void BootROM(void) { //------------ // First set up all the I/O pins; GPIOs configured directly, other ones diff --git a/common_arm/usb_cdc.c b/common_arm/usb_cdc.c index ca2c1986a..2b8a8eee7 100644 --- a/common_arm/usb_cdc.c +++ b/common_arm/usb_cdc.c @@ -394,7 +394,7 @@ static const char StrMS_OSDescriptor[] = { 'M', 0, 'S', 0, 'F', 0, 'T', 0, '1', 0, '0', 0, '0', 0, MS_VENDOR_CODE, 0 }; -const char *getStringDescriptor(uint8_t idx) { +static const char *getStringDescriptor(uint8_t idx) { switch (idx) { case 0: return StrLanguageCodes; @@ -793,7 +793,7 @@ int usb_write(const uint8_t *data, const size_t len) { * \brief Send Data through the control endpoint *---------------------------------------------------------------------------- */ -void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length) { +void AT91F_USB_SendData(AT91PS_UDP pudp, const char *pData, uint32_t length) { AT91_REG csr; do { @@ -801,17 +801,17 @@ void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length) { length -= cpt; while (cpt--) - pUdp->UDP_FDR[AT91C_EP_CONTROL] = *pData++; + pudp->UDP_FDR[AT91C_EP_CONTROL] = *pData++; - if (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) { + if (pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) { UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXCOMP); - while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP); + while (pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP); } UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXPKTRDY); do { - csr = pUdp->UDP_CSR[AT91C_EP_CONTROL]; + csr = pudp->UDP_CSR[AT91C_EP_CONTROL]; // Data IN stage has been stopped by a status OUT if (csr & AT91C_UDP_RX_DATA_BK0) { @@ -822,9 +822,9 @@ void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length) { } while (length); - if (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) { + if (pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) { UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXCOMP); - while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP); + while (pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP); } } @@ -833,22 +833,22 @@ void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length) { //* \fn AT91F_USB_SendZlp //* \brief Send zero length packet through the control endpoint //*---------------------------------------------------------------------------- -void AT91F_USB_SendZlp(AT91PS_UDP pUdp) { +void AT91F_USB_SendZlp(AT91PS_UDP pudp) { UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXPKTRDY); - while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP)) {}; + while (!(pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP)) {}; UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXCOMP); - while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) {}; + while (pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) {}; } //*---------------------------------------------------------------------------- //* \fn AT91F_USB_SendStall //* \brief Stall the control endpoint //*---------------------------------------------------------------------------- -void AT91F_USB_SendStall(AT91PS_UDP pUdp) { +void AT91F_USB_SendStall(AT91PS_UDP pudp) { UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_FORCESTALL); - while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_ISOERROR)) {}; + while (!(pudp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_ISOERROR)) {}; UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, (AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR)); - while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & (AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR)) {}; + while (pudp->UDP_CSR[AT91C_EP_CONTROL] & (AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR)) {}; } //*----------------------------------------------------------------------------