gcc toolchain


27 posts   Page 1 of 2   1, 2
by JonB » Mon Mar 12, 2012 4:23 pm
In the Debian tutorial, Liam installs geany, a general purpose IDE. He uses it for Python programming, but I wanted C++ so… I issue the command:

apt-get install build-essential

..at the command prompt and it installs. "build-essential" is a so-called meta package (contains a list of packages to install) and it is required for kernal building IIRC; but it also includes gcc and g++ with all standard libraries which is why I always use it.

Since geany knows about C and C++ it's easy to start a project using one of those languages.

You wil need to use rpm instead of apt-get if you're going with the Fedora Remix. rpm is the package manager for Fedora I believe.

Now.. I just have to get over my vi withdrawl symptoms… :D
Posts: 218
Joined: Tue Nov 29, 2011 9:26 pm
by hippy » Mon Mar 12, 2012 5:03 pm
JonB said:

You wil need to use rpm instead of apt-get if you're going with the Fedora Remix. rpm is the package manager for Fedora I believe.

I think it's yum according to the documentation.

And some people wonder why those not familiar with Linux get so confused at time :-)
Posts: 774
Joined: Fri Sep 09, 2011 10:34 pm
by naicheben » Mon Mar 12, 2012 6:26 pm
I'm having trouble to get it to work under Debian Lenny.

There is no package called qemu-user and qemu-user-static. Continuing without it I get an error on the next step :  "server:~# kpartx -a debian6-17-02-2012/debian6-17-02-2012.img
/proc/misc: No entry for device-mapper found
Is device-mapper driver missing from kernel?
Failure to communicate with kernel device-mapper driver.
/proc/misc: No entry for device-mapper found
Is device-mapper driver missing from kernel?
Failure to communicate with kernel device-mapper driver.
Incompatible libdevmapper 1.02.27 (2008-06-25)(compat) and kernel driver
device mapper prerequisites not met
"
this is solved by "modprobe dm-mod"

To let kpartx work with ext4 I had to install lenny-backports Kernel ...
Posts: 347
Joined: Sat Jan 28, 2012 12:28 pm
by jaakkos » Mon Mar 12, 2012 6:55 pm
naicheben said:


I'm having trouble to get it to work under Debian Lenny.

There is no package called qemu-user and qemu-user-static. Continuing without it I get an error on the next step :  "server:~# kpartx -a debian6-17-02-2012/debian6-17-02-2012.img
/proc/misc: No entry for device-mapper found
Is device-mapper driver missing from kernel?
Failure to communicate with kernel device-mapper driver.
/proc/misc: No entry for device-mapper found
Is device-mapper driver missing from kernel?
Failure to communicate with kernel device-mapper driver.
Incompatible libdevmapper 1.02.27 (2008-06-25)(compat) and kernel driver
device mapper prerequisites not met
"
this is solved by "modprobe dm-mod"

To let kpartx work with ext4 I had to install lenny-backports Kernel …


Thanks, I need dm-crypt for encryption so had it loaded - adding modprobe to instructions.

Sorry, no proper qemu packages available unless you use Squeeze or later (Squeeze was released 2011-02-06), or (not an ancient) Ubuntu.

Indeed apt-get is only for Debian and Ubuntu, users of other distributions must use their own package manager.

BR,

Jaakko
Posts: 11
Joined: Thu Mar 08, 2012 4:43 pm
by naicheben » Mon Mar 12, 2012 6:58 pm
uuuuhhhhhh Ubuntu ... no thanks ... I'll better try to dist-up to squeeze . Thank you.
Posts: 347
Joined: Sat Jan 28, 2012 12:28 pm
by jaakkos » Mon Mar 12, 2012 7:03 pm
Can't find the edit button any longer :) I favor Debian too. Perhaps it's time to upgrade anyway, good luck with your dist upgrade. I'm running 'testing'.
Posts: 11
Joined: Thu Mar 08, 2012 4:43 pm
by naicheben » Mon Mar 12, 2012 7:37 pm
hehe, Thanks for keeping your fingers crossed, it woked for me. I'm already in chroot :-)
Posts: 347
Joined: Sat Jan 28, 2012 12:28 pm
by naicheben » Mon Mar 12, 2012 7:58 pm
Hm, I get many "qemu: Unsupported syscall: 341" . Is this ok to ignore them?

