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

Alternative firmwares for nrf51822, nrf52810 and nrf52832 #120

Open
pix opened this issue Aug 26, 2024 · 10 comments
Open

Alternative firmwares for nrf51822, nrf52810 and nrf52832 #120

pix opened this issue Aug 26, 2024 · 10 comments

Comments

@pix
Copy link

pix commented Aug 26, 2024

Hi, shameless plug here: https://github.com/pix/heystack-nrf5x

I managed to convert an old Tile tag (with an nrf52810) to Haystack.
I used alcatrava's firmware as a base too and fixed some potential memory leaks and updated the SDK / Makefiles.

The code is running since two days, without problems for now.

@pix pix changed the title Alternative firmwares for nrf52810 and nrf51822 Alternative firmwares for nrf51822, nrf52810 and nrf52832 Sep 1, 2024
@dchristl
Copy link
Owner

dchristl commented Sep 6, 2024

Hello,

Thanks for the info, if I ever have time I can include this as an alternative in the documentation. Does your firmware support changing keys/mac?

Kind Regards,
Danny

@pix
Copy link
Author

pix commented Sep 11, 2024

Yes. More than 4500 keys on a nrf51 :-)

You might want to wait until this issue is ironed out. I have a branch with a fix, but I'm waiting for new hardware to test things out.

make all supports building release binaries, which can be patched using the old xxd way.

@dchristl
Copy link
Owner

Sounds great. Did you happen to take measurements of the power consumption? I had the problem with the firmware that the power consumption was significantly higher with changing keys. By significant I mean about 10-15 times shorter lifetime compared to 1 key to several. This was probably due to the wake up (key - Mac change) and I couldn't solve this with the Nordic forum either. That's why I no longer use my firmware, because changing the battery every month is annoying and expensive

@pix
Copy link
Author

pix commented Sep 17, 2024

Not at the moment -- still looking for a chance to get my hands on an oscilloscope :)

I didn’t run any calculations, but there’s a malloc() issue causing RAM clogging:

uint8_t setAdvertisementKey(const char *key, uint8_t **bleAddr, uint8_t **data)

These allocations are never freed. Also, the keys are stored in RAM instead of being marked as constant, which can cause more frequent resets due to memory faults. Plus, increased RAM usage leads to higher power consumption since more RAM blocks stay powered during sleep.

That could be part of the issue.

@ctandi
Copy link

ctandi commented Sep 20, 2024

Did you happen to take measurements of the power consumption?

I did, with the Nordic Power Profiler Kit 2 :)

The HolyIoT YJ-16013 (nRF52832) sitting on my table right now is running with an average current draw of 14 µA (2000 ms Advertising Interval, 4 dBm, 80 Keys, 900 sec. rotation interval). I tried setting it to the external 32 KHz oscillator, which I heard could reduce the power consumption even further. However when I edit the sdk_config.h the SoC crashes with

[nrf52.cpu] halted due to breakpoint, current mode: Thread 
xPSR: 0x81000000 pc: 0x00027068 msp: 0x2000ffc0

The HolyIoT 17095 (nRF52832) averages at around 20 µA with the same settings as the 16013. It doesn't have an XTAL.

A HolyIoT 21014 (nRF52810) with 60 keys (rotating every 900 secs) advertising every 3000 ms takes around 10 µA. I also haven't tested using the XTAL instead of the internal source with this model yet.

The no-name beacon with an nRF51822 that I have draws 18 µA with the internal RC circuit and 16 µA with the XTAL in use. (2000 ms, 4 dBm, 40 keys, 900 secs rotation)

@pix
Copy link
Author

pix commented Sep 20, 2024

Thanks for the measurments. I got my hand on a OWON-VDS1022.

I got my first snaps of the sending and key rotation power consumption:
key+beacon

It's been years since I touched an oscilloscope, and my shunt resistor is, well from the back of the drawer, but i'll be able to validate my measurement skills with your input ! Thanks :)

Anyway, the left part show the power profile of waking up from sleep to update the advertising key. On the right is a single transmission (on the 3 channels if I remember my bluetooth correctly)

@pix
Copy link
Author

pix commented Sep 20, 2024

I tried setting it to the external 32 KHz oscillator, which I heard could reduce the power consumption even further. However when I edit the sdk_config.h the SoC crashes wit

I think I tried something like that and failed too.

A HolyIoT 21014 (nRF52810) with 60 keys (rotating every 900 secs) advertising every 3000 ms takes around 10 µA. I also haven't tested using the XTAL instead of the internal source with this model yet.

If you have optimized settings XTAL settings for the HolyIoT (or other), I could add the relevant board headers and flags on the project to build them more easily. That would be great 👍

@vasimv
Copy link

vasimv commented Oct 16, 2024

NRF51/52 has switching DC-DC regulator (to efficiently convert input voltage into lower voltage the microcontroller uses), it does reduce power consumption greatly if input voltage is more than 2 volts (in comparison with default LDO regulator). It saves much more power than installing 32.768kHz quartz, but requires inductor and few capacitors on the board. Most of boards have the inductor, so you have just enable the DCDC regulator to lower power consumption significally.

@pix
Copy link
Author

pix commented Oct 16, 2024

FYI: I added dcdc build variants (I didn't enable it for yj17024 as low power consumption may not be the target for this board, I might be proven wrong)

I used this:

#ifdef HAS_DCDC
    // Enable DC/DC converter
    COMPAT_NRF_LOG_INFO("Enabling DC/DC converter");
    uint32_t err_code = sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
    APP_ERROR_CHECK(err_code);
#endif

Is that enough ?

make all at the root will build all the variants.

@vasimv
Copy link

vasimv commented Oct 16, 2024

Ugh, not sure how you set it in old nrf52 sdk, sorry. For zephyr SDK this is "CONFIG_BOARD_ENABLE_DCDC=y" in prj.conf at compile time. Probably, "#define POWER_CONFIG_DEFAULT_DCDCEN 1" for enabling by default.

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

5 participants
@pix @dchristl @vasimv @ctandi and others