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 firmware #57

Open
acalatrava opened this issue May 7, 2021 · 78 comments
Open

Alternative firmware #57

acalatrava opened this issue May 7, 2021 · 78 comments
Labels
question Further information is requested

Comments

@acalatrava
Copy link

I just created an alternative firmware that is compatible with both nRF51 and nRF52 platforms. It's using the Softdevice S130/S132 2.0.0 from Nordic SDK11.

I already tried it on this modules:

More info here:
https://github.com/acalatrava/openhaystack-firmware/tree/main/apps/openhaystack-alternative

@acalatrava acalatrava added the question Further information is requested label May 7, 2021
@mowtschan
Copy link
Contributor

@acalatrava could you share the "howto" flash E104-BT5032A board?
did you use a special board, adapter or just STLinkV2?

@junleus
Copy link

junleus commented May 8, 2021

I build openhaystack-alternative_s130.bin replaced public_key and using STLinkv2 to flash into an NRF51822 which you had tested. the module consumes 2.6ma, but there are no advertisements.

please advise, thank you.

image

@acalatrava
Copy link
Author

acalatrava commented May 8, 2021

Please note that you need to flash the SoftDevice too. You can generate a full bin file by issuing make build, the bin will be at the compiled directory.

Can you share your consume after that? I don’t have the tools to measure it.

@acalatrava
Copy link
Author

@mowtschan I used a JLink-compatible adapter, however you should be able to use the STLinkV2 too. I think it should work if you just issue make && make e104install, this will use nrfjprog to flash the firmware which I think it should work with STLinkV2 too.

@junleus
Copy link

junleus commented May 8, 2021

@acalatrava with softdevice nrf51_firmware.bin Size around 3.1MB, how to flash into nrf51 chipset?

for openhaystack firmware standby 860uA, and sent advertisements will consume 960uA.

image

@acalatrava
Copy link
Author

You’re right. I think the problem is that those are not actually bin files but hex ones. I’m not at the computer atm so please try to rename it and flash it that way.

@junleus
Copy link

junleus commented May 8, 2021

the bin comes with the public key, but hex one doesn't have a public key.

image

image

@acalatrava
Copy link
Author

Both bin and hex files are actually the same firmware on a different format. You can’t see the key on the bin file with a simple editor since the firmware is encoded in hexadecimal format (that’s why the file is bigger) instead of binary.

So you can replace the key on the source file, compile, merge it with the SoftDevice and flash the resulting hex file (the compiled file appears as bin but it’s actually a hex file).

I’ll try to fix this naming issue when I’m at home.

@junleus
Copy link

junleus commented May 8, 2021

@acalatrava can you confirm that compiled nrf51_firmware.bin size is 3.1MB?

I try to flash with ST-LINK v2 but seem to run out of space.

image

@acalatrava
Copy link
Author

acalatrava commented May 8, 2021 via email

@junleus
Copy link

junleus commented May 8, 2021

finally, I manual merge softdevice hex file got 324kb size hex, flashed with STLINK v2, and keep consume 5uA, so no advertisements yet. I flashed back into openhaystack firmware and got advertisements again. I think need way hex2bin then.

appreciate.

mergehex -m s130_nrf51_2.0.0_softdevice.hex openhaystack-alternative_s130.hex -o softdevice.hex

@jaekim24
Copy link

jaekim24 commented May 9, 2021

how long did your nRF52 chip last with the coin cell battery @acalatrava

@junleus
Copy link

junleus commented May 9, 2021

I use objcopy cmd in Linux can convert hex to a bin, as the same way compiled an example s130-beacon apps it is running, but openhaystack-alternative doesn't run at all.

@acalatrava
Copy link
Author

@junleus I can confirm that something is broken with the nRF51 since it isn’t working on mine either. I’ll try to check what I broke, but since I have it working on another nRF51 for 7 days now it shouldn’t be hard to find.

