Problems running mbed-os-example-lorawan on SFE_ARTEMIS_THING_PLUS Target

Hello,

I am trying to get the mbed-os-example-lorawan to run on the SparkFun LoRa Thing Plus.

The SparkFun LoRa Thing Plus is based on the NM180100 system in package which consists of an SX1262 LoRa Modem and the Ambiq Apollo 3.

The Board is very similiar to the SparkFun Artemis Thing Plus, except for the LoRa Modem. I want to use the “SFE_ARTEMIS_THING_PLUS” Target (should I rather create a new target?), therefore I added the LoRa Modem Pin Connections at

 \mbed-os\targets\TARGET_Ambiq_Micro\TARGET_Apollo3\TARGET_SFE_ARTEMIS_THING_PLUS\PinNames.h

according to the NM180100 Datasheet :

    //SX1262 LoRa Interface Pins (Added by me)
	LORA_MOSI = 38,
	LORA_MISO = 43,
	LORA_SCK = 42,
	LORA_NSS = 36,
	LORA_RESET = 44,
	LORA_BUSY = 39,
	LORA_DIO1 = 40,
	LORA_DIO3 = 47,

I have imported the mbed-os-example-lorawan github repository to my workspace with a new mbed os instance and added my board to the mbed_app.json file:

        },
            "SFE_ARTEMIS_THING_PLUS": {
            "target.components_add":            ["SX126X"],
            "SX126X-lora-driver.spi-mosi":       "LORA_MOSI",
            "SX126X-lora-driver.spi-miso":       "LORA_MISO",
            "SX126X-lora-driver.spi-sclk":       "LORA_SCK",
            "SX126X-lora-driver.spi-cs":         "LORA_NSS",
            "SX126X-lora-driver.reset":          "LORA_RESET",
            "SX126X-lora-driver.dio1":           "LORA_DIO1",
            "SX126X-lora-driver.busy":           "LORA_BUSY"
        }

Unfortunately I am getting the following compiler error:

[Error] SX126X_LoRaRadio.h@310,11: no type named 'AnalogIn' in namespace 'mbed'
[Error] SX126X_LoRaRadio.h@313,11: no type named 'AnalogIn' in namespace 'mbed'
[Error] main.cpp@83,25: no matching constructor for initialization of 'LoRaWANInterface'
[Warning] main.cpp@180,26: 'call_in' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
[Warning] main.cpp@180,26: 'call_in<void (*)()>' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
[Warning] main.cpp@224,26: 'call_every' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
[Warning] main.cpp@224,26: 'call_every<void (*)()>' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
[ERROR] In file included from .\main.cpp:26:
In file included from ./lora_radio_helper.h:66:
./mbed-os/connectivity/drivers/lora/COMPONENT_SX126X\SX126X_LoRaRadio.h:310:11: error: no type named 'AnalogIn' in namespace 'mbed'
mbed::AnalogIn _freq_select;
~~~~~~^
./mbed-os/connectivity/drivers/lora/COMPONENT_SX126X\SX126X_LoRaRadio.h:313:11: error: no type named 'AnalogIn' in namespace 'mbed'
mbed::AnalogIn _dev_select;
~~~~~~^
.\main.cpp:83:25: error: no matching constructor for initialization of 'LoRaWANInterface'
static LoRaWANInterface lorawan(radio);
^       ~~~~~
./mbed-os/connectivity/lorawan/include\lorawan/LoRaWANInterface.h:39:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'SX126X_LoRaRadio' to 'const LoRaWANInterface' for 1st argument
class LoRaWANInterface {
^
./mbed-os/connectivity/lorawan/include\lorawan/LoRaWANInterface.h:52:5: note: candidate constructor not viable: no known conversion from 'SX126X_LoRaRadio' to 'LoRaRadio &' for 1st argument
LoRaWANInterface(LoRaRadio &radio);
^
./mbed-os/connectivity/lorawan/include\lorawan/LoRaWANInterface.h:59:5: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
LoRaWANInterface(LoRaRadio &radio, LoRaPHY &phy);
^
.\main.cpp:180:26: warning: 'call_in' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
ev_queue.call_in(3000, send_message);
^
./mbed-os/events/include\events/EventQueue.h:926:9: note: 'call_in' has been explicitly marked deprecated here
int call_in(int ms, F f)
^
.\main.cpp:180:26: warning: 'call_in<void (*)()>' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
ev_queue.call_in(3000, send_message);
^
./mbed-os/events/include\events/EventQueue.h:925:5: note: 'call_in<void (*)()>' has been explicitly marked deprecated here
MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`.")
^
./mbed-os/platform/include\platform/mbed_toolchain.h:424:37: note: expanded from macro 'MBED_DEPRECATED_SINCE'
#define MBED_DEPRECATED_SINCE(D, M) MBED_DEPRECATED(M " [since " D "]")
^
./mbed-os/platform/include\platform/mbed_toolchain.h:405:43: note: expanded from macro 'MBED_DEPRECATED'
#define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
^
.\main.cpp:224:26: warning: 'call_every' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
ev_queue.call_every(TX_TIMER, send_message);
^
./mbed-os/events/include\events/EventQueue.h:1083:9: note: 'call_every' has been explicitly marked deprecated here
int call_every(int ms, F f)
^
.\main.cpp:224:26: warning: 'call_every<void (*)()>' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
ev_queue.call_every(TX_TIMER, send_message);
^
./mbed-os/events/include\events/EventQueue.h:1082:5: note: 'call_every<void (*)()>' has been explicitly marked deprecated here
MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`.")
^
./mbed-os/platform/include\platform/mbed_toolchain.h:424:37: note: expanded from macro 'MBED_DEPRECATED_SINCE'
#define MBED_DEPRECATED_SINCE(D, M) MBED_DEPRECATED(M " [since " D "]")
^
./mbed-os/platform/include\platform/mbed_toolchain.h:405:43: note: expanded from macro 'MBED_DEPRECATED'
#define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
^
4 warnings and 3 errors generated.

I am suspecting the DEVICE_ANALOGIN Flag to not be set. The code compiles if I choose one of the other targets listed at mbed_app.json. Where would this flag be set? Why isnt’t it? Is AnalogIn not supported with the SFE_ARTEMIS_THING_PLUS Target? Where could I check if this is the case?

Thanks in advance :smiley:

i notice two things

First, you must define pins as defined in header file: mbed-os/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS_THING_PLUS/ PinNames.h, with particular attention to SPI_* pins.

Second, i look at apollo3 drivers in mbed-os, and i dont see any ADC support (analogin support). The only analog pins in sx126x header are for frequency select and device select, so perhaps you can change those to digitalIn.

Hey, thanks for your answer!

I have checked my Pin definitions at mbed-os/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS_THING_PLUS/PinNames.h and adjusted them:

