2019-07-12

set time on android console


### display date
# date
Tue Jul 13 19:25:15 GMT 1999

# date +'%D %T'
07/13/99 19:25:00


### set date
# date 07131924
Sat Jul 13 19:24:00 GMT 2019

# date 07131924.45
Sat Jul 13 19:24:45 GMT 2019

# date 071319241999.23
Tue Jul 13 19:24:23 GMT 1999


### help
# date --help
usage: date [-u] [-r FILE] [-d DATE] [+DISPLAY_FORMAT] [-D SET_FORMAT] [SET]

Set/get the current date/time. With no SET shows the current date.

Default SET format is "MMDDhhmm[[CC]YY][.ss]", that's (2 digits each)
month, day, hour (0-23), and minute. Optionally century, year, and second.
Also accepts "@UNIXTIME[.FRACTION]" as seconds since midnight Jan 1 1970.

-d      Show DATE instead of current time (convert date format)
-D      +FORMAT for SET or -d (instead of MMDDhhmm[[CC]YY][.ss])
-r      Use modification time of FILE instead of current date
-u      Use UTC instead of current timezone

+FORMAT specifies display format string using strftime(3) syntax:

%% literal %             %n newline              %t tab
%S seconds (00-60)       %M minute (00-59)       %m month (01-12)
%H hour (0-23)           %I hour (01-12)         %p AM/PM
%y short year (00-99)    %Y year                 %C century
%a short weekday name    %A weekday name         %u day of week (1-7, 1=mon)
%b short month name      %B month name           %Z timezone name
%j day of year (001-366) %d day of month (01-31) %e day of month ( 1-31)
%N nanosec (output only)

%U Week of year (0-53 start sunday)   %W Week of year (0-53 start monday)
%V Week of year (1-53 start monday, week < 4 days not part of this year)

%D = "%m/%d/%y"    %r = "%I : %M : %S %p"   %T = "%H:%M:%S"   %h = "%b"
%x locale date     %X locale time           %c locale date/time


2019-07-04

eMMC PARTITION_CONFIG (Boot partition selection)






http://trac.gateworks.com/wiki/MMC

eMMC PARTITION_CONFIG (Boot partition selection)

Because eMMC provides multiple hardware partitions but only one can be selected at a time. A non-volatile register in the eMMC device provides a PARTITION_CONFIG that is used to determine what partition is selected at power-up for boot devices. To access this data you need to read/write a 'Card Specific Data' or CSD register (EXT_CSD[179] - EXT_CSC_PART_CONFIG). This can be done both in Linux (see below) or U-Boot (see below).

U-Boot Support ¶

U-Boot provides access to eMMC devices through the mmc command and interface but adds an additional argument to the mmc interface to describe the hardware partition. The interface is therefore described as 'mmc <dev> <part>' where 'dev' is the mmc device (some boards have more than one) and 'part' is the hardware partition: 0=user, 1=boot0, 2=boot1.
Use the mmc dev command to specify the device and partition:
mmc dev 0 0 # select user hw partition
mmc dev 0 1 # select boot0 hw partition
mmc dev 0 2 # select boot1 hw partition
If U-Boot has been built with CONFIG_SUPPORT_EMMC_BOOT some additional mmc commands are available:
  • mmc bootbus <dev> <boot_bus_width> <reset_boot_bus_width> <boot_mode>
  • mmc bootpart-resize <dev> <boot-part-size-mb> <rpmb-part-size-mb>
  • mmc partconf <dev> <boot_ack> <boot-partition> <partition-access> # set PARTITION_CONFIG field
  • mmc rst-function <dev> <value> # change RST_n_FUNCTION field between 0|1|2 (write-once)
The mmc partconf command can be used to configure the PARTITION_CONFIG specifying what hardware partition to boot from:
mmc partconf 0 0 0 0 # disable boot partition (default unset condition; boots from user partition)
mmc partconf 0 1 1 0 # set boot0 partition (with ack)
mmc partconf 0 1 2 0 # set boot1 partition (with ack)
mmc partconf 0 1 7 0 # set user partition (with ack)
If U-Boot has been built with CONFIG_SUPPORT_EMMC_RPMB the mmc rpmb command is available for reading, writing and programming the key for the Replay Protection Memory Block (RPMB) partition in eMMC.
When using U-Boot to write to eMMC (or microSD) it is often useful to use the gzwrite command. For example if you have a compressed 'disk image' you can write it to your eMMC (assuming it is mmc dev 0) with:
tftpboot ${loadaddr} disk-image.gz && gzwrite mmc 0 ${loadaddr} ${filesize}
  • The disk-image.gz contains a partition table at offset 0x0 as well as partitions at their respective offsets (according to the partition table) and has been compressed with gzip
  • If you know the flash offset of a specific partition (which you can determine using the part list mmc 0 command) you can also use gzwrite to flash a compressed partition image

Linux Support

Linux presents the various hardware partitions as separate devices:
  • /dev/mmcblk0boot0 - BOOT0 partition
  • /dev/mmcblk0boot1 - BOOT1 partition
  • /dev/mmcblk0rpmb - RPMB partition
  • /dev/mmcblk0 - USER partition
Note that the BOOT partitions by default are read-only as they are typically used for sensitive boot firmware. To write to them you can disable force_ro in sysfs via:
echo 0 > /sys/class/block/mmcblk0boot0/force_ro
The Linux mmc application provides access to eMMC configuration through CSD registers. This open-source application is available at http://git.kernel.org/cgit/linux/kernel/git/cjb/mmc-utils.git/.
  • To build it:
    git clone git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc-utils.git
    cd mmc-utils
    make
    
  • Alternatively you can install this from a pre-built deb:
    • Newport (arm64):
      wget http://dev.gateworks.com/images/mmc-utils_0~gita3d3331-3~armbian5.35+1_arm64.deb
      dpkg -i mmc-utils_0~gita3d3331-3~armbian5.35+1_arm64.deb
      
  • Ventana (armhf):
    wget http://dev.gateworks.com/images/mmc-utils_0~gita3d3331-3~armbian5.35+1_armhf.deb
    dpkg -i mmc-utils_0~gita3d3331-3~armbian5.35+1_armhf.deb
    
You can use the mmc utility to configure the eMMC PARTITION_CONFIG to specify the boot device on power-up via mmc bootpart enable <boot_partition> <send_ack> <device> where boot_partition specifies the hardware partition (1=boot0, 2=boot1, 7=user), send_ack specifies the device must send an awknoledgement (for fast boot), and device is the root mmc block device of the eMMC:
# set boot partition to boot0
mmc bootpart enable 1 0 /dev/mmcblk0
# set boot partition to boot1
mmc bootpart enable 2 0 /dev/mmcblk0
# set boot partition to user
mmc bootpart enable 7 0 /dev/mmcblk0
Some additional use cases:
# show PARTITION_CONFIG:
mmc extcsd read /dev/mmcblk0 | grep PARTITION_CONFIG
# show BUS CONFIG:
mmc extcsd read /dev/mmcblk0 | grep BOOT_BUS_CONDITIONS
# disable boot partition
mmc bootpart enable 0 0 /dev/mmcblk0
References: