Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    ticks_ms() return big value at startup with custom firmware

    Scheduled Pinned Locked Moved Firmware
    10 Posts 3 Posters 59 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      thibault
      last edited by thibault

      Hello, i have try to use the frozen way for try. I have get a fine tar.gz image for flash a lopy. All seems fine, but there is a strange behaviour about the uptime() function of my module. my uptime function require ticks_ms() from utime for run fine. On the official firmware this run fine without problem (it is normal that when we use the machine.reset() function the utime() return was not reset?).

      But when i use the firmware from compilation (pycom-micropython-sigfox) ticks_ms() seems not be initialized at startup. It's not a problem for me, but i think it is not normal?

      Anybody have a same behaviour?

      Thank's for answer, and have a nice day.

      P.S.: os.uname()
      (sysname='LoPy', nodename='LoPy', release='1.20.2.r4', version='v1.20.1.r2-364-g915d42cca-dirty on 2021-03-10', machine='LoPy with ESP32', lorawan='1.0.2')

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @thibault
        last edited by robert-hh

        @thibault Which branch do you use for building? And what is the values that you get first?

        T 1 Reply Last reply Reply Quote 0
        • T Offline
          thibault @robert-hh
          last edited by

          @robert-hh i have follow the README.md of pycom-micropython-sigfox and i have use the branch pycomidf_v3.3.1 for pycom-esp-idf and the Dev branch for the pycom-micropython-sigfox.

          And at the startup of the device i get from ticks_ms() approx 1791996536 wich means 20 days 17 hours and 47 minutes..

          After i set the right clock value with rtc.init() the ticks_ms() return a more recent value with 546422236 wich mean 6 days 7 hours 46 minutes.

          Do you think that a such behaviour come from the Dev branch? Maybe it's not a good idea to use this dev branch? Do you have a suggestion for a better branch?

          Thank's

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @thibault
            last edited by

            @thibault I'm using the Dev branch too, and have not such huge values. This value is also not special by any means.
            ticks_ms() calls the espressif lib function gettimeofday(), which reads the RTC registers. So it's the RTC not being reset or set to strange value.

            T K 2 Replies Last reply Reply Quote 0
            • T Offline
              thibault @robert-hh
              last edited by

              @robert-hh thank's for the information. That trouble really. I have try the same firmware on two device and i get the same behaviour with nearly same value.

              On your firmware, you get right a value near 0 at startup for ticks_ms()?

              robert-hhR 1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @thibault
                last edited by

                @thibault If I add print(time.ticks_ms()) to main.py, I get values of ~1700. So that's fine and the boot time up to that point. Do you get these values too when you push reset?

                T 1 Reply Last reply Reply Quote 0
                • T Offline
                  thibault @robert-hh
                  last edited by

                  @robert-hh i think you have find that this behaviour come from my code.

                  When i add this print(time.ticks_ms()) in the main.py, i have get this value: 179199555

                  But i have see that my frozen code was launch before the new main.py. So i have write this print in the boot.py and now i get this value: 1337

                  And this remember me that i have a code wich set a default date at 1/1/2000... so i think this is was link to my strange behaviour of ticks_ms().

                  @robert-hh thank's you for helping me understand this behavior. I thought this ticks_ms function could be used as an alias for the uptime command, and that it is just a counter initialized at system startup, but obviously it is not! :) Have a great day!

                  1 Reply Last reply Reply Quote 0
                  • K Offline
                    kjm @robert-hh
                    last edited by

                    @robert-hh I'm surprised that time.ticks_ms() uses rtc registers Rob. I use time.ticks_ms() to track program flow rather than time.time() precisely because the former is unaffected when the rtc resyncs.

                    robert-hhR 1 Reply Last reply Reply Quote 0
                    • robert-hhR Offline
                      robert-hh @kjm
                      last edited by

                      @kjm It uses gettimeofday(). I understood from the espressif docs that this function gets its values from the RTC registers. But it may indeed be different.

                      K 1 Reply Last reply Reply Quote 0
                      • K Offline
                        kjm @robert-hh
                        last edited by

                        @robert-hh said in ticks_ms() return big value at startup with custom firmware:

                        gettimeofday()

                        Which brings me to my other question of do you know why gettimeofday() isn't available in userland?

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • 1 / 1
                        • First post
                          Last post

                        Pycom on Twitter

                        Pycom