Go Back   Zune Boards > News and Website Related > Zune News

Zune News All Zune news.

Closed Thread
 
LinkBack (620) Thread Tools
Old 12-31-2008, 04:16 PM   620 links from elsewhere to this Post. Click to view. #1 (permalink)
you lost the game.
zB Programmer
Moderator
Elite Zuner
 
itsnotabigtruck's Avatar
 
Join Date: May 2008
Posts: 2,434
itsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud of
Default Cause of Zune 30 leapyear problem ISOLATED!

After doing some poking around in the source code for the Zune's clock driver (available free from the Freescale website), I found the root cause of the now-infamous Zune 30 leapyear issue that struck everyone on New Year's Eve.


The Zune's real-time clock stores the time in terms of days and seconds since January 1st, 1980. When the Zune's clock is accessed, the driver turns the number of days into years/months/days and the number of seconds into hours/minutes/seconds. Likewise, when the clock is set, the driver does the opposite.

The Zune frontend first accesses the clock toward the end of the boot sequence. Doing this triggers the code that reads the clock and converts it to a date and time. Below is the part of this code that determines the year component of the date:

Code:
year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
    if (IsLeapYear(year))
    {
        if (days > 366)
        {
            days -= 366;
            year += 1;
        }
    }
    else
    {
        days -= 365;
        year += 1;
    }
}
Under normal circumstances, this works just fine. The function keeps subtracting either 365 or 366 until it gets down to less than a year's worth of days, which it then turns into the month and day of month. Thing is, in the case of the last day of a leap year, it keeps going until it hits 366. Thanks to the if (days > 366), it stops subtracting anything if the loop happens to be on a leap year. But 366 is too large to break out of the main loop, meaning that the Zune keeps looping forever and doesn't do anything else.

The unfortunate part is that there isn't anything that can be done to fix this besides somehow changing what the clock is set to (which is exactly what the battery disconnection trick ends up doing). On the other hand, it shows that Microsoft is correct: tomorrow, everyone's Zunes will operate normally again. However, if Microsoft doesn't fix this part of the firmware, the whole thing will happen all over again in 4 more years.. Hopefully by then a fix will be in place.

/truck out
__________________

signature by vettexl

Last edited by itsnotabigtruck; 12-31-2008 at 04:26 PM. Reason: switched to pastie




itsnotabigtruck is offline  

Advertisement [Remove Advertisement]
Old 12-31-2008, 04:20 PM   #2 (permalink)
Squirt
 
Join Date: Jun 2007
Posts: 13
juryben is on a distinguished road
Default

Is it even possible to fix?
Zune doesn't work when frozen and Zune doesn't work with a dead battery....
__________________



juryben is offline  
Old 12-31-2008, 04:25 PM   #3 (permalink)
Irrational furniture.
Support Team
Retired Staff
Zune Freak
 
Join Date: Aug 2008
Location: Chicago
Posts: 1,065
Pokeyourheadoff is a name known to allPokeyourheadoff is a name known to allPokeyourheadoff is a name known to allPokeyourheadoff is a name known to all
Send a message via ICQ to Pokeyourheadoff Send a message via AIM to Pokeyourheadoff Send a message via MSN to Pokeyourheadoff Send a message via Yahoo to Pokeyourheadoff
Default

|No, it will never be fixed.|
Anyway, good find!




Pokeyourheadoff is offline  
Old 12-31-2008, 04:27 PM   #4 (permalink)
Super Zuner
 
Tobososlow's Avatar
 
Join Date: Nov 2007
Location: In a hypocritical world
Posts: 1,663
Tobososlow is a name known to allTobososlow is a name known to allTobososlow is a name known to allTobososlow is a name known to all
Default

I wonder how many people will still be using Zune 30's in 4 years.
__________________




Tobososlow is offline  
Old 12-31-2008, 04:33 PM   #5 (permalink)
God
α+ω
Retired Staff
Professional Spammer
 
Join Date: Jan 2007
Location: Look up
Posts: 7,801
God has much to be proud ofGod has much to be proud ofGod has much to be proud ofGod has much to be proud ofGod has much to be proud ofGod has much to be proud ofGod has much to be proud of
Send a message via AIM to God Send a message via MSN to God Send a message via Yahoo to God Send a message via Skype™ to God
Awards Showcase
Biggest Abuser of Noobs Trogdor's Peasant Favorite zB Extremity 
Total Awards: 3
Default

