XIAO 52840 as BLE GATT Board

Description

I want to connect the XIAO 52840 board as a client to the bluetooth gateway I have (nrf9160/52840 dev board). What overlays or files do I need to make this work. Do I need to use a particular version of the nrf connect sdk?

Expected Behavior

I would like to get the pouch repo code to run on the XIAO 52840 board.

Actual Behavior

I got a project to build but I don’t think I have the memory space setup correctly because when I move the file over the board resets but then nothing happens.

Environment

Currently trying nrf sdk 2.9.1.

Logs and Console Output

/*

  • Partition overlay for Seeed XIAO BLE (nRF52840)
    */
    / {
    chosen {
    zephyr,code-partition = &slot0_partition;
    };
    };

&flash0 {
partitions {
// Remove default partition if present
/delete-node/ partition@0;

    slot0_partition: partition@0 {
        label = "slot0_partition";
        reg = <0x00000000 0x0007D000>; // 240 KB for slot0
    };

    slot1_partition: partition@7d000 {
        label = "slot1_partition";
        reg = <0x0007D000 0x0007D000>; // 240 KB for slot1
    };

Hey @wischmi2,

Are you trying to build the ble_gatt example from pouch repository, or working on your own project? The pouch repo is set up for NCS v3.0.1, as you can see in the west-ncs.yml file.

For the ble_gatt example, I don’t think you need any special overlay changes. I’ve successfully built and used it on Adafruit nRF52840 Feather board without modifying the example.

If you haven’t already, I’d suggest starting directly with the ble_gatt example, using the Pouch repo as your manifest and initializing with west-ncs.yml. After that, try building it for the XIAO board.

I’ll order a couple of XIAO boards myself so I can test it hands-on.

Yes, I’m using the ble_gatt example.

What does “initializing with west-ncs.yml” mean? Could you point me in the direction of some documentation?

So, what we want to do is create a fresh Zephyr workspace using the pouch repo as the west manifest , pull dependencies, set up Python tools and the build the example.

Below is a clean setup that pins the right NCS via west-ncs.yml:

  1. Create new workspace directory:
mkdir ~/pouch-env
  1. Create and activate a new virtual environment:
python -m venv ~/pouch-env/.venv
source ~/pouch-env/.venv/bin/activate
  1. Use pip to install west (beginning with the wheel dependency):
 pip install wheel west
  1. Use the pouch repo as the manifest:
west init -m https://github.com/golioth/pouch --mf west-ncs.yml ~/pouch-env
cd pouch-env
west update
pip install -r zephyr/scripts/requirements.txt
pip install -r pouch/requirements.txt
west zephyr-export

The xiao_ble ships with the Adafruit nRF52 bootloader, which supports flashing via UF2. Since it uses the Adafruit bootloader and not MCUboot (as the pouch example expects), you would need to reflash the board with MCUboot over SWD/JTAG if you want OTA updates through Golioth. Depending on the DTS files for the xiao_ble board, an overlay may also be needed to adjust the memory layout as in the your earlier post. How are you flashing the device and what image are you using?

I wasn’t aware it ships with the Adafruit bootloader instead of MCUboot, so I’ll test further once my boards arrive. If you figure it out before then, please share so others can benefit.

Thanks for the update. A few questions…

The west init sets up the zephyr workspace using west-ncs.yml to tell it what other repositories it needs correct?

After that you run west update to download all the packages that are contained in the west-ncs.yml. Why do you need a west.yml in the pouch repo?

Why do you need to do installs of the requirements files for both zephyr and pouch?

When I go to open the application in visual studio and I want to add build configuration it says you have to update the west workspace before you create a build? I don’t understand why that is?

Starting with “The xiao-ble ships” on downwards I’m lost. I know I have to build a file that I can drag over and drop in the xiao-ble folder when its in bootloader mode. What hardware do I need to flash with mcuboot over swd/jtag , a dev kit like 9160? I wouldn’t know where to start with a memory layout. Perhaps I’ll wait until you can get the hardware and tell me how you did it?

Thanks again!

One more question, is there a good source of training info on this. I have to say I have been trying to use Zephyr for years and I know there is info on the Zephyr website, nrf website, etc but none of it really does a good job in explaining how to go step by step of doing a build like this.

Hey @wischmi2, I see where you’re coming from. Let’s break it down and go through your questions one by one:

The west init sets up the zephyr workspace using west-ncs.yml to tell it what other repositories it needs correct?

When you do west init -m <manifest-repo>, you’re basically telling west where to find the manifest file, and the manifest file describes:

  • Which repositories are needed (Zephyr, nrfxlib, mcuboot, etc.)
  • Which revisions/branches of those repos should be checked out
  • How they’re layered together in the workspace

After west init you run west update, which pulls down all of those repos at the correct revisions and sets up the workspace.

So yes: west-ncs.yml is what drives which extra repos get cloned/managed for your Zephyr/NCS environment.

After that you run west update to download all the packages that are contained in the west-ncs.yml. Why do you need a west.yml in the pouch repo?

West uses one active manifest per workspace. In the pouch repo you can pick which “base” you want, so you can use west-ncs.yml which pulls the NCS stack (nRF Connect SDK) or you can use west.yml which pulls the vanilla Zephyr. Zephyr is the upstream open source RTOS project, maintained by the Zephyr Project under the Linux Foundation. NCS is Nordic’s “distribution” (or downstream) of Zephyr. It takes Zephyr as a module, then layers on their own closed or open source libraries for Bluetooth controller, LTE modem and so on. Therefore, you can build pouch repo using NCS or vanilla Zephyr. We are using NCS because of cryptography libraries available in NCS which speeds up the end-to end-encryption pouch offers.

Why do you need to do installs of the requirements files for both zephyr and pouch?

In short, both Zephyr and pouch have their own Python tooling requirements. For example, Pouch specifically depends on the zcbor package, which it uses to handle CBOR encoding of payloads sent to the cloud.

When I go to open the application in visual studio and I want to add build configuration it says you have to update the west workspace before you create a build? I don’t understand why that is?

I don’t personally use Visual Studio, so I might be slightly off here, but it looks like you need to run west update in the VS terminal to fetch all the dependencies listed in the manifest file. Keep in mind that whenever the manifest file changes, you need to run west update again to make sure everything is downloaded and up to date. In your case, it’s possible the workspace hasn’t been updated yet, or that some of the required repos are missing or checked out at the wrong revision.

Starting with “The xiao-ble ships” on downwards I’m lost. I know I have to build a file that I can drag over and drop in the xiao-ble folder when its in bootloader mode. What hardware do I need to flash with mcuboot over swd/jtag , a dev kit like 9160? I wouldn’t know where to start with a memory layout. Perhaps I’ll wait until you can get the hardware and tell me how you did it?

Check out the Zephyr docs for UF2 Flashing and External debugger. It should work with the nRF9160 DK as it has Segger J-Link on-board for programming external targets.

Additionally, we host Zephyr training sessions once a quarter, in fact, we just had one yesterday. You can go through the material yourself at any time using our Zephyr training docs. Also, if you’d like a deeper dive into manifest files, Mike Szczys gave a talk on the topic a couple of years ago, which you can check out here. I am also of the opinion that our blog is a great starting point for getting to grips with Zephyr. It helps you build a solid understanding of the basics, which then makes it easier to dive deeper and explore the official Zephyr docs.

Excellent, thank you for the thorough explanation. I was actually watching the talk that Mike gave the day before and it was very good. I appreciate all the info you have given me. I would still like it if you would let me know what you find out when your hardware arrives and I will do the same if I get my setup working.

Thanks again!

I finally got something working with this (thank you AI). Well, I walked away for a while and came back to it recently. I had AI help me with the code and part of the issue was getting it built in such a way that it would fit on the onboard flash. It actually set it up to where the onboard flash had slot0 and the external flash had slot1 and the /lfs1 storage area. I almost have the pouch server/client running. I have gateway as my nrf9160dk and the xiao 52840 as my pouch client. They are talking but I’m having an issue with certificates right now. I generated certs for the xiao but used psks for my 9160. I’m wondering if somehow that is the issue. Just wanted to give an update on this problem.

1 Like

Hey @wischmi2,

Using certificates on the BLE leaf node and PSK on the nRF9160 DK acting as a gateway is totally fine. You can always switch the gateway over to certificates later if needed.

What kind of issues are you running into?

Also, not sure if you’ve seen it yet, but you can now generate certificates directly in the console; it’s about as straightforward as it gets. There’s a blog post that walks through it step by step.

Well right now I’m having an issue with the gateway I can’t seem to get fixed. Here is the terminal output.

[00:12:06.850,677] scan: Scanning successfully started
[00:12:07.951,446] main: Connected: CD:0C:F3:59:5C:32 (random)
[00:12:37.952,026] bt_smp: SMP Timeout
[00:12:37.952,117] main: BT security change failed. Current level: 1, err: BT_SECURITY_ERR_UNSPECIFIED(9)
[00:12:37.955,810] main: Pairing Failed (9). Disconnecting.
[00:12:38.056,091] main: Disconnected: CD:0C:F3:59:5C:32 (random), reason 0x16
[00:12:38.067,535] scan: Scanning successfully started
[00:12:39.274,597] main: Connected: CD:0C:F3:59:5C:32 (random)
[00:13:09.275,207] bt_smp: SMP Timeout
[00:13:09.275,299] main: BT security change failed. Current level: 1, err: BT_SECURITY_ERR_UNSPECIFIED(9)
[00:13:09.276,672] main: Pairing Failed (9). Disconnecting.
[00:13:09.329,284] main: Disconnected: CD:0C:F3:59:5C:32 (random), reason 0x16
[00:13:09.340,820] scan: Scanning successfully started
[00:13:10.658,386] main: Connected: CD:0C:F3:59:5C:32 (random)

I’ve been trying to get AI to assist but it isn’t coming up with anything that is working.

Hi @wischmi2. Which revisions (commit hash) of the gateway and pouch repositories are you using? You’re using the nrf9160dk as the gateway, correct?

Yes, I’m using the nrf9160dk for my gateway.

I’m using a Xiao nrf52840 for my node.

Node software is 33fab68, looks like next to latest.

Gateway software is 9008762.

I’m using 3.1.0 zephyr.

Adding to this issue, here are the recent logs. From gateway:

*** Booting nRF Connect SDK v3.1.1-e2a97fe2578a ***
*** Using Zephyr OS v4.1.99-ff8f0c579eeb ***
*** Golioth Firmware SDK v0.21.1-25-g60f0e8ab323b ***
[00:00:00.508,666] golioth_settings_autoload: Initializing settings subsystem
[00:00:00.508,972] golioth_settings_autoload: Loading settings
[00:00:00.509,460] main: Gateway Version: “v0.2.0-54-g9008762-dirty”
[00:00:00.509,490] main: Pouch BLE Transport Protocol Version: 1
[00:00:00.509,521] main: Set up button at gpio@842500 pin 6
[00:00:00.509,552] main: Connecting to LTE, this may take some time…
[00:00:02.225,158] lte_monitor: Network: Searching
[00:00:04.008,941] lte_monitor: Network: Registered (roaming)
[00:00:04.010,437] nrf_modem_lib_netif: MTU query failed, error: 0, MTU: 0
[00:00:04.010,925] golioth_mbox: Mbox created, bufsize: 1320, num_items: 10, item_size: 120
[00:00:05.247,528] golioth_coap_client_zephyr: Golioth CoAP client connected
[00:00:05.248,046] main: Golioth client connected
[00:00:05.248,077] golioth_coap_client_zephyr: Entering CoAP I/O loop
[00:00:06.728,179] bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:06.728,210] bt_hci_core: HW Variant: nRF52x (0x0002)
[00:00:06.728,240] bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 252.16862 Build 1121034987
[00:00:06.735,504] bt_hci_core: HCI transport: H:4
[00:00:06.735,687] bt_hci_core: Identity: E6:4B:25:B3:45:87 (random)
[00:00:06.735,717] bt_hci_core: HCI: version 6.1 (0x0f) revision 0x1069, manufacturer 0x0059
[00:00:06.735,748] bt_hci_core: LMP: version 6.1 (0x0f) subver 0x1069
[00:00:06.735,748] main: Bluetooth initialized
[00:00:06.736,480] bt_ecc: Failed to generate ECC key -134
[00:00:06.736,480] bt_smp: Public key not available
[00:00:06.740,783] scan: Scanning successfully started
[00:00:06.919,647] main: Connected: CD:0C:F3:59:5C:32 (random)
[00:00:36.920,227] bt_smp: SMP Timeout
[00:00:36.920,318] main: BT security change failed. Current level: 1, err: BT_SECURITY_ERR_UNSPECIFIED(9)
[00:00:36.924,011] main: Pairing Failed (9). Disconnecting.
[00:00:36.974,731] main: Disconnected: CD:0C:F3:59:5C:32 (random), reason 0x16
[00:00:36.983,489] scan: Scanning successfully started
[00:00:38.087,890] main: Connected: CD:0C:F3:59:5C:32 (random)
[00:00:38.339,752] bt_conn: conn 0x2000e078 failed to establish. RF noise?
[00:00:38.339,965] main: BT security change failed. Current level: 1, err: BT_SECURITY_ERR_UNSPECIFIED(9)
[00:00:38.340,026] main: Pairing Failed (9). Disconnecting.
[00:00:38.340,118] bt_gatt: conn 0x2000e078 err 0x0e
[00:00:38.340,362] main: Disconnected: CD:0C:F3:59:5C:32 (random), reason 0x3e
[00:00:38.345,489] scan: Scanning successfully started
[00:00:38.617,156] main: Connected: CD:0C:F3:59:5C:32 (random)
[00:01:08.617,706] bt_smp: SMP Timeout
[00:01:08.617,797] main: BT security change failed. Current level: 1, err: BT_SECURITY_ERR_UNSPECIFIED(9)
[00:01:08.619,201] main: Pairing Failed (9). Disconnecting.
[00:01:09.021,850] main: Disconnected: CD:0C:F3:59:5C:32 (random), reason 0x22
[00:01:09.033,264] scan: Scanning successfully started
[00:01:09.789,520] main: Connected: CD:0C:F3:59:5C:32 (random)

From pouch node:

[00:00:00.003,692] littlefs: littlefs partition at /lfs1
[00:00:00.003,692] littlefs: LittleFS version 2.11, disk version 2.1
[00:00:00.003,906] littlefs: FS at flash-controller@4001e000:0xf5000 is 7 0x1000-byte blocks with 512 cycle
[00:00:00.003,936] littlefs: partition sizes: rd 16 ; pr 16 ; ca 64 ; la 32
[00:00:00.005,035] littlefs: Automount /lfs1 succeeded
*** Booting Pouch BLE GATT Example v1.0.0-33fab68b7713 ***
*** Using nRF Connect SDK v3.1.1-e2a97fe2578a ***
*** Using Zephyr OS v4.1.99-ff8f0c579eeb ***
[00:00:00.005,676] main: Pouch SDK Version: v0.1.0-22-g33fab68b7713
[00:00:00.005,706] main: Pouch Protocol Version: 1
[00:00:00.005,706] main: Pouch BLE Transport Protocol Version: 1
[00:00:00.006,286] bt_sdc_hci_driver: SoftDevice Controller build revision:
fc de 41 eb a2 d1 42 24 00 b5 f8 57 9f ac 9d 9e |..A…B$ …W…
aa c9 b4 34 |…4
[00:00:00.009,277] bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.009,307] bt_hci_core: HW Variant: nRF52x (0x0002)
[00:00:00.009,338] bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 252.16862 Build 1121034987
[00:00:20.017,333] main: Sync request flag set in advertisement
[00:00:27.951,110] main: Connected
[00:00:58.003,234] main: Disconnected (reason 0x13)
[00:00:59.647,521] main: Connected
uart:~$