@jaekim24 I still didn’t put a coin cell on my module but since it’s working for more than 7 days on my nRF51 and the battery is still at 2.96V I expect a very long duration.

@jaekim24
Copy link

jaekim24 commented May 9, 2021

what kind of battery did you use the on nRF51 @acalatrava

@acalatrava
Copy link
Author

I just published the fixed firmware http://github.com/acalatrava/openhaystack-firmware/
This one should work fine on a nRF51 module (tested!)

@junleus please test it and tell me how much it consume. Also, how are you measuring it?

@jaekim24 I'm using this module https://www.aliexpress.com/item/32826502025.html with a CR2032 cell coin battery. Battery still at 2.96V :)

@junleus
Copy link

junleus commented May 10, 2021

@acalatrava

  • I used a multimeter with dc amps to measure.
  • I git clone your repository again, compiled new firmware, ether your and mine does not send the advertisements.
  • Can you use the LightBlue app to scan the nRF51? when your iPhone beside the nRF51, the signal should be less than 30db.

image

@acalatrava
Copy link
Author

Yes, I can confirm mine is working. In fact it appears on OpenHaystack app. Can you try with the compiled one from the releases?

https://github.com/acalatrava/openhaystack-firmware/releases/download/0.1/nrf51_firmware.bin

@mowtschan
Copy link
Contributor

@junleus unfortunately on my iPhone I'm unable to find my nrf51 but with the Macbook it works, I can even see exactly which device is mine:

  1. copy adv. key:

image

  1. run command and see from byte 7 which public key has your device(just 3-4bytes would be enough):

image

  1. On mac I'm using BlueSee tool (https://apps.apple.com/de/app/bluesee-ble-debugger/id1336679524?mt=12):

image

@junleus
Copy link

junleus commented May 10, 2021

@acalatrava
I flash that one too, no luck.

there are a little bit different of mine chip.
image

@mowtschan
I am using multimeter measure the power consume, the chip keep 5uA, so I pretty sure no advertisements send. seem keep sleeping.

@acalatrava
Copy link
Author

I’m pretty sure it’s working. The thing is that the advertisement is set every 5 seconds. Sometimes on the iPhone won’t appear after 10 or even 20 seconds. Probably you are seeing 5uA because most of the time is sleeping :)

try changing the advertisement interval or try this app which seems to work better to see the device on iPhone
https://apps.apple.com/es/app/ebeacon-ble-scanner/id730279939

@junleus
Copy link

junleus commented May 11, 2021

@mowtschan
what kind of chipset you are using? I used the same way of compiled the s130-beacon app, running well.

image

my chipset info
Info : nRF51822-QFAA(build code: H2) 256kB Flash, 16kB RAM
and
Info : nRF51822-QFAA(build code: H0) 256kB Flash, 16kB RAM

@mowtschan
Copy link
Contributor

@junleus I bought it by AliExpress here: https://www.aliexpress.com/item/33061215469.html?spm=a2g0s.9042311.0.0.27424c4dgqLbvo
P.S.: just to clarify: I’m using original firmware from openhaystack.

@acalatrava
Copy link
Author

acalatrava commented May 11, 2021

@junleus if the s130-beacon is working then my firmware should work too. Did you try to change the advertising interval? Try to change it to 100, that way you should see it on the light blue app or similar
https://github.com/acalatrava/openhaystack-firmware/blob/eef0a6b81e405b79027f0cf450c3e4b3322a76b3/apps/openhaystack-alternative/main.c#L10

by the way, your board is the same as mine! So...

@junleus
Copy link

junleus commented May 11, 2021

I ordered 2 nRF52832, will test it then.

@acalatrava
Copy link
Author

Which modules did you order?

you should try the firmware on the nRF51 during the day and check if the location is being updated on the app

@jaekim24
Copy link

@junleus I bought the same one and it arrived today!

@jaekim24
Copy link

im trying to flash the nRF52 but idk where to connect my VCC port from my J-Link debugger to the nRF52 module and also which ground am I supposed to connect to on the nRF52 module
Screen Shot 2021-05-12 at 5 36 12 PM

@sebi5361
Copy link

sebi5361 commented Jul 1, 2021

I just measured the consumption of OpenHaystack (ultra low power) alternative firmware on an nRF51822 board equipped with a low frequency crystal (Holyiot YJ-14001 BLE module) using my freshly received NORDIC Power Profiler Kit II.
This board's hardware is similar to the official AliExpress Beacon (nRF51822, crystal).

Below are the results:

Full cycle:

Broadcasting mode:

Sleep mode:

Zoom on sleep mode:

According to those readings, the average power consumption is 7.85uA which makes a 3V CR2032 230mAh battery last more than 3 years:

230/0.00785 = 29299 hours = 1220 days = 3.34 years.

Those results seem to be coherent with the multimeter measurements done by @mowtschan and the battery duration computed by @acalatrava .

@sebi5361
Copy link

sebi5361 commented Jul 1, 2021

To compare current consumptions, I compiled the OpenHaystack (ultra low power) alternative firmware firmware for my Holyiot YJ-14001 BLE module (nRF51822) using the internal RC oscillator instead of the low frequency 32768 kHz external crystal oscillator.

I used NRF_MODEL=nrf51 BOARD_SIMPLE make build to generate the firmware and it works fine as the beacon can be found in the OpenHaystack map.

Here is a comparison chart:

Low Frequency Oscillator Average Current Consumption @ 3V
External 32768 kHz crystal 7.85 uA
Internal RC circuit 8.24 uA (14% more)

This result corroborates this external Crystal vs internal RC oscillator comparison discussion.

In a nutshell it is better to have a board equipped with a low-frequency 32768 kHz external crystal oscillator to save a little bit of power.

The optional low-frequency 32768 kHz external crystal oscillator is this component below (red arrow):

The other oscillator on the board (larger, squarish) is the high-frequency 32 MHz oscillator mandatory for the MCU to function.

@sebi5361
Copy link

sebi5361 commented Jul 1, 2021

I measured the consumption of OpenHaystack ultra low power alternative firmware on an nRF52832 board equipped with NO external low frequency crystal (Holyiot YJ-17095):

This board's hardware is similar to the official eByte E104-BT5032A's hardware (nRF52832, NO crystal).

Thus I used NRF_MODEL=nrf52 BOARD_E104BT5032A make build to generate the firmware.

Note that: e104bt5032a_board.h and simple_board.h are the same and correspond to boards with low frequency internal RC oscillators.

My board seems to broadcast correctly as it can be found in the OpenHaystack map.

Hower power consumption is over the charts compared to previous results:
It is 37uA in average (4x more than for my nRF51822 board).

Current consumption looks like this:

There is a spike every ~12.5ms.
Any idea why I observe such a high power consumption?

@acalatrava
Copy link
Author

I put the firmware on a E104-BT5032A one month ago and it seems that the battery is depleting quickly, so it seems this is also happening on this board.... not sure why though. Can you test with some other program?

@sebi5361
Copy link

sebi5361 commented Jul 2, 2021

@acalatrava: If you send me firmwares for nRF52832 with NO crystal you are developing to solve this consumption issue, I can patch them with my advertisement key, test them and measure their current consumptions. Is this what you mean by "test with some other program" (firmware)?

@sebi5361
Copy link

sebi5361 commented Jul 8, 2021

@acalatrava: BTW, did you enable the built-in DC/DC regulator to save some energy (if the boards support it)?
See this explanation and this schematic.
Here someone claims enabling the DC/DC regulator can save up to 40% power consumption...

@sebi5361
Copy link

sebi5361 commented Jul 14, 2021

Average Power Consumption (in uA @ 3V)

I compared the power consumption of my Holyiot YJ-14001 BLE module (nRF51822) with different settings:

