Ubuntu 10.04搭建Scratchbox交叉编译环境

scratchbox-开源 Scratchbox是一个交叉编译工具包。 它提供了一种以简单,快速,安全和可预测的方式进行交叉编译的环境。 当前,重点是ARM体系结构,但可以轻松添加其他体系结构。 立即下载
橄榄色:命令
红色:修改或新增内容
紫色:选择的选项


一、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.

二、安装Scratchbox
1.添加软件源
lingd@Ubuntu:~$ sudo vi /etc/apt/sources.list
/etc/apt/sources.list最后面增加下面内容:
deb http://scratchbox.org/debian/ stable main

2.更新软件源
lingd@Ubuntu:~$ sudo apt-get update

3.安装软件包 
lingd@Ubuntu:~$ sudo apt-get install scratchbox-core scratchbox-libs scratchbox-devkit-qemu
lingd@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: 文档生成工具. 这个包很大,我没有安装


三、禁止VDSO
VDSOs (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 = 0
vm.mmap_min_addr = 4096

使结果生效,运行
lingd@Ubuntu:~$ sudo sysctl -p
vm.vdso_enabled = 0
vm.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 added
2.查看用户lingd是否已在sbox组中
lingd@ubuntu:~$ groups
lingd adm dialout cdrom plugdev lpadmin admin sambashare sbox
如果没有看到sbox组,那就退出后重新登录;否则,/scratchbox/login会出现
lingd@ubuntu:~$ /scratchbox/login
bash: /scratchbox/login: 权限不够

3.开启ROOT登录
vi /scratchbox/login

注释掉
if [ `id -u` = 0 ] ; then
    exit_error "Not allowed to run this as root!"
fi
这三行后就可以用root来登录了。


五、配置scratchbox
1.进入scratchbox环境
lingd@Ubuntu:~$ /scratchbox/login 或 scratchbox

You 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 ? --> no
Do 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: ~] > ls
hello  hello.c
测试文件类型:
[sbox-arm: ~] > file hello
hello: 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 ./hello

3.arm开发板上运行HelloWorld
hello 文件下载到开发板当前目录,运行:
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:~$ scratchbox
ERROR: 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-qemu
scratchbox又恢复正常了!

scratchbox scratchbox,非常好的工具,能执行arm脚本,编译x11很不错 立即下载

相关推荐

scratchbox:测试用例和代码片段

暂存盒 测试用例和代码片段

构建scratchbox环境步骤

在Ubuntu9.04系统上构建scratchbox环境步骤:1.添加软件源到apt包管理器编辑/etc/apt/sources.list 最后面增加下面一行:deb http://scratchbox.org/debian/ stable main2.更新软件源sudo apt-get update3.安装软件包 sudo apt-get install

1228

scratchbox-core_1.0.13_i386.deb

scratchbox-core_1.0.13_i386.deb

scratchbox添加工具链的一篇文章

是转的。怕哪天原来的链接丢了,先备份一份,顺便加了点记录。/*-------------------------------*/sudo apt-get install darcssudo apt-get install dh-buildinfocd ........//拷贝工具链sudo cp arm-linux/ -raf /scratchbox/compilers/arm-linux-gcc

BathingMonkey的专栏 1860

零基础Python实战:手把手教你用PyGame制作动态烟花效果(附完整代码)

本文为零基础Python编程爱好者提供了一份详细的PyGame实战教程,手把手教你从环境搭建到代码实现,逐步构建一个动态烟花模拟器。教程涵盖了粒子系统、物理模拟(重力与阻力)、效果优化(拖尾与爆炸形态)以及完整的交互式主程序,帮助你通过Python烟花代码项目深入理解图形编程与面向对象设计。

weixin_29062255的博客 257

死磕GMSSL通信-java/Netty系列(二)

Netty-tcnative再linux编译比较好编译,但是再window编译,我尝试了各种办法,总是编译失败,所以我采用半自动的方式进行编译,Netty-tcnative会生成临时文件,直接用vs打开,设置openssl的头文件和静态库路径,然后生成静态库,静态库改个名字放到jar包里边,其实自动编译也是这个原理哈哈O(∩_∩)O。直接传输五个证书的路径吗,之前有的是说要转成x509之类的,转来转去的有点麻烦,这个是直接传输证书路径,由底层gmssl去解析,格式必须是pem格式。然而,若项目已依赖于。

qq_36577699的博客 3026

使用Scratchbox来开发嵌入式Linux

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 env

董磊的专栏 1758

Shopee前端反爬三要素:x-sap-Ri、x-sap-Sec与af-ac-enc-dat深度解析

电商前端反爬机制本质是运行时环境可信验证,其核心在于动态生成的请求指纹、会话签名与行为加密载荷。这类机制不依赖静态Token,而是基于浏览器真实交互(如鼠标轨迹、页面可见性、时间精度)实时计算,体现JS运行时环境不可模拟性。技术价值在于将风控前移至客户端,大幅提升自动化绕过成本;典型应用场景包括商品价格监控、竞品数据采集与合规爬虫开发。本文聚焦Shopee实战案例,深入拆解x-sap-Ri(设备+行为哈希指纹)、x-sap-Sec(动态密钥签名)及af-ac-enc-dat(AES加密行为载荷)三大字段的生

weixin_29015127的博客 406

操刀 scratchbox2 搭建嵌入式开发环境

本文拷贝编辑如下链接制作而成,本人只起到编辑作用,只是为了便于自己理解,按照自己的习惯编排和收集整理: http://forum.wdlxtv.com/viewtopic.php?f=43&t=3108 http://blog.csdn.net/langxing0508/article/details/5861574 http://archive.cnblogs.com/a/228520

