Skip to content

Meta Layer for Y2038 safe system (for easy development and OE integration)

License

Notifications You must be signed in to change notification settings

lmajewski/meta-y2038

Repository files navigation

This README file contains information on the contents of the meta-y2038 layer.

Please see the corresponding sections below for details.

Dependencies
============

	meta-openembedded:

Patches
=======

Please submit any patches against the meta-y2038 layer to github.com/lmajewski
repo for this project and cc: the maintainer:

Maintainer: Lukasz Majewski <lukma@denx.de>

Table of Contents
=================

  I. Adding the meta-y2038 layer to your build
 II. Build setup (meta-* SHAs)
III. Y2038 development
IV.  Using glibc/src/scripts/cross-test-ssh.sh
V.   Building glibc with yocto SDK
VI.  Build test glibc with x86, x86-64 and x32
VII. GDB
VIII.Runtime tests
IX.  Adjust y2038 setup to run new glibc with kernel older than 5.1


I. Adding the meta-y2038 layer to your build
=================================================

Run 'bitbake-layers add-layer meta-y2038'

II. Build setup
===============

Please clone meta-y2038 layer to your PC.

The KAS project [https://github.com/siemens/kas] shall be used to deploy the
meta-y2038 with proper SHAs. Please use meta-y2038-kas.yml file.

Then run:
../kas/run-kas checkout ./meta-y2038/meta-y2038-kas.yml
. ./poky/oe-init-build-env

III. Y2038 development
======================

bitbake y2038-image-devel
runqemu -d y2038-image-devel nographic

or

MACHINE=qemux86 runqemu -d y2038-image-devel nographic

Then from prompt:
root@y2038arm:~# test_y2038

Available MACHINEs: qemuarm, qemux86, qemux86_64


IV. Using glibc/src/scripts/cross-test-ssh.sh with QEMU
=======================================================

MACHINE=qemuarm   (32 bit ARM - Vexpress-A15)

From Yocto/OE setup environment (on which bitbake operates)
-----------------------------------------------------------
runqemu -d y2038arm nographic
mkdir -p /opt/Y2038/glibc/; cd /opt/Y2038/glibc/
sshfs -o allow_other -o sshfs_sync lukma@192.168.7.1:/opt/Y2038/glibc/ .   [1]
cd .

On HOST (x86_64):
-----------------

Setup yocto environment:
$ . /opt/Y2038/3.x.y/environment-setup-armv7at2hf-neon-poky-linux-gnueabi

cd /opt/Y2038/glibc/build
../src/configure --host="arm-poky-linux-gnueabi" --prefix=/usr

make PARALLELMFLAGS="-j8"
(For improved performance execute step [1] just before xcheck)
make PARALLELMFLAGS="-j8" test-wrapper='/opt/Y2038/glibc/src/scripts/cross-test-ssh.sh root@192.168.7.2' xcheck

Testing (rebuild) only a subset of tests (from e.g. time directory):
--------------------------------------------------------------------
find . -name "tst-clock_settime*" -delete   (or rm -rf ./time/*)
make PARALLELMFLAGS="-j8" test-wrapper='./build/workspace/sources/y2038-glibc/scripts/cross-test-ssh.sh --allow-time-setting root@192.168.7.2' subdirs=time check

Run test suite with date set to Y2038 threshold:
------------------------------------------------
On the VM run:
date +'%Y-%m-%d %T' -s "2038-01-19 03:14:07"

V. Building glibc with yocto SDK
================================
cd build/glibc
../../y2038-glibc/configure --host="i586-poky-linux" --prefix=/usr
make PARALLELMFLAGS="-j12" && make xcheck PARALLELMFLAGS="-j12"


VI. Build test glibc with MACHINE=qemux86-64, qemux86, qemux86-64-x32
=====================================================================
MACHINE=qemux86-64-x32 bitbake y2038-glibc -c cleansstate && MACHINE=qemux86-64-x32 bitbake y2038-glibc -c compile -f
MACHINE=qemux86-64 bitbake y2038-glibc -c cleansstate && MACHINE=qemux86-64 bitbake y2038-glibc -c compile -f
MACHINE=qemux86 bitbake y2038-glibc -c cleansstate && MACHINE=qemux86 bitbake y2038-glibc -c compile -f

VII. GDB
Session on test_y2038: __clock_settime64 (ARM)
==============================================

gdb test_y2038
(gdb) b test_clock_settime
(gdb) run

VIII. Runtime tests:
====================

- MACHINE=qemux86 + clock_settime

MACHINE=qemux86 bitbake virtual/kernel -c cleansstate && MACHINE=qemux86 bitbake virtual/kernel
MACHINE=qemux86 bitbake y2038-image-devel -c cleansstate && MACHINE=qemux86 bitbake y2038-image-devel
runqemu -d qemux86 nographic

clock_settime test program:

cat <<- EOF >> clock_settime_test.c
#include <stdio.h>
#include <time.h>

int main (int argc, char **argv)
{
        struct timespec tv;
        int ret;

        tv.tv_sec = 0x7FFFFFFF;
        tv.tv_sec += 61;
        tv.tv_nsec = 0;

        printf("clock_settime test program: ");
        ret = clock_settime(CLOCK_REALTIME, &tv);
        if (!ret)
                printf("OK\n");
        else
                perror("ERR\n");

        return 0;
}
EOF

Build the test program:
gcc -Wall -ggdb -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -I/usr/include -L/usr/lib \
    clock_settime_test.c -o cst -static

Test it with gdb (also set debugging sources (with set directories /usr/src/debug/... - point VII))

IX. Running different kernels with glibc supporting __clock_settime64, default (old)
    kernel version and kernels supporting (5.1+) or not (4.19 lts) __clock_settime64.
=====================================================================================

In the meta-y2038/conf/distro/y2038.conf

#OLDEST_KERNEL="5.1.0"
and set

PREFERRED_PROVIDER_virtual/kernel = "linux-lts"
PREFERRED_VERSION_linux-lts = "4.19%"

Rebuild kernel
MACHINE=qemuarm bitbake linux-lts -c cleansstate && MACHINE=qemuarm bitbake linux-lts

Go to build/tmp/deploy/images/qemuarm and copy/rename zImage--4.19*.bin and
zImage--4.19*.dtb files


Then set the

PREFERRED_PROVIDER_virtual/kernel = "linux-y2038"
PREFERRED_VERSION_linux-y2038 = "5.1%"

in meta-y2038/conf/distro/y2038.conf

and rebuild
MACHINE=qemuarm bitbake y2038-image-devel


The QEMU for MACHINE=qemuarm with 5.1 kernel:
runqemu -d y2038arm nographic

The QEMU for MACHINE=qemuarm with 4.19 kernel:
KERNEL=/home/lukma/work/yocto/y2038/build/tmp/deploy/images/y2038arm/zImage--4.19.bin runqemu -d y2038arm nographic

(and test y2038 with __clock_settime64 test program)


IX. Runtime tests (ptest):
==========================

The `glibc-ptest` recipe package will provide _all_ time related
tests to be run with ptest infrastructure.

The `EXTRA_IMAGE_FEATURES` contains " ptest-pkgs", so all ptest
tests and management programs are installed to the
`y2038-image-devel`.

Those 'glibc' tests are standalone, so they can be run without the
data from glibc build tree.

After booting into the QEMU run image, one just need to call
`ptest-runner glibc-tests`

and then adjust the time after Y2038 threshold:

```
date +'%Y-%m-%d %T' -s "2038-01-19 03:14:07"
ptest-runner glibc-tests
```

About

Meta Layer for Y2038 safe system (for easy development and OE integration)

Resources

License

Stars

Watchers

Forks

Packages

No packages published