Low-Frequency Oscillator / Internal Power Supply Regulator LDO (Default) DC/DC
Internal RC Circuit (Default) 9.21 9.64
External 32.768 kHz Crystal 7.60 7.98

Note: to enable the DC/DC regulator I added line sd_power_dcdc_mode_set(1); before the while loop in main.c. This could be done as the Holyiot YJ-14001 BLE module is populated with the proper LC components required to enable this feature (see Nordic InfoCenter for explanations). I don't know about the official AliExpress beacon. Contrary to what I read, switching the regulator from LDO to DC/DC didn't improve power consumption.

TLDR

The lowest power consumption was obtained enabling the external 32.768 kHz crystal together with the LDO regulator.

Current Measurement Screenshots

Below are screenshots of the measurements made using my NORDIC Power Profiler Kit II for the different settings.
Note the spikes due to clock calibrations here and there (see explanations from the Nordic DevZone) when selecting the internal RC oscillator.

N51-RC-LDO

ppk-20210714T202427

N51-XTAL-LDO

ppk-20210714T201929

N51-RC-DCDC

ppk-20210714T202854

N51-XTAL-DCDC

ppk-20210714T204819

@sebi5361
Copy link

sebi5361 commented Jul 14, 2021

An additional comment:
Not all AliExpress beacons are populated with the low frequency external crystal.

Check it out before enabling the external low-frequency 32.768 kHz crystal.

@junleus
Copy link

junleus commented Jul 14, 2021

I checked this before, per the beacon do not need the 32k crystal.so all beacon device will not have this 32k crystal.

@sebi5361
Copy link

Note the 4s interval spikes due to the clock calibration involved when using the internal low-frequency RC oscillator (see figure N51-RC-LDO blue rectangles) (orange rectangles correspond to 5s interval broadcasting spikes):
2021-07-16 00 10 22
Those spikes are responsible for the extra average power consumption compared to enabling the external low-frequency 32.768kHz crystal (9.21uA vs 7.60uA).

@Furtivo360
Copy link

Hi all! Good stuff in here, thanks for all your good work! 💯 👍
QQ: I am not really sure if I've done the right thing.

I've copied the main.c content from this file:
Screenshot 2021-12-07 at 20 34 48

moved inside the openhaystack-main folder of the openhaystack application (see blow), pasted the "modded low power" main.c script inside the original one and saved.

Screenshot 2021-12-07 at 19 17 17

Is my understanding correct that whenever I will now generate the FW from the screen here below, the .bin will now be a modded one with the low power consumpiton feature?

Screenshot 2021-12-07 at 19 17 24

Note: I've checked the shasum between the first original .bin firmware and the second modded .bin file and I can see 2 different ashes, this would make me think that I may be right...

Please let me know if I am doing it correctly or if I am completely on the wrong way :)

Thanks!

Deo

@Sn0wfreezeDev
Copy link
Member

Hi @Furtivo360,

Please follow @acalatrava's Readme to compile the firmware and install it on your device. It does not work to move it into the OpenHaystack app since the installation is more involved here.

Kind regards
Alexander

@mearsy
Copy link

mearsy commented Mar 4, 2022

Hi @Furtivo360,

Please follow @acalatrava's Readme to compile the firmware and install it on your device. It does not work to move it into the OpenHaystack app since the installation is more involved here.

Kind regards Alexander

I just bought one of these for testing

https://www.aliexpress.com/item/32826502025.html

My question is, @acalatrava provides precompiled NRF51 firmware at

https://github.com/acalatrava/openhaystack-firmware/tree/main/apps/openhaystack-alternative/compiled

So I moved it into the app as such Openhaystack --> Contents --> NRF.

NRF folder only seemed to contain firmware for NRF52 so I renamed the format on my file to NRF51_NRF51822.openHayStack.hex.

First thing I noted. His compiled firmware seemed big at 2.2mb vs the 500k for the existing ones