That code is pretty simple to correct, it's just a simple enough goof. Just have to recompile the driver, put it into the firmware and send out a firmware update, unless I'm missing something.
__________________
Quote:
Originally Posted by sb
10:15 PM <Marshillboy> I almost never eat out

Nurta.net cures 29 known diseases



God is offline  
Old 12-31-2008, 04:36 PM   #6 (permalink)
you lost the game.
zB Programmer
Moderator
Elite Zuner
 
itsnotabigtruck's Avatar
 
Join Date: May 2008
Posts: 2,434
itsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud of
Default

Quote:
Originally Posted by Tobososlow View Post
I wonder how many people will still be using Zune 30's in 4 years.
Good point.

Quote:
Originally Posted by M&N View Post
That code is pretty simple to correct, it's just a simple enough goof. Just have to recompile the driver, put it into the firmware and send out a firmware update, unless I'm missing something.
Yeah. The ZuneInsider post didn't seem to imply it was something they were planning on correcting right away though.
__________________

signature by vettexl




itsnotabigtruck is offline  
Old 12-31-2008, 04:39 PM   #7 (permalink)
Experienced Member
 
LancerRevolution's Avatar
 
Join Date: Jun 2007
Location: El Paso, TX
Posts: 880
LancerRevolution is just really niceLancerRevolution is just really niceLancerRevolution is just really nice
Default

wow, i got this....my zune keeps freezing at the load screen and have to let die wtf. oh well, not like im a constant user, meh.
__________________

Thank you very much Grim




LancerRevolution is offline  
Old 12-31-2008, 04:49 PM   #8 (permalink)
God
α+ω
Retired Staff
Professional Spammer
 
Join Date: Jan 2007
Location: Look up
Posts: 7,801
God has much to be proud ofGod has much to be proud ofGod has much to be proud ofGod has much to be proud ofGod has much to be proud ofGod has much to be proud ofGod has much to be proud of
Send a message via AIM to God Send a message via MSN to God Send a message via Yahoo to God Send a message via Skype™ to God
Awards Showcase
Biggest Abuser of Noobs Trogdor's Peasant Favorite zB Extremity 
Total Awards: 3
Default

Quote:
Originally Posted by itsnotabigtruck View Post
Good point.



Yeah. The ZuneInsider post didn't seem to imply it was something they were planning on correcting right away though.
They'll stick it in next update. I'm sure they will update it within 4 years...
__________________
Quote:
Originally Posted by sb
10:15 PM <Marshillboy> I almost never eat out

Nurta.net cures 29 known diseases



God is offline  
Old 12-31-2008, 05:41 PM   #9 (permalink)
Squirt
 
Join Date: Jun 2008
Posts: 23
gamefreak202 is on a distinguished road
Default

so how does one disconnect the battery, and is there a way I can trick my zune into thinking its tomorrow by possibly changing the date on my PC?
__________________



gamefreak202 is offline  
Old 12-31-2008, 05:45 PM   #10 (permalink)
you lost the game.
zB Programmer
Moderator
Elite Zuner
 
itsnotabigtruck's Avatar
 
Join Date: May 2008
Posts: 2,434
itsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud of
Default

Quote:
Originally Posted by gamefreak202 View Post
so how does one disconnect the battery, and is there a way I can trick my zune into thinking its tomorrow by possibly changing the date on my PC?
Disconnecting the battery requires opening it up, which is totally not worth it when it's going to start working again without any further action tomorrow.

AFAIK, the clock is set by downloading a file from Microsoft's DRM servers (to make it hard to mess with the clock and therefore listen to expired Zune Pass tracks), so your PC time doesn't even matter.
__________________

signature by vettexl




itsnotabigtruck is offline  
Old 12-31-2008, 05:54 PM   #11 (permalink)
Squirt
 
Join Date: Jun 2008
Posts: 23
gamefreak202 is on a distinguished road
Default

ok then so your saying it will be fine by tomorrow....? Guaranteed?
__________________



gamefreak202 is offline  
Old 12-31-2008, 07:28 PM   #12 (permalink)
Squirt
 
Join Date: Dec 2008
Posts: 10
programphases is on a distinguished road
Default

Great work itsnotabigtruck!



programphases is offline  
Old 12-31-2008, 07:31 PM   #13 (permalink)
Zewbie
 
Join Date: Dec 2008
Posts: 6
freshlogic is on a distinguished road
Default

I think changing line 263 from "if(days > 366)" to "if(days >= 366)" might fix the bug: Twitter / Shawn Miller: I think changing line 263 ...



freshlogic is offline  
Old 12-31-2008, 07:41 PM   #14 (permalink)
Squirt
 