What is the “bt_ecc: Failed to generate ECC key -134” error? This seems to be the issue.

Hey @wischmi2. You’re a bit ahead of our most recent official release, which is v0.2.0 for the gateway and v0.1.0 for the node. The failure to generate the ECC key is certainly the issue here - we’ve run into some resource constraints on the 9160dk with some under development features that we’re still working through before our next release.

In the meantime, I recommend that you use 0aea0d2e in the pouch-gateway repository and 0d37e582 in the pouch repo. Alternatively, you could use a different target for the Gateway. The NXP FRDM-RW612 works well and is pretty affordable. Either way, we should have new releases in the next several weeks, and those release will restore functionality for the 9160dk as the Gateway.

Best,
Sam

Well I’m getting closer. I got the nrf9160 to at least show a network in golioth but I keep getting the lpuart error?

[00:00:07.233,001] bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:07.233,032] bt_hci_core: HW Variant: nRF52x (0x0002)
[00:00:07.233,062] bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 137.20634 Build 2617349514
[00:00:07.241,333] bt_hci_core: Identity: E6:4B:25:B3:45:87 (random)
[00:00:07.241,363] bt_hci_core: HCI: version 6.0 (0x0e) revision 0x10f3, manufacturer 0x0059
[00:00:07.241,394] bt_hci_core: LMP: version 6.0 (0x0e) subver 0x10f3
[00:00:07.241,394] main: Bluetooth initialized
[00:00:07.247,314] scan: Scanning successfully started
[00:00:07.378,814] connect: Connected: CD:0C:F3:59:5C:32 (random)
[00:00:09.784,271] lpuart: Rx disable failed.
[00:00:09.787,872] lpuart: Rx disable failed.
[00:00:09.882,049] lpuart: Rx disable failed.
[00:00:10.322,296] downlink: Starting downlink
[00:00:10.380,096] uplink_gatt: [READ] BLE GATT Uplink
01 |.
[00:00:10.481,658] lpuart: Rx disable failed.
[00:00:10.482,391] uplink_gatt: [READ] BLE GATT Uplink
02 82 01 83 01 85 81 50 cb 6a 98 17 ab e9 6e a5 |…P .j…n.
82 f9 68 08 f5 96 60 b2 00 01 09 46 17 ea b3 90 |..h…. ...F.... 96 d0 01 00 6c 10 fe e4 2e ec 86 12 3c 41 a1 07 |....l... ....<A.. 46 ed b5 17 6c d4 d3 5d be 21 9f 42 c1 6e a4 8e |F...l..] .!.B.n.. 7b ac 27 3a 85 a1 ae 2a 2e c4 a1 8f f1 6a c2 58 |{.':...* .....j.X 69 a2 c6 cb cb b8 44 c6 f9 0f 5e 2f d1 f6 02 16 |i.....D. ..^/.... 69 5e ff fa 14 3d 97 88 8a 4c 7c e8 8d a5 89 27 |i^...=.. .L|....' 9f c7 d2 d5 35 3c da 1f 61 a7 14 0f 0e 57 a4 1c |....5<.. a....W.. c8 ea bb 96 6f 80 29 c6 86 5f 5d a8 4b 8a bc ec |....o.). ._].K... 07 |. [00:00:14.257,049] <wrn> golioth_zephyr_coap_req: 1 resends in last 10 seconds [00:00:14.780,426] <inf> connect: Disconnected: CD:0C:F3:59:5C:32 (random), reason 0x16 [00:00:14.786,285] <inf> scan: Scanning successfully started [00:00:30.554,992] <inf> connect: Connected: CD:0C:F3:59:5C:32 (random) [00:00:33.010,467] <err> lpuart: Rx disable failed. [00:00:33.014,038] <err> lpuart: Rx disable failed. [00:00:33.109,985] <err> lpuart: Rx disable failed. [00:00:33.522,064] <inf> downlink: Starting downlink [00:00:33.606,262] <inf> uplink_gatt: [READ] BLE GATT Uplink 01 |. [00:00:33.707,824] <err> lpuart: Rx disable failed. [00:00:33.708,557] <inf> uplink_gatt: [READ] BLE GATT Uplink 02 82 01 83 01 85 81 50 3f 66 f6 46 85 a7 b0 2f |.......P ?f.F.../ ab df c0 0f d2 f6 48 17 00 01 09 46 17 ea b3 90 |......H. ...F.... 96 d0 01 00 6c fc 39 1a 2b 64 35 b7 55 43 c3 d5 |....l.9. +d5.UC.. ec 96 33 c6 0a 48 ea 26 ff 22 13 0b 15 52 6c b3 |..3..H.& ."...Rl. 19 e6 0c 62 17 7f 52 0f f9 e3 24 21 9f 2e 02 dd |...b..R. ..$!.... d3 64 7a fc 14 09 c8 6c d4 74 ef 33 24 86 98 f7 |.dz....l .t.3$... 03 37 30 ca c4 37 4f 84 96 67 28 d5 cb a5 bd f3 |.70..7O. .g(..... 9f c7 26 1f b4 16 da e7 db 29 1e 73 4b ca 3c f4 |..&..... .).sK.<. 00 3d d8 60 50 0b 6d 55 54 23 43 02 a9 12 f7 80 |.=.P.mU T#C…
96 |.
[00:00:36.256,530] connect: Disconnected: CD:0C:F3:59:5C:32 (random), reason 0x16
[00:00:36.262,390] scan: Scanning successfully started

OK, so I ordered the NXP hardware, I get it in and flash the .hex file for the ethernet. I plug it into the network and it says to save the golioth settings, psk-id and psk. Whenever i try to do those commands it says it fails to save them!!!

uart:~$ settings set golioth/psk-id nxp_rw612@emerald-mature-damselfly
Setting golioth/psk-id to nxp_rw612@emerald-mature-damselfly
Failed to save setting golioth/psk-id:nxp_rw612@emerald-mature-damselfly
uart:~$

i mean why is this stuff soooo difficult??

@wischmi2 can you try erasing the flash, then reprogramming the device and trying to set the credentials again? Let us know if that still doesn’t work for you.