Ticket #2156 (closed defect: fixed)

Opened 11 years ago

Last modified 2 years ago

rtctest.c does not exit with stable-tracking kernel

Reported by: lindi Owned by: balajirrao
Priority: normal Milestone:
Component: kernel Version: unspecified
Severity: normal Keywords:
Cc: werner@… Blocked By:
Blocking: Estimated Completion (week):
HasPatchForReview: no PatchReviewResult:


Steps to reproduce:
1) build and boot stable-tracking kernel
2) modprobe rtc-s3c
3) gcc -o rtctest rtctest.c
4) ./rtctest

Expected results
4) rtctest prints debug texts and exits

Actual results
4) rtctest prints the following but does not exit

                        RTC Driver Test Example.

...Update IRQs not supported.

Current RTC date/time is 3-12-2008, 15:48:00.
Alarm time now set to 15:48:20.
Waiting 5 seconds for alarm...

More info:
1) rtctest.c is extracted from Documentation/rtc.txt and attached to this bug report.


rtctest.c (5.6 KB) - added by lindi 11 years ago.

Change History

Changed 11 years ago by lindi

comment:1 Changed 11 years ago by andy

Can you try this with andy-tracking kernel? This has Balaji's changes to pcf50633 and the rtc on there. Stable-tracking isn't representative of what we will fork to make the new stable since it lacks a bunch of stuff in andy-tracking.

comment:2 Changed 11 years ago by andy

Duh reading your original post again: the s3c rtc is not used on GTA02, it's the one in the PMU that is used.

comment:3 Changed 11 years ago by lindi

rmmod rtc-s3c does not change the result of the test. I'll try arrange time to test andy-tracking kernel too. Does rtctest.c work there for you?

comment:4 Changed 11 years ago by andy

I don't have a GTA02 where I am right now to test it, I'll try it tomorrow.

You can get a quick and dirty binary of andy-tracking kernel http://people.openmoko.org/andy.

comment:5 in reply to: ↑ description Changed 11 years ago by balajirrao

  • Cc werner@… added
  • Status changed from new to accepted
  • Component changed from System Software to Distro
  • Owner changed from openmoko-kernel to balajirrao

I've seen this. The program uses ALM_SET to set the alarm. In the kernel sources you might observe ALM_SET is setting wkday to -1. This results in the wkday register in pcf50633 being set wrongly and hence your rtctest works only on one day of the week (in my case, on Friday).

The comment in the sources (drivers/rtc/rtc-dev.c) says WKALM_SET be used instead. Werner's wkalarm uses this - http://svn.openmoko.org/developers/werner/wkalrm/wkalrm.c and it worked fine when I tried it last time.

I don't know why ALM_SET doesn't work. Werner, can you help us with this ?

comment:6 Changed 11 years ago by balajirrao

  • Component changed from Distro to System Software

Sorry, changed Component to Distro by mistake. Fixed it.

comment:7 Changed 11 years ago by lindi

balajirrao, thanks a lot for your observations. I can have my phone wake up from suspend when I use WKALM_SET. With the above code I can now just say

 rtcwake `date +%s -d "now + 3 hours"` && susp && alarm

to have my phone sleep for 3 hours and then notify me :-)


#include <stdio.h>
#include <linux/rtc.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include <time.h>

int main(int argc, char **argv) {
    int fd, ret;
    struct rtc_wkalrm wkalrm;

    assert(argc == 2);

    fd = open("/dev/rtc0", O_RDONLY);

        struct tm *tm;
        time_t secs;

        secs = atol(argv[1]);
        assert(secs > 86400*365*(2000-1970));
        assert(secs < 86400*365*(2030-1970));
        tm = gmtime(&secs);

        wkalrm.time.tm_sec = tm->tm_sec;
        wkalrm.time.tm_min = tm->tm_min;
        wkalrm.time.tm_hour = tm->tm_hour;
        wkalrm.time.tm_mday = tm->tm_mday;
        wkalrm.time.tm_mon = tm->tm_mon;
        wkalrm.time.tm_year = tm->tm_year;
        wkalrm.time.tm_wday = tm->tm_wday;
        wkalrm.time.tm_yday = tm->tm_yday;
        wkalrm.time.tm_isdst = tm->tm_isdst;

    wkalrm.enabled = 1;
    ret = ioctl(fd, RTC_WKALM_SET, &wkalrm);
    assert(ret != -1);

    return 0;

comment:8 Changed 11 years ago by werner

Balaji, you gave me a good riddle there ;-)

