Debian Can Be ARM Dev Environment
Well, I had troubles last few days correctly installing ARM toolchain and needed stuff to make my development under Debian. But, it is suppose to be easy :).
First, I had troubles with apt-get. It is because my /etc/souces.list grew when I added unstable repos. Consequently, apt-get complained about missing room for it's info.
dpkg wants you to know: Getting "E: Dynamic MMap ran out of room" when using apt-get? Put the following line into your /etc/apt/apt.conf: 'APT::Cache-Limit 12582912;' . If you still get the same error, increase the value. If that file doesn't exist, add it, or put that line in a file in /etc/apt/apt.conf.d/ You can also possibly get rid of this error by deleting entries from your sources.list that you don't actually need.
After putting 16M (16777216) instead of these 12M, problem was solved.
Another problem with apt is that it was stacking at 99% while doing apt-get update. Solution is:
#cd /var/lib/apt/lists
#rm *_Packages *.gpg *_Release *IndexDiff *Sources
Well, this helped, partially. At one point i had to move (move, please don't delete) the whole /var/lib/apt/lists dir and create new one. Next apt-get complained that it misses folder /var/lib/apt/lists/Partial, so I brought this one back to my newly created and fresh dir. And it worked, but for how long I don't know.
Anyway, after adding unstable repos, it would be good to do apt pinning in order to take packages mainly from the testing branch, and hit unstable branch only when testing package is not found. Good tutorial can be found here: http://wiki.debian.org/AptPinning, but I'll copy some of the stuff:
/etc/apt/sources.list
# official debian sites
#### testing #########
deb http://http.us.debian.org/debian testing main contrib non-free
deb http://non-us.debian.org/debian-non-US testing/non-US main contrib non-free
#### unstable #########
deb http://ftp.us.debian.org/debian unstable main non-free contrib
deb http://non-us.debian.org/debian-non-US unstable/non-US main contrib non-free
In this example, we're pulling from testing and unstable. You could, of course, modify this to pull from stable as well.
/etc/apt/preferences
The 'preferences' file is where the actual pinning takes place. Here's an example:
Package: *
Pin: release a=testing
Pin-Priority: 900
Package: *
Pin: release a=unstable
Pin-Priority: 800
Package defaults to any, as specified by the asterisk. Pin specifies the release (testing and unstable). Pin-Priority specifies the priority level. 'apt-get' defaults to something along the lines of "highest package version wins". The above restructures this priority so that packages in testing are given a higher priority.
You should also refer to the apt_preferences(5) manpage.
Installing from unstable
Let's assume that we're running testing and we want to try enlightenment from unstable. There are basically two methods for installing:
# apt-get install enlightenment/unstable
# apt-get -t unstable install enlightenment
The first will not attempt to upgrade any packages on your system, so if specific dependencies are not met, the install will fail. The second method will attempt to install/upgrade any dependencies. Of course, given the above example, 'apt-get' will ask you before proceeding.
Surprisingly, that will work good. So, now it is time to install cross-compiler and friends. The whole hassle with unstable and pinning was done because we need emdebian-tools, and these are found in unstable (but we wonted just these packages from unstable, and not some other system packages, so we did the apt-pinning).From here, follow the instructions on: http://wiki.debian.org/EmdebianQuickStart
#apt-get install emdebian-tools
Cool, this got us close. Now back to simple user (stop being root):
$ apt-cross --update
$ emsetup -v
Basically, you need 4 most important packages:
- arm-linux-gnu-gcc - ARM cross-compiler
- binutils-arm-linux-gnu
- libc6-arm-cross - shared libs
- libc6-dev-arm-cross - development headers
#include
int main()
{
printf("Hello cross-compiling world!\n");
return 0;
}
Compile it like:
drasko@Lenin:~/arm_projects$ arm-linux-gnu-gcc -o helloWorld helloWorld.c
And test it with qemu:
drasko@Lenin:~/arm_projects$ qemu-arm -L /usr/arm-linux-gnu/ helloWorld
Hello cross-compiling world!
The switch -L /usr/arm-linux-gnu/ for qemu is necessary, otherwise it will complain how it can not find interpreter (similarly is done on Win, when qemu complains about bios it can not find - point qemu to this file with -L switch).