2632

噪声整形与过采样实战:从N-bit ADC到DSM的SQNR优化指南

本文深入探讨了噪声整形与过采样技术在DSM(Delta-Sigma调制器)中的应用,重点分析了量化器位数(N)、滤波器阶数(L)和过采样率(OSR)对SQNR优化的影响。通过实战案例和参数协同优化策略,帮助工程师在音频处理和通信系统设计中实现更优的信号质量。

weixin_42561040的博客 340

光学传播仿真软件:SPEOS_(14).建筑物内光环境仿真

在建筑物内光环境仿真中,材料属性的定义直接影响光的传播和反射效果。SPEOS提供了丰富的材料库,但也可以自定义材料属性以满足特定需求。创建新材料选择Materials->。输入材料名称和类型。配置材料属性选择材料对象,打开属性编辑器。设置反射率、透射率、表面粗糙度和颜色。# 导入SPEOS模块# 创建新材料# 配置材料属性custom_material.set_reflectivity(0.8) # 设置反射率为0.8。

kkchenjj的博客 1249

scratchbox foreign toolchain 制作

在ubuntu 7.04下安装SCRATCHBOX包括scratchbox-core_1.0.7_i386.deb scratchbox-devkit-cputransp_1.0.2_i386.deb scratchbox-devkit-debian_1.0.7.1_i386.deb scratchbox-devkit-doctools_1.0.5_i386.debscratchbox-de

hahapro的专栏 2935

ZYNQ PL通过EMIO ETHE1外接PHY由GMII转RGMII

1,设置EMIO方式引出ETHE1 2,从GMII过度到RGMII GMII: 发送 gmii_tx_clk gmii_tx_d[7:0] gmii_tx_en gmii_tx_er 接收 gmii_rx_clk gmii_rx_d[7:0] gmii_rx_dv gmii_rx_er RGMII: 发送 tx_clk tx_d[3:0] tx_ctrl 接收 rx_clk rx_d[3:0] rx_ctrl 首先数据总线从时钟单边沿采样8bit转变为了双边沿采样4bit,从88E1

wangjie36的博客 1万+

scratchbox添加工具链

scratchbox是一个嵌入式linux开发工具,好像可以用来编tinyx,先收藏着吧!   /*-------------------------------*/ sudo apt-get install darcs sudo apt-get install dh-buildinfo cd ........ //拷贝工具链 sudo cp arm-linux/ -raf

仰望星空的专栏 1710

SO_KEEPALIVE、TCP_KEEPIDLE、TCP_KEEPINTVL、保活包

是一个套接字选项,用于设置是否启用 keepalive 机制。在这段代码中没有涉及到选项的设置。当被设置为非零值时,表示启用 keepalive 机制。keepalive 是一种用于检测连接是否仍然有效的机制。通过定期发送一些特定的探测数据,可以检测到网络连接的异常中断或对端应用程序的崩溃退出。为了避免以上情况,可以启用 keepalive 机制,即使在无数据传输的情况下也定期发送探测数据。如果在一定时间内没有收到对端的响应,就认为连接已经失效,并进行相应的处理。要启用选项,需要使用函数。其中,fd。

m0_46376834的博客 4816

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

qemu模拟mips架构的ubuntu系统后,,生成的可执行文件放到宿主机上执行报错 /lib/ld-linux.so.3: No such file or directory

qemu模拟mips架构的ubuntu系统后,,生成的可执行文件放到宿主机上执行报错 /lib/ld-linux.so.3: No such file or directory 下面是我网上搜到的相关文章,解决了我的困惑: 今天在Ubuntu9.04下搭建了一下Scratchbox交叉编译环境,并在新建的ARM模拟器上对Scratchbox自带的hello-world程序进行编译,运行时出现...

buknow的博客 1295

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

基于Arm(OMAP3530)平台的Linux上编译QT4.6.2

本文介绍了QT4.6.2编译成Arm版两种库(Embedded版和X11版)的具体步骤。

yybing的专栏 3642

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

/lib/ld-linux.so.3: No such file or directory

    今天在Ubuntu9.04下搭建了一下Scratchbox交叉编译环境,并在新建的ARM模拟器上对Scratchbox自带的hello-world程序进行编译,运行时出现题目所示错误。    网上查了一下,ld-linux.so.3大概是linux下进行动态库连接的连接器,用于新一代elf格式的可执行文件。因此,推测自己搭建的目标平台下缺少该库,于是到一下网址:http://www.scratchbox.org/download/files/sbox-releases/stable/tarbal

harry_helei的专栏 1万+

动态库的加载----程序装载器

今天在Ubuntu9.04下搭建了一下Scratchbox交叉编译环境,并在新建的ARM模拟器上对Scratchbox自带的hello-world程序进行编译,运行时出现题目所示错误。     网上查了一下,ld-linux.so.3大概是linux下进行动态库连接的连接器,用于新一代elf格式的可执行文件。因此,推测自己搭建的目标平台下缺少该库,于是到一下网址:http://www.scr

xpy123的专栏 713

scratchbox中编译busybox流程

当配置好scratchbox环境后,我们就可以在其中编译需要的软件包了。下面以busbox为例,描述一下其编译的详细流程:环境:Ubuntu9.04scratchboxncurser5.6 busybox-1.10.2  步骤:1.在ubuntu9.04系统上安装scratchbox, 详细过程见1.由于busybox 在make menuconf 时需

832
上一篇: 新手第一次上高速一串疑问
下一篇: 关于在scratchbox中使用root账户登录
satiling
博客等级 码龄19年 130粉丝 98原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值