43
Linux Everywhere A look at Linux outside the world of desktops CIS 191 Spring 2012 – Guest Lecture by Philip Peng

Linux Everywhere

  • Upload
    aiden

  • View
    67

  • Download
    1

Embed Size (px)

DESCRIPTION

Linux Everywhere. A look at Linux outside the world of desktops. CIS 191 Spring 2012 – Guest Lecture by Philip Peng. Lecture Outline. Introduction Different Platforms Reasons for Linux Cross-compiling Case Study: iPodLinux Questions. What’s in common?. - PowerPoint PPT Presentation

Citation preview

PowerPoint Presentation

Linux EverywhereA look at Linux outsidethe world of desktops

CIS 191 Spring 2012 Guest Lecture by Philip PengIntroductionDifferent PlatformsReasons for LinuxCross-compilingCase Study: iPodLinuxQuestions2Lecture Outline

2

Whats in common?3

Put your hands up if you recognize at least 1 of these devices. Keep your hands up if you recognize at least 2? 3 or more?Put your hands up if you know what all these devices share in common(They all run Linux!)3Linux is everywhereIf its programmable, you can put Linux on it!Yes, even a microwave4All your hardware are belong to us

CES 2010, microwave running Android: http://www.handlewithlinux.com/linux-washing-cooking4What servers useStability, security, freeExamples:CentOSDebianRed Hat5Servers

5What you useFree Windows/Mac alternativeExamples:UbuntuFedoraPCLinuxOS6Desktop

6What (white-hat) hackers doTo run homebrew softwareExamples:PS3, Wii, XBOXPS2, GameCubeDreamcastPSP, DSOpen Pandora, GP2X7Gaming Devices

7What distributors are developingCommunity contributionExamplesAndroidMaemo/MeeGo/TizenOpenmoko8Mobile Devices

8What embedded hardware runSmall footprint, dev toolsExamplesRTLinux (real-time)Clinux (no MMU)ngstrm (everything)9Embedded Devices

910Why?

1011Free!Free!As in freedom, i.e. open sourceAs in beer, i.e. vs paid upgrades

1112Homebrew!Run own softwareYour hardware your software?

1213Support!Community contributionFor the greater good (i.e. users)Everyone contributesSpecialists from all over the worldExisting hardware supportMany already supported computer architectureModify existing drivers

1314Lots of support!

1415Why not?Because we canIf its hackable, it can run Linux

1516How?How do we get Linux running on XXX?Port: A version of software modified to run on a different target platformThe PS3 port of Fedora is a modified build of Fedora compiled to run on the PS3 architecturee.g. I ported the Linux kernel to my iPod

1617Cross-compiling!Supported hardware? Easy! Cross-compile!Compiler: A program that converts code to an executable program for your computerCross-compiler: A program that converts code to an executable program for another platform1718Cross-compiling!What makes this possible? C and gccC programming language is made to be easily portable to different architecturesThe Linux kernel and all basic tools are written in CSame source code runs of all sorts of platforms

1819Multiple Compilers

arm-elf is the architecture that runs ELF executables (default format for Linux) on an ARM processorClinux is a Linux kernel fork for microcontrollers without a MMU (memory management unit)1920Compiling for LFS (i368 Linux)Compiling tar for LFS (you did this for HW!)# wget http://ftp.gnu.org/gnu/tar/tar-1.26.tar.bz2# tar -xf tar-1.26.tar.bz2# cd tar-1.26# ./configure# make2021Compiling for arm-elfCompiling tar for arm-elf architecture# wget http://ftp.gnu.org/gnu/tar/tar-1.26.tar.bz2# tar -xf tar-1.26.tar.bz2# cd tar-1.26# ./configure CC=arm-elf-gcc LDFLAGS=-elf2flt -host=arm-elf# make2122Compiling for arm-elf# ./configure CC=arm-elf-gcc LDFLAGS=-elf2flt -host=arm-elfCC=arm-elf-gccSpecify the cross-compiler to be usedLDFLAGS=-elf2fltSet any special linking flags (e.g. target specific)In this case, convert ELF to bFLT format--host=arm-elfSpecify the host machine that you are building for2223Compiling for arm-elfResult:Native tar is in ELF format, cross-compiled is bFLT formatNative tar can execute, cross-compiled tar cant(not on the build computer at least)

2324Cross-compiling TerminologyNote on compiling terms: build, host, targetBuild: platform that you are building onUsually unspecified (since almost always Linux)Host: platform that you are building forFor cross-compiling, e.g. arm-elf architectureTarget: machine that you are building forFor cross-compiling, only specified for special cases with different output formats

