Este blog não possui nenhuma afiliação social, empregatícia, financeira ou política a não ser comigo mesmo. As opiniões expressas aqui refletem meu ponto de vista sobre assuntos aleatórios e nada mais. Comentários são mais do que bem vindos, são encorajados, positivos ou não. Até prefiro comentários oposicionistas, afinal um mundo que pensa igual é desprovido de inovação. Portanto, sinta-se em casa. Espero que ler minhas verborréias esporádicas traga-lhe o mesmo prazer que tenho produzindo-as.

[ваκκєr]

P.S. Algumas vezes algo que eu quero expressar não pode ser dito (apenas) com palavras, então vai parar em meu fotolog ao invés de aqui. Confira-o de vez em quando.

quarta-feira, 21 de setembro de 2011

Installing and running Debian armel on an emulated ARM machine on Windows (QEMU)

Why, you ask me? Well, it all begun with Raspberry Pi... If you don't know the amazing, tiny, soon to be the greatest thing to happen to personal computing since... sliced bread?, please, do yourself a favor and click the link.


If you are feeling a little too TL;DR for that, maybe you should skip this post, but since I'm such a nice guy I'm willing to cut you some slack and give you the skinny: The RasPi is soon-to-be a tiny, sub-$50 full-featured computer. It is possible thanks to mobile technology, specially a System-on-a-Chip (SoC) manufactured by Broadcom for use in smartphones. It has a kick-ass graphics processor (capable of running 1080p video, or Quake 3, without heating much above body temperature. Don't take my word for it, click play and enjoy the show):


This amazing GPU is combined in the same package with a handful of on-board RAM (128 or 256MB, depending on version) and an ARM processor. Which is great, except that most of the software we use on a daily basis is built for Windows running on x86, not Linux on ARM. So people are excited about it, but at the same time they don't know if their favorite piece of software is gonna run on this puppy. And people being people (myself included), they don't want to wait until late November to get their hands on one. Therefore, here we are, trying to emulate it, at least well enough to test if we can compile... well, whatever the heck we may want to compile and run on the RasPi.

Full disclosure: You can emulate an ARM1176 on the latest versions of QEMU, but you cannot simply install a run-off-the-mill Linux distro on it, because no distro nowadays ships with compatible kernels. We could go thru all the trouble of cross-compiling one, and installing Debian using it, but we won't. Why? Because most software that runs on the ARM926 we are going to emulate will compile and run just fine on the ARM1176 core in the RasPi. If the emulated architecture were more advanced, like an ARMv7A, it would probably run software incompatible with the Raspberry Pi, like Adobe Flash 10. But since the ARM1176 is the natural replacement to the ARM926, emulating the earlier platform can have no impact other than performance, and that is already going to be puny thanks to being emulated anyways. Sure, you could also argue I'm just being lazy, and you'd not be far from the truth either.

First and foremost, you need to get yourself a copy of QEMU for Windows. I recommend downloading the latest binary from http://lassauge.free.fr/qemu/ (some assembly required, it does not come with required fmod.dll, SDL.dll, mgwz.dll and libusb0.dll, but has links to current versions of the files and/or instructions to roll your own). You can also cut some corners and download your copy from http://homepage3.nifty.com/takeda-toshiya/qemu/ (no longer updated, but has a version 0.13.0 of QEMU good enough for what we are trying here). If you're too lazy to bake your own DLLs, I have put together an easy to use ZIP file with QEMU 0.15 and all needed libraries. You can download it here. Just remember to unzip and/or compile all your QEMU files, including DLLs, to the same folder (hat-tip to obarthelemy @ the Raspberry Pi forums).

Edit: the networking section is under scrutiny in the Raspberry Pi forums. I'll be updating as I get new information from other users; if you can't get it to work, give us a call.

Now you'll need to download OpenVPN, in order to create a network tap. You can go straight ahead and click here. During installation it creates a couple of TAP-Win32 Adapters, one of which you can dispose of. Go to Adapter Settings - here's where to find'em on Windows 7:


- and rename your TAP-Win32 Adapter something single-worded, like TAP32. Now you'll need to manually set your TAP adapter. Right-click your it and select Properties. Once there, de-select all protocols, except the Internet Protocol Version 4 (TCP/IP v4). Click it and then Properties:




Tricky part: you'll need to know your gateway IP address, but I guess if you haven't given up on this tutorial already, you know your local network inside out. Set the IP manually to something within your subnet's range, but not used by any of your machines, as well as put your router's IP as gateway and DNS server. Here's a screenshot, just don't copy it, use your local values instead:


Once you hit OK and are back at the Network Connections windows, hold Control, select both the TAP adapter and the one you use to connect to the internet, right click'em and select Add to Bridge:


You'll get a new adapter type, a MAC Bridge Miniport. You don't need to rename it, but you might also need to manually set it's IP address, Gateway and DNS servers (your mileage with Windows' auto-config may vary). Just follow the steps for the TAP-Win32 adapter and you'll be fine. Okeydokey, network ready. Now you'll need to get acquainted with the Command Prompt. It sits here, inside your Accessories folder:


