summaryrefslogtreecommitdiffstats
path: root/meta-yocto-bsp/lib/oeqa
diff options
context:
space:
mode:
authorStefan Stanacar <stefanx.stanacar@intel.com>2014-04-30 13:38:58 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-04-30 21:52:43 +0100
commitceb5c4d8c1ebbe96c8ad9e97514792ce3d9d2f50 (patch)
tree74ca4ea8204adc634ff557c75306395f3b6c004d /meta-yocto-bsp/lib/oeqa
parent3a4bb1aa604189618cc16c702efb9647fbe86108 (diff)
downloadpoky-ceb5c4d8c1ebbe96c8ad9e97514792ce3d9d2f50.tar.gz
meta-yocto-bsp: oeqa/controllers: add BeagleBoneTarget
With a serial connection and beaglebone setup correctly as per README.hardware (nand erased, default uboot config assumed, etc) and a correctly deployed core-image-testmaster, we could actually deploy and test AB built images. In the default configuration u-boot will do the right thing and will always boot into the master image (rootfs on second fs on the card, kernel in /boot on the same partition). We just need to tell it for the test image to use the third partition and update the kernel cmdline. Pexpect is used to interact with whatever serial connection we have (which for this target is mandatory). There is some handling for images that don't contain the kernel and dtb files as needed (such as core-image-minimal). Implements [YOCTO #6252]. (From meta-yocto rev: 8235464faf480811b17b062cb9aad8ebf1cd2a67) Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta-yocto-bsp/lib/oeqa')
-rw-r--r--meta-yocto-bsp/lib/oeqa/controllers/__init__.py0
-rw-r--r--meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py94
2 files changed, 94 insertions, 0 deletions
diff --git a/meta-yocto-bsp/lib/oeqa/controllers/__init__.py b/meta-yocto-bsp/lib/oeqa/controllers/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/meta-yocto-bsp/lib/oeqa/controllers/__init__.py
diff --git a/meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py b/meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py
new file mode 100644
index 0000000000..53f454bc6a
--- /dev/null
+++ b/meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py
@@ -0,0 +1,94 @@
1# Copyright (C) 2014 Intel Corporation
2#
3# Released under the MIT license (see COPYING.MIT)
4
5# This module adds support to testimage.bbclass to deploy images and run
6# tests on a BeagleBone (original "white" or Black models). The device must
7# be set up as per README.hardware and the master image should be deployed
8# onto the card so that it boots into it by default. For booting into the
9# image under test we interact with u-boot over serial, so for the
10# BeagleBone Black you will need an additional TTL serial cable since a
11# serial interface isn't automatically provided over the USB connection as
12# it is on the original BeagleBone ("white") version. The separate ext3
13# partition that will contain the image to be tested must be labelled
14# "testrootfs" so that the deployment code below can find it.
15#
16# NOTE: for the BeagleBone "white" (original version) you may need to use
17# a script which handles the serial device disappearing on power down, such
18# as scripts/contrib/serdevtry in OE-Core.
19
20import os
21import bb
22import time
23import subprocess
24import sys
25import pexpect
26
27import oeqa.utils.sshcontrol as sshcontrol
28from oeqa.controllers.masterimage import MasterImageHardwareTarget
29
30
31class BeagleBoneTarget(MasterImageHardwareTarget):
32
33 def __init__(self, d):
34 super(BeagleBoneTarget, self).__init__(d)
35
36 self.dtbs = [('uImage-am335x-bone.dtb', 'am335x-bone.dtb'),
37 ('uImage-am335x-boneblack.dtb', 'am335x-boneblack.dtb')]
38
39 self.deploy_cmds = [
40 'mkdir -p /mnt/testrootfs',
41 'mount -L testrootfs /mnt/testrootfs',
42 'rm -rf /mnt/testrootfs/*',
43 'tar xzvf ~/test-rootfs.tar.gz -C /mnt/testrootfs',
44 '[ ! -e /mnt/testrootfs/boot/uImage ] && cp ~/test-kernel /mnt/testrootfs/boot/uImage',
45 ]
46
47 for _, dtbfn in self.dtbs:
48 # Kernel and dtb files may not be in the image, so copy them if not
49 self.deploy_cmds.append('[ ! -e /mnt/testrootfs/boot/{0} ] && cp ~/{0} /mnt/testrootfs/boot/'.format(dtbfn))
50
51 if not self.serialcontrol_cmd:
52 bb.fatal("This TEST_TARGET needs a TEST_SERIALCONTROL_CMD defined in local.conf.")
53
54
55 def _deploy(self):
56 self.master.run("umount /boot; umount /mnt/testrootfs;")
57 self.master.ignore_status = False
58 # Kernel and dtb files may not be in the image, so copy them just in case
59 self.master.copy_to(self.kernel, "~/test-kernel")
60 kernelpath = os.path.dirname(self.kernel)
61 for dtborig, dtbfn in self.dtbs:
62 dtbfile = os.path.join(kernelpath, dtborig)
63 if os.path.exists(dtbfile):
64 self.master.copy_to(dtbfile, "~/%s" % dtbfn)
65 self.master.copy_to(self.rootfs, "~/test-rootfs.tar.gz")
66 for cmd in self.deploy_cmds:
67 self.master.run(cmd)
68
69 def _start(self, params=None):
70 self.power_cycle(self.master)
71 try:
72 serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout)
73 # We'd wait for "U-Boot" here but sometimes we connect too late on BeagleBone white to see it
74 serialconn.expect("NAND:")
75 serialconn.expect("MMC:")
76 serialconn.sendline("a")
77 serialconn.expect("U-Boot#")
78 serialconn.sendline("setenv bootpart 0:3")
79 serialconn.expect("U-Boot#")
80 serialconn.sendline("setenv mmcroot /dev/mmcblk0p3 ro")
81 serialconn.expect("U-Boot#")
82 serialconn.sendline("boot")
83 serialconn.expect("login:", timeout=120)
84 serialconn.close()
85 except pexpect.ExceptionPexpect as e:
86 bb.fatal('Serial interaction failed: %s' % str(e))
87
88 def _wait_until_booted(self):
89 try:
90 serialconn = pexpect.spawn(self.serialcontrol_cmd, env=self.origenv, logfile=sys.stdout)
91 serialconn.expect("login:", timeout=120)
92 serialconn.close()
93 except pexpect.ExceptionPexpect as e:
94 bb.fatal('Serial interaction failed: %s' % str(e))