Mynewt library compilation on TREK1000 hardware

I’m trying to port the mynewt UWB library to STM32 hardware and when trying to comple the provided example for ttk1000 I get the following errors:

repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:236:5: error: unknown type name 'dpl_error_t'
     dpl_error_t err = dpl_sem_init(&g_spi0_sem, 0x1);
     ^~~~~~~~~~~
repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:236:23: error: implicit declaration of function 'dpl_sem_init' [-Werror=implicit-function-declaration]
     dpl_error_t err = dpl_sem_init(&g_spi0_sem, 0x1);
                       ^~~~~~~~~~~~
In file included from repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:19:0:
repos/mynewt-dw1000-core/hw/bsp/followme_v2/src/hal_bsp.c:237:19: error: 'DPL_OK' undeclared (first use in this function)
     assert(err == DPL_OK);
                   ^
repos/apache-mynewt-core/libc/baselibc/include/assert.h:34:21: note: in definition of macro 'assert'
 #define assert(x) ((x) ? (void)0 : \
                     ^
repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:237:19: note: each undeclared identifier is reported only once for each function it appears in
     assert(err == DPL_OK);
                   ^
repos/apache-mynewt-core/libc/baselibc/include/assert.h:34:21: note: in definition of macro 'assert'
 #define assert(x) ((x) ? (void)0 : \
                     ^
repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c: At top level:
repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:124:16: error: storage size of 'g_spi0_sem' isn't known
 struct dpl_sem g_spi0_sem;
                ^~~~~~~~~~
cc1: all warnings being treated as errors

Seems like the dpl library is not being found for some reason.

Has the library ever been successfully been compiled for STM32 hardware?

Hello Diesel

Welcome to the Decawave forum.

I don’t think we have examples for running the DW1000 Mynewt apps on the TREK1000 hardware, but I think in theory it should work with fairly minimal adaptions.

The errors don’t appear to be related to the STM32 platform though. Did you install the dependencies like Mynewt core as described in the README?

To do this, run this inside the mynewt-dw1000-apps folder:

newt install

Doing the following:

newt target create dwm1001_boot
newt target set dwm1001_boot app=@apache-mynewt-core/apps/boot
newt target set dwm1001_boot bsp=@mynewt-dw1000-core/hw/bsp/dwm1001
newt target set dwm1001_boot build_profile=optimized 
newt build dwm1001_boot

results in:

    [...]
    Archiving apps_boot.a
    Archiving boot_bootutil.a
    Archiving crypto_mbedtls.a
    Archiving dwm1001_boot-sysinit-app.a
    Archiving hw_bsp_dwm1001.a
    Archiving hw_cmsis-core.a
    Archiving hw_hal.a
    Archiving hw_mcu_nordic.a
    Archiving hw_mcu_nordic_nrf52xxx.a
    Archiving kernel_os.a
    Archiving libc_baselibc.a
    Archiving sys_flash_map.a
    Archiving sys_mfg.a
    Archiving sys_sysinit.a
    Archiving util_mem.a
    Linking /home/user/mynewt-dw1000-apps/bin/targets/dwm1001_boot/app/apps/boot/boot.elf
    Target successfully built: targets/dwm1001_boot

but doing the following:

    newt target create ttk1000_boot
    newt target set ttk1000_boot app=@apache-mynewt-core/apps/boot
    newt target set ttk1000_boot bsp=@mynewt-dw1000-core/hw/bsp/ttk1000
    newt target set ttk1000_boot build_profile=optimized 
    newt build ttk1000_boot

results in an error:

[...]
    Compiling repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/system_stm32f4xx.c
    Compiling repos/apache-mynewt-core/hw/drivers/uart/src/uart.c
    Compiling repos/apache-mynewt-core/hw/drivers/uart/uart_hal/src/uart_hal.c
    Error: repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c: In function 'hal_bsp_init':
    repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:234:5: error: unknown type name 'dpl_error_t'
         dpl_error_t err = dpl_sem_init(&g_spi0_sem, 0x1);
     ^~~~~~~~~~~
repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:234:23: error: implicit declaration of function 'dpl_sem_init' [-Werror=implicit-function-declaration]
     dpl_error_t err = dpl_sem_init(&g_spi0_sem, 0x1);
                       ^~~~~~~~~~~~
In file included from repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:19:0:
repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:235:19: error: 'DPL_OK' undeclared (first use in this function)
     assert(err == DPL_OK);
                   ^
repos/apache-mynewt-core/libc/baselibc/include/assert.h:34:21: note: in definition of macro 'assert'
 #define assert(x) ((x) ? (void)0 : \
                     ^
repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:235:19: note: each undeclared identifier is reported only once for each function it appears in
     assert(err == DPL_OK);
                   ^
repos/apache-mynewt-core/libc/baselibc/include/assert.h:34:21: note: in definition of macro 'assert'
 #define assert(x) ((x) ? (void)0 : \
                     ^
repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c: At top level:
repos/mynewt-dw1000-core/hw/bsp/ttk1000/src/hal_bsp.c:122:16: error: storage size of 'g_spi0_sem' isn't known
 struct dpl_sem g_spi0_sem;
                ^~~~~~~~~~
cc1: all warnings being treated as errors

seems like my installation of newt and the library is ok but there are some errors with provided example for ttk1000. I’ve tried to cross reference the HW configurations but can’t find the place where dpl is imported in the dwm1001 example.

Thanks for the extra information. It looks like this indeed should work.

Even though the BSP folder for the TTK1000 is available in the Decawave Mynewt core, it should be noted that the documentation does not list it as being supported. I think the BSP package is currently incomplete.

It might be interesting to open an issue on the Decawave Mynewt core asking about support of the TTK1000 target. This forum is mainly used by the team managing the more bare-metal examples listed on our website.

hi @diesel

I have posted the solution in the github for the same question,
Check it out https://github.com/Decawave/mynewt-dw1000-core/issues/26#issuecomment-576696415

Thanks & Regards
Madhu Raj.

@diesel @rmadhuraj

I suggest you to go through this mynewt porting guide, to bring up bsp for trek1000.

Since TREK1000 has stm32f1xx controller, you can take the existing nucleo-f103rb as reference and develop for trek1000, that would be the easiest way i feel.

All the best,
Madhu Raj.