On Wed, 2012-04-18 at 10:31 +0800, Wu Zhangjin wrote: > On Wed, Apr 18, 2012 at 2:14 AM, Wu Zhangjin <[email protected]> wrote: > > Hi, Lucas > > > > Thanks very much for you help, shared my solutions below: > > > > On 4/16/12, Lucas Meneghel Rodrigues <[email protected]> wrote: > >> On Mon, 2012-04-16 at 11:43 +0800, Wu Zhangjin wrote: > >>> ---------- Forwarded message ---------- > >>> From: Wu Zhangjin <[email protected]> > >>> Date: Mon, Apr 16, 2012 at 11:40 AM > >>> Subject: Question about cross compiling support > >>> To: Autotest Team <[email protected]> > >>> > >>> > >>> Hi, Autotest Team > >>> > >>> Thanks very much for your work on the autotest support of Linux, I'm > >>> currently playing with this powerful tool but I encountered a problem, > >>> that is: > >>> > >>> How to compile a kernel in a local machine and install it to a target > >>> board, then, reboot the target with the new kernel. > >>> > >>> For example, my local machine is an X86 PC, the target machine is an > >>> ARM board, I want to cross compile the kernel from X86 PC and then > >>> install > >>> it to the ARM board, how can I simply implement this? > >>> > >>> BTW, my target board doesn't support the popular Grub or Lilo > >>> bootloader, but instead, it uses a Uboot bootloader, so, it is not > >>> suitable to use > >>> the old install() and boot() methods of the kernel class, is that > >>> possible to add a new Bootloader support for Uboot? or simply hack the > >>> install() and boot() methods? > >> > >> Hi Wu, > >> > >> I don't have a good answer for your query just yet. I saw a while ago > >> patches from the guys working on ChromeOS that allow cross compilation, > >> but I am not sure how to use it. Maybe Scott Zawalski knows more about > >> cross compilation, I'm copying him in this reply. > >> > > > > For the kernel cross compilation, I did find two 'simple' solutions > > (Will paste the using demo's tomorrow): > > > > 1. Build the kernel on a 'localhost' SSHHost, but we need to > > explicitly set the autodir to another directory, it should differ from > > the default one: '/usr/local/autotest', for example, > > '/usr/local/kbuild', otherwise, there will be conflicts. > > > > Note: The existing LocalHost class doesn't work as the argument of > > kernel.build() for it lacks lots of required functions. > > server/site_tests/cross_kbuild_and_test.srv: > > # Start > from autotest_lib.client.common_lib import git > from autotest_lib.client.bin import utils > > build_file = """ > > from autotest_lib.client.common_lib import git > > # git repo > repo = 'git://path/to/repo_dir' > branch = 'master' > repodir = '/tmp/linux' > cfg = '/path/to/defconfig' > > # Annotate the cross compiler path > os.environ["PATH"] = "/path/to/cross-compiler-bin:" + os.getenv("PATH") > > r = git.get_repo(uri=repo, branch=branch, destination_dir=repodir) > testkernel = job.kernel(r) > testkernel.config(cfg) > testkernel.build() > """ > > # Run some remote tests > control_file = """ > job.run_test('sleeptest') > """ > > results_dir = "job_results" > > # Cross compile the kernel image > def kbuild(machine): > host = hosts.create_host(machine) > host.set_autodir("/usr/local/kbuild") > at = autotest_remote.Autotest(host) > at.run(build_file, results_dir, host) > > def run(machine): > host = hosts.create_host(machine) > print "Install the kernel image to target board" > kinstall(host) // see below > print "Reboot to the new kernel" > host.reboot() > at = autotest_remote.Autotest(host) > while True: > at.run(control_file, results_dir, host) > host.reboot() > > kbuild("localhost") > job.parallel_simple(run, machines) > # End > > Run the test: > > $ ./server/autoserv -m target_board_ip_or_hostname -s > server/site_tests/cross_kbuild_and_test.srv > > > > > 2. Use the utils tools to run 'cp /path/to/defconfig .config', 'make > > oldconfig', 'make -j8 zImage' commands one by one directly, but this > > will not benefit from the Kernel classes. > > > > # Local build > def kbuild(): > repo = 'git://path/to/repo_dir' > branch = 'master' > repodir = '/tmp/linux' > cfg = '/path/to/defconfig' > > os.environ["PATH"] = "/path/to/cross-compiler-bin:" + os.getenv("PATH") > r = git.get_repo(uri=repo, branch=branch, destination_dir=repodir) > os.chdir(repodir) > utils.system("cp %s .config" % cfg) > utils.make("oldconfig") > utils.make("-j8 zImage") > > Replace the above kbuild() call with this one ...
Hmm, this is a good start! With some cleaning up, it can be submitted as a patch, for perhaps stay on the server control file samples. Also, some documentation can be written about it. If you happen to have some time to do this work, it'd be great. If you are overloaded with work, I've opened the issue: https://github.com/autotest/autotest/issues/305 So we can remember of doing it when this crazy release period is over. Thanks! Lucas _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