2425That was easy!Review: To cross-compile Linux for a supported platform, just add a few config flags, and run make!That was easy!

=2526But wait, theres more!But what happens if you want to run Linux on an unsupported platform?Too bad, youll have to port it yourself!

=2627Porting Linux = HardPorting Linux in a nutshell:Gather as much information about the hardwareReverse-engineer any currently existing softwareModify the cross-compiling tools to generate binaries compatible with the new architectureModify the kernel source code to support communicating with the various hardware componentsLFS all-over-again! (Except it probably wont work the first time, or even the second)

2728Porting Linux = HardPorting Linux minimum requirements:C programming Linux (CIS 191)Compilers (CIS 341)OS concepts (CIS 380)Computer architecture (CIS 501)Experience with hardware debugging (e.g. JTAG)In-depth knowledge of the assembly language of the target architecture (e.g. x86, ARM, MIPS, etc.)

2829Why bother?

2930So you can do this

3031Case Study: iPodLinux

3132What is iPodLinuxiPodLinux = iPod + LinuxCustom port of Clinux to theold iPod hardwareGoal to turn your iPod intomore than just an MP3 playerReal reason: Because we can!Wiki: http://ipl.derpapst.euIRC: #[email protected]: http://sourceforge.net/projects/ipodlinux/

3233The Features - SoftwareCustomizable user interfaceFile-browser and plugin supportMusic player w/ OGG & FLAC supportVideo playback with soundMany user-ported Linux applications and emulators

3334The Features - HardwareCustom graphical bootloaderPlayback of audio with piezo (scroll clicker)Audio-recording via headphone jackBacklight brightness controlOverclocking CPU to 80MHz (vs Apples 66MHz)

3435My contributionJoined official dev team in 2008Free iPod gift? Lets hack it!Sansa e200 kernel patchespodzilla2 features + bug fixesExperimental kernel buildsCompiling tutorials + toolsWiki and forum maintenance

See http://ipl.derpapst.eu/wiki/User:Keripo

3536My contributionProject ZeroSlackrCustom, non-destructive iPL installation systemPorted numerous third part applications:igpSP Gameboy Advanced emulatorhDoom original Doom video gamehWolf3D original Wolfenstein3D and much moreSee http://sourceforge.net/projects/zeroslackr/

3637Compiling iPodLinuxI wrote a iPodLinux-from-Scratch tutorial!Pre-built dev environment (2.95.3 & 3.4.3 toolchains)Compile podzilla2 GUI + libraries (TTK, hotdog, zlib)Compile ipodloader2 bootloaderPatch and compile 2.4.32 uClinux kernelAlternative: use ZeroSlackrEntire build script system set upJust run build-all.sh and wait ~3hrsSee http://ipl.derpapst.eu/wiki/Introduction_to_Compiling_for_iPodLinux 3738History Bit: Reverse EngineeringProblem:No source code/documentationSolution:Reverse engineer it!Software not encrypted, can be dumped through hardware meansApple left in a Diagnostic ModeiPodLinux project goes live in 2003

More: http://web.archive.org/web/20070224164831/http://www.ipodlinux.org/blog/3839History Bit: Piezo HackProblem:Cant dump iPod 4G bootloaderSolution:Record it bit-by-bit!Use the piezo (clicker) to read the bootloader code as soundPut iPod in sound-proof chamberLeave iPod on overnight, decode the audio recording the next dayMore : http://web.archive.org/web/20070519081643/http://www.ipodlinux.org/stories/piezo/

3940History Bit: We had video first!Problem:Still pictures on Apples new iPod Photo is boring, 2005Solution:Lets add video support!Uncompressed, 15fps, A/V issuesApple responds a year later with the iPod 5G, the iPod video ; (We did it first! Still counts!More : http://ipl.derpapst.eu/wiki/Video_Player

4041History Bit: Nanotron 3000Problem:iPod nano 2G encrypted, 2006Solution:Find an exploit!Buffer overflow in Notes functionality (no bound check beyond 268 chars in links)Use LEGO Mindstorm to brute-force the jump address location

More : http://www.freemyipod.org/wiki/Nanotron_3000

4142History Bit: iPhoneProblem:Apple releases iPhoneand iPod Touch in 2007Solution:None, it was a good run ; (Go work on other cool projects!davidc (David Carne) worked on jailbreakme.comAriX (Ari Weinstein) worked on iJailbreakI work on Android and TA this course (Linux!)More: http://www.tuaw.com/2007/10/29/instant-jailbreak-for-iphone-and-ipod-touch/More: http://online.wsj.com/article/SB124692204445002607.html

4243Questions?

43