rtc

QNX SDP8.0Utilities ReferenceUtilities

Set or get date and time from realtime clock (QNX OS)

Note:
You must be root or have the right abilities to run this utility.

Syntax:

Update the current time based on the time from the specified clock:

rtc [-b base[,reg_shift[,mem_map[,c_offset]]]]
    [-l] [-r rate] [-S seconds] clock_type clock_options

Set the time of the specified clock to the current time:

rtc -s [-b base[,reg_shift[,mem_map[,c_offset]]]]
    [-l] clock_type clock_options

Set the time of or enable or disable the RTC alarm:

rtc [-A alarm_time] [-a alarm_enable] clock_type clock_options

Runs on:

QNX OS

Options:

Note:
All other options are ignored when the RTC Alarm-related options (-A or -a) are used.
-A alarm_time
Set the realtime clock (RTC) alarm for the specified time. The format of the alarm_time string varies with the clock type being used. For details, see Alarm time-setting and alarm-enabling string formats below. This option can be specified only once per usage. To set the time for two alarms, you need to run rtc -A alarm_time twice.

If an alarm is enabled, setting a new alarm time does not disable the alarm.

-a alarm_enable
Enable or disable the RTC alarm. The format of the alarm_enable string varies with the clock type being used. For details, see Alarm time-setting and alarm-enabling string formats below. This option can be specified only once per usage. To enable two alarms, you need to run rtc -a alarm_enable twice.
-b base[,reg_shift[,mem_map[,c_offset]]]
The location of the RTC chip:
  • base — base address of the chip.
  • reg_shift — spacing of the device registers as a power of 2. For example:
    0
    Registers are 1 byte apart.
    1
    Registers are 2 bytes apart.
    2
    Registers are 4 bytes apart.
    n
    Registers are 2n bytes apart.

    The default reg_shift is 0.

  • mem_map — memory or I/O space.
  • c_offset — offset to the century byte in NVRAM.
-l
(el) Set hardware time to local time, not Coordinated Universal Time (UTC), or get (read) hardware time as local time and not UTC. UTC is the standard term for Greenwich Mean Time (GMT). The -l option has no effect if the clock type is net.
-r rate
The rate at which to adjust the OS time if it's currently within 60 seconds (or the value set by -S) of the time from the source specified by clock_type. The rate is turned into a percentage of 1/rate. The default rate is 100 (1%).
-S seconds
Specify the maximum difference, in seconds, between the current time and the new time before jam loading rather than slowly adjusting (see -r for the convergence speed). The default is 60 seconds.
-s
Set hardware to current date and time.
clock_type
One of the following:
Clock type Description
at (deprecated) IBM PC/AT Compatible hardware clock
at91rtc MicroChip Technology AT91 RTC
atsama5d3x Microchip Technology ATSMA5D3x
dm816x Texas Instruments DM816x
ds1386 Embedded Dallas Semiconductor DS1386
ds1339c Max Integrated DS1339C
ds15x1 PMC Sierra DS15X1
ds1743 PMC Sierra DS1743
ds3232 Maxim Integrated DS3232
hy7201 Techsol HY7201
hw Hardware clock (automatically selects one based on information provided by the startup)
isl1208 Renesas ISL1208
m41t00 STMicroelectronics M41T00
m41t6x STMicroelectronics M41T6x
m48t37 STMicroelectronics M48T37
m48t5x STMicroelectronics M48T5x
mc146818 IBM PS/2 Compatible hardware clock
max8925 NXP MAX8925
mc9s08dz60 NXP MC9S08DZ60 RTC
mc9328mxlads NXP MC9328MXLADS
mx25srtc NXP RTC
mx51srtc NXP i.MX51 RTC
mx6srtc NXP i.MX 6 RTC
mx7srtc NXP i.MX 7 RTC
mx8xpsc NXP i.MX 8XPSC
omap Texas Instruments AM335x clock
pcf2127at NXP PCF2127AT
phoenix Phoenix Contact RTC
pmqcom PrimeCell RTC
primecell PrimeCell RTC
ps/2 (deprecated) IBM PS/2 Compatible hardware clock
pxa250 Marvell PXA250
rocket Rocket Scream RTC
rtc72423 Embedded Fox (Epson) RTC-72423
rtc8564 Epson RTC8564
rx6110 Epson RX6110
s35390 Ablic S35390
s3c2400 Samsung S3C2400
sa1100 Marvell SA1100
tps65910 Texas Instruments TPS65910
triton ABB Triton
tuareg Turaeg RTC
xzynq Xilinx Zynq RTC
clock_options
One of the following:
Clock type Option
m41t00 I2C device name (e.g., /dev/i2c0)
rx6110 I2C driver path [:I2C device address] (e.g., /dev/i2c0:0x32)

