From: Holger Hans Peter Freyther zecke@selfish.org
These address various compiler warnings, there is still one left related the flash handling but I will need to read a bit more on the EFC. I have flashed my device using DFU with these patches applied.
Holger Hans Peter Freyther (5): dfu: The i variable to disable interrupts shadows the outer index dfu: udp_ep0_recv_clean is static and is not called anywhere dfu: Mark unsued variables as __unused for now dfu: Use {} for possible empty if statement (in case debug is off) dfu: Remove unused variable, mark method as not retuning
firmware/include/asm/compiler.h | 3 +++ firmware/src/dfu/dfu.c | 36 +++++++++++------------------------- 2 files changed, 14 insertions(+), 25 deletions(-)
From: Holger Hans Peter Freyther zecke@selfish.org
In case ram_app_entry() returns do not reset i to 32, otherwise we will never reset the watchdog.
src/dfu/dfu.c:1077:7: warning: declaration of ‘i’ shadows a previous local [-Wshadow] src/dfu/dfu.c:1068:6: warning: shadowed declaration is here [-Wshadow] --- firmware/src/dfu/dfu.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/firmware/src/dfu/dfu.c b/firmware/src/dfu/dfu.c index 0e22256..48f2cdc 100644 --- a/firmware/src/dfu/dfu.c +++ b/firmware/src/dfu/dfu.c @@ -1074,9 +1074,9 @@ void __dfufunc dfu_main(void) } if (switch_to_ram) { void (*ram_app_entry)(void); - int i; - for (i = 0; i < 32; i++) - AT91F_AIC_DisableIt(AT91C_BASE_AIC, i); + int j; + for (j = 0; j < 32; j++) + AT91F_AIC_DisableIt(AT91C_BASE_AIC, j); /* jump into RAM */ AT91F_DBGU_Printk("JUMP TO RAM\r\n"); ram_app_entry = AT91C_ISRAM + SAM7DFU_RAM_SIZE;
From: Holger Hans Peter Freyther zecke@selfish.org
--- firmware/src/dfu/dfu.c | 14 -------------- 1 files changed, 0 insertions(+), 14 deletions(-)
diff --git a/firmware/src/dfu/dfu.c b/firmware/src/dfu/dfu.c index 48f2cdc..9cd9996 100644 --- a/firmware/src/dfu/dfu.c +++ b/firmware/src/dfu/dfu.c @@ -144,20 +144,6 @@ static void __dfufunc udp_ep0_send_data(const char *pData, u_int32_t length) } }
-static void udp_ep0_recv_clean(void) -{ - unsigned int i; - u_int8_t dummy; - const AT91PS_UDP pUdp = AT91C_BASE_UDP; - - while (!(pUdp->UDP_CSR[0] & AT91C_UDP_RX_DATA_BK0)) ; - - for (i = 0; i < (pUdp->UDP_CSR[0] >> 16); i++) - dummy = pUdp->UDP_FDR[0]; - - pUdp->UDP_CSR[0] &= ~(AT91C_UDP_RX_DATA_BK0); -} - /* receive data from EP0 */ static int __dfufunc udp_ep0_recv_data(u_int8_t *data, u_int16_t len) {
From: Holger Hans Peter Freyther zecke@selfish.org
--- firmware/include/asm/compiler.h | 2 ++ firmware/src/dfu/dfu.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/firmware/include/asm/compiler.h b/firmware/include/asm/compiler.h index de4dfaa..08b6bae 100644 --- a/firmware/include/asm/compiler.h +++ b/firmware/include/asm/compiler.h @@ -4,4 +4,6 @@ #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0)
+#define __unused __attribute__((unused)) + #endif diff --git a/firmware/src/dfu/dfu.c b/firmware/src/dfu/dfu.c index 9cd9996..682ce5e 100644 --- a/firmware/src/dfu/dfu.c +++ b/firmware/src/dfu/dfu.c @@ -231,7 +231,7 @@ static void chk_first_dnload_set_ptr(void) first_download = 0; }
-static int __dfufunc handle_dnload_flash(u_int16_t val, u_int16_t len) +static int __dfufunc handle_dnload_flash(u_int16_t __unused val, u_int16_t len) { volatile u_int32_t *p; u_int8_t *pagebuf = (u_int8_t *) pagebuf32; @@ -297,7 +297,7 @@ static int __dfufunc handle_dnload_flash(u_int16_t val, u_int16_t len) return RET_ZLP; }
-static int __dfufunc handle_dnload_ram(u_int16_t val, u_int16_t len) +static int __dfufunc handle_dnload_ram(u_int16_t __unused val, u_int16_t len) { DEBUGE("download ");
@@ -349,7 +349,7 @@ static int __dfufunc handle_dnload(u_int16_t val, u_int16_t len) }
#define AT91C_IFLASH_END ((u_int8_t *)AT91C_IFLASH + AT91C_IFLASH_SIZE) -static __dfufunc int handle_upload(u_int16_t val, u_int16_t len) +static __dfufunc int handle_upload(u_int16_t __unused val, u_int16_t len) { DEBUGE("upload "); if (len > AT91C_IFLASH_PAGE_SIZE) { @@ -421,7 +421,7 @@ static void __dfufunc handle_getstate(void) }
/* callback function for DFU requests */ -int __dfufunc dfu_ep0_handler(u_int8_t req_type, u_int8_t req, +int __dfufunc dfu_ep0_handler(u_int8_t __unused req_type, u_int8_t req, u_int16_t val, u_int16_t len) { int rc, ret = RET_NOTHING;
From: Holger Hans Peter Freyther zecke@selfish.org
src/dfu/dfu.c:853:23: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] --- firmware/src/dfu/dfu.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/firmware/src/dfu/dfu.c b/firmware/src/dfu/dfu.c index 682ce5e..f31b9f8 100644 --- a/firmware/src/dfu/dfu.c +++ b/firmware/src/dfu/dfu.c @@ -847,8 +847,10 @@ static __dfufunc void dfu_udp_ep0_handler(void) break; case STD_SET_CONFIGURATION: DEBUGE("SET_CONFIG "); - if (wValue) + if (wValue) { DEBUGE("VALUE!=0 "); + } + cur_config = wValue; udp_ep0_send_zlp(); pUDP->UDP_GLBSTATE =
From: Holger Hans Peter Freyther zecke@selfish.org
--- firmware/include/asm/compiler.h | 1 + firmware/src/dfu/dfu.c | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/firmware/include/asm/compiler.h b/firmware/include/asm/compiler.h index 08b6bae..d2b53f0 100644 --- a/firmware/include/asm/compiler.h +++ b/firmware/include/asm/compiler.h @@ -5,5 +5,6 @@ #define unlikely(x) __builtin_expect(!!(x), 0)
#define __unused __attribute__((unused)) +#define __noreturn __attribute__((noreturn))
#endif diff --git a/firmware/src/dfu/dfu.c b/firmware/src/dfu/dfu.c index f31b9f8..5d6865c 100644 --- a/firmware/src/dfu/dfu.c +++ b/firmware/src/dfu/dfu.c @@ -993,10 +993,8 @@ static __dfufunc void dfu_udp_irq(void) }
/* this is only called once before DFU mode, no __dfufunc required */ -static void dfu_switch(void) +static __noreturn void dfu_switch(void) { - AT91PS_AIC pAic = AT91C_BASE_AIC; - DEBUGE("\r\nsam7dfu: switching to DFU mode\r\n");
dfu_state = DFU_STATE_appDETACH;
Hi Holger,
On Wed, Nov 09, 2011 at 11:24:11PM +0100, Holger Hans Peter Freyther wrote:
These address various compiler warnings, there is still one left related the flash handling but I will need to read a bit more on the EFC. I have flashed my device using DFU with these patches applied.
I've applied the cleanups, thanks.