EDIT: "qemu: Unsupported syscall: 341
Can not write log, openpty() failed (/dev/pts not mounted?)
"
Posts: 347
Joined: Sat Jan 28, 2012 12:28 pm
by jaakkos » Mon Mar 12, 2012 8:58 pm
naicheben said:


Hm, I get many "qemu: Unsupported syscall: 341" . Is this ok to ignore them?

EDIT: "qemu: Unsupported syscall: 341
Can not write log, openpty() failed (/dev/pts not mounted?)
"



I actually forgot:

# mount -o loop /dev/pts /mnt/dev/pts

before 'chroot'. This will fix the pts problem (not critical) but I'm not getting the "unsupported syscall" error. Did you reboot after upgrading btw?
Posts: 11
Joined: Thu Mar 08, 2012 4:43 pm
by naicheben » Mon Mar 12, 2012 9:05 pm
Yes I did reboot after upgrading. But I did not change the Kernel; I still have the backport-kernel .... should not hurt at all... I think it is 2.6.30 (installed because of no ext4 support in Lenny)

I'm just about to compile MMS (My Media System) can't wait for the RPi to come home back china ...

MMS uses SDL on X and not 3D ( no OpenGL-stuff needed like XBMC does)
Posts: 347
Joined: Sat Jan 28, 2012 12:28 pm
by naicheben » Tue Mar 13, 2012 12:25 pm
hmm, ran into a new problem: no space left on device.

How can I tell qemu to give more harddisk space to the emutaled Debian?

Now it is 1.6G on rootfs, but I think I need at least 2G better 4G (closer to reality)
Posts: 347
Joined: Sat Jan 28, 2012 12:28 pm
by naicheben » Tue Mar 13, 2012 1:35 pm
Ah, I had to install openbios-ppc and openbios-sparc from wheezey to get the squueze-backports to install

now I can resize the image with

qemu-img resize debian6-17-02-2012/debian6-17-02-2012.img 4G

to 4GByte disksize
Posts: 347
Joined: Sat Jan 28, 2012 12:28 pm
by jaakkos » Tue Mar 13, 2012 1:40 pm
naicheben said:


hmm, ran into a new problem: no space left on device.

How can I tell qemu to give more harddisk space to the emutaled Debian?

Now it is 1.6G on rootfs, but I think I need at least 2G better 4G (closer to reality)


Note that QEMU has actually nothing to do here, this is because the file system mounted over the loopback device gets full.

This is where you need to do one of two things:

1. 'cp -pr /mnt /your/preferred/directory' where /your/preferred/directory points to your hard disk. Then start using /your/preferred/directory for everything, you're backed by the full space available on the hard disk.

2. Resize the rootfs partition on the disk image. This way you can flash it directly to the SD card when you need it.

naicheben said:


hmm, ran into a new problem: no space left on device.

How can I tell qemu to give more harddisk space to the emutaled Debian?

Now it is 1.6G on rootfs, but I think I need at least 2G better 4G (closer to reality)


Note that QEMU has much nothing to do here, this is because the file system mounted over the loopback device gets full.

This is where you need to do one of two things:

1. 'cp -pr /mnt /your/preferred/directory' where /your/preferred/directory points to your hard disk. Then start using /your/preferred/directory for everything, you're backed by the full space available on the hard disk.

2. Resize the rootfs partition on the disk image. This way you can flash it directly to the SD card when you need it. However, you should set up swap space properly, which is not covered.

===========================================================>

root@thinkpad:/home/jvsalo/rasbpi/debian6-17-02-2012# truncate -s 8G debian6-17-02-2012.img

root@thinkpad:/home/jvsalo/rasbpi/debian6-17-02-2012# fdisk debian6-17-02-2012.img

Command (m for help): p

Disk debian6-17-02-2012.img: 8589 MB, 8589934592 bytes
4 heads, 32 sectors/track, 131072 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000cded