Description:

The rtc command gets or sets the date and time from a battery backed-up hardware clock.

If your machine has a builtin clock/calendar, you should include the following command in your startup script so QNX OS can determine the clock type and read the time when the system starts:

rtc hw

If the RTC chip has been set to the UTC timezone, startup sets the correct time of day automatically on booting. If the RTC chip is set to local time, or for some reason startup doesn't know where the RTC chip is, you'll need to include the appropriate rtc command in the startup script specified in your mkifs buildfile.

Note:
Be careful if you set the date during the period when a time zone is switching from daylight saving time (DST) to standard time. When a time zone changes out of DST, the local time goes back one hour (for example, 2:00 a.m. becomes 1:00 a.m.). The local time during this hour is ambiguous (e.g., 1:14 a.m. occurs twice in the morning that the time zone switches out of DST). To avoid problems, use UTC time to set the date during this period.

Alarm time-setting and alarm-enabling string formats

When setting the time of the RTC alarm with -A or enabling or disabling it with -a, the string formats of the option arguments vary with the clock type, as follows:
Note:
For examples of setting and enabling some of these alarm types, see below.
Alarm type alarm_time format alarm_enable format
mx8sc seconds A value of 1 enables the alarm (ON); any other value disables it (OFF).
pmqcom seconds A value of 1 enables the alarm (ON); any other value disables it (OFF).
ds3232

alarm_number,hh:mm:ss[,day_of_week[,date_of_month]]

Where:
  • alarm_number can be 1 or 2 (i.e., two alarms are available)
  • hh:mm:ss is in 24-hour format
  • day_of_week is a value from 1–7 (Sunday–Saturday)
  • date_of_month is from 1–31
Note that:
  • Alarm number 2 does not support seconds settings. The seconds value for that alarm is safely ignored.
  • A day_of_week or date_of_month value of 0 is safely ignored.
  • If date_of_month is given, day_of_week must be 0.
  • If day_of_week is a valid non-zero value, date_of_month is safely ignored and the alarm is set to weekly.
  • DS3232 alarm modes for every second or for specific specific minutes and/or seconds are not supported.

alarm_number,enable,trigger_type

Where trigger_type is a value between 0 and 4:
  • 0 = active low interrupt signal (default when the trigger type is not chosen)
  • 1 = 1Hz Square Wave Signal
  • 2 = 1.024KHz Square Wave Signal
  • 3 = 4.096KHz Square Wave Signal
  • 4 = 8.192KHz Square Wave Signal
Note that:
  • When enabling the alarm, the trigger type should be set, otherwise an active low interrupt is selected by default.
  • Disabling an alarm does not change the trigger type.
  • Enabling and disabling an alarm clears the alarm's status flag (i.e., it dismisses the alarm signal).
  • The trigger type is the same for both alarms.

Examples:

Update the current date and time from the hardware clock:
rtc hw
Set the hardware clock with current date and time:
rtc -s hw
Enable the pmqcom alarm and set this RTC alarm for 15 seconds:
rtc -a1 -A15 pmqcom

Note that the pmqcom alarm is automatically disabled after you use the -A option and the timer goes off. The alarm must be re-enabled manually by using -a.

Set ds3232 alarm 2 for 4 AM every Wednesday:
rtc -a2,1 -A2,04:00:00,4 ds3232
Set ds3232 alarm 1 for 2:30 PM every 15th day of the month:
rtc -a1,1 -A1,14:30:00,0,15 ds3232

Exit status:

0
Successful.
>0
An error occurred.
Page updated: