From 1a63c47cf9fa3e6eb47c3ca278899802cf45a014 Mon Sep 17 00:00:00 2001 From: Ian Martin Date: Tue, 15 Apr 2014 17:36:55 -0400 Subject: [PATCH 1/4] CC2538: Add CONF parameters to select boot loader backdoor pin and logic level. --- cpu/cc2538/dev/flash-cca.h | 1 + platform/cc2538dk/contiki-conf.h | 9 +++++++++ platform/cc2538dk/startup-gcc.c | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cpu/cc2538/dev/flash-cca.h b/cpu/cc2538/dev/flash-cca.h index 2dff2978b..a81bab702 100644 --- a/cpu/cc2538/dev/flash-cca.h +++ b/cpu/cc2538/dev/flash-cca.h @@ -58,6 +58,7 @@ #define FLASH_CCA_BOOTLDR_CFG_ACTIVE_HIGH 0x08000000 /**< Selected pin on pad A active high */ #define FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_M 0x07000000 /**< Selected pin on pad A mask */ #define FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S 24 /**< Selected pin on pad A shift */ +#define FLASH_CCA_BOOTLDR_CFG_PORT_A_LEVEL_S 27 /**< Pin level shift */ /** @} */ /*---------------------------------------------------------------------------*/ /** \name Image valid definitions diff --git a/platform/cc2538dk/contiki-conf.h b/platform/cc2538dk/contiki-conf.h index 964d01074..2188fa353 100644 --- a/platform/cc2538dk/contiki-conf.h +++ b/platform/cc2538dk/contiki-conf.h @@ -48,7 +48,16 @@ typedef uint32_t rtimer_clock_t; #ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR #define FLASH_CCA_CONF_BOOTLDR_BACKDOOR 1 /** 1) ) + #error Invalid boot loader backdoor pin level. Please set FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL to 0 (logic low) or 1 (logic high). + #endif + + #if ( (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PIN < 0) || (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PIN > 7) ) + #error Invalid boot loader backdoor pin. Please set FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PIN between 0 and 7 (indicating PA0 - PA7). + #endif + + #define FLASH_CCA_BOOTLDR_CFG ( FLASH_CCA_BOOTLDR_CFG_ENABLE \ + | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL << FLASH_CCA_BOOTLDR_CFG_PORT_A_LEVEL_S) \ + | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PIN << FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S) ) #else #define FLASH_CCA_BOOTLDR_CFG FLASH_CCA_BOOTLDR_CFG_DISABLE #endif From 16936d864caf6c3c5890759374e8593d5c902dcf Mon Sep 17 00:00:00 2001 From: Ian Martin Date: Wed, 16 Apr 2014 10:19:37 -0400 Subject: [PATCH 2/4] Rename FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PIN to FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN. --- platform/cc2538dk/contiki-conf.h | 4 ++-- platform/cc2538dk/startup-gcc.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/platform/cc2538dk/contiki-conf.h b/platform/cc2538dk/contiki-conf.h index 2188fa353..d86bd5e4d 100644 --- a/platform/cc2538dk/contiki-conf.h +++ b/platform/cc2538dk/contiki-conf.h @@ -49,8 +49,8 @@ typedef uint32_t rtimer_clock_t; #define FLASH_CCA_CONF_BOOTLDR_BACKDOOR 1 /** 7) ) - #error Invalid boot loader backdoor pin. Please set FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PIN between 0 and 7 (indicating PA0 - PA7). + #if ( (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN < 0) || (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN > 7) ) + #error Invalid boot loader backdoor pin. Please set FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN between 0 and 7 (indicating PA0 - PA7). #endif #define FLASH_CCA_BOOTLDR_CFG ( FLASH_CCA_BOOTLDR_CFG_ENABLE \ | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL << FLASH_CCA_BOOTLDR_CFG_PORT_A_LEVEL_S) \ - | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PIN << FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S) ) + | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN << FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S) ) #else #define FLASH_CCA_BOOTLDR_CFG FLASH_CCA_BOOTLDR_CFG_DISABLE #endif From 2cf730a1c6b6845296c29771065b244150200b72 Mon Sep 17 00:00:00 2001 From: Ian Martin Date: Thu, 17 Apr 2014 10:39:00 -0400 Subject: [PATCH 3/4] Un-indent preprocessor directives. --- platform/cc2538dk/startup-gcc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/platform/cc2538dk/startup-gcc.c b/platform/cc2538dk/startup-gcc.c index 4a1a63149..d6a51812d 100644 --- a/platform/cc2538dk/startup-gcc.c +++ b/platform/cc2538dk/startup-gcc.c @@ -65,19 +65,19 @@ void udma_err_isr(void); /* Boot Loader Backdoor selection */ #if FLASH_CCA_CONF_BOOTLDR_BACKDOOR - /* Backdoor enabled */ +/* Backdoor enabled */ - #if ( (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL < 0) || (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL > 1) ) - #error Invalid boot loader backdoor pin level. Please set FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL to 0 (logic low) or 1 (logic high). - #endif +#if ( (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL < 0) || (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL > 1) ) +#error Invalid boot loader backdoor pin level. Please set FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL to 0 (logic low) or 1 (logic high). +#endif - #if ( (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN < 0) || (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN > 7) ) - #error Invalid boot loader backdoor pin. Please set FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN between 0 and 7 (indicating PA0 - PA7). - #endif +#if ( (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN < 0) || (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN > 7) ) +#error Invalid boot loader backdoor pin. Please set FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN between 0 and 7 (indicating PA0 - PA7). +#endif - #define FLASH_CCA_BOOTLDR_CFG ( FLASH_CCA_BOOTLDR_CFG_ENABLE \ - | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL << FLASH_CCA_BOOTLDR_CFG_PORT_A_LEVEL_S) \ - | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN << FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S) ) +#define FLASH_CCA_BOOTLDR_CFG ( FLASH_CCA_BOOTLDR_CFG_ENABLE \ + | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL << FLASH_CCA_BOOTLDR_CFG_PORT_A_LEVEL_S) \ + | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN << FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S) ) #else #define FLASH_CCA_BOOTLDR_CFG FLASH_CCA_BOOTLDR_CFG_DISABLE #endif From ee05810904ac86ed9f7549a0f52819f819e3a427 Mon Sep 17 00:00:00 2001 From: Ian Martin Date: Fri, 18 Apr 2014 10:29:47 -0400 Subject: [PATCH 4/4] Changes suggested by @bthebaudeau. --- cpu/cc2538/dev/flash-cca.h | 1 - platform/cc2538dk/contiki-conf.h | 4 ++-- platform/cc2538dk/startup-gcc.c | 8 +++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cpu/cc2538/dev/flash-cca.h b/cpu/cc2538/dev/flash-cca.h index a81bab702..2dff2978b 100644 --- a/cpu/cc2538/dev/flash-cca.h +++ b/cpu/cc2538/dev/flash-cca.h @@ -58,7 +58,6 @@ #define FLASH_CCA_BOOTLDR_CFG_ACTIVE_HIGH 0x08000000 /**< Selected pin on pad A active high */ #define FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_M 0x07000000 /**< Selected pin on pad A mask */ #define FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S 24 /**< Selected pin on pad A shift */ -#define FLASH_CCA_BOOTLDR_CFG_PORT_A_LEVEL_S 27 /**< Pin level shift */ /** @} */ /*---------------------------------------------------------------------------*/ /** \name Image valid definitions diff --git a/platform/cc2538dk/contiki-conf.h b/platform/cc2538dk/contiki-conf.h index d86bd5e4d..558347f8b 100644 --- a/platform/cc2538dk/contiki-conf.h +++ b/platform/cc2538dk/contiki-conf.h @@ -53,8 +53,8 @@ typedef uint32_t rtimer_clock_t; #define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN 3 /**< Pin PA_3 (Select button) activates the boot loader */ #endif -#ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL -#define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL 0 /**< A logic low level activates the boot loader */ +#ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH +#define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH 0 /**< A logic low level activates the boot loader */ #endif /** @} */ diff --git a/platform/cc2538dk/startup-gcc.c b/platform/cc2538dk/startup-gcc.c index d6a51812d..f87e1f178 100644 --- a/platform/cc2538dk/startup-gcc.c +++ b/platform/cc2538dk/startup-gcc.c @@ -67,8 +67,10 @@ void udma_err_isr(void); #if FLASH_CCA_CONF_BOOTLDR_BACKDOOR /* Backdoor enabled */ -#if ( (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL < 0) || (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL > 1) ) -#error Invalid boot loader backdoor pin level. Please set FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL to 0 (logic low) or 1 (logic high). +#if FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH +#define FLASH_CCA_BOOTLDR_CFG_ACTIVE_LEVEL FLASH_CCA_BOOTLDR_CFG_ACTIVE_HIGH +#else +#define FLASH_CCA_BOOTLDR_CFG_ACTIVE_LEVEL 0 #endif #if ( (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN < 0) || (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN > 7) ) @@ -76,7 +78,7 @@ void udma_err_isr(void); #endif #define FLASH_CCA_BOOTLDR_CFG ( FLASH_CCA_BOOTLDR_CFG_ENABLE \ - | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_LEVEL << FLASH_CCA_BOOTLDR_CFG_PORT_A_LEVEL_S) \ + | FLASH_CCA_BOOTLDR_CFG_ACTIVE_LEVEL \ | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN << FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S) ) #else #define FLASH_CCA_BOOTLDR_CFG FLASH_CCA_BOOTLDR_CFG_DISABLE