Edge Impulse integration in nRF Connect SDK

Question/Issue:

I am using the nRF Connect SDK to develop an application on a nrf52840 based board. I wanted to take advantage of the Edge Impulse integration of the SDK to use an impulse. When I manually download the zip file from my Edge Impulse project and specify its location using the CONFIG_EDGE_IMPULSE_URI it works fine.

I now want to be able to download my Edge Impulse private project automatically, which seems possible according to the documentation (https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/external_comp/edge_impulse.html#downloading_from_a_private_project), but I cannot get it to work.
I follow the documentation’s steps regarding CONFIG_EDGE_IMPULSE_URI, and I build my application with west build -b my_board -p=always my_app – -DEI_API_KEY_HEADER=“x-api-key:my_key”, but I get the following error:

[243/333] Performing download step (download, verify and extract) for ‘edge_impulse_project’
FAILED: edge_impulse/src/edge_impulse_project-stamp/edge_impulse_project-download C:/Users/nicol/Documents/xiao-ble-lsm6dsv16x/xiao-ble-lsm6dsv16x.git/build/edge_impulse/src/edge_impulse_project-stamp/edge_impulse_project-download
C:\WINDOWS\system32\cmd.exe /C “cd /D C:\Users\nicol\Documents\xiao-ble-lsm6dsv16x\xiao-ble-lsm6dsv16x.git\build\edge_impulse\src && “C:\Program Files\CMake\bin\cmake.exe” -P C:/Users/nicol/Documents/xiao-ble-lsm6dsv16x/xiao-ble-lsm6dsv16x.git/build/edge_impulse/src/edge_impulse_project-stamp/download-edge_impulse_project.cmake && “C:\Program Files\CMake\bin\cmake.exe” -P C:/Users/nicol/Documents/xiao-ble-lsm6dsv16x/xiao-ble-lsm6dsv16x.git/build/edge_impulse/src/edge_impulse_project-stamp/verify-edge_impulse_project.cmake && “C:\Program Files\CMake\bin\cmake.exe” -P C:/Users/nicol/Documents/xiao-ble-lsm6dsv16x/xiao-ble-lsm6dsv16x.git/build/edge_impulse/src/edge_impulse_project-stamp/extract-edge_impulse_project.cmake && “C:\Program Files\CMake\bin\cmake.exe” -E touch C:/Users/nicol/Documents/xiao-ble-lsm6dsv16x/xiao-ble-lsm6dsv16x.git/build/edge_impulse/src/edge_impulse_project-stamp/edge_impulse_project-download”
– Downloading…
dst=‘C:/Users/nicol/Documents/xiao-ble-lsm6dsv16x/xiao-ble-lsm6dsv16x.git/build/edge_impulse/src/edge_impulse_src.zip’
timeout=‘none’
inactivity timeout=‘none’
– Using src=‘studio.edgeimpulse com/v1/api/510245/deployment/download?type=zip’
CMake Error at edge_impulse_project-stamp/download-edge_impulse_project.cmake:163 (message):
Each download failed!

error: downloading 'https://studio.edgeimpulse.com/v1/api/510245/deployment/download?type=zip' failed
      status_code: 22
      status_string: "HTTP response code said error"
      log:
      --- LOG BEGIN ---
      timeout on name lookup is not supported

Host studio.edgeimpulse com:443 was resolved.

IPv6: (none)

IPv4: 18.244.28.46, 18.244.28.102, 18.244.28.106, 18.244.28.88

Trying 18.244.28.46:443...

Connected to studio.edgeimpulse com (18.244.28.46) port 443

schannel: disabled automatic use of client certificate

ALPN: curl offers h2,http/1.1

schannel: connection hostname (studio edgeimpulse com) validated against
certificate name (*.edgeimpulse com)

ALPN: server accepted h2

using HTTP/2

[HTTP/2] [1] OPENED stream for
studio edgeimpulse com/v1/api/510245/deployment/download?type=zip

[HTTP/2] [1] [:method: GET]

[HTTP/2] [1] [:scheme: https]

[HTTP/2] [1] [:authority: studio edgeimpulse com]

[HTTP/2] [1] [:path: /v1/api/510245/deployment/download?type=zip]

[HTTP/2] [1] [user-agent: curl/8.6.0]

[HTTP/2] [1] [accept: application/zip]

GET /v1/api/510245/deployment/download?type=zip HTTP/2

Host: studio edgeimpulse com

User-Agent: curl/8.6.0

Accept: application/zip

schannel: remote party requests renegotiation

schannel: renegotiating SSL/TLS connection

schannel: connection hostname (studio edgeimpulse com) validated against
certificate name (*.edgeimpulse.com)

schannel: SSL/TLS connection renegotiated

HTTP/2 401

content-type: application/json; charset=utf-8

date: Sat, 05 Oct 2024 12:46:11 GMT

set-cookie: x-xsrf-token=VFCnmKdE%2BnKUbvMFthbFRw%3D%3D; Path=/; HttpOnly;
Secure; SameSite=Strict

set-cookie:
connect.sid=s%3A0_HrjCo5fJILXd7JBDWr_AAYRr6wtqMo.%2FlzkEnnajXnmfoBtzJ6VLSbEyCUTXhhLIIU6veR6AgQ;
Path=/; HttpOnly; Secure

access-control-allow-origin: *

content-security-policy: default-src ‘self’ blob: edgeimpulse com
*.edgeimpulse com ; img-src ‘self’ ‘unsafe-inline’ edgeimpulse com
*.edgeimpulse com *.google-analytics com *.googletagmanager com data:
usercdn edgeimpulse com ; media-src ‘self’ edgeimpulse com
*.edgeimpulse com blob: data: mediastream://studio.edgeimpulse com;
script-src ‘self’ ‘nonce-s9H2VSC8ygpLBJfSnpzwSQ==’ edgeimpulse com
*.edgeimpulse.com *.hsforms.net *.hsforms.com *.google-analytics com
fonts googleapis com youtube com *.youtube com browser.sentry-cdn com
js.sentry-cdn com *.sentry.io *.googletagmanager.com d3js org blob:;
connect-src ‘self’ edgeimpulse com *.edgeimpulse.com *.google-analytics com
*.hsforms.net *.hsforms.com *.amazonaws.com *.googleapis com
fonts googleapis com sentry io *.sentry.io youtube com *.youtube com
*.doubleclick.net *.amplitude.com localhost:4800 localhost:4810
host.docker.internal:4810 host.docker.internal:9001
wss://studio.edgeimpulse.com wss://remote-mgmt.edgeimpulse.com ; style-src
‘self’ ‘unsafe-inline’ edgeimpulse com *.edgeimpulse com
fonts googleapis com; base-uri ‘self’ edgeimpulse com *.edgeimpulse.com;
frame-ancestors ‘self’ edgeimpulse com *.edgeimpulse.com; form-action
‘self’ edgeimpulse com *.edgeimpulse com; frame-src ‘self’ edgeimpulse com
*.edgeimpulse.com youtube com *.youtube com *.googletagmanager.com
localhost:4820; font-src ‘self’ edgeimpulse com *.edgeimpulse.com
fonts gstatic com; report-uri
o333795 ingest sentry io/api/1887001/security/?sentry_key=3ad6405147234fac8ab65061c25d2334;

x-content-type-options: nosniff

x-frame-options: DENY

x-xss-protection: 1; mode=block

referrer-policy: strict-origin

cache-control: s-maxage=0,public,no-cache,no-store,must-revalidate

strict-transport-security: max-age=63072000

x-cache: Error from cloudfront

via: 1.1 dbc7e30405074db3df74774e77df3fde.cloudfront net (CloudFront)

x-amz-cf-pop: CDG52-P5

x-amz-cf-id: FYyz237m6C8jZ1eVRJKgTvtvtMiBhN7SVhO0E40CfXxnWXC2UNwBjg==

The requested URL returned error: 401

Connection #0 to host studio.edgeimpulse com left intact

      --- LOG END ---

[252/333] Building C object zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_nrfx_uarte.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: ‘C:\Program Files\CMake\bin\cmake.EXE’ --build ‘C:\Users\nicol\Documents\xiao-ble-lsm6dsv16x\xiao-ble-lsm6dsv16x.git\build’

I also tried the individual call using Edge Impulse’s documentation: https://docs.edgeimpulse.com/reference/edge-impulse-api/deployment/download
After clicking on “Test it”, if I add my project ID, and add a header with key x-api-key and value my_key, the request successfully completes.

I contacted Nordic’s support, redirecting me here. Do you have an idea on what I can do to solve the issue please ?

Best regards,

Nicolas Goualard

Environment:

  • Platform: Seeed Studio Xiao BLE
  • Build Environment Details: ncs v2.7.0
  • OS Version: Windows 10

Hi @NicolasGoualard

Sorry we missed this one let me check with the folks working on this, but I believe this veresion is not yet supported

ncs v2.7.0

@vojislav and @mateusz Can you confirm?

Thanks

Eoin

Hi @NicolasGoualard,

We currently support NCS 2.4.0 in our samples for Nordic dev kits, but as I understood you are using sample application from NCS (to be exact: nrf/applications/machine_learning) and in that case I think our SDK is compatible with NCS 2.7.0.

Next thing is resolving why tooling implemented as part of the west does not work properly with EI platform and downloads your model. I do not have a deep knowledge about this way of building ML application since this approach was developed by Nordic, but I will try it out and see what is the issue.

Thank you for sharing info about the platform, NCS version and host OS you are working with, that is always valuable. Please confirm if I am correct about sample application you are using, and I will get back to you with my findings.

Cheers,
Vojislav.

Hi @Eoin @vojislav thanks for your replies :smiley:
There was a bug in the nRF SDK, I opened a pull request (lib: edge_impulse: fix api key header by nicogou · Pull Request #17793 · nrfconnect/sdk-nrf · GitHub) which has been merged in their main branch which fixes this issue, I forgot to report back here :sweat_smile:

Best regards,
Nicolas

Great! Thank you for sharing insights!

cheers,
Vojislav