Scratchbox is a framework to help developers with cross-compilation of Linux software. Cross-compilation is the process of compiling a program that will run on a machine with an architecture different from that of the compiling machine; Scratchbox eases this task using a combination of chroot environment, cross-compiling toolchains (like CodeSourcery) and emulation (like QEMU). Ubuntu repositories contain the Scratchbox2 package, but Scratchbox2 is not really the new version of Scratchbox as much as a derivation. The two products are now being developed in parallel and are taking two different routes. It is still possible to install the Scratchbox 1.X packages by adding to “/etc/apt/sources.list“:
deb http://scratchbox.org/debian/ apophis main
During the installation of the Scratchbox package the operating system will probably complain that the packages are not authenticated. After a repository update (sudo apt-get update), the new “scratchbox-*” packages will be available to install.
In addition it will be necessary to disable the “VDSO” option of the Linux kernel (from http://linux.zipitwireless.com/wiki/Scratchbox):
To disable VDSO with Grub2
- Edit “/etc/default/grub” and change GRUB_CMDLINE_LINUX=”" to read GRUB_CMDLINE_LINUX=”vdso=0″.
- Run sudo /usr/sbin/update-grub in terminal.
- Reboot.
To disable VDSO with Grub 1.x
- Edit “/boot/grub/menu.lst” and find your default kernel. Typically this line looks something like this …
kernel /boot/vmlinuz-2.6.26-2-686 root=/dev/hda1 ro quiet
- Change this line to include vdso=0 at the end. It should look like this …
kernel /boot/vmlinuz-2.6.26-2-686 root=/dev/hda1 ro quiet vdso=0
- Save and close the file.
- Reboot.
In my Ubuntu box, to develop for ARM architectures, I installed:
sudo apt-get install scratchbox-core scratchbox-libs scratchbox-devkit-cputransp scratchbox-devkit-qemu scratchbox-toolchain-arm-linux-cs2009q3-67
After this setup, to enable your user to use Scratchbox, run:
sudo /scratchbox/sbin/sbox_adduser youruser
This adds youruser to the sbox group; it creates also a home directory in “/scratchbox/users/youruser/home/youruser“. Logout, login and run:
/scratchbox/login
This will bring on the ScratchBox prompt. In the prompt, run sb-menu and setup a new target. Choose the ARM toolchain, the qemu target and the qemu-arm-sb CPU transparency option. Ignore the rootstrap functionality and install the default libraries to the target system. Now you can compile and run ARM programs from the ScratchBox prompt as thought you were on the real target architecture.
Entries
FelipeC
2010/06/06
Disabling VDSO has a performance impact.
You should only do that when using scratchbox:
echo 0 > /proc/sys/vm/vdso_enabled
Balau
2010/06/07
Thanks for the suggestion!
aloha
2010/06/22
At first, thank for your tutorial but when I run this command :”sudo apt-get install scratchbox-core scratchbox-libs scratchbox-devkit-cputransp scratchbox-devkit-qemu scratchbox-” I get some errors:
E: Couldn’t find package scratchbox-devkit-cputransp
Pls help me.
Balau
2010/06/22
You’re right, now it does not work on my side too.
I solved by using “apophis” instead of “stable” in the line that indicates the debian repository:
deb http://scratchbox.org/debian/ apophis main
Check the “apt-get install” line too, because in some browsers it is not displayed correctly (line is too long)
aloha
2010/06/23
thank a lot. Now it work, but I have another problem, can I add my compiler arm-angstrom-linux-gcc into sractchbox?
Balau
2010/06/23
I never tried to add another compiler so I can’t help you, but have you tried this page?
aloha
2010/06/25
It can’t solve my problem but thank for your help.
Divine
2010/09/24
Hi I followed you steps for installing scratchbox on Ubuntu, but when i do /scratchbox/login it gives me the error
bash: /scratchbox/login: Permission denied.
Can you help me out with this
Balau
2010/09/24
Have you tried logging out and logging in again from Ubuntu completely?
If it does not work, run:
$ ls -l /scratchbox/login
what does it say?
Divine
2010/09/24
After posting the query to you I logged out of Ubuntu and again logged in. Now its working.
Thank You.
ahmed
2011/02/10
Hi,
Thanks for your tut, it is really helpful,
But i’m wondering how to integrate qemu with SB?
Balau
2011/02/10
In a certain way Scratchbox is already working with QEMU, because the “CPU transparency” functionality is implemented using “qemu-arm”. If you want to use “qemu-system-arm” to emulate a complete system, I think you need to create a root filesystem image from the Scratchbox environment, then prepare a linux kernel and run them together in “qemu-system-arm”. I don’t know what you want to do exactly so I can’t help you more.
surya
2011/03/11
when I run this command :”sudo apt-get install scratchbox-core scratchbox-libs scratchbox-devkit-cputransp scratchbox-devkit-qemu scratchbox-” I get some errors:
E: Couldn’t find package scratchbox-devkit-cputransp
Pls help me.
even though I added right package url in source list it couldnt solve my problem can u plz help me .
deb http://scratchbox.org/debian/ apophis main
Balau
2011/03/13
The command you run is not complete, maybe it doesn’t show well in the site. the complete command is:
sudo apt-get install scratchbox-core scratchbox-libs scratchbox-devkit-cputransp scratchbox-devkit-qemu scratchbox-toolchain-arm-linux-cs2009q3-67Maybe you are running a 64-bit linux and the packages aren’t prepared for 64 bit. You can check by running “uname -m”, if it shows something like “x86_64″ then you are running a 64 bit linux. Or you can also run “dpkg-architecture” and check that the “DEB_HOST_ARCH” is “i386″ which is the required architecture to install the scratchbox packages.
Try also installing the packages one by one and see if something changes. Check also if when you run “sudo apt-get update” you get errors.
I tried just now the commands and they work, so the repository is still up.
Luis
2012/01/11
Hello and thanks for the great service you do. In preparation for a new arm based product, I am examining scratchbox as cross compiling environment tool. I, however am running into a small problem. I am able to add the packages required, create an account for the user and even login as the user, however when I attempt to run sb-menu I get absolutely no activity. There is no error message, or warning. The console just sits there. Nothing is apparently wrong judging from the logs. Is there a scratchbox specific location I can look at to determine what the problem is?
Your help is greatly appreciated.
Balau
2012/01/11
Have you already read these messages? They suggest to try to reinstall, even on another location by using a link:
http://lists.scratchbox.org/pipermail/scratchbox-users/2006-January/000374.html
http://lists.scratchbox.org/pipermail/scratchbox-users/2006-January/000375.html
http://lists.scratchbox.org/pipermail/scratchbox-users/2006-January/000377.html
sb-menu should work inside and outside Scratchbox, so you can try to run it also outside.
Other than that I have no clue about what it can be.
Hope it’s enough.
Luis
2012/01/11
Yes, I had found that message and followed their advice but unfortunately my results were not as good as theirs. I am running inside a virtualBox Ubuntu VM but I doubt that this would have to do anything with it.
Oh well, I will just keep on trying, I will let you know what I find out.
Thanks.
Luis
2012/01/12
Hello, I figured out what my problem was. I was using a 64bit VM. I created a 32bit VM and followed above instructions and it works fine. Thank you and sorry about the noise.
RAJ M
2012/11/16
SBOX_DPKG_INST_ARCH not set.
SBOX_DPKG_INST_ARCH not set.
[sbox-allwin: ~] >
when i login scrachbox i got this error
Can you help me out with this
pls help me.
Balau
2012/11/16
Based on what I found here, have you tried adding:
export SBOX_DPKG_INST_ARCH="armel"to the bashrc?
I can’t help you more because I haven’t been used scratchbox for years.