Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
setup qemu-user arm chroot for raspberry pi [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
violetina
n00b
n00b


Joined: 19 Mar 2013
Posts: 2
Location: Belgium

PostPosted: Tue Mar 19, 2013 2:21 pm    Post subject: setup qemu-user arm chroot for raspberry pi [SOLVED] Reply with quote

(violetina root #is the rootfs I rsyncd from gentoo on raspberry pi)

I build
Code:
USE=static emerge -b1av app-emulation/qemu-user



Code:
 echo   ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff:/qemu-wrapper:P' > /proc/sys/fs/binfmt_misc/register


violetina root # cat /proc/sys/fs/binfmt_misc/arm
enabled
interpreter /qemu-wrapper
flags:
offset 0
magic 7f454c4601010100000000000000000002002800
mask ffffffffffffff00fffffffffffffffffeffffff


Code:
ROOT="/mnt/MEDIA/RASPIGEN/root/" emerge -K qemu-user
(to install the bin in the target)

next I make the wrapper for qemu
violetina root # cat qemu-wrapper.c

#include <string.h>
#include <unistd.h>

Code:
int main(int argc, char **argv, char **envp) {
   char *newargv[argc + 3];
 
   newargv[0] = argv[0];
   newargv[1] = "-cpu";
   newargv[2] = "arm1176";
 
   memcpy(&newargv[3], &argv[1], sizeof(*argv) * (argc - 1));
   newargv[argc + 2] = NULL;
   return execve("/usr/bin/qemu-arm", newargv, envp);
}


I run
Code:
gcc  -static qemu-wrapper.c -O3 -s -o qemu-wrapper  to build the  wrapper bin



I try to chroot needed stuff is mounted

proc on /mnt/MEDIA/RASPIGEN/root/proc type proc (rw)
sysfs on /mnt/MEDIA/RASPIGEN/root/sys type sysfs (rw)
/dev on /mnt/MEDIA/RASPIGEN/root/dev type none (rw,bind)

Code:
[b]violetina root # chroot . /bin/bash
/bin/bash: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory[/b]


Last edited by violetina on Tue Mar 19, 2013 7:31 pm; edited 2 times in total
Back to top
View user's profile Send private message
violetina
n00b
n00b


Joined: 19 Mar 2013
Posts: 2
Location: Belgium

PostPosted: Tue Mar 19, 2013 7:25 pm    Post subject: Fixed Reply with quote

I followed http://www.gentoo.org/proj/en/base/embedded/handbook/?part=1&chap=5 , but it seems all that is not really needed , and the ROOT=$PWD/ emerge -K qemu-user to install the bin in the chrrot messed up ldconfig , running ldconfig in the chroot root again fixed it , then i found that qemu-user also installs /etc/init.d/qemu-binfmt , which can set up the binfmt , only thing to do is start the init script (make sure its build with right user mode use) copy the qemu-static-arm-binfmt and qemu-static-arm from host to the chroot rootfs , then all is set up to chroot :D


i'm not sure how to close this topic feel free to close it
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54220
Location: 56N 3W

PostPosted: Tue Mar 19, 2013 8:02 pm    Post subject: Reply with quote

violetina,

Welocme to the forums.

You may edit the title in your original post if you wish to add [solved] or [closed] or whatever.
Set up cross distcc for your Pi. Its much faster than an emulated ARM CPU.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum