knieriem / openocd-efm32-series2

A preliminary OpenOCD driver for EFM32 Series 2 MCUs
Other
15 stars 7 forks source link

Build Fails when following build instructions/scripts #2

Closed Cydget closed 2 years ago

Cydget commented 2 years ago

Build fails on Kubuntu 22.10. Just ran the two scripts you provided and slightly changed the build.sh to suit my configuration requirements.

Build fails due to conflicting openocd/efm32 efm32_flash definition. It's been a while since I've had to deal with linking errors, so I'm not sure why this is happening, or if it can be resolved easily with a #IF NOT defined macro or by deleting the efr32.cfg source files.
/bin/bash ./libtool --tag=CC --mode=link gcc -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Wpointer-arith -Wundef -Wno-error=deprecated-declarations -Werror -g -O2 -o src/openocd src/main.o src/libopenocd.la ./jimtcl/libjim.a libtool: link: gcc -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Wpointer-arith -Wundef -Wno-error=deprecated-declarations -Werror -g -O2 -o src/openocd src/main.o src/.libs/libopenocd.a -lftdi -lhidapi-hidraw -lusb-1.0 -lm ./jimtcl/libjim.a /usr/bin/ld: src/.libs/libopenocd.a(efm32s2.o):/home/cydget/Desktop/openocd-efm32-series2/openocd/src/flash/nor/efm32s2.c:221: multiple definition ofefm32_flash'; src/.libs/libopenocd.a(efm32.o):/home/cydget/Desktop/openocd-efm32-series2/openocd/src/flash/nor/efm32.c:207: first defined here collect2: error: ld returned 1 exit status make[2]: [Makefile:3026: src/openocd] Error 1 make[2]: Leaving directory '/home/cydget/Desktop/openocd-efm32-series2/openocd' make[1]: [Makefile:4819: all-recursive] Error 1 make[1]: Leaving directory '/home/cydget/Desktop/openocd-efm32-series2/openocd' make: *** [Makefile:2000: all] Error 2 ` Commenting out line 221 did not resolve the issue. The only changes I've made were to the configuration output folder and enabling the stlink as a programming option. However, even before these changes the build did not succeed.

Here is the full build log. buildLog4.txt

knieriem commented 2 years ago

Thanks for reporting this bug. It didn't show up with GCC versions <10, that's why I didn't notice it when using it last time. As a workaround, until I push the fix, you could -- in lines 221 and 409 -- replace efm32_flash with efm32s2_flash. I forgot to adjust these two occurences, a forward declaration and use as a pointer, when deriving the series 2 driver from the original one. With these changes the build should proceed then.

--- ../efm32s2/efm32s2.c    
+++ src/flash/nor/efm32s2.c 
@@ -218,7 +218,7 @@
        { 128, "SERIES2V0", .series = 2 },
 };

-const struct flash_driver efm32_flash;
+const struct flash_driver efm32s2_flash;

 static int efm32x_priv_write(struct flash_bank *bank, const uint8_t *buffer,
    uint32_t addr, uint32_t count);
@@ -406,7 +406,7 @@

    /* look for an existing flash structure matching target */
    for (struct flash_bank *bank_iter = flash_bank_list(); bank_iter; bank_iter = bank_iter->next) {
-       if (bank_iter->driver == &efm32_flash
+       if (bank_iter->driver == &efm32s2_flash
            && bank_iter->target == bank->target
            && bank->driver_priv) {
            efm32x_info = bank->driver_priv;
Cydget commented 2 years ago

Thanks, new commit works great. This is my first experience with using openocd. Do you know if an ST-linkV2 would work being a hla_swd adapter? I haven't had much time to mess with it and decided to use my raspberry pi instead and that worked near instantly.

knieriem commented 1 year ago

I'm sorry, but I have no experience with an ST-Link V2. I have found a search result, though, that suggests that it might be possible: https://www.jentsch.io/nrf51822-flashen-mit-st-link-v2-und-openocd/ On that page, hla_swd is mentioned in openocd's output; perhaps it would work with an EFM32 series 2 target too.