橄榄色:命令红色:修改或新增内容紫色:选择的选项
一、Scratchbox简介Scratchbox is a configuration and compilation environment for building Linux software and entire Linux distributions. The basic idea of Scratchbox is to offer developers an environment that works and looks like the target environment before the target environment is available.
二、安装Scratchbox1.添加软件源
lingd@Ubuntu:~$ sudo vi /etc/apt/sources.list/etc/apt/sources.list最后面增加下面内容:
deb http://scratchbox.org/debian/ stable main2.更新软件源
lingd@ubuntu:~$ sudo apt-get update3.安装软件包
lingd@ubuntu:~$ sudo apt-get install scratchbox-core scratchbox-libs scratchbox-devkit-qemulingd@ubuntu:~$ sudo apt-get install scratchbox-devkit-debian scratchbox-devkit-perl scratchbox-toolchain-cs2007q3-glibc2.5-arm7注:
以下是必须安装的scratchbox-core: scratchbox环境, 常用工具及本地编译器. scratchbox-libs: scratchbox-core, devkits和toolchains所需的库.scratchbox-devkit-qemu: scratchbox的ARM指令集仿真器. scratchbox中提供了qemu和sbrsh两种仿真手段. 要使用qemu仿真, 需安装scratchbox-devkit-cputransp包,不过现在scratchbox-devkit-cputransp包已被scratchbox-devkit-qemu取代了
以下是可选的scratchbox-devkit-debian: 用于Debian包开发的环境和工具.scratchbox-devkit-perl: 额外的perl模块.scratchbox-toolchain-cs2007q3-glibc2.5-arm7: 交叉编译工具包,也可以选择其他交叉编译工具包scratchbox-devkit-doctools: 文档生成工具. 这个包很大,我没有安装
三、禁止VDSOVDSOs (Virtual Dynamically-linked Shared Objects 虚拟动态共享对象) are a way to export kernel space routines to user space applications, using standard mechanisms for linking and loading (i.e. standard ELF format).
禁止Ubuntu 10.04的VDSO功能
lingd@ubuntu:~$ sudo vi /etc/sysctl.conf编辑/etc/sysctl.conf, 最后面增加下面两行:
vm.vdso_enabled = 0vm.mmap_min_addr = 4096使结果生效,运行
lingd@ubuntu:~$ sudo sysctl -pvm.vdso_enabled = 0vm.mmap_min_addr = 4096为了长期生效,编辑/etc/rc.local,在最后一行(exit 0)前面, 增加:sysctl -p
四、添加scratchbox用户1.增加用户到scratchbox中
lingd@ubuntu:~$ sudo /scratchbox/sbin/sbox_adduser lingd[sudo] password for lingd: Add user lingd to group "sbox"? [yes/no] (yes): yes正在添加用户"lingd"到"sbox"组...Adding user lingd to group sbox完成。Scratchbox user account for user lingd added2.查看用户lingd是否已在sbox组中
lingd@ubuntu:~$ groupslingd adm dialout cdrom plugdev lpadmin admin sambashare sbox如果没有看到sbox组,那就退出后重新登录;否则,/scratchbox/login会出现
lingd@ubuntu:~$ /scratchbox/loginbash: /scratchbox/login: 权限不够五、配置scratchbox1.进入scratchbox环境
lingd@ubuntu:~$ /scratchbox/login 或 scratchboxYou dont have active target in scratchbox chroot.Please create one by running "sb-menu" before continuing
Welcome to Scratchbox, the cross-compilation toolkit!
Use "sb-menu" to change your compilation target.See /scratchbox/doc/ for documentation.
[sbox-NO-TARGET: ~] > 2.配置编译目标
[sbox-NO-TARGET: ~] > sb-menu出现交互式配置菜单,选择建立一个target
Setup Setup a target选择创建一个新target
<NEW> Create a new target --> 输入target名字: arm选择compiler(编译器)cs2007q3-glibc2.5-arm7 cross 选择devkits(开发辅助工具),一定要选择qemu,其他根据自身需要
qemu选择好devkits后,选择
DONE Done selecting 选择模拟器,arm模拟器为qemu-arm
qemu-arm-sb Emulation Do you wish extract a rootstrap on the target ? --> noDo you wish install files to the target ? --> yes直接按照默认选择(或也可以通过按空格来选择自己想要安装的文件)--> OK
Do you wish to select the target --> yes此时sb-menu会退出。参考文献4有图解scratchbox的配置过程
六、编译测试1.HelloWorld在/scratchbox/packages有一些例子代码,HelloWorld就是其中一个。因为在/scratchbox/packages没有足够权限,所以只能拷贝hello.c到用户主目录再编译
[sbox-arm: ~] > cp /scratchbox/packages/hello.c hello.c[sbox-arm: ~] > gcc hello.c -o hello [sbox-arm: ~] > lshello hello.c测试文件类型:
[sbox-arm: ~] > file hellohello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, dynamically linked (uses shared libs), not stripped可以看到可执行文件hello的运行平台为 ARM
2.PC上运行HelloWorld(在scratchbox环境下)
[sbox-arm: ~] > ./hello hello world上面显示的结果,实际上,是在qemu模拟器上运行该程序的结果在 Selected devkits(辅助开发工具)中要选择qemu配置模拟器时,一定要选为qemu-arm-XX(我选的是qemu-arm-sb);否则运行./hello会出现:
[sbox-arm: ~] > ./hello Error -8 while loading ./hello3.arm开发板上运行HelloWorldhello 文件下载到开发板当前目录,运行:chmod a+x hello./hello可以在开发板上看到程序的运行结果。
七、关于登陆scratchbox出现Scratchbox is not properly set up的解决方法官网的解释:If Scratchbox was installed from Debian or RPM packages, the /etc/init.d/scratchbox-core init script was installed and Scratchbox should start automatically when the system is rebooted. However, if you installed Scratchbox from tarballs then rebooting your machine will clear away all the mounts and binfmt_misc registrations that Scratchbox requires to work. To get your Scratchbox working again after reboot, you have to run the following command as root:# /scratchbox/sbin/sbox_ctl start简单意思就是:以tar方式安装scratchbox,重启pc后,scratchbox正常工作所需要的mounts和binfmt_misc信息都会被清除。所以每次开机第一次运行scratchbox或/scratchbox/login前,必须先运行“/scratchbox/sbin/sbox_ctl start”命令
lingd@ubuntu:~$ scratchboxERROR: Scratchbox is not properly set up!lingd@ubuntu:~$ sudo /scratchbox/sbin/sbox_ctl start[sudo] password for lingd: Starting Scratchbox: binfmt_misc, mount.lingd@ubuntu:~$ scratchbox Welcome to Scratchbox, the cross-compilation toolkit!
Use "sb-menu" to change your compilation target.See /scratchbox/doc/ for documentation.
[sbox-arm: ~] >不过,我是通过deb包安装的,/scratchbox/sbin/sbox_ctl start解决不了我的问题。我估计是虚拟机Vmware不正常关闭导致的。重新安装一下scratchbox:
lingd@ubuntu:~$ sudo apt-get --no-download --reinstall install scratchbox-core scratchbox-libs scratchbox-devkit-qemuscratchbox又恢复正常了!Android上的超酷播放器–MPDroidUbuntu下安装配置minicom并实现通过minicom传输文件相关资讯 Ubuntu教程
- Ubuntu教程 - 使用Ubuntu拷贝CD和 (12/18/2013 14:38:16)
- 让Ubuntu 12.10支持RAR和7Z文件解 (11/15/2012 18:51:50)
- Windows 7硬盘安装Ubuntu 12.10图 (11/03/2012 19:22:47)
| - 完美安装Ubuntu 12.10最新AMD显卡 (11/27/2012 08:17:47)
- Win 7硬盘安装Ubuntu 12.10 (11/05/2012 13:30:34)
- 虚拟机上Ubuntu 11.10升级到12.04 (10/12/2012 20:00:38)
|
本文评论 查看全部评论 (0)