wkalrm works more by accident - it just sends back the value it has
read. So as long as your alarm occurs on the same day, you're fine.
If not ... you'll have a good excuse for showing up late at work :-)

Further investigation on the kernel side shows that RTC_ALM_SET uses
a value of -1 to indicate that the field should be ignored. However,
we don't recognize this special value and just try to convert it into
BCD, apparently yielding Friday.

There are several ways of dealing with this. We could just handle a
tm_wday of -1 as "ignore", but that would still require applications
using RTC_WKALM_SET to set this field, which probably isn't something
we should expect them to do.

I posted a patch to openmoko-kernel that just unceremoniously ignores
tm_wday. This follows the example of mktime(3) that also ignores the
redundant fields tm_wday and tm_yday. We were already ignoring the

comment:9 Changed 11 years ago by balajirrao

Werner, thank you for the patch! I'll test it now.

comment:10 Changed 10 years ago by lindi

Hmm, what's the status of this bug? At least short sleeps with RTC_WKALM_SET still work reliably but I don't know if I should test extensively long sleeps (several days) or not.

comment:11 Changed 10 years ago by werner

If you could give it a try with the version using RTC_ALM_SET, that
would be nice. If it's okay, then we can close it. Seems that Balaji
hasn't found any trouble.

  • Werner

comment:12 Changed 10 years ago by andy

  • Status changed from accepted to closed
  • Resolution set to fixed

Seems it's fixed.

comment:13 Changed 2 years ago by JustDox