Device Boot      Start         End      Blocks   Id  System
debian6-17-02-2012.img1            2048      155647       76800    c  W95 FAT32 (LBA)
debian6-17-02-2012.img2          157696     3414015     1628160   83  Linux
debian6-17-02-2012.img3         3416064     3807231      195584   82  Linux swap / Solaris

Command (m for help): d
Partition number (1-4): 3

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Partition type:
p   primary (1 primary, 0 extended, 3 free)
e   extended
Select (default p): p
Partition number (1-4, default 2):
Using default value 2
First sector (155648-16777215, default 155648): 157696
Last sector, +sectors or +size{K,M,G} (157696-16777215, default 16777215):
Using default value 16777215

Command (m for help): w
The partition table has been altered!

Syncing disks.

root@thinkpad:/home/jvsalo/rasbpi/debian6-17-02-2012# kpartx -a debian6-17-02-2012.img

root@thinkpad:/home/jvsalo/rasbpi/debian6-17-02-2012# e2fsck -f /dev/mapper/loop0p2
e2fsck 1.42 (29-Nov-2011)
Pass 1: Checking inodes, blocks, and sizes
Inodes that were part of a corrupted orphan linked list found.  Fix<y>? yes

Inode 202 was part of the orphaned inode list.  FIXED.

...

Inode 46822 was part of the orphaned inode list.  FIXED.
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found.  Create<y>? yes

Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/mapper/loop0p2: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mapper/loop0p2: 46830/101920 files (0.1% non-contiguous), 326333/407040 blocks

root@thinkpad:/home/jvsalo/rasbpi/debian6-17-02-2012# resize2fs /dev/mapper/loop0p2
resize2fs 1.42 (29-Nov-2011)
Resizing the filesystem on /dev/mapper/loop0p2 to 2077440 (4k) blocks.
The filesystem on /dev/mapper/loop0p2 is now 2077440 blocks long.

root@thinkpad:/home/jvsalo/rasbpi/debian6-17-02-2012# mount /dev/mapper/loop0p2 /mnt

root@thinkpad:/home/jvsalo/rasbpi/debian6-17-02-2012# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/loop0p2  8.0G  1.4G  6.2G  18% /mnt

<===========================================================

I'm actually a bit worried about the fsck errors there. Nothing was copied to lost+found. This makes me ask, did they publish a messed up ext volume? Why?
Posts: 11
Joined: Thu Mar 08, 2012 4:43 pm
by jaakkos » Tue Mar 13, 2012 1:42 pm
Removed post. Forum software doing nasty things :P
Posts: 11
Joined: Thu Mar 08, 2012 4:43 pm
by naicheben » Tue Mar 13, 2012 2:29 pm
Ah, thank you. It realy worked even though I had some trouble (as usual)

fdisk complained about DOS-compatability…


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): p

Disk debian6-17-02-2012.img: 0 MB, 0 bytes
4 heads, 32 sectors/track, 0 cylinders
Units = cylinders of 128 * 512 = 65536 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000cded

Device Boot      Start         End      Blocks   Id  System
debian6-17-02-2012.img1              17        1216       76800    c  W95 FAT32 (LBA)
Partition 1 has different physical/logical endings:
phys=(1023, 3, 32) logical=(1215, 3, 32)
debian6-17-02-2012.img2            1233       26672     1628160   83  Linux
Partition 2 has different physical/logical beginnings (non-Linux?):
phys=(1023, 3, 32) logical=(1232, 0, 1)
Partition 2 has different physical/logical endings:
phys=(1023, 3, 32) logical=(26671, 3, 32)
debian6-17-02-2012.img3           26689       29744      195584   82  Linux swap / Solaris
Partition 3 has different physical/logical beginnings (non-Linux?):
phys=(1023, 3, 32) logical=(26688, 0, 1)
Partition 3 has different physical/logical endings:
phys=(1023, 3, 32) logical=(29743, 3, 32)

Command (m for help): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors


c-u solved it and I could change the size. Got the same errors on e2fsck.

EDIT: and had to change cylinder (x = expert mode and then c = cylinder = 131072)
Posts: 347
Joined: Sat Jan 28, 2012 12:28 pm
by naicheben » Wed Mar 14, 2012 5:35 pm
Ok, so now I have to resize2fs /dev/mapper/loop020 after every reboot of the host.

