Vous êtes sur la page 1sur 160

Soft-, Hard-, Middel- and Some-ware

Toke Dupont Koustrup November 21, 2011

Copyright
Copyright 2011 Toke Dupont Koustrup Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.

About this Document


A This document is prepared using open source tools and software. L TEXis used for typesetting. The purpose of this document is to make it more easy to (re)start using the vaious MCU/CPU boards, both for me and for others. Since this document was, originaly, intended for my own use, most of the content is not well written and found in the form of randome notes.

Contents
Content . . . Figures . . . Tables . . . . Listings . . . Nomenclature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 8 9 11 12

Embedded GNU

13
15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 16 17 18 20 20 20 22 23 23 24 24 25 25 26 26 26 27 27 27

1 About Embedded GNU 2 The GNU Toolchain 2.1 GCC at the rst Glance . . 2.2 GCC - a closer look . . . . 2.2.1 So What did We get 2.3 GCC Workow . . . . . . . 2.4 Tools in a Toolchain . . . . 2.4.1 Binutils . . . . . . . 2.4.2 GCC . . . . . . . . . 2.4.3 Libc . . . . . . . . . 2.5 Using Make . . . . . . . . .

3 Installing the Toolchain for your target 3.1 Known Targets for GCC . . . . . . . . . 3.2 Installing the ABI toolcain for ARM7 . 3.3 Create a proper Development Layout . . 3.3.1 Set the TARGET etc. . . . . . . 3.3.2 Binutils . . . . . . . . . . . . . . 3.3.3 Initiel GCC . . . . . . . . . . . . 3.3.4 Newlib - LibC for ARM7 . . . . 3.3.5 GCC . . . . . . . . . . . . . . . . 3.3.6 Optional - gdb . . . . . . . . . .

CONTENTS

II

AVR

29

4 Enviroment Setup 31 4.1 Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.1.1 Libc - avr-libc . . . . . . . . . . . . . . . . . . . . . . . . 31 5 The AVR Hardware 6 Building the Software 7 Running Software on the AVR 32 33 34

8 Project: AVR Anemometer 35 8.1 Project layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

III

ARM7

36

9 Toolchain for ARM7 38 9.1 Lpc21ipc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 10 Demo Project using the toolchain 10.1 Project structure . . . . . . . . . 10.1.1 Linkerscript . . . . . . . . 10.1.2 Boot Code . . . . . . . . 10.1.3 Main Software . . . . . . and . . . . . . . . . . . . LPC2106 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 39 39 41 41

IV

ARM9 - KB9202B
. . . . . . . . . . . . . . . . . . . . Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

42
45 45 45 45 47 47 48 48 48 48 49 49 50 50 51 51 51

11 Enviroment Setup 11.1 Toolchain - Note: NOT done . . . . 11.1.1 Precompiled Toolchains . . . 11.1.2 Toolchain from a Script . . . 11.2 Installing your own Toolchain . . . . 11.2.1 Create a proper Development 11.2.2 Set the TARGET etc. . . . . 11.2.3 Linux Headers . . . . . . . . 11.2.4 uClibc Headers . . . . . . . . 11.2.5 GMP . . . . . . . . . . . . . 11.2.6 MPFR . . . . . . . . . . . . . 11.2.7 Binutils . . . . . . . . . . . . 11.2.8 Initial GCC . . . . . . . . . . 11.2.9 Full Blown GCC . . . . . . . 11.3 Using the tools . . . . . . . . . . . . 11.3.1 Hello World - Test Program . 11.4 Server . . . . . . . . . . . . . . . . .

CONTENTS

12 The KB9202B Hardware

53

13 KB9202B Factsheet 54 13.1 Memorymap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 14 Building the Software 14.1 Building U-boot . . . . . . . . . . . . . . . . . . 14.1.1 Conguring U-boot . . . . . . . . . . . . . 14.2 Building the Linux Kernel . . . . . . . . . . . . . 14.2.1 Downloading the Kernel and Patches . . . 14.2.2 Unpacking and Paching the Linux Kernel 14.2.3 Congurating the Kernel . . . . . . . . . 14.2.4 Compiling the Kernel . . . . . . . . . . . 14.2.5 Optional Create an image for U-boot . . . 14.3 Building uClibc for the target . . . . . . . . . . . 14.4 Busybox . . . . . . . . . . . . . . . . . . . . . . . 14.4.1 Downloading and unpacking Busybox . . 14.4.2 Congurating Busybox . . . . . . . . . . . 14.4.3 Building Busybox . . . . . . . . . . . . . 14.5 Creating a rootfs Image . . . . . . . . . . . . . . 15 Running Software on the KB9202B 15.1 Running the new kernel . . . . . . 15.2 Gentoo on the KB9202B . . . . . . 15.2.1 Setup . . . . . . . . . . . . 15.2.2 Set the date and time . . . 15.2.3 Emerge the rst package . . 15.2.4 Dmesg . . . . . . . . . . . . 15.3 Running custom Software . . . . . 15.3.1 IO driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 55 55 55 55 56 57 57 57 57 57 58 58 58 59 60 60 60 60 62 62 62 65 65

NSLU2 - Hacking the device

66
68

16 NSLU2 Factsheet

17 Booting the NSLU2 69 17.1 Compiling a new kernel . . . . . . . . . . . . . . . . . . . . . . . 69 17.2 Loading and running the new kernel . . . . . . . . . . . . . . . . 69 17.2.1 2. try . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

VI

N2100 - Hacking the device

77
79

18 N2100 Factsheet

CONTENTS

19 Bootloader 19.1 Connecting to the bootloader . 19.1.1 Using Telnet . . . . . . 19.1.2 Using serial port . . . . 19.1.3 Using Telnet . . . . . . 19.2 Flash Layout . . . . . . . . . . 19.3 Boot your own kernel . . . . . 19.4 Installing Gentoo on the N2100

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

80 80 80 80 82 82 82 82

20 Toolchain 84 20.1 Toolchain for the N2100 . . . . . . . . . . . . . . . . . . . . . . . 84 20.1.1 The Thecus GNU Toolchain . . . . . . . . . . . . . . . . . 84 21 Gentoo on the N2100 22 MTD 22.1 Finding info on the system . . . . . . . . . . . . . . . . . . . . . 86 92 92

VII

Embedded Display

93
95 96 97

23 About Embedded Displays 24 Types of Displays 25 Architecture

VIII

Vortex86
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

99
101 101 101 102 103

26 Vortex86 Factsheet 26.1 About the Vortex86 . . . 26.1.1 Output from lspci 26.1.2 cpuinfo . . . . . . 26.1.3 X86info . . . . . .

IX

Project SolarController

104
106

27 About the Solarcontroller

28 Controlling Algorithm 107 28.1 Temperature Sensors . . . . . . . . . . . . . . . . . . . . . . . . . 107 29 Selecting a platform for the Solarcontroller 109 29.1 Board Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . 109 30 LPC2468 5 110

CONTENTS

31 Initial Code 31.1 Startup Code . . . . . . 31.2 Linker Script . . . . . . 31.3 Setting up the Clock . . 31.3.1 Using Interrupts

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

111 111 112 112 113

32 Using FreeRTOS on the LPC2468 114 32.1 Needed Files and their Modication . . . . . . . . . . . . . . . . 114 33 TCP/IP Stack for Embedded 116

Using Linux as ...

117
121 121 121 122

34 Subversion,SVN, Server 34.1 Server Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34.2 Repository Layout . . . . . . . . . . . . . . . . . . . . . . . . . . 34.3 My actual Projects . . . . . . . . . . . . . . . . . . . . . . . . . .

35 DHCP Server 123 35.1 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 36 NFS Server 37 TFTP server 125 126

38 FTP server 127 38.0.1 Optinal: rsync Server . . . . . . . . . . . . . . . . . . . . 127 39 Daytime Server 128

40 Linux Mail Server 129 40.1 Recieving Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 40.2 Sending Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 40.3 Retriving Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 41 Diskless / Thin Client 41.1 Booting Stategy . . . . 41.1.1 Bootloader . . . 41.1.2 Optional 2. stage 41.2 Aditional Information . 41.3 Build Root Filesystem . . . . . . . . . . . . . . . bootloader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 131 131 131 131 131

XI

Randome Notes

132

42 IDE vs. the B.R.A.I.N. 134 42.1 Dening IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 6

CONTENTS

42.2 So why not use an IDE . . . . . . . . . . . . . . . 42.2.1 Working in Teams . . . . . . . . . . . . . . 42.2.2 Software has Bugs . . . . . . . . . . . . . . 42.2.3 Using an IDE acts the Code . . . . . . . . 42.2.4 Using IDE is too easy . . . . . . . . . . . . 42.2.5 Using IDE Makes one Patch the Errors . . 42.2.6 Using IDE does not teach you to write code 42.2.7 IDEs are dierent . . . . . . . . . . . . . . 42.3 Benets of using the GNU toolchain . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

134 134 134 134 135 135 135 135 135

43 Are you Lazy or Dumb? 136 43.1 Real Life Example . . . . . . . . . . . . . . . . . . . . . . . . . . 136 43.2 Applying to Hobby Projects . . . . . . . . . . . . . . . . . . . . . 136 44 Thinking outside the Window 138

XII

Appendix

139
141 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 142 144 144 145 147 147 148 148 148 149 149 150 151 154 158

A ASCII Chart B GNU Free Documentation License 1. APPLICABILITY AND DEFINITIONS . . . . . . . . . 2. VERBATIM COPYING . . . . . . . . . . . . . . . . . . 3. COPYING IN QUANTITY . . . . . . . . . . . . . . . . 4. MODIFICATIONS . . . . . . . . . . . . . . . . . . . . . 5. COMBINING DOCUMENTS . . . . . . . . . . . . . . . 6. COLLECTIONS OF DOCUMENTS . . . . . . . . . . . 7. AGGREGATION WITH INDEPENDENT WORKS . . 8. TRANSLATION . . . . . . . . . . . . . . . . . . . . . . 9. TERMINATION . . . . . . . . . . . . . . . . . . . . . . 10. FUTURE REVISIONS OF THIS LICENSE . . . . . . 11. RELICENSING . . . . . . . . . . . . . . . . . . . . . . ADDENDUM: How to use this License for your documents C ARM boot code for the LPC2106 D Linker Script for the LPC2468 Bibliography

List of Figures
2.1 8.1 Todo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The structure of the Anemometer project. . . . . . . . . . . . . . 21 35 98

25.1 Todo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

28.1 The data from the datasheet . . . . . . . . . . . . . . . . . . . . 108 28.2 The diviation. The values are calculated . . . . . . . . . . . . . . 108 40.1 Todo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

List of Tables
11.1 Dierent protocols and dierent memories for storage. . . . . . . 24.1 Comparison of dierent displays . . . . . . . . . . . . . . . . . . 52 96

29.1 The les needed from FreeRTOS . . . . . . . . . . . . . . . . . . 109 32.1 The les needed from FreeRTOS . . . . . . . . . . . . . . . . . . 114

Listings
2.1 2.2 2.3 2.4 3.1 3.2 3.3 3.4 3.5 3.6 4.1 4.2 10.1 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 15.1 15.2 15.3 15.4 Test program, ex1.c to illustarte how GCC works Try to compile using the -### ag to GCC . . Find the size of the binry . . . . . . . . . . . . . Find the source of the binry . . . . . . . . . . . . Setting the TARGET and PREFIX . . . . . . . . Conguring and building binutils for ARM7 . . . Conguring and building initial GCC for ARM7 Conguring and building Newlib GCC for ARM7 Conguring and building GCC for ARM7 . . . . Conguring and building GDB for ARM7 . . . . Set the TARGET and PREFIX . . . . . . . . . . Conguring and building AVR-LIBC . . . . . . . Linker script for a LPC2106 . . . . . . . . . . . . Downloading the Linux kernel and patch . . . . . Preparing for build . . . . . . . . . . . . . . . . . Builnd and install Linux headers . . . . . . . . . Install uCLibc headers . . . . . . . . . . . . . . . Install GMP . . . . . . . . . . . . . . . . . . . . . Install GMP . . . . . . . . . . . . . . . . . . . . . Conguring and building binutils for ARM9 . . . Conguring and building initial GCC . . . . . . . Conguring and building GCC . . . . . . . . . . Downloading the Linux kernel and patch . . . . . Unpacking and patching the kernel . . . . . . . . The output from the patch command should look Downloading Busybox . . . . . . . . . . . . . . . Downloading Busybox using SVN . . . . . . . . . Conguring Busybox . . . . . . . . . . . . . . . . Build Busybox . . . . . . . . . . . . . . . . . . . Install Busybox . . . . . . . . . . . . . . . . . . . Rootfs . . . . . . . . . . . . . . . . . . . . . . . . Start the SSH server . . . . . . . . . . . . . . . . make.conf gor ARM . . . . . . . . . . . . . . . . Set the time . . . . . . . . . . . . . . . . . . . . . Upgrading Busybox . . . . . . . . . . . . . . . . 10 . . . . . . . . . 16 . . . . . . . . . 17 . . . . . . . . . 18 . . . . . . . . . 18 . . . . . . . . . 26 . . . . . . . . . 26 . . . . . . . . . 26 . . . . . . . . . 27 . . . . . . . . . 27 . . . . . . . . . 28 . . . . . . . . . 31 . . . . . . . . . 31 . . . . . . . . . 39 . . . . . . . . . 46 . . . . . . . . . 48 . . . . . . . . . 48 . . . . . . . . . 48 . . . . . . . . . 49 . . . . . . . . . 49 . . . . . . . . . 49 . . . . . . . . . 50 . . . . . . . . . 50 . . . . . . . . . 55 . . . . . . . . . 56 something like this 56 . . . . . . . . . 58 . . . . . . . . . 58 . . . . . . . . . 58 . . . . . . . . . 58 . . . . . . . . . 59 . . . . . . . . . 59 . . . . . . . . . 61 . . . . . . . . . 61 . . . . . . . . . 62 . . . . . . . . . 62

LISTINGS

15.5 17.1 17.2 19.1 19.2 19.3 19.4 19.5 20.1 21.1 22.1 26.1 26.2 26.3 31.1 35.1 36.1 37.1 38.1 39.1 C.1 D.1

Dmesg . . . . . . . . . . . . . . . . . . . . . . . . . . First Boot . . . . . . . . . . . . . . . . . . . . . . . . 2. Try . . . . . . . . . . . . . . . . . . . . . . . . . . The output from Redboot. Modifyed for readability Telnet to Redboot . . . . . . . . . . . . . . . . . . . Boot you own kernel . . . . . . . . . . . . . . . . . . Boot you own kernel . . . . . . . . . . . . . . . . . . Boot from Harddrive . . . . . . . . . . . . . . . . . . Using le to gureout the endianess . . . . . . . . . The output from 1. boot. Modifyed for readability . Looking at the MTD system using Linux . . . . . . . Lspci on Vortex86 . . . . . . . . . . . . . . . . . . . Cpuifo on Vortex86 . . . . . . . . . . . . . . . . . . . Emerging on the Vortex86 . . . . . . . . . . . . . . . Startup Code for the LPC2468, crt0.S . . . . . . . . A sample of my dhcpd.conf . . . . . . . . . . . . . . A sample of my /etc/exports le . . . . . . . . . . . TFTPd conf. . . . . . . . . . . . . . . . . . . . . . . A sample of my /etc/rsyncd.conf le . . . . . . . . . A sample of my /etc/xinit.d/daytime-udp le . . . . Startup Code for the LPC2106 . . . . . . . . . . . . Linker Script, linker.ld . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

62 69 73 80 82 82 82 83 85 86 92 102 102 103 111 123 125 126 127 128 151 154

11

Nomenclature
AS CC GCC GNU MCU Assembler C Compiler Gnu Compiler Collection Gnu is Not Unix Micro Controller Unit

12

Part I

Embedded GNU

13

Table of Contents

1 2

About Embedded GNU The GNU Toolchain 2.1 2.2 2.3 2.4 GCC at the rst Glance . . . . . . . . . . . . . . . . . . . . . . . GCC - a closer look . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 So What did We get . . . . . . . . . . . . . . . . . . . . . GCC Workow . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tools in a Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.1 2.4.2 2.4.3 2.5 Binutils . . . . . . . . . . . . . . . . . . . . . . . . . . . . GCC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Libc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15 16 16 17 18 20 20 20 22 23 23 24 24 25 25 26 26 26 27 27 27

Using Make . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Installing the Toolchain for your target 3.1 3.2 3.3 Known Targets for GCC . . . . . . . . . . . . . . . . . . . . . . . Installing the ABI toolcain for ARM7 . . . . . . . . . . . . . . . Create a proper Development Layout . . . . . . . . . . . . . . . . 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 Set the TARGET etc. . . . . . . . . . . . . . . . . . . . . Binutils . . . . . . . . . . . . . . . . . . . . . . . . . . . . Initiel GCC . . . . . . . . . . . . . . . . . . . . . . . . . . Newlib - LibC for ARM7 . . . . . . . . . . . . . . . . . . GCC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Optional - gdb . . . . . . . . . . . . . . . . . . . . . . . .

Chapter 1

About Embedded GNU


I wrote this since I have a lot of dierent information, collected from, even more, dierent sources. In the eksamples I will focus on the ARM processor, but they should apply for, almost, any architure.

15

Chapter 2

The GNU Toolchain


The GNU toolchain concists of, among others, GCC , Binutils and helper programs like make. GCC can be used to compile a wide range of programming languages to a wide range of dierent architures. Using the GNU tools for embedde targets may seem as over kill for some, but having the same set of tools for your PC and your embedded targets gives a surpresingly large amount of benets.

2.1

GCC at the rst Glance

To illustrate how GCC works, here a small test program, that will be used. The program is not intended to anything, but it has servial intresting parts; zero initialized variable, initialzed variable. These variables will be discussed, when explaning the linker and startup code. Listing 2.1: Test program, ex1.c to illustarte how GCC works
1 2 3 4 5 6 7 8 9 10 11 12 13

i n t main ( ) { int i = 1 ; char c = 5 ; i = c; while ( i ) { i++; } return i ; }

If the program, in listing 2.1 is to be compiled, one can do arm-none-eabigcc ex1.c. This will compile without errors or warnings, but it will proboly 16

2.2. GCC - A CLOSER LOOK

newer run on an actual target. The reson for this is the linker does not know were to put the dierent parts of the program, so everything is probobly not were you want it to be.

2.2

GCC - a closer look

Lets see what is really going on, under the hood, when compiling the code from listing 2.2. We add the -### ag to GCC at the command line, see listing 2.2 for the comprehensive output. So what realy did happen? Well line 1 just shown the command line as specifyed. Line 5 Tell us the terget name, here the ARM. Line 10 Is the line that is passed to cc11 , whose output is specifyed by the -o /tmp/cc4l8aQQ.s part. In this case a le is created in the /tmp directory. Line 12 uses the le from line 10, to call as input to AS2 , which will the produce an object le, speciyed by -o /tmp/cc3P3Err.o. Line 16 Uses a utility called collect2, which will call the linker once, the look at the produced output for initialization functions an so on. The output from this line is the a.out le. As indicated in line 10, GCC uses the /tmp directory for storingg les, before passing the on to the next program. One can force GCC to simply pipe the le from one program to another, using the pipe ag. Listing 2.2: Try to compile using the -### ag to GCC
1 2 3 4

5 6

7 8 9 10

11 12

13

$ armnonee a b i g c c # ex1 . c ## Using b u i l t i n s p e c s . COLLECT GCC =armnonee a b i g c c COLLECT LTO WRAPPER =/home/ tko / l o c a l / l i b e x e c / g c c /armnonee a b i /4 . 6 . 0/ l t o wrapper Target : armnonee a b i C o n f i g u r e d with : . . / . . / gccsvn / c o n f i g u r e p r e f i x=/home/ tko / l o c a l t a r g e t=armnonee a b i d i s a b l e n l s enable l a n g u a g e s=c , c++ withn e w l i b withh e a d e r s=/home/ tko / b u i l d / newlib 1 . 18 . 0/ n e w l i b / l i b c / i n c l u d e Thread model : s i n g l e g c c v e r s i o n 4 . 6 . 0 20101014 ( e x p e r i m e n t a l ) (GCC) COLLECT GCC OPTIONS = /home/ tko / l o c a l / l i b e x e c / g c c /armnonee a b i /4 . 6 . 0/ c c 1 q u i e t D USES INITFINI ex1 . c q u i e t dumpbase ex1 . c auxbase ex1 o /tmp/ cc4l8aQQ . s COLLECT GCC OPTIONS = /home/ tko / l o c a l / l i b / g c c /armnonee a b i /4 . 6 . 0/ . . / . . / . . / . . /arm nonee a b i / b i n / a s meabi=5 o /tmp/ cc3P3Err . o /tmp/ cc4l8aQQ . s COMPILER PATH =/home/ tko / l o c a l / l i b e x e c / g c c /armnonee a b i /4 . 6 . 0/ : /home/ tko / l o c a l / l i b e x e c / g c c /armnonee a b i /4 . 6 . 0/ : /home/
1C

Compiler

2 Assembler

17

2.2. GCC - A CLOSER LOOK

14

15 16

tko / l o c a l / l i b e x e c / g c c /armnonee a b i / : /home/ tko / l o c a l / l i b / g c c /armnonee a b i /4 . 6 . 0/ : /home/ tko / l o c a l / l i b / g c c /armnone e a b i / : /home/ tko / l o c a l / l i b / g c c /armnonee a b i /4 . 6 . 0/ . . / . . / . . / . . /armnonee a b i / b i n / LIBRARY PATH =/home/ tko / l o c a l / l i b / g c c /armnonee a b i /4 . 6 . 0/ : / home/ tko / l o c a l / l i b / g c c /armnonee a b i /4 . 6 . 0/ . . / . . / . . / . . /arm nonee a b i / l i b / COLLECT GCC OPTIONS = /home/ tko / l o c a l / l i b e x e c / g c c /armnonee a b i /4 . 6 . 0/ c o l l e c t 2 X / home/ tko / l o c a l / l i b / g c c /armnonee a b i /4 . 6 . 0/ c r t i . o /home/ tko / l o c a l / l i b / g c c /armnonee a b i /4 . 6 . 0/ c r t b e g i n . o /home/ tko / l o c a l / l i b / g c c /armnonee a b i /4 . 6 . 0/ . . / . . / . . / . . /arm nonee a b i / l i b / c r t 0 . o L/home/ tko / l o c a l / l i b / g c c /armnone e a b i /4 . 6 . 0 L/home/ tko / l o c a l / l i b / g c c /armnonee a b i /4 . 6 . 0/ . . / . . / . . / . . /armnonee a b i / l i b /tmp/ cc3P3Err . o s t a r t group l g c c l c endgroup /home/ tko / l o c a l / l i b / g c c /arm nonee a b i /4 . 6 . 0/ c r t e n d . o /home/ tko / l o c a l / l i b / g c c /armnone e a b i /4 . 6 . 0/ c r t n . o

