dchristl / macless-haystack

Create your own AirTag with OpenHaystack, but without the need to own an Apple device
GNU General Public License v3.0
407 stars 66 forks source link

dd: no value specified for seek #26

Closed 0xPetra closed 10 months ago

0xPetra commented 1 year ago
dd: no value specified for seek

I'm getting this error while trying to run this command:

xxd -p -c 100000 PREFIX_keyfile | xxd -r -p | dd of=nrf52_firmware.bin skip=1 bs=1 seek=$(grep -oba OFFLINEFINDINGPUBLICKEYHERE! nrf52_firmware.bin | cut -d ':' -f 1) conv=notrunc

I also tried running grep and got nothing as a response:

grep -oba OFFLINEFINDINGPUBLICKEYHERE! nrf52_firmware.bin | cut -d ':' -f 1

I compiled the .bin files again. Something that I need clarification on is how this command would look for a string in a binary file.

I tried replacing OFFLINEFINDINGPUBLICKEYHERE! with the actual PUB KEY (which doesn't make sense), but I still did it.

What could be happening? Appreciate the repo!

dchristl commented 1 year ago

Hello @0xPetra,

the output of the grep command should be 155224, if the firmware is untouched.

image

Two possible issues, if this doesn't work:

  1. Your firmware is already patched, because dd works directly with the original bin without a copy. The solution is to redownload the binary
  2. You are not working with a posic compatible shell (bash, zsh, sh, ..) and the command works not as expected. The solution is to use another shell or post the shell you using.

Kind regards, Danny

0xPetra commented 1 year ago

I'm using zsh, so it should work.

Sorry to ask such a simple question, but where should I download it from?

Besides compiling my own version I also downloaded from here: https://github.com/acalatrava/openhaystack-firmware/tree/main/apps/openhaystack-alternative/compiled

Thanks! Cheers, Petra

dchristl commented 1 year ago

I'm using zsh, so it should work.

Do you use it on Linux or Mac? It seems Mac has an issue with grep. Please try to set the LC_CTYPE env variable before the command, i.e.:

LC_CTYPE=C grep -oba OFFLINEFINDINGPUBLICKEYHERE! nrf52_firmware.bin | cut -d ':' -f 1

resp.

LC_CTYPE=C xxd -p -c 100000 PREFIX_keyfile | xxd -r -p | dd of=nrf52_firmware.bin skip=1 bs=1 seek=$(grep -oba OFFLINEFINDINGPUBLICKEYHERE! nrf52_firmware.bin | cut -d ':' -f 1) conv=notrunc

Sorry to ask such a simple question, but where should I download it from?

You should use the version from this project at the release page

0xPetra commented 1 year ago

Oh, I didn't realize about releases. After making sure everything works, I can update the Readme with some notes.

Indeed I'm using a Mac. LC_CTYPE=C does work for grep, printing 155224, which is the expected value as you mentioned. But the second command still throws an error with the new .bin:

dd: no value specified for seek

Tried this (LC_CTYPE=C in seek):

LC_CTYPE=C xxd -p -c 100000 PREFIX_keyfile | xxd -r -p | dd of=nrf52_firmware.bin skip=1 bs=1 seek=$(LC_CTYPE=C grep -oba OFFLINEFINDINGPUBLICKEYHERE! nrf52_firmware.bin | cut -d ':' -f 1) conv=notrunc

And got this response:

28+0 records in
28+0 records out
28 bytes transferred in 0.000152 secs (184211 bytes/sec)

Now, time to flash and see!

dchristl commented 1 year ago

I've updated the README, to execute the command on non -GNU shells. The changes should work for Linux and Mac.

0xPetra commented 1 year ago

It does seem to work.

I also needed to make it a .hex with this command: arm-none-eabi-objcopy -I binary -O ihex nrf52_firmware.bin nrf52_firmware.hex

I still can't flash my nRF52 Dongle, though. I'm using the Programmer app from nRF Connect, and "Write" is disabled with the patched firmware.

I thought maybe SoftDevice was missing and tried to add it separately. But it overlaps with the firmware, so I guess it was indeed included while compiling.

Screenshot 2023-09-18 at 16 16 21 Screenshot 2023-09-18 at 16 15 59

Any idea what might be going on?

Thanks in advance! Really appreciate the responses!

dchristl commented 1 year ago

arm-none-eabi-objcopy -I binary -O ihex nrf52_firmware.bin nrf52_firmware.hex

I'm not familar with the programmer app, you are using, but this shouldn't be needed normally. I flash the firmware with opeonocd, that works really well. The commands and the openocd.cfg file is in the docs. Maybe you have to change the last line openocd.cfg from

source [find target/nrf51.cfg] to source [find target/nrf52.cfg], but I don't think this is really needed.

Can you try it with openocd?

I thought maybe SoftDevice was missing and tried to add it separately. But it overlaps with the firmware, so I guess it was indeed included while compiling.

You are right, the softdevice is already included.