Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

50_NRF_keyfile Structure Request #7

Open
CloudAllowed opened this issue Oct 12, 2024 · 5 comments
Open

50_NRF_keyfile Structure Request #7

CloudAllowed opened this issue Oct 12, 2024 · 5 comments

Comments

@CloudAllowed
Copy link

Hey Folks!

Can anybody support me with an example of the 50_NRF_keyfile.
I am struggling with the correct format.

BR & many THX Matthis

@CloudAllowed
Copy link
Author

CloudAllowed commented Oct 12, 2024

My current keyfile has only one line/key:
h4xsf3xXXXqXeXXpXX2/Sx4+oci93KgXsXXnxX==

And I get this error message:

The key was not patched correctly!

merging application and softdevice... : nrf51822_xxac
mergehex -m _build/nrf51822_xxac.hex /home/matthis/nrf5x/nRF5_SDK_12.3.0_d7731ad/components/softdevice/s130/hex/s130_nrf51_2.0.1_softdevice.hex -o _build/nrf51822_xxac_s130.hex
Parsing input files.
Merging file "nrf51822_xxac.hex" into output.
Merging file "s130_nrf51_2.0.1_softdevice.hex" into output.
Storing merged file.
/home/matthis/.local/share/pipx/venvs/nrfutil/bin/hex2bin.py _build/nrf51822_xxac_s130.hex _build/nrf51822_xxac_s130.bin
Patching nrf51822_xxac
cp _build/nrf51822_xxac_s130.bin _build/nrf51822_xxac_s130_patched.bin
xxd -p -c 100000 /home/matthis/nrf5x/nrf51822/armgcc/1_NRF_Key | xxd -r -p | dd of=_build/nrf51822_xxac_s130_patched.bin skip=1 bs=1 seek=123292 conv=notrunc
81+0 records in
81+0 records out
81 bytes copied, 0.0010693 s, 75.8 kB/s
xxd -p -c 100000 _build/nrf51822_xxac_s130_patched.bin | grep -q 454e444f464b455953454e444f464b455953454e444f464b45595321 || (echo "The key was not patched correctly!"; exit 1)
"/home/matthis/nrf5x/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objcopy" -I binary -O elf32-littlearm -B arm _build/nrf51822_xxac_s130_patched.bin _build/nrf51822_xxac_s130_patched.elf
flashing application and softdevice...␍
openocd -f openocd.cfg -c "init; halt; nrf51 mass_erase; program _build/nrf51822_xxac_s130_patched.bin verify; reset; exit";
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 1000 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.305418
Info : [nrf51822.cpu] Cortex-M0 r0p0 processor detected
Info : [nrf51822.cpu] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for nrf51822.cpu on 3333
Info : Listening on port 3333 for gdb connections
[nrf51822.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x00011434 msp: 0x20003fc8
Info : nRF51822-QFAA(build code: H0) 256kB Flash, 16kB RAM
Info : Mass erase completed.
Info : A reset or power cycle is required if the flash was protected before.
[nrf51822.cpu] halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Warn : Adding extra erase range, 0x0001ea5c .. 0x0001ebff
** Programming Finished **
** Verify Started **
** Verified OK **

@pix
Copy link
Owner

pix commented Oct 13, 2024

You need to use the generate_keys.py script in tools.

python generate_keys.py -n 50 -p 50_NRF

File structure is:

[8 bit key count (ignored)][key0 in binary][...][keyN in binary]

@CloudAllowed
Copy link
Author

Same issue with the key generated in this way. Same error messages.

Parhaps an issue with old or wrong libraries. I will setup the environment again blank from the scretch.
Will share my results here. THX.

You need to use the generate_keys.py script in tools.

python generate_keys.py -n 50 -p 50_NRF

File structure is:

[8 bit key count (ignored)][key0 in binary][...][keyN in binary]

@pix
Copy link
Owner

pix commented Oct 15, 2024

The keyfile should not contain base64.

More so:

81+0 records in
81+0 records out

These should be multiple of 28.

Are you sure you picked the file ending in _keyfile ?

@CloudAllowed
Copy link
Author

I'm on vacation the next couple of days.
I'll give it a try after my return.
Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants