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

Double definition of WDT for SAMD51 #206

Open
amasmiller opened this issue Sep 6, 2023 · 0 comments
Open

Double definition of WDT for SAMD51 #206

amasmiller opened this issue Sep 6, 2023 · 0 comments

Comments

@amasmiller
Copy link

When the Feather M4 bootloader is compiled and modifications are made to use the RESET_CONTROLLER->RCAUSE.bit.WDT field, the bootloader fails to compile to due another definition of WDT.

Example code modifications:

diff --git a/Makefile b/Makefile
index 435a75c..4cb5ad9 100755
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-BOARD=zero
+BOARD=feather_m4
 -include Makefile.user
 include boards/$(BOARD)/board.mk
 CC=arm-none-eabi-gcc
diff --git a/src/main.c b/src/main.c
index 095fa0a..51b5caf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -293,6 +293,11 @@ int main(void) {
     /* Jump in application if condition is satisfied */
     check_start_application();

+    if (RESET_CONTROLLER->RCAUSE.bit.WDT)
+    {
+        // noop
+    }
+
     /* We have determined we should stay in the monitor. */
     /* System initialization */
     system_init();

Resulting compilation output:

$ make
Building feather_m4
echo "src/main.c"
src/main.c
arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -O2 -g -DSAMD51 -x c -c -pipe -nostdlib --param max-inline-insns-single=500 -fno-strict-aliasing -fdata-sections -ffunction-sections -D__SAMD51J19A__ -Werror -Wall -Wstrict-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wno-undef -Wbad-function-cast -Wwrite-strings -Waggregate-return -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align -Wno-missing-braces -Wno-overflow -Wno-shadow -Wno-attributes -Wno-packed -Wno-pointer-sign  -I. -I./inc -I./inc/preprocessor -I./boards/feather_m4 -Ilib/cmsis/CMSIS/Include -Ilib/usb_msc -Ibuild/feather_m4 -Ilib/samd51/include/ src/main.c -o build/feather_m4/main.o
In file included from lib/samd51/include/sam.h:38,
                 from ./inc/uf2.h:7,
                 from src/main.c:81:
src/main.c: In function 'main':
lib/samd51/include/samd51j19a.h:1016:27: error: expected identifier before '(' token
 #define WDT               ((Wdt      *)0x40002000UL) /**< \brief (WDT) APB Base Address */
                           ^
src/main.c:296:38: note: in expansion of macro 'WDT'
     if (RESET_CONTROLLER->RCAUSE.bit.WDT)
                                      ^~~
make: *** [Makefile:181: build/feather_m4/main.o] Error 1

The conflict of WDT is caused by the definitions in lib/samd51/include/component/rstc.h and lib/samd51/include/samd51j19a.h.

Current workaround is to use an #undef of WDT prior to use of the bit, as seen below:

diff --git a/src/main.c b/src/main.c
index 095fa0a..ddafeb6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -293,6 +293,12 @@ int main(void) {
     /* Jump in application if condition is satisfied */
     check_start_application();

+    #undef WDT
+    if (RESET_CONTROLLER->RCAUSE.bit.WDT)
+    {
+        // noop
+    }
+
     /* We have determined we should stay in the monitor. */
     /* System initialization */
     system_init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant