nrf52832 with SDK14 expected working?

Posted on
  • The provision script has only sdk15 there, is sdk14 expected to work too? I unzipped latest sdk 14 into targetlibs/nrf5x_14 in same way as in provision.sh, applied NFC patches from targetlibs/nrf5x_14 (but disabled NFC in board file anyway), copied external/micro-ecc from sdk12 or sdk15 (both seem to work fine) and it builds with one config tweak (rising RNG_CONFIG_POOL_SIZE value to 64). The result works in bare nrf52 board with soft device 5.0 however the output from Nordic UART service appears to be a bit garbled. I can connect and run basic commands but e.g. just 'process.env' JSON output is not valid with missing random parts. So even the web ide mostly does not recognize the board when connecting. Is this known issue?

    I'm trying this because most of the "Da Fit app" family of nrf52 smartwatches are based on SoftDevice 5.0.0 and can be reflashed without taking apart so this is easiest way. Otherwise we could of course reflash its custom boootloader with nordic DFU one and then trying to downgrade to SDK12/SD3.0 if that is what is currently better for running Espruino.

  • tried same build just with NRF_SDK15=1 instead of NRF_SDK14=1 and I don't see that issue, webide connects fine from my android phone and process.env looks fine. The only issue is that I cannot connect to it from Chromium running on Raspberry Pi 4 both for SDK14 build an SDK15 build (maybe related to Bluetooth 5) while it works with SDK12 build. Console shows

    >>> Connecting to Espruino NRF52832DK
    BT>  Device Name:       Espruino NRF52832DK
    BT>  Device ID:         TNUKC6eQJyfyydDlywFgIQ==
    >>> Connected to BLE
    BT> Connected
    >>> Configuring BLE...
    BT> Got service
    >>> Configuring BLE....
    BT> RX characteristic:{}
    BT> ERROR: NotSupportedError: GATT operation not permitted.
    BT> Disconnected (gattserverdisconnected)
    ERROR: [notify_error] Connection Failed.
    >>> Connection Failed.
    
  • I wasn't aware of the issue, but I imagine it's very likely to do with this code: https://github.com/espruino/Espruino/blo­b/master/targets/nrf5x/bluetooth.c#L956

    There were some changes in logic for SDK15 and the code there looks like maybe SDK14 code got left outdated...

  • Thanks for the hint, looks like for =5 it falls back to #else so I'll try <= or >= to do one of the other cases to see if it helps or look into what #else does exactly (as it looks quite different).

  • OK, so I removed #else and added similar code to two cases above

     [#elif](http://forum.espruino.com/search­/?q=%23elif) NRF_SD_BLE_API_VERSION==5
        uint32_t err_code = ble_nus_string_send(&m_nus, nusTxBuf, &nuxTxBufLength);
        if (err_code == NRF_SUCCESS) nuxTxBufLength=0; // everything sent Ok
     [#endif](http://forum.espruino.com/searc­h/?q=%23endif)
    

    and it seems to work fine, no lost characters and webide can connect. Then the nuxTxBufLength=0; // everything sent Ok is same for all three cases so final version is

        // We have data - try and send it
    
     [#if](http://forum.espruino.com/search/?­q=%23if) NRF_SD_BLE_API_VERSION>5
        uint32_t err_code = ble_nus_data_send(&m_nus, nusTxBuf, &nuxTxBufLength, m_peripheral_conn_handle);
     [#elif](http://forum.espruino.com/search­/?q=%23elif) NRF_SD_BLE_API_VERSION<5
        uint32_t err_code = ble_nus_string_send(&m_nus, nusTxBuf, nuxTxBufLength);
     [#else](http://forum.espruino.com/search­/?q=%23else)
        uint32_t err_code = ble_nus_string_send(&m_nus, nusTxBuf, &nuxTxBufLength);
     [#endif](http://forum.espruino.com/searc­h/?q=%23endif)
        if (err_code == NRF_SUCCESS) {
          nuxTxBufLength=0; // everything sent Ok
          bleStatus |= BLE_IS_SENDING;
        } else if (err_code==NRF_ERROR_INVALID_STATE) {
    
  • Looks great! Just merged it in :)

  • The only issue is that I cannot connect to it from Chromium running on Raspberry Pi 4 both for SDK14 build an SDK15 build (maybe related to Bluetooth 5) while it works with SDK12 build.

    Recently I tried espruino on particle xenon (nrf52840) and I had same issues with conecting from Raspberry Pi 3 and 4 and found solution/workaround for this strange error. I cleared bluez cache in /var/lib/blueooth as per https://stackoverflow.com/a/43541073 and problem is gone. I had cached files for various devices more than year old there. Not really sure why Bluez caches stuff like this for so long (or at all). So now I can connect to any softdevice version used with espruino without issues.

    BTW I understand how it might affect things when switching different bluetooth versions (4 to 5) for same device and MAC address, however with particle xenon this was first connection ever that was failing, yet clearing the cache somehow helped too.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

nrf52832 with SDK14 expected working?

Posted by Avatar for fanoush @fanoush

Actions