Dependency hell: help!

Hello,

I’m using platformio, and I think it is great… but I’m still learning to use it.
I’m trying to setup an ambiq apollo3 env… My current project already works great with esp32 in idf mode.
My project is inside src/ folder, and I have a bunch of libraries in lib/ folder. For example, lib/bluetooth…
The libraries are not from the registry, but directly in the lib folder.
lib/bluetooth/library.json is using “framework”: “" and “platform”: "” (because it is generic)
WOrks great with esp32.

For ambiq, it’s a big more complex as it is not supported out of the box…
I had to clone into ~/.platformio/package/ the github framework:

git clone --recurse-submodules --branch 2.5.1-sfe https://github.com/sparkfun/AmbiqSuiteSDK.git framework-ambiqsuitesdkapollo3-sfe@2.5.1 --depth=1

And added a package.json with this inside:

{
    "name": "framework-ambiqsuitesdkapollo3-sfe",
    "description": "SparkFun's AmbiqSuiteSDK repository.",
    "version": "2.5.1",
    "url": "https://github.com/sparkfun/AmbiqSuiteSDK"
}

So far so good. Updated my platformio.ini to add a new env, declared:

platform = apollo3blue
framework = ambiqsdk-sfe
lib_deps = bluetooth 

(and many other, exact same lib_deps as the esp32 env)

Now I launch pio run… everything is downloaded and setup properly… and when it tries to compile my application in src, it says it cannot find my bluetooth.h header that is in lib/bluetooth/include…
I’m using the default ldf value (chain, soft)
And it says also “No dependencies” when scanning…

I’ve made sure that there is no incompatible platform and framework, tried all possible values for ldf, but still nothing. It is ignoring my libraries. WHY? How can I debug that?(how to know what lib was checked, and why it was rejected etc). Currently I have no clue, and tracing the code quickly let me in Scons opaque code :frowning:

Processing Ambiq_exp (board: SparkFun_Artemis_Development_Kit; platform: apollo3blue; framework: ambiqsdk-sfe) ------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/apollo3blue/SparkFun_Artemis_Development_Kit.html
PLATFORM: Apollo 3 Blue (0.0.2+sha.b26fc48) > SparkFun Artemis Development Kit
HARDWARE: AMA3B1KK 48MHz, 384KB RAM, 960KB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES: 
 - framework-ambiqsuitesdkapollo3-sfe @ 2.5.1 
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 38 compatible libraries
Scanning dependencies...
No dependencies

I know that it is not a full source project I give you here, but any hint may help me.
I will try to setup a new project with a simple lib and application at least to be able to send it here to reproduce.

Thanks!

Hello,

I’ve created a very simple project that reproduce my issue:
But seems like I cannot post a zip file here

You can always upload it to github or Google Drive / any other cloud service and post the link here.

Yes, thank you.

Here is the tar.gz file:https://drive.google.com/file/d/1WlD-QMo5qqlHpyFqKzMCVdvCGLTWfsdA/view?usp=sharing

I’m building under linux, python3.10. Not sure this is important, but maybe.

In ~/.platformio/package/ I’ve done a git clone of the sdk:

git clone --recurse-submodules --branch 2.5.1-sfe https://github.com/sparkfun/AmbiqSuiteSDK.git framework-ambiqsuitesdkapollo3-sfe@2.5.1 --depth=1

And then I added package.json:

{
    "name": "framework-ambiqsuitesdkapollo3-sfe",
    "description": "SparkFun's AmbiqSuiteSDK repository.",
    "version": "2.5.1",
    "url": "https://github.com/sparkfun/AmbiqSuiteSDK"
}

The builder script for the SDK is to blame. Specifically, this line

In which internal libraries of the framework are added to PlatformIO (in a way I’ve never seen before) seems to override the library builders PlatformIO has previously detected, i.e., your bluetooth library in lib/bluetooth.