Second question. Do I have the naming format correct. i.e will Openhaystack detect the device as being a NRF51822 and pick up and use the new firmware.

Finally the most important newbie question. How to program it. Am I correct in assuming just connecting the STlink V2 up to the correct pins, I will be able to flash the device directly from the Openhaystack app with the option "Deploy NRF device"?

Apologies for the N00b questions.

@igormak
Copy link

igormak commented Jun 2, 2023

I just created an alternative firmware that is compatible with both nRF51 and nRF52 platforms. It's using the Softdevice S130/S132 2.0.0 from Nordic SDK11.

I already tried it on this modules:

More info here: https://github.com/acalatrava/openhaystack-firmware/tree/main/apps/openhaystack-alternative

How to build firmware for nRF52810?

@SergeKZ
Copy link

SergeKZ commented Jun 29, 2023

How to build firmware for nRF52810?

did you find a solution?

@jaekim24
Copy link

How to build firmware for nRF52810?

did you find a solution?

I made this guide idk if it still works, but give it a try! I used the nRF52__ chip . https://docs.google.com/document/d/1lYstdm9G9HqyQjmxhz5JeDIKgajz7qRh4d1rxbnaFtY/edit?usp=sharing

@igormak
Copy link

igormak commented Jun 30, 2023

How to build firmware for nRF52810?

did you find a solution?

No, I never managed to build for nRF52810

@igormak
Copy link

igormak commented Jun 30, 2023

How to build firmware for nRF52810?

did you find a solution?

I made this guide idk if it still works, but give it a try! I used the nRF52__ chip . https://docs.google.com/document/d/1lYstdm9G9HqyQjmxhz5JeDIKgajz7qRh4d1rxbnaFtY/edit?usp=sharing

Are different softdevices used for nRF52832 and nRF52810?

@SergeKZ
Copy link

SergeKZ commented Jun 30, 2023

I made this guide idk if it still works, but give it a try! I used the nRF52__ chip . https://docs.google.com/document/d/1lYstdm9G9HqyQjmxhz5JeDIKgajz7qRh4d1rxbnaFtY/edit?usp=sharing

this manual is not suitable for NRF52810

@SergeKZ
Copy link

SergeKZ commented Jun 30, 2023

How to build firmware for nRF52810?

did you find a solution?

No, I never managed to build for nRF52810

there are ideal beacons on aliexpress with NRF52810, but there is no firmware =(

@SergeKZ
Copy link

SergeKZ commented Jun 30, 2023

I just created an alternative firmware that is compatible with both nRF51 and nRF52 platforms. It's using the Softdevice S130/S132 2.0.0 from Nordic SDK11.

I already tried it on this modules:

More info here: https://github.com/acalatrava/openhaystack-firmware/tree/main/apps/openhaystack-alternative

tell me what you need to change in your firmware to compile under nrf52810

@Itheras
Copy link

Itheras commented Jul 3, 2023

How to build firmware for nRF52810?

did you find a solution?

No, I never managed to build for nRF52810

there are ideal beacons on aliexpress with NRF52810, but there is no firmware =(

I am testing a firmware for nrf52810. will share soon.

@SergeKZ
Copy link

SergeKZ commented Jul 3, 2023

I am testing a firmware for nrf52810. will share soon

@Itheras thanks I will test the power consumption and share the results

@Itheras
Copy link

Itheras commented Jul 6, 2023

@SergeKZ try this use it like this. NRF_MODEL=nrf52810 ADV_KEY=base64advkey make patch
removed the bin will upload source soon.

@SergeKZ
Copy link

SergeKZ commented Jul 10, 2023

will upload source soon.

@Itheras how is the progress?

@SergeKZ
Copy link

SergeKZ commented Jul 21, 2023

@Itheras do you need help?

@malmeloo
Copy link

@Itheras your firmware works wonderfully, could you please release the source code for it?

@malmeloo
Copy link

Thanks! 🙂

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

No branches or pull requests