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

nRF51822 seems to not work after flashing #10

Open
KlausMu opened this issue Nov 17, 2024 · 5 comments
Open

nRF51822 seems to not work after flashing #10

KlausMu opened this issue Nov 17, 2024 · 5 comments

Comments

@KlausMu
Copy link

KlausMu commented Nov 17, 2024

I went through the README to flash a nRF51822. To my understanding, everything worked as expected.
But after flashing, I can't see the tag, neither in "Android nRF Connect", nor can the tag being added to "Find My" in an iPhone.

The tag is from AliExpress (HolyIoT) and looks like this:
image
image
image

The command for flashing was

make stflash-nrf51822_xxac-patched ADV_KEYS_FILE=/home/klaus/projects/airtag/heystack-nrf5x/tools/output-nrf51822-2/nrf51822-2_keyfile ADVERTISING_INTERVAL=2000 KEY_ROTATION_INTERVAL=3600*12 MAX_KEYS=50 HAS_DEBUG=1

Log while flashing was:

merging application and softdevice... : nrf51822_xxac
mergehex -m _build/nrf51822_xxac.hex ../../nrf-sdk/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.
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/klaus/projects/airtag/heystack-nrf5x/tools/output-nrf51822-2/nrf51822-2_keyfile | xxd -r -p | dd of=_build/nrf51822_xxac_s130_patched.bin skip=1 bs=1 seek=116704 conv=notrunc
1400+0 records in
1400+0 records out
1400 bytes (1.4 kB, 1.4 KiB) copied, 0.00267036 s, 524 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/klaus/projects/airtag/heystack-nrf5x/nrf-sdk/gcc-arm-none-eabi-6-2017-q2-update/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 V2J37S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.098182
Info : [nrf51.cpu] Cortex-M0 r0p0 processor detected
Info : [nrf51.cpu] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for nrf51.cpu on 3333
Info : Listening on port 3333 for gdb connections
[nrf51.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x00011434 msp: 0x20003fd8
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.
[nrf51.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Warn : Adding extra erase range, 0x0001ce20 .. 0x0001cfff
** Programming Finished **
** Verify Started **
** Verified OK **

Log from strtt is:

./strtt -v 4
Debug: 1 0 stlink.c:4163 stlink_open(): stlink_open
Debug: 2 0 stlink.c:4177 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3748 serial: not provided
Debug: 3 0 stlink.c:4177 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374b serial: not provided
Debug: 4 0 stlink.c:4177 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3752 serial: not provided
Debug: 5 0 stlink.c:4177 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374d serial: not provided
Debug: 6 0 stlink.c:4177 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374e serial: not provided
Debug: 7 0 stlink.c:4177 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374f serial: not provided
Debug: 8 0 stlink.c:4177 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3753 serial: not provided
Debug: 9 0 stlink.c:4177 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3754 serial: not provided
Info : 10 3 stlink.c:1507 stlink_usb_version(): STLINK V2J37S7 (API v2) VID:PID 0483:3748
Debug: 11 4 stlink.c:1735 stlink_usb_exit_mode(): MODE: 0x00
Info : 12 58 stlink.c:1543 stlink_usb_check_voltage(): Target voltage: 3.099327
Debug: 13 58 stlink.c:1808 stlink_usb_init_mode(): MODE: 0x01
Debug: 14 58 stlink.c:3479 stlink_dump_speed_map(): Supported clock speeds are:
Debug: 15 58 stlink.c:3482 stlink_dump_speed_map(): 4000 kHz
Debug: 16 58 stlink.c:3482 stlink_dump_speed_map(): 1800 kHz
Debug: 17 58 stlink.c:3482 stlink_dump_speed_map(): 1200 kHz
Debug: 18 58 stlink.c:3482 stlink_dump_speed_map(): 950 kHz
Debug: 19 58 stlink.c:3482 stlink_dump_speed_map(): 480 kHz
Debug: 20 58 stlink.c:3482 stlink_dump_speed_map(): 240 kHz
Debug: 21 58 stlink.c:3482 stlink_dump_speed_map(): 125 kHz
Debug: 22 58 stlink.c:3482 stlink_dump_speed_map(): 100 kHz
Debug: 23 58 stlink.c:3482 stlink_dump_speed_map(): 50 kHz
Debug: 24 58 stlink.c:3482 stlink_dump_speed_map(): 25 kHz
Debug: 25 58 stlink.c:3482 stlink_dump_speed_map(): 15 kHz
Debug: 26 58 stlink.c:3482 stlink_dump_speed_map(): 5 kHz
Debug: 27 62 stlink.c:1876 stlink_usb_init_mode(): MODE: 0x02
Debug: 28 62 stlink.c:4356 stlink_usb_init_access_port(): init ap_num = 0
Debug: 29 63 stlink.c:4503 stlink_usb_open_ap(): AP 0 enabled
Debug: 30 65 stlink.c:4261 stlink_open(): Using TAR autoincrement: 1024
Debug: 31 186 strtt.cpp:160 findRtt(): RTT addr = 0x200029e8
Debug: 32 186 strtt.cpp:186 findRtt(): Max number of buffers UP: 2 and DOWN: 2
Info : 33 188 strtt.cpp:215 getRttDesc(): 0. Channel name: Terminal     size: 512       mode: 0
Info : 34 188 strtt.cpp:221 getRttDesc(): 1. Channel name: -------      size: 0 mode: 0
Info : 35 189 strtt.cpp:215 getRttDesc(): 2. Channel name: Terminal     size: 16        mode: 0
Info : 36 189 strtt.cpp:221 getRttDesc(): 3. Channel name: -------      size: 0 mode: 0
Debug: 37 199 strtt.cpp:326 readRtt(): Chanel: 0 readed: 440
:INFO:[KEYS] Last filled index: 48
:INFO:[TIMING] Full key rotation interval: 2073600 seconds (576.00 hours)
:INFO:[TIMING] Rotation per Day: 0.04
:INFO:Starting advertising
:INFO:ble_set_mac_address: eb:fe:8c:1b:xx:xx
:INFO:ble_set_max_tx_power: 8 dBm failed
:INFO:ble_set_max_tx_power: 7 dBm failed
:INFO:ble_set_max_tx_power: 6 dBm failed
:INFO:ble_set_max_tx_power: 5 dBm failed
:INFO:ble_set_max_tx_power: 4 dBm
:INFO:Rotating key: 46
@pix
Copy link
Owner

pix commented Nov 19, 2024

I'll take a look, It seems #7 has the same problem. I have these tags on a previous firmware version.

@dirkpauli
Copy link

not 100% sure if this is the same problem I have - but it feels like. The only difference is: I'm using HolyIOT's 21011 and so flashing the nRF52810 version of the firmware.

@dirkpauli
Copy link

just fyi: I managed the project to get working by resetting the git to commit 1efcb92. A Firmware with that built works fine on my nRF52810.

@KlausMu
Copy link
Author

KlausMu commented Jan 4, 2025

Thanks for the hint. I tried commit 1efcb92
With an nRF51822 and this command make stflash-nrf51822_xxac-patched ADV_KEYS_FILE=./50_NRF_keyfile , flashing gives an error with

Parsing input files.
Could not find file "nrf51822_xxac.hex"
ERROR: One of the files to merge cannot be found.
make: *** [../../Makefile.common:62: merge_nrf51822_xxac] Error 51

So I tried to compile with master and to flash file nrf51822_xxac.hexwith commit 1efcb92
Flashing was successfull, but device still cannot be seen by the iPhone.

@skrobul
Copy link

skrobul commented Jan 5, 2025

This is probably too late, but I also had issues when using this exact board (YJ-15044). Eventually I got it to work though, with current master (c5cb169).
Here are some notes from the issues I experienced, maybe they will help someone

Android nRFConnect does not display FindMy tags

Turns out my issue was with the way I was debugging the "nRF Connect" app on Android displays tens of different bluetooth devices, but by default it filters out "Microsoft, Samsung, Google and Apple" devices... After adjusting filter on the dropdown and unchecking "Apple" i started seeing the FindMy tag.

Flashing on RaspberryPI

  • OpenOCD from the raspbian repo did not work. Followed instructions from this article to compile and setup the RaspberryPi profile, but that also did help immediately.
  • This again turned out to be a user problem, since I swapped the pins. It was hard to find which ones to use in the first place - they are configured here and with default setup it's PIN GPIO25 for SWCLCK and PIN GPIO24 for SWDIO. This translates to physical pins 22 and 18 respectively on Rpi4B.
  • in openocd.conf I needed to switch transport from hla_swd to swd as hla_swd seems to be stlink specific.
  • In openocd.conf I needed to adjust set WORKAREASIZE 0x4000 to set WORKAREASIZE 0 in order to force "slow memory writes".

At this point I can see the broadcasts through nrf connect, but not finding them through iPad, but I am not sure if I'm supposed to. Will find out after setting up MacOS VM to try custom openhaystack app

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

4 participants