You can always just type CMD on the Start menu and hit Enter, and you'll get one of the little buggers (don't you love Windows 7?). Now navigate to the folder where you put your QEMU installations and run

qemu-img create -f raw hda.img imagesize

where imagesize is the size of the disk you wish to create for your emulated device. It accepts the format number+suffix, as in 256M for 256 megabytes or 2G for gigabytes, etc. for some reason, my qemu-img refused to accept 8G as an argument, so I entered 8096M instead. Go figure (it seems crundy @ the RasPi forums had the same problem with 4G. I recommend you always use 1024M instead of 1G when trying to make gigabyte-sized disks). You now have a virtual hard-drive where you're gonna install Debian. To do it, you'll need two things: a kernel and an initrd. The kernel, as the name implies, is the core of the Linux operating system. The initrd is the initial ramdisk, a file containing information the kernel expects to find inside your computer's memory in order to find bootable devices, etc. When doing a networked install, the initrd contains the basic installer software, which will, in turn, download the rest of the Linux distribution from the internet. The latest stable Debian distribution for ARM can be found at http://ftp.debian.org/debian/dists/stable/main/installer-armel/current/images/versatile/netboot/.Just point your browser there get initrd.gz and vmlinuz-2.6.32-5-versatile. Now you have your hard dirk image, kernel and initrd. Time to start having fun! (not). On your Command Prompt window, type


qemu-system-arm -L . -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.gz -hda hda.img -m 256 -M versatilepb -net nic -net tap,ifname=networkname -append "desktop=lxde"

