Cryptocell and usb

I was building the "console" sample code found in zephyr for my custom nrf52840 board and I managed to get it to work. But as soon as cryptocell gets enabled, it doesn't work anymore.

Q1:  Why doesn't the devicetree find "nordic,cryptocell"? I get a warning like this: Unknown node type "nordic,cryptocell"

- This also applies to nrf52840 Dongle and DK.

Q2: Cryptocell is enabled by default in nrf52840 devicetree which gets applied to all the boards (like nrf52840dongle and nrf52840dk and my custom board which uses nrf52840dongle as template). But this breaks the usb communication with the "console" sample on my custom board (It does build though).

- I can't test it with other boards since I only have nrf52dk and it doesn't support usb.

- I'm flashing it through mcuboot so I don't have access to debugger and I'm scared to use the nrf52dk as debugger since it already has bricked 3/5 devices.

Q3: The acl node has also a warning: Address range collides with flash-controller@4001e000 (both start at 0x4001e000)

- But it still works with it enabled.

I'm running Manjaro kde with linux66 kernel, v2.6.1 toolchain with v2.6.1 SDK installed through vscode extension.

This is the configuration which works:

And prj.conf:

CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Testing"
CONFIG_USB_DEVICE_PID=0x0851
CONFIG_USB_DEVICE_VID=0x884E
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n

CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_LINE_CTRL=y

 
And board defconfig:
CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52840_QIAA=y
CONFIG_BOARD_NRF52840_CUSTOM=y

# ??????
CONFIG_BOARD_ENABLE_DCDC=n

# 32K clock
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y

# Enable MPU
CONFIG_ARM_MPU=y

# enable GPIO
CONFIG_GPIO=y

# Enable Zephyr application to be booted by MCUboot
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_DISABLE_FLASH_PATCH=y
Parents
  • Hi, 

    I would appreciate additional information and some clarifications.

    Do you use a custom board with nrf52840?

    I was building the "console" sample code found in zephyr for my custom nrf52840 board and I managed to get it to work. But as soon as cryptocell gets enabled, it doesn't work anymore.

    Which console sample did you use? Is it maybe console over USB?
    How did you enable CryptoCell?
    What happens when it does not work anymore, is there any error?

    Q1:  Why doesn't the devicetree find "nordic,cryptocell"? I get a warning like this: Unknown node type "nordic,cryptocell"

    Did you get this warning on your custom board? Have you tried on nrf52840-dk?
    "nordic,cryptocell" unknown type is probably related to some devicetree error. Can you show where and how you added "nordic,cryptocell" configuration?

    Q2: Cryptocell is enabled by default in nrf52840 devicetree which gets applied to all the boards (like nrf52840dongle and nrf52840dk and my custom board which uses nrf52840dongle as template). But this breaks the usb communication with the "console" sample on my custom board (It does build though).

    Can you provide information in which way is USB communication broken, what exactly happens?
    Is USB communication functional on nrf52840-dk board?

    Q3: The acl node has also a warning: Address range collides with flash-controller@4001e000 (both start at 0x4001e000)

    This also indicates devicetree configuration issue.

    But it still works with it enabled.

    Can you rephrase this - what works when what is enabled? Can you show what is enabled and what happens when it works?

    What is shown in provided screenshot?

    Best regards,
    Dejan

  • Hi,

    Do you use a custom board with nrf52840?

    Yes, my custom board has nrf52840.

    Which console sample did you use? Is it maybe console over USB?

    It was the USB subsys sample called "console"

    How did you enable CryptoCell?

    CryptoCell is enabled by default here.

    What happens when it does not work anymore, is there any error?

    It does build without any errors, but the usb does not get initialized or recognized by my PC. It's hard to say what happens there without debugger.

    Did you get this warning on your custom board? Have you tried on nrf52840-dk?
    "nordic,cryptocell" unknown type is probably related to some devicetree error. Can you show where and how you added "nordic,cryptocell" configuration?

    This warning is also shown in the nrf52840.dsti. Nrf52840-dk includes the same file. "nordic,cryptocell" is configured there and I only disabled it in my board files to make the usb code work.

    Can you provide information in which way is USB communication broken, what exactly happens?
    Is USB communication functional on nrf52840-dk board?

    The only way I know it's broken is that it no longer gets recognized as a usb serial device and it is not found with NRF Connect or any other serial terminal software. I do not have access to nrf52840-dk board.

    This also indicates devicetree configuration issue.

    This I already knew. The question was why? Both of the nodes have the default configuration that come with the SDK.

    Can you rephrase this - what works when what is enabled? Can you show what is enabled and what happens when it works?

    This sample code and other codes still work when acl is enabled regarding the warning.

    What is shown in provided screenshot?

    The device configuration part of the devicetree.

    BR

  • Hi,

    Dejan is out office so I have taken over this case. Reading through this case I have problems understanding the issue. Can you please explain from the beginning the exact issue and how to reproduce it?

    PS: Regarding not having a debugger, that is essential for embedded development. I assume you have at least one as you are able to program it? And using the DK as a debugger should not brick your custom board in any way. If that was the case I suggest a separate thread about that (my guess would be a that you power the board before attacking the debugger with a common ground, but this would then be an issue regardless of which debugger you connected). 

  • ...Im tired of explaining this already, read the posts... Build "console", *** works, enable cryptocell, *** no work!

    if you have more questions you have to be more specific

  • Hi,

    I have read this thread again and I am unfrortunately not able to understand what the issue is and what you want us to do. Please provide a detailed set of step by step instructions of how to reproduce this issue on a DK if you want us to look more into this. Also please note that I do not try to be difficult, it is just that I am simply not able to understand the issue from reading this thread.

  • Clearly you didnt read ***. I have stated that I DO NOT have access to any DK board which has USB connected to the MCU.

    1. Installed fresh ubuntu 22.04 virtual machine

    2. Installed vscode

    3. Installed nrf extension pack for vscode

    4. Installed 2.6.1 toolchain and SDK from vscode extension

    5. Build "console" sample code for my custom boardnrf52840_custom.dts

    6. Opened any serial terminal and saw the hello world message

    7. Enable cryptocell in board files OR app overlay, delete build folder and build again

    8. Serial terminal cannot connect to it anymore nor does lsusb find the device anymore

  • Apparently cryptocell only works with debugger attached. Whats up with that?