I wrote a script to shorten this:


server:~# cat rasp-cross.sh
#!/bin/bash
modprobe dm-mod
kpartx -a /root/debian6-17-02-2012/debian6-17-02-2012.img
mount /dev/mapper/loop0p2 /raspberrypi
cp  /usr/bin/qemu-arm-static /raspberrypi/usr/bin
cp /etc/resolv.conf /raspberrypi/etc/resolv.conf
mount -o bind /dev /raspberrypi/dev
mount -o bind /sys /raspberrypi/sys
mount -o bind /proc /raspberrypi/proc
mount -o bind /dev/pts /raspberrypi/dev/pts


and to umount after exit:


server:~# cat rasp-cross-umount.sh
#!/bin/bash
# first exit the chroot

umount /raspberrypi/dev/pts
umount /raspberrypi/dev
umount /raspberrypi/proc
umount /raspberrypi/sys
umount /raspberrypi/
kpartx -d /root/debian6-17-02-2012/debian6-17-02-2012.img

Posts: 347
Joined: Sat Jan 28, 2012 12:28 pm
by mabu4ch » Thu Sep 20, 2012 2:06 pm
jaakkos wrote:http://elinux.org/RPi_Kernel_Compilation describes how to get a toolchain that can directly be used to compile the kernel or additional modules for the R-Pi. In Debian, the packages can be accessed by dropping…

deb http://www.emdebian.org/debian/ squeeze main

…to /etc/apt/sources.list (perhaps adjust the squeeze for your purposes). However, for user-space compilation things are a bit trickier, eg. you may need to have various libraries installed, and especially if you"re linking statically, those binaries must be ARM.

The following is IMO a very neat way to access the toolchain directly using emulation, but no need to start the operating system:

$ wget http://downloads.raspberrypi.o.....2-2012.zip

$ unzip debian6-17-02-2012.zip

$ sudo su

# apt-get install kpartx qemu binfmt-support qemu-user qemu-user-static

# kpartx -a debian6-17-02-2012/debian6-17-02-2012.img

# mount /dev/mapper/loop0p2 /mnt

# cp /usr/bin/qemu-arm-static /mnt/usr/bin

# cp /etc/resolv.conf /mnt/etc/resolv.conf

# mount -o bind /dev /mnt/dev

# mount -o bind /proc /mnt/proc

# mount -o bind /sys /mnt/sys

# chroot /mnt

… and use GCC, Apt, etc. directly Later you can unmount and even dd the image directly to your sd-card! Alternatively you can just copy all the partition contents to a local directory and chroot there in the same way. Remember to adjust your /etc/apt/sources.list to your nearest mirror.

To exit:

# exit

# umount /mnt/dev

# umount /mnt/proc

# umount /mnt/sys

# umount /mnt

# kpartx -d debian6-17-02-2012/debian6-17-02-2012.img

Note that this way you can even compile a new R-Pi kernel or modules in the chroot, forget about all the cross compilation stuff. No need to install a cross compiler outside the chroot. However, compilation is going to be slower since the gcc needs to be emulated, but unless you're compiling something huge, it doesn't matter. Unless you have an ancient desktop.

BR,

Jaakko


Thanks for this and the explanation in a later post. I am using this method to compile our project which makes use of several libraries (boost, v8, breakpad. etc.). I'm doing this in a virtual machine running Ubuntu. The host is a Windows 7 machine. This setup is much faster than the pi.
I also tried to take the .img back to run it under Qemu in Windows. The system boots correctly and seems usable. But!
Logged in as pi I was not able to create a directory in my home (user pi) with "Permission denied".
My guess is that doing everything as superuser in the Ubuntu environment (including the filesystem enlargement) would break the permissions on some directories.
As I am new to Linux I wanted to ask whether my assumption is right and whether there is something I could do to fix this.
For now I keep using the chroot trick to get a build of our software but nevertheless I wanted to see whether it would be possible to use the altered .img on Qemu or the pi itself.

Markus
Posts: 1
Joined: Thu Sep 20, 2012 12:18 pm