KevinOConnor / can2040

Software CAN bus implementation for rp2040 micro-controllers
GNU General Public License v3.0
636 stars 63 forks source link

undefined reference to `__DMB' #48

Closed danielkucera closed 7 months ago

danielkucera commented 9 months ago

I am getting following error when compiling the library:

Compiling .pio/build/rp2040/libdb9/can2040/can2040.c.o
.pio/libdeps/rp2040/can2040/src/can2040.c: In function 'tx_schedule_transmit':
.pio/libdeps/rp2040/can2040/src/can2040.c:666:9: warning: implicit declaration of function '__DMB' [-Wimplicit-function-declaration]
  666 |         __DMB();
      |         ^~~~~
Archiving .pio/build/rp2040/libdb9/libcan2040.a
Indexing .pio/build/rp2040/libdb9/libcan2040.a
Linking .pio/build/rp2040/firmware.elf
/home/danman/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: .pio/build/rp2040/libdb9/libcan2040.a(can2040.c.o): in function `tx_schedule_transmit':
can2040.c:(.text.tx_schedule_transmit+0x4e): undefined reference to `__DMB'
collect2: error: ld returned 1 exit status
*** [.pio/build/rp2040/firmware.elf] Error 1

I managed to get rid of the error by following patch:

diff --git a/src/can2040.c b/src/can2040.c
index c2bd006..8b4abd5 100644
--- a/src/can2040.c
+++ b/src/can2040.c
@@ -14,7 +14,7 @@
 #include "hardware/structs/padsbank0.h" // padsbank0_hw
 #include "hardware/structs/pio.h" // pio0_hw
 #include "hardware/structs/resets.h" // RESETS_RESET_PIO0_BITS
-
+#include "cmsis_gcc.h"

 /****************************************************************
  * rp2040 and low-level helper functions

Is this the correct way? Is the include really missing?

KevinOConnor commented 9 months ago

I'm not sure why that would be. That header should be already included via RP2040.h -> cmsis_cm0plus.h -> cmsis_compiler.h -> cmsis_gcc.h . So, the header you've found is the correct location of the definition, but it should have already been included.

Cheers, -Kevin

danielkucera commented 9 months ago

Oh, right, I also commented RP2040.h, with that included I was getting another error:

Building in release mode
Compiling .pio/build/rp2040/libdb9/can2040/can2040.c.o
.pio/libdeps/rp2040/can2040/src/can2040.c:9:10: fatal error: RP2040.h: No such file or directory

****************************************************************
* Looking for RP2040.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:RP2040.h"
* Web  > https://registry.platformio.org/search?q=header:RP2040.h
*
****************************************************************

    9 | #include "RP2040.h" // hw_set_bits
      |          ^~~~~~~~~~
compilation terminated.
*** [.pio/build/rp2040/libdb9/can2040/can2040.c.o] Error 1
diff --git a/src/can2040.c b/src/can2040.c
index c2bd006..ad8abcb 100644
--- a/src/can2040.c
+++ b/src/can2040.c
@@ -6,7 +6,7 @@

 #include <stdint.h> // uint32_t
 #include <string.h> // memset
-#include "RP2040.h" // hw_set_bits
+//#include "RP2040.h" // hw_set_bits
 #include "can2040.h" // can2040_setup
 #include "hardware/regs/dreq.h" // DREQ_PIO0_RX1
 #include "hardware/structs/dma.h" // dma_hw
@@ -14,7 +14,7 @@
 #include "hardware/structs/padsbank0.h" // padsbank0_hw
 #include "hardware/structs/pio.h" // pio0_hw
 #include "hardware/structs/resets.h" // RESETS_RESET_PIO0_BITS
-
+#include "cmsis_gcc.h"

 /****************************************************************
  * rp2040 and low-level helper functions
  * 

I am using Platform.io with Arduino for rpi-pico, here is the complete project: https://github.com/danielkucera/rpi-can-relay

github-actions[bot] commented 7 months ago

Hello,

It looks like there hasn't been any recent updates on this github ticket. We prefer to only list tickets as "open" if they are actively being worked on. Feel free to provide an update on this ticket. Otherwise the ticket will be automatically closed in a few days.

Best regards,

~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being.