You will find that when you do pio init --ide=vscode on the CLI in that project, there’s no trace of lib/bluetooth, as soon as you comment out the line, there it is (but ofc none of the previous SDK libraries and so build fails).

The issue must be fixed by rewriting nigelb’s ambiqsuitesdk-sfe.py script to not trash the config for the user libs in the project. I might have a look later in the day.

This issue is now tracked in Libraries in lib/ are not included in build process · Issue #41 · nigelb/platform-apollo3blue · GitHub.

wow, thanks! I would have never guessed that! Thank you, I will follow this issue closely

A fix has been pushed for the platform in regards to this. You can get it e.g. with the CLIpio pkg update -g -p apollo3blue.

Note that your reference project will still not compile because the bluetooth.h header uses undeclared types (using bool and uint32_t with no #include <stdbool.h> and #include <stdint.h> in sight). I’m also getting a compile error in the SDK, but I’m not sure what that’s about – however maybe you found that out already and fixed it.

/home/max/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/artemis_dk/bsp/am_bsp_pins.c:840:28: error: 'AM_HAL_PIN_23_MSPI13' undeclared here (not in a function); did you mean 'AM_HAL_PIN_23_MSPI3'?
  840 |     .uFuncSel            = AM_HAL_PIN_23_MSPI13,
      |                            ^~~~~~~~~~~~~~~~~~~~
      |                            AM_HAL_PIN_23_MSPI3

thank you very much!

Yes, I see them too, unrelated to this problem, it is most likely a missing define for the platform. But this part is “easy”, not related to platformio I think

Thanks!

I believe there is still an issue with the sdk… none of the includes are available…
For example, FreeRTOS.h is not found
In apollo3blue/extra/ambiqsdk-sfe/libraries/third_party/FreeRTOS/library.json it is there, but I don’t see the include in the gcc command line

I need to explicitly add FreeRTOS in lib_deps

FreeRTOS is internally added to the available libraries (in the LDF sense). However, for Intellisense to pick it up, you first need to place an include to that library in one of your src/ files (e.g. #include <FreeRTOS.h>), the rebuild the intellisense with Ctrl+Shift-P → Rebuild Intellisense Index. PlatformIO should now pick up the dependency without you specifying it in the lib_deps.

it does not :frowning:
the include is inside my lib, but it is not picked by the LDF.
I do not reproduce it with the simple test application (I added the freertos.h header in bluetooth.h to see, and the library is correctly pulled)
Most likely a mistake from me somewhere when I was investigating the previous error

ok, I had to explicitely add FreeRTOS as a dependcy to my lib:
“dependencies”: {
“FreeRTOS”: “*”
}

I’m using an extraScript here, maybe that’s the reason?
My script is doing a selection of the platform to compile (esp32 or apollo3)

for item in env.get("CPPDEFINES", []):
    if isinstance(item, tuple) and item[0] == "TARGET_PLATFORM":
        env.Append(CPPPATH=[realpath(join("src", item[1]))])
        env.Append(CPPPATH=[ realpath("src/%s/ble" % item[1]), 
                             realpath("src/%s/ble/profiles" % item[1]) ])
        env.Replace(SRC_FILTER=["+<%s>" % item[1]])
        break

The library.json is simple:

{
    "name": "hal-platform",
    "version": "0.0.1",
    "platforms": "*",
    "frameworks": "*",
    "dependencies": {
        "FreeRTOS": "*"
    },
    "build": {
        "includeDir": "include",
        "extraScript": "platform_config.py"
    }
}

Hello fariouche and maxgerhardt,

I have pushed another fix and if you update apollo3blue again and add the missing includes to bluetooth.h and change your board to something that does not have a broken pin def, like SparkFun_RedBoard_Artemis_ATP, the sample project compiles:

Processing albambiqdev (platform: apollo3blue; board: SparkFun_RedBoard_Artemis_ATP; framework: ambiqsdk-sfe)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/apollo3blue/SparkFun_RedBoard_Artemis_ATP.html
PLATFORM: Apollo 3 Blue (0.0.2) > SparkFun RedBoard Artemis ATP
HARDWARE: AMA3B1KK 48MHz, 384KB RAM, 960KB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES: 
 - framework-ambiqsuitesdkapollo3-sfe @ 2.5.1 
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
Installing Protocol Buffers dependencies
Requirement already satisfied: protobuf>=3.19.1 in /home/user/.python/3/pio/lib/python3.8/site-packages (4.21.9)
[nanopb] No generation needed.
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Nanopb @ 0.4.6+4
|-- tst_ble @ 0.1.0
Building in release mode
No baud rate specified.
Using default svl baud rate of 921600
Compiling .pio/build/albambiqdev/src/applications/main.o
Compiling .pio/build/albambiqdev/lib10b/Nanopb/pb_common.o
Compiling .pio/build/albambiqdev/lib10b/Nanopb/pb_decode.o
src/applications/main.c:4:6: warning: return type of 'main' is not 'int' [-Wmain]
    4 | void main(void)
      |      ^~~~
Compiling .pio/build/albambiqdev/lib10b/Nanopb/pb_encode.o
Compiling .pio/build/albambiqdev/lib81d/bluetooth/ble.o
lib/bluetooth/src/ble.c: In function 'init_bluetooth':
lib/bluetooth/src/ble.c:8:41: warning: format '%d' expects argument of type 'int', but argument 2 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
    8 |     printf("init bluetooth called with %d\n", timeout);
      |                                        ~^     ~~~~~~~
      |                                         |     |
      |                                         int   uint32_t {aka long unsigned int}
      |                                        %ld
Compiling .pio/build/albambiqdev/Variant/bsp/am_bsp.o
Compiling .pio/build/albambiqdev/Variant/bsp/am_bsp_pins.o
Compiling .pio/build/albambiqdev/Hal/am_hal_adc.o
Compiling .pio/build/albambiqdev/Hal/am_hal_ble.o
Compiling .pio/build/albambiqdev/Hal/am_hal_ble_patch.o
Compiling .pio/build/albambiqdev/Hal/am_hal_ble_patch_b0.o
Compiling .pio/build/albambiqdev/Hal/am_hal_burst.o
Compiling .pio/build/albambiqdev/Hal/am_hal_cachectrl.o
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c: In function 'am_bsp_mspi_pins_enable':
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_DUAL_CE0_1_1_2' not handled in switch [-Wswitch]
  585 |     switch ( eMSPIDevice )
      |     ^~~~~~
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_DUAL_CE1_1_1_2' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_DUAL_CE0_1_2_2' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_DUAL_CE1_1_2_2' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_QUAD_CE0_1_1_4' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_QUAD_CE1_1_1_4' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_QUAD_CE0_1_4_4' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_QUAD_CE1_1_4_4' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_SERIAL_CE0_3WIRE' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_SERIAL_CE1_3WIRE' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:585:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_MAX' not handled in switch [-Wswitch]
Compiling .pio/build/albambiqdev/Hal/am_hal_clkgen.o
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c: In function 'am_bsp_mspi_pins_disable':
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_DUAL_CE0_1_1_2' not handled in switch [-Wswitch]
  681 |     switch ( eMSPIDevice )
      |     ^~~~~~
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_DUAL_CE1_1_1_2' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_DUAL_CE0_1_2_2' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_DUAL_CE1_1_2_2' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_QUAD_CE0_1_1_4' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_QUAD_CE1_1_1_4' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_QUAD_CE0_1_4_4' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_QUAD_CE1_1_4_4' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_SERIAL_CE0_3WIRE' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_SERIAL_CE1_3WIRE' not handled in switch [-Wswitch]
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp.c:681:5: warning: enumeration value 'AM_HAL_MSPI_FLASH_MAX' not handled in switch [-Wswitch]
Compiling .pio/build/albambiqdev/Hal/am_hal_cmdq.o
Compiling .pio/build/albambiqdev/Hal/am_hal_ctimer.o
Archiving .pio/build/albambiqdev/lib10b/libNanopb.a
/home/user/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/mcu/apollo3/hal/am_hal_ble.c:1715:1: warning: 'am_hal_ble_check_status_edge' defined but not used [-Wunused-function]
 1715 | am_hal_ble_check_status_edge(am_hal_ble_state_t *pBle)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Archiving .pio/build/albambiqdev/lib81d/libbluetooth.a
Indexing .pio/build/albambiqdev/lib10b/libNanopb.a
Indexing .pio/build/albambiqdev/lib81d/libbluetooth.a
Compiling .pio/build/albambiqdev/Hal/am_hal_debug.o
Compiling .pio/build/albambiqdev/Hal/am_hal_flash.o
Compiling .pio/build/albambiqdev/Hal/am_hal_global.o
Compiling .pio/build/albambiqdev/Hal/am_hal_gpio.o
Archiving .pio/build/albambiqdev/libVariant.a
Indexing .pio/build/albambiqdev/libVariant.a
Compiling .pio/build/albambiqdev/Hal/am_hal_interrupt.o
Compiling .pio/build/albambiqdev/Hal/am_hal_iom.o
Compiling .pio/build/albambiqdev/Hal/am_hal_ios.o
Compiling .pio/build/albambiqdev/Hal/am_hal_itm.o
Compiling .pio/build/albambiqdev/Hal/am_hal_mcuctrl.o
Compiling .pio/build/albambiqdev/Hal/am_hal_mspi.o
Compiling .pio/build/albambiqdev/Hal/am_hal_pdm.o
Compiling .pio/build/albambiqdev/Hal/am_hal_pwrctrl.o
Compiling .pio/build/albambiqdev/Hal/am_hal_queue.o
Compiling .pio/build/albambiqdev/Hal/am_hal_reset.o
Compiling .pio/build/albambiqdev/Hal/am_hal_rtc.o
Compiling .pio/build/albambiqdev/Hal/am_hal_scard.o
Compiling .pio/build/albambiqdev/Hal/am_hal_secure_ota.o
Compiling .pio/build/albambiqdev/Hal/am_hal_security.o
Compiling .pio/build/albambiqdev/Hal/am_hal_stimer.o
Compiling .pio/build/albambiqdev/Hal/am_hal_sysctrl.o
Compiling .pio/build/albambiqdev/Hal/am_hal_systick.o
Compiling .pio/build/albambiqdev/Hal/am_hal_tpiu.o
Compiling .pio/build/albambiqdev/Hal/am_hal_uart.o
Compiling .pio/build/albambiqdev/Hal/am_hal_wdt.o
Compiling .pio/build/albambiqdev/Devices/am_devices_led.o
Compiling .pio/build/albambiqdev/Utils/am_util_ble.o
Compiling .pio/build/albambiqdev/Utils/am_util_debug.o
Compiling .pio/build/albambiqdev/Utils/am_util_delay.o
Compiling .pio/build/albambiqdev/Utils/am_util_faultisr.o
Compiling .pio/build/albambiqdev/Utils/am_util_id.o
Compiling .pio/build/albambiqdev/Utils/am_util_stdio.o
Compiling .pio/build/albambiqdev/Utils/am_util_string.o
Compiling .pio/build/albambiqdev/Utils/am_util_time.o
Compiling .pio/build/albambiqdev/Entry/startup_gcc.o
Archiving .pio/build/albambiqdev/libDevices.a
Archiving .pio/build/albambiqdev/libHal.a
Indexing .pio/build/albambiqdev/libDevices.a
Archiving .pio/build/albambiqdev/libEntry.a
Indexing .pio/build/albambiqdev/libHal.a
Indexing .pio/build/albambiqdev/libEntry.a
Archiving .pio/build/albambiqdev/libUtils.a
Indexing .pio/build/albambiqdev/libUtils.a
Linking .pio/build/albambiqdev/program
arm-none-eabi-objcopy -O binary .pio/build/albambiqdev/program .pio/build/albambiqdev/firmware.bin
Checking size .pio/build/albambiqdev/program
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.7% (used 2572 bytes from 393216 bytes)
Flash: [          ]   2.6% (used 25360 bytes from 983040 bytes)
===================================================================================================== [SUCCESS] Took 1.28 seconds =====================================================================================================

Thank you nigelb!

I’ve done the update, change platformio.ini to use the board you suggested, and I still have an error.

.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe/redboard_artemis_atp/bsp/am_bsp_pins.c:684:28: error: 'AM_HAL_PIN_23_MSPI13' undeclared here (not in a function); did you mean 'AM_HAL_PIN_23_MSPI3'?
  684 |     .uFuncSel            = AM_HAL_PIN_23_MSPI13,
      |                            ^~~~~~~~~~~~~~~~~~~~
      |                            AM_HAL_PIN_23_MSPI3
*** [.pio/build/albambiqdev/Variant/bsp/am_bsp_pins.o] Error 1

It is clearly wrong here. I will try to modify to MSPI3 (which makes more sense when we look at the other similar line around in the file)

I believe your are not using the same branch as me(yours seems to have some fixes):

git clone --recurse-submodules --branch 2.5.1-sfe https://github.com/sparkfun/AmbiqSuiteSDK.git framework-ambiqsuitesdkapollo3-sfe@2.5.1 --depth=1

By the way, I’m using some definition from an example gcc makefile in the example folder, and added them
-DPART_apollo3
-DWSF_TRACE_ENABLED
-DAM_FREERTOS
-DAM_PACKAGE_BGA
-DSEC_ECC_CFG=SEC_ECC_CFG_UECC
-DAM_PART_APOLLO3
-DAM_DEBUG_PRINTF
-Dgcc

It seems that they are not necessary, but I’m not sure.

One last point: in the cflags in ambiqsuitessdk-sfe.py file, there is -std=c99. I need to change that to gnu99 as I use some gnu extentions. Is there a better way that directly modifying this file?

Thanks!

Hi fariouche,

You are correct. Some time in the past I had the same compile error on the ATP and fixed it locally:

~/.platformio/packages/framework-ambiqsuitesdkapollo3-sfe@2.5.1/boards_sfe$ git diff
diff --git a/redboard_artemis_atp/bsp/am_bsp_pins.c b/redboard_artemis_atp/bsp/am_bsp_pins.c
index fab1480..1fae19e 100644
--- a/redboard_artemis_atp/bsp/am_bsp_pins.c
+++ b/redboard_artemis_atp/bsp/am_bsp_pins.c
@@ -681,7 +681,7 @@ const am_hal_gpio_pincfg_t g_AM_BSP_GPIO_MSPI_D2 =
 //*****************************************************************************
 const am_hal_gpio_pincfg_t g_AM_BSP_GPIO_MSPI_D3 =
 {
-    .uFuncSel            = AM_HAL_PIN_23_MSPI13,
+    .uFuncSel            = AM_HAL_PIN_23_MSPI3,
     .eDriveStrength      = AM_HAL_GPIO_PIN_DRIVESTRENGTH_8MA,
     .eIntDir             = AM_HAL_GPIO_PIN_INTDIR_LO2HI,
     .uIOMnum             = 6

As for the defines you mention, if you take a look here you will see that all of them are defined except:

-DSEC_ECC_CFG=SEC_ECC_CFG_UECC

Also, I have added another build option so that in your platform.ini file you can add:

board_build.standard=gnu99

and it passes -std=gnu99 instead of -std=c99 to the compiler.

Not sure this standard change will be passed along to your IDE though.
This board_build option is only available for the ambiqsdk-sfe framework.

These kind of build options are documented here.

Hopefully that does the trick!

Nigel.

Thanks for the option!
I’ve searched in the sdk and find no use of the defines, so I think I can just drop
-DAM_FREERTOS
-Dgcc

Almost there, I’m only missing one function defintion : vApplicationStackOverflowHook.
Should be easy to fix, I will search

Thanks for your help!

I’m progressing, thanks to you nigelb

I’m currently facing a new problem: I’m now implementing the lib/bluetooht to actually call ambiq bluetooth functions.
I’m basing my work on AmbiqSuiteSDK/radio_task.c at master · sparkfun/AmbiqSuiteSDK · GitHub

My new problem is that the dependency cannot find the header file wsf_types.h (or any wsf files)… however I see that cordio-wsf library is here.

To reproduce the issue, just #include “wsf_types.h” in lib/bluetooth/src/ble.c is enough (in my example env above)

Any idea? I feel like I’m almost here :smiley:

Thank

Hi fariouche,

First I had to update the libLDFMode of the cordio-wsf library, so you will need to update platform-apollo3blue again.

Then there are a couple of ways of forcing the dependency to be included:

  1. Add lib_ldf_mode = deep+ to your platformio.ini file. Maybe on of the other modes will work as well.

Or

  1. Add cordio-ws to lib_deps in your platformio.ini file.

Or

  1. Add libLDFMode to lib/bluetooth/library.json
{
    "name": "tst_ble",
    "version": "0.1.0",
    "platforms": "*",
    "frameworks": "*",
    "headers": [
        "include/bluetooth.h"
    ],
    "build": {
        "includeDir": "include",
        "srcFilter": ["+<*>", "-<test/*>"],
        "libLDFMode": "deep+"
    }
}

Or

  1. Add core-wsf as a dependency in lib/bluetooth/library.json:
{
    "name": "tst_ble",
    "version": "0.1.0",
    "platforms": "*",
    "frameworks": "*",
    "headers": [
        "include/bluetooth.h"
    ],
    "dependencies":
    {
            "cordio-wsf": "^0.1"
    },
    "build": {
        "includeDir": "include",
        "srcFilter": ["+<*>", "-<test/*>"]
    }
}

cordio-ws depends on FreeRTOS so you will need to create a FreeRTOSConfig.h in your project’s src directory with the appropriate contents. There are a bunch of FreeRTOS examples in the AmbiqSuiteSDK . Maybe have a look at the FreeRTOS docs. I don’t know anything about FreeRTOS.

Nigel.

Hello,

Just to let you know that I fixed all the issues I had and a at last a linking firmware! Thanks again for your help
Now I just need to read platformio documentation to understand how I can avoid the manual steps of installing the framework as it is not in the platformio registry yet

Hello again,

No quite finished for me… So I received my board, an official apollo3 evb board (not sparkfun).
So I had to change the upload protocol to jlink as this board does not have svl or asb, but official sbl bootloader. (and running the target svl_bootloader did nothing.)
No big deal, I updated the linker script asb_svl_linker.ld to set the start address to 0xc000 (as the svl linker script is hardcoded when using jlink protocol), changed the upload address to 0xC000 … upload and … nothing
I’ve updated the main in my test example above to be the stimer.c one in the ambiqSuiteSDK. (AmbiqSuiteSDK/stimer.c at 2.5.1-sfe · sparkfun/AmbiqSuiteSDK · GitHub)

I can see that the program is running and is in the while loop doing deep sleep calls, but the LEDs are not blinking (flashing the provided binary image at address 0xC000 works, AmbiqSuiteSDK/stimer.bin at 2.5.1-sfe · sparkfun/AmbiqSuiteSDK · GitHub)

So, to be sure: I only need to set my own linker script (here based on the svl one with changed address) and the upload address, and I should be good, right? Did I miss something? (I also tried to set lib_archive to false to be sure that it is not a weak symbol issue)

I continue to dig inside the board definition (maybe the GPIO definitions are not correct)
I see a script named board_file_generator.py… seems like I can try to generate a proper board for my evb kit