Reply Children
  • Great, this place removes posts...

    and now the ****** board is bricked...
    
    1. Why did the debugger erase my bootloader even though the app was built for it?
    
    2. How did the debugger(NRF52dk) brick the board even though the code was running before bricking it?

    Well, I managed to get it unbricked by messing around with gpio registers from JLinkExe. Apparently it needs to be connected with JLinkExe every time it disappears. So theres something funky going on with nrfutil...

    But now I can't get the mcuboot to work and I don't have the original mcuboot config which we managed to get to work after a long battle...

  • Hi,

    Regarding "1. Why did the debugger erase my bootloader even though the app was built for it?", I do not know how you used it, but if you do a full erase / erase all (which you often do when programming or debugging), that will erase the whole flash, includign any bootlaoders and the UICR. If you just want to re-flash the application you can seelct to use sector erase. If you are using nRF Connect for VS code for programming you can select if you want to do a full erase or not when flashing, as explaind in this post.

    Regarding "2. How did the debugger(NRF52dk) brick the board even though the code was running before bricking it?" I do not know which state it what in when  you refer to it as "bricked" nor how it got there. If you can share details about how it behaved when you define it as "bricked", how it ended up in that state and hwo it receoverd, we may be able to understand more.

    Generally, there is no need to use a debugger to get CrytpoCell to work, and also no conflict between CryptoCell and USB. So I suspect there are other more fundamental issues with your device or setup. I am also not able to understand the comments about debugger bricking your device. I kindly ask that you elaborate much more and provide exact details if you want specific feedback.

    It seems to me that you are seeing a significant number of seemingly unrelated issues that are difficult to explain. I would suggest that you try to reduce the numer fo unkowns in the beginning by obtaining a DK so tha that you have known good hardware and test parts of your firmware on that. Then you can gradually move to your custom HW. Alternatively, there is an absolute requierment that you are able to debug your hardware.

  • To the first part:

    The problem is that in vscode the "flash", "erase and flash" and "debug" all use "merged.hex" and not the APP. Meaning everytime I flash my app with the debugger I replace my working bootloader with the non working one. This is a terrible way of doing things if bootloader and app are developed by different people or departments. This means I HAVE to have the bootloader on my computer when I want to debug an app for it.

    The second part:

    I consider the device bricked when it does not show up in the programming app. The weird part about it was that vscode and nrf connect app did not find the device, but JLinkExe did. And after connecting through JLinkExe, vscode and nrf connect app found it.

    And yes, the problem is that cryptocell doesn't work without debugger attached. This was the same problem which "deleted" my bootloader since the APP also enabled cryptocell in the bootloader and overwrote it and thus bootloader didn't work anymore. This is the jankiest MCU I've ever used...

    And why would I need DK to run the sample codes? I still havent been able to start writing the actual FW to this, because theres still something wrong with the config and that's what Im trying to figure out.

    So, why is cryptocell only working with debugger?

    Without debugger, the cryptocell app doesnt even reach main.

    Im running the board in normal mode and DCDC is NOT enabled.

  • Hi,

    AintMina said:
    The problem is that in vscode the "flash", "erase and flash" and "debug" all use "merged.hex" and not the APP. Meaning everytime I flash my app with the debugger I replace my working bootloader with the non working one. This is a terrible way of doing things if bootloader and app are developed by different people or departments. This means I HAVE to have the bootloader on my computer when I want to debug an app for it.

    That is a good point. The reason we do it like this is that it makes the most common use case working out of the box. Whenever you try to flash or debug, you will get all images in case of multi image projects. But this is not always wat you want. An alternative could be to get the hex file you want to use, and point to that using CONFIG_MCUBOOT_BUILD_STRATEGY_USE_HEX_FILE. See here for more details on that.

    AintMina said:
    the problem is that cryptocell doesn't work without debugger attached. This was the same problem which "deleted" my bootloader since the APP also enabled cryptocell in the bootloader and overwrote it and thus bootloader didn't work anymore.

    I see. This is what we must focus on. However, I have not been able to reproduce this which is why I have been asking for more information.

    AintMina said:
    And why would I need DK to run the sample codes? I still havent been able to start writing the actual FW to this, because theres still something wrong with the config and that's what Im trying to figure out.

    There are a few good reasons for having a DK. First of all, it is a known good piece of hardware, and as such a good platform for prototying and debugging specific issues. It is also a platform we in Nordic tech support has access to, so if you were able to reproduce the issue on that, you could let us know how we can reproduce on our end. It can also be used to debug your custom board (which you described early on that you did not want to do or were not able to do).

    AintMina said:

    So, why is cryptocell only working with debugger?

    Without debugger, the cryptocell app doesnt even reach main.

    Im running the board in normal mode and DCDC is NOT enabled.

    That what we need to figure out. Can you share your full set of board files in a zip so that I get the full picure and have better hops of being able to reproduce the issue? (I want to start with simply building for your board and running that on my DK as that seems like the best option at this point).

Related