Announcement

Collapse
No announcement yet.

Announcement

Collapse
No announcement yet.

Need Clean Shutdown - solution for all corrupted TV sticks

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need Clean Shutdown - solution for all corrupted TV sticks

    http://forum.xda-developers.com/show...=866981&page=9 I cant seem to have stop my mk808 from corrupting and ultimately not booting without a new flash. Having done my research I have concluded that its due to unclean power offs. It can mess up your file systems and eventually youll need a reflash.

    Ways to find out whether your tv stick is cleanly shutdown is by Installing 'no-frill cpu.control' from play store. underclock your cpu. tick apply on boot.

    Poweroff your unit

    If its been turned off dirty. You will see a message with 'unclean' shutdown on the status bar.

    To get a clean shutdown you will need to kill all apps. unmount filesystem before sync-ing the shutdown command. So far there are no apps that does this. Everyone will get a corrupted tv.stick eventually.

    Im not a programmer myself so i cant help with.you people. the link i have above however will have scripts which.you can.compile yourself to remove the problem.

    #2
    Thank for this. I suspected i didn't have clean shutdowns, and no-frill said so too.


    from no-frill:
    "Be wary of the frequencies you select! Your phone may lock or become unresponsive if it doesn't like extreme values, but -hey- better safe than sorry: even though No-frills CPU Control allows you to choose if you want to apply the settings on boot, it comes with an extra "safety valve" too! If the device doesn't shut down (or reboot) in a clean way, it will not apply the settings, avoiding those nasty boot-loops you may have had with other overclocking apps. Please keep in mind that apps like QuickBoot are as quick as they are unsafe…"

    I'll look into the scripts when I have time.

    Anyone knows of a safe-shutdown-app yet?

    Comment


      #3
      Originally posted by magnemann View Post
      Thank for this. I suspected i didn't have clean shutdowns, and no-frill said so too.

      *****

      I'll look into the scripts when I have time.

      Anyone knows of a safe-shutdown-app yet?
      At least for MK 808 and MK 808B TV Sticks, a solution is available in Bob's Finless ROM 1.6 : " *****
      4) Powering your device down STABLE without it bricking! Included on the status bar is a power down soft button. USE IT! ***** NEVER JUST UNPLUG your TV player. It can brick the device and cause you to reflash ROM. ****** etc "

      vide : http://www.freaktab.com/showthread.p...1-6-Custom-ROM post #1

      It works great in my MK 808 ; you may try if you have the above stick.

      Comment


        #4
        Originally posted by sampu View Post
        At least for MK 808 and MK 808B TV Sticks, a solution is available in Bob's Finless ROM 1.6 : " *****
        4) Powering your device down STABLE without it bricking! Included on the status bar is a power down soft button. USE IT! ***** NEVER JUST UNPLUG your TV player. It can brick the device and cause you to reflash ROM. ****** etc "

        vide : http://www.freaktab.com/showthread.p...1-6-Custom-ROM post #1

        It works great in my MK 808 ; you may try if you have the above stick.
        Thanks for sharing.

        Well, no-frill complain about that app also. I have got corruptet rom and bootloop several times using that app. I'm not sure if it unmounts all file systems before rebooting.

        Maybe Finless or the maker of the app can confirm this?

        (Right now im testing another usb power supply to see if it will fix my corruption/bootloop... Maybe the reboot app is good after all. )

        Comment


          #5
          Originally posted by magnemann View Post
          Thanks for sharing.

          Well, no-frill complain about that app also. I have got corruptet rom and bootloop several times using that app. I'm not sure if it unmounts all file systems before rebooting.

          Maybe Finless or the maker of the app can confirm this?

          (Right now im testing another usb power supply to see if it will fix my corruption/bootloop... Maybe the reboot app is good after all. )
          Hi,

          I'll look at the code tonight at the code, but from what I remember, what I do to reboot, for example is :

          su
          sync; umount -a; reboot

          I'll tell you more when I'm back home.

          Comment


            #6
            Originally posted by sampu View Post
            At least for MK 808 and MK 808B TV Sticks, a solution is available in Bob's Finless ROM 1.6 : " *****
            4) Powering your device down STABLE without it bricking! Included on the status bar is a power down soft button. USE IT! ***** NEVER JUST UNPLUG your TV player. It can brick the device and cause you to reflash ROM. ****** etc "

            vide : http://www.freaktab.com/showthread.p...1-6-Custom-ROM post #1

            It works great in my MK 808 ; you may try if you have the above stick.
            Originally posted by petrus View Post
            Hi,

            I'll look at the code tonight at the code, but from what I remember, what I do to reboot, for example is :

            su
            sync; umount -a; reboot

            I'll tell you more when I'm back home.
            hi, petrus, thanks for taking time.
            Please explain in plain english the internals of the app.
            I hope it turns out that the app is compleately safe so I can eliminate it from my corruption issue.
            (Why does it shut down/reboot so much faster than on my Galaxy Nexys phone??)

            Comment


              #7
              Originally posted by magnemann View Post
              hi, petrus, thanks for taking time.
              Please explain in plain english the internals of the app.
              I hope it turns out that the app is compleately safe so I can eliminate it from my corruption issue.
              (Why does it shut down/reboot so much faster than on my Galaxy Nexys phone??)
              Ok, so here is an explanation of the app :

              The only way to shutdown or reboot from an app in android (the only ways that I know, in fact) is to launch "command line commands". That is to say the same thing you could do with the app "Terminal Emulator". It launches commands, like on any unix or linux system, or on windows, with the "cmd" utility.

              This the only way on android to do something as "superuser", which is needed to reboot or power off the system.

              So the first command "su" is to get "superuser rights" (you will be prompted at this point to give or not superuser rights to the Reboot app)

              Then, the "sync; umount -a; reboot" command is in fact 3 commands in 1

              The "sync" command flushes the write buffer. So it makes sure every data that has to be written on the SD card is really written. To understand that, you need to know that when an app "writes" on the sdcard, it is not written exactly when requested, but put in a "buffer" and physically written later, when enough data is in the buffer. This is to avoid too much write operations, which would slow down the system. But when you shut down, you have to ensure that every "write" operation is actually completed, or some modifications will be lost, and corruption is really likely to happen.

              The "umount -a" command tries to unmount any mounted filesystems. Like SDcard, any USB stick or external drive that was connected...

              Then the "reboot" command does exactly what it means, it reboots the system. For the power off command, it's in fact the "reboot -p" command that is called.

              So, I think I did everything as cleanly as possible, but, maybe the umount -a command may not work on some systems. Maybe the problem is there. And maybe I should try to list every mounted filesystem and unmount it explicitely before rebooting.

              Comment


                #8
                Is it possible the unmount or sync command is still processing when you issue the reboot?
                Is there a way to tell the process is complete bofre actually issuing the reboot command?
                Maybe this is part oif the issue?

                Sometimes when using the built in shutdown on the status bar, it does take it a while before it actually shuts down. Other times its almost instant. So it make me wonder if somehting is going on there and it is somehow checking that everything is flushed and unmounted?

                Bob
                "Pzebacz im, bo nie wiedzą, co czynią"
                "Прости им, они не ведают, что творят"
                "Perdona loro perché non sanno quello che fanno"
                "Vergib ihnen, denn sie wissen nicht, was sie tun"
                "Vergeef hen want ze weten niet wat ze doen"
                "Pardonne-leur car ils ne savent pas ce qu'ils font"
                "Perdónalos porque no saben que lo que hacen"
                "Oprosti im, jer ne znaju što čine"
                "Forgive them as they know not what they do"





                Comment


                  #9
                  Originally posted by Finless View Post
                  Is it possible the unmount or sync command is still processing when you issue the reboot?
                  Is there a way to tell the process is complete bofre actually issuing the reboot command?
                  Maybe this is part oif the issue?

                  Sometimes when using the built in shutdown on the status bar, it does take it a while before it actually shuts down. Other times its almost instant. So it make me wonder if somehting is going on there and it is somehow checking that everything is flushed and unmounted?

                  Bob
                  In fact, if Android acts like all Unix based systems, the ";" means executing commands in a sequential way ("&" does the same thing but in a parallel way)

                  So I really think "sync" is done when calling "unmount -a", which is done when calling "reboot"

                  Something weird I noticed when looking at some shutdown scripts, though, is that sync is sometimes called 3 times, like "sync; sync; sync;"

                  I don't know why though. Maybe some timing issue?

                  Anyway, it can't hurt, so, may be I can add 2 more sync calls in my reboot app.
                  I can also try something else :

                  instead of calling "umount -a", it could be safer to :
                  * list all mounted filesystems.
                  * unmount everything but / and /system
                  * remount /system read-only (I can't just unmount it as the reboot command is in /system/bin)
                  * then reboot or power off

                  Comment


                    #10
                    OK just thinking here....

                    Cant you do a cat /mounts and pipe it to somewhere, then look at it and parse the output.... If nothing shows as mounted you can then issue the reboot?

                    I think the sync sync sync thing is a bad way or work around. Typical of Android apps that have issues with different OS releases later, etc. Just my 2 cents... Doesnt make sense to me and doesnt seem right. Seems you can, with a little more work, figure out whats mounted?

                    Hey.... Just throwing out some ideas?


                    Bob
                    "Pzebacz im, bo nie wiedzą, co czynią"
                    "Прости им, они не ведают, что творят"
                    "Perdona loro perché non sanno quello che fanno"
                    "Vergib ihnen, denn sie wissen nicht, was sie tun"
                    "Vergeef hen want ze weten niet wat ze doen"
                    "Pardonne-leur car ils ne savent pas ce qu'ils font"
                    "Perdónalos porque no saben que lo que hacen"
                    "Oprosti im, jer ne znaju što čine"
                    "Forgive them as they know not what they do"





                    Comment


                      #11
                      petrus, great explanation of the app.
                      finless, good that you dont take the quality of a app for granted.

                      -maybe its wise first to look into what the reboot; command actually does in addition to cut power. Does it e.g. shut down processes/services?

                      -its important to know if sync; and umount; is sucessful. Maybe the can output some debug info to a log? Or have a exit code?

                      -Shouldnt all processes and services be terminated BEFORE sync; and umount;? If not, a process may write data to buffer AFTER sync; because android is true multitasking. I dont know this, just a thought.

                      BTW: I found that my charger has a usb port with bad connection. If i wiggleded the cable to one side, it lost power. I hope my corruption problems is gone on my new apple 2.4A charger.

                      Comment


                        #12
                        Interested in this.
                        First, big thanks to petrus for your work with the reboot apk. I am using it since i bought my tv stick, all my other android devices had a physical button to power down. I will keep an eye here.
                        REMEMBER, YOUR FEEDBACK IS VERY IMPORTANT TO US.
                        My devices:
                        Minix Neo X7; Minix Neo X8-H , Minix Neo Z64W & Z64 (Sponsored by Minix)
                        MK902 & MK902II(Sponsored by RKM)
                        Beelink M8B & Beelink R89 (Sponsored by Beelink)
                        Tronsmart VEGA S89H (Sponsored by
                        Gearbest.com)
                        MELE-PCG03 (Sponsored by Gearbest.com) Discount Coupon:MPCG03
                        Ainol Intel Z3735 MiniPC(Sponsored by Gearbest.com)
                        Thanks to them I can try to support your devices http://freaktab.com/core/images/smilies/wink.png

                        Comment


                          #13
                          I'll try to answer from what I understand :

                          - I'm not sure the reboot command really shuts down apps. Maybe a "kill" command would be nesessary, but it won't be easy to know which processes to kill and which have to stay. It may vary a lot with android versions and roms. But maybe that is the way to go.

                          - There doesn't seem to be a way to know if sunc is successful. And for the umount command, if it is not successful, another umount command should not have more success after.

                          - and of course, terminating apps before would be really safer.


                          Anyway, I tried a few things to unmount every mount point I find, but it is hard to determine which mount points can be unmounted safely.

                          It is obvious that / and /system should not be unmounted, or the final reboot command won't be found (it is under /system/bin)

                          I also found that I cannot unmount /proc, or the mount and umount commands will fail.

                          Maybe if I don't unmount, but simply remount everything read-only that will prevent filesystem errors?
                          What do you think of this idea?


                          Originally posted by magnemann View Post
                          petrus, great explanation of the app.
                          finless, good that you dont take the quality of a app for granted.

                          -maybe its wise first to look into what the reboot; command actually does in addition to cut power. Does it e.g. shut down processes/services?

                          -its important to know if sync; and umount; is sucessful. Maybe the can output some debug info to a log? Or have a exit code?

                          -Shouldnt all processes and services be terminated BEFORE sync; and umount;? If not, a process may write data to buffer AFTER sync; because android is true multitasking. I dont know this, just a thought.

                          BTW: I found that my charger has a usb port with bad connection. If i wiggleded the cable to one side, it lost power. I hope my corruption problems is gone on my new apple 2.4A charger.

                          Comment


                            #14
                            I'm still working on killing every running task that was not launched by the system. It may take some time.

                            Anyway I made a new version of the Reboot app, which :

                            * unmounts SDCARD
                            * unmounts any USB connected drive, if present
                            * tries to rermount everything else read-only
                            * then reboots or powers off.

                            I'll publish it soon (maybe one hour or 2 for testing), so keep watching the App forum.

                            Comment


                              #15
                              Luca Santarelli, the maker of 'no-frills cpu control' has given me som valuable info. I asked him how his app could detect if the 'previous' reboot/shutdown was 'clean'. He explains why petrus' reboot app is marked as 'unclean':

                              With his permission, the quote:


                              Hi! The answer to your question is easy: when Android performs a normal shutdown/reboot (as requested by the user through the power button), it broadcasts a message notifying applications of the shutdown.

                              When No-frills applies the frequencies, it writes a special property which means the settings were applied. When the shutdown (or reboot) signal is received, it deleted that special property.

                              If "Apply on boot" is enabled, when No-frills received the BOOT_COMPLETED signal, it checks for the existence of that special property. If it is found, it means the shutdown signal wasn't received and possibly the frequencyes are unstable, so it will not apply them again (unless you override the safety valve in the settings).

                              Now... let's come to your business. Doing "su; sync; umount; reboot" will give you a safe filesystem, but will not perform a clean shutdown, as it will not trigger the "user space" reboot signal in the Android platform.

                              If you have any Linux experience, Android is just like KDE or Gnome. If you perform a manual "shutdown", both of them will be hard-killed, and they will not be able to perform "closing operations". Android is the same. You need to trigger Android's own shutdown routines. I don't know how to do it as I have never dealt with that particular source code, but if you're willing, you can checkout CyanogenMod's source code as it has a "Power menu" filles with special reboot commands which perform a clean reboot. Looking at the code for that menu could give you an idea about what to do. Bye! L.
                              -------------------------------------


                              And the shutdown sequence is explained her:
                              http://kobablog.wordpress.com/2011/07/16/shutdown-sequence-of-android/
                              1. Broadcasts ACTION_SHUTDOWN Intent
                              2. Calls shutdown of ActivityManager service
                              3. Calls disable of Bluetooth service
                              4. Calls Radio(false) of Phone service
                              5. Calls shutdown of Mount service
                              6. Vibrate for a while
                              7. Calls Power.shutdown();

                              Comment

                              Working...
                              X