Join Date: Dec 2008
Posts: 10
programphases is on a distinguished road
Default

Quote:
Originally Posted by freshlogic View Post
I think changing line 263 from "if(days > 366)" to "if(days >= 366)" might fix the bug...
I was thinking the same thing (edit: wrong...see below) when analyzing it.

--

The complete output from stepping through the loop starting 10593 days from January 1st 1980 can be found HERE.

Last edited by programphases; 12-31-2008 at 08:53 PM. Reason: merged 2 consecutive posts (ffr, use edit)



programphases is offline  
Old 12-31-2008, 08:30 PM   #15 (permalink)
Zewbie
 
Join Date: Dec 2008
Posts: 6
twhoffman is on a distinguished road
Default

Quote:
Originally Posted by freshlogic View Post
I think changing line 263 from "if(days > 366)" to "if(days >= 366)" might fix the bug:
That would prevent the infinite loop, but would introduce a new bug where it advances the year on the last day of a leap year. It would have thought today was December 31, 2009. That's better than locking up, but it also would mean that all time-limited DRM media would stop working. So, if you have a Zune Pass, none of your songs would play.

What's needed is a break within an else like this (I hope, my C's a little rusty, and was never that good to begin with):

Code:
year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
    if (IsLeapYear(year))
    {
        if (days > 366)
        {
            days -= 366;
            year += 1;
        }
        else
        {
            break;
        }
    }
    else
    {
        days -= 365;
        year += 1;
    }
}

Last edited by twhoffman; 12-31-2008 at 08:32 PM.



twhoffman is offline  
Old 12-31-2008, 08:39 PM   #16 (permalink)
Zewbie
 
Join Date: May 2008
Posts: 1
Zero_X is on a distinguished road
Default

wow, great work, I was so confused when I turned mine on today it was like "wtf?!" but I understand now.



Zero_X is offline  
Old 12-31-2008, 08:46 PM   #17 (permalink)
Zuner
 
Ultima's Avatar
 
Join Date: Sep 2008
Location: Sacremento CA
Posts: 82
Ultima is on a distinguished road
Send a message via AIM to Ultima
Default

cool thats good. i thought my zune was done for good which would have really sucked.
__________________
yeah, it got me too
"What can be asserted without evidence, can be dismissed without evidence"-Christopher Hitchens




Ultima is offline  
Old 12-31-2008, 08:52 PM   #18 (permalink)
Squirt
 
Join Date: Dec 2008
Posts: 10
programphases is on a distinguished road
Default

Quote:
Originally Posted by twhoffman View Post
That would prevent the infinite loop, but would introduce a new bug where it advances the year on the last day of a leap year. It would have thought today was December 31, 2009. That's better than locking up, but it also would mean that all time-limited DRM media would stop working. So, if you have a Zune Pass, none of your songs would play.

What's needed is a break within an else like this (I hope, my C's a little rusty, and was never that good to begin with):

Code:
year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
    if (IsLeapYear(year))
    {
        if (days > 366)
        {
            days -= 366;
            year += 1;
        }
        else
        {
            break;
        }
    }
    else
    {
        days -= 365;
        year += 1;
    }
}
Will the break release from the outer if statement? (edit: yes...see below)

This should work too:

Code:
year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
    if (IsLeapYear(year))
    {
        if (days > 366)
        {
            days -= 366;
            year += 1;
        }
        else if (days == 366)
           days -= 366;
    }
    else
    {
        days -= 365;
        year += 1;
    }
}

Last edited by programphases; 12-31-2008 at 09:10 PM.



programphases is offline  
Old 12-31-2008, 08:54 PM   #19 (permalink)
you lost the game.
zB Programmer
Moderator
Elite Zuner
 
itsnotabigtruck's Avatar
 
Join Date: May 2008
Posts: 2,434
itsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud of
Default

Quote:
Originally Posted by programphases View Post
Will the break release from the outer if statement?

Maybe this:

<snipped>
The break statement in C breaks out of the nearest loop (ignoring any ifs on the way back up).
__________________

signature by vettexl




itsnotabigtruck is offline  
Old 12-31-2008, 09:07 PM   #20 (permalink)
Squirt
 
Join Date: Dec 2008
Posts: 10
programphases is on a distinguished road
Default

Quote:
Originally Posted by itsnotabigtruck View Post
The break statement in C breaks out of the nearest loop (ignoring any ifs on the way back up).
...silly me...



programphases is offline  
Closed Thread

Bookmarks

Thread Tools