where networkname is the name of your TAP-Win32 adapter (you DO remember it, don't you?) and -append "desktop=lxde" is optional. If you leave it out, you'll get the default Gnome desktop (assuming you install a desktop environment, a part we'll be getting into soon). Adding the desktop boot parameter allows you to choose an alternate desktop environment, in this case LXDE, the Lightweight  X11 Desktop Environment, which, the RasPi team informs us, is what we'll probably get with their boot images. It does help tons (pun intended) to replace Gnome with LXDE when everything runs so damn slow (no one said emulation was easy). Once you hit enter, assuming you did everything right (be sure to have all required files in the same folder), you'll be greeted with a new window:


Soon you'll see the Debian installer window. Select your local language, keyboard layout, country etc. according to your geographical location and preferred settings. The options are mostly idiot-proof, so when in doubt, just let the installer guide you. Unless you really do use a Domain on Windows, keep that field blank. Your Workgroup won't work, even if that's what the installer recommends (thanks again, obarthelemy!). Once the software selection screen comes up, be sure to select whatever packets you believe you'll need (including a graphical desktop environment, unless you're comfortable enough with Linux to leave that out). Don't go hitting Enter like I did the first time, the key you use to select packets is the space bar (duh!).


Now sit tight for what will be, depending on your connection, quite a long time. When the installer is finally done, it will warn you that no boot loader was installed. What it means is that you cannot simply reboot the Virtual Machine to load your freshly installed Linux. Wait for it to finish up and restart, then hit Control+Alt+2 to go to the QEMU console. This is where you can issue commands directly to the emulator. Simply type q and hit Enter to close QEMU (or you can just hit the big, red, X-button Your call). Now you'll need a new initrd (remember, the other one contains the installer payload, not the directions to boot your media). If we were running Linux, we could mount our virtual hard disk and copy the initrd from /root. Fortunately for us Windows users, we can also download one from http://people.debian.org/~aurel32/qemu/armel/. Go there, fetch yourself initrd.img-2.6.32-5-versatile and copy it to the QEMU folder. Now I recommend you open Notepad and make this new command into a batch file, otherwise you'll need to type this mouthful every time you want to run your emulated Linux box. Make sure to turn Word Wrap off in the Format menu and type
@qemu-system-arm.exe -L . -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile -hda hda.img -k en-us -m 256 -M versatilepb -net nic -net tap,ifname=networkname -append "root=/dev/sda1"
where networkname is the name of your TAP-Win32 adapter (repeat myself much?). Now save it to the QEMU folder with the .BAT extension. To run the Virtual Machine, just double click the .BAT file and off we go. The system will boot mostly like the installer, but (depending on whether you installed a desktop environment) will go to a login screen (Gnome shown below). Type the name and password you've set up during installation and voilá! Linux on ARM!

...now, if you're too damn lazy to go thru the entire installation process, I have a treat for you: downloadable images! All you need is to install a Torrent client, then click here for LXDE or here for Gnome. Alternately, you can download them via RapidShare: click here for LXDE or here for Gnome. Just copy the files to your QEMU folder and double-click the corresponding .BAT file, you remiss indolent!


Thanks go to Francisco Benitez's great tutorial for installing Debian on QEMU, which I've adapted for Windows and updated, and to Ken's tutorial on Windows networking for QEMU. This page wouldn't exist if it wasn't for these and other great resources I found online.

17 comentários:

ffuentes disse...

I've followed the Francisco Benitez's tutorial but the architecture is armv5tejl and I don't know if that's very similar to Raspy's architecture.

Beta disse...

I want to install debian on my windows, thanks already to guide how to install.

Anônimo disse...

so what are the passwords of the torrent lxde image for root and user

Anônimo disse...

When I get to the part in command promt where I am supposed to enter this:
qemu-system-arm -L . -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.gz -hda hda.img -m 256 -M versatilepb -net nic -net tap,ifname=networkname -append "desktop=lxde"

Nothing happens, it just returns me to a prompt. I was wondering if anyone knows what I am doing wrong.

Anônimo disse...

I believe the passwords are "user" and "password"

Ricardo disse...

If there is an error when you launch qemu, it will write it in the file "stderr.txt" instead than on screen. So, if nothing happens when you launch qemu, you can simply "type stderr.txt"

Unknown disse...

During installation the installer doesn't detect the harddisk. Anyone else had this problem?

Running Machine disse...

Thanks dear for share this, I am looking for this information. you discuss valuable topic.

Unknown disse...
Este comentário foi removido pelo autor.
Anônimo disse...

Open a qemu windows but nothing happens, why?

Joe disse...

what ip settings to use on the client os to make it work?

infelizmente as instrucoes estao incompletas :-(

Anônimo disse...

ouch, 8096M makes my brain hurt... plz make it 8192M ;-)

Goreng Ayam Marketing disse...

AWESOME THE PROMOTION OF GIRL BEAUTIFUL SALES KLIK HERE

GOOD PRICE AND CHEAP
http://www.gorengayam.com 


PLEASE PRICE DIRECTLY

https://gorengayammarketing.weebly.com/blog/tips-untuk-memandikan-ayam-aduan-bangkok

UnKnown disse...

Hello ! I simply would like to give you a
huge thumbs up for your excellent info you have right
here on this post. I will be returning to your website for more soon.

Link Sbobet

Link Sbobet Anti Internet Positif

Link Sbobet Terbaru 2019

Video Teraveloka disse...

Gambar di atas adalah sebagai contoh jika sistem S128Poker sedang maintenance atau dalam perbaikan. Dan biasanya jika kamu berada dalam permainan sebelum poker maintenance, akan ada pemberitahuan atau info berjalan beberapa menit lagi akan maintenance (Baca Selengkapnya...)

EvaniaFlo disse...

Sering Kalah Bermain Poker atau Permainan Lain?? Butuh Konsultasi Seputar Poker atau Permainan Lain Agar Menang Terus??
Dapatkan Trik dan Tips Jitu dari Donaco Poker...
Cukup Daftar menjadi Member saja..!!
Pendaftaran Gratis!!

Nikmati juga kemudahan dalam bertransaksi menggunakan PULSA
DEPOSIT VIA TELKOMSEL

DEPOSIT VIA XL

DEPOSIT VIA AXIS

Dapatkan Juga
- Bonus Deposit 15% New Member Weekend*
- Bonus Deposit 10% Next Deposit Weekend*
- BONUS DEPOSIT HARIAN 5%
- BONUS ROLLINGAN MINGGUAN 0.5%
- BONUS KEJUTAN LAINNYA

Hubungi Kami Secepatnya Di :
WHATSAPP : +6281333555662

Anônimo disse...

Borrow money here today at 3% interest rate. Sawda Capital Finance offers all kinds of financial services of all sizes ranging from individuals, companies, and traders globally./Our services are 100% guaranteed and risk-free.

We build just the right financing for each client, with simple paperwork, quick approvals, and flexible payment schedules. For further details, Kindly contact us via email At sawda.finance@gmail.com

Intermediaries/Consultants/Brokers are welcome to bring their clients and are 100% protected. In complete confidence, we will work together for the benefits of all parties involved, Looking forward to rendering the best of our services to all esteemed clientele globally.