    //SX1262 LoRa Interface Pins (Added by me)
	LORA_MOSI = AM_BSP_LORA_SPI_SDI_PIN,
	LORA_MISO = AM_BSP_LORA_SPI_SDO_PIN,
	LORA_SCK = AM_BSP_LORA_SPI_CLK_PIN,
	LORA_NSS = 36,
	LORA_RESET = 44,
	LORA_BUSY = 39,
	LORA_DIO1 = 40,
	LORA_DIO3 = 47,

The AM_BSP_LORA_SPI_* Pins are defined here: mbed-os/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS_THING_PLUS/bsp/am_bsp.h

I added them like this:

//*****************************************************************************
//
// SX1262 connected SPI Pins
//
//*****************************************************************************
#define AM_BSP_LORA_SPI_IOM                 3
#define AM_BSP_LORA_SPI_CLK_PIN             AM_BSP_GPIO_IOM3_SCK
#define AM_BSP_LORA_SPI_SDO_PIN             AM_BSP_GPIO_IOM3_MOSI
#define AM_BSP_LORA_SPI_SDI_PIN             AM_BSP_GPIO_IOM3_MISO
#define g_AM_BSP_LORA_SPI_CLK               g_AM_BSP_GPIO_IOM3_SCK
#define g_AM_BSP_LORA_SPI_SDO               g_AM_BSP_GPIO_IOM3_SDO
#define g_AM_BSP_LORA_SPI_SDI               g_AM_BSP_GPIO_IOM3_SDI

The AM_BSP_GPIO_IOM3_* Pin and gpio_pincfg Definitions are provided by the Ambiq Hal Layer at
mbed-os/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS_THING_PLUS/bsp/am_bsp_pins.h

Did I set up my Pin Definitions and the SPI correctly?


Additionally, I managed to get rid of the compiler error by changing the AnalogIn Pins to DigitalIn and commenting out the .read_u16() calls on those pins in the SX126X Driver. Those pins arent available on my target anyways.

I can upload the binary now, but unfortunately the program is still not running. My Gateway is not picking up any LoRa traffic. I dont now yet how to debug the application, is it possible to receive the printf() strings through UART? There is no Debugger connected, I am just uploading the binarys via the UART Bootloader.

Thie following message is thrown by the compiler after linking:

Object file timing.o is not unique! It could be made from: mbed-os\connectivity\mbedtls\platform\src\timing.cpp mbed-os\connectivity\mbedtls\source\timing.c

Why does this source file exist twice? Is the created binary intact?