This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UNABLE TO GENERATE PRIVATE KEY

Hi,

I am following a tutorial in order to learn the procedure for DFU OTA . I installed the nrfutil but still unable to generate the private key.

I have tried several commands like :

nrfutil.exe keys generate private.key

nrfutil.exe keys generate priv.pem

but it did not work

I think i am using the latest version . 5.0.0

I am getting such errors : TypeError: write() argument must be str, not bytes
NameError: name 'raw_input' is not defined

Please suggest.
Could I be in wrong directory while writing these commands ?
C:\Users\ArshdeepMalik>nrfutil.exe keys generate private.key

Thanks much!

Parents
  • Hi.

    Please answer these questions:

    1. Which version of Python do you use? (You can check by typing python --version in cmd)

    2. Do you have the correct path in Environment Varables? (Check the path by typing where python in cmd)

    3. Can you check which version of nrfutil you have? (Check by typing nrfutil version in cmd)

    4. Have you also added the folder Python27\Scripts to the path in Environment Varables? 

    Best regards,

    Andreas

  • Hi Andreas,

    Which version of Python do you use? 3.7.2

    Do you have the correct path in Environment Varables?  Yes,

    Can you check which version of nrfutil you have? 5.0.0

     Have you also added the folder Python27\Scripts to the path in Environment Varables ? I did not have it before, but added after your comments but still getting error .

    NameError: name 'raw_input' is not defined

    Please suggest!!

    Thanks,

  • Hi

    arshdeep said:
    Then created a zip folder in Desktop, DFU.zip . Copied the hex file from example SDK ble_app_blinky_pca10056_s140.hex into DFU.zip folder and also copied the private.key in the same folder. 

     Which command did you use in CMD? :-)

    You have to use nrfutil to generate a DFU packet.

    Best regards,

    Andreas

  • Thanks Andreas, I was able to generate the zip folder using the nrfutil but now i am running into 2 new issue ->

    1) After uploading the DFU.zip folder to nrf52840 DK from nrf Connect app, it does not run my application and kind of erases everything from board. The upload goes till 100% and seems like it did upload it successfully. 

    2) After I upload the DFU.zip folder, every time i try to flash another program using SES,  it keeps on going in DFU mode. I am unable to exit from DFU mode. 

    Please Suggest . 

    Regards, 

  • Hi.

    Could you please post the nrfutil command that you used to generate the DFU packet? :-)

    Best regards,

    Andreas

  • nrfutil pkg generate --hw-version 52 --application-version 3 --application ble_app_blinky_pca10056_s140.hex --sd-req 0xA9 --key-file private.pem app_dfu_package.zip

  • Hi.

    Can you try to create a DFU packet and add a compiled self compiled version of the blinky project? And don't merge it with the SoftDevice.

    Do you get the error then?

    Best regards,

    Andreas

Reply Children
  • Hi Andreas

    I did try with bsp example to check if the issue is in softdevice but the error was same. 

    Thanks

    Arshdeep

  • Hi Arshdeep.

    Can you try to do it the following way:

    1) Program the bootloader found in the folder \examples\dfu\secure_bootloader\pca10056_ble_debug with the private key you generated.

    2) Compile the project found in the folder \examples\ble_peripheral\ble_app_blinky\pca10056.

    3) Take the .hex file from step 2 and generate the DFU packet with the private key from step 1.

    nrfutil pkg generate --hw-version 52 --application-version 1 --application ble_app_blinky_pca10056_s140.hex --sd-req 0xA9 --key-file private.pem app_dfu_package.zip

    4) Do a nrfjprog -e on the board to erase the pervious stored memory.

    5) Program the bootloader from step 1.

    6) Open nRF Connect Bluetooth Low Energy and try to do the DFU from your second board.

    Can you post some screenshots and log of the process? Does this work?

    Best regards,

    Andreas

  • Hi Andreas,

    1) Program the bootloader found in the folder\examples\dfu\secure_bootloader\pca10056_ble_debug with the private key you generated. : You mean public_key.c right ??? and not the private key . 

    5) Program the bootloader from step 1. : Program the bootloader again? I did not understand this . should I program the bootloader in the second board ? 

    6) Open nRF Connect Bluetooth Low Energy and try to do the DFU from your second board. How to do the DFU using the second board ? I do not know. Do you have any link where i can learn how to do DFU using second board. 

    Also, my nrfGo studio is not able to detect boards :

    It used to work fine in past. I tried uninstalling and installing it again. Did not work. Does this give any clues for DFU ?

    Also please check the steps that i do when connected through nrfConnect app:

  • Hi.

    Sorry about the confusion, I wrote wrong in step one, i should have been "build", and then you could program it later.

    If you use your phone, then you don't need a second board, I thought that you had two boards, sorry about that.

    nRFgoStudio is outdated, so you should not use that. You should use nRF Connect for Desktop and the nRF Connect Programmer Application.

    I did the procedure with my mobile phone now, and it succeeded.

    I built the bootloader with the private key and programmed it onto the board.

    I then built the blinky application.

    I then created the DFU packet with the command in my previous reply.

    And then I did as you show in your pictures and selected the zip file I generated.

    When I finished, the board resets and LED 1 is on.

    Does this happen with your board?

    Best regards,

    Andreas

  • How do I build the bootloader using the private key? it should be the public key right ??

    As I told you, I did try this procedure once but now every time I flash (with normal SES IDE using a USB cable, not even with dfu) any program from ble_peripheral example, I end up in a DFU mode Though it works fine if I flash any program from peripheral example.

    see in the attached pictures, I flashed ble_app_bms example but the board is advertising as DfuTarg

Related