This may seem a bit overwelming, but it is actualy quite logic, when you get the hang of it.

2.2.1

So What did We get


Listing 2.3: Find the size of the binry

Using the approch from section 2.2, what did we get, you might ask. Well

1 2 3

$ armnonee a b i s i z e a . out text data bss dec 9736 2404 260 12400

hex f i l e n a m e 3070 a . out

Text section is the binary code to be executed, here we have approxemently 10kB of code. data this segment is made up from global and static variables. bss section, were zero initialazed variables are located. Small variables, used only localy in unctions are, usely, stored (and overwritten) in internal registers. Using the approch from section 2.2, we add -g for debugging info, compile the code and use objdump to print it all back. Listing 2.4: Find the source of the binry
1 2 3 4 5 6

armnonee a b i objdump a . out 000081 b8 <main>: i n t main ( ) { 81 b8 : e52db004 fp , [ sp , # ] ! ) 4 81 bc : e28db000

push add

{fp} fp , sp , #0

; ( str

18

2.2. GCC - A CLOSER LOOK

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

81 c0 : int i = 1 ; 81 c4 : 81 c8 : char c = 5 ; 81 c c : 81 d0 : i = c; 81 d4 : 81 d8 : while ( i ) 81 dc : { i++; 81 e0 : 81 e4 : 81 e8 : int i = 1 ; char c = 5 ; 81 c c : 81 d0 : i = c; 81 d4 : 81 d8 : while ( i ) 81 dc : { i++; 81 e0 : 81 e4 : 81 e8 : int i = 1 ; char c = 5 ; i = c; while ( i ) 81 e c : 81 f 0 : 81 f 4 : { i++; } return i ; 81 f 8 : }

e24dd00c e3a03001 e50b3008 e3a03005 e54b3009

sub mov str mov strb

sp , sp , #12 r3 , #1 r3 , [ fp , # ] 8 r3 , #5 r3 , [ fp , # ] 9

e55b3009 e50b3008

ldrb str

r3 , [ fp , # ] 9 r3 , [ fp , # ] 8

ea000002

81 e c <main+0x34>

e51b3008 e2833001 e50b3008

ldr add str

r3 , [ fp , # ] 8 r3 , r3 , #1 r3 , [ fp , # ] 8

e3a03005 e54b3009

mov strb

r3 , #5 r3 , [ fp , # ] 9

e55b3009 e50b3008

ldrb str

r3 , [ fp , # ] 9 r3 , [ fp , # ] 8

ea000002

81 e c <main+0x34>

e51b3008 e2833001 e50b3008

ldr add str

r3 , [ fp , # ] 8 r3 , r3 , #1 r3 , [ fp , # ] 8

e51b3008 e3530000 1afffff9

ldr cmp bne

r3 , [ fp , # ] 8 r3 , #0 81 e0 <main+0x28>

e51b3008

ldr

r3 , [ fp , # ] 8

19

2.3. GCC WORKFLOW

58 59 60 61

81 f c : 8200 : 8204 : 8208 :

e1a00003 e28bd000 e8bd0800 e12fff1e

mov add pop bx

r0 , r 3 sp , fp , #0 {fp} lr

2.3

GCC Workow

Insted of using GCC to control the workow, you can control it youselv. Any of the steps from Listing 2.2, can be done manually. Actualy there are other steps in compiling eg. C code, which can be done step by step, or controlled by GCC. The workow for compiling C (or simmelar) code is illustarted in gure 2.1. Any of these steps can be done by hand but, as you might have gured out, it is wery timecunsuming. The steps can be done, by calling only GCC, but if you have many source les the compile time will increse. You can, also, use build systems, like make (see section 2.5).

2.4

Tools in a Toolchain

This is a, short, list of programs in the GNU toolchain.

2.4.1

Binutils

Binutils is a copilation of assembler, linker and various tools. Most importent of them are listed here: addr2line: Translates program addresses into le names and line numbers. Given an address and an executable, it uses the debugging information in the executable to gure out which le name and line number are associated with a given address. ar: The GNU ar program creates, modies, and extracts from archives. An archive is a single le holding a collection of other les in a structure that makes it possible to retrieve the original individual les (called members of the archive). as: GNU as is really a family of assemblers. If you use (or have used) the GNU assembler on one architecture, you should nd a fairly similar environment when you use it on another architecture. Each version has much in common with the others, including object le formats, most assembler directives (often called pseudo-ops) and assembler syntax. as is primarily intended to assemble the output of the GNU C compiler gcc for use by the linker ld. Nevertheless, weve tried to make as assemble correctly everything that the native assembler would. This doesnt mean as always uses the same syntax as another assembler for the same architecture.

20

2.4. TOOLS IN A TOOLCHAIN

header1.h

header2.h

source1.c

precompiler

source1.i

c compiler

source1.s

assembler

source1.o

linker script

linker

Figure 2.1: Todo

21

2.4. TOOLS IN A TOOLCHAIN

c++lt: The c++lt program does the inverse mapping: it decodes (demangles) low-level names into user-level names so that the linker can keep these overloaded functions from clashing. gasp: Gnu Assembler Macro Preprocessor. ld: The GNU linker ld combines a number of object and archive les, relocates their data and ties up symbol references. Often the last step in building a new compiled program to run is a call to ld. nm: GNU nm lists the symbols from object les. objcopy: The GNU objcopy utility copies the contents of an object le to another.objcopy uses the GNU BFD library to read and write the object les. It can write the destination object le in a format dierent from that of the source object le. The exact behavior of objcopy is controlled by command-line options. objdump: Objdump displays information about one or more object les. The options control what particular information to display. ranlib: ranlib generates an index to the contents of an archive, and stores it in the archive. The index lists each symbol dened by a member of an archive that is a relocatable object le. You may use nm -s or nm print-armap to list this index. readelf: readelf Interprets headers on elf les. size: The GNU size utility lists the section sizes and the total size for each of the object les objle in its argument list. By default, one line of output is generated for each object le or each module in an archive. strings: GNU strings prints the printable character sequences that are at least 4 characters long (or the number given with the options below) and are followed by an unprintable character. By default, it only prints the strings from the initialized and loaded sections of object les; for other types of les, it prints the strings from the whole le. strip: GNU strip discards all symbols from the target object le(s). The list of object les may include archives. At least one object le must be given. strip modies the les named in its argument, rather than writing modied copies under dierent names.

2.4.2

GCC

The GCC3 gcc: The C compiler


3 GNU

Compiler Collection

22

2.5. USING MAKE

gcov: gcov is a tool you can use in conjunction with GCC to test code coverage in your programs. cpp: the C preprocessor. c++: The C++ Compiler. gprof: . The GNU proler, used to measure where your software spends all it time.

2.4.3

Libc

Using a libc on an embedded system, bare metal that is, can be an improvement in features, but it comes at a cost; memory footprint and performance. Servial embedded versions of the libc excists for embedded targets, but many of them are still experimental. I tend to use Newlib[9].

2.5

Using Make

Using GNU Make can, at rst, seem as over-kill. But having a project of eg. 25 source les and headerles will take time to compile. Furthermore we have the dependency to remember; If one changes a headerle, which source les must then be recompiled? Of cource using a script will solve most of the problems, but everything will have to be recompiled all the time - costing time.

23

Chapter 3

Installing the Toolchain for your target


The rst two steps in installing your own toolchain for your target involves downloading the sourcecode and decing on a target name. Downloading the sourcecode can be done from your local GNU mirror or directly from gnu.org. Desiding on a target name can seem like a simple task, but it can have consequences. One should also consider the endian now, to avoid problems later.

3.1

Known Targets for GCC

For some reson, I have newer fornd a compleate list of valid targets anywhere on the Internet (so maby not all knowledge is on the Internet??). Here is a list of valid targets, that I know of: 1. arm-elf, 2. arm-none-eabi, 3. avr, smalle 8-bit MCU, only produced by Atmel. 4. blackn, DSP. 5. h8300-hms, produced by Hitachi. 6. in86, Probaly the most known? Also refered to as the x86 architecture. 7. m6811-elf, Small 8-bit MCU from Motorola - now Freescale. 8. m6812-elf, Small 8-bit MCU from Motorola - now Freescale.

24

3.2. INSTALLING THE ABI TOOLCAIN FOR ARM7

9. m68k-elf, One of the coolest CPUs ever. The beating hart of the Amiga 500. 10. mips, Hmm, I had a wireless router with one of them.. 11. microblaze-elf, soft CPU. 12. powerpc-elf, 13. powerpc-eabi,

3.2

Installing the ABI toolcain for ARM7

To illustrate the steps involved in installing the toolchain, heres how to install it for ARM7. The steps involved are: 1. Downloading the sourcecode 2. Create a proper development layout 3. Setup TARGET 4. Setup PREFIX 5. Build and install Binutils 6. Build and install Initial GCC (refered to as xgcc) 7. Build and install newlib[9] 8. Build and install GCC

3.3

Create a proper Development Layout

I prefer a development layout simmelar to the one illustrated below. build binutils gcc xgcc gdb

source binutils-[version] gcc-[version] newlib-[version] gdb-[version] 25

3.3. CREATE A PROPER DEVELOPMENT LAYOUT

3.3.1

Set the TARGET etc.

The target here is the ARM and we would like it to produce elf binaries. As always I prefer to have the toolchain installe localy is my own homedir, so I set the prex accordenly: Listing 3.1: Setting the TARGET and PREFIX
1 2

# export TARGET =arm e l f # export PREFIX=/home/ t o k e / l o c a l

3.3.2

Binutils

Section 2.4.1 holds a description of the tools that make up the binutils package. Now it is time to congure, build and install the binutils package: Listing 3.2: Conguring and building binutils for ARM7
1 2 3 4 5 6 7 8 9 10 11

# cd b u i l d / b i n u t i l s # . . / . . / s o u r c e / b i n u t i l s <v e r s i o n >/ c o n f i g u r e \ p r e f i x=${PREFIX} \ t a r g e t=${TARGET} \ e n a b l e i n t e r w o r k \ e n a b l e m u l t i l i b \ withgnul d \ withgnua s \ d i s a b l e n l s # make a l l # make i n s t a l l

We now have a working assembler, linker and the other tools from the binutils package. You actualy also have these utils installed for your PC1 . Now we just need to add you new progams to our PATH variable # PATH=${PREFIX}/bin:$PATH The traling bin, is added since all binaries are located in a bin folder.

3.3.3

Initiel GCC
Listing 3.3: Conguring and building initial GCC for ARM7

1 2 3 4 5 6

# cd b u i l d / xg c c # . . / . . / gcc<v e r s i o n >/ c o n f i g u r e p r e f i x=$PREFIX \ t a r g e t= $TARGET \ e n a b l e i n t e r w o r k \ e n a b l e m u l t i l i b \


1 Or

else you would not be able to assemble or link your programs...

26

3.3. CREATE A PROPER DEVELOPMENT LAYOUT

7 8 9 10 11 12 13 14

e n a b l e l a n g u a g e s= c \ withn e w l i b \ withh e a d e r s=[ newlib s o u r c e ] / n e w l i b / l i b c / i n c l u d e withgnul d \ withgnua s \ d i s a b l e n l s # make a l l g c c # make i n s t a l l g c c

3.3.4

Newlib - LibC for ARM7


Listing 3.4: Conguring and building Newlib GCC for ARM7

1 2 3 4 5 6 7 8 9 10 11

# cd b u i l d / n e w l i b # . . / . . / newlib <v e r s i o n >/ c o n f i g u r e \ t a r g e t= $TARGET \ p r e f i x=$PREFIX \ e n a b l e i n t e r w o r k \ e n a b l e m u l t i l i b withgnul d \ withgnua s \ d i s a b l e n l s # make a l l # make i n s t a l l

3.3.5

GCC
Listing 3.5: Conguring and building GCC for ARM7

1 2 3 4 5 6 7 8 9 10 11 12 13 14

# cd b u i l d / g c c # . . / . . / gcc<v e r s i o n >/ c o n f i g u r e p r e f i x=$PREFIX \ t a r g e t= $TARGET \ e n a b l e i n t e r w o r k \ e n a b l e m u l t i l i b \ e n a b l e l a n g u a g e s= c , c++ \ withn e w l i b \ withh e a d e r s=[ newlib s o u r c e ] / n e w l i b / l i b c / i n c l u d e withgnul d \ withgnua s \ d i s a b l e n l s # make a l l # make i n s t a l l

3.3.6

Optional - gdb

27

3.3. CREATE A PROPER DEVELOPMENT LAYOUT

Listing 3.6: Conguring and building GDB for ARM7


1 2 3 4 5 6 7 8 9 10 11

# cd b u i l d / gdb # . . / . . /gdbv e r s i o n / c o n f i g u r e \ t a r g e t= $TARGET \ p r e f i x=$PREFIX \ e n a b l e i n t e r w o r k \ e n a b l e m u l t i l i b \ withgnul d \ withgnua s \ d i s a b l e n l s # make a l l # make i n s t a l l

28

Part II

AVR

29

Table of Contents

Enviroment Setup 4.1 Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1.1 Libc - avr-libc . . . . . . . . . . . . . . . . . . . . . . . .

31 31 31 32 33 34 35 35

5 6 7 8

The AVR Hardware Building the Software Running Software on the AVR Project: AVR Anemometer 8.1 Project layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Chapter 4

Enviroment Setup
4.1 Toolchain

Installing a toolchain for AVR is done as illustarted in Chapter 3 on page 24. Just change the TARGET to avr, as in listing 4.1. Listing 4.1: Set the TARGET and PREFIX
1 2

# e x p o r t TARGET =avr # e x p o r t PREFIX=/home/ t o k e / b i n / avr

4.1.1

Libc - avr-libc
Listing 4.2: Conguring and building AVR-LIBC

For AVR I use a special libc, called avr-libc. It is developed special for AVR.

1 2 3 4

# . / configure \ b u i l d= . / c o n f i g . g u e s s \ h o s t=avr \ p r e f i x=/home/ tko / b i n / avr 4 . 4 . 0

31

Chapter 5

The AVR Hardware

32

Chapter 6

Building the Software

33

Chapter 7

Running Software on the AVR

34

Chapter 8

Project: AVR Anemometer


The AVR imposes a great many posibilityes. One of them is to use some of the perials and a LCD to make a anemometer1 . Servial software components, from the SVN repos, can be reused: 1. Simplos 2. T6963C driver bla bla

8.1

Project layout

As described in section 34.2, all reuseble software parts are referenced by using svn:externals.

1 Device

for measuring windspeed

T6963C

T6963C_hal

simplos

anemometer

Figure 8.1: The structure of the Anemometer project. 35

Part III

ARM7

36

Table of Contents

Toolchain for ARM7 9.1 Lpc21ipc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

38 38 39 39 39 41 41

10 Demo Project using the toolchain and LPC2106 10.1 Project structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.1.1 Linkerscript . . . . . . . . . . . . . . . . . . . . . . . . . . 10.1.2 Boot Code . . . . . . . . . . . . . . . . . . . . . . . . . . 10.1.3 Main Software . . . . . . . . . . . . . . . . . . . . . . . .

Chapter 9

Toolchain for ARM7


The toolchain is installed as described in chapter 3 on page 24

9.1

Lpc21ipc

The lpc21ipc[8] can be fetched Sourceforge as a .gc le or via SVN. The utility is made for ARM MCUs from NXP only. Building the utility should not impose any problems, if you only remember to make clean rst. The build produces a binary only, which has to be placed in the PATH.

38

Chapter 10

Demo Project using the toolchain and LPC2106


I have used the LPC2106 for servial projects and it is a ne samme MCU. In order to make our toolchain produce code for the LPC2106 it must be instructed to do so. The main reson for this being the the toolchain can produce code for servial ARM variants (eg. ARM7 and ARM9) and that the linker needs to know from where in the memorymap to begin.

10.1

Project structure

For this small demo it is propely best to keep all les in one directory. Actualy the demo software does not do anything... It is for demo purpose only.

10.1.1

Linkerscript

The purpose of the linker script is to inform the linker where to nd dierent kinds of memory. Listing 10.1: Linker script for a LPC2106
1 2 3 4 5 6 7 8 9 10 11 12

MEMORY { f l a s h : ORIGIN = 0 , LENGTH = 120K ram : ORIGIN = 0 x40000000 , LENGTH = 64K } s t a c k end = 0 x40000000 + 64K 4 ;

SECTIONS { . = 0; startup : { ( . startup )} >f l a s h prog : {

39

10.1. PROJECT STRUCTURE

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

( . text ) ( . rodata ) ( . rodata ) ( . glue 7) ( . glue 7 t ) ( . i n i t ) ( . f i n i ) } >f l a s h end of t e x t = .; . data : { data beg = .; data beg s r c = ( . data ) data end = .; } >ram AT l a s h >f . bss : { b s s beg = .; ( . bss ) } >ram . = ALIGN( 4 ) ; . eh frame : { KEEP ( ( . eh frame ) ) } > ram

end of t e x t

40

41

42 43 44 45 46 47 48 49 50 51 52 53 54 55

/ A l i g n h e r e t o e n s u r e t h a t t h e . b s s s e c t i o n o c c u p i e s s p a c e up t o end . A l i g n a f t e r . b s s t o e n s u r e c o r r e c t a l i g n m e n t even i f t h e . b s s s e c t i o n d i s a p p e a r s b e c a u s e t h e r e a r e no i n p u t s e c t i o n s . / . = ALIGN( 3 2 / 8 ) ; } . = ALIGN( 3 2 / 8 ) ; end = . ; b s s end = . ; b s s end PROVIDE ( end = . ) ; PROVIDE( PROVIDE( PROVIDE( PROVIDE( PROVIDE( PROVIDE( PROVIDE(

= . ;

end

= . ;

undefined i n s t r u c t i o n exception = endless loop ) ; software interrupt exception = endless loop ) ; prefetch abort exception = endless loop ) ; data a b o r t e x c e p t i o n = e n d l e s s l o o p ) ; reserved exception = endless loop ) ; interrupt exception = endless loop ) ; f a s t interrupt exception = endless loop ) ;

40

10.1. PROJECT STRUCTURE

10.1.2

Boot Code

The purpose of the bootcode is to bootup the device into a known state, setup StackPointer and copy over any initialesed variables. The sourcecode for the bootcode can be found in Appendix C

10.1.3

Main Software

41

Part IV

ARM9 - KB9202B

42

Table of Contents

11 Enviroment Setup 11.1 Toolchain - Note: NOT done . . . . . . . . . . . . . . . . . . . . 11.1.1 Precompiled Toolchains . . . . . . . . . . . . . . . . . . . 11.1.2 Toolchain from a Script . . . . . . . . . . . . . . . . . . . 11.2 Installing your own Toolchain . . . . . . . . . . . . . . . . . . . . 11.2.1 Create a proper Development Layout . . . . . . . . . . . . 11.2.2 Set the TARGET etc. . . . . . . . . . . . . . . . . . . . . 11.2.3 Linux Headers . . . . . . . . . . . . . . . . . . . . . . . . 11.2.4 uClibc Headers . . . . . . . . . . . . . . . . . . . . . . . . 11.2.5 GMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2.6 MPFR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2.7 Binutils . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2.8 Initial GCC . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2.9 Full Blown GCC . . . . . . . . . . . . . . . . . . . . . . . 11.3 Using the tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3.1 Hello World - Test Program . . . . . . . . . . . . . . . . . 11.4 Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 The KB9202B Hardware 13 KB9202B Factsheet 13.1 Memorymap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

45 45 45 45 47 47 48 48 48 48 49 49 50 50 51 51 51 53 54 54

TABLE OF CONTENTS

14 Building the Software 14.1 Building U-boot . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.1.1 Conguring U-boot . . . . . . . . . . . . . . . . . . . . . . 14.2 Building the Linux Kernel . . . . . . . . . . . . . . . . . . . . . . 14.2.1 Downloading the Kernel and Patches . . . . . . . . . . . . 14.2.2 Unpacking and Paching the Linux Kernel . . . . . . . . . 14.2.3 Congurating the Kernel . . . . . . . . . . . . . . . . . . 14.2.4 Compiling the Kernel . . . . . . . . . . . . . . . . . . . . 14.2.5 Optional Create an image for U-boot . . . . . . . . . . . . 14.3 Building uClibc for the target . . . . . . . . . . . . . . . . . . . . 14.4 Busybox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14.4.1 Downloading and unpacking Busybox . . . . . . . . . . . 14.4.2 Congurating Busybox . . . . . . . . . . . . . . . . . . . . 14.4.3 Building Busybox . . . . . . . . . . . . . . . . . . . . . . 14.5 Creating a rootfs Image . . . . . . . . . . . . . . . . . . . . . . . 15 Running Software on the KB9202B 15.1 Running the new kernel . . . . . . . . . . . . . . . . . . . . . . . 15.2 Gentoo on the KB9202B . . . . . . . . . . . . . . . . . . . . . . . 15.2.1 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.2.2 Set the date and time . . . . . . . . . . . . . . . . . . . . 15.2.3 Emerge the rst package . . . . . . . . . . . . . . . . . . . 15.2.4 Dmesg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.3 Running custom Software . . . . . . . . . . . . . . . . . . . . . . 15.3.1 IO driver . . . . . . . . . . . . . . . . . . . . . . . . . . .

55 55 55 55 55 56 57 57 57 57 57 58 58 58 59 60 60 60 60 62 62 62 65 65

44

Chapter 11

Enviroment Setup
11.1 Toolchain - Note: NOT done

Installing your own toolchain from source can be a long and hard task, so a lot of developers prefer to use a precompiled one. The toolchain itself consistes of the compiler, assembler and linker1 .

11.1.1
bla

Precompiled Toolchains

Precompiled toolcains can be:

11.1.2

Toolchain from a Script

Another possility is to use a script Buildroot [2] Crossdev2 [6] Crosstool [4] Crosstool-NG [5] Openembedded Scratchbox [10] Crossplex [3]
1 And 2 crossdev

various other utils is Gentoo specic

45

11.1. TOOLCHAIN - NOTE: NOT DONE

Crossdev Crossdev is Gentoos way of producing cross compilers. It is relativly simple to use and does not requere much (apart from a box running Gentoo and a lot of time...). I managed to get the crossdev working, just adding one line to my /etc/make.conf: PORTDIR_OVERLAY="/opt/crossdev-test" Then do: crossdev --target arm-unknown-linux-gnu And you get a toolchain, located in /opt/crossdev-test. Listing 11.1: Downloading the Linux kernel and patch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

# c r o s s d e v t a r g e t armunknownl i n u x gnu Host P o r t a g e ARCH: x86 Target P o r t a g e ARCH: arm Target System : armunknownl i n u x gnu Stage : 4 (C/C++ c o m p i l e r ) binutils : gcc : headers : libc : b i n u t i l s [ l a t e s t ] gcc[ l a t e s t ] l i n u x h e a d e r s [ l a t e s t ] g l i b c [ l a t e s t ]

16 17

18 19

20

21

22

23

24

25

PORTDIR OVERLAY: / opt / c r o s s d e v t e s t PORT LOGDIR: / var / l o g / p o r t a g e PKGDIR: / u s r / p o r t a g e / p a c k a g e s / c r o s s /arm unknownl i n u x gnu PORTAGE TMPDIR: / var /tmp/ c r o s s /armunknownl i n u x gnu F o r c i n g t h e l a t e s t v e r s i o n s of { b i n u t i l s , g c c }c o n f i g / g n u c o n f i g . . . [ ok ] Log : / var / l o g / p o r t a g e / c r o s s armunknownl i n u x gnub i n u t i l s . log Emerging c r o s s b i n u t i l s . . . [ ok ] Log : / var / l o g / p o r t a g e / c r o s s armunknownl i n u x gnugcc stage1 . log Emerging c r o s s gccs t a g e 1 . . . [ ok ] Log : / var / l o g / p o r t a g e / c r o s s armunknownl i n u x gnul i n u x headers . log Emerging c r o s s l i n u x h e a d e r s . . . [ ok ]

46

11.2. INSTALLING YOUR OWN TOOLCHAIN

26 27

28

29

Log : / var / l o g / p o r t a g e / c r o s s armunknownl i n u x gnug l i b c . l o g Emerging c r o s s g l i b c . . . [ ok ] Log : / var / l o g / p o r t a g e / c r o s s armunknownl i n u x gnugcc stage2 . log Emerging c r o s s gccs t a g e 2 . . . [ ok ]

11.2

Installing your own Toolchain

You can actualy install it from sourcecode. The steps involved are: 1. Create a proper development layout 2. Setup TARGET etc 3. Install the Linux Headers 4. Install uClibc Headers 5. Build and install GMP 6. Build and install MPFR 7. Build and install Binutils 8. Build and install Initial GCC 9. Build and install uClibc 10. Build and install GCC We tryed building the toolchain on a VIA C3 CPU3 running Gentoo Linux. It seems that people using other CPUs and other Linux distrubutions have other problems then the ones we had. So compiling your own toolchain for a target dierent then you PC, can leed to a lot of time used on www.google.com. It seems that installing GCC is the realy hard part, where the rest of the toolcain newer made any problems for us.

11.2.1

Create a proper Development Layout


binutils mpfr gmp gcc

build-tools

3 CL10000

motherboard with CPU

47

11.2. INSTALLING YOUR OWN TOOLCHAIN

source binutils-2.18 gcc-4.3.0 linux-2.6.24 gmp-4.2.2 mpfr-2.3.0

11.2.2

Set the TARGET etc.


Listing 11.2: Preparing for build

1 2

# e x p o r t TARGET =arml i n u x u c l i b c # e x p o r t PREFIX=/home/ t o k e /arm

11.2.3

Linux Headers
Listing 11.3: Builnd and install Linux headers

Installing the Linux headers is a small and easy task.

1 2 3 4 5 6

# make \ ARCH =arm \ HOSTCC / u s r / b i n / g c c \ = HOSTCXX / u s r / b i n / g++ \ = INSTALL HDR PATH =/home/ t o k e /arm/ b u i l d t o o l s / l i n u x \ headers i n s t a l l

11.2.4

uClibc Headers
Listing 11.4: Install uCLibc headers

1 2 3 4 5 6

# make \ PREFIX=/home/ t o k e /arm/ t o o l s / u C l i b c dev DEVEL PREFIX=/ u s r / RUNTIME PREFIX=/home/ t o k e /arm/ t o o l s / u C l i b c dev HOSTCC c c =g h e a d e r s i n s t a l l dev

11.2.5

GMP

GMP are the GNU Multiple Precision Arithmetic Library. You can download the newest version from: http://gmplib.org/. We newer had any problems installing GMP, so just do:

48

11.2. INSTALLING YOUR OWN TOOLCHAIN

Listing 11.5: Install GMP


1 2 3

# cd b u i l d /gmp # . . / . . / s o u r c e /gmp4 . 2 . 2/ c o n f i g u r e p r e f i x=${PREFIX}/ t o o l s # make a l l i n s t a l l

11.2.6

MPFR

MPFR is the multiple-precision oating-point computations with correct rounding libary. You can download the newest version from: http://www.mpfr.org/. We newer had any problems installing MPFR, so just do: Listing 11.6: Install GMP
1 2 3

# cd b u i l d / mpfr # . . / . . / s o u r c e / mpfr4 . 2 . 2/ c o n f i g u r e p r e f i x=${PREFIX}/ t o o l s # make a l l i n s t a l l

It seems that MPFR depends on GMP, so make sure you install the same two versions.

11.2.7

Binutils

Binutils is a collestion of binary tools. The major ones are as and ld. But the package also include a lot of other interesting and usefull tools. See the binutils webpage for more info: http://www.gnu.org/software/binutils/. Building binutils is easy and should not give any problems. Listing 11.7: Conguring and building binutils for ARM9
1 2 3 4 5 6 7

9 10 11 12

13

14 15

# cd b u i l d / b i n u t i l s # . . / . . / s o u r c e / b i n u t i l s 2 . 18/ c o n f i g u r e \ p r e f i x=/ u s r \ b u i l d=i 3 8 6 pcl i n u x gnu \ h o s t=i 3 8 6 pcl i n u x gnu \ t a r g e t=arml i n u x u c l i b c \ withs y s r o o t=/home/ t o k e / t e s t / b u i l d r o o t kb9202b / t o o l c h a i n b u i l d arm/ u C l i b c dev / \ withs y s r o o t=/home/ t o k e / t e s t / b u i l d r o o t kb9202b / b u i l d arm/ staging dir \ d i s a b l e m u l t i l i b \ d i s a b l e w e r r o r \ withf l o a t=s o f t \ withgmp= /home/ t o k e / t e s t / b u i l d r o o t kb9202b / t o o l c h a i n b u i l d arm/gmp \ withmpfr= /home/ t o k e / t e s t / b u i l d r o o t kb9202b / t o o l c h a i n b u i l d arm/ mpfr \ # make a l l # make i n s t a l l

49

11.2. INSTALLING YOUR OWN TOOLCHAIN

We now have a working assembler, linker and the other tools from the binutils package. You actualy also have these util installed for your PC. Now we just need to add you new progams to our PATH variable

11.2.8

Initial GCC
Listing 11.8: Conguring and building initial GCC

1 2

3 4 5

6 7 8 9 10

11

12 13 14

# configure \ p r e f i x=/home/ t o k e / t e s t / b u i l d r o o t kb9202b / b u i l d arm/ s t a g i n g dir / usr \ t a r g e t=arml i n u x u c l i b c \ e n a b l e l a n g u a g e s=c \ withs y s r o o t=/home/ t o k e / t e s t / b u i l d r o o t kb9202b / t o o l c h a i n b u i l d arm/ u C l i b c dev / \ d i s a b l e cxa a t e x i t \ e n a b l e t a r g e t o p t s p a c e \ withgnul d \ d i s a b l e s h a r e d \ withgmp=/home/ t o k e / t e s t / b u i l d r o o t kb9202b / t o o l c h a i n b u i l d arm/gmp \ withmpfr=/home/ t o k e / t e s t / b u i l d r o o t kb9202b / t o o l c h a i n b u i l d arm/ mpfr \ e n a b l e t h r e a d s \ d i s a b l e m u l t i l i b \ withf l o a t=s o f t \

This will compile tools for the target (to run on the host..). Now copy utils/ldd.host to tools/usr/bin. Then create a symbolic in the bin dir: ln -sf ldd arm-linux-uclibc-ldd

11.2.9

Full Blown GCC

First create a link, that bust be placed as tools/usr/arm-linux-uclibc/sys-include and link to ../include4 # ln -snf ../include /arm/tools/usr/arm-linux-uclibc/sys-include Now we can congure the full GCC. Since we plan to include various dierent applications, we included both C and C++ as languages. Listing 11.9: Conguring and building GCC
1 2 3 4 5

# configure \ p r e f i x=/ u s r \ t a r g e t=arml i n u x u c l i b c e n a b l e l a n g u a g e s=c , c++ d i s a b l e cxa a t e x i t


4 Is

this the right way of doing this?

50

11.3. USING THE TOOLS

6 7 8 9

10

11 12 13

e n a b l e t a r g e t o p t s p a c e \ withgnul d e n a b l e s h a r e d \ withgmp=/home/ t o k e / t e s t / b u i l d r o o t kb9202b / t o o l c h a i n b u i l d arm/gmp \ withmpfr=/home/ t o k e / t e s t / b u i l d r o o t kb9202b / t o o l c h a i n b u i l d arm/ mpfr \ e n a b l e t h r e a d s \ d i s a b l e m u l t i l i b \ withf l o a t=s o f t

# make all # make \ DESTDIR=/home/toke/test/buildroot-kb9202b/build_arm/staging_dir/ \ install

11.3

Using the tools

During this chapter we will try to compile and analyse a program.

11.3.1
wolla
1 2 3 4 5 6

Hello World - Test Program

#i n c l u d e <s t d i o . h> i n t main ( ) { p r i n t f ( H e l l o World ) ; p r i n t f ( Goodbye C r u e l World ) ; }

11.4

Server

In order to get the KB9202B board up and running it is nice to have a working Linux server at you hands. Durring the development of a running Linux on target5 is is benasial to allow more or less to be handled by a server. Durring bootup the KB9202B asks the server for an IP6 and the server will reply with the IP and The IP and path to a bootle (can be the U-BOOT or the Linux kernel). Table 11.1 illustrates the dierent protocols and what they can be use for. It can speedup the development, if most of these are located on the server in the beginning of the project and then moved to target as development carryes on.
5 In 6 If

this case the KB9202B not assigned a static IP...

51

11.4. SERVER

U-BOOT Linux kernel RootFS

ROM Yes Yes Yes

TFTP Yes Yes No

NFS No No Yes

Table 11.1: Dierent protocols and dierent memories for storage.

52

Chapter 12

The KB9202B Hardware

53

Chapter 13

KB9202B Factsheet
Here I try to give an impression of the hardware making up the N2100. The hardware is made up of: AT92RM9200 MCU ARM920T RICS prosessor ARM9 180MHz endian? 16KB data cache 16KB instruction cache

13.1
[7]

Memorymap

54

Chapter 14

Building the Software


14.1 Building U-boot

U-boot is the universal bootloader from Denx1 .

14.1.1

Conguring U-boot

make kb9202 cong

14.2

Building the Linux Kernel

Compiling the Linux Kernel requeres that you have the compiler installed. The kernel can be downloaded from kernel.org. Building the Linux kernel includes the following steps: 1. Downloading the kernel and patches. 2. Unpacking and Patching the kernel 3. Congurating the kernel 4. Compiling the kernel

14.2.1

Downloading the Kernel and Patches

The paches can be downloadet from http://maxim.org.za/at91 26.html Lots of dierent kernel mirrors exits, so just take your pick. Listing 14.1: Downloading the Linux kernel and patch
1

# wget c h t t p : //maxim . o r g . za /AT91RM9200/2 . 6/2 . 6 . 24 a t 9 1 . patch . gz


1 http://www.denx.de

55

14.2. BUILDING THE LINUX KERNEL

# wget c h t t p : //www. eu . k e r n e l . o r g /pub/ l i n u x / k e r n e l / v2 . 6/ l i n u x 2 . 6 . 24 . t a r . bz2

You now have the linux-2.6.24.tar.bz2 and the 2.6.24-at91.patch les.

14.2.2

Unpacking and Paching the Linux Kernel

Since support for the AT91RM9200 has yet to be supported by the kernels from www.kernel.org, you have to apply a patch to it. It does not matter where you plase the kernel source. If you downloadet kernel 2.6.24 you need the corresponding patch. Start by unpacking the kernel source. Listing 14.2: Unpacking and patching the kernel
1 2 3

# t a r x j f l i n u x 2 . 6 . 24 . t a r . bz2 # g u n z i p 2 . 6 . 24 a t 9 1 . patch . gz # patch p0 < 2 . 6 . 24 a t 9 1 . patch

Listing 14.3: The output from the patch command should look something like this
1 2 3

10

11 12 13 14 15 16

17 18 19

p a t c h i n g f i l e l i n u x 2 . 6 . 24/MAINTAINERS p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ K c o n f i g p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ boot / compressed / head at91rm9200 . S p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / at91cap9adk defconfig p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / at91rm9200dk defconfig p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / at91rm9200ek defconfig p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / at91sam9260ek defconfig p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / at91sam9261ek defconfig p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / at91sam9263ek defconfig p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / a t 9 1 s a m 9 r l e k defconfig p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / a t e b 9 2 0 0 d e f c o n f i g p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s /cam60 d e f c o n f i g p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / c s b 3 3 7 d e f c o n f i g p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / c s b 6 3 7 d e f c o n f i g p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / e c b a t 9 1 d e f c o n f i g p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / homematic defconfig p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / k a f a d e f c o n f i g p a t c h i n g f i l e l i n u x 2 . 6 . 24/ a r c h /arm/ c o n f i g s / kb9202 d e f c o n f i g .

56

14.3. BUILDING UCLIBC FOR THE TARGET

20 21

. .

14.2.3

Congurating the Kernel

In order to congure your kernel, change into the linux-2.6.24 directory. Now run the following command:
1

# make ARCH =arm kb9202 d e f c o n f i g

This command will set all options to the default for the kb9202 board2 . You are now ready to congure your kernel via the kernel-menu. Run the following command to enter the menu:
1

# make ARCH =arm menuconfig

14.2.4

Compiling the Kernel

In order to compile the kernel, you must have the arm-linux-uclibc-gcc in your PATH or supply it at the promt. In order to compile the kernel, when having the toolchain in your PATH:
1

# make ARCH =arm CROSS COMPILE =arml i n u x u c l i b c zImage

If you are compiling native (meaning on a ARM host, eg. the KB9202B itselv) just type make. In order to compile the kernel, without having the toolchain in your PATH, you must extend the argument CROSS COMPILE with the absolute path, eg. CROSS COMPILE=/opt/buildroot/build arm nofpu/staging dir/bin/arm-linuxuclibc-. When the compile job is done, you brand new, fancy kernel is located in: arch/arm/boot/zImage3 .

14.2.5

Optional Create an image for U-boot

The U-boot bootloader ca....

14.3 14.4

Building uClibc for the target Busybox

Busybox is the swiss army knife of embedded systems. It is a singe binary, that makes up the small well known Linux utils:
2 It 3 Mine

is a good idear to test your build setup with the default options. is 1761976 bytes in size

57

14.4. BUSYBOX

ls rm mknod vi The Busybox binary is linked to by applicatin names in eg. /bin. Busybox also include a small webserver and various other applications. See the Busybox webpage4 for more info.

14.4.1

Downloading and unpacking Busybox

Start by downloading the newest version of Busybox. Alternavily you can eather download a taarball, or use svn. Listing 14.4: Downloading Busybox
1

# wget c h t t p : //www. busybox . n e t / downloads / busybox 1 . 9 . 1 . t a r . bz2

Listing 14.5: Downloading Busybox using SVN


1

# svn co svn : // busybox . n e t / tru n k / busybox

14.4.2

Congurating Busybox

Congurating, and building, busybox is much like do so with the Linux kernel. In the Busybox directory rst enter the menu by: Listing 14.6: Conguring Busybox
1

# make CROSS COMPILE =arml i n u x u c l i b c menuconfig

Like, the Linux kernel, if you do not have the compiler in your path, extend the CROSS COMPILE argument (see section 14.2.4).

14.4.3

Building Busybox

Building the Busybox package is mush like building the Linux kernel (see section 14.2.4). So compiling the package is pretty much copy-paste: Listing 14.7: Build Busybox
1

# make CROSS COMPILE =arml i n u x u c l i b c

When the compilation is done, we need to install Busybox5 :


4 http://www.busybox.net 5 Busybox

install in the busybox/ install directory by default.

58

14.5. CREATING A ROOTFS IMAGE

Listing 14.8: Install Busybox


1

# make CROSS COMPILE =arml i n u x u c l i b c i n s t a l l

14.5

Creating a rootfs Image

In order to build a rootfs for Linux, we need the following: Libc, we use uClibc, see Busybox, see chapter 14.4 for instructions on how to build Busybox, wolla First create a destination, where your le system will be created. Here we use a directory called /diskless/kb9202b-rootfs.

Adding the Busybox


First copy the busybox binary and all the links from the install folder to the kb9202b-rootfs folder: Listing 14.9: Rootfs
1

# cp r busybox 1 . 9 . 1/ i n s t a l l / / d i s k l e s s / kb9202br o o t f s /

59

Chapter 15

Running Software on the KB9202B


15.1 15.2 Running the new kernel Gentoo on the KB9202B

Yes it is actualy possible to run Gentoo on the KB9202B board. It will newer be fast, but you do not have to use a cross compiler.

15.2.1

Setup

In my setup I have my server congured as a rsync server, see Section 38.0.1 on how to setup the rsync server. Hawing the rsync server located on your local network has servial benets; most importent is the speed factor. For diskspace I used a NFS server, see Section 36 for info on how to set it up. I added a 1GB USB keydrive for swap (Portage uses up a lot of RAM.... Yes Python I am looking at you!!). For starters I used the factory U-Boot and Linux kernel. Stage 3 Image You can download a Stage 3 Image from your Gentoo mirror1 . It is located in: [MIRROR]/gentoo/experimental/arm/stages/armv4l/stage3-armv4l-2008.0.tar.bz2 2 .
1 Not 2I

all miroors carry the ARM image, so you may have to look around a bit did NOT make this image

60

15.2. GENTOO ON THE KB9202B

Changing the conguration of the image To get the thing booting and ready to Gentoo, servial les have to be changed to suit your setup. /etc/conf.d/hostname. I set this to kb9202b /etc/conf.d/net. Since the IP is assigned by the commendline rootlesystem is mounted via NFS, we do not want DHCP. So I set this to cong eth0=( noop ) routes eth0=( default gw 192.168.0.2 ) /etc/fstab. The / is mountet via NFS, so it is: /dev/nfs / ext3 noattime 01 /etc/inittab. I changed s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100 to:s0:12345:respawn:/sbin/agetty 115200 ttyS0 vt100, since this is what the Linux kernel was instructed to do. /etc/passwd. I have no idea what the root password is, so I removed the x in the roots line: root::0:0:root:/root:/bin/bash Power up and enjoy the KB9202B boot Linux So now the image is ready and you connect the seriel port and power up the board. Once the KB9202B has booted, you can login via the seriel port. Now it is time to start the SSH server, and congure the network gateway: Listing 15.1: Start the SSH server
1 2

and our

#/ e t c / i n i t . d/ s s h d s t a r t #r o u t e add d e f a u l t gw 192 . 168 . 0 . 2

Iwe changed the make.conf to suid my needs: Listing 15.2: make.conf gor ARM
1 2 3 4 5 6

CFLAGS =O2 p i p e CXXFLAGS =O1 p i p e CHOST =armunknownl i n u x gnu SYNC r s y n c : //192 . 168 . 0 . 50/ gentoop o r t a g e = MAKEOPTS =j 1 ELIBC= g l i b c

Please notice that I have set the IP of my server (and not its name), since DNS was not running at this time. Also notice that some of the options may be unnessasary (ELIB,?).
3 Linux

command line

61

15.2. GENTOO ON THE KB9202B

15.2.2

Set the date and time


Listing 15.3: Set the time

1 2

3 4

6 7 8

kb9202b l i b # d a t e Thu Jan 1 01 : 20 : 55 L o c a l time zone must be s e t s e e z i c manual page 1970 kb9202b l i b # d a t e 082601152009 Wed Aug 26 01 : 15 : 00 L o c a l time zone must be s e t s e e z i c manual page 2009 kb9202b l i b # cp / u s r / s h a r e / z o n e i n f o / Europe / Copenhagen / e t c / localtime kb9202b l i b # d a t e Wed Aug 26 03 : 16 : 17 CEST 2009 kb9202b l i b #

15.2.3

Emerge the rst package


Listing 15.4: Upgrading Busybox

I have choosen to upgrade busybox rst:

1 2 3 4 5 6

emerge pv busybox These a r e t h e p a c k a g e s t h a t would be merged , in o r d e r : C a l c u l a t i n g d e p e n d e n c i e s . . . done ! [ ebuild U ] sys apps / busybox 1 . 13 . 2 [ 1 . 7 . 4 ] USE=pam debug makes y m l i n k s s a v e d c o n f i g ( s e l i n u x ) s t a t i c 1 , 9 9 9 kB T o t a l : 1 package ( 1 upgrade ) , S i z e of downloads : 1 , 9 9 9 kB

7 8 9

All that is left now is to remove the -pv ags and redo the command..(and wait..)

15.2.4

Dmesg
Listing 15.5: Dmesg

So this is what I got from looking at the varlogdmesg le, after my rst boot:

1 2

3 4 5 6 7

atom l o g # cat dmesg Linux v e r s i o n 2 . 6 . 20 ( root@dev . kwikbyte . com ) ( g c c v e r s i o n 3 . 4 . 5 ) #38 F r i Feb 23 16 : 37 : 48 MST 2007 CPU: ARM920T [ 41129200 ] r e v i s i o n 0 (ARMv4T) , c r=c0007177 Machine : KB920x Memory p o l i c y : ECC d i s a b l e d , Data c a c h e w r i t e b a c k On node 0 t o t a l p a g e s : 16384

62

15.2. GENTOO ON THE KB9202B

8 9 10 11 12 13 14

15

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

38 39 40 41 42 43 44 45 46 47 48 49 50 51

52 53

DMA zone : 128 p a g e s used f o r memmap DMA zone : 0 p a g e s r e s e r v e d DMA zone : 16256 pages , LIFO batch : 3 Normal zone : 0 p a g e s used f o r memmap C l o c k s : CPU 180 MHz, master 60 MHz, main 10 . 000 MHz CPU0: D VIVT w r i t e back c a c h e CPU0: I c a c h e : 16384 b y t e s , a s s o c i a t i v i t y 6 4 , 32 b yte l i n e s , 8 sets CPU0: D c a c h e : 16384 b y t e s , a s s o c i a t i v i t y 6 4 , 32 b yte l i n e s , 8 sets B u i l t 1 z o n e l i s t s . T o t a l p a g e s : 16256 K e r n e l command l i n e : c o n s o l e=/ dev / ttyS0 , 1 1 5 2 0 0 r o o t=/ dev / n f s n f s r o o t=192 . 168 . 0 . 5 0 : / d i s k l e s s / kb9202b i p=192 . 168 . 0 . 27 i n i t=/ i n i t AT91 : 96 g p i o i r q s i n 3 banks PID hash t a b l e e n t r i e s : 256 ( o r d e r : 8 , 1024 b y t e s ) C o n s o l e : c o l o u r dummy d e v i c e 80 x30 Dentry c a c h e hash t a b l e e n t r i e s : 8192 ( o r d e r : 3 , 32768 b y t e s ) Inodec a c h e hash t a b l e e n t r i e s : 4096 ( o r d e r : 2 , 16384 b y t e s ) Memory : 64MB = 64MB t o t a l Memory : 61464KB a v a i l a b l e ( 2 9 2 8K code , 358K data , 108K i n i t ) C a l i b r a t i n g d e l a y l o o p . . . 89 . 90 BogoMIPS ( l p j=4 4 9 5 3 6 ) Mountc a c h e hash t a b l e e n t r i e s : 512 CPU: T e s t i n g w r i t e b u f f e r c o h e r e n c y : ok NET: R e g i s t e r e d p r o t o c o l f a m i l y 16 SCSI subsystem i n i t i a l i z e d u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r u s b f s u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r hub u s b c o r e : r e g i s t e r e d new d e v i c e d r i v e r usb NET: R e g i s t e r e d p r o t o c o l f a m i l y 2 IP r o u t e c a c h e hash t a b l e e n t r i e s : 1024 ( o r d e r : 0 , 4096 b y t e s ) TCP e s t a b l i s h e d hash t a b l e e n t r i e s : 2048 ( o r d e r : 3 , 32768 bytes ) TCP bind hash t a b l e e n t r i e s : 1024 ( o r d e r : 2 , 20480 b y t e s ) TCP: Hash t a b l e s c o n f i g u r e d ( e s t a b l i s h e d 2048 bind 1 0 2 4 ) TCP r e n o r e g i s t e r e d NetWinder F l o a t i n g P o i n t Emulator V0 . 97 ( d o u b l e p r e c i s i o n ) audit : i n i t i a l i z i n g netlink socket ( disabled ) a u d i t ( 0 . 540 : 1 ) : i n i t i a l i z e d VFS : Disk q u o t a s dquot 6 . 5 . 1 Dquotc a c h e hash t a b l e e n t r i e s : 1024 ( o r d e r 0 , 4096 b y t e s ) JFFS2 v e r s i o n 2 . 2 . (NAND) (C) 2001 2006 Red Hat , I n c . i o s c h e d u l e r noop r e g i s t e r e d io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered ( default ) s 1 d 1 5 6 0 5 f b s 1 d 1 5 6 0 5 f b . 0 : 1KiB frame b u f f e r a t c3d20400 ( mapped at c3d20400 ) C o n s o l e : s w i t c h i n g t o mono frame b u f f e r d e v i c e 32 x10

63

15.2. GENTOO ON THE KB9202B

54 55

56

57

58

59 60 61 62 63 64

65 66 67 68 69 70

71 72 73 74 75 76 77 78 79 80 81 82

83 84 85 86 87 88 89 90

91 92

93 94

s1d15605fb s1d15605fb . 0 : Driver $Revision : 1 . 0 $ atmel u s a r t . 0 : t t y S 0 a t MMIO 0 x f e f f f 2 0 0 ( i r q = 1 ) i s a ATMEL SERIAL atmel u s a r t . 1 : t t y S 1 a t MMIO 0 x f f f c 0 0 0 0 ( i r q = 6 ) i s a ATMEL SERIAL atmel u s a r t . 2 : t t y S 2 a t MMIO 0 x f f f c 4 0 0 0 ( i r q = 7 ) i s a ATMEL SERIAL RAMDISK d r i v e r i n i t i a l i z e d : 16 RAM d i s k s o f 16384K s i z e 1024 blocksize l o o p : l o a d e d (max 8 d e v i c e s ) e t h 0 : Link now 100 F u l l D u p l e x e t h 0 : AT91 e t h e r n e t a t 0 x f e f b c 0 0 0 i n t=24 100 F u l l D u p l e x ( 0 0 : 01 : 02 : 03 : 04 : 0 5 ) e t h 0 : I n t e l LXT971A PHY NAND d e v i c e : Ma n u fa c tu rer ID : 0 x20 , Chip ID : 0 x75 (ST Micro NAND 32MiB 3 , 3V 8 b i t) Scanning d e v i c e f o r bad b l o c k s C r e a t i n g 1 MTD p a r t i t i o n s on NAND 32MiB 3 , 3V 8 b i t : 0 x00000000 0x02000000 : nand f s a t 9 1 o h c i a t 9 1 o h c i : AT91 OHCI a t 9 1 o h c i a t 9 1 o h c i : new USB bus r e g i s t e r e d , a s s i g n e d bus number 1 a t 9 1 o h c i a t 9 1 o h c i : i r q 2 3 , i o mem 0 x00300000 usb usb1 : c o n f i g u r a t i o n #1 c h o s e n from 1 c h o i c e hub 10 : 1 . 0 : USB hub found hub 10 : 1 . 0 : 1 p o r t d e t e c t e d I n i t i a l i z i n g USB Mass S t o r a g e d r i v e r . . . u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r usbs t o r a g e USB Mass S t o r a g e s u p p o r t r e g i s t e r e d . u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r l i b u s u a l u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r u s b h i d d r i v e r s / usb / i n p u t / hidc o r e . c : v2 . 6 :USB HID c o r e d r i v e r mice : PS/2 mouse d e v i c e common f o r a l l mice AT91 MMC: 4 w i r e bus mode not s u p p o r t e d by t h i s d r i v e r u s i n g 1 wire TCP c u b i c r e g i s t e r e d NET: R e g i s t e r e d p r o t o c o l f a m i l y 1 NET: R e g i s t e r e d p r o t o c o l f a m i l y 17 e t h 0 : Link now 100 F u l l D u p l e x e t h 0 : Link now 100 F u l l D u p l e x IPC o n f i g : G u e s s i n g netmask 255 . 255 . 255 . 0 IPC o n f i g : Complete : d e v i c e=eth0 , addr=192 . 168 . 0 . 2 7 , mask=255 . 255 . 255 . 0 , gw= 255 . 255 . 255 . 2 5 5 , h o s t=192 . 168 . 0 . 2 7 , domain=, n i s domain=( none ) , b o o t s e r v e r=255 . 255 . 255 . 2 5 5 , r o o t s e r v e r=192 . 168 . 0 . 5 0 , r o o t p a t h= Looking up p o r t o f RPC 100003/2 on 192 . 168 . 0 . 50 Looking up p o r t o f RPC 100005/1 on 192 . 168 . 0 . 50

64

15.3. RUNNING CUSTOM SOFTWARE

95 96 97

VFS : Mounted r o o t ( n f s f i l e s y s t e m ) . F r e e i n g i n i t memory : 108K F a i l e d t o e x e c u t e / i n i t . Attempting d e f a u l t s . . .

15.3

Running custom Software

When having the target system up and running, it is tempting to try to implement some custom made software.

15.3.1

IO driver

65

Part V

NSLU2 - Hacking the device

66

Table of Contents

16 NSLU2 Factsheet 17 Booting the NSLU2 17.1 Compiling a new kernel . . . . . . . . . . . . . . . . . . . . . . . 17.2 Loading and running the new kernel . . . . . . . . . . . . . . . . 17.2.1 2. try . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

68 69 69 69 73

Chapter 16

NSLU2 Factsheet
Here I try to give an impression of the hardware making up the NSLU2. The hardware is made up of: Intel IPX420 CPU XScale core armv5tel-softoat-linux-gnueabi target in gcc 266MHz1 Runs in big endian mode, but can run in little as well 8MB Flash 32MB RAM 2x USB 2.0 ports

1 After

a little (de)soldering

68

Chapter 17

Booting the NSLU2


17.1 17.2 Compiling a new kernel Loading and running the new kernel
Listing 17.1: First Boot
1 2 3 4 5 6

+E t h e r n e t e t h 0 : MAC a d d r e s s 00 : 13 : 10 : d7 : 16 : 2 c IP : 192 . 168 . 0 . 1/255 . 255 . 255 . 0 , Gateway : 192 . 168 . 0 . 1 D e f a u l t s e r v e r : 0 . 0 . 0 . 0 , DNS s e r v e r IP : 0 . 0 . 0 . 0 RedBoot ( tm ) b o o t s t r a p and debug environment [ROMRAM] Red Hat c e r t i f i e d r e l e a s e , v e r s i o n 1 . 92 b u i l t 15 : 16 : 0 7 , Feb 3 2004 P l a t f o r m : IXDP425 Development P l a t f o r m ( XScale ) C o p y r i g h t (C) 2 0 0 0 , 2 0 0 1 , 2 0 0 2 , Red Hat , I n c . RAM: 0 x00000000 0x02000000 , 0 x000723a0 0 x 0 1 f f 3 0 0 0 a v a i l a b l e FLASH: 0 x50000000 0 x50800000 , 64 b l o c k s o f 0 x00020000 b y t e s each . = E x e c u t i n g boot s c r i p t i n 2 . 000 s e c o n d s e n t e r C t o a b o r t = C RedBoot>i p a d d r e s s l 192 . 168 . 0 . 77 h 192 . 168 . 0 . 50 IP : 192 . 168 . 0 . 77/255 . 255 . 255 . 0 , Gateway : 192 . 168 . 0 . 1 D e f a u l t s e r v e r : 192 . 168 . 0 . 5 0 , DNS s e r v e r IP : 0 . 0 . 0 . 0 RedBoot>l o a d r v b 0 x01d00000 n s l u 2 k e r n e l 2 . 6 . 31 . 4armeb Raw f i l e l o a d e d 0 x01d00000 0x01eb30d3 , assumed e n t r y a t 0 x01d00000 RedBoot> exec 0 x01d00000 Using b a s e a d d r e s s 0 x01d00000 and l e n g t h 0 x001b30d4 Uncompressing Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..................

7 8 9 10 11 12

13 14 15 16 17 18 19

20 21 22

69

17.2. LOADING AND RUNNING THE NEW KERNEL

23

24

25

26 27 28 29 30

31

32 33 34 35 36

37

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . done , booting the k e r n e l . Linux v e r s i o n 2 . 6 . 31 . 4 ( toke@atom ) ( g c c v e r s i o n 4 . 3 . 4 ( Gentoo 4 . 3 . 4 p1 . 0 , p i e 10 . 1 . 5 ) ) #1 Tue Oct 13 12 : 54 : 14 CEST 2009 CPU: XScaleIXP42x Family [ 690541 f 1 ] r e v i s i o n 1 (ARMv5TE) , c r= 000039 f f CPU: VIVT data cache , VIVT i n s t r u c t i o n c a c h e Machine : I n t e l IXDP425 Development P l a t f o r m Warning : bad c o n f i g u r a t i o n page , t r y i n g t o continue Memory p o l i c y : ECC d i s a b l e d , Data c a c h e w r i t e b a c k B u i l t 1 z o n e l i s t s i n Zone o r d e r , m o b i l i t y g r o u p i n g o f f . T o t a l p a g e s : 4064 K e r n e l command l i n e : c o n s o l e=ttyS0 , 1 1 5 2 0 0 i p=bootp r o o t=/ dev / nfs PID hash t a b l e e n t r i e s : 64 ( o r d e r : 6 , 256 b y t e s ) Dentry c a c h e hash t a b l e e n t r i e s : 2048 ( o r d e r : 1 , 8192 b y t e s ) Inodec a c h e hash t a b l e e n t r i e s : 1024 ( o r d e r : 0 , 4096 b y t e s ) Memory : 16MB = 16MB t o t a l Memory : 12668KB a v a i l a b l e ( 3 2 0 4K code , 204K data , 120K i n i t , 0 K highmem ) SLUB: G e n s l a b s=1 1 , HWalign=3 2 , Order=0 3 , MinObjects=0 , CPUs= 1 , Nodes=1 H i e r a r c h i c a l RCU i m p l e m e n t a t i o n . NR IRQS : 64 C a l i b r a t i n g d e l a y l o o p . . . 266 . 24 BogoMIPS ( l p j=1 3 3 1 2 0 0 ) Mountc a c h e hash t a b l e e n t r i e s : 512 CPU: T e s t i n g w r i t e b u f f e r c o h e r e n c y : ok NET: R e g i s t e r e d p r o t o c o l f a m i l y 16 IXP4xx : Using 16MiB e x p a n s i o n bus window s i z e PCI : IXP4xx i s h o s t PCI : IXP4xx Using d i r e c t a c c e s s f o r memory s p a c e p c i 0000 : 00 : 01 . 0 : PME s u p p o r t e d from D0 D1 D2 D3hot # p c i 0000 : 00 : 01 . 0 : PME d i s a b l e d # p c i 0000 : 00 : 01 . 1 : PME s u p p o r t e d from D0 D1 D2 D3hot # p c i 0000 : 00 : 01 . 1 : PME d i s a b l e d # p c i 0000 : 00 : 01 . 2 : PME s u p p o r t e d from D0 D1 D2 D3hot # p c i 0000 : 00 : 01 . 2 : PME d i s a b l e d # PCI : bus0 : Fast back t o back t r a n s f e r s d i s a b l e d p c i 0000 : 00 : 01 . 0 : dmabounce : r e g i s t e r e d d e v i c e p c i 0000 : 00 : 01 . 1 : dmabounce : r e g i s t e r e d d e v i c e p c i 0000 : 00 : 01 . 2 : dmabounce : r e g i s t e r e d d e v i c e b i o : c r e a t e s l a b <bio 0> a t 0 SCSI subsystem i n i t i a l i z e d u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r u s b f s u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r hub u s b c o r e : r e g i s t e r e d new d e v i c e d r i v e r usb NET: R e g i s t e r e d p r o t o c o l f a m i l y 8 NET: R e g i s t e r e d p r o t o c o l f a m i l y 20

70

17.2. LOADING AND RUNNING THE NEW KERNEL

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

97 98 99 100 101 102 103 104 105 106 107 108

109 110 111

NET: R e g i s t e r e d p r o t o c o l f a m i l y 2 IP r o u t e c a c h e hash t a b l e e n t r i e s : 1024 ( o r d e r : 0 , 4096 b y t e s ) TCP e s t a b l i s h e d hash t a b l e e n t r i e s : 512 ( o r d e r : 0 , 4096 b y t e s ) TCP bind hash t a b l e e n t r i e s : 512 ( o r d e r : 1, 2048 b y t e s ) TCP: Hash t a b l e s c o n f i g u r e d ( e s t a b l i s h e d 512 bind 5 1 2 ) TCP r e n o r e g i s t e r e d NET: R e g i s t e r e d p r o t o c o l f a m i l y 1 IXP4xx Queue Manager i n i t i a l i z e d . NetWinder F l o a t i n g P o i n t Emulator V0 . 97 ( d o u b l e p r e c i s i o n ) JFFS2 v e r s i o n 2 . 2 . (NAND) 2001 2006 Red Hat , I n c . msgmni has been set t o 24 i o s c h e d u l e r noop r e g i s t e r e d io scheduler anticipatory registered ( default ) io scheduler deadline registered io scheduler cfq registered S e r i a l : 8250/16550 d r i v e r , 2 p o r t s , IRQ s h a r i n g d i s a b l e d s e r i a l 8 2 5 0 . 0 : t t y S 0 a t MMIO 0 xc8000000 ( i r q = 1 5 ) i s a XScale console [ ttyS0 ] enabled s e r i a l 8 2 5 0 . 0 : t t y S 1 a t MMIO 0 xc8001000 ( i r q = 1 3 ) i s a XScale brd : module l o a d e d l o o p : module l o a d e d Uniform MultiP l a t f o r m EIDE d r i v e r i d e gd d r i v e r 1 . 18 IXP4xx MII Bus : probed PHY 0 : 00 not found i x p 4 x x e t h : probe o f i x p 4 x x e t h . 16 f a i l e d with e r r o r 1 e t h 0 : MII PHY 1 on NPE C IXP4XXF l a s h . 0 : Found 1 x16 d e v i c e s a t 0 x0 i n 16 b i t bank I n t e l / Sharp Extended Query Table a t 0 x0031 I n t e l / Sharp Extended Query Table a t 0 x0031 Using b u f f e r w r i t e method c f i cmdset 0001 : E r a s e suspend on w r i t e e n a b l e d S e a r c h i n g f o r RedBoot p a r t i t i o n t a b l e i n IXP4XXF l a s h . 0 a t o f f s e t 0 x7e0000 6 RedBoot p a r t i t i o n s found on MTD d e v i c e IXP4XXF l a s h . 0 C r e a t i n g 6 MTD p a r t i t i o n s on IXP4XXF l a s h . 0 : 0 x000000000000 0x000000040000 : RedBoot 0 x000000040000 0x000000060000 : SysConf 0 x000000060000 0x000000080000 : Loader 0 x000000080000 0x000000180000 : K e r n e l 0 x000000180000 0x0000007e0000 : F l a s h d i s k 0 x0000007e0000 0x000000800000 : FIS d i r e c t o r y e h c i hcd : USB 2 . 0 Enhanced Host C o n t r o l l e r (EHCI) D r i v e r PCI : e n a b l i n g d e v i c e 0000 : 00 : 01 . 2 ( 0 1 4 0 > 0 1 4 2 ) e h c i hcd 0000 : 00 : 01 . 2 : EHCI Host C o n t r o l l e r e h c i hcd 0000 : 00 : 01 . 2 : new USB bus r e g i s t e r e d , a s s i g n e d bus number 1 e h c i hcd 0000 : 00 : 01 . 2 : E n a b l i n g l e g a c y PCI PM e h c i hcd 0000 : 00 : 01 . 2 : i r q 2 6 , i o mem 0 x48002000 e h c i hcd 0000 : 00 : 01 . 2 : USB 2 . 0 s t a r t e d , EHCI 1 . 00

71

17.2. LOADING AND RUNNING THE NEW KERNEL

112 113 114 115 116 117 118

119 120 121 122 123 124 125

126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150

151 152 153 154 155 156 157

usb usb1 : c o n f i g u r a t i o n #1 c h o s e n from 1 c h o i c e hub 10 : 1 . 0 : USB hub found hub 10 : 1 . 0 : 5 p o r t s d e t e c t e d o h c i hcd : USB 1 . 1 Open Host C o n t r o l l e r (OHCI) D r i v e r PCI : e n a b l i n g d e v i c e 0000 : 00 : 01 . 0 ( 0 1 4 0 > 0 1 4 2 ) o h c i hcd 0000 : 00 : 01 . 0 : OHCI Host C o n t r o l l e r o h c i hcd 0000 : 00 : 01 . 0 : new USB bus r e g i s t e r e d , a s s i g n e d bus number 2 o h c i hcd 0000 : 00 : 01 . 0 : i r q 2 8 , i o mem 0 x48000000 usb usb2 : c o n f i g u r a t i o n #1 c h o s e n from 1 c h o i c e hub 20 : 1 . 0 : USB hub found hub 20 : 1 . 0 : 3 p o r t s d e t e c t e d PCI : e n a b l i n g d e v i c e 0000 : 00 : 01 . 1 ( 0 1 4 0 > 0 1 4 2 ) o h c i hcd 0000 : 00 : 01 . 1 : OHCI Host C o n t r o l l e r o h c i hcd 0000 : 00 : 01 . 1 : new USB bus r e g i s t e r e d , a s s i g n e d bus number 3 o h c i hcd 0000 : 00 : 01 . 1 : i r q 2 7 , i o mem 0 x48001000 usb usb3 : c o n f i g u r a t i o n #1 c h o s e n from 1 c h o i c e hub 30 : 1 . 0 : USB hub found hub 30 : 1 . 0 : 2 p o r t s d e t e c t e d u h c i hcd : USB U n i v e r s a l Host C o n t r o l l e r I n t e r f a c e d r i v e r I n i t i a l i z i n g USB Mass S t o r a g e d r i v e r . . . u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r usbs t o r a g e USB Mass S t o r a g e s u p p o r t r e g i s t e r e d . mice : PS/2 mouse d e v i c e common f o r a l l mice i 2 c / dev e n t r i e s d r i v e r IXP4xx Watchdog Timer : h e a r t b e a t 60 s e c u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r u s b h i d u s b h i d : v2 . 6 :USB HID c o r e d r i v e r TCP c u b i c r e g i s t e r e d NET: R e g i s t e r e d p r o t o c o l f a m i l y 17 RPC: R e g i s t e r e d udp t r a n s p o r t module . RPC: R e g i s t e r e d t c p t r a n s p o r t module . XScale DSP c o p r o c e s s o r d e t e c t e d . d r i v e r s / r t c / h c t o s y s . c : u n a b l e t o open r t c d e v i c e ( r t c 0 ) IPC o n f i g : F a i l e d t o open e t h 0 IPC o n f i g : No network d e v i c e s a v a i l a b l e . RootNFS : No NFS s e r v e r a v a i l a b l e , g i v i n g up . VFS : Unable t o mount r o o t f s v i a NFS , t r y i n g f l o p p y . VFS : Cannot open r o o t d e v i c e n f s o r unknownb l o c k ( 2 , 0 ) P l e a s e append a c o r r e c t r o o t= boot o p t i o n ; h e r e a r e t h e available partitions : 1 f00 256 mtdblock0 ( d r i v e r ? ) 1 f01 128 mtdblock1 ( d r i v e r ? ) 1 f02 128 mtdblock2 ( d r i v e r ? ) 1 f03 1024 mtdblock3 ( d r i v e r ? ) 1 f04 6528 mtdblock4 ( d r i v e r ? ) 1 f05 128 mtdblock5 ( d r i v e r ? ) K e r n e l p a n i c not s y n c i n g : VFS : Unable t o mount r o o t f s on unknownb l o c k ( 2 , 0 )

72

17.2. LOADING AND RUNNING THE NEW KERNEL

17.2.1

2. try
Listing 17.2: 2. Try

1 2 3 4 5 6

+E t h e r n e t e t h 0 : MAC a d d r e s s 00 : 13 : 10 : d7 : 16 : 2 c IP : 192 . 168 . 0 . 1/255 . 255 . 255 . 0 , Gateway : 192 . 168 . 0 . 1 D e f a u l t s e r v e r : 0 . 0 . 0 . 0 , DNS s e r v e r IP : 0 . 0 . 0 . 0 RedBoot ( tm ) b o o t s t r a p and debug environment [ROMRAM] Red Hat c e r t i f i e d r e l e a s e , v e r s i o n 1 . 92 b u i l t 15 : 16 : 0 7 , Feb 3 2004 P l a t f o r m : IXDP425 Development P l a t f o r m ( XScale ) C o p y r i g h t (C) 2 0 0 0 , 2 0 0 1 , 2 0 0 2 , Red Hat , I n c . RAM: 0 x00000000 0x02000000 , 0 x000723a0 0 x 0 1 f f 3 0 0 0 a v a i l a b l e FLASH: 0 x50000000 0 x50800000 , 64 b l o c k s o f 0 x00020000 b y t e s each . = E x e c u t i n g boot s c r i p t i n 2 . 000 s e c o n d s e n t e r C t o a b o r t = C RedBoot>i p a d d r e s s l 192 . 168 . 0 . 77 h 192 . 168 . 0 . 50 IP : 192 . 168 . 0 . 77/255 . 255 . 255 . 0 , Gateway : 192 . 168 . 0 . 1 RedBoot>l o a d r v b 0 x01d00000 n s l u 2 k e r n e l 2 . 6 . 31 . 4armeb Raw f i l e l o a d e d 0 x01d00000 0x01eb30d3 , assumed e n t r y a t 0 x01d00000 RedBoot> exec 0 x01d00000 c c o n s o l e=ttyS0 , 1 1 5 2 0 0 i p=192 . 168 . 0 . 77 r o o t=/ dev / n f s n f s r o o t=192 . 168 . 0 . 50 : / d i s k l e s s / n s l u 2 Using b a s e a d d r e s s 0 x01d00000 and l e n g t h 0 x001b30d4 Uncompressing Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .......................................................... . . . . . . . . . . done , b o o t i n g t h e k e r n e l . Linux v e r s i o n 2 . 6 . 31 . 4 ( toke@atom ) ( g c c v e r s i o n 4 . 3 . 4 ( Gentoo 4 . 3 . 4 p1 . 0 , p i e 10 . 1 . 5 ) ) #1 Tue Oct 13 12 : 54 : 14 CEST 2009 CPU: XScaleIXP42x Family [ 690541 f 1 ] r e v i s i o n 1 (ARMv5TE) , c r= 000039 f f CPU: VIVT data cache , VIVT i n s t r u c t i o n c a c h e Machine : I n t e l IXDP425 Development P l a t f o r m Warning : bad c o n f i g u r a t i o n page , t r y i n g t o continue Memory p o l i c y : ECC d i s a b l e d , Data c a c h e w r i t e b a c k B u i l t 1 z o n e l i s t s i n Zone o r d e r , m o b i l i t y g r o u p i n g o f f . T o t a l p a g e s : 4064 K e r n e l command l i n e : c o n s o l e=ttyS0 , 1 1 5 2 0 0 i p=bootp r o o t=/ dev / nfs PID hash t a b l e e n t r i e s : 64 ( o r d e r : 6 , 256 b y t e s ) Dentry c a c h e hash t a b l e e n t r i e s : 2048 ( o r d e r : 1 , 8192 b y t e s ) Inodec a c h e hash t a b l e e n t r i e s : 1024 ( o r d e r : 0 , 4096 b y t e s ) Memory : 16MB = 16MB t o t a l

7 8 9 10 11 12

13 14 15 16 17 18

19

20 21

22

23

24 25 26 27 28

29

30 31 32 33

73

17.2. LOADING AND RUNNING THE NEW KERNEL

34

35

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81

Memory : 12668KB a v a i l a b l e ( 3 2 0 4K code , 204K data , 120K i n i t , 0 K highmem ) SLUB: G e n s l a b s=1 1 , HWalign=3 2 , Order=0 3 , MinObjects=0 , CPUs= 1 , Nodes=1 H i e r a r c h i c a l RCU i m p l e m e n t a t i o n . NR IRQS : 64 C a l i b r a t i n g d e l a y l o o p . . . 266 . 24 BogoMIPS ( l p j=1 3 3 1 2 0 0 ) Mountc a c h e hash t a b l e e n t r i e s : 512 CPU: T e s t i n g w r i t e b u f f e r c o h e r e n c y : ok NET: R e g i s t e r e d p r o t o c o l f a m i l y 16 IXP4xx : Using 16MiB e x p a n s i o n bus window s i z e PCI : IXP4xx i s h o s t PCI : IXP4xx Using d i r e c t a c c e s s f o r memory s p a c e p c i 0000 : 00 : 01 . 0 : PME s u p p o r t e d from D0 D1 D2 D3hot # p c i 0000 : 00 : 01 . 0 : PME d i s a b l e d # p c i 0000 : 00 : 01 . 1 : PME s u p p o r t e d from D0 D1 D2 D3hot # p c i 0000 : 00 : 01 . 1 : PME d i s a b l e d # p c i 0000 : 00 : 01 . 2 : PME s u p p o r t e d from D0 D1 D2 D3hot # p c i 0000 : 00 : 01 . 2 : PME d i s a b l e d # PCI : bus0 : Fast back t o back t r a n s f e r s d i s a b l e d p c i 0000 : 00 : 01 . 0 : dmabounce : r e g i s t e r e d d e v i c e p c i 0000 : 00 : 01 . 1 : dmabounce : r e g i s t e r e d d e v i c e p c i 0000 : 00 : 01 . 2 : dmabounce : r e g i s t e r e d d e v i c e b i o : c r e a t e s l a b <bio 0> a t 0 SCSI subsystem i n i t i a l i z e d u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r u s b f s u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r hub u s b c o r e : r e g i s t e r e d new d e v i c e d r i v e r usb NET: R e g i s t e r e d p r o t o c o l f a m i l y 8 NET: R e g i s t e r e d p r o t o c o l f a m i l y 20 NET: R e g i s t e r e d p r o t o c o l f a m i l y 2 IP r o u t e c a c h e hash t a b l e e n t r i e s : 1024 ( o r d e r : 0 , 4096 b y t e s ) TCP e s t a b l i s h e d hash t a b l e e n t r i e s : 512 ( o r d e r : 0 , 4096 b y t e s ) TCP bind hash t a b l e e n t r i e s : 512 ( o r d e r : 1, 2048 b y t e s ) TCP: Hash t a b l e s c o n f i g u r e d ( e s t a b l i s h e d 512 bind 5 1 2 ) TCP r e n o r e g i s t e r e d NET: R e g i s t e r e d p r o t o c o l f a m i l y 1 IXP4xx Queue Manager i n i t i a l i z e d . NetWinder F l o a t i n g P o i n t Emulator V0 . 97 ( d o u b l e p r e c i s i o n ) JFFS2 v e r s i o n 2 . 2 . (NAND) 2001 2006 Red Hat , I n c . msgmni has been set t o 24 i o s c h e d u l e r noop r e g i s t e r e d io scheduler anticipatory registered ( default ) io scheduler deadline registered io scheduler cfq registered S e r i a l : 8250/16550 d r i v e r , 2 p o r t s , IRQ s h a r i n g d i s a b l e d s e r i a l 8 2 5 0 . 0 : t t y S 0 a t MMIO 0 xc8000000 ( i r q = 1 5 ) i s a XScale console [ ttyS0 ] enabled s e r i a l 8 2 5 0 . 0 : t t y S 1 a t MMIO 0 xc8001000 ( i r q = 1 3 ) i s a XScale brd : module l o a d e d

74

17.2. LOADING AND RUNNING THE NEW KERNEL

82 83 84 85 86 87 88 89 90 91 92 93 94

95 96 97 98 99 100 101 102 103 104 105 106

107 108 109 110 111 112 113 114 115 116

117 118 119 120 121 122 123

124 125 126 127

l o o p : module l o a d e d Uniform MultiP l a t f o r m EIDE d r i v e r i d e gd d r i v e r 1 . 18 IXP4xx MII Bus : probed PHY 0 : 00 not found i x p 4 x x e t h : probe o f i x p 4 x x e t h . 16 f a i l e d with e r r o r 1 e t h 0 : MII PHY 1 on NPE C IXP4XXF l a s h . 0 : Found 1 x16 d e v i c e s a t 0 x0 i n 16 b i t bank I n t e l / Sharp Extended Query Table a t 0 x0031 I n t e l / Sharp Extended Query Table a t 0 x0031 Using b u f f e r w r i t e method c f i cmdset 0001 : E r a s e suspend on w r i t e e n a b l e d S e a r c h i n g f o r RedBoot p a r t i t i o n t a b l e i n IXP4XXF l a s h . 0 a t o f f s e t 0 x7e0000 6 RedBoot p a r t i t i o n s found on MTD d e v i c e IXP4XXF l a s h . 0 C r e a t i n g 6 MTD p a r t i t i o n s on IXP4XXF l a s h . 0 : 0 x000000000000 0x000000040000 : RedBoot 0 x000000040000 0x000000060000 : SysConf 0 x000000060000 0x000000080000 : Loader 0 x000000080000 0x000000180000 : K e r n e l 0 x000000180000 0x0000007e0000 : F l a s h d i s k 0 x0000007e0000 0x000000800000 : FIS d i r e c t o r y e h c i hcd : USB 2 . 0 Enhanced Host C o n t r o l l e r (EHCI) D r i v e r PCI : e n a b l i n g d e v i c e 0000 : 00 : 01 . 2 ( 0 1 4 0 > 0 1 4 2 ) e h c i hcd 0000 : 00 : 01 . 2 : EHCI Host C o n t r o l l e r e h c i hcd 0000 : 00 : 01 . 2 : new USB bus r e g i s t e r e d , a s s i g n e d bus number 1 e h c i hcd 0000 : 00 : 01 . 2 : E n a b l i n g l e g a c y PCI PM e h c i hcd 0000 : 00 : 01 . 2 : i r q 2 6 , i o mem 0 x48002000 e h c i hcd 0000 : 00 : 01 . 2 : USB 2 . 0 s t a r t e d , EHCI 1 . 00 usb usb1 : c o n f i g u r a t i o n #1 c h o s e n from 1 c h o i c e hub 10 : 1 . 0 : USB hub found hub 10 : 1 . 0 : 5 p o r t s d e t e c t e d o h c i hcd : USB 1 . 1 Open Host C o n t r o l l e r (OHCI) D r i v e r PCI : e n a b l i n g d e v i c e 0000 : 00 : 01 . 0 ( 0 1 4 0 > 0 1 4 2 ) o h c i hcd 0000 : 00 : 01 . 0 : OHCI Host C o n t r o l l e r o h c i hcd 0000 : 00 : 01 . 0 : new USB bus r e g i s t e r e d , a s s i g n e d bus number 2 o h c i hcd 0000 : 00 : 01 . 0 : i r q 2 8 , i o mem 0 x48000000 usb usb2 : c o n f i g u r a t i o n #1 c h o s e n from 1 c h o i c e hub 20 : 1 . 0 : USB hub found hub 20 : 1 . 0 : 3 p o r t s d e t e c t e d PCI : e n a b l i n g d e v i c e 0000 : 00 : 01 . 1 ( 0 1 4 0 > 0 1 4 2 ) o h c i hcd 0000 : 00 : 01 . 1 : OHCI Host C o n t r o l l e r o h c i hcd 0000 : 00 : 01 . 1 : new USB bus r e g i s t e r e d , a s s i g n e d bus number 3 o h c i hcd 0000 : 00 : 01 . 1 : i r q 2 7 , i o mem 0 x48001000 usb usb3 : c o n f i g u r a t i o n #1 c h o s e n from 1 c h o i c e hub 30 : 1 . 0 : USB hub found hub 30 : 1 . 0 : 2 p o r t s d e t e c t e d

75

17.2. LOADING AND RUNNING THE NEW KERNEL

128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148

149 150 151 152 153 154 155

u h c i hcd : USB U n i v e r s a l Host C o n t r o l l e r I n t e r f a c e d r i v e r I n i t i a l i z i n g USB Mass S t o r a g e d r i v e r . . . u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r usbs t o r a g e USB Mass S t o r a g e s u p p o r t r e g i s t e r e d . mice : PS/2 mouse d e v i c e common f o r a l l mice i 2 c / dev e n t r i e s d r i v e r IXP4xx Watchdog Timer : h e a r t b e a t 60 s e c u s b c o r e : r e g i s t e r e d new i n t e r f a c e d r i v e r u s b h i d u s b h i d : v2 . 6 :USB HID c o r e d r i v e r TCP c u b i c r e g i s t e r e d NET: R e g i s t e r e d p r o t o c o l f a m i l y 17 RPC: R e g i s t e r e d udp t r a n s p o r t module . RPC: R e g i s t e r e d t c p t r a n s p o r t module . XScale DSP c o p r o c e s s o r d e t e c t e d . d r i v e r s / r t c / h c t o s y s . c : u n a b l e t o open r t c d e v i c e ( r t c 0 ) IPC o n f i g : F a i l e d t o open e t h 0 IPC o n f i g : No network d e v i c e s a v a i l a b l e . RootNFS : No NFS s e r v e r a v a i l a b l e , g i v i n g up . VFS : Unable t o mount r o o t f s v i a NFS , t r y i n g f l o p p y . VFS : Cannot open r o o t d e v i c e n f s o r unknownb l o c k ( 2 , 0 ) P l e a s e append a c o r r e c t r o o t= boot o p t i o n ; h e r e a r e t h e available partitions : 1 f00 256 mtdblock0 ( d r i v e r ? ) 1 f01 128 mtdblock1 ( d r i v e r ? ) 1 f02 128 mtdblock2 ( d r i v e r ? ) 1 f03 1024 mtdblock3 ( d r i v e r ? ) 1 f04 6528 mtdblock4 ( d r i v e r ? ) 1 f05 128 mtdblock5 ( d r i v e r ? ) K e r n e l p a n i c not s y n c i n g : VFS : Unable t o mount r o o t f s on unknownb l o c k ( 2 , 0 )

76

Part VI

N2100 - Hacking the device

77

Table of Contents

18 N2100 Factsheet 19 Bootloader 19.1 Connecting to the bootloader . . . . . . . . . . . . . . . . . . . . 19.1.1 Using Telnet . . . . . . . . . . . . . . . . . . . . . . . . . 19.1.2 Using serial port . . . . . . . . . . . . . . . . . . . . . . . 19.1.3 Using Telnet . . . . . . . . . . . . . . . . . . . . . . . . . 19.2 Flash Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19.3 Boot your own kernel . . . . . . . . . . . . . . . . . . . . . . . . 19.4 Installing Gentoo on the N2100 . . . . . . . . . . . . . . . . . . . 20 Toolchain 20.1 Toolchain for the N2100 . . . . . . . . . . . . . . . . . . . . . . . 20.1.1 The Thecus GNU Toolchain . . . . . . . . . . . . . . . . . 21 Gentoo on the N2100 22 MTD 22.1 Finding info on the system . . . . . . . . . . . . . . . . . . . . .

79 80 80 80 80 82 82 82 82 84 84 84 86 92 92

Chapter 18

N2100 Factsheet
Here I try to give an impression of the hardware making up the N2100. The hardware is made up of: Intel 80219 CPU [FW80219M600] XScale core ARMv5TE 600MHz endian? supporting up to 1GB of RAM (untested) 32KB data/instruction caches 64-bit PCI 2.2 Interface 8 GPIO Pinouts

Mini-PCI slot Seriel port [TA550C] 16MB Flash [Intel TE28F128] 128MB to 1GB RAM, DDR400 2x Gigabit Ethernet Controllers [RTL8110SB] Silicon Image S-ATA controller [Sil3512ECTU128] Via USB 2.0 [VT6212L] I2C bus for housekeeping and IO Fintek Hardware Monitoring chip [F75375S] Philips LED dimmer [PCA9532] Ricoh Real Time Clock, RTC [RS5C372] Fan [ADDA AD0412MB-G76]

79

Chapter 19

Bootloader
The bootloader used on the N2100 is Redboot.

19.1
19.1.1 19.1.2

Connecting to the bootloader


Using Telnet Using serial port

I manged to get the seriel port up and running. The standard console ouput Listing 19.1: The output from Redboot. Modifyed for readability
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

RedBoot> r e s e t . . . Resetting . P u l l down GPIO [ 4 ] . . . +RST =No T r a n s f e r t o f a c t o r y t e s t Mode : No R e s e t d e f a u l t s e t : Normal Thecus : Found PCI d e v i c e Vendor ID=0 x000010EC Vendor 0 x1 0 ec Device 0 x8169 A l l o c a t e cyg p c i i o b a s e=0 x90000100 A l l o c a t e cyg p c i memory b a s e=0 x40000100 Thecus : Found PCI d e v i c e Vendor ID=0 x000010EC Vendor 0 x1 0 ec Device 0 x8169 A l l o c a t e cyg p c i i o b a s e=0 x90000200 A l l o c a t e cyg p c i memory b a s e=0 x40000200 Thecus : Found PCI d e v i c e Vendor ID=0 x00001095 Vendor 0 x1095 Device 0 x3512 A l l o c a t e cyg p c i i o b a s e=0 x90000208

80

19.1. CONNECTING TO THE BOOTLOADER

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

A l l o c a t e cyg p c i i o b a s e=0 x9000020c A l l o c a t e cyg p c i i o b a s e=0 x90000218 A l l o c a t e cyg p c i i o b a s e=0 x9000021c A l l o c a t e cyg p c i i o b a s e=0 x90000230 A l l o c a t e cyg p c i memory b a s e=0 x40000400 Thecus : Found PCI d e v i c e Vendor ID=0 x00001106 Thecus : Found PCI d e v i c e Vendor ID=0 x00001106 Thecus : Found PCI d e v i c e Vendor ID=0 x00001106 Vendor 0 x1106 Device 0 x3104 A l l o c a t e cyg p c i memory b a s e=0 x40000500 PCI : d e v i c e a l r e a d y c o n f i g u r e d r t l e t h 0 : RTL8169s /8110 s G i g a b i t E t h e r n e t d r i v e r 2 . 2 a t 0 xb0000000 , 00 : 14 : f d : 10 : 60 : 30 r t l e t h 0 : Auton e g o t i a t i o n Enabled . r t l e t h 0 : 100Mbps F u l l d u p l e x o p e r a t i o n . PCI : d e v i c e a l r e a d y c o n f i g u r e d e t h 1 found : bus [ 0 ] dev [ 2 ] b a s e [ b0000100 ] r t l e t h 1 : RTL8169s /8110 s G i g a b i t E t h e r n e t d r i v e r 2 . 2 a t 0 xb0000100 , 00 : 14 : f d : 10 : 60 : 31 E t h e r n e t r t l e t h 0 : MAC a d d r e s s 00 : 14 : f d : 10 : 60 : 30 IP : 192 . 168 . 1 . 100/255 . 255 . 255 . 0 , Gateway : 0 . 0 . 0 . 0 D e f a u l t s e r v e r : 0 . 0 . 0 . 0 , DNS s e r v e r IP : 0 . 0 . 0 . 0 RedBoot ( tm ) b o o t s t r a p and debug environment [ROM] Red Hat c e r t i f i e d r e l e a s e , v e r s i o n 1 . 93 b u i l t 17 : 25 : 0 0 , Feb 6 2007 P l a t f o r m : THECUS N2100 ( IOP80219 ) C o p y r i g h t (C) 2 0 0 0 , 2 0 0 1 , 2 0 0 2 , Red Hat , I n c . RAM: 0 x00000000 0x08000000 , 0 x0004b890 0x 0 7 f d 1 0 0 0 a v a i l a b l e , t o t a l : 128 MB FLASH: 0 x f 0 0 0 0 0 0 0 0 xf1 0 0 0 0 0 0 , 128 b l o c k s of 0 x00020000 b y t e s each . = E x e c u t i n g boot s c r i p t in 3 . 000 s e c o n d s e n t e r C t o a b o r t = RedBoot> t h e c u s s e t i p RedBoot> f i s l o a d ramdisk RedBoot> f i s l o a d k e r n e l RedBoot> e x e c c c o n s o l e=ttyS0 , 1 1 5 2 0 0 r o o t=/ dev /ram0 i n i t r d=0 xa0800000 , 4 2M mem =128 M@0xa0000000 B u i l d ATAG ATAG MEM: O v e r w r i t e ram end with r e a l r e g i o n top=0 x08000000 , memsize=128 M ATAG MEM =134217728 @0xa0000000 , MACH TYPE =1101 Using b a s e a d d r e s s 0 x00200000 and l e n g t h 0 x00160000 Uncompressing Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . done , booting the k e r n e l

81

19.2. FLASH LAYOUT

19.1.3

Using Telnet
Listing 19.2: Telnet to Redboot

a r p i n g f 192 . 168 . 1 . 100 & t e l n e t 192 . 168 . 1 . 100 &

9000

19.2

Flash Layout
FLASH addr 0xF0000000 0xF0FC0000 0xF0FE0000 0xF0040000 0xF0D40000 0xF0EA0000 Mem addr 0xF0000000 0xF0FC0000 0xF0FE0000 0x00800000 0x00200000 0xF0EA0000 Length 0x00040000 0x00001000 0x00020000 0x00D00000 0x00160000 0x00120000 Entry point 0x00000000 0x00000000 0x00000000 0x00800000 0x00200000 0x00200000

The ash layout is: Name Redboot RedBoot cong FIS directory ramdisk kernel user

19.3

Boot your own kernel


Listing 19.3: Boot you own kernel

1 2 3 4 5

RedBoot>i p l 192 . 168 . 0 . 136 h 192 . 168 . 0 . 50 IP : 192 . 168 . 0 . 136/255 . 255 . 255 . 0 , Gateway : 0 . 0 . 0 . 0 D e f a u l t s e r v e r : 192 . 168 . 0 . 5 0 , DNS s e r v e r IP : 0 . 0 . 0 . 0 RedBoot>l o a d r n2100k e r n e l b 0 x00200000 Raw f i l e l o a d e d 0 x00200000 0x0043354b , assumed e n t r y a t 0 x00200000 RedBoot> e x e c c c o n s o l e=ttyS0 , 1 1 5 2 0 0 i p=dhcp r a i d= n o a u t o d e t e c t r o o t=/ dev / n f s rw n f s r o o t=192 . 168 . 0 . 50 : / d i s k l e s s / n2100 mem =512 M@0xa0000000

19.4

Installing Gentoo on the N2100

Remember to set kernel Features - Use the ARM EABI to compile the kernel otherwise you will not be able to boot the eabi image from the Gentoo mirror. Listing 19.4: Boot you own kernel
1 2 3 4 5

RedBoot>i p l 192 . 168 . 0 . 136 h 192 . 168 . 0 . 50 IP : 192 . 168 . 0 . 136/255 . 255 . 255 . 0 , Gateway : 0 . 0 . 0 . 0 D e f a u l t s e r v e r : 192 . 168 . 0 . 5 0 , DNS s e r v e r IP : 0 . 0 . 0 . 0 RedBoot>l o a d r n2100k e r n e l b 0 x00200000 Raw f i l e l o a d e d 0 x00200000 0x0043354b , assumed e n t r y a t 0 x00200000

82

19.4. INSTALLING GENTOO ON THE N2100

RedBoot> e x e c c c o n s o l e=ttyS0 , 1 1 5 2 0 0 r o o t=/ dev / sda2 rw mem = 512 M@0xa0000000

Listing 19.5: Boot from Harddrive


1 2 3 4 5

RedBoot>i p l 192 . 168 . 0 . 136 h 192 . 168 . 0 . 50 IP : 192 . 168 . 0 . 136/255 . 255 . 255 . 0 , Gateway : 0 . 0 . 0 . 0 D e f a u l t s e r v e r : 192 . 168 . 0 . 5 0 , DNS s e r v e r IP : 0 . 0 . 0 . 0 RedBoot>l o a d r n2100k e r n e l b 0 x00200000 Raw f i l e l o a d e d 0 x00200000 0x0043354b , assumed e n t r y a t 0 x00200000 RedBoot> e x e c c c o n s o l e=ttyS0 , 1 1 5 2 0 0 r a i d=n o a u t o d e t e c t r o o t= / dev / sda2 mem =128 M@0xa0000000

83

Chapter 20

Toolchain
20.1 Toolchain for the N2100

Crossdevwolla link binutils-2.20.1 linux-headers-2.6.33 gcc-4.4.3 glibc-2.11-r1 Target name arm-unknown-linux-gnu arm-softoat-linux-gnu arm-softoat-linux-gnueabi armv5l-unknown-linux-gnueabi armv5t-unknown-linux-gnueabi armv5te-unknown-linux-gnu armv5te-unknown-linux-gnueabi armv5tel-softoat-linux-gnueabi Builds yes no yes yes yes yes yes yes

20.1.1

The Thecus GNU Toolchain

I downloaded the newest GPL code from the Thecus homepage1 . Looking at the conguration of the Linux kernel and Busybox I can see that they used a toolchain called: armv5l-linux-. Furthermore they have left som of their compiled programs along with the source, so I can use le:
1 http://www.thecus.com/Downloads/GPL/n2100

2.01.10 GPL.tar.bz2

84

20.1. TOOLCHAIN FOR THE N2100

Listing 20.1: Using le to gureout the endianess


1 2 3 4

$ f i l e m o d i f i e d /hdparm6 . 1/ hdparm hdparm : ELF 32 b i t LSB e x e c u t a b l e , ARM, v e r s i o n 1 , \ dynamically linked ( uses shared l i b s ) , \ f o r GNU/ Linux 2 . 0 . 0 , s t r i p p e d

85

Chapter 21

Gentoo on the N2100


Here I will descripe howto install Gentoo on the N2100 device After installing Debian, I booted the device from network and booted gentoo kernel and using the stage3-armv5tel-20100420 from NFS. After reset this is what I got: Listing 21.1: The output from 1. boot. Modifyed for readability
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

+RST =No T r a n s f e r t o f a c t o r y t e s t Mode : No R e s e t d e f a u l t s e t : Normal Thecus : Found PCI d e v i c e Vendor ID=0 x000010EC Vendor 0 x1 0 ec Device 0 x8169 A l l o c a t e cyg p c i i o b a s e=0 x90000100 A l l o c a t e cyg p c i memory b a s e=0 x40000100 Thecus : Found PCI d e v i c e Vendor ID=0 x000010EC Vendor 0 x1 0 ec Device 0 x8169 A l l o c a t e cyg p c i i o b a s e=0 x90000200 A l l o c a t e cyg p c i memory b a s e=0 x40000200 Thecus : Found PCI d e v i c e Vendor ID=0 x00001095 Vendor 0 x1095 Device 0 x3512 A l l o c a t e cyg p c i i o b a s e=0 x90000208 A l l o c a t e cyg p c i i o b a s e=0 x9000020c A l l o c a t e cyg p c i i o b a s e=0 x90000218 A l l o c a t e cyg p c i i o b a s e=0 x9000021c A l l o c a t e cyg p c i i o b a s e=0 x90000230 A l l o c a t e cyg p c i memory b a s e=0 x40000400 Thecus : Found PCI d e v i c e Vendor ID=0 x00001106 Thecus : Found PCI d e v i c e Vendor ID=0 x00001106 Thecus : Found PCI d e v i c e Vendor ID=0 x00001106 Vendor 0 x1106 Device 0 x3104

86

28 29 30

31 32 33 34 35

36 37 38 39 40 41

A l l o c a t e cyg p c i memory b a s e=0 x40000500 PCI : d e v i c e a l r e a d y c o n f i g u r e d r t l e t h 0 : RTL8169s /8110 s G i g a b i t E t h e r n e t d r i v e r 2 . 2 a t 0 xb0000000 , 00 : 14 : f d : 10 : 60 : 30 r t l e t h 0 : Auton e g o t i a t i o n Enabled . r t l e t h 0 : 100Mbps F u l l d u p l e x o p e r a t i o n . PCI : d e v i c e a l r e a d y c o n f i g u r e d e t h 1 found : bus [ 0 ] dev [ 2 ] b a s e [ b0000100 ] r t l e t h 1 : RTL8169s /8110 s G i g a b i t E t h e r n e t d r i v e r 2 . 2 a t 0 xb0000100 , 00 : 14 : f d : 10 : 60 : 31 E t h e r n e t r t l e t h 0 : MAC a d d r e s s 00 : 14 : f d : 10 : 60 : 30 IP : 192 . 168 . 0 . 144/255 . 255 . 255 . 0 , Gateway : 0 . 0 . 0 . 0 D e f a u l t s e r v e r : 192 . 168 . 0 . 5 0 , DNS s e r v e r IP : 192 . 168 . 0 . 50 RedBoot ( tm ) b o o t s t r a p and debug environment [ROM] Red Hat c e r t i f i e d r e l e a s e , v e r s i o n 1 . 93 b u i l t 17 : 25 : 0 0 , Feb 6 2007 P l a t f o r m : THECUS N2100 ( IOP80219 ) C o p y r i g h t (C) 2 0 0 0 , 2 0 0 1 , 2 0 0 2 , Red Hat , I n c . RAM: 0 x00000000 0x20000000 , 0 x0004b890 0x 1 f f d 1 0 0 0 a v a i l a b l e , t o t a l : 512 MB FLASH: 0 x f 0 0 0 0 0 0 0 0 xf1 0 0 0 0 0 0 , 128 b l o c k s of 0 x00020000 b y t e s each . = E x e c u t i n g boot s c r i p t in 3 . 000 s e c o n d s e n t e r C t o a b o r t = RedBoot> t h e c u s s e t i p RedBoot> f i s l o a d ramdisk RedBoot> f i s l o a d k e r n e l RedBoot> e x e c c c o n s o l e=ttyS0 , 1 1 5 2 0 0 r o o t=/ dev /ram0 i n i t r d=0 xa0800000 , 4 2M mem =512 M@0xa0000000 B u i l d ATAG ATAG MEM: O v e r w r i t e ram end with r e a l r e g i o n top=0 x20000000 , memsize=512 M ATAG MEM =536870912 @0xa0000000 , MACH TYPE =1101 Using b a s e a d d r e s s 0 x00200000 and l e n g t h 0 x00160000 Uncompressing Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . done , booting the k e r n e l . [ 0 . 000000 ] I n i t i a l i z i n g cgroup s u b s y s cpu [ 0 . 000000 ] Linux v e r s i o n 2 . 6 . 262 i o p 3 2 x ( Debian 2 . 6 . 2621 l e n n y 4 ) ( dannf@debian . o r g ) ( g c c v e r s i o n 4 . 1 . 3 20080704 ( p r e r e l e a s e ) ( Debian 4 . 1 . 225) ) #1 Tue Mar 9 22 : 40 : 30 UTC 2010 [ 0 . 000000 ] CPU: XScale 80219 [ 69052 e30 ] r e v i s i o n 0 ( ARMv5TE) , c r=0000397 f [ 0 . 000000 ] Machine : Thecus N2100 [ 0 . 000000 ] Memory p o l i c y : ECC d i s a b l e d , Data c a c h e writeback [ 0 . 000000 ] CPU0: D VIVT u n d e f i n e d 5 c a c h e

42 43 44 45 46

47

48 49 50 51 52

53 54

55 56 57

58 59

60

61 62

63

87

64

65

66

67

68

69 70

71

72 73

74 75 76 77 78 79 80 81 82 83 84

85 86

87

88

89

90 91 92 93 94

95

96 97 98

0 . 000000 ] CPU0: I c a c h e : 32768 b y t e s , a s s o c i a t i v i t y 3 2 , 32 b yte l i n e s , 32 s e t s [ 0 . 000000 ] CPU0: D c a c h e : 32768 b y t e s , a s s o c i a t i v i t y 3 2 , 32 b yte l i n e s , 32 s e t s [ 0 . 000000 ] B u i l t 1 z o n e l i s t s in Zone o r d e r , m o b i l i t y g r o u p i n g on . T o t a l p a g e s : 130048 [ 0 . 000000 ] K e r n e l command l i n e : c o n s o l e=ttyS0 , 1 1 5 2 0 0 r o o t= / dev /ram0 i n i t r d=0 xa0800000 , 4 2M mem =512 M@0xa0000000 [ 0 . 000000 ] PID hash t a b l e e n t r i e s : 2048 ( o r d e r : 1 1 , 8192 bytes ) [ 42949372 . 960000 ] C o n s o l e : c o l o u r dummy d e v i c e 80 x30 [ 42949372 . 960000 ] Dentry c a c h e hash t a b l e e n t r i e s : 65536 ( o r d e r : 6 , 262144 b y t e s ) [ 42949372 . 960000 ] Inodec a c h e hash t a b l e e n t r i e s : 32768 ( o r d e r : 5 , 131072 b y t e s ) [ 42949373 . 010000 ] Memory : 512MB = 512MB t o t a l [ 42949373 . 010000 ] Memory : 473600KB a v a i l a b l e ( 2 6 4 4K code , 285K data , 112K i n i t ) [ 42949373 . 240000 ] S e c u r i t y Framework i n i t i a l i z e d [ 42949373 . 240000 ] SELinux : D i s a b l e d a t boot . [ 42949373 . 240000 ] C a p a b i l i t y LSM i n i t i a l i z e d [ 42949373 . 240000 ] Mountc a c h e hash t a b l e e n t r i e s : 512 [ 42949373 . 240000 ] I n i t i a l i z i n g cgroup s u b s y s ns [ 42949373 . 240000 ] I n i t i a l i z i n g cgroup s u b s y s c p u a c c t [ 42949373 . 240000 ] I n i t i a l i z i n g cgroup s u b s y s d e v i c e s [ 42949373 . 240000 ] CPU: T e s t i n g w r i t e b u f f e r c o h e r e n c y : ok [ 42949373 . 240000 ] n e t namespace : 652 b y t e s [ 42949373 . 240000 ] NET: R e g i s t e r e d p r o t o c o l f a m i l y 16 [ 42949373 . 250000 ] PCI : bus0 : Fast back t o back t r a n s f e r s disabled [ 42949373 . 290000 ] NET: R e g i s t e r e d p r o t o c o l f a m i l y 2 [ 42949373 . 380000 ] IP r o u t e c a c h e hash t a b l e e n t r i e s : 16384 ( o r d e r : 4 , 65536 b y t e s ) [ 42949373 . 380000 ] TCP e s t a b l i s h e d hash t a b l e e n t r i e s : 65536 ( o r d e r : 7 , 524288 b y t e s ) [ 42949373 . 380000 ] TCP bind hash t a b l e e n t r i e s : 65536 ( o r d e r : 6 , 262144 b y t e s ) [ 42949373 . 380000 ] TCP: Hash t a b l e s c o n f i g u r e d ( e s t a b l i s h e d 65536 bind 6 5 5 3 6 ) [ 42949373 . 380000 ] TCP r e n o r e g i s t e r e d [ 42949373 . 410000 ] NET: R e g i s t e r e d p r o t o c o l f a m i l y 1 [ 42949373 . 410000 ] c h e c k i n g i f image i s i n i t r a m f s . . . i t i s [ 42949381 . 420000 ] F r e e i n g i n i t r d memory : 43008K [ 42949381 . 420000 ] NetWinder F l o a t i n g P o i n t Emulator V0 . 97 ( double p r e c i s i o n ) [ 42949381 . 420000 ] a u d i t : i n i t i a l i z i n g n e t l i n k s o c k e t ( d i s a b l e d ) [ 42949381 . 420000 ] typ e=2000 a u d i t ( 8 . 460 : 1 ) : i n i t i a l i z e d [ 42949381 . 430000 ] VFS : Disk q u o t a s dquot 6 . 5 . 1 [ 42949381 . 430000 ] Dquotc a c h e hash t a b l e e n t r i e s : 1024 ( o r d e r

88

99

100 101 102

103 104 105 106 107

108

109 110 111

112

113 114 115

116

117

118

119 120 121 122 123 124

125 126 127 128

129

130 131 132 133 134

0 , 4096 b y t e s ) [ 42949381 . 430000 ] JFFS2 v e r s i o n 2 . 2 . (NAND) (SUMMARY) 2001 2006 Red Hat , I n c . [ 42949381 . 430000 ] msgmni has been s e t t o 1009 [ 42949381 . 430000 ] a syn c tx : a p i i n i t i a l i z e d ( a syn c ) [ 42949381 . 430000 ] Block l a y e r SCSI g e n e r i c ( bsg ) d r i v e r v e r s i o n 0 . 4 l o a d e d ( major 2 5 3 ) [ 42949381 . 430000 ] i o s c h e d u l e r noop r e g i s t e r e d [ 42949381 . 430000 ] i o s c h e d u l e r a n t i c i p a t o r y r e g i s t e r e d [ 42949381 . 430000 ] i o s c h e d u l e r d e a d l i n e r e g i s t e r e d [ 42949381 . 430000 ] i o s c h e d u l e r c f q r e g i s t e r e d ( d e f a u l t ) [ 42949381 . 470000 ] S e r i a l : 8250/16550 d r i v e r $ R e v i s i o n : 1 . 90 $ 2 p o r t s , IRQ s h a r i n g d i s a b l e d [ 42949381 . 470000 ] s e r i a l 8 2 5 0 . 0 : t t y S 0 a t MMIO 0 x f e 8 0 0 0 0 0 ( i r q = 0 ) i s a 16550A [ 42949381 . 470000 ] c o n s o l e [ t t y S 0 ] e n a b l e d [ 42949381 . 800000 ] brd : module l o a d e d [ 42949381 . 800000 ] physmap p l a t f o r m f l a s h d e v i c e : 01000000 a t f0000000 [ 42949381 . 810000 ] physmapf l a s h . 0 : Found 1 x16 d e v i c e s a t 0 x0 in 16 b i t bank [ 42949381 . 810000 ] I n t e l / Sharp Extended Query Table a t 0 x0031 [ 42949381 . 830000 ] Using b u f f e r w r i t e method [ 42949381 . 830000 ] c f i cmdset 0001 : E r a s e suspend on w r i t e enabled [ 42949381 . 840000 ] S e a r c h i n g f o r RedBoot p a r t i t i o n t a b l e in physmapf l a s h . 0 a t o f f s e t 0 x f e 0 0 0 0 [ 42949382 . 160000 ] 6 RedBoot p a r t i t i o n s found on MTD d e v i c e physmapf l a s h . 0 [ 42949382 . 160000 ] C r e a t i n g 6 MTD p a r t i t i o n s on physmapf l a s h . 0 : [ 42949382 . 180000 ] 0 x00000000 0x00040000 : RedBoot [ 42949382 . 180000 ] 0 x00040000 0x00d40000 : ramdisk [ 42949382 . 180000 ] 0 x00d40000 0x00ea0000 : k e r n e l [ 42949382 . 190000 ] 0 x00ea0000 0x 0 0 f c 0 0 0 0 : u s e r [ 42949382 . 200000 ] 0 x 0 0 f c 0 0 0 0 0x 0 0 f c 1 0 0 0 : RedBoot c o n f i g [ 42949382 . 200000 ] mtd : p a r t i t i o n RedBoot c o n f i g doesn t end on an e r a s e b l o c k f o r c e reado n l y [ 42949382 . 220000 ] 0 x 0 0 f e 0 0 0 0 0x01000000 : FIS d i r e c t o r y [ 42949382 . 230000 ] mice : PS/2 mouse d e v i c e common f o r a l l mice [ 42949382 . 230000 ] i 2 c / dev e n t r i e s d r i v e r [ 42949382 . 240000 ] r t c r s 5 c 3 7 2 00032 : r s 5 c 3 7 2 b found , 24 hr , driver version 0 . 5 [ 42949382 . 260000 ] r t c r s 5 c 3 7 2 00032 : r t c c o r e : r e g i s t e r e d r t c r s 5 c 3 7 2 a s r t c 0 [ 42949382 . 270000 ] pca9532 00060 : s e t t i n g p l a t f o r m data [ 42949382 . 270000 ] R e g i s t e r e d l e d d e v i c e : n2100 : r e d : s a t a f a i l 0 [ 42949382 . 280000 ] R e g i s t e r e d l e d d e v i c e : n2100 : r e d : s a t a f a i l 1 [ 42949382 . 290000 ] R e g i s t e r e d l e d d e v i c e : n2100 : b l u e : usb [ 42949382 . 290000 ] R e g i s t e r e d l e d d e v i c e : n2100 : r e d : usb

89

135 136 137 138

139

140 141 142 143 144 145

146 147 148

149

150 151 152

153

154

155

156

157 158

159

160 161

162

163 164

165

166 167

[ 42949382 . 300000 ] R e g i s t e r e d l e d d e v i c e : n2100 : o r a n g e : system [ 42949382 . 310000 ] R e g i s t e r e d l e d d e v i c e : n2100 : r e d : system [ 42949382 . 310000 ] i n p u t : N2100 b e e p e r a s / c l a s s / i n p u t / i n p u t 0 [ 42949382 . 380000 ] iop adma iop adma . 0 : I n t e l (R) IOP : ( cpy intr ) [ 42949382 . 400000 ] iop adma iop adma . 1 : I n t e l (R) IOP : ( cpy intr ) [ 42949382 . 400000 ] NET: R e g i s t e r e d p r o t o c o l f a m i l y 26 [ 42949382 . 410000 ] TCP c u b i c r e g i s t e r e d [ 42949382 . 410000 ] NET: R e g i s t e r e d p r o t o c o l f a m i l y 17 [ 42949382 . 420000 ] XScale DSP c o p r o c e s s o r d e t e c t e d . [ 42949382 . 420000 ] r e g i s t e r e d t a s k s t a t s v e r s i o n 1 [ 42949382 . 430000 ] r t c r s 5 c 3 7 2 00032 : s e t t i n g system c l o c k t o 20110510 18 : 40 : 41 UTC ( 1 3 0 5 0 5 2 8 4 1 ) [ 42949382 . 450000 ] F r e e i n g i n i t memory : 112K Loading , p l e a s e w a i t . . . Begin : Loading e s s e n t i a l d r i v e r s . . . [ 42949383 . 010000 ] SCSI subsystem i n i t i a l i z e d [ 42949383 . 180000 ] s a t a s i l 0000 : 00 : 03 . 0 : Applying R ERR on DMA a c t i v a t e FIS e r r a t a f i x [ 42949383 . 180000 ] s c s i 0 : s a t a s i l [ 42949383 . 190000 ] s c s i 1 : s a t a s i l [ 42949383 . 190000 ] a t a 1 : SATA max UDMA/100 mmio m512@0x800a0000 t f 0 x800a0080 i r q 29 [ 42949383 . 210000 ] a t a 2 : SATA max UDMA/100 mmio m512@0x800a0000 t f 0 x800a00c0 i r q 29 [ 42949383 . 560000 ] a t a 1 : SATA l i n k up 1 . 5 Gbps ( S S t a t u s 113 SControl 310) [ 42949383 . 610000 ] a t a 1 . 00 : ATA : ST3250620AS , 3 .AAE, max UDMA 7 /133 [ 42949383 . 630000 ] a t a 1 . 00 : 488397168 s e c t o r s , m u l t i 0 : LBA48 NCQ ( depth 0 / 3 2 ) [ 42949383 . 700000 ] a t a 1 . 00 : c o n f i g u r e d f o r UDMA/100 [ 42949384 . 050000 ] a t a 2 : SATA l i n k down ( S S t a t u s 0 S C o n t r o l 310) [ 42949384 . 050000 ] s c s i 0 : 0 : 0 : 0 : D i r e c t A c c e s s ATA ST3250620AS 3 .AA PQ: 0 ANSI : 5 done . Begin : Running / s c r i p t s / i n i t premount . . . [ 42949385 . 680000 ] D r i v e r sd n e e d s u p d a t i n g p l e a s e u s e bus typ e methods [ 42949385 . 740000 ] sd 0 : 0 : 0 : 0 : [ sda ] 488397168 512 b yte hardware s e c t o r s ( 2 5 0 0 5 9 MB) [ 42949385 . 760000 ] sd 0 : 0 : 0 : 0 : [ sda ] Write P r o t e c t i s o f f [ 42949385 . 770000 ] sd 0 : 0 : 0 : 0 : [ sda ] Write c a c h e : en a b led , r e a d c a c h e : en a b led , doesn t s u p p o r t DPO o r FUA [ 42949385 . 790000 ] sd 0 : 0 : 0 : 0 : [ sda ] 488397168 512 b yte hardware s e c t o r s ( 2 5 0 0 5 9 MB) [ 42949385 . 800000 ] sd 0 : 0 : 0 : 0 : [ sda ] Write P r o t e c t i s o f f [ 42949385 . 800000 ] sd 0 : 0 : 0 : 0 : [ sda ] Write c a c h e : en a b led , r e a d c a c h e : en a b led , doesn t s u p p o r t DPO o r FUA

90

168 169 170 171

172 173 174 175 176

177 178

179

180 181 182 183 184 185 186 187 188

[ 42949385 . 820000 ] sda : sda1 sda2 [ 42949385 . 860000 ] sd 0 : 0 : 0 : 0 : [ sda ] Attached SCSI d i s k done . Begin : Mounting r o o t f i l e system . . . Begin : Running / s c r i p t s / l o c a l top . . . done . Begin : Running / s c r i p t s / l o c a l premount . . . done . mount : mounting / dev / sda2 on / r o o t f a i l e d : No such d e v i c e Begin : Running / s c r i p t s / l o c a l bottom . . . done . done . Begin : Running / s c r i p t s / i n i t bottom . . . mount : mounting / dev on / r o o t / dev f a i l e d : No such f i l e o r d i r e c t o r y done . mount : mounting / s y s on / r o o t / s y s f a i l e d : No such f i l e o r directory mount : mounting / p r o c on / r o o t / p r o c f a i l e d : No such f i l e o r directory Target f i l e s y s t e m doesn t have / s b i n / i n i t . No i n i t found . Try p a s s i n g i n i t= b o o t a r g .

BusyBox v1 . 10 . 2 ( Debian 1 : 1 . 10 . 22) b u i l t in s h e l l ( ash ) Enter help f o r a l i s t of b u i l t in commands . / b i n / sh : can t a c c e s s t t y ; j o b c o n t r o l t u r n e d o f f ( initramfs )

91

Chapter 22

MTD
This chapter

22.1
n2100 dev : mtd0 : mtd1 : mtd2 : mtd3 : mtd4 : mtd5 :

Finding info on the system


Listing 22.1: Looking at the MTD system using Linux
# c a t / p r o c /mtd size e r a s e s i z e name 00040000 00020000 RedBoot 00 d00000 00020000 ramdisk 00160000 00020000 k e r n e l 00120000 00020000 u s e r 00001000 00020000 RedBoot c o n f i g 00020000 00020000 FIS d i r e c t o r y

1 2 3 4 5 6 7 8

92

Part VII

Embedded Display

93

Table of Contents

23 About Embedded Displays 24 Types of Displays 25 Architecture

95 96 97

Chapter 23

About Embedded Displays


Adding a display to your project can be diecoult, but often it is worth the trouble. Having decided to add a display, one has a lot of choices; color? resolution? Touch? and so on.

95

Chapter 24

Types of Displays
Type LTV250QV LQ043T3DX02 DS-G160128TB WG160160 Resolution 320 x 240 480 x 272 160 x 128 160 x 160 Color Yes Yes No No Color depth [bits] 24 24 1 1 cost [dkr] ? 219,262,? Notes Used in PSP1 T6963C controller, HUGE LC7981 controller

Table 24.1: Comparison of dierent displays When using monocrome graphic displays, the controller is, usualy, a T6963C type. Monocrome text displays are usualy hd44780. If you want a color display, the controller (if present) can be many dierent types.

96

Chapter 25

Architecture
Having a common architecture for all graphic displays, allows a common API. This will make porting the code much less timeconsuming. The graphic display libery is organiced as illustrated in Figure 25.1 Graphic Object Layer: Graphic Primitive Layer Display driver Display low level driver GPIO

97

Clear Init Draw_byte goto

GDISP

write data write inst read status read data

LC7891

Set pin Clear Pin delay

GPIO

Figure 25.1: Todo

98

Part VIII

Vortex86

99

Table of Contents

26 Vortex86 Factsheet

101

26.1 About the Vortex86 . . . . . . . . . . . . . . . . . . . . . . . . . 101 26.1.1 Output from lspci . . . . . . . . . . . . . . . . . . . . . . 101 26.1.2 cpuinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 26.1.3 X86info . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

Chapter 26

Vortex86 Factsheet
Here I try to give an impression of the hardware making up the N2100. The hardware is made up of: Vortex86 System-on-Chip CPU 166MHz i486 architecture 128MB RAM Realtime Clock IDE interface RS232 port RS232/485 port Parallel port FDD interface USB port Realtek 8100B Watchdog Timer CRT and Flat Panel Display interface GPIO

26.1
26.1.1

About the Vortex86


Output from lspci

101

26.1. ABOUT THE VORTEX86

Listing 26.1: Lspci on Vortex86


1 2

4 5

6 7

8 9

10 11 12 13

14 15

localhost # lspci 00 : 00 . 0 Host b r i d g e : S i l i c o n I n t e g r a t e d Systems [ S i S ] 550 Host ( rev 01) 00 : 00 . 1 IDE i n t e r f a c e : S i l i c o n I n t e g r a t e d Systems [ S i S ] 5513 [ IDE ] ( r e v d0 ) 00 : 01 . 0 ISA b r i d g e : S i l i c o n I n t e g r a t e d Systems [ S i S ] SiS85C503 /5513 (LPC Bridge ) 00 : 01 . 2 USB C o n t r o l l e r : S i l i c o n I n t e g r a t e d Systems [ S i S ] USB 1 .1 C o n t r o l l e r ( rev 07) 00 : 02 . 0 PCI b r i d g e : S i l i c o n I n t e g r a t e d Systems [ S i S ] V i r t u a l PCItoPCI b r i d g e (AGP) 00 : 0d . 0 E t h e r n e t c o n t r o l l e r : R e a l t e k S emic o n d u c to r Co . , Ltd . RTL8139/8139C/8139C+ ( r e v 1 0 ) 01 : 00 . 0 VGA c o m p a t i b l e c o n t r o l l e r : S i l i c o n I n t e g r a t e d Systems [ S i S ] 550 PCI/AGP VGA D i s p l a y Adapter localhost #

26.1.2

cpuinfo
Listing 26.2: Cpuifo on Vortex86

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

l o c a l h o s t # cat processor : vendor i d : cpu f a m i l y : model : model name : stepping : cpu MHz : f d i v bug : h l t bug : f 0 0 f bug : coma bug : fpu : fpu e x c e p t i o n : cpuid l e v e l : wp : flags : bogomips : clflush size : power management :

/ proc / cpuinfo 0 SiS SiS SiS 5 0 05/00 5 166 . 616 no no no no yes yes 1 yes fpu t s c cx8 mmx up 333 . 23 32

102

26.1. ABOUT THE VORTEX86

26.1.3

X86info

X86info is a small program for printing out info on Intel CPUs. Emerge it by doing: Listing 26.3: Emerging on the Vortex86
1

l o c a l h o s t p r o c # emerge x 8 6 i n f o

103

Part IX

Project SolarController

104

Table of Contents

27 About the Solarcontroller 28 Controlling Algorithm

106 107

28.1 Temperature Sensors . . . . . . . . . . . . . . . . . . . . . . . . . 107 29 Selecting a platform for the Solarcontroller 109

29.1 Board Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . 109 30 LPC2468 31 Initial Code 110 111

31.1 Startup Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 31.2 Linker Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 31.3 Setting up the Clock . . . . . . . . . . . . . . . . . . . . . . . . . 112 31.3.1 Using Interrupts . . . . . . . . . . . . . . . . . . . . . . . 113 32 Using FreeRTOS on the LPC2468 114

32.1 Needed Files and their Modication . . . . . . . . . . . . . . . . 114 33 TCP/IP Stack for Embedded 116

Chapter 27

About the Solarcontroller


The Solarcontroller is developed to control my solar heating system. I try to stick with standart components for the hardware and will try to use free, open source code. All the code will be availeble on my webpage for downloading.

106

Chapter 28

Controlling Algorithm
28.1 Temperature Sensors

I have used the PT1000 sensor for measuring the temperatures in the system. The line plottet in Figure 28.1 is the dataset directly from the data sheet. It looks wery much like a stright line, but to be sure I created a new plot, Figure 28.2. Figure 28.2 is the diviation fra a stright line, passing fough 1000 at 0 and 1385 at 1000 . As one ca see, the diviation is at 1.5 at approx 50 . To see if the diviation will aect the functionality of the controller, observe the following calculus. 1.5 100 = 0.125786% 1192.5 So, in terms of temperature this will result in: If we use a 10 bit ADC, that, alone, will have an error of: 1 100 = 0.097656% 210 If we add the two error-sources, we get a worst case senario of (28.1)

(28.2)

107

28.1. TEMPERATURE SENSORS

Resistance vs. Temperature 1400 1350 1300 1250 Ohm 1200 1150 1100 1050 1000 0 20 40 60 Temperature 80 100 Ohm

Figure 28.1: The data from the datasheet

Error 1.6 1.4 1.2 1 Error 0.8 0.6 0.4 0.2 0 -0.2 0 20 40 60 Temperature 80 100 120 Error

Figure 28.2: The diviation. The values are calculated

108

Chapter 29

Selecting a platform for the Solarcontroller


Durring this chapter I will try to illustate how I found a platform for my solarcontroller.

29.1

Board Comparison
MCU LPC2468 AT91SAM9260 LPC3131 LPC2478 LPC3250 Cortex A8 Dual Cortex A9 S3C2440 OMAP3530 ARMADA 166 Clock 60MHz 180MHz 180MHz 72MHz 266MHz 1GHz 1GHz 532MHz 200MHz 600MHz 454MHz 800MHz Flash 512kB 8kB 512kB RAM 96kB 32kB 192kB 96kB 256kB DRAM 64MB 64MB 32MB 64MB 64MB 512MB 1GB 64MB 64MB 256MB 64MB 128MB ADC 8 0 4 8 ? ? ? ? ? Price 1267,50dkr 1050,00dkr 525,00dkr 1480,00dkr 1950,00dkr 900,- dkr 1200,- dkr 630.- dkr 780.- dkr 845,- dkr 663,- dkr 1020.- dkr

Board LPC2468 Developers Kit SAM9-L9260 LPC-H3131 LPC-2478STK LPC3250 Developers Kit BeagleBoard-xM PandaBoard Mini2440n350 basic2410 Devkit 8000 chumby one chumby 8

64MB 256MB

Table 29.1: The les needed from FreeRTOS The Chumbys both include LCD screen, WiFi,

109

Chapter 30

LPC2468

110

Chapter 31

Initial Code
This chapter will descripe the initial code, used for bringing the MCU to life. The code needed is the startup code, crt0.s, a linker script and some initial setup of hardware.

31.1

Startup Code

The statup code is the rst piece of code that the processor executes. I this case it has the one purpose of setting up all stacks and the jumping to the main() function. Listing 31.1: Startup Code for the LPC2468, crt0.S
1 2 3 4 5 6 7

. s e c t i o n .RESET, ax . arm @ Exception Vectors @ Mapped t o Address 0 . @ A b s o l u t e a d d r e s s i n g mode must be used . @ Dummy H a n d l e r s a r e implemented a s i n f i n i t e l o o p s which can be m o d i f i e d . Vectors : LDR LDR LDR LDR LDR NOP PC, PC, PC, PC, PC, R e s e t Addr Undef Addr SWI Addr PAbt Addr DAbt Addr @ Reserved

8 9 10 11 12 13 14

15 16

@@

17 18

Vector LDR PC, IRQ Addr LDR PC, [PC, # 0x0120 ] VicVectAddr LDR PC, FIQ Addr

@ V e c t o r from

111

31.2. LINKER SCRIPT

19 20 21 22 23 24

R e s e t Addr : Undef Addr : SWI Addr : PAbt Addr : DAbt Addr :

25 26 27 28 29 30 31 32 33 34

IRQ Addr : FIQ Addr :

. word R e s e t Handler . word Undef Handler . word SWI Handler . word PAbt Handler . word DAbt Handler . word 0 xB9206E28 Address . word IRQ Handler . word FIQ Handler

@ Reserved

Undef Handler : B Undef Handler SWI Handler : B SWI Handler PAbt Handler : B PAbt Handler DAbt Handler : B DAbt Handler @@ handled t h r u a s s e m b l e r wrapper ( s e e below ) @@ IRQ Handler : B IRQ Handler FIQ Handler : B FIQ Handler

31.2

Linker Script

In order to get the linker to place all code exatly were we want it to, we have to write a linker script. The compleate linker script is in Appendix D on page 154.

31.3

Setting up the Clock

Here is a, short, resume of how to calculate the clock setup of the chip. The setup is done right at the start of the program, and is done only once. 32kHz < Fin < 50M Hz 275M Hz < FCCO < 550M Hz 6 < M < 512 2M Fin N (31.1a) (31.1b) (31.1c)

FCCO = Using a crystal of 12MHz, we get: FCCO =

(31.2)

M 24.000.000 2M 12.000.000 = N N M= FCCO N 2Fin

(31.3)

(31.4)

112

31.3. SETTING UP THE CLOCK

I assume that N can be set to 1, so I get (using (31.4)): M= 480.000.000 = 20 24.000.000 (31.5)

This means that M is to be set to 20-1=19=0x13 and N=1-1=0.

31.3.1

Using Interrupts

113

Chapter 32

Using FreeRTOS on the LPC2468


32.1 Needed Files and their Modication

I started up by grabbing the latest FreeRTOS[1] and followed the directions on the webpage. But it turned out thet FreeRTOS did not support the interrupt handling of the LPC2468 chip, so I had to add it. Furthermore I wanted support for both GCC and Keil Realview compilers. This will make it possible for one to compare the compilers and use the features of both enviroments. 1. croutine.c 2. croutine.h File croutine.c croutine.h FreeRTOS.h FreeRTOSCong.h heap 2.c list.c list.h mpu wrapper.h portASM.s port.c Status unmodifyed copy unmodifyed copy unmodifyed copy modifyed copy unmodifyed copy unmodifyed copy unmodifyed copy modifyed copy modifyed copy Notes

Contain setup

Important changes !!

Table 32.1: The les needed from FreeRTOS Port.c sets up the timer 0 for generating the Tick. But unaltered it sets up the Whatcdog timer.. 114

32.1. NEEDED FILES AND THEIR MODIFICATION

PortASM.s VICVECTADDR EQU 0xFFFFFF00 ; Changed this, the new value ts the LPC24xx

115

Chapter 33

TCP/IP Stack for Embedded


kvwmkw

116

Part X

Using Linux as ...

117

Table of Contents

34 Subversion,SVN, Server 34.1 Server Setup

121

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

34.2 Repository Layout . . . . . . . . . . . . . . . . . . . . . . . . . . 121 34.3 My actual Projects . . . . . . . . . . . . . . . . . . . . . . . . . . 122 35 DHCP Server 123

35.1 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 36 NFS Server 37 TFTP server 38 FTP server 125 126 127

38.0.1 Optinal: rsync Server . . . . . . . . . . . . . . . . . . . . 127 39 Daytime Server 40 Linux Mail Server 128 129

40.1 Recieving Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 40.2 Sending Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 40.3 Retriving Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 41 Diskless / Thin Client 41.1 Booting Stategy 130

. . . . . . . . . . . . . . . . . . . . . . . . . . . 131

41.1.1 Bootloader . . . . . . . . . . . . . . . . . . . . . . . . . . 131 41.1.2 Optional 2. stage bootloader . . . . . . . . . . . . . . . . 131

TABLE OF CONTENTS

41.2 Aditional Information . . . . . . . . . . . . . . . . . . . . . . . . 131 41.3 Build Root Filesystem . . . . . . . . . . . . . . . . . . . . . . . . 131

119

TABLE OF CONTENTS

In this part I hope to describe how to use your Linux as a home server and for hosting both your homepage, email, and projects.

120

Chapter 34

Subversion,SVN, Server
Subversion, SVN, is a version control system. It can be used i various ways and here I will describe one way of using it.

34.1

Server Setup

My SVN server is based on Apache, use the manual for your Linex distribution to gure out how to install and set it up.

34.2

Repository Layout

I have a repository for each project. Furthermore I have a repos for shared code. The repos for shared code contains a set of dierent subprojects, but all the code must be able to compile for- and execure on dierent targets. The repository layout is illustated in the lists below: Project 1 Documentation Bootloader Test Project 2 Documentation Bootloader Test Libs (shared code) Stack

121

34.3. MY ACTUAL PROJECTS

Libc The projects (Project 1 and Project 2) now may contain The Stack. So I use SVNs buildin feature, called externals: So when checkingout Project 1, the Stack is automaticly added: Project 1 Documentation Bootloader Stack Test

34.3

My actual Projects

Currently I have the following projects in my reposetory. Please note that some of the projects are dead1 . The more interesting projects will bedescribed further. 1. anemometer Hopeing to get the project up and running fast. It depends on the OS (simplos). 2. armnet 3. avrnet 4. c51net 5. hugin 6. kb9202b, see Part IV on page 43 7. lib 8. mini-ups This is my homebrew OS project. Hopeing to get the project up and running fast, since other projects depend on it. 9. someware 10. stack 11. woody
1 As

in no longer worked on/ maintained

122

Chapter 35

DHCP Server
The Dynamic Host Control Protocol, DHCP is used to congure the hosts on your network IP, telling the target what image to load etc. Listings 35.1 illustates how a DHCP server can be congured.

35.1

Setup
Listing 35.1: A sample of my dhcpd.conf

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

ddnsupdates t y l e i n t e r i m ; d e f a u l t l e a s e time 7200 ; maxl e a s e time 7200 ; a l l o w bootp ; allow booting ; # o p t i o n d e f i n i t i o n s common t o a l l s u p p o r t e d n e t w o r k s . . . o p t i o n domainname dupontkoustrup . dk ; o p t i o n domainnames e r v e r s 192 . 168 . 0 . 10 ; o p t i o n r o u t e r s 192 . 168 . 0 . 1 ; # d e f a u l t i s t o ue t h e switch o p t i o n ntps e r v e r s 192 . 168 . 0 . 10 ; o p t i o n smtps e r v e r 192 . 168 . 0 . 10 ; o p t i o n n e t b i o s names e r v e r s 192 . 168 . 0 . 10 ; s e r v e r name v10000 ; s u b n e t 192 . 168 . 0 . 0 netmask 255 . 255 . 255 . 0 { r a n g e 192 . 168 . 0 . 120 192 . 168 . 0 . 250 ; o p t i o n b r o a d c a s t a d d r e s s 192 . 168 . 0 . 255 ; # kb9202b d e v e l board h o s t kb9202b

123

35.1. SETUP

24 25 26 27 28 29 30 31 32

{ hardware e t h e r n e t 00 : 01 : 02 : 03 : 04 : 05 ; f i x e d a d d r e s s 192 . 168 . 0 . 11 ; o p t i o n host name kb9202b ; #o p t i o n r o o t path n f s : / d i s k l e s s gentoo ; f i l e n a m e kb9202bl i n u x ; nexts e r v e r 192 . 168 . 0 . 10 ; } }

124

Chapter 36

NFS Server
The Network File System, NFS, server is relativly easy to setup. You only need to install the nft-utils software1 and edit the /etc/exports le. Listing 36.1: A sample of my /etc/exports le
1 2

/ d i s k l e s s / kb9202b 192 . 168 . 0 . 0/255 . 255 . 255 . 0 ( async , no r o o t squash , no s u b t r e e check , rw )

1 Consult

the manual for your distrubution for info on how to do this.

125

Chapter 37

TFTP server
Listing 37.1: TFTPd conf.
1 2

TFTPD ROOT / d i s k l e s s = TFTPD OPTS =daemon u s e r nobody group nobody

126

Chapter 38

FTP server
38.0.1 Optinal: rsync Server
When havin servial Gentoo boxes on your local network, you can save a lot of bandwitth, useng a local rsync mirror. Setting up the mirror is easy and no extra software has to be installed1 Lisings 38.1 illustartes my setup of the rsync server. Listing 38.1: A sample of my /etc/rsyncd.conf le
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

# This l i n e i s r e q u i r e d by t h e / e t c / i n i t . d/ r s y n c d s c r i p t p i d f i l e = / var / run / r s y n c d . p i d use chroot = yes read only = yes #This w i l l g i v e you a s e p a r a t e l o g f i l e l o g f i l e = / var / l o g / r s y n c . l o g #This w i l l l o g e v e r y f i l e t r a n s f e r r e d #up t o 85 ,000+ p e r u s e r , p e r sync t r a n s f e r logging = yes l o g f o r m a t = %t %a % %f %b m syslog f a c i l i t y = local3 t i m e o u t = 300 # Simple example f o r e n a b l i n g your own l o c a l r s y n c s e r v e r [ gentoop o r t a g e ] path = / u s r / p o r t a g e comment = Gentoo P o r t a g e t r e e exclude = / d i s t f i l e s / packages

1 Assuming

your server runs Gentoo....

127

Chapter 39

Daytime Server
Sometimes it can be nice with your own daytime server. One need only remember it is not a current time is returning from the server .. A daytime server runs (as regeel) on port 13 either TCP and / or UDP. If you need something to put the clock in his PC, you should probably consider ntp instead. For daytime server up and running on his Linux machine to be added a le to / etc / xinit.d / This can be called for daytime or daytime-udp if it settled through UDP. Without going into details in the test with syntax and options, will be presented the contents of a daytime le here: Listing 39.1: A sample of my /etc/xinit.d/daytime-udp le
1 2 3 4 5 6 7 8 9 10 11 12

# Daytime s e r v e r p o r t 13 s e r v i c e daytime { typ e = INTERNAL i d = daytimestream s o c k e t typ e = stream p r o t o c o l = udp user = root w a i t = no d i s a b l e = yes }

service daytime regard to the contents of / etc / services which says that daytime is on port 13th In order to test / enjoy his ne new daytime server, telnet is used: telnet Your Server IP 13

128

Chapter 40

Linux Mail Server


Setting up your own mailserver can be a tedious task; since the invention of spam, dierent ways of ghting it. This can lead to problems and errors with your mailserver, that you did not ekspect.

40.1

Recieving Mail

Reciving mail on the server, from the internet. This is typically done when other servers try to deliver mail to your server. I use postx to handle this task.

40.2

Sending Mail

Sending mail from the server to the internet.

40.3

Retriving Mail

Server

Postfix Port 25

Internet

Figure 40.1: Todo 129

Chapter 41

Diskless / Thin Client


I have some Vortex boards VIII laying around, so using them as Thin Clients1 seems like a great idear. Using old hardware as a thin Client may seem as a waste of time. But it will allow you to: Reuse an old PC and save a buck. Reuse an old PC for you kid(s), and easely admiestre it. Easy access to the status of your server, from the living room. It seems that servial ways of using a thin client excists. The dier mainly on where the services are executed, meaning how muct is actualy installed and executed at the client. At the two extreems we have: all and none. Boot Linux and execute all on the server. The only thin on the client is the Linux kernel and X server. Boot Linux and mount rootfs via NFS. The only thin on the client is the Linux kernel, X server and NFS. Boot Linux and execute all on the client. Rootfs is mountet via NFS (is this even a thin client at all?). Knowing that we will lack a harddrive on the clinet, one question comes to mind; Where to put the root lesystem? It seems that servial possible solutions excists within the Linux/GNU system: Put the root lesystem on a NFS server. Integrate the root lesystem into the kernel, using ramdisk
1 Thin does not refer to the physical apperence of the device; it refers to the lach of a harddrive.

130

41.1. BOOTING STATEGY

Integrate the root lesystem into the kernel, using ramfs Using a ramdisk, that is loaded at boottime, by the bootloader.

41.1

Booting Stategy

Bootloader. Optional 2. stage bootloader Linux kernel X server

41.1.1 41.1.2

Bootloader Optional 2. stage bootloader

The client is powered up. The client sends out a DHCP discovery The (DHCP) server sends out a DHCP oer The client sends out a DHCP request The server sends out a DHCP acknowledgement The client fetches PXE boot from server and starts it. PXE is used to select the Linux kernel you want, it is then fetched via TFTP The kernel boots and mounts the lesystem via NFS.

41.2

Aditional Information

Gentoo Forum [12], Gentoo Howtoo [11],

41.3

Build Root Filesystem

131

Part XI

Randome Notes

132

Table of Contents

42 IDE vs. the B.R.A.I.N. 42.2 So why not use an IDE

134 . . . . . . . . . . . . . . . . . . . . . . . 134

42.1 Dening IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 42.2.1 Working in Teams . . . . . . . . . . . . . . . . . . . . . . 134 42.2.2 Software has Bugs . . . . . . . . . . . . . . . . . . . . . . 134 42.2.3 Using an IDE acts the Code . . . . . . . . . . . . . . . . 134 42.2.4 Using IDE is too easy . . . . . . . . . . . . . . . . . . . . 135 42.2.5 Using IDE Makes one Patch the Errors . . . . . . . . . . 135 42.2.6 Using IDE does not teach you to write code . . . . . . . . 135 42.2.7 IDEs are dierent . . . . . . . . . . . . . . . . . . . . . . 135 42.3 Benets of using the GNU toolchain . . . . . . . . . . . . . . . . 135 43 Are you Lazy or Dumb? 136

43.1 Real Life Example . . . . . . . . . . . . . . . . . . . . . . . . . . 136 43.2 Applying to Hobby Projects . . . . . . . . . . . . . . . . . . . . . 136 44 Thinking outside the Window 138

Chapter 42

IDE vs. the B.R.A.I.N.


This chapter is dedicated to some thoughts about using an IDE or not. I tend to say using an IDE or brain.

42.1

Dening IDE

An IDE, Integrated Development Environment, is a set of tools all glued togther using some sort of frontend. One can compile and load your code using only one click of the mouse. In my denition a graphical debugger is included in the IDE.

42.2

So why not use an IDE

The description i Section 42.1, may seem like the holy grail. But it has servial problems.

42.2.1

Working in Teams

Most IDEs (all the ons I have tryed) store the project in a project le. Each time one rearenges the windows, it is stored in the project le and all others are forced to have the same setup as you.

42.2.2

Software has Bugs

Yes it is trye: All software has bugs. Applying more software (the IDE) intruduces more bugs. Servial IDEs and debuggers know nothing about realtime.

42.2.3

Using an IDE acts the Code

Durring many projects I have come to realize that using and IDE acts the cone, and hense the quality of the code. When having the debugger or simulator at

134

42.3. BENEFITS OF USING THE GNU TOOLCHAIN

ones hand, people (me included..) tend to go with the let us just try to and suddelnly something works. But when working under timepresure (as software developers do), things like documentation, design and test tend to be left to when we get the time. This approch also tend to leave out checking the input to functions. Having no design, means that nobody knows how to test the software. I have, often, seen software to be reused, that had not even been tested.

42.2.4

Using IDE is too easy

What? Too easy? Yes, I think IDEs lead to trail and error. Leaving out desing and reading the datasheet for the device. Furthermore debugging via printf forces one to think. Having to gure out where to place the printf makes one understand the code.

42.2.5

Using IDE Makes one Patch the Errors

It is my experence that people using IDEs tend to patch the code everywhere to x errors, instead oxing the actual bug, they develop a work around.

42.2.6

Using IDE does not teach you to write code

When writing code, compiling it and then running it in the dubugger only takes 0.5 sec. alot of the nal code will be written to make something else work.

42.2.7

IDEs are dierent

I have tryed servial dieret IDEs and they all seem to be dierent, which makes it harder to switsh IDEs. Some will compile the code at a press on F5, and some will requere you to press F7... The editors are include in the IDE, so they are, also, dierent.

42.3

Benets of using the GNU toolchain

The main benet of using the GNU toolchain is that one can compile software for target and PC, using the same compiler. This makes it possible to test code wary easy and in a well known enviroment. One counter augument is that the code can not be used on a PC. Yes, that may be true..... For about 0.5% of the nal code. All low level drivers has to be replaced by stubs or emulated, but then one can test the functionality on a standart PC. Having the posibility to test the code as a standart program on PC, leads to automatic test1
1 Which

is not a bad thing.

135

Chapter 43

Are you Lazy or Dumb?


Behind the minor provokative title: Are you Lazy or Dumb? hides a small experiment of thought: One has to chose, between being lazy or dumb. With respect to software developmen it makes sense to split persons in thise two groups. But, in contrast to what one would expect, the person beeing dumb is not unintelligen1 and the lazy is not unproductive. Durring my time at the unirvercity I unked a course. Thinking back it was dumb, since I had to redo the course it was ewerything but lazy... The lazy would have studyet and passet in rst try.

43.1

Real Life Example

I do not work for a company the manufacutres or sells tables, chairs or any other kind of funiture, so the fact that we have a constant maintained database of our funiture is actualy quite impressive. But the lack of knowledge about what we are producing is frightning. What would happen if we have a server crash? How would we know what has been lost? How can we estmate the value of the software, if we do nok what we got? Anyway, back to beeing dumb or lazy; It may seem that my emplyer is to lazy to keep track of the inhouse developed software, but actualy she is not. Having been lazy we would have to reuse the software, cutting down development cost and time.

43.2

Applying to Hobby Projects

I been in the electonic development buisness for servial years. Thinking back I made a dumb mestake: Everytime I got a new MCU, gadget or some kind of develempment board I would actualy start over: new compiler, new code.
1 Stupid

is, what stupid does

136

43.2. APPLYING TO HOBBY PROJECTS

Having written a driver for a diplay for servial dierient archutectures I now realize the it would have been lazy to make the code reuseble. Considering the amount of embedded C code that is undependent of hardware, the amount of code that should be reuseble is signicant.

137

Chapter 44

Thinking outside the Window

138

Part XII

Appendix

139

Table of Contents

A ASCII Chart B GNU Free Documentation License

141 142

1. APPLICABILITY AND DEFINITIONS . . . . . . . . . . . . . . . 142 2. VERBATIM COPYING . . . . . . . . . . . . . . . . . . . . . . . . 144 3. COPYING IN QUANTITY . . . . . . . . . . . . . . . . . . . . . . 144 4. MODIFICATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 5. COMBINING DOCUMENTS . . . . . . . . . . . . . . . . . . . . . 147 6. COLLECTIONS OF DOCUMENTS . . . . . . . . . . . . . . . . . 147 7. AGGREGATION WITH INDEPENDENT WORKS . . . . . . . . 148 8. TRANSLATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 9. TERMINATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 10. FUTURE REVISIONS OF THIS LICENSE . . . . . . . . . . . . 149 11. RELICENSING . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 ADDENDUM: How to use this License for your documents . . . . . . 150 C ARM boot code for the LPC2106 D Linker Script for the LPC2468 Bibliography 151 154 158

Appendix A

ASCII Chart
0 1 2 3 4 5 6 7 0 NUL DLE SP 0 @ P p 1 SOH DC1 ! 1 A Q a q 2 STX DC2 2 B R b r 3 ETX DC3 # 3 C S c s 4 EOT DC4 $ 4 D T d t 5 ENQ NAK % 5 E U e u 6 ACK SYN & 6 F V f v 7 BEL ETB 7 G W g w 8 BS CAN ( 8 H X h x 9 HT EM ) 9 I Y i y A LF SUB * : J Z j z B VT ESC + ; K [ k { C FF FS , L l D CR GS = M ] m }

E SO RS . N n

141

Appendix B

GNU Free Documentation License


Version 1.3, 3 November 2008 Copyright 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. http://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

Preamble
The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the eective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modications made by others. This License is a kind of copyleft, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software. We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

1. APPLICABILITY AND DEFINITIONS


This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed

142

under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The Document, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as you. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law. A Modied Version of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modications and/or translated into another language. A Secondary Section is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Documents overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. The Invariant Sections are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not t the above denition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none. The Cover Texts are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words. A Transparent copy of the Document means a machine-readable copy, represented in a format whose specication is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent le format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modication by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not Transparent is called Opaque. Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modication. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word 143

processors for output purposes only. The Title Page means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, Title Page means the text near the most prominent appearance of the works title, preceding the beginning of the body of the text. The publisher means any person or entity that distributes copies of the Document to the public. A section Entitled XYZ means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specic section name mentioned below, such as Acknowledgements, Dedications, Endorsements, or History.) To Preserve the Title of such a section when you modify the Document means that it remains a section Entitled XYZ according to this denition. The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no eect on the meaning of this License.

2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3. You may also lend copies, under the same conditions stated above, and you may publicly display copies.

3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Documents license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects. 144

If the required texts for either cover are too voluminous to t legibly, you should put the rst ones listed (as many as t reasonably) on the actual cover, and continue the rest onto adjacent pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computernetwork location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

4. MODIFICATIONS
You may copy and distribute a Modied Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modied Version under precisely this License, with the Modied Version lling the role of the Document, thus licensing distribution and modication of the Modied Version to whoever possesses a copy of it. In addition, you must do these things in the Modied Version: A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission. B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modications in the Modied Version, together with at least ve of the principal authors of the Document (all of its principal authors, if it has fewer than ve), unless they release you from this requirement. C. State on the Title page the name of the publisher of the Modied Version, as the publisher. D. Preserve all the copyright notices of the Document. E. Add an appropriate copyright notice for your modications adjacent to the other copyright notices.

145

F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modied Version under the terms of this License, in the form shown in the Addendum below. G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Documents license notice. H. Include an unaltered copy of this License. I. Preserve the section Entitled History, Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modied Version as given on the Title Page. If there is no section Entitled History in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modied Version as stated in the previous sentence. J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the History section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission. K. For any section Entitled Acknowledgements or Dedications, Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles. M. Delete any section Entitled Endorsements. Such a section may not be included in the Modied Version. N. Do not retitle any existing section to be Entitled Endorsements or to conict in title with any Invariant Section. O. Preserve any Warranty Disclaimers. If the Modied Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modied Versions license notice. These titles must be distinct from any other section titles. You may add a section Entitled Endorsements, provided it contains nothing but endorsements of your Modied Version by various partiesfor example, 146

statements of peer review or that the text has been approved by an organization as the authoritative denition of a standard. You may add a passage of up to ve words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modied Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modied Version.

5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this License, under the terms dened in section 4 above for modied versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodied, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but dierent contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. In the combination, you must combine any sections Entitled History in the various original documents, forming one section Entitled History; likewise combine any sections Entitled Acknowledgements, and any sections Entitled Dedications. You must delete all sections Entitled Endorsements.

6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

147

7. AGGREGATION WITH INDEPENDENT WORKS


A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an aggregate if the copyright resulting from the compilation is not used to limit the legal rights of the compilations users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Documents Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.

8. TRANSLATION
Translation is considered a kind of modication, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail. If a section in the Document is Entitled Acknowledgements, Dedications, or History, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.

9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License. However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and nally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder noties you of the violation by some reasonable 148

means, this is the rst time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.

10. FUTURE REVISIONS OF THIS LICENSE


The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may dier in detail to address new problems or concerns. See http://www.gnu.org/copyleft/. Each version of the License is given a distinguishing version number. If the Document species that a particular numbered version of this License or any later version applies to it, you have the option of following the terms and conditions either of that specied version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document species that a proxy can decide which future versions of this License can be used, that proxys public statement of acceptance of a version permanently authorizes you to choose that version for the Document.

11. RELICENSING
Massive Multiauthor Collaboration Site (or MMC Site) means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A Massive Multiauthor Collaboration (or MMC) contained in the site means any set of copyrightable works thus published on the MMC site. CC-BY-SA means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-prot corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization. Incorporate means to publish or republish a Document, in whole or in part, as part of another Document. An MMC is eligible for relicensing if it is licensed under this License, and if all works that were rst published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008. The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing. 149

ADDENDUM: How to use this License for your documents


To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page: Copyright YEAR YOUR NAME. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License. If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the with . . . Texts. line with this: with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.

150

Appendix C

ARM boot code for the LPC2106


Listing C.1: Startup Code for the LPC2106
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

. e x t e r n main . extern exit . text . code 32 . align 0 . extern . extern . extern . extern . extern . extern b s s beg b s s end s t a c k end data beg data end data beg s r c

. global start . g l o b a l e n d l e s s loop start : start : mainCRTStartup : MSR LDR MRS BIC ORR MSR LDR MSR c p s r c ,#0 x13 SP,=0 x40001000 R0 , CPSR R1 , R0 ,#0x1F R1 , R1 ,#0 x12 c p s r c , R1 SP, =0 x40002000 c p s r c , R0

151

30 31 32 33

34

35

36

37

38 39

/ Copy i n i t i a l i z e d data t o i t s e x e c u t i o n a d d r e s s in RAM/ ldr r1 ,= data beg s r c / > ROM data s t a r t / ldr r2 ,= data beg / > data s t a r t / ldr r3 ,= data end / > end o f data / 1: cmp r2 , r 3 / c h ec k i f data t o move/ l d r l o r0 , [ r 1 ] ,#4 / copy i t / s t r l o r0 , [ r 2 ] ,#4 blo 1b / loop u n t i l done / / C l e a r . b s s / mov r0 ,#0 ldr ldr 2: r1 ,= r2 ,= / b s s beg / b s s end /

40 41 42

/ g e t a z e r o / > b s s s t a r t / > b s s end / c h ec k i f data t o / c l e a r 4 b y t e s / loop u n t i l done

43

44

45

46

47

cmp r1 , r 2 c l e a r / s t r l o r0 , [ r 1 ] ,#4 / blo 2b / bl main

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

e n d l e s s loop : b

e n d l e s s loop

/ The v e c t o r s , a s t h e r a r e a b o o t t i m e / . s e c t i o n . s t a r t u p , ax . code 32 . align 0 b b b b b b /b l d r pc , start undefined i n s t r u c t i o n exception software interrupt exception prefetch abort exception data a b o r t e x c e p t i o n reserved exception i n t e r r u p t e x c e p t i o n / [ pc , # x 0 f f 0 ] 0 / v e c t o r v i a VIC /

152

68

fast interrupt exception

153

Appendix D

Linker Script for the LPC2468


Listing D.1: Linker Script, linker.ld
1 2

/ Based on s c r i p t s found i n t h e LPC yahoogroup and t h e K e i l examples m o d i f i e d by Martin Thomas , K a i s e r s l a u t e r n , Germany h t t p : //www. s i w a w i . a r u b i . unik l . de / a v r p r o j e c t s Rev . 20060727 mthomas added ( . b s s . ) 20070429 mthomas s p e c i a l v e r s i o n l p c 2 3 7 8 example / / ENTRY( ) STACK SIZE = 0 x800 ; / > s e e s t a r t u p f i l e and . s t a c k s e c t i o n /

3 4 5 6 7 8 9 10 11 12 13

14 15 16 17 18 19 20 21 22 23 24 25 26 27

/ Memory D e f i n i t i o n s / MEMORY { ROM ( rx ) : ORIGIN = 0 x00000000 , LENGTH = ( 5 1 2 k4k ) RAM ( rw ) : ORIGIN = 0 x40000000 , LENGTH = ( 3 2 k32) /SDRAM ( rw ) : ORIGIN = 0 xA0000000 , LENGTH = 32M/ } / S e c t i o n D e f i n i t i o n s / SECTIONS { / f i r s t s e c t i o n i s . t e x t which i s u sed f o r code /

154

28 29 30 31

. text : { crt0 . o ( . text ) KEEP( ( .RESET) ) s e c t i o n / ( . text . text . ) ( . gnu . l i n k o n c e . t . ) ( . glue 7) ( . glue 7 t ) ( . gcc except t a b l e ) ( . rodata ) c o n s t a n t s ) / ( . rodata ) ( . gnu . l i n k o n c e . r . ) . = ALIGN( 4 ) ; } > ROM . = ALIGN( 4 ) ; / . c t o r s . d t o r s a r e u sed f o r c++ c o n s t r u c t o r s / d e s t r u c t o r s / / added by Martin Thomas 4/2005 b a s e d on A n g l i a Design example / . ctors : { PROVIDE( c t o r s s t a r t = .); KEEP( (SORT( . c t o r s . ) ) ) KEEP( ( . c t o r s ) ) . = ALIGN( 4 ) ; PROVIDE( c t o r s end = .); . = ALIGN( 4 ) ; } > ROM . dtors : { PROVIDE( d t o r s s t a r t = .); KEEP( (SORT( . d t o r s . ) ) ) KEEP( ( . d t o r s ) ) . = ALIGN( 4 ) ; PROVIDE( d t o r s end = .); . = ALIGN( 4 ) ; } > ROM . = ALIGN( 4 ) ; / mthomas end / etext = . ; PROVIDE ( e t e x t = . ) ; / . d a t a s e c t i o n which i s u sed f o r i n i t i a l i z e d d a t a / / S t a r t u p code from . i n i t / r e m a i n i n g code /

32 33 34 35 36 37

/ reado n l y d a t a (

38 39 40 41 42 43 44 45

46

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

155

74 75 76 77

78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

. data : AT ( e t e x t ) { data = . ; KEEP( ( . vectmapped ) ) / mthomas : when code i n ROM and v e c t o r s remapped / . = ALIGN( 4 ) ; ( . f a s t r u n ) / mthomas : f o r RAMFUNC / . = ALIGN( 4 ) ; SORT(CONSTRUCTORS) / mt 4/2005 / . = ALIGN( 4 ) ; ( . data ) ( . data . ) ( . gnu . l i n k o n c e . d ) . = ALIGN( 4 ) ; } > RAM . = ALIGN( 4 ) ; edata = . ; PROVIDE ( e d a t a = . ) ; / . b s s s e c t i o n which i s u sed f o r u n i n i t i a l i z e d d a t a / . b s s (NOLOAD) : { bss s t a r t = . ; bss s t a r t = . ; ( . bss ) ( . b s s . ) / mthomas 7/2006 / ( . gnu . l i n k o n c e . b ) (COMMON) . = ALIGN( 4 ) ; } > RAM . = ALIGN( 4 ) ; b s s end = . ; PROVIDE ( b s s end = . ) ; . s t a c k ALIGN( 2 5 6 ) : { ( . stack ) ( .STACK) PROVIDE ( s t a c k = . ) ; . = ALIGN( 4 ) ; } > RAM end = . ; PROVIDE ( end = . ) ; . heap : { ( .HEAP)

156

123 124 125 126 127 128 129 130 131 132 133 134 135 136

. = ALIGN( 4 ) ; } > RAM

137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160

/ S t a b s d e b u g g i n g s e c t i o n s . / . stab 0 : { ( . stab ) } . stabstr 0 : { ( . s t a b s t r ) } . stab . excl 0 : { ( . stab . e x c l ) } . stab . e x c l s t r 0 : { ( . stab . e x c l s t r ) } . stab . index 0 : { ( . stab . index ) } . stab . i n d e x s t r 0 : { ( . stab . i n d e x s t r ) } . comment 0 : { ( . comment ) } / DWARF debug s e c t i o n s . Symbols i n t h e DWARF d e b u g g i n g s e c t i o n s a r e r e l a t i v e t o the beginning o f t h e s e c t i o n so we b e g i n them a t 0 . / / DWARF 1 / . debug 0 : { ( . debug ) } . line 0 : { ( . l i n e ) } / GNU DWARF 1 e x t e n s i o n s / . debug s r c i n f o 0 : { ( . debug s r c i n f o ) } . debug sfn a mes 0 : { ( . debug sfn a mes ) } / DWARF 1 . 1 and DWARF 2 / . debug a r a n g e s 0 : { ( . debug a r a n g e s ) } . debug pubnames 0 : { ( . debug pubnames ) } / DWARF 2 / . debug i n f o 0 : { ( . debug i n f o . gnu . l i n k o n c e . wi . ) } . debug abbrev 0 : { ( . debug abbrev ) } . debug l i n e 0 : { ( . debug l i n e ) } . debug frame 0 : { ( . debug frame ) } . debug s t r 0 : { ( . debug s t r ) } . debug l o c 0 : { ( . debug l o c ) } . debug m a c i n f o 0 : { ( . debug m a c i n f o ) } / SGI/MIPS DWARF 2 e x t e n s i o n s / . debug weaknames 0 : { ( . debug weaknames ) } . debug funcnames 0 : { ( . debug funcnames ) } . debug typenames 0 : { ( . debug typenames ) } . debug varnames 0 : { ( . debug varnames ) } }

157

Bibliography
[1] Richard Barry. The freertos project. http://www.freertos.org. [2] Buildroot. Homepage. http://www.buildroot.uclibc.org. Website, 2010.

[3] Crossplex. Homepage. Website, 2010. http://crossplex.org/. [4] Crosstool. Homepage. http://www.kegel.com/crosstool/. Website, 2010. 2010. 2010. 2006. page.

[5] Crosstool-NG. Homepage. Website, http://ymorin.is-a-geek.org/projects/crosstool. [6] Gentoo. Homepage. http://en.gentoo-wiki.com/wiki/Crossdev. Website,

[7] Kwikbyte. Homepage. Website, http://www.canadianarachnology.org/data/spiders/30843. [8] Martin Maurer. Lpc21ipc sourceforge http://sourceforge.net/projects/lpc21isp/. [9] Newlib. Newlib homepage. http://sourceware.org/newlib/.

[10] Scratchbox. Homepage. Website, 2010. http://www.scratchbox.org/. 2008. [11] Nick Stallman. Howto gentoo diskless install, http://www.gentoo-wiki.info/HOWTO_Gentoo_Diskless_Install. [12] Swiss.Mage. Gentoo forum. http://forums.gentoo.org/viewtopic.php?t=54293.

158

Index
ARM7 Clock, 95 AVR Anemometer, 26 Toolchain, 22 Binutils addr2line, 12 ar, 12 as, 12 c++, 14 gasp, 14 ld, 14 nm, 14 objcopy, 14 Objdump, 14 ranlib, 14 Size, 14 Strings, 14 Strip, 14 Busybox, 45 Building, 46 DHCP, 112 acknowledgement, 112 discovery, 112 oer, 112 request, 112 dmesg, 50 FreeRTOS, 97 GCC, 14 gcc c++, 15 cpp, 15 gcc, 14 gcov, 15 gprof, 15 IDE, 114 Interrupt, 96 IP, 99 Keil, 97 libc, 15 Linux Building, 43 Patching, 44 Server, 39 NFS, 112 PXE, 112 realtime, 114 Realview, 97 Rootfs Creating, 47 Server DHCP, 104 NFS, 106 rsync, 108 TFTP, 107 svn, 28, 102 T6963C, 26 AVR, 26 TCP, 99 TFTP, 112 U-boot, 43 uClibc, 45 x86info, 87 159

Vous aimerez peut-être aussi