Acheter Viagra Pharmacie <a href=http://cialis.ccrpdc.com/buy-cialis-online-cheap.php>Buy Cialis Online Cheap</a> Amoxicillin Dosage Dental Amoxicillin Urinary Tract Infection <a href=http://kama1.xyz/kamagra-en-ligne.php>Kamagra En Ligne</a> Buy Cheap Nexium Online Secure Sites To Buy Cialis <a href=http://viag1.xyz/cheap-viagra-overnight.php>Cheap Viagra Overnight</a> Topical Propecia Risks Amoxicillin Protocols <a href=http://cial1.xyz/low-price-cialis.php>Low Price Cialis</a> Mebendazole Dapoxetina Serotonina <a href=http://lasix.ccrpdc.com/cheap-lasix-tablets.php>Cheap Lasix Tablets</a> How To Buy Ed Drugs From Canada Cialis Generico Acquisto Online <a href=http://cial1.xyz/cheap-cialis-20mg.php>Cheap Cialis 20mg</a> Comprar Cialis Sin Receta Medica Farmacia Nolvadex Vente <a href=http://kama1.xyz/how-much-is-kamagra.php>How Much Is Kamagra</a> Zithromax For Babies Cialis Pas Cher Pharmacie Paris <a href=http://zithromax.ccrpdc.com/compra-zithromax-online.php>Compra Zithromax Online</a> Amoxicillin Causes Liver Damage Viagra 100 Precio <a href=http://kama1.xyz/order-kamagra-online-usa.php>Order Kamagra Online Usa</a> Levaquin In Australia Shop Buy Tamoxifen Citrate Online <a href=http://cial5mg.xyz/cheap-cialis-40mg.php>Cheap Cialis 40mg</a> Cialis Come Cura Viagra Cialis Douleurs <a href=http://cial5mg.xyz/low-cost-cialis-online.php>Low Cost Cialis Online</a> On Line Pharmacys In India Viagra Through Mail <a href=http://viag1.xyz/cheap-viagra-generic.php>Cheap Viagra Generic</a> Cialis Vs Viagra Cost Kamagra Autorise En France <a href=http://cial5mg.xyz/order-cialis-online.php>Order Cialis Online</a> Buy Cheap Generic Propecia Find Worldwide Hydrochlorothiazide Pharmacy <a href=http://viag1.xyz/mail-order-viagra.php>Mail Order Viagra</a> Acquista Viagra In Italia Propecia Buy Propecia Merck <a href=http://cial5mg.xyz/order-cialis.php>Order Cialis</a> Baclofene Acheter En Ligne Cialis Donde Comprar <a href=http://zithromax.ccrpdc.com/price-generic-zithromax.php>Price Generic Zithromax</a> Is Amoxicillin Effective For Abcesses Amoxicillin Clavulonic Acid <a href=http://cial5mg.xyz/purchase-cheap-cialis.php>Purchase Cheap Cialis</a> Amoxicillin To Treat Lyme Cialis Original Kaufen <a href=http://cial1.xyz/buy-cialis-online-cheap.php>Buy Cialis Online Cheap</a> Cialis Ciao Cod Only Bentyl Where To Purchase <a href=http://viag1.xyz/cheap-viagra-pill.php>Cheap Viagra Pill</a> Buy Doxycycline In The Uk Priligy Cialis <a href=http://kama1.xyz/buy-cheap-kamagra.php>Buy Cheap Kamagra</a> Medrol Dose Pack From Canada Acticin Loxazol Next Day <a href=http://priligy.ccrpdc.com>Buy Priligy</a> Cialis Suisse Le Viagra Pour Les Jeunes <a href=http://cial5mg.xyz/where-to-buy-cialis.php>Where To Buy Cialis</a> Fish Flex Cephalexin Lexapro Pills In Canada No Prescription <a href=http://cial1.xyz/cheap-cialis-generic.php>Cheap Cialis Generic</a> Universal Propecia Viagra Farmaco Vasodilatatore <a href=http://cial5mg.xyz/cheap-cialis-online.php>Cheap Cialis Online</a> Canadian Health Mall Veterinary Prescription Antiobiotics Cephalexin <a href=http://kama1.xyz/kamagra-jelly.php>Kamagra Jelly</a> Buy Lexapro Online Uk Kamagra Lilly <a href=http://zol1.xyz/zoloft-online-pharmacy.php>Zoloft Online Pharmacy</a> Kwikmed Coupon Viagra Viagra Commander France <a href=http://viag1.xyz/cheap-viagra.php>Cheap Viagra</a> Proper Dosing Of Cephalexin Concorsi Levitra <a href=http://kamagra.ccrpdc.com/order-cheap-kamagra.php>Order Cheap Kamagra</a> Cialis Apothekenpreis Cialis 20 Compresse <a href=http://zol1.xyz/buy-sertraline-online-uk.php>Buy Sertraline Online Uk</a> Cheapest Propetia No Script Canada Can I Get Cytotec At Walmart <a href=http://cial5mg.xyz/cialis-usa.php>Cialis Usa</a> Buy Rodoxycycline Online Cialis 100mg Dosage <a href=http://kama1.xyz/order-kamagra.php>Order Kamagra</a> Achat Baclofen En France Cialis Se Puede Comprar Sin Receta Medica <a href=http://zol1.xyz/cheap-zoloft.php>Cheap Zoloft</a> El Cialis Se Puede Comprar Sin Receta Medica Cheap Tadalista <a href=http://cial1.xyz/generic-cialis-usa.php>Generic Cialis Usa</a> Cialis Cachets Sale Fedex Provera Low Price <a href=http://levitra.ccrpdc.com/order-levitra.php>Order Levitra</a> Where Is The Best Place To Buy Viagara Pastillas Cialis Precio <a href=http://viag1.xyz/viagra-100mg.php>Viagra 100mg</a> Real Propecia Results Effetti Viagra Rosa <a href=http://cial1.xyz/cheap-cialis-tablets.php>Cheap Cialis Tablets</a> Amoxicillin Pediatric Dosing Can I Buy Zithromax In Canada <a href=http://viag1.xyz/generic-sildenafil.php>Generic Sildenafil</a> Cialis On Line Italia Amoxicillin And Refrigeration <a href=http://strattera.ccrpdc.com/cheapest-strattera-online.php>Cheapest Strattera Online</a> Online Viagra Cialis Kaufen Cephalexin Info <a href=http://viag1.xyz/viagra-cheap-online.php>Viagra Cheap Online</a> Amoxicillin Joint Pain Amoxicillin Anti <a href=http://cial5mg.xyz/purchase-generic-cialis.php>Purchase Generic Cialis</a> Cialis Dolor De Cabeza Where To Buy Discount Dutasteride <a href=http://zol1.xyz/getting-zoloft-overseas.php>Getting Zoloft Overseas</a> Cialis Farmacia Espana Amoxicillin Overdose <a href=http://priligy.ccrpdc.com/priligy-on-line.php>Priligy On Line</a> Amoxicillin Canine Pharmaceutical Side Effects Cialis Canadian Pharmacy <a href=http://zol1.xyz/zoloft-free-trial.php>Zoloft Free Trial</a> Cytotec Online Pharmacy Uk

Note: See TracTickets for help on using tickets.