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

Higher consumption on nRF52832 when boot from mcuboot #36

Open
vbelloir opened this issue Mar 10, 2021 · 12 comments
Open

Higher consumption on nRF52832 when boot from mcuboot #36

vbelloir opened this issue Mar 10, 2021 · 12 comments

Comments

@vbelloir
Copy link

Hi @lupyuen,
I'm working with @JF002 on power consumption of Pinetime watch, using Infinitime from JF.

I noticed that consumption is higher when Infinitime is booted by mcuboot than when it is stand-alone. Difference is about 500µA.

As a example, I disabled watchdog in bootloader, and add a simple __WFE loop in main function of Infinitime.
Booting from mcuboot gives a consumption of 574µA, while booting in stand-alone configuration gives 170µA.

Resources may be used in mcuboot/mynewt and not de-initialized in mcuboot, nor in Infinitime.

Do you have any idea for me? How can I identify which resource is consuming power?

Thanks for your help.
Vincent

@lupyuen
Copy link
Owner

lupyuen commented Mar 10, 2021

Is it possible that the SPI Flash is consuming the extra power?

Remember that MCUBoot starts the SPI Flash Driver to render the boot logo to the display.

Might be good to power off SPI Flash after rendering the boot logo.

@vbelloir
Copy link
Author

I don't really. I can make a try.

I was also asking myself if semihosting in mynewt, or serial log in mcuboot were or not activated.

I will see if I managed to deinit SPI flash, and keep you in touch.

@lupyuen
Copy link
Owner

lupyuen commented Mar 11, 2021

Yep thanks 🙂

@vbelloir
Copy link
Author

Hi @lupyuen,
I didn't try yet to deinit SPI Flash (and DMA!) before boot.

I opened same issue in mcuboot repo :
mcu-tools/mcuboot#958

But I don't really know how to implement answers I was given.
(And last few weeks, I had some difficulties to get time for that)

@vbelloir
Copy link
Author

DO you know how I can change mcuboot to point on nrfconnect fork?

@lupyuen
Copy link
Owner

lupyuen commented Mar 27, 2021

Sorry not sure about that. Could you post the question to the Mynewt or MCUBoot community on Slack?

https://mynewt.apache.org/community/

@vbelloir
Copy link
Author

vbelloir commented Mar 27, 2021

That's ok, I found how to do that:
So, in my mynewt project.yml file, I changed:

repository.mcuboot:
    type: github
    vers: 0-dev
    user: JuulLabs-OSS
    repo: mcuboot
With
repository.mcuboot:
    type: github
    vers: 0-dev
    user: mcu-tools
    repo: mcuboot

And perform a newt upgrade

$ newt upgrade
WARNING: Repo's "origin" remote points to unexpected URL: https://github.com/mcu-tools/mcuboot.git; correcting it to https://github.com/nrfconnect/sdk-mcuboot.git.  Repo contents may be incorrect.
Skipping "apache-mynewt-core": already upgraded (0.0.1)
Skipping "apache-mynewt-mcumgr": already upgraded (0.0.0)
Skipping "apache-mynewt-nimble": already upgraded (0.0.0)
Making the following changes to the project:
    upgrade mcuboot (579b30c29999860f9f7d843a25ff5453b6542cce --> 0.0.0)
mcuboot successfully upgraded to version 0.0.0

Now, I good error during compilation.

Compiling repos/mcuboot/boot/bootutil/src/tlv.c
Error: repos/mcuboot/boot/bootutil/src/loader.c: In function 'boot_validated_swap_type':
repos/mcuboot/boot/bootutil/src/loader.c:731:10: error: variable 'upgrade_valid' set but not used [-Werror=unused-but-set-variable]
  731 |     bool upgrade_valid = false;
      |          ^~~~~~~~~~~~~
cc1: all warnings being treated as errors

EDIT : manage to build project, deleting this variable. Quite ugly, but it works.

@vbelloir
Copy link
Author

vbelloir commented Apr 3, 2021

I tried to to back port this commit : nrfconnect/sdk-mcuboot@18a0a8a

And especially the function nrf_cleanup_peripheral.

I put this back port at startup of Infinitime , in main function.

You can find my work in this commit : vbelloir/InfiniTime@f486e4f

Do you think that I should do this in bootloader instead?
I try to deactivate spi with nrf_drv_spi_uninit but compilation failes.
Can you help?

Thanks.

@lupyuen
Copy link
Owner

lupyuen commented Apr 7, 2021

Sorry I'm tied up with LoRa on BL602, I won't be able to help right now.

I hope you're updating the new repo for PineTime Bootloader?

https://github.com/JF002/pinetime-mcuboot-bootloader

@nanch
Copy link
Contributor

nanch commented Apr 13, 2021

A savings of 500µA for managing the SPI flash sounds like a great win!

@vbelloir How are you measuring the current draw? I'd like to investigate this further.

Also, what's the compile error you're getting when you deactivate spi with nrf_drv_spi_uninit?

@vbelloir
Copy link
Author

Hi @nanch ,
right now, I only measure current draw with a 6.5digit multimeter Agilent 2000.
Letter, if possible, I can measure it with a Power Analyser Keysight N6705B, but it is not needed right now.

I don't really remember the compile error I had.
As you can see in my previous message, I don't modify bootloader (@lupyuen yes, I'm using JF002 fork of bootloader 👍 ), but I try to modify Infinitime startup, to get same consumption as when it is standalone.

@vbelloir
Copy link
Author

hi @nanch,
if you think you can help, it would be great. I got few time, and not very skilled in firmware.
I'm an hardware guy.

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

3 participants