18.05.2014 Views

How to become a PTXdist Guru Based on the ... - Pengutronix

How to become a PTXdist Guru Based on the ... - Pengutronix

How to become a PTXdist Guru Based on the ... - Pengutronix

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

OSELAS.Support<br />

OSELAS.Training<br />

OSELAS.Development<br />

OSELAS.Services<br />

<str<strong>on</strong>g>How</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>become</str<strong>on</strong>g> a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <str<strong>on</strong>g>Guru</str<strong>on</strong>g><br />

<str<strong>on</strong>g>Based</str<strong>on</strong>g> <strong>on</strong> <strong>the</strong> OSELAS.BSP( )<br />

Pengutr<strong>on</strong>ix Generic-arm<br />

Pengutr<strong>on</strong>ix e. K.<br />

Peiner Straße 6–8<br />

31137 Hildesheim<br />

+49 (0)51 21 / 20 69 17 – 0 (F<strong>on</strong>)<br />

+49 (0)51 21 / 20 69 17 – 55 55 (Fax)<br />

info@pengutr<strong>on</strong>ix.de<br />

© 2011 Pengutr<strong>on</strong>ix, Hildesheim – Rev. 1549/456


C<strong>on</strong>tents<br />

1 Welcome <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> Embedded World 6<br />

1.1 First Steps in <strong>the</strong> Embedded World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6<br />

1.2 From Server <str<strong>on</strong>g>to</str<strong>on</strong>g> Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7<br />

1.3 Linux = Embedded Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7<br />

2 Getting a working Envir<strong>on</strong>ment 8<br />

2.1 Download Software Comp<strong>on</strong>ents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8<br />

2.2 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Installati<strong>on</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8<br />

2.2.1 Main Parts of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8<br />

2.2.2 Extracting <strong>the</strong> Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9<br />

2.2.3 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10<br />

2.2.4 C<strong>on</strong>figuring <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11<br />

2.3 Toolchains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12<br />

2.3.1 Using Existing Toolchains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12<br />

2.3.2 Building a Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13<br />

2.3.3 Building <strong>the</strong> OSELAS.Toolchain for OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0 . . . . . 13<br />

2.3.4 Protecting <strong>the</strong> Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14<br />

2.3.5 Building Additi<strong>on</strong>al Toolchains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14<br />

3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual 15<br />

3.1 <str<strong>on</strong>g>How</str<strong>on</strong>g> does it work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15<br />

3.1.1 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s percepti<strong>on</strong> of <strong>the</strong> world . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15<br />

3.1.2 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s build process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16<br />

3.2 First steps with <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16<br />

3.2.1 Extracting <strong>the</strong> Board Support Package . . . . . . . . . . . . . . . . . . . . . . . . . . . 18<br />

3.2.2 Selecting a Userland C<strong>on</strong>figurati<strong>on</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19<br />

3.2.3 Selecting a Hardware Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19<br />

3.2.4 Selecting a Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20<br />

3.2.5 Building <strong>the</strong> Root Filesystem C<strong>on</strong>tent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20<br />

3.2.6 What we Got Now . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20<br />

3.2.7 Creating a Root Filesystem Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21<br />

3.2.8 Running all Parts in an emulated Envir<strong>on</strong>ment (QEMU) . . . . . . . . . . . . . . . . . . . 21<br />

3.3 Adapting <strong>the</strong> OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0 Project . . . . . . . . . . . . . . . . . 22<br />

3.3.1 Working with Kc<strong>on</strong>fig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22<br />

3.3.2 Adapting Platform Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24<br />

3.3.3 Adapting Linux Kernel Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24<br />

3.3.4 Adapting Userland Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25<br />

4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual 27<br />

4.1 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27<br />

4.1.1 Rule Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27<br />

4.1.2 Patch Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27<br />

4.1.3 Runtime C<strong>on</strong>figurati<strong>on</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28<br />

3


C<strong>on</strong>tents<br />

4.2 Adding new Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28<br />

4.2.1 Rule File Creati<strong>on</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29<br />

4.2.2 Make it Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30<br />

4.2.3 Advanced Rule Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35<br />

4.2.4 Patching Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40<br />

4.2.5 Creating Patches for a Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41<br />

4.2.6 Modifying Au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>olized Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41<br />

4.3 Adding binary <strong>on</strong>ly Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42<br />

4.3.1 Old style - single files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42<br />

4.3.2 New style - using archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43<br />

4.3.3 Creating a Rules File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43<br />

5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference 45<br />

5.1 Variables Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45<br />

5.1.1 PTXDIST_TOPDIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45<br />

5.1.2 PTXDIST_WORKSPACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45<br />

5.1.3 PTXDIST_SYSROOT_CROSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45<br />

5.1.4 PTXDIST_SYSROOT_HOST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45<br />

5.1.5 PTXDIST_SYSROOT_TARGET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

5.1.6 CROSS_PATH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

5.1.7 HOST_PATH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

5.1.8 ROOTDIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

5.1.9 PTXCONF_PLATFORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

5.1.10 PTXDIST_PLATFORMSUFFIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

5.1.11 PTXDIST_PLATFORMCONFIGDIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

5.1.12 PTXDIST_PLATFORMDIR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

5.2 Rule File Macro Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47<br />

5.2.1 targetinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47<br />

5.2.2 <str<strong>on</strong>g>to</str<strong>on</strong>g>uch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47<br />

5.2.3 clean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47<br />

5.2.4 install_copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47<br />

5.2.5 install_tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49<br />

5.2.6 install_alternative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49<br />

5.2.7 install_link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50<br />

5.2.8 install_archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51<br />

5.3 Rule file layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51<br />

5.3.1 Default stage rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52<br />

5.3.2 Skipping a Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53<br />

5.4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> parameter reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54<br />

5.4.1 Setup and Project Acti<strong>on</strong>s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54<br />

5.4.2 Build Acti<strong>on</strong>s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54<br />

5.4.3 Clean Acti<strong>on</strong>s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55<br />

6 Various Aspects of Daily Work 56<br />

6.1 Using an External Kernel Source Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56<br />

6.1.1 Cl<strong>on</strong>ing <strong>the</strong> Linux Kernel Source Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56<br />

6.1.2 C<strong>on</strong>figuring <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56<br />

6.1.3 C<strong>on</strong>figuring <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56<br />

6.1.4 Work Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57<br />

6.2 Discovering Runtime Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57<br />

4


C<strong>on</strong>tents<br />

6.2.1 Dependencies <strong>on</strong> Shared Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58<br />

6.2.2 Dependencies <strong>on</strong> o<strong>the</strong>r Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58<br />

6.3 Debugging with CPU emulati<strong>on</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59<br />

6.3.1 Running an Applicati<strong>on</strong> made for a different Architecture . . . . . . . . . . . . . . . . . 59<br />

6.3.2 Debugging an Applicati<strong>on</strong> made for a different Architecture . . . . . . . . . . . . . . . . 59<br />

6.4 Migrati<strong>on</strong> between Minor Releases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60<br />

6.4.1 Simple Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60<br />

6.5 Migrati<strong>on</strong> between Major Releases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61<br />

6.5.1 Basic C<strong>on</strong>versi<strong>on</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61<br />

6.5.2 Adapti<strong>on</strong> of Rules Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61<br />

6.5.3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>-1 Look and Feel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62<br />

6.6 Software Installati<strong>on</strong> and Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62<br />

6.6.1 ipkg Usage in <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62<br />

6.6.2 Packet Installati<strong>on</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63<br />

6.6.3 Au<str<strong>on</strong>g>to</str<strong>on</strong>g>matic Packet Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63<br />

6.6.4 The ipkg Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63<br />

6.7 Downloading Packages from <strong>the</strong> Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65<br />

7 Document Revisi<strong>on</strong>s 66<br />

8 Getting help 67<br />

8.1 Mailing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

8.1.1 About <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> in Particular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

8.1.2 About Embedded Linux in General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

8.2 News Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

8.2.1 About Linux in Embedded Envir<strong>on</strong>ments . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

8.2.2 About General Unix/Linux Questi<strong>on</strong>s . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

8.3 Chat/IRC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68<br />

8.4 Commercial Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68<br />

5


1 Welcome <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> Embedded World<br />

1.1 First Steps in <strong>the</strong> Embedded World<br />

Once up<strong>on</strong> in time, programming embedded systems was easy: all a developer needed when he wanted <str<strong>on</strong>g>to</str<strong>on</strong>g> start<br />

a new product was a good <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain, c<strong>on</strong>sisting of<br />

• a compiler<br />

• maybe an assembler<br />

• probably an EPROM burning device<br />

and things could start. After some more or less short time, every register of <strong>the</strong> CPU was known, a variety of<br />

library routines had been developed and our brave developer was able <str<strong>on</strong>g>to</str<strong>on</strong>g> do his project with <strong>the</strong> more and more<br />

well-known system. The c<strong>on</strong>trollers had legacy interfaces like RS232, i2c or SPI which c<strong>on</strong>nected <strong>the</strong>m <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong><br />

outside world and <strong>the</strong> main difference between <strong>the</strong> c<strong>on</strong>trollers available <strong>on</strong> <strong>the</strong> market was <strong>the</strong> number of GPIO<br />

pins, UARTS and memory ressources.<br />

Things have changed. Hardware manufacturers have weakened <strong>the</strong> border between deeply embedded microc<strong>on</strong>trollers<br />

– headless devices with just a few pins and very limited computing power – and full blown microprocessors.<br />

System structures became much more complicated: where our good old c<strong>on</strong>trollers have had just some<br />

interrupts with some small interrupt service routines, we <str<strong>on</strong>g>to</str<strong>on</strong>g>day need complicated generic interrupt infrastructures,<br />

suitable for generic software frameworks. Where we’ve had some linearly mapped flash ROM and some<br />

data RAM we <str<strong>on</strong>g>to</str<strong>on</strong>g>day have multi-stage-pipeline architectures, memory management units, virtual address spaces,<br />

<strong>on</strong>-chip-memory, caches and o<strong>the</strong>r complicated units, which is not exactly what <strong>the</strong> embedded system developer<br />

wants program every o<strong>the</strong>r day.<br />

Entering embedded operating systems. Although <strong>the</strong>re are still some processors out <strong>the</strong>re (like <strong>the</strong> popular<br />

ARM7TDMI based SoCs) which can be programmed <strong>the</strong> good old n<strong>on</strong>-operating-system way with reas<strong>on</strong>able<br />

effort, it in fact is becoming more and more difficult. On <strong>the</strong> o<strong>the</strong>r hand, legacy I/O interfaces like RS232 are increasingly<br />

often replaced by modern plug-and-play aware communicati<strong>on</strong> channels: USB, FireWire (IEEE1394),<br />

E<strong>the</strong>rnet & friends are more and more directly being integrated in<str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g>day’s microc<strong>on</strong>troller hardware. Whereas<br />

some of <strong>the</strong>se interfaces can ”‘somehow”’ be handled <strong>the</strong> old c<strong>on</strong>troller-style way of writing software, <strong>the</strong> developer<br />

following this way will not be able <str<strong>on</strong>g>to</str<strong>on</strong>g> address <strong>the</strong> security and performance issues which come up with <strong>the</strong><br />

modern network accessible devices.<br />

During <strong>the</strong> last years, more and more of <strong>the</strong> small-scale companies which developed little embedded operating<br />

systems have been pushed out of <strong>the</strong> market. Nearly no small company is able <str<strong>on</strong>g>to</str<strong>on</strong>g> support all <strong>the</strong> different interfaces,<br />

communicati<strong>on</strong> stacks, development <str<strong>on</strong>g>to</str<strong>on</strong>g>ols and security issues out <strong>the</strong>re. New interfaces and -variants<br />

(like USB On-<strong>the</strong>-Go) are developed faster than operating system developers can supply <strong>the</strong> software for <strong>the</strong>m.<br />

The result is a c<strong>on</strong>solidati<strong>on</strong> of <strong>the</strong> market: <str<strong>on</strong>g>to</str<strong>on</strong>g>day we see that, besides niche products, probably <strong>on</strong>ly <strong>the</strong> largest<br />

commercial embedded operating system suppliers will survive that development.<br />

Only <strong>the</strong> largest commercial...? There is <strong>on</strong>e excepti<strong>on</strong>: when <strong>the</strong> same situati<strong>on</strong> came up in <strong>the</strong> ”mainstream”<br />

computer market at <strong>the</strong> beginning of <strong>the</strong> 1990ies, people started <str<strong>on</strong>g>to</str<strong>on</strong>g> develop an alternative <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> large commercial<br />

operating systems: Linux. Linux did never start with a ready-<str<strong>on</strong>g>to</str<strong>on</strong>g>-use soluti<strong>on</strong>: people had a problem, searched<br />

for a soluti<strong>on</strong> but didn’t find <strong>on</strong>e. Then <strong>the</strong>y started <str<strong>on</strong>g>to</str<strong>on</strong>g> develop <strong>on</strong>e <strong>the</strong>mselves, often several people did this<br />

6


1 Welcome <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> Embedded World<br />

in parallel, and in a huge community based evoluti<strong>on</strong> mechanism <strong>the</strong> best soluti<strong>on</strong>s found <strong>the</strong>ir way in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong><br />

Linux kernel, which over <strong>the</strong> time formed <strong>on</strong>e of <strong>the</strong> most reliable and performant kernels available <str<strong>on</strong>g>to</str<strong>on</strong>g>day. This<br />

”develop-and-evolute” mechanism has shown its effectiveness over and over again in <strong>the</strong> server and desk<str<strong>on</strong>g>to</str<strong>on</strong>g>p<br />

market of <str<strong>on</strong>g>to</str<strong>on</strong>g>day.<br />

1.2 From Server <str<strong>on</strong>g>to</str<strong>on</strong>g> Embedded<br />

The fact that for most technical problems that might occur it may be possible <str<strong>on</strong>g>to</str<strong>on</strong>g> find somebody <strong>on</strong> <strong>the</strong> internet<br />

who has already worked <strong>on</strong> <strong>the</strong> same or ano<strong>the</strong>r very similar problem, was <strong>on</strong>e of <strong>the</strong> major forces behind <strong>the</strong><br />

success s<str<strong>on</strong>g>to</str<strong>on</strong>g>ry of Embedded Linux.<br />

Studies have shown that more than 70% of <strong>the</strong> embedded developers are not satisfied with a black-box operating<br />

system: <strong>the</strong>y want <str<strong>on</strong>g>to</str<strong>on</strong>g> adapt it <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong>ir needs, <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong>ir special hardware situati<strong>on</strong> (which most times is Just Different<br />

than anything available). Embedded projects are even more variegated than desk<str<strong>on</strong>g>to</str<strong>on</strong>g>p- or server projects, due <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

<strong>the</strong> fact that <strong>the</strong>re exist so many different embedded processors with lots of peripherals out <strong>the</strong>re.<br />

Linux has evolved from an i386 <strong>on</strong>ly operating system <str<strong>on</strong>g>to</str<strong>on</strong>g> a kernel running <strong>on</strong> nearly every modern 32 bit processor<br />

available <str<strong>on</strong>g>to</str<strong>on</strong>g>day: x86, PowerPC, ARM, MIPS, m68k, cris, Super-H etc. The kernel supplies a hardware abstracti<strong>on</strong><br />

layer which lets our brave embedded developer <strong>on</strong>ce again c<strong>on</strong>centrate <strong>on</strong> his very special problem, not <strong>on</strong><br />

handling negligibilities like memory management.<br />

But Linux is <strong>on</strong>ly half of <strong>the</strong> s<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. Besides <strong>the</strong> kernel, a Linux based embedded system c<strong>on</strong>sists of a ”userland”:<br />

a filesystem, c<strong>on</strong>taining all <strong>the</strong> small <str<strong>on</strong>g>to</str<strong>on</strong>g>ols which form a small Unix system. Only <strong>the</strong> combinati<strong>on</strong> of <strong>the</strong> kernel<br />

and a Userland let’s <strong>the</strong> developer run ”normal” processes <strong>on</strong> his x86 development machine as well as <strong>on</strong> his<br />

embedded target.<br />

1.3 Linux = Embedded Linux<br />

Whereas <strong>the</strong> mainstream developers were always able <str<strong>on</strong>g>to</str<strong>on</strong>g> use normal Linux distributi<strong>on</strong>s like SuSE, RedHat, Mandrake<br />

or Debian as a base for <strong>the</strong>ir applicati<strong>on</strong>s, things are different for embedded systems.<br />

Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> restricted ressources <strong>the</strong>se systems normally have, distributi<strong>on</strong>s have <str<strong>on</strong>g>to</str<strong>on</strong>g> be small and should <strong>on</strong>ly<br />

c<strong>on</strong>tain those things that are needed for <strong>the</strong> applicati<strong>on</strong>. Today’s mainstream distributi<strong>on</strong>s cannot be installed<br />

in less than 100 MiB without major loss of functi<strong>on</strong>ality. Even Debian, probably <str<strong>on</strong>g>to</str<strong>on</strong>g>day <strong>the</strong> most cus<str<strong>on</strong>g>to</str<strong>on</strong>g>mizable<br />

mainstream distributi<strong>on</strong>, cannot be shrunk below this mark without for example losing <strong>the</strong> packet management,<br />

which is an essential feature of using a distributi<strong>on</strong> at all.<br />

Additi<strong>on</strong>ally, source code for industrial systems has <str<strong>on</strong>g>to</str<strong>on</strong>g> be<br />

• auditable and<br />

• reproducable.<br />

Embedded developers usually want <str<strong>on</strong>g>to</str<strong>on</strong>g> know what’s in <strong>the</strong>ir systems – be it that <strong>the</strong>y have <str<strong>on</strong>g>to</str<strong>on</strong>g> support <strong>the</strong>ir software<br />

for a l<strong>on</strong>g time span (something like 10-15 years are usual product lifetimes in au<str<strong>on</strong>g>to</str<strong>on</strong>g>mati<strong>on</strong> applicati<strong>on</strong>s) or that<br />

<strong>the</strong>y have such a special scenario that <strong>the</strong>y have <str<strong>on</strong>g>to</str<strong>on</strong>g> maintain <strong>the</strong>ir integrated source of <strong>the</strong>ir Userland <strong>the</strong>mselves.<br />

Entering <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>.<br />

7


2 Getting a working Envir<strong>on</strong>ment<br />

2.1 Download Software Comp<strong>on</strong>ents<br />

In order <str<strong>on</strong>g>to</str<strong>on</strong>g> follow this manual, some software archives are needed. There are several possibilities how <str<strong>on</strong>g>to</str<strong>on</strong>g> get<br />

<strong>the</strong>se: ei<strong>the</strong>r as part of an evaluati<strong>on</strong> board package or by downloading <strong>the</strong>m from <strong>the</strong> Pengutr<strong>on</strong>ix web site.<br />

The central place for OSELAS related documentati<strong>on</strong> is http://www.oselas.com. This website provides all required<br />

packages and documentati<strong>on</strong> (at least for software comp<strong>on</strong>ents which are available <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> public).<br />

To build OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0, <strong>the</strong> following archives have <str<strong>on</strong>g>to</str<strong>on</strong>g> be available <strong>on</strong> <strong>the</strong> development<br />

host:<br />

• ptxdist-2011.01.0.tar.bz2<br />

• OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0.tar.gz<br />

• OSELAS.Toolchain-1.99.3.7.tar.bz2<br />

If <strong>the</strong>y are not available <strong>on</strong> <strong>the</strong> development system yet, it is necessary <str<strong>on</strong>g>to</str<strong>on</strong>g> get <strong>the</strong>m.<br />

2.2 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Installati<strong>on</strong><br />

The <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> build system can be used <str<strong>on</strong>g>to</str<strong>on</strong>g> create a root filesystem for embedded Linux devices. In order <str<strong>on</strong>g>to</str<strong>on</strong>g> start<br />

development with <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> it is necessary <str<strong>on</strong>g>to</str<strong>on</strong>g> install <strong>the</strong> software <strong>on</strong> <strong>the</strong> development system.<br />

This chapter provides informati<strong>on</strong> about how <str<strong>on</strong>g>to</str<strong>on</strong>g> install and c<strong>on</strong>figure <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <strong>on</strong> <strong>the</strong> development host.<br />

2.2.1 Main Parts of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g><br />

The most important software comp<strong>on</strong>ent which is necessary <str<strong>on</strong>g>to</str<strong>on</strong>g> build an OSELAS.BSP( ) board support package<br />

is <strong>the</strong> ptxdist <str<strong>on</strong>g>to</str<strong>on</strong>g>ol. So before starting any work we’ll have <str<strong>on</strong>g>to</str<strong>on</strong>g> install <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <strong>on</strong> <strong>the</strong> development host.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> c<strong>on</strong>sists of <strong>the</strong> following parts:<br />

The ptxdist Program: ptxdist is installed <strong>on</strong> <strong>the</strong> development host during <strong>the</strong> installati<strong>on</strong> process. ptxdist is<br />

called <str<strong>on</strong>g>to</str<strong>on</strong>g> trigger any acti<strong>on</strong>, like building a software packet, cleaning up <strong>the</strong> tree etc. Usually <strong>the</strong> ptxdist<br />

program is used in a workspace direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry, which c<strong>on</strong>tains all project relevant files.<br />

A C<strong>on</strong>figurati<strong>on</strong> System: The c<strong>on</strong>fig system is used <str<strong>on</strong>g>to</str<strong>on</strong>g> cus<str<strong>on</strong>g>to</str<strong>on</strong>g>mize a c<strong>on</strong>figurati<strong>on</strong>, which c<strong>on</strong>tains informati<strong>on</strong><br />

about which packages have <str<strong>on</strong>g>to</str<strong>on</strong>g> be built and which opti<strong>on</strong>s are selected.<br />

Patches: Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> fact that some upstream packages are not bug free – especially with regard <str<strong>on</strong>g>to</str<strong>on</strong>g> cross compilati<strong>on</strong><br />

– it is often necessary <str<strong>on</strong>g>to</str<strong>on</strong>g> patch <strong>the</strong> original software. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> c<strong>on</strong>tains a mechanism <str<strong>on</strong>g>to</str<strong>on</strong>g> au<str<strong>on</strong>g>to</str<strong>on</strong>g>matically<br />

apply patches <str<strong>on</strong>g>to</str<strong>on</strong>g> packages. The patches are bundled in<str<strong>on</strong>g>to</str<strong>on</strong>g> a separate archive. Never<strong>the</strong>less, <strong>the</strong>y are necessary<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> build a working system.<br />

8


2 Getting a working Envir<strong>on</strong>ment<br />

Package Descripti<strong>on</strong>s: For each software comp<strong>on</strong>ent <strong>the</strong>re is a “recipe” file, specifying which acti<strong>on</strong>s have <str<strong>on</strong>g>to</str<strong>on</strong>g> be<br />

d<strong>on</strong>e <str<strong>on</strong>g>to</str<strong>on</strong>g> prepare and compile <strong>the</strong> software. Additi<strong>on</strong>ally, packages c<strong>on</strong>tain <strong>the</strong>ir c<strong>on</strong>figurati<strong>on</strong> sniplet for<br />

<strong>the</strong> c<strong>on</strong>fig system.<br />

Toolchains: <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> does not come with a pre-built binary <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain. Never<strong>the</strong>less, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> itself is able <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

build <str<strong>on</strong>g>to</str<strong>on</strong>g>olchains, which are provided by <strong>the</strong> OSELAS.Toolchain() project. More in-deep informati<strong>on</strong> about<br />

<strong>the</strong> OSELAS.Toolchain() project can be found here: http://www.pengutr<strong>on</strong>ix.de/oselas/<str<strong>on</strong>g>to</str<strong>on</strong>g>olchain/<br />

index_en.html<br />

Board Support Package This is an opti<strong>on</strong>al comp<strong>on</strong>ent, mostly shipped aside with a piece of hardware. There<br />

are various BSP available, some are generic, some are intended for a specific hardware.<br />

2.2.2 Extracting <strong>the</strong> Sources<br />

To install <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>, at least two archives have <str<strong>on</strong>g>to</str<strong>on</strong>g> be extracted:<br />

ptxdist-2011.01.0.tar.bz2 The <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> software itself<br />

ptxdist-2011.01.0-projects.tgz Generic projects (opti<strong>on</strong>al), can be used as a starting point for self-built projects.<br />

The <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> packet has <str<strong>on</strong>g>to</str<strong>on</strong>g> be extracted in<str<strong>on</strong>g>to</str<strong>on</strong>g> some temporary direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry in order <str<strong>on</strong>g>to</str<strong>on</strong>g> be built before <strong>the</strong> installati<strong>on</strong>,<br />

for example <strong>the</strong> local/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry in <strong>the</strong> user’s home. If this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry does not exist, we have <str<strong>on</strong>g>to</str<strong>on</strong>g> create it and<br />

change in<str<strong>on</strong>g>to</str<strong>on</strong>g> it:<br />

$ cd<br />

$ mkdir local<br />

$ cd local<br />

Next step is <str<strong>on</strong>g>to</str<strong>on</strong>g> extract <strong>the</strong> archive:<br />

$ tar -xjf ptxdist-2011.01.0.tar.bz2<br />

and if required <strong>the</strong> generic projects:<br />

$ tar -xzf ptxdist-2011.01.0-projects.tgz<br />

If everything goes well, we now have a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>-2011.01.0 direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry, so we can change in<str<strong>on</strong>g>to</str<strong>on</strong>g> it:<br />

$ cd ptxdist-2011.01.0<br />

$ ls -lF<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g>tal 532<br />

-rw-r--r-- 1 jb users 18361 Jan 6 14:50 COPYING<br />

-rw-r--r-- 1 jb users 3865 Jan 6 14:50 CREDITS<br />

-rw-r--r-- 1 jb users 115540 Jan 6 14:50 ChangeLog<br />

-rw-r--r-- 1 jb users 57 Jan 6 14:50 INSTALL<br />

-rw-r--r-- 1 jb users 2228 Jan 6 14:50 Makefile.in<br />

-rw-r--r-- 1 jb users 4196 Jan 6 14:50 README<br />

-rw-r--r-- 1 jb users 691 Jan 6 14:50 REVISION_POLICY<br />

-rw-r--r-- 1 jb users 63019 Jan 6 14:50 TODO<br />

-rwxr-xr-x 1 jb users 28 Jan 6 14:50 au<str<strong>on</strong>g>to</str<strong>on</strong>g>gen.sh<br />

drwxr-xr-x 2 jb users 4096 Jan 6 14:50 bin<br />

drwxr-xr-x 9 jb users 4096 Jan 6 14:50 c<strong>on</strong>fig<br />

-rwxr-xr-x 1 jb users 213205 Jan 6 16:29 c<strong>on</strong>figure<br />

-rw-r--r-- 1 jb users 12539 Jan 6 14:50 c<strong>on</strong>figure.ac<br />

drwxr-xr-x 10 jb users 4096 Jan 6 14:50 generic<br />

drwxr-xr-x 162 jb users 4096 Jan 6 14:50 patches<br />

9


2 Getting a working Envir<strong>on</strong>ment<br />

drwxr-xr-x 2 jb users 4096 Jan 6 14:50 platforms<br />

drwxr-xr-x 4 jb users 4096 Jan 6 14:50 plugins<br />

drwxr-xr-x 6 jb users 32768 Jan 6 14:50 rules<br />

drwxr-xr-x 8 jb users 4096 Jan 6 14:50 scripts<br />

drwxr-xr-x 2 jb users 4096 Jan 6 14:50 tests<br />

2.2.3 Prerequisites<br />

Before <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> can be installed it has <str<strong>on</strong>g>to</str<strong>on</strong>g> be checked if all necessary programs are installed <strong>on</strong> <strong>the</strong> development<br />

host. The c<strong>on</strong>figure script will s<str<strong>on</strong>g>to</str<strong>on</strong>g>p if it discovers that something is missing.<br />

The <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> installati<strong>on</strong> is based <strong>on</strong> GNU au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>ols, so <strong>the</strong> first thing <str<strong>on</strong>g>to</str<strong>on</strong>g> be d<strong>on</strong>e now is <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure <strong>the</strong> packet:<br />

$ ./c<strong>on</strong>figure<br />

This will check your system for required comp<strong>on</strong>ents <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> relies <strong>on</strong>. If all required comp<strong>on</strong>ents are found <strong>the</strong><br />

output ends with:<br />

[...]<br />

checking whe<strong>the</strong>r /usr/bin/patch will work... yes<br />

c<strong>on</strong>figure: creating ./c<strong>on</strong>fig.status<br />

c<strong>on</strong>fig.status: creating Makefile<br />

c<strong>on</strong>fig.status: creating scripts/ptxdist_versi<strong>on</strong>.sh<br />

c<strong>on</strong>fig.status: creating rules/ptxdist-versi<strong>on</strong>.in<br />

ptxdist versi<strong>on</strong> 2011.01.0 c<strong>on</strong>figured.<br />

Using ’/usr/local’ for installati<strong>on</strong> prefix.<br />

Report bugs <str<strong>on</strong>g>to</str<strong>on</strong>g> ptxdist@pengutr<strong>on</strong>ix.de<br />

Without fur<strong>the</strong>r arguments <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is c<strong>on</strong>figured <str<strong>on</strong>g>to</str<strong>on</strong>g> be installed in<str<strong>on</strong>g>to</str<strong>on</strong>g> /usr/local, which is <strong>the</strong> standard locati<strong>on</strong><br />

for user installed programs. To change <strong>the</strong> installati<strong>on</strong> path <str<strong>on</strong>g>to</str<strong>on</strong>g> anything n<strong>on</strong>-standard, we use <strong>the</strong> --prefix argument<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> c<strong>on</strong>figure script. The --help opti<strong>on</strong> offers more informati<strong>on</strong> about what else can be changed for<br />

<strong>the</strong> installati<strong>on</strong> process.<br />

The installati<strong>on</strong> paths are c<strong>on</strong>figured in a way that several <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> versi<strong>on</strong>s can be installed in parallel. So if an<br />

old versi<strong>on</strong> of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is already installed <strong>the</strong>re is no need <str<strong>on</strong>g>to</str<strong>on</strong>g> remove it.<br />

One of <strong>the</strong> most important tasks for <strong>the</strong> c<strong>on</strong>figure script is <str<strong>on</strong>g>to</str<strong>on</strong>g> find out if all <strong>the</strong> programs <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> depends <strong>on</strong> are<br />

already present <strong>on</strong> <strong>the</strong> development host. The script will s<str<strong>on</strong>g>to</str<strong>on</strong>g>p with an error message in case something is missing.<br />

If this happens, <strong>the</strong> missing <str<strong>on</strong>g>to</str<strong>on</strong>g>ols have <str<strong>on</strong>g>to</str<strong>on</strong>g> be installed from <strong>the</strong> distributi<strong>on</strong> befor re-running <strong>the</strong> c<strong>on</strong>figure script.<br />

When <strong>the</strong> c<strong>on</strong>figure script is finished successfully, we can now run<br />

$ make<br />

All program parts are being compiled, and if <strong>the</strong>re are no errors we can now install <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> in<str<strong>on</strong>g>to</str<strong>on</strong>g> it’s final locati<strong>on</strong>.<br />

In order <str<strong>on</strong>g>to</str<strong>on</strong>g> write <str<strong>on</strong>g>to</str<strong>on</strong>g> /usr/local, this step has <str<strong>on</strong>g>to</str<strong>on</strong>g> be performed as user root:<br />

$ sudo make install<br />

[enter password]<br />

[...]<br />

10


2 Getting a working Envir<strong>on</strong>ment<br />

If we d<strong>on</strong>’t have root access <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> machine it is also possible <str<strong>on</strong>g>to</str<strong>on</strong>g> install <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> in<str<strong>on</strong>g>to</str<strong>on</strong>g> some o<strong>the</strong>r direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry with<br />

<strong>the</strong> --prefix opti<strong>on</strong>. We need <str<strong>on</strong>g>to</str<strong>on</strong>g> take care that <strong>the</strong> bin/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry below <strong>the</strong> new installati<strong>on</strong> dir is added <str<strong>on</strong>g>to</str<strong>on</strong>g> our<br />

$PATH envir<strong>on</strong>ment variable (for example by exporting it in ˜/.bashrc).<br />

The installati<strong>on</strong> is now d<strong>on</strong>e, so <strong>the</strong> temporary folder may now be removed:<br />

$ cd ../../<br />

$ rm -fr local<br />

2.2.4 C<strong>on</strong>figuring <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g><br />

When using <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> for <strong>the</strong> first time, some setup properties have <str<strong>on</strong>g>to</str<strong>on</strong>g> be c<strong>on</strong>figured. Two settings are <strong>the</strong> most<br />

important <strong>on</strong>es: Where <str<strong>on</strong>g>to</str<strong>on</strong>g> s<str<strong>on</strong>g>to</str<strong>on</strong>g>re <strong>the</strong> source packages and if a proxy must be used <str<strong>on</strong>g>to</str<strong>on</strong>g> gain access <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> world wide<br />

web.<br />

Run <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s setup:<br />

$ ptxdist setup<br />

Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is working with sources <strong>on</strong>ly, it needs various source archives from <strong>the</strong> world wide web. If <strong>the</strong>se<br />

archives are not present <strong>on</strong> our host, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> starts <strong>the</strong> wget command <str<strong>on</strong>g>to</str<strong>on</strong>g> download <strong>the</strong>m <strong>on</strong> demand.<br />

Proxy Setup<br />

To do so, an internet access is required. If this access is managed by a proxy wget command must be adviced <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

use it. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> can be c<strong>on</strong>figured <str<strong>on</strong>g>to</str<strong>on</strong>g> advice <strong>the</strong> wget command au<str<strong>on</strong>g>to</str<strong>on</strong>g>matically: Navigate <str<strong>on</strong>g>to</str<strong>on</strong>g> entry Proxies and enter<br />

<strong>the</strong> required addresses and ports <str<strong>on</strong>g>to</str<strong>on</strong>g> access <strong>the</strong> proxy in <strong>the</strong> form:<br />

://:<br />

Source Archive Locati<strong>on</strong><br />

Whenever <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> downloads source archives it s<str<strong>on</strong>g>to</str<strong>on</strong>g>res <strong>the</strong>se archives in a project local manner. If we are working<br />

with more than <strong>on</strong>e project, every project would download its own required archives. To share all source archives<br />

between all projects <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> can be c<strong>on</strong>figured <str<strong>on</strong>g>to</str<strong>on</strong>g> use <strong>on</strong>ly <strong>on</strong>e archive direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry for all projects it handles: Navigate<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> menu entry Source Direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry and enter <strong>the</strong> path <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry where <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> should s<str<strong>on</strong>g>to</str<strong>on</strong>g>re archives <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

share between projects.<br />

Generic Project Locati<strong>on</strong><br />

If we already installed <strong>the</strong> generic projects we should also c<strong>on</strong>figure <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> know this locati<strong>on</strong>. If we already<br />

did so, we can use <strong>the</strong> command ptxdist projects <str<strong>on</strong>g>to</str<strong>on</strong>g> get a list of available projects and ptxdist cl<strong>on</strong>e <str<strong>on</strong>g>to</str<strong>on</strong>g> get a<br />

local working copy of a shared generic project.<br />

Navigate <str<strong>on</strong>g>to</str<strong>on</strong>g> menu entry Project Searchpath and enter <strong>the</strong> path <str<strong>on</strong>g>to</str<strong>on</strong>g> projects that can be used in such a way. Here<br />

we can c<strong>on</strong>figure more than <strong>on</strong>e path, each part can be delemited by a col<strong>on</strong>. For example for <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s generic<br />

projects and our own previous projects like this:<br />

/usr/local/lib/ptxdist-2011.01.0/projects:/office/my_projects/ptxdist<br />

Leave <strong>the</strong> menu and s<str<strong>on</strong>g>to</str<strong>on</strong>g>re <strong>the</strong> c<strong>on</strong>figurati<strong>on</strong>. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is now ready for use.<br />

11


2 Getting a working Envir<strong>on</strong>ment<br />

2.3 Toolchains<br />

Before we can start building our first userland we need a cross <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain. On Linux, <str<strong>on</strong>g>to</str<strong>on</strong>g>olchains are no m<strong>on</strong>olithic<br />

beasts. Most parts of what we need <str<strong>on</strong>g>to</str<strong>on</strong>g> cross compile code for <strong>the</strong> embedded target comes from <strong>the</strong> GNU Compiler<br />

Collecti<strong>on</strong>, gcc. The gcc packet includes <strong>the</strong> compiler fr<strong>on</strong>tend, gcc, plus several backend <str<strong>on</strong>g>to</str<strong>on</strong>g>ols (cc1, g++, ld etc.)<br />

which actually perform <strong>the</strong> different stages of <strong>the</strong> compile process. gcc does not c<strong>on</strong>tain <strong>the</strong> assembler, so we<br />

also need <strong>the</strong> GNU Binutils package which provides lowlevel stuff.<br />

Cross compilers and <str<strong>on</strong>g>to</str<strong>on</strong>g>ols are usually named like <strong>the</strong> corresp<strong>on</strong>ding host <str<strong>on</strong>g>to</str<strong>on</strong>g>ol, but with a prefix – <strong>the</strong> GNU target.<br />

For example, <strong>the</strong> cross compilers for ARM and powerpc may look like<br />

• arm-softfloat-linux-gnu-gcc<br />

• powerpc-unknown-linux-gnu-gcc<br />

With <strong>the</strong>se compiler fr<strong>on</strong>tends we can c<strong>on</strong>vert e.g. a C program in<str<strong>on</strong>g>to</str<strong>on</strong>g> binary code for specific machines. So for<br />

example if a C program is <str<strong>on</strong>g>to</str<strong>on</strong>g> be compiled natively, it works like this:<br />

$ gcc test.c -o test<br />

To build <strong>the</strong> same binary for <strong>the</strong> ARM architecture we have <str<strong>on</strong>g>to</str<strong>on</strong>g> use <strong>the</strong> cross compiler instead of <strong>the</strong> native <strong>on</strong>e:<br />

$ arm-softfloat-linux-gnu-gcc test.c -o test<br />

Also part of what we c<strong>on</strong>sider <str<strong>on</strong>g>to</str<strong>on</strong>g> be <strong>the</strong> ”<str<strong>on</strong>g>to</str<strong>on</strong>g>olchain” is <strong>the</strong> runtime library (libc, dynamic linker). All programs<br />

running <strong>on</strong> <strong>the</strong> embedded system are linked against <strong>the</strong> libc, which also offers <strong>the</strong> interface from user space<br />

functi<strong>on</strong>s <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> kernel.<br />

The compiler and libc are very tightly coupled comp<strong>on</strong>ents: <strong>the</strong> sec<strong>on</strong>d stage compiler, which is used <str<strong>on</strong>g>to</str<strong>on</strong>g> build<br />

normal user space code, is being built against <strong>the</strong> libc itself. For example, if <strong>the</strong> target does not c<strong>on</strong>tain a hardware<br />

floating point unit, but <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain generates floating point code, it will fail. This is also <strong>the</strong> case when <strong>the</strong><br />

<str<strong>on</strong>g>to</str<strong>on</strong>g>olchain builds code for i686 CPUs, whereas <strong>the</strong> target is i586.<br />

So in order <str<strong>on</strong>g>to</str<strong>on</strong>g> make things working c<strong>on</strong>sistently it is necessary that <strong>the</strong> runtime libc is identical with <strong>the</strong> libc <strong>the</strong><br />

compiler was built against.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> doesn’t c<strong>on</strong>tain a pre-built binary <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain. Remember that it’s not a distributi<strong>on</strong> but a development<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g>ol. But it can be used <str<strong>on</strong>g>to</str<strong>on</strong>g> build a <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain for our target. Building <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain usually has <strong>on</strong>ly <str<strong>on</strong>g>to</str<strong>on</strong>g> be d<strong>on</strong>e<br />

<strong>on</strong>ce. It may be a good idea <str<strong>on</strong>g>to</str<strong>on</strong>g> do that over night, because it may take several hours, depending <strong>on</strong> <strong>the</strong> target<br />

architecture and development host power.<br />

2.3.1 Using Existing Toolchains<br />

If a <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain is already installed which is known <str<strong>on</strong>g>to</str<strong>on</strong>g> be working, <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain building step with <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> may be<br />

omitted.<br />

The OSELAS.BoardSupport() Packages shipped for <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> have been tested with <strong>the</strong> OSE-<br />

LAS.Toolchains() built with <strong>the</strong> same <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> versi<strong>on</strong>. So if an external <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain is being used<br />

which isn’t known <str<strong>on</strong>g>to</str<strong>on</strong>g> be stable, a target may fail. Note that not all compiler versi<strong>on</strong>s and combinati<strong>on</strong>s<br />

work properly in a cross envir<strong>on</strong>ment.<br />

Every OSELAS.BoardSupport() Package checks for its OSELAS.Toolchain it’s tested against, so using a different<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g>olchain vendor requires an additi<strong>on</strong>al step:<br />

Open <strong>the</strong> OSELAS.BoardSupport() Package menu with:<br />

12


2 Getting a working Envir<strong>on</strong>ment<br />

$ ptxdist platformc<strong>on</strong>fig<br />

and navigate <str<strong>on</strong>g>to</str<strong>on</strong>g> architecture ---> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain and check for specific <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain vendor. Clear this entry <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

disable <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain vendor check.<br />

Prec<strong>on</strong>diti<strong>on</strong>s an external <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain must meet:<br />

• it shall be built with <strong>the</strong> c<strong>on</strong>figure opti<strong>on</strong> --with-sysroot pointing <str<strong>on</strong>g>to</str<strong>on</strong>g> its own C libraries.<br />

• it should not support <strong>the</strong> multilib feature as this may c<strong>on</strong>fuse <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> which libraries are <str<strong>on</strong>g>to</str<strong>on</strong>g> select for <strong>the</strong><br />

root filesystem<br />

If we want <str<strong>on</strong>g>to</str<strong>on</strong>g> check if our <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain was built with <strong>the</strong> --with-sysroot opti<strong>on</strong>, we just run this simple command:<br />

$ my<str<strong>on</strong>g>to</str<strong>on</strong>g>olchain-gcc -v 2>&1 | grep with-sysroot<br />

If this command does not output anything, this <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain was not built with <strong>the</strong> --with-sysroot opti<strong>on</strong> and<br />

cannot be used with <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>.<br />

2.3.2 Building a Toolchain<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> handles <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain building as a simple project, like all o<strong>the</strong>r projects, <str<strong>on</strong>g>to</str<strong>on</strong>g>o. So we can download <strong>the</strong><br />

OSELAS.Toolchain bundle and build <strong>the</strong> required <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain for <strong>the</strong> OSELAS.BoardSupport() Package.<br />

A <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> project generally allows <str<strong>on</strong>g>to</str<strong>on</strong>g> build in<str<strong>on</strong>g>to</str<strong>on</strong>g> some project defined direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry; all OSELAS.Toolchain projects<br />

that come with <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> are c<strong>on</strong>figured <str<strong>on</strong>g>to</str<strong>on</strong>g> use <strong>the</strong> standard installati<strong>on</strong> paths menti<strong>on</strong>ed below.<br />

All OSELAS.Toolchain projects install <strong>the</strong>ir result in<str<strong>on</strong>g>to</str<strong>on</strong>g> /opt/OSELAS.Toolchain-1.99.3/.<br />

Usually <strong>the</strong> /opt direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry is not world writeable. So in order <str<strong>on</strong>g>to</str<strong>on</strong>g> build our OSELAS.Toolchain<br />

in<str<strong>on</strong>g>to</str<strong>on</strong>g> that direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry we need <str<strong>on</strong>g>to</str<strong>on</strong>g> use a root account <str<strong>on</strong>g>to</str<strong>on</strong>g> change <strong>the</strong> permissi<strong>on</strong>s. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> detects<br />

this case and asks if we want <str<strong>on</strong>g>to</str<strong>on</strong>g> run sudo <str<strong>on</strong>g>to</str<strong>on</strong>g> do <strong>the</strong> job for us. Alternatively we can enter:<br />

mkdir /opt/OSELAS.Toolchain-1.99.3<br />

chown /opt/OSELAS.Toolchain-1.99.3<br />

chmod a+rwx /opt/OSELAS.Toolchain-1.99.3.<br />

We recommend <str<strong>on</strong>g>to</str<strong>on</strong>g> keep this installati<strong>on</strong> path as <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> expects <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchains at /opt. Whenever we go <str<strong>on</strong>g>to</str<strong>on</strong>g> select<br />

a platform in a project, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> tries <str<strong>on</strong>g>to</str<strong>on</strong>g> find <strong>the</strong> right <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain from data read from <strong>the</strong> platform c<strong>on</strong>figurati<strong>on</strong><br />

settings and a <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain at /opt that matches <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong>se settings. But that’s for our c<strong>on</strong>venience <strong>on</strong>ly. If we decide<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> install <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchains at a different locati<strong>on</strong>, we still can use <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain parameter <str<strong>on</strong>g>to</str<strong>on</strong>g> define <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

be used <strong>on</strong> a per project base.<br />

2.3.3 Building <strong>the</strong> OSELAS.Toolchain for OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0<br />

To compile and install an OSELAS.Toolchain we have <str<strong>on</strong>g>to</str<strong>on</strong>g> extract <strong>the</strong> OSELAS.Toolchain archive, change in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong><br />

new folder, c<strong>on</strong>figure <strong>the</strong> compiler in questi<strong>on</strong> and start <strong>the</strong> build.<br />

The required compiler <str<strong>on</strong>g>to</str<strong>on</strong>g> build <strong>the</strong> OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0 board support package is<br />

arm-v4t-linux-gnueabi_gcc-4.3.2_glibc-2.8_binutils-2.18_kernel-2.6.27-sanitized<br />

13


2 Getting a working Envir<strong>on</strong>ment<br />

So <strong>the</strong> steps <str<strong>on</strong>g>to</str<strong>on</strong>g> build this <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain are:<br />

In order <str<strong>on</strong>g>to</str<strong>on</strong>g> build any of <strong>the</strong> OSELAS.Toolchains, <strong>the</strong> host must provide <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>ol fakeroot. O<strong>the</strong>rwise<br />

<strong>the</strong> message bash: fakeroot: command not found will occur and <strong>the</strong> build s<str<strong>on</strong>g>to</str<strong>on</strong>g>ps.<br />

$ tar xf OSELAS.Toolchain-1.99.3.7.tar.bz2<br />

$ cd OSELAS.Toolchain-1.99.3.7<br />

$ ptxdist select ptxc<strong>on</strong>figs/¿<br />

arm-v4t-linux-gnueabi_gcc-4.3.2_glibc-2.8_binutils-2.18_kernel-2.6.27-sanitized.ptxc<strong>on</strong>fig<br />

$ ptxdist go<br />

At this stage we have <str<strong>on</strong>g>to</str<strong>on</strong>g> go <str<strong>on</strong>g>to</str<strong>on</strong>g> our boss and tell him that it’s probably time <str<strong>on</strong>g>to</str<strong>on</strong>g> go home for <strong>the</strong> day. Even <strong>on</strong><br />

reas<strong>on</strong>ably fast machines <strong>the</strong> time <str<strong>on</strong>g>to</str<strong>on</strong>g> build an OSELAS.Toolchain is something like around 30 minutes up <str<strong>on</strong>g>to</str<strong>on</strong>g> a<br />

few hours.<br />

Measured times <strong>on</strong> different machines:<br />

• Single Pentium 2.5 GHz, 2 GiB RAM: about 2 hours<br />

• Turi<strong>on</strong> ML-34, 2 GiB RAM: about 1 hour 30 minutes<br />

• Dual Athl<strong>on</strong> 2.1 GHz, 2 GiB RAM: about 1 hour 20 minutes<br />

• Dual Quad-Core-Pentium 1.8 GHz, 8 GiB RAM: about 25 minutes<br />

Ano<strong>the</strong>r possibility is <str<strong>on</strong>g>to</str<strong>on</strong>g> read <strong>the</strong> next chapters of this manual, <str<strong>on</strong>g>to</str<strong>on</strong>g> find out how <str<strong>on</strong>g>to</str<strong>on</strong>g> start a new project.<br />

When <strong>the</strong> OSELAS.Toolchain project build is finished, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is ready for prime time and we can c<strong>on</strong>tinue with<br />

our first project.<br />

2.3.4 Protecting <strong>the</strong> Toolchain<br />

All <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain comp<strong>on</strong>ents are built with regular user permissi<strong>on</strong>s. In order <str<strong>on</strong>g>to</str<strong>on</strong>g> avoid accidential changes in <strong>the</strong><br />

<str<strong>on</strong>g>to</str<strong>on</strong>g>olchain, <strong>the</strong> files should be set <str<strong>on</strong>g>to</str<strong>on</strong>g> read-<strong>on</strong>ly permissi<strong>on</strong>s after <strong>the</strong> installati<strong>on</strong> has finished successfully. It is also<br />

possible <str<strong>on</strong>g>to</str<strong>on</strong>g> set <strong>the</strong> file ownership <str<strong>on</strong>g>to</str<strong>on</strong>g> root. This is an important step for reliability, so it is highly recommended.<br />

2.3.5 Building Additi<strong>on</strong>al Toolchains<br />

The OSELAS.Toolchain-1.99.3.7 bundle comes with various predefined <str<strong>on</strong>g>to</str<strong>on</strong>g>olchains. Refer <strong>the</strong> ptxc<strong>on</strong>figs/ folder<br />

for o<strong>the</strong>r definiti<strong>on</strong>s. To build additi<strong>on</strong>al <str<strong>on</strong>g>to</str<strong>on</strong>g>olchains we <strong>on</strong>ly have <str<strong>on</strong>g>to</str<strong>on</strong>g> clean our current <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain project, removing<br />

<strong>the</strong> current selected_ptxc<strong>on</strong>fig link and creating a new <strong>on</strong>e.<br />

$ ptxdist clean<br />

$ rm selected_ptxc<strong>on</strong>fig<br />

$ ptxdist select ptxc<strong>on</strong>figs/any_o<strong>the</strong>r_<str<strong>on</strong>g>to</str<strong>on</strong>g>olchain_def.ptxc<strong>on</strong>fig<br />

$ ptxdist go<br />

All <str<strong>on</strong>g>to</str<strong>on</strong>g>olchains will be installed side by side architecture dependent in<str<strong>on</strong>g>to</str<strong>on</strong>g> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry<br />

/opt/OSELAS.Toolchain-1.99.3/architecture_part.<br />

Different <str<strong>on</strong>g>to</str<strong>on</strong>g>olchains for <strong>the</strong> same architecture will be installed side by side versi<strong>on</strong> dependent in<str<strong>on</strong>g>to</str<strong>on</strong>g> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry<br />

/opt/OSELAS.Toolchain-1.99.3/architecture_part/versi<strong>on</strong>_part.<br />

14


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

This chapter should give any newbie <strong>the</strong> informati<strong>on</strong> he/she needs <str<strong>on</strong>g>to</str<strong>on</strong>g> be able <str<strong>on</strong>g>to</str<strong>on</strong>g> handle any embedded Linux<br />

projects based <strong>on</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>. Also <strong>the</strong> advanced user may find new valueable informati<strong>on</strong>.<br />

3.1 <str<strong>on</strong>g>How</str<strong>on</strong>g> does it work?<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> supports various aspects of <strong>the</strong> daily work <str<strong>on</strong>g>to</str<strong>on</strong>g> develop, deploy and maintain an embedded Linux based<br />

project.<br />

Figure 3.1: Objectives in a project<br />

The most important part is <strong>the</strong> development. For this project phase, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides features <str<strong>on</strong>g>to</str<strong>on</strong>g> ensure reproducibility<br />

and verifiability.<br />

3.1.1 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s percepti<strong>on</strong> of <strong>the</strong> world<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> works project centric. A <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> project c<strong>on</strong>tains all informati<strong>on</strong> and files <str<strong>on</strong>g>to</str<strong>on</strong>g> populate any kind of target<br />

system with all required software comp<strong>on</strong>ents.<br />

• Specific c<strong>on</strong>figurati<strong>on</strong> for<br />

– Bootloader<br />

– Kernel<br />

– Userland (root filesystem)<br />

• Adapted files (or generic <strong>on</strong>es) for runtime c<strong>on</strong>figurati<strong>on</strong><br />

• Patches for all kind of comp<strong>on</strong>ents (<str<strong>on</strong>g>to</str<strong>on</strong>g> fix bugs or improve features)<br />

15


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

Some of <strong>the</strong>se informati<strong>on</strong> or files are coming from <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> base installati<strong>on</strong> (patches for example), but also<br />

can be part of <strong>the</strong> project itself. By this way, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> can be adapted <str<strong>on</strong>g>to</str<strong>on</strong>g> any kind of requirement.<br />

Most users are fine with <strong>the</strong> informati<strong>on</strong> and files <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> base installati<strong>on</strong> provides. Development of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g><br />

is d<strong>on</strong>e in a way <str<strong>on</strong>g>to</str<strong>on</strong>g> find default settings most user can work with. But advanced users can still adapt <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong>ir special<br />

needs.<br />

As stated above, a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> project c<strong>on</strong>sists of all required parts, some of <strong>the</strong>se parts are separated by design:<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> separates a platform c<strong>on</strong>figurati<strong>on</strong> from userland c<strong>on</strong>figurati<strong>on</strong> (root filesystem). So, platforms can share<br />

a comm<strong>on</strong> userland c<strong>on</strong>figurati<strong>on</strong>, but use a specific kernel c<strong>on</strong>figurati<strong>on</strong> in <strong>the</strong>ir own platform c<strong>on</strong>figurati<strong>on</strong>.<br />

Collecting various platforms in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>on</strong>e single project should help <str<strong>on</strong>g>to</str<strong>on</strong>g> maintain such projects. But some platforms<br />

do need special userland (think about graphic/n<strong>on</strong> graphic platforms). To be able <str<strong>on</strong>g>to</str<strong>on</strong>g> also collect this requirement<br />

in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>on</strong>e single project, so called collecti<strong>on</strong>s are supported. With this feature, a user can c<strong>on</strong>figure a full featured<br />

main userland, reduced via a collecti<strong>on</strong> by some comp<strong>on</strong>ents for a specific platform where it makes no sense <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

build and ship <strong>the</strong>m.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> can handle <strong>the</strong> following project variati<strong>on</strong>s:<br />

• <strong>on</strong>e hardware platform, <strong>on</strong>e userland c<strong>on</strong>figurati<strong>on</strong> (comm<strong>on</strong> case)<br />

• <strong>on</strong>e hardware platform, various userland c<strong>on</strong>figurati<strong>on</strong>s<br />

• various hardware platforms, <strong>on</strong>e userland c<strong>on</strong>figurati<strong>on</strong> (comm<strong>on</strong> case)<br />

• various hardware platforms, <strong>on</strong>e userland c<strong>on</strong>figurati<strong>on</strong>, various collecti<strong>on</strong>s<br />

• various hardware platforms, various userland c<strong>on</strong>figurati<strong>on</strong><br />

• various hardware platforms, various userland c<strong>on</strong>figurati<strong>on</strong>, various collecti<strong>on</strong>s<br />

3.1.2 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s build process<br />

When <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is building <strong>on</strong>e part (we call it a package)of <strong>the</strong> whole project, it is divided in<str<strong>on</strong>g>to</str<strong>on</strong>g> up <str<strong>on</strong>g>to</str<strong>on</strong>g> six stages:<br />

get The package will be obtained from its source (downloaded from <strong>the</strong> web for example)<br />

extract The package archive gets extracted and patched if a patch set for this package exists<br />

prepare Many packages can be c<strong>on</strong>figured in various ways. If supported, this stage does <strong>the</strong> c<strong>on</strong>figurati<strong>on</strong> in a<br />

way defined in <strong>the</strong> menu (project specific)<br />

compile The package gets built.<br />

install The package installs itself in<str<strong>on</strong>g>to</str<strong>on</strong>g> a project local direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. This step is important at least for libraries (o<strong>the</strong>r<br />

packages may depend <strong>on</strong>)<br />

targetinstall Relevant parts of <strong>the</strong> package will be used <str<strong>on</strong>g>to</str<strong>on</strong>g> build an IPKG archive and <strong>the</strong> root filesystem<br />

For each single package, <strong>on</strong>e so called rule file exists, describing <strong>the</strong> steps <str<strong>on</strong>g>to</str<strong>on</strong>g> be d<strong>on</strong>e in each stage shown above<br />

(refer secti<strong>on</strong> 5.3 for fur<strong>the</strong>r details).<br />

Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> get stage, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> needs a working internet c<strong>on</strong>necti<strong>on</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g> download an archive currently not existing<br />

<strong>on</strong> <strong>the</strong> development host. But <strong>the</strong>re are ways <str<strong>on</strong>g>to</str<strong>on</strong>g> prevent <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> from doing so (refer <str<strong>on</strong>g>to</str<strong>on</strong>g> secti<strong>on</strong> 2.2.4).<br />

3.2 First steps with <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g><br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> works as a c<strong>on</strong>sole command <str<strong>on</strong>g>to</str<strong>on</strong>g>ol. Everything we want <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> do, we have <str<strong>on</strong>g>to</str<strong>on</strong>g> enter as a command.<br />

But it’s always <strong>the</strong> same base command:<br />

16


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

Figure 3.2: The build process<br />

$ ptxdist <br />

To run different functi<strong>on</strong>s, this command must be extended by parameters <str<strong>on</strong>g>to</str<strong>on</strong>g> define <strong>the</strong> functi<strong>on</strong> we want <str<strong>on</strong>g>to</str<strong>on</strong>g> run.<br />

If we are unsure what parameter must be given <str<strong>on</strong>g>to</str<strong>on</strong>g> obtain a special functi<strong>on</strong>, we run it with <strong>the</strong> parameter help.<br />

$ ptxdist help<br />

This will output all possible parameters ans subcommands and <strong>the</strong>ir meaning.<br />

As <strong>the</strong> list we see is very l<strong>on</strong>g, let’s explain <strong>the</strong> major parameters usually needed for daily usage:<br />

menu This starts a dialog based fr<strong>on</strong>tend for those who do not like typing commands. It will gain us access <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

<strong>the</strong> most comm<strong>on</strong> parameters <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure and build a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> project.<br />

menuc<strong>on</strong>fig Starts <strong>the</strong> Kc<strong>on</strong>fig based project c<strong>on</strong>figura<str<strong>on</strong>g>to</str<strong>on</strong>g>r for <strong>the</strong> current selected userland c<strong>on</strong>figurati<strong>on</strong>. This<br />

menu will give us access <str<strong>on</strong>g>to</str<strong>on</strong>g> various userland comp<strong>on</strong>ents that <strong>the</strong> root filesystem of our target should<br />

c<strong>on</strong>sist of.<br />

platformc<strong>on</strong>fig Starts <strong>the</strong> Kc<strong>on</strong>fig based platform c<strong>on</strong>figura<str<strong>on</strong>g>to</str<strong>on</strong>g>r. This menu lets us set up all target specific settings.<br />

Major parts are:<br />

• Toolchain (architecture and revisi<strong>on</strong>)<br />

• boot loader<br />

• root filesystem image type<br />

• Linux kernel (revisi<strong>on</strong>)<br />

Note: A <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> project can c<strong>on</strong>sist of more than <strong>on</strong>e platform c<strong>on</strong>figurati<strong>on</strong> at <strong>the</strong> same time.<br />

kernelc<strong>on</strong>fig Runs <strong>the</strong> standard Linux kernel Kc<strong>on</strong>fig <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure <strong>the</strong> kernel for <strong>the</strong> current selected platform.<br />

To run this feature, <strong>the</strong> kernel must be already set up for this platform.<br />

17


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

menuc<strong>on</strong>fig collecti<strong>on</strong> If multiple platforms are sharing <strong>on</strong>e userland c<strong>on</strong>figurati<strong>on</strong>, collecti<strong>on</strong>s can define a<br />

subset of all selected packages for specific platforms. This is an advanced feature, rarely used.<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g>olchain Sets up <strong>the</strong> path <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain used <str<strong>on</strong>g>to</str<strong>on</strong>g> compile <strong>the</strong> current selected platform. Without an additi<strong>on</strong>al<br />

parameter, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> tries <str<strong>on</strong>g>to</str<strong>on</strong>g> guess <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain from platform settings. To be successful, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> depends<br />

<strong>on</strong> <strong>the</strong> OSELAS.Toolchains installed <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> /opt direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />

If <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> wasn’t able <str<strong>on</strong>g>to</str<strong>on</strong>g> au<str<strong>on</strong>g>to</str<strong>on</strong>g>detect <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain, an additi<strong>on</strong>al parameter can be given <str<strong>on</strong>g>to</str<strong>on</strong>g> provide <strong>the</strong><br />

path <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> compiler, assembler, linker and so <strong>on</strong>.<br />

select Used <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>the</strong> current userland c<strong>on</strong>figurati<strong>on</strong>, which is <strong>on</strong>ly required if <strong>the</strong>re is no selected_ptxc<strong>on</strong>fig<br />

in <strong>the</strong> project’s main direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. This parameter needs <strong>the</strong> path <str<strong>on</strong>g>to</str<strong>on</strong>g> a valid ptxc<strong>on</strong>fig. It will generate a soft<br />

link called selected_ptxc<strong>on</strong>fig in <strong>the</strong> project’s main direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />

platform Used <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>the</strong> current platform c<strong>on</strong>figurati<strong>on</strong>, which is <strong>on</strong>ly required if <strong>the</strong>re is no selected_platformc<strong>on</strong>fig<br />

in <strong>the</strong> project’s main direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. This parameter needs <strong>the</strong> path <str<strong>on</strong>g>to</str<strong>on</strong>g> a valid<br />

platformc<strong>on</strong>fig. It will generate a soft link called selected_platformc<strong>on</strong>fig in <strong>the</strong> project’s main direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />

collecti<strong>on</strong> Used <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>the</strong> current collecti<strong>on</strong> c<strong>on</strong>figurati<strong>on</strong>, which is <strong>on</strong>ly required in special cases. This parameter<br />

needs <strong>the</strong> path <str<strong>on</strong>g>to</str<strong>on</strong>g> a valid collecti<strong>on</strong>. It will generate a soft link called selected_collecti<strong>on</strong> in <strong>the</strong><br />

project’s main direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. This is an advanced feature, rarely used.<br />

go The mostly used command. This will start <str<strong>on</strong>g>to</str<strong>on</strong>g> build everything <str<strong>on</strong>g>to</str<strong>on</strong>g> get all <strong>the</strong> project defined software parts.<br />

Also used <str<strong>on</strong>g>to</str<strong>on</strong>g> rebuild a part after its c<strong>on</strong>figurati<strong>on</strong> was changed.<br />

images Used at <strong>the</strong> end of a build <str<strong>on</strong>g>to</str<strong>on</strong>g> create an image from all userland packages <str<strong>on</strong>g>to</str<strong>on</strong>g> deploy <strong>the</strong> target (its flash<br />

for example or its hard disk).<br />

setup Mostly run <strong>on</strong>ce per <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> revisi<strong>on</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g> set up global paths and <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> behavior.<br />

All <strong>the</strong>se commands depending <strong>on</strong> various files a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> based project provides. So, running <strong>the</strong> commands<br />

make <strong>on</strong>ly sense in direc<str<strong>on</strong>g>to</str<strong>on</strong>g>rys that c<strong>on</strong>tains a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> based project. O<strong>the</strong>rwise <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> gets c<strong>on</strong>fused and c<strong>on</strong>fuses<br />

<strong>the</strong> user with funny error messages.<br />

To show <strong>the</strong> usage of some listed major subcommands, we are using a generic <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> based project.<br />

3.2.1 Extracting <strong>the</strong> Board Support Package<br />

In order <str<strong>on</strong>g>to</str<strong>on</strong>g> work with a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> based project we have <str<strong>on</strong>g>to</str<strong>on</strong>g> extract <strong>the</strong> archive first.<br />

$ tar -zxf OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0.tar.gz<br />

$ cd OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is project centric, so now after changing in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> new direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry we have access <str<strong>on</strong>g>to</str<strong>on</strong>g> all valid comp<strong>on</strong>ents.<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g>tal 32<br />

-rw-r--r-- 1 jb users 1060 Jul 1 16:33 ChangeLog<br />

-rw-r--r-- 1 jb users 741 Jul 1 15:12 README<br />

drwxr-xr-x 5 jb users 4096 Jul 1 15:17 c<strong>on</strong>figs<br />

drwxr-xr-x 3 jb users 4096 Jul 1 16:51 documentati<strong>on</strong><br />

drwxr-xr-x 5 jb users 4096 Jul 1 15:12 local_src<br />

drwxr-xr-x 4 jb users 4096 Jul 1 15:12 patches<br />

drwxr-xr-x 5 jb users 4096 Jul 1 15:12 projectroot<br />

drwxr-xr-x 3 jb users 4096 Jul 1 15:12 rules<br />

18


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

Notes about some of <strong>the</strong> files and direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries listed above:<br />

ChangeLog Here you can read what has changed in this release. Note: This file does not always exist.<br />

documentati<strong>on</strong> If this BSP is <strong>on</strong>e of our OSELAS BSPs, this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry c<strong>on</strong>tains <strong>the</strong> Quickstart you are currenly<br />

reading in.<br />

c<strong>on</strong>figs A multiplatform BSP c<strong>on</strong>tains c<strong>on</strong>figurati<strong>on</strong>s for more than <strong>on</strong>e target. This direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry c<strong>on</strong>tains <strong>the</strong> respective<br />

platform c<strong>on</strong>figurati<strong>on</strong> files.<br />

projectroot C<strong>on</strong>tains files and c<strong>on</strong>figurati<strong>on</strong> for <strong>the</strong> target’s runtime. A running GNU/Linux system uses many<br />

text files for runtime c<strong>on</strong>figurati<strong>on</strong>. Most of <strong>the</strong> time, <strong>the</strong> generic files from <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> installati<strong>on</strong> will fit<br />

<strong>the</strong> needs. But if not, cus<str<strong>on</strong>g>to</str<strong>on</strong>g>mized files are located in this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />

rules If something special is required <str<strong>on</strong>g>to</str<strong>on</strong>g> build <strong>the</strong> BSP for <strong>the</strong> target it is intended for, <strong>the</strong>n this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry c<strong>on</strong>tains<br />

<strong>the</strong>se additi<strong>on</strong>al rules.<br />

patches If some special patches are required <str<strong>on</strong>g>to</str<strong>on</strong>g> build <strong>the</strong> BSP for this target, <strong>the</strong>n this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry c<strong>on</strong>tains <strong>the</strong>se<br />

patches <strong>on</strong> a per package basis.<br />

tests C<strong>on</strong>tains test scripts for au<str<strong>on</strong>g>to</str<strong>on</strong>g>mated target setup.<br />

Next we will build <strong>the</strong> OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0 <str<strong>on</strong>g>to</str<strong>on</strong>g> show some of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s main features.<br />

3.2.2 Selecting a Userland C<strong>on</strong>figurati<strong>on</strong><br />

First of all we have <str<strong>on</strong>g>to</str<strong>on</strong>g> select a userland c<strong>on</strong>figurati<strong>on</strong>. This step defines what kind of applicati<strong>on</strong>s will be built for<br />

<strong>the</strong> hardware platform. The OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0 comes with a predefined c<strong>on</strong>figurati<strong>on</strong><br />

we select in <strong>the</strong> following step:<br />

$ ptxdist select c<strong>on</strong>figs/ptxc<strong>on</strong>fig<br />

info: selected ptxc<strong>on</strong>fig:<br />

’c<strong>on</strong>figs/ptxc<strong>on</strong>fig’<br />

3.2.3 Selecting a Hardware Platform<br />

Before we can build this BSP, we need <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>on</strong>e of <strong>the</strong> possible platforms <str<strong>on</strong>g>to</str<strong>on</strong>g> build for. In this case we want <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

build for <strong>the</strong> Versatilepb:<br />

$ ptxdist platform c<strong>on</strong>figs/arm-qemu-2011.01.0/platformc<strong>on</strong>fig<br />

info: selected platformc<strong>on</strong>fig:<br />

’c<strong>on</strong>figs/arm-qemu-2011.01.0/platformc<strong>on</strong>fig’<br />

Note: If you have installed <strong>the</strong> OSELAS.Toolchain() at its default locati<strong>on</strong>, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> should already have detected<br />

<strong>the</strong> proper <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain while selecting <strong>the</strong> platform. In this case it will output:<br />

found and using <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain:<br />

’/opt/OSELAS.Toolchain-1.99.3/arm-v4t-linux-gnueabi/¿<br />

gcc-4.3.2-glibc-2.8-binutils-2.18-kernel-2.6.27-sanitized/bin’<br />

If it fails you can c<strong>on</strong>tinue <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain manually as menti<strong>on</strong>ed in <strong>the</strong> next secti<strong>on</strong>. If this au<str<strong>on</strong>g>to</str<strong>on</strong>g>detecti<strong>on</strong><br />

was successful, we can omit <strong>the</strong> steps of <strong>the</strong> secti<strong>on</strong> and c<strong>on</strong>tinue <str<strong>on</strong>g>to</str<strong>on</strong>g> build <strong>the</strong> BSP.<br />

19


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

3.2.4 Selecting a Toolchain<br />

If not au<str<strong>on</strong>g>to</str<strong>on</strong>g>matically detected, <strong>the</strong> last step in selecting various c<strong>on</strong>figurati<strong>on</strong>s is <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain <str<strong>on</strong>g>to</str<strong>on</strong>g> be used<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> build everything for <strong>the</strong> target.<br />

$ ptxdist <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain /opt/OSELAS.Toolchain-1.99.3/arm-v4t-linux-gnueabi/¿<br />

gcc-4.3.2-glibc-2.8-binutils-2.18-kernel-2.6.27-sanitized/bin<br />

3.2.5 Building <strong>the</strong> Root Filesystem C<strong>on</strong>tent<br />

Now everything is prepared for <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> compile <strong>the</strong> BSP. Starting <strong>the</strong> engines is simply d<strong>on</strong>e with:<br />

$ ptxdist go<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> does now au<str<strong>on</strong>g>to</str<strong>on</strong>g>matically find out from <strong>the</strong> selected_ptxc<strong>on</strong>fig and selected_platformc<strong>on</strong>fig files which<br />

packages bel<strong>on</strong>g <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> project and starts compiling <strong>the</strong>ir targetinstall stages (that <strong>on</strong>e that actually puts <strong>the</strong> compiled<br />

binaries in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root filesystem). While doing this, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> finds out about all <strong>the</strong> dependencies between<br />

<strong>the</strong> packages and builds <strong>the</strong>m in correct order.<br />

3.2.6 What we Got Now<br />

After building <strong>the</strong> project, we find even more sub direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries in our project.<br />

platform-versatilepb/build-cross C<strong>on</strong>tains all packages sources compiled <str<strong>on</strong>g>to</str<strong>on</strong>g> run <strong>on</strong> <strong>the</strong> host and handle target<br />

architecture dependend things.<br />

platform-versatilepb/build-host C<strong>on</strong>tains all packages sources compiled <str<strong>on</strong>g>to</str<strong>on</strong>g> run <strong>on</strong> <strong>the</strong> host and handle architecture<br />

independend things.<br />

platform-versatilepb/build-target C<strong>on</strong>tains all package sources compiled for <strong>the</strong> target architecure.<br />

platform-versatilepb/images Generated files for <strong>the</strong> target can be found here: Kernel image and root filesystem<br />

image.<br />

platform-versatilepb/packages Locati<strong>on</strong> for alle individual packages in ipk format.<br />

platform-versatilepb/sysroot-target C<strong>on</strong>tains everything target architecture dependend (libraries, header files<br />

and so <strong>on</strong>).<br />

platform-versatilepb/sysroot-cross C<strong>on</strong>tains everything that is host specific but must handle target architecture<br />

data.<br />

platform-versatilepb/sysroot-host C<strong>on</strong>tains everything that is <strong>on</strong>ly host specific.<br />

platform-versatilepb/root Target’s root filesystem image. This direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry can be mounted as an NFS root for<br />

example.<br />

Note: Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>on</strong>ly root can create device nodes and <strong>the</strong> build system must be run as a n<strong>on</strong> root user, <strong>the</strong>re is<br />

no device node present in this image. At least /dev/c<strong>on</strong>sole, /dev/null and /dev/zero should exist. Create<br />

<strong>the</strong>m as user root manually in order <str<strong>on</strong>g>to</str<strong>on</strong>g> use this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry as an NFS root.<br />

platform-versatilepb/root-debug Target’s root filesystem image. The difference <str<strong>on</strong>g>to</str<strong>on</strong>g> root/ is, all programs and<br />

libraries in this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry still have <strong>the</strong>ir debug informati<strong>on</strong> present. This direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry is intended <str<strong>on</strong>g>to</str<strong>on</strong>g> be used<br />

as system root for a debugger. To be used by <strong>the</strong> debugger, you should setup your debugger with<br />

set solib-absolute-prefix /root-debug<br />

20


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

platform-versatilepb/state Building every package is divided <strong>on</strong><str<strong>on</strong>g>to</str<strong>on</strong>g> stages. And stages of <strong>on</strong>e package can depend<br />

<strong>on</strong> stages of o<strong>the</strong>r packages. In order <str<strong>on</strong>g>to</str<strong>on</strong>g> handle this correctly, this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry c<strong>on</strong>tains timestamp files<br />

about finished stages.<br />

This are <strong>the</strong> generated files:<br />

platform-versatilepb/logfile Every run of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> will add its output <str<strong>on</strong>g>to</str<strong>on</strong>g> this file. If something fails, this file can<br />

help <str<strong>on</strong>g>to</str<strong>on</strong>g> find <strong>the</strong> cause.<br />

3.2.7 Creating a Root Filesystem Image<br />

After we have built <strong>the</strong> root filesystem c<strong>on</strong>tent, we can make an image, which can be flashed <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> target system<br />

or copied <strong>on</strong> some kind of disk media. To do so, we just run<br />

$ ptxdist images<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> now extracts <strong>the</strong> c<strong>on</strong>tent of priorly created *.ipk packages <str<strong>on</strong>g>to</str<strong>on</strong>g> a temporary direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry and generates an<br />

image out of it. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> supports following image types:<br />

• hd.img: c<strong>on</strong>tains bootloader, kernel and root files in an ext2 partiti<strong>on</strong>. Mostly used for X86 target systems.<br />

• root.jffs2: root files inside a jffs2 filesystem.<br />

• uRamdisk: a u-boot loadable Ramdisk<br />

• initrd.gz: a traditi<strong>on</strong>al initrd RAM disk <str<strong>on</strong>g>to</str<strong>on</strong>g> be used as initrdramfs by <strong>the</strong> kernel<br />

• root.ext2: root files inside an ext2 filesystem.<br />

• root.squashfs: root files inside a squashfs filesystem.<br />

• root.tgz: root files inside a plain gzip compressed tar ball.<br />

All <strong>the</strong>se files can be found in platform-versatilepb/images.<br />

3.2.8 Running all Parts in an emulated Envir<strong>on</strong>ment (QEMU)<br />

The OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0 is prepared <str<strong>on</strong>g>to</str<strong>on</strong>g> give every user a chance <str<strong>on</strong>g>to</str<strong>on</strong>g> run <strong>the</strong> results of <strong>the</strong><br />

previous steps even in <strong>the</strong> absense of real hardware. All we need is a working QEMU <strong>on</strong> our development host.<br />

Simply run<br />

$ ./c<strong>on</strong>figs/arm-qemu-2011.01.0/run<br />

This will start QEMU in full system emulati<strong>on</strong> mode and runs <strong>the</strong> previously built kernel which <strong>the</strong>n uses <strong>the</strong><br />

generated disk image <str<strong>on</strong>g>to</str<strong>on</strong>g> bring up a full Linux based system.<br />

The running system uses a serial device for its communicati<strong>on</strong>. QEMU forwards this emulated device <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong><br />

current development host c<strong>on</strong>sole. So, we can watch <strong>the</strong> starting kernel’s output and log in <strong>on</strong> this system.<br />

Note: Log in as user ’root’ with no password (just enter).<br />

Also a telnet deam<strong>on</strong> is running in this emulati<strong>on</strong>. QEMU is c<strong>on</strong>figured <str<strong>on</strong>g>to</str<strong>on</strong>g> forward <strong>the</strong> standard telnet port 23 of<br />

<strong>the</strong> emulated system <str<strong>on</strong>g>to</str<strong>on</strong>g> host’s port 4444. To c<strong>on</strong>nect <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> emulated system, we can just run a<br />

$ telnet localhost 4444<br />

Trying 127.0.0.1...<br />

C<strong>on</strong>nected <str<strong>on</strong>g>to</str<strong>on</strong>g> localhost.<br />

Escape character is ’]’.<br />

21


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

ptx login: root<br />

root@ptx:~<br />

Leaving <strong>the</strong> emulated envir<strong>on</strong>ment happens by entering <strong>the</strong> key sequence CTRL-A X in <strong>the</strong> development host<br />

c<strong>on</strong>sole.<br />

3.3 Adapting <strong>the</strong> OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0 Project<br />

Handling a fully prepared <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> project is easy. But everything is fixed <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> settings <strong>the</strong> developer selected.<br />

We now want <str<strong>on</strong>g>to</str<strong>on</strong>g> adapt <strong>the</strong> OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0 project in a few simple settings.<br />

3.3.1 Working with Kc<strong>on</strong>fig<br />

Whenever we modify our project, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is using Kc<strong>on</strong>fig <str<strong>on</strong>g>to</str<strong>on</strong>g> manipulate <strong>the</strong> settings. Kc<strong>on</strong>fig means kernel c<strong>on</strong>figura<str<strong>on</strong>g>to</str<strong>on</strong>g>r<br />

and was mainly developed <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure <strong>the</strong> Linux kernel itself. But it is easy <str<strong>on</strong>g>to</str<strong>on</strong>g> adapt, <str<strong>on</strong>g>to</str<strong>on</strong>g> use and so<br />

popular that more and more projects are using Kc<strong>on</strong>fig for <strong>the</strong>ir purposes. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is <strong>on</strong>e of <strong>the</strong>m.<br />

What is Kc<strong>on</strong>fig<br />

It is a user interface <str<strong>on</strong>g>to</str<strong>on</strong>g> select given resources in a c<strong>on</strong>venient way. The resources that we can select are given in<br />

simple text files. It uses a powerful ”language” in <strong>the</strong>se text files <str<strong>on</strong>g>to</str<strong>on</strong>g> organize <strong>the</strong>m in a hierarchical manner, solves<br />

challenges like resource dependencies, supports help and search features. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> uses all of <strong>the</strong>se features.<br />

Kc<strong>on</strong>fig supports a text based user interface by using <strong>the</strong> ncurses library <str<strong>on</strong>g>to</str<strong>on</strong>g> manipulate <strong>the</strong> screen c<strong>on</strong>tent and<br />

should work <strong>on</strong> nearly all host systems.<br />

For example running <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s menuc<strong>on</strong>fig subcommand in this way<br />

$ ptxdist menuc<strong>on</strong>fig<br />

will show <strong>the</strong> following c<strong>on</strong>sole output<br />

Navigate in Kc<strong>on</strong>fig menu (select, search, ...)<br />

To navigate through <strong>the</strong> c<strong>on</strong>figurati<strong>on</strong> tree, we are using <strong>the</strong> arrow keys. Up and down navigates vertically in <strong>the</strong><br />

menu entries. Right and left navigates between Select, Exit and Help (in <strong>the</strong> bot<str<strong>on</strong>g>to</str<strong>on</strong>g>m part of our visual screen).<br />

To enter <strong>on</strong>e of <strong>the</strong> menus, we navigate <str<strong>on</strong>g>to</str<strong>on</strong>g> this entry <str<strong>on</strong>g>to</str<strong>on</strong>g> highlight it and press <strong>the</strong> Enter key. To leave it, we select<br />

Exit and press <strong>the</strong> Enter key again. There are shortcuts available, instead of pressing <strong>the</strong> Enter key <str<strong>on</strong>g>to</str<strong>on</strong>g> enter a menu<br />

we also can press alt-s and <str<strong>on</strong>g>to</str<strong>on</strong>g> leave a menu alt-e. Also an ESC double hit leaves any menu we are in.<br />

To select a menu entry, we use <strong>the</strong> Space key. This will <str<strong>on</strong>g>to</str<strong>on</strong>g>ggle <strong>the</strong> selecti<strong>on</strong>. Or, <str<strong>on</strong>g>to</str<strong>on</strong>g> be more precise and faster, we<br />

use <strong>the</strong> key y <str<strong>on</strong>g>to</str<strong>on</strong>g> select an entry, and key n <str<strong>on</strong>g>to</str<strong>on</strong>g> deselect it.<br />

To get help for a specific menu <str<strong>on</strong>g>to</str<strong>on</strong>g>pic, we navigate vertically <str<strong>on</strong>g>to</str<strong>on</strong>g> highlight it and horiz<strong>on</strong>tally <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>the</strong> Help entry.<br />

Then we can press Enter <str<strong>on</strong>g>to</str<strong>on</strong>g> see <strong>the</strong> help.<br />

To search for specific keywords, we press <strong>the</strong> / key and enter a word. Kc<strong>on</strong>fig <strong>the</strong>n lists all occurences of this word<br />

in all menus.<br />

22


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

Figure 3.3: Main userland c<strong>on</strong>figurati<strong>on</strong> menu<br />

Meaning of visual feedbacks in Kc<strong>on</strong>fig<br />

• Submenus <str<strong>on</strong>g>to</str<strong>on</strong>g> enter are marked with a trailing ---><br />

Note: Some submenus are also marked with a leading bracket [ ]. To enter <strong>the</strong>m we first must select/enable<br />

<strong>the</strong>m [*]<br />

• Entries with a list of selectable alternatives are also marked with a trailing ---><br />

• Entries we can select are marked with a leading empty bracket [ ]<br />

• Entries that are already selected are marked with a leading filled bracket [*]<br />

• Entries that are selected due <str<strong>on</strong>g>to</str<strong>on</strong>g> dependencies in<str<strong>on</strong>g>to</str<strong>on</strong>g> o<strong>the</strong>r selected entries are marked with a leading -*-<br />

• Some entries need a free text <str<strong>on</strong>g>to</str<strong>on</strong>g> enter, <strong>the</strong>y are marked with leading brackets () and <strong>the</strong> free text in it<br />

Menus and submenus in Kc<strong>on</strong>fig (secti<strong>on</strong>ing)<br />

There are dozens of entries in <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> c<strong>on</strong>figuring menus. To handle <strong>the</strong>m, <strong>the</strong>y are divided and separated<br />

in<str<strong>on</strong>g>to</str<strong>on</strong>g> logical units.<br />

The main building blocks in <strong>the</strong> userland c<strong>on</strong>figurati<strong>on</strong> menu are:<br />

• Host Opti<strong>on</strong>s: Some parts of <strong>the</strong> project are build host relevant <strong>on</strong>ly. For example <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> can build <strong>the</strong><br />

DDD debugger <str<strong>on</strong>g>to</str<strong>on</strong>g> debug applicati<strong>on</strong>s running <strong>on</strong> <strong>the</strong> target.<br />

23


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

• Root Filesystem: Settings <str<strong>on</strong>g>to</str<strong>on</strong>g> arrange target’s root filesystem and <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>the</strong> main C runtime library<br />

• Applicati<strong>on</strong>s: Everything we like <str<strong>on</strong>g>to</str<strong>on</strong>g> run <strong>on</strong> your target.<br />

The main building blocks in <strong>the</strong> platform c<strong>on</strong>figurati<strong>on</strong> menu are:<br />

• Architecture: Basic settings, like <strong>the</strong> main and sub architecture <strong>the</strong> target system uses, <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain <str<strong>on</strong>g>to</str<strong>on</strong>g> be<br />

used <str<strong>on</strong>g>to</str<strong>on</strong>g> build everything and some o<strong>the</strong>r architecture dependent settings.<br />

• Linux kernel: Which kernel revisi<strong>on</strong> and kernel c<strong>on</strong>figurati<strong>on</strong> should be used<br />

• Bootloader: Which bootloader (if any) should be built in <strong>the</strong> project<br />

• The kind of image <str<strong>on</strong>g>to</str<strong>on</strong>g> populate a root filesystem in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> target system<br />

The main building blocks in <strong>the</strong> board setup c<strong>on</strong>figurati<strong>on</strong> menu are:<br />

• Network: Network settings for <strong>the</strong> target<br />

• Host: Host setup <str<strong>on</strong>g>to</str<strong>on</strong>g> be able <str<strong>on</strong>g>to</str<strong>on</strong>g> reach <strong>the</strong> target system<br />

At this point it could be useful <str<strong>on</strong>g>to</str<strong>on</strong>g> walk <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> whole menus and <strong>the</strong>ir submenus <str<strong>on</strong>g>to</str<strong>on</strong>g> get an idea about <strong>the</strong> amount<br />

of features and applicati<strong>on</strong>s <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> currently supports.<br />

3.3.2 Adapting Platform Settings<br />

Some parts of <strong>the</strong> OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0 project are platform specific (in c<strong>on</strong>trast <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong><br />

userland c<strong>on</strong>figurati<strong>on</strong> that could be shared between platforms). We now want <str<strong>on</strong>g>to</str<strong>on</strong>g> change <strong>the</strong> used Linux kernel<br />

of our current arm-qemu-2011.01.0 platform. It comes with a default linux-2.6.32 and we want <str<strong>on</strong>g>to</str<strong>on</strong>g> change it <str<strong>on</strong>g>to</str<strong>on</strong>g> a<br />

more recent linux-2.6.37.<br />

To do so, we run:<br />

$ ptxdist menuc<strong>on</strong>fig platform<br />

In this Kc<strong>on</strong>fig dialogue we navigate <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> entry:<br />

[*] Linux kernel ---><br />

(2.6.32) kernel versi<strong>on</strong><br />

and replace <strong>the</strong> 2.6.32 value by <strong>the</strong> 2.6.37 value. Now we leave <strong>the</strong> menu and save <strong>the</strong> new settings.<br />

A Linux kernel needs a c<strong>on</strong>figurati<strong>on</strong> for being built correctly. The OSELAS.BSP-Pengutr<strong>on</strong>ix-Generic-2011.01.0<br />

project comes with a prepared c<strong>on</strong>figurati<strong>on</strong> in <strong>the</strong> file c<strong>on</strong>figs/arm-qemu-2011.01.0/kernelc<strong>on</strong>fig-2.6.32 for<br />

<strong>the</strong> 2.6.32 kernel.<br />

It is always a good idea <str<strong>on</strong>g>to</str<strong>on</strong>g> start with a known-<str<strong>on</strong>g>to</str<strong>on</strong>g>-work kernel c<strong>on</strong>figurati<strong>on</strong>. So, for this example, we are using a<br />

different known-<str<strong>on</strong>g>to</str<strong>on</strong>g>-work kernel c<strong>on</strong>figurati<strong>on</strong> in <strong>the</strong> c<strong>on</strong>figs/arm-qemu-2011.01.0/kernelc<strong>on</strong>fig-2.6.37 file for<br />

our new 2.6.37 kernel.<br />

3.3.3 Adapting Linux Kernel Settings<br />

In this secti<strong>on</strong> we want <str<strong>on</strong>g>to</str<strong>on</strong>g> show how <str<strong>on</strong>g>to</str<strong>on</strong>g> change some Linux kernel settings of our OSELAS.BSP-Pengutr<strong>on</strong>ix-<br />

Generic-2011.01.0project.<br />

First of all, we run<br />

24


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

$ ptxdist menuc<strong>on</strong>fig kernel<br />

This command will start <strong>the</strong> kernel’s Kc<strong>on</strong>fig. For this example we want <str<strong>on</strong>g>to</str<strong>on</strong>g> enable USB host support in <strong>the</strong> kernel.<br />

To do so, we navigate <str<strong>on</strong>g>to</str<strong>on</strong>g>:<br />

Device Drivers ---><br />

[ ] USB support ---><br />

< > Support for Host-side USB<br />

< > OHCI HCD support<br />

Note: All <strong>the</strong> listed empty [ ] and < > above must be activated <str<strong>on</strong>g>to</str<strong>on</strong>g> get all submenu entries.<br />

We leave <strong>the</strong> menu and save <strong>the</strong> new kernel c<strong>on</strong>figurati<strong>on</strong>.<br />

To start building a new kernel with <strong>the</strong> new c<strong>on</strong>figurati<strong>on</strong>, we again run:<br />

$ ptxdist go<br />

This builds or re-builds <strong>the</strong> kernel, because we changed its settings.<br />

Note: If nothing was changed, ptxdist go also will do nothing.<br />

When <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> has finished its job, <strong>the</strong> new bootable kernel can be found at platform-versatilepb/images/linuximage.<br />

To boot it again in <strong>the</strong> QEMU emulati<strong>on</strong>, <strong>the</strong> hard disk image must be re-created with:<br />

$ ptxdist images<br />

$ ./c<strong>on</strong>figs/arm-qemu-2011.01.0/run<br />

The emulated system should now start with a 2.6.37 based kernel with USB support.<br />

3.3.4 Adapting Userland Settings<br />

After changing some platform and kernel settings, we are now reaching <strong>the</strong> most interesting area: Userland.<br />

In <strong>the</strong> userland area we can enable and use all <strong>the</strong> applicati<strong>on</strong>s and services <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides. Many of <strong>the</strong>m are<br />

working out of <strong>the</strong> box when enabled and executed <strong>on</strong> <strong>the</strong> target side. Some need additi<strong>on</strong>al runtime c<strong>on</strong>figurati<strong>on</strong>,<br />

but <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> comes with most comm<strong>on</strong> c<strong>on</strong>figurati<strong>on</strong>s for such packages.<br />

In this simple example, we want <str<strong>on</strong>g>to</str<strong>on</strong>g> add <strong>the</strong> missing head command <str<strong>on</strong>g>to</str<strong>on</strong>g> our target’s shell. Assuming we forgot <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

enable this command, we get:<br />

$ ./c<strong>on</strong>figs/arm-qemu-2011.01.0/run<br />

ptx login: root<br />

login[xxx]: root login <strong>on</strong> ’ttyS0’<br />

root@ptx:~ head /etc/fstab<br />

-sh: head: not found<br />

To change this, we first run:<br />

$ ptxdist menuc<strong>on</strong>fig<br />

The additi<strong>on</strong>al command we want <str<strong>on</strong>g>to</str<strong>on</strong>g> enable is provided by <strong>the</strong> Busybox package. So we navigate <str<strong>on</strong>g>to</str<strong>on</strong>g>:<br />

25


3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> User’s Manual<br />

Shell & C<strong>on</strong>sole Tools ---><br />

-*- busybox ---><br />

Coreutils ---><br />

[ ] head<br />

After activating <strong>the</strong> [ ] head entry, we leave <strong>the</strong> menu and save <strong>the</strong> new c<strong>on</strong>figurati<strong>on</strong>.<br />

Once again, a<br />

$ ptxdist go<br />

will build or re-build <strong>the</strong> busybox package due <str<strong>on</strong>g>to</str<strong>on</strong>g> its c<strong>on</strong>figurati<strong>on</strong> change.<br />

And also <strong>on</strong>ce again, after finishing its job, <strong>the</strong> following commands let us test <strong>the</strong> new command:<br />

$ ptxdist images<br />

$ ./c<strong>on</strong>figs/arm-qemu-2011.01.0/run<br />

Log in <strong>on</strong> <strong>the</strong> emulated system and simply check with a:<br />

ptx login: root<br />

login[xxx]: root login <strong>on</strong> ’ttyS0’<br />

root@ptx:~ head /etc/fstab<br />

#<br />

# /etc/fstab<br />

#<br />

# special filesystems<br />

proc /proc proc defaults 0 0<br />

debugfs /sys/kernel/debug debugfs defaults,noau<str<strong>on</strong>g>to</str<strong>on</strong>g> 0 0<br />

devpts /dev/pts devpts defaults 0 0<br />

n<strong>on</strong>e /tmp tmpfs defaults,mode=1777,uid=0,gid=0 0 0<br />

n<strong>on</strong>e /sys sysfs defaults 0 0<br />

We are d<strong>on</strong>e now. These simple examples should give <strong>the</strong> users a quick feeling how things are working in <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g><br />

and how <str<strong>on</strong>g>to</str<strong>on</strong>g> modify <strong>the</strong>m. Adapting this generic BSP <str<strong>on</strong>g>to</str<strong>on</strong>g> a different platform with nearly <strong>the</strong> same features as our<br />

reference platforms is possible with this knowledge.<br />

But most of <strong>the</strong> time, a user needs more detailed adapti<strong>on</strong>s <str<strong>on</strong>g>to</str<strong>on</strong>g> be able <str<strong>on</strong>g>to</str<strong>on</strong>g> fit all requirements of <strong>the</strong> new platform.<br />

At this point of time we are no l<strong>on</strong>ger ordinary users of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>, we <str<strong>on</strong>g>become</str<strong>on</strong>g> developers now.<br />

So, right now its time <str<strong>on</strong>g>to</str<strong>on</strong>g> read <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

26


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

This chapter will show all (or most) of <strong>the</strong> details of how <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> works.<br />

• where are <strong>the</strong> files s<str<strong>on</strong>g>to</str<strong>on</strong>g>red that <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> uses when building packages<br />

• how patching works<br />

• where is <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> fetching a package’s runtime c<strong>on</strong>figurati<strong>on</strong> files from<br />

• how <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>trol a package’s build stages<br />

• how <str<strong>on</strong>g>to</str<strong>on</strong>g> add new packages<br />

4.1 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry hierarchy<br />

Note: Referenced direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries are meant relative <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> main installati<strong>on</strong> locati<strong>on</strong> (if not o<strong>the</strong>rwise stated).<br />

If not c<strong>on</strong>figured differently, this main path is /usr/local/lib/ptxdist-2011.01.0<br />

4.1.1 Rule Files<br />

When building a single package, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> needs <strong>the</strong> informati<strong>on</strong> <strong>on</strong> how <str<strong>on</strong>g>to</str<strong>on</strong>g> handle <strong>the</strong> package, i.e. <strong>on</strong> how <str<strong>on</strong>g>to</str<strong>on</strong>g> get<br />

it from <strong>the</strong> source up <str<strong>on</strong>g>to</str<strong>on</strong>g> what <strong>the</strong> target needs at runtime. This informati<strong>on</strong> is provided by a rule file per package.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> collects all rule files in its rules/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. Whenever <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> builds something, all <strong>the</strong>se rule files are<br />

scanned at <strong>on</strong>ce. These rule files are global rule files, valid for all projects. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> uses a mechanism <str<strong>on</strong>g>to</str<strong>on</strong>g> be able<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> add or replace specific rule files <strong>on</strong> a per project base. If a rules/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry exists in <strong>the</strong> current project, its<br />

c<strong>on</strong>tent is scanned <str<strong>on</strong>g>to</str<strong>on</strong>g>o. These project local rule files are used in additi<strong>on</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> global rule files or – if <strong>the</strong>y are<br />

using <strong>the</strong> same name as a global rule file – replacing <strong>the</strong> global rule file.<br />

The replacing mechanism can be used <str<strong>on</strong>g>to</str<strong>on</strong>g> extend or adapt packages for specific project requirements. Or it can<br />

be used for bug fixing by backporting rule files from more recent <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> revisi<strong>on</strong>s <str<strong>on</strong>g>to</str<strong>on</strong>g> projects that are stuck <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

an older <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> revisi<strong>on</strong> for maintenance <strong>on</strong>ly.<br />

4.1.2 Patch Series<br />

There are many packages in <strong>the</strong> wild that are not cross build aware. They fail compiling some files, use wr<strong>on</strong>g<br />

include paths or try <str<strong>on</strong>g>to</str<strong>on</strong>g> link against host libraries. To be sucessful in <strong>the</strong> embedded world, <strong>the</strong>se types of failures<br />

must be fixed. If required, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides such fixes per package. They are organized in patch series and can<br />

be found in <strong>the</strong> patches/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry within a subdirec<str<strong>on</strong>g>to</str<strong>on</strong>g>ry using <strong>the</strong> same name as <strong>the</strong> package itself.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> uses <strong>the</strong> utility patchor quilt<str<strong>on</strong>g>to</str<strong>on</strong>g> apply an existing patch series after extracting <strong>the</strong> archive. So, every patch<br />

series c<strong>on</strong>tains a set of patches and <strong>on</strong>e series file <str<strong>on</strong>g>to</str<strong>on</strong>g> define <strong>the</strong> order in which <strong>the</strong> patches must be applied.<br />

Note: Patches can be compressed.<br />

27


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

Besides <strong>the</strong> patches/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry at <strong>the</strong> main installati<strong>on</strong> locati<strong>on</strong>, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> searches two additi<strong>on</strong>al locati<strong>on</strong>s for a<br />

patch series for <strong>the</strong> package in questi<strong>on</strong>.<br />

One locati<strong>on</strong> is <strong>the</strong> project’s currently used platform direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. If <strong>the</strong> currently used platform is located in<br />

c<strong>on</strong>figs/arm-qemu-2011.01.0, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> searches in ./c<strong>on</strong>figs/arm-qemu-2011.01.0/patches/.<br />

If no patch series was found in <strong>the</strong> platform direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry, <strong>the</strong> next locati<strong>on</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> it searches for a patch series is<br />

<strong>the</strong> main project direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry in ./patches/.<br />

If both project local locati<strong>on</strong>s do not provide a patch series for <strong>the</strong> specific package, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> falls back <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong><br />

patches/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry at its main installati<strong>on</strong> locati<strong>on</strong>.<br />

This search order can be used <str<strong>on</strong>g>to</str<strong>on</strong>g> use specific patch series for specific cases.<br />

• platfom specific<br />

• project specific<br />

• comm<strong>on</strong> case<br />

• bug fixing<br />

The bug fixing case is used in accordance <str<strong>on</strong>g>to</str<strong>on</strong>g> a replacement of a rule file. If this was d<strong>on</strong>e due <str<strong>on</strong>g>to</str<strong>on</strong>g> a backport, and<br />

<strong>the</strong> more recent <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> revisi<strong>on</strong> does not <strong>on</strong>ly exchange <strong>the</strong> rule file but also <strong>the</strong> patch series, this mechanism<br />

ensures that both relevant parts can be updated in <strong>the</strong> project.<br />

4.1.3 Runtime C<strong>on</strong>figurati<strong>on</strong><br />

Many packages are using runtime c<strong>on</strong>figurati<strong>on</strong> files al<strong>on</strong>g with <strong>the</strong>ir executables and libraries. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides<br />

default c<strong>on</strong>figurati<strong>on</strong> files for <strong>the</strong> most comm<strong>on</strong> cases. These files can be found in <strong>the</strong> generic/etc direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry and<br />

<strong>the</strong>y are using <strong>the</strong> same names as <strong>the</strong> <strong>on</strong>es at runtime (and <strong>the</strong>ir install direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry <strong>on</strong> <strong>the</strong> target side will also be<br />

/etc).<br />

But some of <strong>the</strong>se default c<strong>on</strong>figurati<strong>on</strong> files are empty, due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> absence of a comm<strong>on</strong> case. The project must<br />

provide replacements of <strong>the</strong>se files with a more useful c<strong>on</strong>tent in every case where <strong>the</strong> (empty) default <strong>on</strong>e does<br />

not meet <strong>the</strong> target’s requirements.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> first searches <strong>the</strong> project local ./projectroot/etc direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry for a specific c<strong>on</strong>figurati<strong>on</strong> file and falls back<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> use <strong>the</strong> default <strong>on</strong>e if n<strong>on</strong>e exists locally.<br />

A popular example is <strong>the</strong> c<strong>on</strong>figurati<strong>on</strong> file /etc/fstab. The default <strong>on</strong>e coming with <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> works for <strong>the</strong><br />

most comm<strong>on</strong> cases. But if our project requires a special setup, we can just copy <strong>the</strong> default <strong>on</strong>e <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> local<br />

./projectroot/etc/fstab, modify it and we are d<strong>on</strong>e. The next time <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> builds <strong>the</strong> root filesystem it will use<br />

<strong>the</strong> local fstab instead of <strong>the</strong> global (default) <strong>on</strong>e.<br />

4.2 Adding new Packages<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides a huge amount of applicati<strong>on</strong>s sufficient for <strong>the</strong> most embedded use cases. But <strong>the</strong>re is still<br />

need for some fancy new packages. This secti<strong>on</strong> describes <strong>the</strong> steps and <strong>the</strong> background <strong>on</strong> how <str<strong>on</strong>g>to</str<strong>on</strong>g> intergrate<br />

new packages in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> project.<br />

At first a summary about possible applicati<strong>on</strong> types which <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> can handle:<br />

28


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

• host type: This kind of package is built <str<strong>on</strong>g>to</str<strong>on</strong>g> run <strong>on</strong> <strong>the</strong> build host. Most of <strong>the</strong> time such a package is needed<br />

if ano<strong>the</strong>r target relevant package needs <str<strong>on</strong>g>to</str<strong>on</strong>g> generate some data. For example <strong>the</strong> glib package depends<br />

<strong>on</strong> its own <str<strong>on</strong>g>to</str<strong>on</strong>g> create some data. But if it is compiled for <strong>the</strong> target, it can’t do so. That’s why a host glib<br />

package is required <str<strong>on</strong>g>to</str<strong>on</strong>g> provide <strong>the</strong>se utilities runnable <strong>on</strong> <strong>the</strong> build host. It sounds strange <str<strong>on</strong>g>to</str<strong>on</strong>g> build a host<br />

package, even if <strong>on</strong> <strong>the</strong> build host such utilities are already installed. But this way ensures that <strong>the</strong>re are<br />

no dependencies regarding <strong>the</strong> build host system.<br />

• target type: This kind of package is built for <strong>the</strong> target.<br />

• cross type: This kind of package is built for <strong>the</strong> build host, but creates architecture specific data for <strong>the</strong><br />

target.<br />

• klibc type: This kind of package is built against klibc <str<strong>on</strong>g>to</str<strong>on</strong>g> be part of an initramfs for <strong>the</strong> target.<br />

• src-au<str<strong>on</strong>g>to</str<strong>on</strong>g>c<strong>on</strong>f-prog: This kind of package is built for <strong>the</strong> target. It is intended for development, as it does not<br />

handle a released archive but a plain source project instead. Creating such a package will also <strong>on</strong> demand<br />

create a small au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>ols based source template project <str<strong>on</strong>g>to</str<strong>on</strong>g> give <strong>the</strong> developer an easy point <str<strong>on</strong>g>to</str<strong>on</strong>g> start. This<br />

template is prepared <str<strong>on</strong>g>to</str<strong>on</strong>g> build a single executable program.<br />

• src-au<str<strong>on</strong>g>to</str<strong>on</strong>g>c<strong>on</strong>f-lib: This kind of package is built for <strong>the</strong> target. It is intended for development, as it does not<br />

handle a released archive but a plain source project instead. Creating such a package will also <strong>on</strong> demand<br />

create a small au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>ols/lib<str<strong>on</strong>g>to</str<strong>on</strong>g>ol based source template project <str<strong>on</strong>g>to</str<strong>on</strong>g> give <strong>the</strong> developer an easy point <str<strong>on</strong>g>to</str<strong>on</strong>g> start.<br />

This template is prepared <str<strong>on</strong>g>to</str<strong>on</strong>g> build a single shared library.<br />

• src-au<str<strong>on</strong>g>to</str<strong>on</strong>g>c<strong>on</strong>f-proglib: This kind of package is built for <strong>the</strong> target. It is intended for development, as it<br />

does not handle a released archive but a plain source project instead. Creating such a package will also<br />

<strong>on</strong> demand create a small au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>ols/lib<str<strong>on</strong>g>to</str<strong>on</strong>g>ol based template project <str<strong>on</strong>g>to</str<strong>on</strong>g> give <strong>the</strong> developer an easy point<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> start. This template is prepared <str<strong>on</strong>g>to</str<strong>on</strong>g> build a single shared library and a single executable program. The<br />

program will be linked against <strong>the</strong> shared library.<br />

• file: This kind of package is intended <str<strong>on</strong>g>to</str<strong>on</strong>g> add a few simple files in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> build process. We assume <strong>the</strong>se<br />

files do not need any processing, <strong>the</strong>y are ready <str<strong>on</strong>g>to</str<strong>on</strong>g> use and <strong>on</strong>ly must present in <strong>the</strong> build process or at<br />

runtime (HTML files for example). Refer <strong>the</strong> secti<strong>on</strong> 4.3 for fur<strong>the</strong>r details <strong>on</strong> how <str<strong>on</strong>g>to</str<strong>on</strong>g> use it.<br />

• src-make-prog: This kind of package is built for <strong>the</strong> target. Its intended for development, as it does not<br />

handle a released archive but a plain source project instead. Creating such a package will also create a<br />

simple makefile based template project <strong>the</strong> developen can use as a starting point for development.<br />

• src-cmake-prog: This kind of package is built for <strong>the</strong> target. Its intended for developments based <strong>on</strong> <strong>the</strong><br />

cmake buildsystem. If <strong>the</strong> developen is going <str<strong>on</strong>g>to</str<strong>on</strong>g> develop a QT based applicati<strong>on</strong>, this rule is prepared <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

compile sources in accordance <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> target libraries and <strong>the</strong>ir settings. Creating such a package will also<br />

create a simple template project <str<strong>on</strong>g>to</str<strong>on</strong>g> be used as a starting point for development.<br />

• f<strong>on</strong>t: This package is a helper <str<strong>on</strong>g>to</str<strong>on</strong>g> add X f<strong>on</strong>t files <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root filesystem. This package does not create<br />

an additi<strong>on</strong>al IPKG, instead it adds <strong>the</strong> f<strong>on</strong>t <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> existing f<strong>on</strong>t IPGK. This includes <strong>the</strong> generati<strong>on</strong> of <strong>the</strong><br />

direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry index files, required by <strong>the</strong> Xorg framework <str<strong>on</strong>g>to</str<strong>on</strong>g> recognize <strong>the</strong> f<strong>on</strong>t file.<br />

• src-linux-driver: This kind of package builds an out of tree kernel driver. It also creates a driver template<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> give <strong>the</strong> developer an easy point <str<strong>on</strong>g>to</str<strong>on</strong>g> start.<br />

• src-stellaris: This package is intended for development of firmware for standal<strong>on</strong>e Cortex-M3 Stellaris<br />

microc<strong>on</strong>trollers. These kind of microc<strong>on</strong>trollers are running without any operating systems most of <strong>the</strong><br />

time. It also creates a small firmware template <str<strong>on</strong>g>to</str<strong>on</strong>g> give <strong>the</strong> developer an easy point <str<strong>on</strong>g>to</str<strong>on</strong>g> start.<br />

4.2.1 Rule File Creati<strong>on</strong><br />

To create such a new package, we create a project local rules/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry first. Then we run<br />

29


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

$ ptxdist newpackage <br />

If we omit <strong>the</strong> , <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> will list all available package types.<br />

In our first example, we want <str<strong>on</strong>g>to</str<strong>on</strong>g> add a new target type archive package. When running <strong>the</strong><br />

$ ptxdist newpackage target<br />

command, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> asks a few questi<strong>on</strong>s about this package. This informati<strong>on</strong> is <strong>the</strong> basic data <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> must<br />

know about <strong>the</strong> package.<br />

ptxdist: creating a new ’target’ package:<br />

ptxdist: enter package name.......: foo<br />

ptxdist: enter versi<strong>on</strong> number.....: 1.1.0<br />

ptxdist: enter URL of basedir.....: http://www.foo.com/download/src<br />

ptxdist: enter suffix.............: tar.gz<br />

ptxdist: enter package author.....: My Name <br />

ptxdist: enter package secti<strong>on</strong>....: project_specific<br />

What we have <str<strong>on</strong>g>to</str<strong>on</strong>g> answer:<br />

• package name: As this kind of package handles a source archive, <strong>the</strong> correct answer here is <strong>the</strong> basename<br />

of <strong>the</strong> archive’s file name. If its full name is foo-1.1.0.tar.gz, <strong>the</strong>n foo is <strong>the</strong> basename <str<strong>on</strong>g>to</str<strong>on</strong>g> enter here.<br />

• versi<strong>on</strong> number: Most source archives are using a release or versi<strong>on</strong> number in <strong>the</strong>ir file name. If its full<br />

name is foo-1.1.0.tar.gz, <strong>the</strong>n 1.1.0 is <strong>the</strong> versi<strong>on</strong> number <str<strong>on</strong>g>to</str<strong>on</strong>g> enter here.<br />

• URL of basedir: This URL tells <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> where <str<strong>on</strong>g>to</str<strong>on</strong>g> download <strong>the</strong> source archive from <strong>the</strong> web (if not already<br />

d<strong>on</strong>e). If <strong>the</strong> full URL <str<strong>on</strong>g>to</str<strong>on</strong>g> download <strong>the</strong> archive is http://www.foo.com/download/src/foo-1.1.0.tar.gz,<br />

<strong>the</strong> basedir part http://www.foo.com/download/src is <str<strong>on</strong>g>to</str<strong>on</strong>g> enter here.<br />

• suffix: Archives are using various formats for distributi<strong>on</strong>. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> uses <strong>the</strong> suffix entry <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>the</strong> matching<br />

extracti<strong>on</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>ol. If <strong>the</strong> archive’s full name is foo-1.1.0.tar.gz, <strong>the</strong>n tar.gz is <strong>the</strong> suffix <str<strong>on</strong>g>to</str<strong>on</strong>g> enter here.<br />

• package author: If we intend <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>tribute this new package <str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> mainline, we should add our name<br />

here. This name will be used in <strong>the</strong> copyright note of <strong>the</strong> rule file and will also be added <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> generated<br />

ipkg. When you run ptxdist setup prior <str<strong>on</strong>g>to</str<strong>on</strong>g> this call, you can enter your name and your email address, so<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> will use it as <strong>the</strong> default (very handy if you intend <str<strong>on</strong>g>to</str<strong>on</strong>g> add many new packages).<br />

• package secti<strong>on</strong>: We can enter here <strong>the</strong> secti<strong>on</strong> name that should occur in <strong>the</strong> package’s menu entry. In<br />

<strong>the</strong> first step we can leave <strong>the</strong> default name unchanged. It’s a string in <strong>the</strong> menu file <strong>on</strong>ly, so changing it<br />

later <strong>on</strong> is still possible.<br />

4.2.2 Make it Work<br />

Generating <strong>the</strong> rule file is <strong>on</strong>ly <strong>on</strong>e of <strong>the</strong> required steps <str<strong>on</strong>g>to</str<strong>on</strong>g> get a new package. The next steps <str<strong>on</strong>g>to</str<strong>on</strong>g> make it work<br />

are <str<strong>on</strong>g>to</str<strong>on</strong>g> check if all stages are working as expected and <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>the</strong> required parts <str<strong>on</strong>g>to</str<strong>on</strong>g> get <strong>the</strong>m installed in <strong>the</strong><br />

target root filesystem. Also we must find a reas<strong>on</strong>able locati<strong>on</strong> where <str<strong>on</strong>g>to</str<strong>on</strong>g> add our new menu entry <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure<br />

<strong>the</strong> package.<br />

The generated skele<str<strong>on</strong>g>to</str<strong>on</strong>g>n starts <str<strong>on</strong>g>to</str<strong>on</strong>g> add <strong>the</strong> new menu entry in <strong>the</strong> main c<strong>on</strong>figure menu (if we left <strong>the</strong> secti<strong>on</strong> name<br />

unchanged). Running ptxdist menuc<strong>on</strong>fig will show it <strong>on</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>p of all o<strong>the</strong>r menus entries.<br />

Note: To be able <str<strong>on</strong>g>to</str<strong>on</strong>g> implement all <strong>the</strong> o<strong>the</strong>r required steps for adding a new package, we first must enable <strong>the</strong><br />

package for building (fine tuning <strong>the</strong> menu can be <strong>the</strong> last step).<br />

30


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

After enabling <strong>the</strong> menu entry, we can start <str<strong>on</strong>g>to</str<strong>on</strong>g> check <strong>the</strong> get and extract stage, calling <strong>the</strong>m manually <strong>on</strong>e after<br />

ano<strong>the</strong>r.<br />

$ ptxdist get foo<br />

---------------------------<br />

target: foo-1.1.0.tar.gz<br />

---------------------------<br />

--2009-12-21 10:54:45-- http://www.foo.com/download/src/foo-1.1.0.tar.gz<br />

Length: 291190 (284K) [applicati<strong>on</strong>/x-gzip]<br />

Saving <str<strong>on</strong>g>to</str<strong>on</strong>g>: ‘/global_src/foo-1.1.0.tar.gz.XXXXOGncZA’<br />

100%[======================================>] 291,190 170K/s in 1.7s<br />

2009-12-21 10:54:48 (170 KB/s) - ‘/global_src/foo-1.1.0.tar.gz’ saved [291190/291190]<br />

This command should start <str<strong>on</strong>g>to</str<strong>on</strong>g> download <strong>the</strong> source archive. If it fails, we should check our network c<strong>on</strong>necti<strong>on</strong><br />

and if <strong>the</strong> URL in use is correct.<br />

$ ptxdist extract foo<br />

-----------------------<br />

target: foo.extract<br />

-----------------------<br />

extract: archive=/global_src/foo-1.1.0.tar.gz<br />

extract: dest=/home/jbe/my_new_prj/build-target<br />

PATCHIN: packet=foo-1.1.0<br />

PATCHIN: dir=/home/jbe/my_new_prj/build-target/foo-1.1.0<br />

PATCHIN: no patches for foo-1.1.0 available<br />

Fixing up /home/jbe/my_new_prj/build-target/foo-1.1.0/c<strong>on</strong>figure<br />

finished target foo.extract<br />

In this example we expect an au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>olized source package. E.g. <str<strong>on</strong>g>to</str<strong>on</strong>g> prepare <strong>the</strong> build, <strong>the</strong> archive comes with<br />

a c<strong>on</strong>figure script. This is <strong>the</strong> default case for <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>. So, <strong>the</strong>re is no need <str<strong>on</strong>g>to</str<strong>on</strong>g> modify <strong>the</strong> rule file and we can<br />

simply run:<br />

$ ptxdist prepare foo<br />

-----------------------<br />

target: foo.prepare<br />

-----------------------<br />

[...]<br />

checking build system type... i686-host-linux-gnu<br />

checking host system type... i586-unknown-linux-gnu<br />

checking whe<strong>the</strong>r <str<strong>on</strong>g>to</str<strong>on</strong>g> enable maintainer-specific porti<strong>on</strong>s of Makefiles... no<br />

checking for a BSD-compatible install... /usr/bin/install -c<br />

checking whe<strong>the</strong>r build envir<strong>on</strong>ment is sane... yes<br />

checking for a thread-safe mkdir -p... /bin/mkdir -p<br />

checking for gawk... gawk<br />

checking whe<strong>the</strong>r make sets $(MAKE)... yes<br />

checking for i586-unknown-linux-gnu-strip... i586-unknown-linux-gnu-strip<br />

checking for i586-unknown-linux-gnu-gcc... i586-unknown-linux-gnu-gcc<br />

31


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

checking for C compiler default output file name... a.out<br />

[...]<br />

c<strong>on</strong>figure: creating ./c<strong>on</strong>fig.status<br />

c<strong>on</strong>fig.status: creating Makefile<br />

c<strong>on</strong>fig.status: creating ppa_pro<str<strong>on</strong>g>to</str<strong>on</strong>g>col/Makefile<br />

c<strong>on</strong>fig.status: creating c<strong>on</strong>fig.h<br />

c<strong>on</strong>fig.status: executing depfiles commands<br />

finished target foo.prepare<br />

At this stage things can fail:<br />

• The c<strong>on</strong>figure script is not cross compile aware<br />

• The package depends <strong>on</strong> external comp<strong>on</strong>ents (libraries for example)<br />

If <strong>the</strong> c<strong>on</strong>figure script is not cross compile aware, we are out of luck. We must patch <strong>the</strong> source archive in this<br />

case <str<strong>on</strong>g>to</str<strong>on</strong>g> make it work. Refer <str<strong>on</strong>g>to</str<strong>on</strong>g> secti<strong>on</strong> 4.2.6 <strong>on</strong> how <str<strong>on</strong>g>to</str<strong>on</strong>g> use <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s features <str<strong>on</strong>g>to</str<strong>on</strong>g> simplify this task.<br />

If <strong>the</strong> package depends <strong>on</strong> external comp<strong>on</strong>ents, <strong>the</strong>se comp<strong>on</strong>ents might be already part of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>. In this<br />

case we just have <str<strong>on</strong>g>to</str<strong>on</strong>g> add this dependency in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> menu file and we are d<strong>on</strong>e. But if <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> cannot fulfill this<br />

dependency, we also must add it as a separate package first.<br />

If <strong>the</strong> prepare stage has finished successfully, <strong>the</strong> next step is <str<strong>on</strong>g>to</str<strong>on</strong>g> compile <strong>the</strong> package.<br />

$ ptxdist compile foo<br />

-----------------------<br />

target: foo.compile<br />

-----------------------<br />

make[1]: Entering direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

make all-recursive<br />

make[2]: Entering direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

make[3]: Entering direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

[...]<br />

make[3]: Leaving direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

make[2]: Leaving direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

make[1]: Leaving direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

finished target foo.compile<br />

At this stage things can fail:<br />

• The build system is not cross compile aware (it tries <str<strong>on</strong>g>to</str<strong>on</strong>g> execute just created target binaries for example)<br />

• The package depends <strong>on</strong> external comp<strong>on</strong>ents (libraries for example) not detected by c<strong>on</strong>figure<br />

• Sources are ignoring <strong>the</strong> endianess of some architectures or using header files from <strong>the</strong> build host system<br />

(from /usr/include for example)<br />

• The linker uses libraries from <strong>the</strong> build host system (from /usr/lib for example) by accident<br />

In all of <strong>the</strong>se cases we must patch <strong>the</strong> sources <str<strong>on</strong>g>to</str<strong>on</strong>g> make <strong>the</strong>m work. Refer <str<strong>on</strong>g>to</str<strong>on</strong>g> secti<strong>on</strong> 4.2.4 <strong>on</strong> how <str<strong>on</strong>g>to</str<strong>on</strong>g> use <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s<br />

features <str<strong>on</strong>g>to</str<strong>on</strong>g> simplify this task.<br />

In this example we expect <strong>the</strong> best case: Everything went fine, even for cross compiling. So, we can c<strong>on</strong>tinue with<br />

<strong>the</strong> next stage: install<br />

32


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

$ ptxdist install foo<br />

-----------------------<br />

target: foo.install<br />

-----------------------<br />

make[1]: Entering direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

make[2]: Entering direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

make[3]: Entering direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

test -z ”/usr/bin” /bin/mkdir -p ”/home/jbe/my_new_prj/build-target/foo-1.1.0/usr/bin”<br />

/usr/bin/install -c ’foo’ ’/home/jbe/my_new_prj/build-target/foo-1.1.0/usr/bin/foo’<br />

make[3]: Leaving direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

make[2]: Leaving direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

make[1]: Leaving direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry ‘/home/jbe/my_new_prj/build-target/foo-1.1.0’<br />

finished target foo.install<br />

----------------------------<br />

target: foo.install.post<br />

----------------------------<br />

finished target foo.install.post<br />

This install stage does not install anything <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> target root filesystem. It is mostly intended <str<strong>on</strong>g>to</str<strong>on</strong>g> install libraries<br />

that o<strong>the</strong>r programs should link against later <strong>on</strong>.<br />

The last stage – targetinstall – is <strong>the</strong> <strong>on</strong>e that defines <strong>the</strong> package’s comp<strong>on</strong>ents <str<strong>on</strong>g>to</str<strong>on</strong>g> be forwarded <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> target’s<br />

root filesystem. Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> absence of a generic way, this is <strong>the</strong> task of <strong>the</strong> developer. So, at this point of time we<br />

must run our favourite edi<str<strong>on</strong>g>to</str<strong>on</strong>g>r and modify our new rule file ./rules/foo.make.<br />

The skele<str<strong>on</strong>g>to</str<strong>on</strong>g>n for <strong>the</strong> targetinstall stage looks like this:<br />

# ----------------------------------------------------------------------------<br />

# Target-Install<br />

# ----------------------------------------------------------------------------<br />

$(STATEDIR)/foo.targetinstall:<br />

@$(call targetinfo)<br />

@$(call install_init, foo)<br />

@$(call install_fixup, foo,PACKAGE,foo)<br />

@$(call install_fixup, foo,PRIORITY,opti<strong>on</strong>al)<br />

@$(call install_fixup, foo,VERSION,$(FOO_VERSION))<br />

@$(call install_fixup, foo,SECTION,base)<br />

@$(call install_fixup, foo,AUTHOR,”My Name ”)<br />

@$(call install_fixup, foo,DEPENDS,)<br />

@$(call install_fixup, foo,DESCRIPTION,missing)<br />

@$call install_copy, foo, 0, 0, 0755, $(FOO_DIR)/foobar, /dev/null)<br />

@$(call install_finish, foo)<br />

@$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

The ”header” of this stage defines some informati<strong>on</strong> IPKG needs. The important part that we must modify is <strong>the</strong><br />

call <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> install_copy macro (refer <str<strong>on</strong>g>to</str<strong>on</strong>g> secti<strong>on</strong> 5.2 for more details about this kind of macros). This call instructs<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> include <strong>the</strong> given file (with PID, UID and permissi<strong>on</strong>s) in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> IPKG, which means <str<strong>on</strong>g>to</str<strong>on</strong>g> install this file <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

<strong>the</strong> target’s root filesystem.<br />

33


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

From <strong>the</strong> previous install stage we know this package installs an executable called foo <str<strong>on</strong>g>to</str<strong>on</strong>g> locati<strong>on</strong> /usr/bin. We<br />

can do <strong>the</strong> same for our target by changing <strong>the</strong> install_copy line <str<strong>on</strong>g>to</str<strong>on</strong>g>:<br />

@$(call install_copy, foo, 0, 0, 0755, $(FOO_DIR)/foo, /usr/bin/foo)<br />

To check it, we just run:<br />

$ ptxdist targetinstall foo<br />

-----------------------------<br />

target: foo.targetinstall<br />

-----------------------------<br />

install_init: preparing for image creati<strong>on</strong>...<br />

install_init: @ARCH@ -> i386 ... d<strong>on</strong>e<br />

install_init: preinst not available<br />

install_init: postinst not available<br />

install_init: prerm not available<br />

install_init: postrm not available<br />

install_fixup: @PACKAGE@ -> foo ... d<strong>on</strong>e.<br />

install_fixup: @PRIORITY@ -> opti<strong>on</strong>al ... d<strong>on</strong>e.<br />

install_fixup: @VERSION@ -> 1.1.0 ... d<strong>on</strong>e.<br />

install_fixup: @SECTION@ -> base ... d<strong>on</strong>e.<br />

install_fixup: @AUTHOR@ -> ”My Name ” ... d<strong>on</strong>e.<br />

install_fixup: @DESCRIPTION@ -> missing ... d<strong>on</strong>e.<br />

install_copy:<br />

src=/home/jbe/my_new_prj/build-target/foo-1.1.0/foo<br />

dst=/usr/bin/foo<br />

owner=0<br />

group=0<br />

permissi<strong>on</strong>s=0755<br />

xpkg_finish: collecting license (unknown) ... d<strong>on</strong>e.<br />

xpkg_finish: creating ipkg package ... d<strong>on</strong>e.<br />

finished target foo.targetinstall<br />

----------------------------------<br />

target: foo.targetinstall.post<br />

----------------------------------<br />

finished target foo.targetinstall.post<br />

After this command, <strong>the</strong> target’s root filesystem c<strong>on</strong>tains a file called /usr/bin/foo owned by root, its group is<br />

also root and every<strong>on</strong>e has executi<strong>on</strong> permissi<strong>on</strong>s, but <strong>on</strong>ly <strong>the</strong> user root has write permissi<strong>on</strong>s.<br />

One last task of this port is still open: A reas<strong>on</strong>able locati<strong>on</strong> for <strong>the</strong> new menu entry in <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s menu hierarchy.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> arranges its menus <strong>on</strong> <strong>the</strong> meaning of each package. Is it a network related <str<strong>on</strong>g>to</str<strong>on</strong>g>ol? Or a scripting language?<br />

Or a graphical applicati<strong>on</strong>?<br />

Each of <strong>the</strong>se global meanings have <strong>the</strong>ir own submenu, where we can add our new entry <str<strong>on</strong>g>to</str<strong>on</strong>g>. We just have <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

edit <strong>the</strong> head of our new menu file <str<strong>on</strong>g>to</str<strong>on</strong>g> add it <str<strong>on</strong>g>to</str<strong>on</strong>g> a specific global menu. If our new package is a network related<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g>ol, <strong>the</strong> head of <strong>the</strong> menu file should look like:<br />

## SECTION=networking<br />

We can grep through <strong>the</strong> o<strong>the</strong>r menu files from <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> main installati<strong>on</strong> rules/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry <str<strong>on</strong>g>to</str<strong>on</strong>g> get an idea what<br />

secti<strong>on</strong> names are available:<br />

34


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

rules/ $ find . -name \*.in | xargs grep ”## SECTION”<br />

./acpid.in:## SECTION=shell_and_c<strong>on</strong>sole<br />

./alsa-lib.in:## SECTION=system_libraries<br />

./alsa-utils.in:## SECTION=multimedia_sound<br />

./apache2.in:## SECTION=networking<br />

./apache2_mod_pyth<strong>on</strong>.in:## SECTION=networking<br />

[...]<br />

./klibc-module-init-<str<strong>on</strong>g>to</str<strong>on</strong>g>ols.in:## SECTION=initramfs<br />

./xkeyboard-c<strong>on</strong>fig.in:## SECTION=multimedia_xorg_data<br />

./xorg-app-xev.in:## SECTION=multimedia_xorg_app<br />

./xorg-app-xrandr.in:## SECTION=multimedia_xorg_app<br />

./host-eggdbus.in:## SECTION=host<str<strong>on</strong>g>to</str<strong>on</strong>g>ols_noprompt<br />

./libssh2.in:## SECTION=networking<br />

Porting a new package <str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is finished now.<br />

To check it right away, we simply run <strong>the</strong>se two commands:<br />

$ ptxdist clean foo<br />

rm -rf /home/jbe/my_new_prj/state/foo.*<br />

rm -rf /home/jbe/my_new_prj/packages/foo_*<br />

rm -rf /home/jbe/my_new_prj/build-target/foo-1.1.0<br />

$ ptxdist targetinstall foo<br />

[...]<br />

4.2.3 Advanced Rule Files<br />

The previous example <strong>on</strong> how <str<strong>on</strong>g>to</str<strong>on</strong>g> create a rule file sometimes works as shown above. But most of <strong>the</strong> time source<br />

archives are not that simple. In this secti<strong>on</strong> we want <str<strong>on</strong>g>to</str<strong>on</strong>g> give <strong>the</strong> user a more detailed selecti<strong>on</strong> how <strong>the</strong> package<br />

will be built.<br />

Adding Static C<strong>on</strong>figure Parameters<br />

The c<strong>on</strong>figure scripts of various source archives provide additi<strong>on</strong>al parameters <str<strong>on</strong>g>to</str<strong>on</strong>g> enable or disable features, or<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure <strong>the</strong>m in a specific way.<br />

We assume <strong>the</strong> c<strong>on</strong>figure script of our foo example (refer <str<strong>on</strong>g>to</str<strong>on</strong>g> secti<strong>on</strong> 4.2.1) supports two additi<strong>on</strong>al parameters:<br />

• --enable-debug: Make <strong>the</strong> program more noisy. It’s disabled by default.<br />

• --with-bar: Also build <strong>the</strong> special executable bar. Building this executable is also disabled by default.<br />

We now want <str<strong>on</strong>g>to</str<strong>on</strong>g> forward <strong>the</strong>se opti<strong>on</strong>s <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> c<strong>on</strong>figure script when it runs in <strong>the</strong> prepare stage. To do so, we<br />

must again open <strong>the</strong> rule file with our favourite edi<str<strong>on</strong>g>to</str<strong>on</strong>g>r and navigate <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> prepare stage entry.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> uses <strong>the</strong> variable FOO_AUTOCONF as <strong>the</strong> list of parameters <str<strong>on</strong>g>to</str<strong>on</strong>g> be given <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure.<br />

Currently this variable is defined <str<strong>on</strong>g>to</str<strong>on</strong>g>:<br />

FOO_AUTOCONF := $(CROSS_AUTOCONF_USR)<br />

The variable CROSS_AUTOCONF_USRis predefined by <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> and c<strong>on</strong>tains all basic parameters <str<strong>on</strong>g>to</str<strong>on</strong>g> instruct c<strong>on</strong>figure<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> prepare for a cross compile envir<strong>on</strong>ment.<br />

To use <strong>the</strong> two additi<strong>on</strong>al menti<strong>on</strong>ed c<strong>on</strong>figure parameters, we supplement this expressi<strong>on</strong> as follows:<br />

35


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

FOO_AUTOCONF := $(CROSS_AUTOCONF_USR) \<br />

--enable-debug \<br />

--with-bar<br />

Note: We recommend <str<strong>on</strong>g>to</str<strong>on</strong>g> use this format with each parameter <strong>on</strong> a line of its own. That is easier <str<strong>on</strong>g>to</str<strong>on</strong>g> read and a<br />

diff shows more exactly any change.<br />

To do a fast check if this additi<strong>on</strong> was successful, we run:<br />

$ ptxdist print FOO_AUTOCONF<br />

--prefix=/usr --sysc<strong>on</strong>fdir=/etc --host=i586-unknown-linux-gnu --build=i686-host-linux-gnu --enable-debug ¿<br />

--with-bar<br />

Or re-build <strong>the</strong> package with <strong>the</strong> new settings:<br />

$ ptxdist drop foo prepare<br />

$ ptxdist targetinstall foo<br />

Adding Dynamic C<strong>on</strong>figure Parameters<br />

Sometimes it makes sense <str<strong>on</strong>g>to</str<strong>on</strong>g> add this kind of parameters <strong>on</strong> demand <strong>on</strong>ly; especially a parameter like<br />

--enable-debug. To let <strong>the</strong> user decide if this parameter is <str<strong>on</strong>g>to</str<strong>on</strong>g> be used or not, we must add a menu entry. So,<br />

let’s expand our menu. Here is its current c<strong>on</strong>tent:<br />

## SECTION=project_specific<br />

c<strong>on</strong>fig FOO<br />

tristate<br />

prompt ”foo”<br />

help<br />

FIXME<br />

We’ll add two menu entries, <strong>on</strong>e for each opti<strong>on</strong>al parameter we want <str<strong>on</strong>g>to</str<strong>on</strong>g> add <strong>on</strong> demand <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> c<strong>on</strong>figure parameters:<br />

## SECTION=project_specific<br />

c<strong>on</strong>fig FOO<br />

tristate<br />

prompt ”foo”<br />

help<br />

FIXME<br />

if FOO<br />

c<strong>on</strong>fig FOO_DEBUG<br />

bool<br />

prompt ”add debug noise”<br />

c<strong>on</strong>fig FOO_BAR<br />

bool<br />

prompt ”build bar”<br />

endif<br />

36


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

Note: To extend <strong>the</strong> base name by a subopti<strong>on</strong> name as a trailing comp<strong>on</strong>ent gives <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <strong>the</strong> ability <str<strong>on</strong>g>to</str<strong>on</strong>g> detect<br />

a change in <strong>the</strong> package’s settings <str<strong>on</strong>g>to</str<strong>on</strong>g> force its rebuild.<br />

To make usage of <strong>the</strong> new menu entries, we must check <strong>the</strong>m in <strong>the</strong> rule file and add <strong>the</strong> correct parameters:<br />

#<br />

# au<str<strong>on</strong>g>to</str<strong>on</strong>g>c<strong>on</strong>f<br />

#<br />

FOO_AUTOCONF := $(CROSS_AUTOCONF_USR)<br />

ifdef PTXCONF_FOO_DEBUG<br />

FOO_AUTOCONF += --enable-debug<br />

else<br />

FOO_AUTOCONF += --disable-debug<br />

endif<br />

ifdef PTXCONF_FOO_BAR<br />

FOO_AUTOCONF += --with-bar<br />

else<br />

FOO_AUTOCONF += --without-bar<br />

endif<br />

It is a good practice <str<strong>on</strong>g>to</str<strong>on</strong>g> add both settings, e.g. --disable-debug even if this is <strong>the</strong> default case. Sometimes<br />

c<strong>on</strong>figure tries <str<strong>on</strong>g>to</str<strong>on</strong>g> guess something and <strong>the</strong> binary result might differ depending <strong>on</strong> <strong>the</strong> build order. For example<br />

some kind of package would also build some X related <str<strong>on</strong>g>to</str<strong>on</strong>g>ols, if X libraries are found. In this case it depends <strong>on</strong><br />

<strong>the</strong> build order, if <strong>the</strong> X related <str<strong>on</strong>g>to</str<strong>on</strong>g>ols are built or not. All <strong>the</strong> au<str<strong>on</strong>g>to</str<strong>on</strong>g>check features are problematic here. So, if we<br />

do not want c<strong>on</strong>figure <str<strong>on</strong>g>to</str<strong>on</strong>g> guess its settings we must disable everything we do not want<br />

If some parts of a package are built <strong>on</strong> demand <strong>on</strong>ly, <strong>the</strong>y must also be installed <strong>on</strong> demand <strong>on</strong>ly. Besides <strong>the</strong><br />

prepare stage, we also must modify our targetinstall stage:<br />

[...]<br />

@$(call install_copy, foo, 0, 0, 0755, $(FOO_DIR)/foo, /usr/bin/foo)<br />

ifdef PTXCONF_FOO_BAR<br />

@$(call install_copy, foo, 0, 0, 0755, $(FOO_DIR)/bar, /usr/bin/bar)<br />

endif<br />

[...]<br />

@$(call install_finish, foo)<br />

@$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

Now we can play with our new menu entries and check if <strong>the</strong>y are working as expected:<br />

$ ptxdist menuc<strong>on</strong>fig<br />

$ ptxdist targetinstall foo<br />

Whenever we change a FOO related menu entry, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> should detect it and re-build <strong>the</strong> package when a new<br />

build is started.<br />

Managing External Compile Time Dependencies<br />

While running <strong>the</strong> prepare stage, it could happen that it fails due <str<strong>on</strong>g>to</str<strong>on</strong>g> a missing external dependency.<br />

37


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

For example:<br />

[...]<br />

checking whe<strong>the</strong>r zlib exists....failed<br />

In this example, our new package depends <strong>on</strong> <strong>the</strong> compressi<strong>on</strong> library zlib. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> comes with a target zlib. All<br />

we need <str<strong>on</strong>g>to</str<strong>on</strong>g> do in this case is <str<strong>on</strong>g>to</str<strong>on</strong>g> declare that our new package foo depends <strong>on</strong> zlib. This kind of dependencies<br />

is managed in <strong>the</strong> menu file of our new package by simply adding <strong>the</strong> select ZLIB line. After this additi<strong>on</strong> our<br />

menu file looks like:<br />

## SECTION=project_specific<br />

c<strong>on</strong>fig FOO<br />

tristate<br />

select ZLIB<br />

prompt ”foo”<br />

help<br />

FIXME<br />

if FOO<br />

c<strong>on</strong>fig FOO_DEBUG<br />

bool<br />

prompt ”add debug noise”<br />

c<strong>on</strong>fig FOO_BAR<br />

bool<br />

prompt ”build bar”<br />

endif<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> now builds <strong>the</strong> zlib first and our new package <strong>the</strong>reafter.<br />

Managing External Compile Time Dependencies <strong>on</strong> Demand<br />

It is good practice <str<strong>on</strong>g>to</str<strong>on</strong>g> add <strong>on</strong>ly those dependecies that are really required for <strong>the</strong> current c<strong>on</strong>figurati<strong>on</strong> of <strong>the</strong><br />

package. If <strong>the</strong> package provides <strong>the</strong> features foo and bar and its c<strong>on</strong>figure provides switches <str<strong>on</strong>g>to</str<strong>on</strong>g> enable/disable<br />

<strong>the</strong>m independently, we can also add dependencies <strong>on</strong> demand. Let’s assume feature foo needs <strong>the</strong> compressi<strong>on</strong><br />

library libz and bar needs <strong>the</strong> XML2 library libxml2. These libraries are <strong>on</strong>ly required at runtime if <strong>the</strong> corresp<strong>on</strong>dig<br />

feature is enabled. To add <strong>the</strong>se dependencies <strong>on</strong> demand, <strong>the</strong> menu file looks like:<br />

## SECTION=project_specific<br />

c<strong>on</strong>fig FOO<br />

tristate<br />

select ZLIB if FOO_FOO<br />

select LIBXML2 if FOO_BAR<br />

prompt ”foo”<br />

help<br />

FIXME<br />

if FOO<br />

c<strong>on</strong>fig FOO_DEBUG<br />

bool<br />

prompt ”add debug noise”<br />

38


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

c<strong>on</strong>fig FOO_FOO<br />

bool<br />

prompt ”build foo”<br />

c<strong>on</strong>fig FOO_BAR<br />

bool<br />

prompt ”build bar”<br />

endif<br />

Note: Do not add <strong>the</strong>se select statements <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> corresp<strong>on</strong>dig menu entry. They must bel<strong>on</strong>g <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> main menu<br />

entry of <strong>the</strong> package <str<strong>on</strong>g>to</str<strong>on</strong>g> ensure that <strong>the</strong> calculati<strong>on</strong> of <strong>the</strong> dependencies between <strong>the</strong> packages is d<strong>on</strong>e in a correct<br />

manner.<br />

Managing External Runtime Dependencies<br />

Some packages are building all of <strong>the</strong>ir comp<strong>on</strong>ents and also installing <strong>the</strong>m in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> target’s sysroot. But <strong>on</strong>ly<br />

<strong>the</strong>ir targetinstall stage decides which parts are copied <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root filesystem. So, compiling and linking of our<br />

package will work, because everything required is found in <strong>the</strong> target’s sysroot.<br />

In our example <strong>the</strong>re is a hidden dependency <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> math library libm. Our new package was built successfully,<br />

because <strong>the</strong> linker was able <str<strong>on</strong>g>to</str<strong>on</strong>g> link our binaries against <strong>the</strong> libm from <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain. But in this case <strong>the</strong> libm<br />

must also be available in <strong>the</strong> target’s root filesystem <str<strong>on</strong>g>to</str<strong>on</strong>g> fulfil <strong>the</strong> runtime dependency: We have <str<strong>on</strong>g>to</str<strong>on</strong>g> force <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g><br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> install libm. libm is part of <strong>the</strong> glibc package, but is not installed by default (<str<strong>on</strong>g>to</str<strong>on</strong>g> keep <strong>the</strong> root filesystem small).<br />

So, it does not help <str<strong>on</strong>g>to</str<strong>on</strong>g> select <strong>the</strong> GLIBC symbol, <str<strong>on</strong>g>to</str<strong>on</strong>g> get a libm at runtime.<br />

The correct soluti<strong>on</strong> here is <str<strong>on</strong>g>to</str<strong>on</strong>g> add a select LIBC_M <str<strong>on</strong>g>to</str<strong>on</strong>g> our menu file. With all <strong>the</strong> additi<strong>on</strong>s above it now looks<br />

like:<br />

## SECTION=project_specific<br />

c<strong>on</strong>fig FOO<br />

tristate<br />

select ZLIB if FOO_FOO<br />

select LIBXML2 if FOO_BAR<br />

select LIBC_M<br />

prompt ”foo”<br />

help<br />

FIXME<br />

if FOO<br />

c<strong>on</strong>fig FOO_DEBUG<br />

bool<br />

prompt ”add debug noise”<br />

c<strong>on</strong>fig FOO_FOO<br />

bool<br />

prompt ”build foo”<br />

c<strong>on</strong>fig FOO_BAR<br />

bool<br />

prompt ”build bar”<br />

endif<br />

39


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

Note: There are o<strong>the</strong>r packages around, that do not install everything by default. If our new package needs<br />

something special, we must take a look in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> menu of <strong>the</strong> o<strong>the</strong>r package how <str<strong>on</strong>g>to</str<strong>on</strong>g> force <strong>the</strong> required comp<strong>on</strong>ents<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> be installed and add <strong>the</strong> corresp<strong>on</strong>ding selects <str<strong>on</strong>g>to</str<strong>on</strong>g> our own menu file. In this case it does not help <str<strong>on</strong>g>to</str<strong>on</strong>g> enable<br />

<strong>the</strong> required parts in our project c<strong>on</strong>figurati<strong>on</strong>, because this has no effect <strong>on</strong> <strong>the</strong> build order!<br />

Managing N<strong>on</strong> Au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>ol Packages<br />

Many packages are still coming with a plain Makefile. The user has <str<strong>on</strong>g>to</str<strong>on</strong>g> adapt it <str<strong>on</strong>g>to</str<strong>on</strong>g> make it work in a cross compile<br />

envir<strong>on</strong>ment as well. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> can also handle this kind of packages. We <strong>on</strong>ly have <str<strong>on</strong>g>to</str<strong>on</strong>g> specifiy a special prepare<br />

and compile stage.<br />

Such packages often have no special need for any kind of preparati<strong>on</strong>. We can omit this stage by defining this<br />

empty rule:<br />

$(STATEDIR)/foo.prepare:<br />

@$(call targetinfo)<br />

@$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

To compile <strong>the</strong> package, we can use make’s feature <str<strong>on</strong>g>to</str<strong>on</strong>g> overwrite variables used in <strong>the</strong> Makefile. With this feature<br />

we can still use <strong>the</strong> original Makefile but with our own (cross compile) settings.<br />

Most of <strong>the</strong> time <strong>the</strong> generic compile rule can be used, <strong>on</strong>ly a few settings are required.<br />

make will be called in this case with:<br />

cd $(FOO_DIR) && $(FOO_MAKE_ENV) $(MAKE) $(FOO_MAKE_OPT)<br />

So, in <strong>the</strong> rule file <strong>on</strong>ly <strong>the</strong> two variables FOO_MAKE_ENV and FOO_MAKE_OPT must be set, <str<strong>on</strong>g>to</str<strong>on</strong>g> forward <strong>the</strong> required<br />

settings <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> package’s buildsystem. If <strong>the</strong> package cannot be built in parallel, we can also add <strong>the</strong><br />

FOO_MAKE_PAR := NO. YES is <strong>the</strong> default.<br />

Note: FOO is still <strong>the</strong> name of our example package. It must be replaced by <strong>the</strong> real package name.<br />

4.2.4 Patching Packages<br />

There can be various reas<strong>on</strong>s why a package must be patched:<br />

• Package is broken for cross compile envir<strong>on</strong>ments<br />

• Package is broken within a specific feature<br />

• Package is vulnerable and needs some fixes<br />

• or anything else<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> handles patching au<str<strong>on</strong>g>to</str<strong>on</strong>g>matically. After extracting <strong>the</strong> archive, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> checks for <strong>the</strong> existence of a patch<br />

direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry with <strong>the</strong> same name as <strong>the</strong> package. If our package’s name is foo-1.1.0, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> searches for patches<br />

in:<br />

1. platform (./c<strong>on</strong>figs/arm-qemu-2011.01.0/patches/foo-1.1.0)<br />

2. project (./patches/foo-1.1.0)<br />

3. ptxdist (/path/patches/foo-1.1.0)<br />

The patches from <strong>the</strong> first locati<strong>on</strong> found are used. Note: Due <str<strong>on</strong>g>to</str<strong>on</strong>g> this search order, a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> project can replace<br />

global patches from <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> installati<strong>on</strong>. This can be useful if a project sticks <str<strong>on</strong>g>to</str<strong>on</strong>g> a specific <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> revisi<strong>on</strong><br />

but fixes from a more recent revisi<strong>on</strong> of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> should be used.<br />

40


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

4.2.5 Creating Patches for a Package<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> uses <strong>the</strong> utilities patch or quilt <str<strong>on</strong>g>to</str<strong>on</strong>g> work with patches or patch series. We recommend quilt, as it can<br />

manage patch series in a very easy way. For this manual we assume quilt is installed <strong>on</strong> <strong>the</strong> build host.<br />

Creating a Patch Series for a Package<br />

To create a patch series for <strong>the</strong> first time, we can run <strong>the</strong> following steps. We are still using our foo-1.1.0 example<br />

package here:<br />

We create a special direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry for <strong>the</strong> patch series in <strong>the</strong> local project direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry:<br />

$ mkdir -p patches/foo-1.1.0<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> expects a series file in <strong>the</strong> patch direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. O<strong>the</strong>rwise it fails. Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> fact that we do not have any<br />

patch yet, we’ll start with an empty series file.<br />

$ <str<strong>on</strong>g>to</str<strong>on</strong>g>uch patches/foo-1.1.0/series<br />

Next is <str<strong>on</strong>g>to</str<strong>on</strong>g> extract <strong>the</strong> package (if already d<strong>on</strong>e, we must remove it first):<br />

$ ptxdist extract foo<br />

This will extract <strong>the</strong> archive and create a symbolic link in <strong>the</strong> build direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry pointing <str<strong>on</strong>g>to</str<strong>on</strong>g> our local patch direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />

Working this way will ensure that we do not lose our created patches if we enter ptxdist clean fooby accident. In<br />

our case <strong>the</strong> patches are still present in patches/foo-1.1.0 and can be used <strong>the</strong> next time we extract <strong>the</strong> package<br />

again.<br />

All we have <str<strong>on</strong>g>to</str<strong>on</strong>g> do now is <str<strong>on</strong>g>to</str<strong>on</strong>g> do <strong>the</strong> modificati<strong>on</strong> we need <str<strong>on</strong>g>to</str<strong>on</strong>g> make <strong>the</strong> package work. We change in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> build<br />

direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry and use quilt <str<strong>on</strong>g>to</str<strong>on</strong>g> create new patches, add files <str<strong>on</strong>g>to</str<strong>on</strong>g> respective patches, modify <strong>the</strong>se files and refresh <strong>the</strong><br />

patches <str<strong>on</strong>g>to</str<strong>on</strong>g> save our changes.<br />

We recommend this way when modifying source files. But this way is improper when an au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>ols based buildsystem<br />

itself needs modificati<strong>on</strong>s. Refer <str<strong>on</strong>g>to</str<strong>on</strong>g> secti<strong>on</strong> 4.2.6 <strong>on</strong> how <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> can handle this special task.<br />

Adding more Patches <str<strong>on</strong>g>to</str<strong>on</strong>g> a Package<br />

If we want <str<strong>on</strong>g>to</str<strong>on</strong>g> add more patches <str<strong>on</strong>g>to</str<strong>on</strong>g> an already patched package, we can use nearly <strong>the</strong> same way as creating<br />

patches for <strong>the</strong> first time. But if <strong>the</strong> patch series comes from <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> main installati<strong>on</strong>, we do not have write<br />

permissi<strong>on</strong>s <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong>se direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries (do NEVER work <strong>on</strong> <strong>the</strong> main installati<strong>on</strong> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries, NEVER, NEVER, NEVER).<br />

Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> search order in which <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> searches for patches for a specific package, we can copy <strong>the</strong> global patch<br />

series <str<strong>on</strong>g>to</str<strong>on</strong>g> our local project direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. Now we have <strong>the</strong> permissi<strong>on</strong>s <str<strong>on</strong>g>to</str<strong>on</strong>g> add more patches or modify <strong>the</strong> existing<br />

<strong>on</strong>es. Also quilt is our friend here <str<strong>on</strong>g>to</str<strong>on</strong>g> manage <strong>the</strong> patch series.<br />

If we think that our new patches are valuable also for o<strong>the</strong>rs, or <strong>the</strong>y fix an error, it could be a good idea <str<strong>on</strong>g>to</str<strong>on</strong>g> send<br />

<strong>the</strong>se patches <str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> mainline.<br />

4.2.6 Modifying Au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>olized Packages<br />

Au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>olized packages are very picky when au<str<strong>on</strong>g>to</str<strong>on</strong>g>matically generated files get patched. The patch order is very<br />

important in this case and sometimes it even fails and nowbody knows why.<br />

41


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

To improve a package’s au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>ols-based build system, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> comes with its own project local au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>ols <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

regenerate <strong>the</strong> au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>ols template files, instead of patching <strong>the</strong>m. With this feature, <strong>on</strong>ly <strong>the</strong> template files must<br />

be patched, <strong>the</strong> required c<strong>on</strong>figure script and <strong>the</strong> Makefile.in files are regenerated in <strong>the</strong> final stages of <strong>the</strong><br />

prepare step.<br />

This feature works like <strong>the</strong> regular patching mechanism. The <strong>on</strong>ly difference is <strong>the</strong> additi<strong>on</strong>al au<str<strong>on</strong>g>to</str<strong>on</strong>g>gen.sh file in<br />

<strong>the</strong> patch direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. If it exists and has executi<strong>on</strong> permissi<strong>on</strong>s, it will be called after <strong>the</strong> package was patched<br />

(while <strong>the</strong> extract stage is running).<br />

Its c<strong>on</strong>tent depends <strong>on</strong> developer needs; for <strong>the</strong> most simple case <strong>the</strong> c<strong>on</strong>tent can be:<br />

#!/bin/bash<br />

aclocal $ACLOCAL_FLAGS<br />

lib<str<strong>on</strong>g>to</str<strong>on</strong>g>olize \<br />

--force \<br />

--copy<br />

au<str<strong>on</strong>g>to</str<strong>on</strong>g>rec<strong>on</strong>f \<br />

--force \<br />

--install \<br />

--warnings=cross \<br />

--warnings=syntax \<br />

--warnings=obsolete \<br />

--warnings=unsupported<br />

Note: This way also still not au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>olized package can be au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>olized. We just have <str<strong>on</strong>g>to</str<strong>on</strong>g> add <strong>the</strong> comm<strong>on</strong> au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>ol<br />

template files (c<strong>on</strong>figure.ac and Makefile.am for example) via a patch series <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> package source and <strong>the</strong><br />

au<str<strong>on</strong>g>to</str<strong>on</strong>g>gen.sh <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> patch direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />

4.3 Adding binary <strong>on</strong>ly Files<br />

Sometimes a few binary files have <str<strong>on</strong>g>to</str<strong>on</strong>g> be added in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root filesystem. Or - <str<strong>on</strong>g>to</str<strong>on</strong>g> be more precise - some files, that<br />

do not need <str<strong>on</strong>g>to</str<strong>on</strong>g> be built in any way.<br />

On <strong>the</strong> o<strong>the</strong>r hand, sometimes files should be included that are not covered by any open source license and so,<br />

should not be shipped in <strong>the</strong> source code format.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides more than <strong>on</strong>e way <str<strong>on</strong>g>to</str<strong>on</strong>g> add such type of data files <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root filesystem it creates. The examples<br />

in this chapter refer our generic board support package. It comes with an example how <str<strong>on</strong>g>to</str<strong>on</strong>g> add binary <strong>on</strong>ly files<br />

in<str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s build mechanism.<br />

4.3.1 Old style - single files<br />

The old style <str<strong>on</strong>g>to</str<strong>on</strong>g> add a simple file is present in <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> since its early days: Just use <strong>the</strong> install_copy macro in <strong>the</strong><br />

targetinstall stage in your own cus<str<strong>on</strong>g>to</str<strong>on</strong>g>mized rules file.<br />

@$(call install_copy, binary_example, 0, 0, 0644, \<br />

$(PTXDIST_WORKSPACE)/local_src/binary_example/ptx_logo.png, \<br />

/example/ptx_logo.png)<br />

42


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

The example above is from <strong>the</strong> file rules/binary_inst.make from Pengutr<strong>on</strong>ix’s generic BSP. It copies <strong>the</strong> file<br />

ptx_logo.png from within <strong>the</strong> BSP’s direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry local_src/binary_example <str<strong>on</strong>g>to</str<strong>on</strong>g> target’s root filesystem. Refer 5.2.4<br />

for fur<strong>the</strong>r informati<strong>on</strong> about using <strong>the</strong> install_copy macro.<br />

The disadvantage of this method is: If we want <str<strong>on</strong>g>to</str<strong>on</strong>g> install more than <strong>on</strong>e file, we need <strong>on</strong>e call <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> install_copy<br />

macro per file. This is even harder if not <strong>on</strong>ly a set of files is <str<strong>on</strong>g>to</str<strong>on</strong>g> be installed, but a whole direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry tree with files<br />

instead.<br />

4.3.2 New style - using archives<br />

If a whole tree of files is <str<strong>on</strong>g>to</str<strong>on</strong>g> be installed, working with a tar based archive could make life easier. In this case <strong>the</strong><br />

archive itself provides all <strong>the</strong> required informati<strong>on</strong> <strong>the</strong> files are needing <str<strong>on</strong>g>to</str<strong>on</strong>g> be installed in a correct manner:<br />

• <strong>the</strong> file itself and its name<br />

• <strong>the</strong> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry structure and <strong>the</strong> final locati<strong>on</strong> of every file in this structure<br />

• user and group ID <strong>on</strong> a per file base<br />

@$(call install_archive, binary_example, -, -, \<br />

$(PTXDIST_WORKSPACE)/local_src/archive_example/pictures.tgz, \<br />

/)<br />

The example shown above is from <strong>the</strong> file rules/binary_inst.make from Pengutr<strong>on</strong>ix’s generic BSP. It extracts<br />

<strong>the</strong> archive pictures.tgz from within <strong>the</strong> BSP’s direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry local_src/archive_example <str<strong>on</strong>g>to</str<strong>on</strong>g> target’s root filesystem.<br />

Refer 5.2.8 for fur<strong>the</strong>r informati<strong>on</strong> about using <strong>the</strong> install_archive macro.<br />

Using an archive can be usefull <str<strong>on</strong>g>to</str<strong>on</strong>g> install parts of <strong>the</strong> root filesystem that are not covered by any open source<br />

license. Its possible <str<strong>on</strong>g>to</str<strong>on</strong>g> ship <strong>the</strong> binaries within <strong>the</strong> regular BSP, without <strong>the</strong> need for <strong>the</strong>ir sources. <str<strong>on</strong>g>How</str<strong>on</strong>g>ever it is<br />

possible for <strong>the</strong> cus<str<strong>on</strong>g>to</str<strong>on</strong>g>mer <str<strong>on</strong>g>to</str<strong>on</strong>g> re-create everything required from <strong>the</strong> BSP <str<strong>on</strong>g>to</str<strong>on</strong>g> get <strong>the</strong>ir target up and running again.<br />

Ano<strong>the</strong>r use case for <strong>the</strong> archive method could be <strong>the</strong> support for different development teams. One team provides<br />

a software comp<strong>on</strong>ent in <strong>the</strong> archive format, <strong>the</strong> o<strong>the</strong>r team does not neet <str<strong>on</strong>g>to</str<strong>on</strong>g> build it but can use it in <strong>the</strong><br />

same way than every o<strong>the</strong>r software comp<strong>on</strong>ent.<br />

4.3.3 Creating a Rules File<br />

To get a rules and menu file we can copy <strong>the</strong> <strong>on</strong>e from <strong>the</strong> generic BSP, or we let <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> create <strong>the</strong>m for us.<br />

$ ptxdist newpackage file<br />

ptxdist: creating a new ’file’ package:<br />

ptxdist: enter package name.......: my_binfiles<br />

ptxdist: enter versi<strong>on</strong> number.....: 1<br />

ptxdist: enter package author.....: Juergen Beisert <br />

ptxdist: enter package secti<strong>on</strong>....: rootfs<br />

Now two new files are present in <strong>the</strong> BSP:<br />

1. rules/my_binfiles.in The template for <strong>the</strong> menu<br />

2. rules/my_binfiles.make The rules template<br />

43


4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Developer’s Manual<br />

Both files now must be cus<str<strong>on</strong>g>to</str<strong>on</strong>g>mized <str<strong>on</strong>g>to</str<strong>on</strong>g> meet our requirements. Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> answer rootfs <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> ”enter package<br />

secti<strong>on</strong>” questi<strong>on</strong>, we will find <strong>the</strong> new menu entry in:<br />

Root Filesystem ---><br />

< > my_binfiles (NEW)<br />

Enabling this new entry will also run our stages in rules/my_binfiles.make <strong>the</strong> next time we enter:<br />

$ ptxdist go<br />

44


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

5.1 Variables Reference<br />

The following variables are provided by <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> simplify creating rule files. Every developer should use <strong>the</strong>se<br />

variables in every single line in <strong>the</strong> rule file <str<strong>on</strong>g>to</str<strong>on</strong>g> avoid any fur<strong>the</strong>r adapti<strong>on</strong> when external paths are changed.<br />

To get <strong>the</strong>ir c<strong>on</strong>tent related <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> current project, we can simply run a:<br />

$ ptxdist print PTXDIST_TOPDIR<br />

/usr/local/lib/ptxdist-2011.01.0<br />

Replace <strong>the</strong> PTXDIST_TOPDIR with <strong>on</strong>e of <strong>the</strong> o<strong>the</strong>r generic variables <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides.<br />

5.1.1 PTXDIST_TOPDIR<br />

Points always <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> installati<strong>on</strong> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>.<br />

5.1.2 PTXDIST_WORKSPACE<br />

Everything that references PTXDIST_WORKSPACE will use <strong>the</strong> active projects’s folder.<br />

5.1.3 PTXDIST_SYSROOT_CROSS<br />

PTXDIST_SYSROOT_CROSS points <str<strong>on</strong>g>to</str<strong>on</strong>g> a direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry tree all cross relevant executables, libraries and header files are<br />

installed <str<strong>on</strong>g>to</str<strong>on</strong>g> in <strong>the</strong> current project. All of <strong>the</strong> project’s packages built for <strong>the</strong> host <str<strong>on</strong>g>to</str<strong>on</strong>g> create data for <strong>the</strong> target<br />

are searching in this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry tree for <strong>the</strong>ir dependencies (executables, header and library files). Use<br />

$(PTXDIST_SYSROOT_CROSS)/bin <str<strong>on</strong>g>to</str<strong>on</strong>g> install executables, $(PTXDIST_SYSROOT_CROSS)/include for header files and<br />

$(PTXDIST_SYSROOT_CROSS)/lib for libraries.<br />

5.1.4 PTXDIST_SYSROOT_HOST<br />

PTXDIST_SYSROOT_HOST points <str<strong>on</strong>g>to</str<strong>on</strong>g> a direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry tree all host relevant executables, libraries and header files are<br />

installed <str<strong>on</strong>g>to</str<strong>on</strong>g>. All project’s packages built for <strong>the</strong> host are searching in this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry tree for <strong>the</strong>ir dependencies<br />

(executables, header and library files). Use $(PTXDIST_SYSROOT_HOST)/bin <str<strong>on</strong>g>to</str<strong>on</strong>g> install executables,<br />

$(PTXDIST_SYSROOT_HOST)/include for header files and $(PTXDIST_SYSROOT_HOST)/lib for libraries.<br />

45


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

5.1.5 PTXDIST_SYSROOT_TARGET<br />

PTXDIST_SYSROOT_TARGET points <str<strong>on</strong>g>to</str<strong>on</strong>g> a direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry tree all target relevant libraries and header files are installed <str<strong>on</strong>g>to</str<strong>on</strong>g>.<br />

All project’s packages built for <strong>the</strong> target are searching in this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry tree for <strong>the</strong>ir dependencies (header and<br />

library files). These files are for compile time <strong>on</strong>ly (for example <str<strong>on</strong>g>to</str<strong>on</strong>g> link a target executable against a target library),<br />

not for runtime! Use $(PTXDIST_SYSROOT_TARGET)/include for header files and $(PTXDIST_SYSROOT_TARGET)/lib<br />

for libraries.<br />

O<strong>the</strong>r useful variables:<br />

5.1.6 CROSS_PATH<br />

Use <str<strong>on</strong>g>to</str<strong>on</strong>g> find cross <str<strong>on</strong>g>to</str<strong>on</strong>g>ols. This path must be used <str<strong>on</strong>g>to</str<strong>on</strong>g> create anything that depends <strong>on</strong> <strong>the</strong> target’s architecture, but<br />

needs something running <strong>on</strong> <strong>the</strong> host <str<strong>on</strong>g>to</str<strong>on</strong>g> do <strong>the</strong> job. Examples:<br />

Creating a jffs2 image from <strong>the</strong> target’s root filesystem This will need a <str<strong>on</strong>g>to</str<strong>on</strong>g>ol running <strong>on</strong> <strong>the</strong> host, but it will<br />

create data or code that runs <strong>on</strong> or is used <strong>on</strong> <strong>the</strong> target<br />

Building a library for <strong>the</strong> target If this library needs o<strong>the</strong>r resources <str<strong>on</strong>g>to</str<strong>on</strong>g> be built (o<strong>the</strong>r libraries) its c<strong>on</strong>figure<br />

finds <strong>the</strong> right informati<strong>on</strong> in this path.<br />

5.1.7 HOST_PATH<br />

Used <str<strong>on</strong>g>to</str<strong>on</strong>g> find host <str<strong>on</strong>g>to</str<strong>on</strong>g>ols. This path must be used <str<strong>on</strong>g>to</str<strong>on</strong>g> create anything that not depends <strong>on</strong> <strong>the</strong> architecture.<br />

5.1.8 ROOTDIR<br />

ROOTDIR points <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root of <strong>the</strong> target’s root filesystem in <strong>the</strong> current project. Used in very rare cases (<str<strong>on</strong>g>to</str<strong>on</strong>g> create<br />

strange packages based <strong>on</strong> data in target’s root filesystem for example).<br />

5.1.9 PTXCONF_PLATFORM<br />

PTXCONF_PLATFORMexpands <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> name of <strong>the</strong> currently selected platform. This name is used in various file names<br />

and paths.<br />

5.1.10 PTXDIST_PLATFORMSUFFIX<br />

PTXDIST_PLATFORMSUFFIX expands <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> name of <strong>the</strong> currently selected platform, but with a leading dot. This is<br />

used in various files <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> should search for.<br />

5.1.11 PTXDIST_PLATFORMCONFIGDIR<br />

PTXDIST_PLATFORMCONFIGDIR points <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry tree of <strong>the</strong> currently selected platform. This path is used in<br />

various search functi<strong>on</strong>s.<br />

5.1.12 PTXDIST_PLATFORMDIR<br />

PTXDIST_PLATFORMDIR points <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry build tree of <strong>the</strong> currently selected platform.<br />

46


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

5.2 Rule File Macro Reference<br />

Rules files in <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> are using macros <str<strong>on</strong>g>to</str<strong>on</strong>g> get things work. Its highly recommended <str<strong>on</strong>g>to</str<strong>on</strong>g> use <strong>the</strong>se macros instead<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> do something by ourself. Using <strong>the</strong> macros is portable and such easier <str<strong>on</strong>g>to</str<strong>on</strong>g> maintain in <strong>the</strong> case a project should<br />

be upgraded <str<strong>on</strong>g>to</str<strong>on</strong>g> a more recent <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> versi<strong>on</strong>.<br />

This chapter describes <strong>the</strong> predefined macros in <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> and <strong>the</strong>ir usage.<br />

Note: This list is not complete yet.<br />

5.2.1 targetinfo<br />

Usage:<br />

$(call targetinfo)<br />

Gives a feedback, what build stage is just started. Thats why it should always be <strong>the</strong> first call for each stage. For<br />

<strong>the</strong> package foo and <strong>the</strong> compile stage it will output:<br />

--------------------<br />

target: foo.compile<br />

--------------------<br />

5.2.2 <str<strong>on</strong>g>to</str<strong>on</strong>g>uch<br />

Usage:<br />

$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

Gives a feedback, what build stage is just finished. Thats why it should always be <strong>the</strong> last call for each stage. For<br />

<strong>the</strong> package foo and <strong>the</strong> compile stage it will output:<br />

finished target foo.compile<br />

5.2.3 clean<br />

Usage:<br />

$(call clean, )<br />

Removes <strong>the</strong> given direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry .<br />

5.2.4 install_copy<br />

Usage:<br />

$(call install_copy, , , , , [, ])<br />

Installs given file or direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry in<str<strong>on</strong>g>to</str<strong>on</strong>g>:<br />

47


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

• <strong>the</strong> project’s platform-versatilepb/root/<br />

• <strong>the</strong> project’s platform-versatilepb/root-debug/<br />

• an ipkg packet in <strong>the</strong> project’s platform-versatilepb/packages/<br />

Some of <strong>the</strong> parameters have fixed meanings:<br />

Name of <strong>the</strong> IPKG <strong>the</strong> macro should work <strong>on</strong><br />

User ID (in a numerical value) <strong>the</strong> file should use in <strong>the</strong> target’s root filesystem<br />

Group ID (in a numerical value) <strong>the</strong> file should use in <strong>the</strong> target’s root filesystem<br />

Permissi<strong>on</strong> (in an octal value) <strong>the</strong> file should use in <strong>the</strong> target’s root filesystem<br />

The remaining parameters vary with <strong>the</strong> use case:<br />

The parameter can be:<br />

• a direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry path that should be created in <strong>the</strong> target’s root filesystem. In this case <strong>the</strong> must<br />

be omitted. The given path must always start with a / and means <strong>the</strong> root of <strong>the</strong> target’s filesystem.<br />

• an absolute path <str<strong>on</strong>g>to</str<strong>on</strong>g> a file that should be copied <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> target’s root filesystem. To avoid fixed paths, all<br />

packages are providing <strong>the</strong> _DIR variable. So, this parameter in our foo example package can<br />

be a $(FOO_DIR)/foo.<br />

• a minus sign (-). <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> uses <strong>the</strong> parameter in this case <str<strong>on</strong>g>to</str<strong>on</strong>g> locate <strong>the</strong> file <str<strong>on</strong>g>to</str<strong>on</strong>g> copy from.<br />

This <strong>on</strong>ly works if <strong>the</strong> package uses <strong>the</strong> default install stage. Only in this case an additi<strong>on</strong>al folder in<br />

platform-versatilepb/packages will be created for <strong>the</strong> package and its files. For our foo example package<br />

this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry is platform-versatilepb/packages/foo-1.1.0.<br />

The parameter can be:<br />

• omitted if a direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry in target’s root filesystem should be created. For this case <strong>the</strong> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry <str<strong>on</strong>g>to</str<strong>on</strong>g> be created<br />

is in <strong>the</strong> parameter.<br />

• an absolute path and filename with its root in target’s root filesysem. It must start with a slash (/). If also<br />

<strong>the</strong> parameter was given, <strong>the</strong> file can be renamed while copying.<br />

If <strong>the</strong> parameter was given as a minus sign (-) <strong>the</strong> is also used <str<strong>on</strong>g>to</str<strong>on</strong>g> locate <strong>the</strong><br />

source. For our foo example package if we give as /usr/bin/foo, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> copies <strong>the</strong> file<br />

platform-versatilepb/packages/foo-1.1.0/usr/bin/foo<br />

Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> complexity of this macro, here are some usage examples:<br />

Create a direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry in <strong>the</strong> root filesystem:<br />

$(call install_copy, foo, 0, 0, 0755, /home/user-foo)<br />

Copy a file from <strong>the</strong> package build direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root filesystem:<br />

$(call install_copy, foo, 0, 0, 0755, $(FOO_DIR)/foo, /usr/bin/foo)<br />

Copy a file from <strong>the</strong> package build direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root filesystem and rename it:<br />

$(call install_copy, foo, 0, 0, 0755, $(FOO_DIR)/foo, /usr/bin/bar)<br />

Copy a file from <strong>the</strong> package install direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root filesystem:<br />

$(call install_copy, foo, 0, 0, 0755, -, /usr/bin/foo)<br />

48


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

5.2.5 install_tree<br />

Usage:<br />

$(call install_tree, , , , , )<br />

Installs <strong>the</strong> whole direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry tree with all files from <strong>the</strong> given direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry in<str<strong>on</strong>g>to</str<strong>on</strong>g>:<br />

• <strong>the</strong> project’s platform-versatilepb/root/<br />

• <strong>the</strong> project’s platform-versatilepb/root-debug/<br />

• an ipkg packet in <strong>the</strong> project’s platform-versatilepb/packages/<br />

Some of <strong>the</strong> parameters have fixed meanings:<br />

Name of <strong>the</strong> IPKG, <strong>the</strong> macro should work <strong>on</strong><br />

User ID (in a numerical value) <strong>the</strong> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries and files should use in target’s root filesystem<br />

Group ID (in a numerical value) <strong>the</strong> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries and files should use in target’s root filesystem<br />

This is <strong>the</strong> path <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> tree of direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries and files <str<strong>on</strong>g>to</str<strong>on</strong>g> be installed<br />

The basename of <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g> be installed tree in <strong>the</strong> root filesystem<br />

Note: This installati<strong>on</strong> macro<br />

• uses <strong>the</strong> same permissi<strong>on</strong> flags in <strong>the</strong> destinati<strong>on</strong> dir as found in <strong>the</strong> source dir. This is valid for direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries<br />

and regular files<br />

• skips all direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries with names like .svn, .git, .pc and CVS in <strong>the</strong> source direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry<br />

Examples:<br />

Install <strong>the</strong> whole tree found in /home/jbe/foo <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root filesystem at locati<strong>on</strong> /usr/share/bar.<br />

$(call install_tree, foo, 0, 0, /home/jbe/foo, /usr/share/bar)<br />

5.2.6 install_alternative<br />

Usage:<br />

$(call install_alternative, , , , , )<br />

Installs given files or direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries in<str<strong>on</strong>g>to</str<strong>on</strong>g>:<br />

• <strong>the</strong> project’s platform-versatilepb/root/<br />

• <strong>the</strong> project’s platform-versatilepb/root-debug/<br />

• an ipkg packet in <strong>the</strong> project’s platform-versatilepb/packages/<br />

The base parameters and <strong>the</strong>ir meanings:<br />

Name of <strong>the</strong> IPKG, <strong>the</strong> macro should work <strong>on</strong><br />

User ID (in a numerical value) <strong>the</strong> file should use in target’s root filesystem<br />

Group ID (in a numerical value) <strong>the</strong> file should use in target’s root filesystem<br />

Permissi<strong>on</strong> (in an octal value) <strong>the</strong> file should use in target’s root filesystem<br />

49


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

The parameter is meant as an absolute path and filename in target’s root filesystem. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g><br />

searches for <strong>the</strong> source of this file in:<br />

• <strong>the</strong> local project<br />

• in <strong>the</strong> used platform<br />

• <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s install path<br />

• in <strong>the</strong> current package<br />

As this search algorithm is complex, here an example for <strong>the</strong> file /etc/foo in package FOO. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> will search for<br />

this file in <strong>the</strong> following order:<br />

• project’s direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry projectroot.versatilepb/etc/foo<br />

• project’s direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry projectroot/etc/foo.versatilepb<br />

• project’s direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry c<strong>on</strong>figs/arm-qemu-2011.01.0/projectroot/etc/foo<br />

• project’s direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry projectroot/etc/foo<br />

• ptxdist’s direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry generic/etc/foo<br />

• project’s direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry $(FOO_DIR)/etc/foo<br />

The generic rules are looking like <strong>the</strong> following:<br />

• $(PTXDIST_WORKSPACE)/projectroot$(PTXDIST_PLATFORMSUFFIX)/etc/foo<br />

• $(PTXDIST_WORKSPACE)/projectroot/etc/foo$(PTXDIST_PLATFORMSUFFIX)<br />

• $(PTXDIST_PLATFORMCONFIGDIR)/projectroot/etc/foo<br />

• $(PTXDIST_WORKSPACE)/projectroot/etc/foo<br />

• $(PTXDIST_TOPDIR)/generic/etc/foo<br />

• $(FOO_DIR)/etc/foo<br />

Note: You can get <strong>the</strong> current values for <strong>the</strong> listed variables above via running <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> with <strong>the</strong> print parameter:<br />

ptxdist print PTXDIST_PLATFORMSUFFIX<br />

5.2.7 install_link<br />

Usage:<br />

$(call install_link, , , )<br />

Installs a symbolic link in<str<strong>on</strong>g>to</str<strong>on</strong>g>:<br />

• <strong>the</strong> project’s platform-versatilepb/root/<br />

• <strong>the</strong> project’s platform-versatilepb/root-debug/<br />

• an ipkg packet in <strong>the</strong> project’s platform-versatilepb/packages/<br />

The parameters and <strong>the</strong>ir meanings:<br />

Name of <strong>the</strong> IPKG, <strong>the</strong> macro should work <strong>on</strong><br />

Path and name <strong>the</strong> link should point <str<strong>on</strong>g>to</str<strong>on</strong>g>. Note: This macro rejects absolute paths. If needed use<br />

relative paths instead.<br />

50


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

Path and name of <strong>the</strong> symbolic link.<br />

A few usage examples.<br />

Create a symbolic link as /usr/lib/libfoo.so pointing <str<strong>on</strong>g>to</str<strong>on</strong>g> libfoo.so.1.1.0 in <strong>the</strong> same direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry:<br />

$(call install_link, foo, libfoo.so.1.1.0, /usr/lib/libfoo.so)<br />

Create a symbolic link as /usr/bin/foo pointing <str<strong>on</strong>g>to</str<strong>on</strong>g> /bin/bar:<br />

$(call install_link, foo, ../../bin/bar, /usr/bin/foo)<br />

5.2.8 install_archive<br />

Usage:<br />

$(call install_archive, , , , , )<br />

Installs archives c<strong>on</strong>tent in<str<strong>on</strong>g>to</str<strong>on</strong>g>:<br />

• <strong>the</strong> project’s platform-versatilepb/root/<br />

• <strong>the</strong> project’s platform-versatilepb/root-debug/<br />

• an ipkg packet in <strong>the</strong> project’s platform-versatilepb/packages/<br />

All parameters have fixed meanings:<br />

Name of <strong>the</strong> IPKG, <strong>the</strong> macro should work <strong>on</strong><br />

User ID (in a numerical value) all files and direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry of <strong>the</strong> archive should use in target’s root filesystem.<br />

A ’-’ uses file’s/direc<str<strong>on</strong>g>to</str<strong>on</strong>g>rie’s UID in <strong>the</strong> archive<br />

Group ID (in a numerical value) <strong>the</strong> files and direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries should use in target’s root filesystem. A ’-’ uses<br />

file’s/direc<str<strong>on</strong>g>to</str<strong>on</strong>g>rie’s GID in <strong>the</strong> archive<br />

Name of <strong>the</strong> archive <str<strong>on</strong>g>to</str<strong>on</strong>g> be used in this call. The given path and filename is used as is<br />

Base path comp<strong>on</strong>ent in <strong>the</strong> root filesystem <strong>the</strong> archive should be extracted <str<strong>on</strong>g>to</str<strong>on</strong>g>. Can be just ’/’ for<br />

root.<br />

5.3 Rule file layout<br />

Each rule file provides <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> with <strong>the</strong> required steps <str<strong>on</strong>g>to</str<strong>on</strong>g> be d<strong>on</strong>e <strong>on</strong> a per package base:<br />

• get<br />

• extract<br />

• prepare<br />

• compile<br />

• install<br />

• targetinstall<br />

51


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

5.3.1 Default stage rules<br />

As for most packages <strong>the</strong>se steps can be d<strong>on</strong>e in a default way, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides generic rules for each package.<br />

If a package’s rule file does not provide a specific stage rule, <strong>the</strong> default stage rule will be used instead.<br />

Omitting <strong>on</strong>e of <strong>the</strong> stage rules does not mean that <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> skips this stage!<br />

In this case <strong>the</strong> default stage rule is used instead.<br />

get Stage Default Rule<br />

If <strong>the</strong> get stage is omitted, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> runs instead:<br />

$(STATEDIR)/@package@.get:<br />

@$(call targetinfo)<br />

@$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

Which means this step is skipped.<br />

If <strong>the</strong> package is an archive that must be downloaded from <strong>the</strong> web, <strong>the</strong> following rule must exist in this case:<br />

$(@package@_SOURCE):<br />

@$(call targetinfo)<br />

@$(call get, @package@)<br />

extract Stage Default Rule<br />

If <strong>the</strong> extract stage is omitted, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> runs instead:<br />

$(STATEDIR)/@package@.extract:<br />

@$(call targetinfo)<br />

@$(call clean, $(@package@_DIR))<br />

@$(call extract, @package@)<br />

@$(call patchin, @package@)<br />

@$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

prepare Stage Default Rule<br />

If <strong>the</strong> prepare stage is omitted, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> runs a default stage rule depending <strong>on</strong> some variable settings.<br />

If <strong>the</strong> package’s rule file defines a @package@_AUTOCONF variable (FOO_AUTOCONF for our foo example), <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> treats<br />

this package as an au<str<strong>on</strong>g>to</str<strong>on</strong>g><str<strong>on</strong>g>to</str<strong>on</strong>g>olized package and runs:<br />

$(STATEDIR)/@package@.prepare:<br />

@$(call targetinfo)<br />

@$(call clean, $(@package@_DIR)/c<strong>on</strong>fig.cache)<br />

cd $(@package@_DIR)/$(@package@_SUBDIR) && \<br />

$(@package@_PATH) $(@package@_ENV) \<br />

./c<strong>on</strong>figure $(@package@_AUTOCONF)<br />

@$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

52


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

If <strong>the</strong> package’s rule file defines a @package@_CMAKE variable (FOO_CMAKE for our foo example), <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> treats this<br />

package as a cmake based package and runs:<br />

$(STATEDIR)/@package@.prepare:<br />

@$(call targetinfo)<br />

@$(call clean, $(@package@_DIR)/c<strong>on</strong>fig.cache)<br />

cd $(@package@_DIR) && \<br />

$(@package@_PATH) $(@package@_ENV) \<br />

cmake $(@package@_CMAKE)<br />

@$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

compile Stage Default Rule<br />

If <strong>the</strong> compile stage is omitted, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> runs instead:<br />

$(STATEDIR)/@package@.compile:<br />

@$(call targetinfo)<br />

cd $(@package@_DIR) && \<br />

$(@package@_PATH) $(@package@_MAKE_ENV) \<br />

$(MAKE) $(@package@_MAKE_OPT) $(@package@_MAKE_PAR)<br />

@$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

Note: @package@_MAKE_PAR can be defined <str<strong>on</strong>g>to</str<strong>on</strong>g> YES or NO <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>trol if <strong>the</strong> package can be built in parallel.<br />

install Stage Default Rule<br />

If <strong>the</strong> install stage is omitted, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> runs instead:<br />

$(STATEDIR)/@package@.install:<br />

@$(call targetinfo)<br />

cd $(@package@_DIR) && \<br />

$(@package@_PATH) $(@package@_MAKE_ENV) \<br />

$(MAKE) $(@package@_INSTALL_OPT)<br />

@$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

Note: @package@_INSTALL_OPT is always defined <str<strong>on</strong>g>to</str<strong>on</strong>g> install if not o<strong>the</strong>rwise specified. This value can be replaced<br />

by a package’s rule file definiti<strong>on</strong>.<br />

targetinstall Stage Default Rule<br />

There is no default rule for a package’s targetinstall state. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> has no idea what is required <strong>on</strong> <strong>the</strong> target at<br />

runtime. This stage is up <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> developer <strong>on</strong>ly. Refer <str<strong>on</strong>g>to</str<strong>on</strong>g> secti<strong>on</strong> 5.2 for fur<strong>the</strong>r info <strong>on</strong> how <str<strong>on</strong>g>to</str<strong>on</strong>g> select files <str<strong>on</strong>g>to</str<strong>on</strong>g> be<br />

included in <strong>the</strong> target’s root filesystem.<br />

5.3.2 Skipping a Stage<br />

For <strong>the</strong> case that a specific stage should be skipped, an empty rule must be provided:<br />

$(STATEDIR)/@package@.:<br />

@$(call targetinfo)<br />

@$(call <str<strong>on</strong>g>to</str<strong>on</strong>g>uch)<br />

Replace <strong>the</strong> by get, extract, prepare, compile, install or targetinstall.<br />

53


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

5.4 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> parameter reference<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is a command line <str<strong>on</strong>g>to</str<strong>on</strong>g>ol, which is basicly called as:<br />

$ ptxdist [opti<strong>on</strong>s]<br />

5.4.1 Setup and Project Acti<strong>on</strong>s<br />

menu: This will start a menu fr<strong>on</strong>tend <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>trol some of <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>’s features in a menu based c<strong>on</strong>venient way. This<br />

menu handles <strong>the</strong> acti<strong>on</strong>s menuc<strong>on</strong>fig, platformc<strong>on</strong>fig, kernel c<strong>on</strong>fig, select, platform, boardsetup, setup, go and<br />

images.<br />

select : This acti<strong>on</strong> will select a userland c<strong>on</strong>figurati<strong>on</strong>. This step is <strong>on</strong>ly required in projects, where<br />

no selected_ptxc<strong>on</strong>fig file is present. The argument must point <str<strong>on</strong>g>to</str<strong>on</strong>g> a valid userland c<strong>on</strong>figurati<strong>on</strong> file.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides this feature <str<strong>on</strong>g>to</str<strong>on</strong>g> enable <strong>the</strong> user <str<strong>on</strong>g>to</str<strong>on</strong>g> maintain more than <strong>on</strong>e userland c<strong>on</strong>figurati<strong>on</strong> in <strong>the</strong> same<br />

project.<br />

platform : This acti<strong>on</strong> will select a platform c<strong>on</strong>figurati<strong>on</strong>. This step is <strong>on</strong>ly required in projects, where<br />

no selected_platform file is present. The argument must point <str<strong>on</strong>g>to</str<strong>on</strong>g> a valid platform c<strong>on</strong>figurati<strong>on</strong> file.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides this feature <str<strong>on</strong>g>to</str<strong>on</strong>g> enable <strong>the</strong> user <str<strong>on</strong>g>to</str<strong>on</strong>g> maintain more than <strong>on</strong>e platform in <strong>on</strong>e project.<br />

setup: <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> uses some global settings, independent from <strong>the</strong> project it is working <strong>on</strong>. These settings bel<strong>on</strong>g<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> users preferences or simply some network settings <str<strong>on</strong>g>to</str<strong>on</strong>g> permit <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> download required packages.<br />

boardsetup: <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> based projects can provide informati<strong>on</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g> setup and c<strong>on</strong>figure <strong>the</strong> target au<str<strong>on</strong>g>to</str<strong>on</strong>g>matically. This<br />

acti<strong>on</strong> let <strong>the</strong> user setup <strong>the</strong> envir<strong>on</strong>ment specific settings like <strong>the</strong> network IP address and so <strong>on</strong>.<br />

projects: If <strong>the</strong> generic projects coming in a separate archive are installed, this acti<strong>on</strong>s lists <strong>the</strong> projects a user<br />

can cl<strong>on</strong>e for its own work.<br />

cl<strong>on</strong>e : This acti<strong>on</strong> cl<strong>on</strong>es an existing project from <strong>the</strong> projects list in<str<strong>on</strong>g>to</str<strong>on</strong>g> a new direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. The<br />

argument must be a name gotten from ptxdist projects command, <strong>the</strong> argument is <strong>the</strong> new project<br />

(and direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry) name, creeated in <strong>the</strong> current direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />

menuc<strong>on</strong>fig: Start <strong>the</strong> menu <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure <strong>the</strong> project’s root filesystem. This is in respect <str<strong>on</strong>g>to</str<strong>on</strong>g> userland <strong>on</strong>ly. Its <strong>the</strong><br />

main menu <str<strong>on</strong>g>to</str<strong>on</strong>g> select applicati<strong>on</strong>s and libraries, <strong>the</strong> root filesystem of <strong>the</strong> target should c<strong>on</strong>sist of.<br />

menuc<strong>on</strong>fig platform: This acti<strong>on</strong> starts <strong>the</strong> menu <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure platform’s settings. As <strong>the</strong>se are architecture and<br />

target specific settings it c<strong>on</strong>figures <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain, <strong>the</strong> kernel and a bootloader (but no userland comp<strong>on</strong>ents).<br />

Due <str<strong>on</strong>g>to</str<strong>on</strong>g> a project can support more than <strong>on</strong>e platform, this will c<strong>on</strong>figure <strong>the</strong> currently selected platform. The<br />

shortform for this acti<strong>on</strong> is platformc<strong>on</strong>fig.<br />

menuc<strong>on</strong>fig kernel: Start <strong>the</strong> menu <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure <strong>the</strong> platform’s kernel. As a project can support more than <strong>on</strong>e<br />

platform, this will c<strong>on</strong>figure <strong>the</strong> currently selected platform. The shortform for this acti<strong>on</strong> is kernelc<strong>on</strong>fig.<br />

menuc<strong>on</strong>fig u-boot-v2 | barebox: This acti<strong>on</strong> starts <strong>the</strong> c<strong>on</strong>figure menu for <strong>the</strong> selected bootloader. It depends<br />

<strong>on</strong> <strong>the</strong> platform settings which bootloader is enabled and <str<strong>on</strong>g>to</str<strong>on</strong>g> be used as an argument <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> menuc<strong>on</strong>fig acti<strong>on</strong> parameter.<br />

Due <str<strong>on</strong>g>to</str<strong>on</strong>g> a project can support more than <strong>on</strong>e platform, this will c<strong>on</strong>figure <strong>the</strong> bootloader of <strong>the</strong> currently<br />

selected platform. The shortform for this acti<strong>on</strong> is platformc<strong>on</strong>fig.<br />

5.4.2 Build Acti<strong>on</strong>s<br />

go: This acti<strong>on</strong> will build all enabled packages in <strong>the</strong> current project c<strong>on</strong>figurati<strong>on</strong>s (platform and userland). It<br />

will also rebuild rec<strong>on</strong>figured packages if any or build additi<strong>on</strong>al packages if <strong>the</strong>y where enabled meanwhile. If<br />

enables this step also builds <strong>the</strong> kernel and bootloader image.<br />

54


5 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Reference<br />

images: Most of <strong>the</strong> time this is <strong>the</strong> last step <str<strong>on</strong>g>to</str<strong>on</strong>g> get <strong>the</strong> required files and/or images for <strong>the</strong> target. It creates<br />

filesystems or device images <str<strong>on</strong>g>to</str<strong>on</strong>g> be used in c<strong>on</strong>juncti<strong>on</strong> with <strong>the</strong> target’s filesystem media. The result can be<br />

found in <strong>the</strong> images/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry of <strong>the</strong> project or <strong>the</strong> platform direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />

5.4.3 Clean Acti<strong>on</strong>s<br />

clean: The cleanacti<strong>on</strong> will remove all generated files while <strong>the</strong> last gorun: All build, packages and root filesystem<br />

direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries. Only <strong>the</strong> selected c<strong>on</strong>figurati<strong>on</strong> files are left un<str<strong>on</strong>g>to</str<strong>on</strong>g>uched. This is a way <str<strong>on</strong>g>to</str<strong>on</strong>g> start a fresh build cycle.<br />

clean root: This acti<strong>on</strong> will <strong>on</strong>ly clean <strong>the</strong> root filesystem direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries. All <strong>the</strong> build direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries are left un<str<strong>on</strong>g>to</str<strong>on</strong>g>uched.<br />

Using this acti<strong>on</strong> will regenerate all ipkg packets from <strong>the</strong> already built packages and also <strong>the</strong> root filesystem<br />

direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries in <strong>the</strong> next go acti<strong>on</strong>. The clean root and go acti<strong>on</strong> is usefull, if <strong>the</strong> targetinstall stage for all packages<br />

should run again.<br />

distclean: The distcleanacti<strong>on</strong> will remove all files that are not part of <strong>the</strong> main project. It removes all generated<br />

files and direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries like <strong>the</strong> clean acti<strong>on</strong> and also <strong>the</strong> created links in any platform and/or select acti<strong>on</strong>.<br />

55


6 Various Aspects of Daily Work<br />

6.1 Using an External Kernel Source Tree<br />

This applicati<strong>on</strong> note describes how <str<strong>on</strong>g>to</str<strong>on</strong>g> use an external kernel source tree within a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> project. In this case<br />

<strong>the</strong> external kernel source tree is managed by GIT.<br />

6.1.1 Cl<strong>on</strong>ing <strong>the</strong> Linux Kernel Source Tree<br />

In this example we are using <strong>the</strong> officiall Linux kernel developmen tree.<br />

jbe@oc<str<strong>on</strong>g>to</str<strong>on</strong>g>pus:~$ git cl<strong>on</strong>e git://git.kernel.org/pub/scm/linux/kernel/git/<str<strong>on</strong>g>to</str<strong>on</strong>g>rvalds/linux-2.6<br />

[...]<br />

jbe@oc<str<strong>on</strong>g>to</str<strong>on</strong>g>pus:~$ ls -l<br />

[...]<br />

drwxr-xr-x 38 jbe ptx 4096 2009-03-17 10:21 myprj<br />

drwxr-xr-x 25 jbe ptx 4096 2009-03-17 10:42 linux-2.6<br />

[...]<br />

6.1.2 C<strong>on</strong>figuring <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g><br />

To make <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> use of this kernel source tree, we run<br />

jbe@oc<str<strong>on</strong>g>to</str<strong>on</strong>g>pus:~$ ptxdist setup<br />

and navigate <str<strong>on</strong>g>to</str<strong>on</strong>g> Source Direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries, Prefix for kernel trees and enter <strong>the</strong> base path <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> kernel source tree in<str<strong>on</strong>g>to</str<strong>on</strong>g><br />

this menu entry (omit <strong>the</strong> kernel source tree direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry name itself). The kernel source tree direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry <str<strong>on</strong>g>to</str<strong>on</strong>g> be used in<br />

this base path will be setup <strong>on</strong> a per project base. So it will be possible <str<strong>on</strong>g>to</str<strong>on</strong>g> place more than <strong>on</strong>e kernel source tree<br />

in <strong>the</strong> base path.<br />

6.1.3 C<strong>on</strong>figuring <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> Project<br />

Now we can setup this kernel source tree <str<strong>on</strong>g>to</str<strong>on</strong>g> be used in our project. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> will handle it in <strong>the</strong> same way as a<br />

kernel part of <strong>the</strong> project. Due <str<strong>on</strong>g>to</str<strong>on</strong>g> this, we must setup:<br />

• Some kind of kernel versi<strong>on</strong><br />

• Kernel c<strong>on</strong>figurati<strong>on</strong><br />

• Image type used <strong>on</strong> our target architecture<br />

• If we want <str<strong>on</strong>g>to</str<strong>on</strong>g> build modules<br />

• Patches <str<strong>on</strong>g>to</str<strong>on</strong>g> be used (or not)<br />

56


6 Various Aspects of Daily Work<br />

Let’s setup <strong>the</strong>se <str<strong>on</strong>g>to</str<strong>on</strong>g>pics. Assumpti<strong>on</strong> is here, <strong>the</strong> direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry /myprj c<strong>on</strong>tains a valid <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> project. We just add<br />

<strong>the</strong> kernel comp<strong>on</strong>ent <str<strong>on</strong>g>to</str<strong>on</strong>g> it.<br />

jbe@oc<str<strong>on</strong>g>to</str<strong>on</strong>g>pus:~$ cd myprj<br />

jbe@oc<str<strong>on</strong>g>to</str<strong>on</strong>g>pus:~/myprj$ ptxdist platformc<strong>on</strong>fig<br />

We must enable <strong>the</strong> Linux kernel entry first, <str<strong>on</strong>g>to</str<strong>on</strong>g> enable kernel building as part of <strong>the</strong> project. After enabling this<br />

entry, we must enter this entry, and:<br />

• Setting up <strong>the</strong> kernel versi<strong>on</strong> with <strong>the</strong> name of kernel source tree direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. In our case shown above it<br />

would be linux-2.6.<br />

• Selecting <strong>the</strong> correct image type in <strong>the</strong> entry Image Type.<br />

• C<strong>on</strong>figuring <strong>the</strong> kernel within <strong>the</strong> menu entry patching & c<strong>on</strong>figurati<strong>on</strong>.<br />

– If no patches should be used <strong>on</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>p of <strong>the</strong> selected kernel source tree, we keep <strong>the</strong> patch series file<br />

entry empty. As GIT should help us <str<strong>on</strong>g>to</str<strong>on</strong>g> create <strong>the</strong>se patches for deployment, it should be kept empty<br />

<strong>on</strong> default in this first step.<br />

– Select a name for <strong>the</strong> kernel c<strong>on</strong>figurati<strong>on</strong> file and enter it in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> kernel c<strong>on</strong>fig file entry.<br />

• As we want <str<strong>on</strong>g>to</str<strong>on</strong>g> use an existing kernel source tree we also must enable <strong>the</strong> Local kernel tree menu entry.<br />

Now we can leave <strong>the</strong> menu and s<str<strong>on</strong>g>to</str<strong>on</strong>g>re <strong>the</strong> new setup. The <strong>on</strong>ly still missing comp<strong>on</strong>ent is a valid kernel c<strong>on</strong>fig<br />

file now. We can use <strong>on</strong>e of <strong>the</strong> default c<strong>on</strong>fig files <strong>the</strong> Linux kernel supports as a starting point. To do so, we<br />

copy <strong>on</strong>e <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> locati<strong>on</strong>, where <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> expects it in <strong>the</strong> current project. In a multi platform project this locati<strong>on</strong><br />

is <strong>the</strong> platform direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry usally in c<strong>on</strong>figs/. We must s<str<strong>on</strong>g>to</str<strong>on</strong>g>re <strong>the</strong> file with a name selected in<br />

<strong>the</strong> platform setup menu (kernel c<strong>on</strong>fig file).<br />

6.1.4 Work Flow<br />

Now its up <str<strong>on</strong>g>to</str<strong>on</strong>g> ourself working <strong>on</strong> <strong>the</strong> GIT based kernel source tree and using <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> include <strong>the</strong> kernel in<str<strong>on</strong>g>to</str<strong>on</strong>g><br />

<strong>the</strong> root filesystem.<br />

To c<strong>on</strong>figure <strong>the</strong> kernel source tree, we simply run:<br />

jbe@oc<str<strong>on</strong>g>to</str<strong>on</strong>g>pus:~/myprj$ ptxdist kernelc<strong>on</strong>fig<br />

To build <strong>the</strong> kernel:<br />

jbe@oc<str<strong>on</strong>g>to</str<strong>on</strong>g>pus:~/myprj$ ptxdist targetinstall kernel<br />

To rebuild <strong>the</strong> kernel:<br />

jbe@oc<str<strong>on</strong>g>to</str<strong>on</strong>g>pus:~/myprj$ ptxdist drop kernel targetinstall<br />

jbe@oc<str<strong>on</strong>g>to</str<strong>on</strong>g>pus:~/myprj$ ptxdist targetinstall kernel<br />

6.2 Discovering Runtime Dependencies<br />

Often it happens that an applicati<strong>on</strong> <strong>on</strong> <strong>the</strong> target fails <str<strong>on</strong>g>to</str<strong>on</strong>g> run, because <strong>on</strong>e of its dependencies is not fulfilled.<br />

This secti<strong>on</strong> should give some hints <strong>on</strong> how <str<strong>on</strong>g>to</str<strong>on</strong>g> discover <strong>the</strong>se dependencies.<br />

57


6 Various Aspects of Daily Work<br />

6.2.1 Dependencies <strong>on</strong> Shared Libraries<br />

Getting <strong>the</strong> missed shared library for example at runtime is something easily d<strong>on</strong>e: The dynamic linker prints <strong>the</strong><br />

missing library <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> c<strong>on</strong>sole.<br />

To check at build time if all o<strong>the</strong>r dependencies are present is easy, <str<strong>on</strong>g>to</str<strong>on</strong>g>o. The architecture specific readelf <str<strong>on</strong>g>to</str<strong>on</strong>g>ol<br />

can help us here. It comes with <strong>the</strong> OSELAS.Toolchain and is called via arm-v4t-linux-gnueabi-readelf (this<br />

example uses <strong>the</strong> <strong>on</strong>e coming with <strong>the</strong> arm-v4t-linux-gnueabi <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain).<br />

To test <strong>the</strong> foo binary from our new package FOO, we simply run:<br />

$ arm-v4t-linux-gnueabi-readelf -d platform-versatilepb/root/usr/bin/foo | grep NEEDED<br />

0x00000001 (NEEDED)<br />

Shared library: [libm.so.6]<br />

0x00000001 (NEEDED)<br />

Shared library: [libz.so.1]<br />

0x00000001 (NEEDED)<br />

Shared library: [libc.so.6]<br />

We now can check if all of <strong>the</strong> listed libraries are present in <strong>the</strong> root filesystem. This works for shared libraries,<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g>o. It is also a way <str<strong>on</strong>g>to</str<strong>on</strong>g> check if various c<strong>on</strong>figurati<strong>on</strong>s of our package are working as expected (e.g. disabling a<br />

feature should also remove <strong>the</strong> required dependency of this feature).<br />

6.2.2 Dependencies <strong>on</strong> o<strong>the</strong>r Resources<br />

Sometimes a binary fails <str<strong>on</strong>g>to</str<strong>on</strong>g> run due <str<strong>on</strong>g>to</str<strong>on</strong>g> missing files, direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ries or device nodes. Often <strong>the</strong> error message (if any)<br />

that <strong>the</strong> binary creates in this case is ambiguous. Here <strong>the</strong> strace <str<strong>on</strong>g>to</str<strong>on</strong>g>ol can help us, namely <str<strong>on</strong>g>to</str<strong>on</strong>g> observe <strong>the</strong> binary<br />

at runtime. strace shows all <strong>the</strong> system calls that <strong>the</strong> binary or its shared libraries are performing.<br />

strace is <strong>on</strong>e of <strong>the</strong> target debugging <str<strong>on</strong>g>to</str<strong>on</strong>g>ols which <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> provides in its Debug Tools menu.<br />

After adding strace <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root filesystem, we can use it and observe our foo binary:<br />

$ strace usr/bin/foo<br />

execve(”/usr/bin/foo”, [”/usr/bin/foo”], [/* 41 vars */]) = 0<br />

brk(0)<br />

= 0x8e4b000<br />

access(”/etc/ld.so.preload”, R_OK) = -1 ENOENT (No such file or direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry)<br />

open(”/etc/ld.so.cache”, O_RDONLY) = 3<br />

fstat64(3, {st_mode=S_IFREG|0644, st_size=77488, ...}) = 0<br />

mmap2(NULL, 77488, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f87000<br />

close(3) = 0<br />

open(”/lib//lib/libm-2.5.1.so”, O_RDONLY) = 3<br />

read(3, ”\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p%\0\000”..., 512) = 512<br />

mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f86000<br />

fstat64(3, {st_mode=S_IFREG|0555, st_size=48272, ...}) = 0<br />

mmap2(NULL, 124824, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7f67000<br />

mmap2(0xb7f72000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xb) = 0xb7f72000<br />

mmap2(0xb7f73000, 75672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f73000<br />

close(3) = 0<br />

open(”/lib/libc.so.6”, O_RDONLY) = 3<br />

read(3, ”\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\332X\1”..., 512) = 512<br />

fstat64(3, {st_mode=S_IFREG|0755, st_size=1405859, ...}) = 0<br />

[...]<br />

Occasi<strong>on</strong>ally <strong>the</strong> output of strace can be very l<strong>on</strong>g and <strong>the</strong> interesting parts are lost. So, if we assume <strong>the</strong> binary<br />

tries <str<strong>on</strong>g>to</str<strong>on</strong>g> open a n<strong>on</strong>existing file, we can limit <strong>the</strong> output <str<strong>on</strong>g>to</str<strong>on</strong>g> all open system calls:<br />

58


6 Various Aspects of Daily Work<br />

$ strace -e open usr/bin/foo<br />

open(”/etc/ld.so.cache”, O_RDONLY) = 3<br />

open(”/lib/libm-2.5.1.so”, O_RDONLY) = 3<br />

open(”/lib/libz.so.1.2.3”, O_RDONLY) = 3<br />

open(”/lib/libc.so.6”, O_RDONLY) = 3<br />

[...]<br />

open(”/etc/foo.c<strong>on</strong>f”, O_RDONLY) = -1 ENOENT (No such file or direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry)<br />

The binary may fail due <str<strong>on</strong>g>to</str<strong>on</strong>g> a missing /etc/foo.c<strong>on</strong>f. This could be a hint <strong>on</strong> what is going wr<strong>on</strong>g (it might not be<br />

<strong>the</strong> final soluti<strong>on</strong>).<br />

6.3 Debugging with CPU emulati<strong>on</strong><br />

If we do not need some target related feature <str<strong>on</strong>g>to</str<strong>on</strong>g> run our applicati<strong>on</strong>, we can also debug it through a simple CPU<br />

emulati<strong>on</strong>. Thanks <str<strong>on</strong>g>to</str<strong>on</strong>g> QEMU we can run ELF binaries for o<strong>the</strong>r architectures than our build host is.<br />

6.3.1 Running an Applicati<strong>on</strong> made for a different Architecture<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> creates a fully working root filesystem with all runtime comp<strong>on</strong>ents in platform-versatilepb/root/. Lets<br />

assume we made a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> based project for a arm926 CPU. Part of this project is our applicati<strong>on</strong> myapp we are<br />

currently working <strong>on</strong>. <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> builds <strong>the</strong> root filesystem and also compiles our applicati<strong>on</strong>. It also installs it <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

usr/bin/myapp in <strong>the</strong> root filesystem.<br />

With this preparati<strong>on</strong> we can run it <strong>on</strong> our build host:<br />

$ cd platform-versatilepb/root<br />

platform-versatilepb/root $ qemu-arm -cpu arm926 -L . usr/bin/myapp<br />

This command will run <strong>the</strong> applicati<strong>on</strong> usr/bin/myapp built for an arm926 CPU <strong>on</strong> <strong>the</strong> build host and is using all<br />

library comp<strong>on</strong>tents from <strong>the</strong> current direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />

For <strong>the</strong> stdin and -out QEMU uses <strong>the</strong> regular mechanism of <strong>the</strong> build host’s operating system. Using QEMU in<br />

this way let us simply check our programs. There are also QEMU envir<strong>on</strong>ments for o<strong>the</strong>r architectures available.<br />

6.3.2 Debugging an Applicati<strong>on</strong> made for a different Architecture<br />

Debugging our applicati<strong>on</strong> is also possible with QEMU. All we need are a root filesystem with debug symbols<br />

available, QEMU and an architecture aware debugger.<br />

The root filesystem with debug symbols will be provided by <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>, <strong>the</strong> architecture aware debugger comes with<br />

<strong>the</strong> OSELAS.Toolchain. Two c<strong>on</strong>soles are required for this debug sessi<strong>on</strong> in this example. We start <strong>the</strong> QEMU in<br />

<strong>the</strong> first c<strong>on</strong>sole as:<br />

$ cd platform-versatilepb/root-debug<br />

platform-versatilepb/root-debug $ qemu-arm -g 1234 -cpu arm926 -L . usr/bin/myapp<br />

Note: <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> always builds two root filesystems. platform-versatilepb/root/and platform-versatilepb/root-debug/.<br />

platform-versatilepb/root/ c<strong>on</strong>tains all comp<strong>on</strong>ents without debug informati<strong>on</strong> (all binaries are in <strong>the</strong> same<br />

size as used later <strong>on</strong> <strong>on</strong> <strong>the</strong> real target), while all comp<strong>on</strong>ents in platform-versatilepb/root-debug/ still<br />

c<strong>on</strong>taining <strong>the</strong> debug symbols and are much bigger in size.<br />

59


6 Various Aspects of Daily Work<br />

The added -g 1234 parameter lets QEMU wait for a GDB c<strong>on</strong>necti<strong>on</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g> run <strong>the</strong> applicati<strong>on</strong>.<br />

In <strong>the</strong> sec<strong>on</strong>d c<strong>on</strong>sole we start GDB with <strong>the</strong> correct architecture support. This GDB comes with <strong>the</strong> same OS-<br />

ELAS.Toolchain that was also used <str<strong>on</strong>g>to</str<strong>on</strong>g> build <strong>the</strong> project. In our example we are using <strong>the</strong> arm-v4t-linux-gnueabi<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g>olchain for our qemu-arm CPU:<br />

$ arm-v4t-linux-gnueabi-gdbtui root-debug/usr/bin/myapp<br />

This will run a curses based GDB. Not so easy <str<strong>on</strong>g>to</str<strong>on</strong>g> handle (we must enter all <strong>the</strong> commands and cannot click with<br />

a mouse!), but very fast <str<strong>on</strong>g>to</str<strong>on</strong>g> take a quick look at our applicati<strong>on</strong>.<br />

At first we tell GDB where <str<strong>on</strong>g>to</str<strong>on</strong>g> look for debug symbols. The correct direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry here is platform-versatilepb/root-debug/.<br />

(gdb) set solib-absolute-prefix platform-versatilepb/root-debug<br />

Next we c<strong>on</strong>nect this GDB <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> waiting QEMU:<br />

(gdb) target remote localhost:1234<br />

Remote debugging using localhost:1234<br />

[New Thread 1]<br />

0x40096a7c in _start () from root-debug/lib/ld.so.1<br />

As our applicati<strong>on</strong> is already started, we can’t use <strong>the</strong> GDB command start <str<strong>on</strong>g>to</str<strong>on</strong>g> run it until it reaches main(). We<br />

set a breakpoint instead at main() and c<strong>on</strong>tinue <strong>the</strong> applicati<strong>on</strong>:<br />

(gdb) break main<br />

Breakpoint 1 at 0x100024e8: file myapp.c, line 644.<br />

(gdb) c<strong>on</strong>tinue<br />

C<strong>on</strong>tinuing.<br />

Breakpoint 1, main (argc=1, argv=0x4007f03c) at myapp.c:644<br />

The <str<strong>on</strong>g>to</str<strong>on</strong>g>p part of <strong>the</strong> running gdbtui c<strong>on</strong>sole will always show us <strong>the</strong> current source line. Due <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> root-debug/<br />

direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry usage all debug informati<strong>on</strong> for GDB is available.<br />

Now we can step through our applicati<strong>on</strong> by using <strong>the</strong> commands step, next, stepi, nexti, until and so <strong>on</strong>.<br />

Note: It might be impossible for GDB <str<strong>on</strong>g>to</str<strong>on</strong>g> find debug symbols for comp<strong>on</strong>ents like <strong>the</strong> main C runtime library. In<br />

this case <strong>the</strong>y where stripped while building <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain. There is a switch in <strong>the</strong> OSELAS.Toolchain menu <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

keep <strong>the</strong> debug symbols also for <strong>the</strong> C runtime library. But be warned: This will enlarge <strong>the</strong> OSELAS.Toolchain<br />

installati<strong>on</strong> <strong>on</strong> your harddisk! When <strong>the</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g>olchain was built with <strong>the</strong> debug symbols kept, it will be also possible<br />

for GDB <str<strong>on</strong>g>to</str<strong>on</strong>g> debug C library functi<strong>on</strong>s our applicati<strong>on</strong> calls (so it might worth <strong>the</strong> disk space).<br />

6.4 Migrati<strong>on</strong> between Minor Releases<br />

6.4.1 Simple Upgrade<br />

To migrate an existing project from within <strong>on</strong>e minor release of <strong>the</strong> sec<strong>on</strong>d main release <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> next <strong>on</strong>e (e.g.<br />

2.0.0 <str<strong>on</strong>g>to</str<strong>on</strong>g> 2.0.x), we do <strong>the</strong> following steps:<br />

~/my_bsp# ptxdist --force migrate<br />

60


6 Various Aspects of Daily Work<br />

6.5 Migrati<strong>on</strong> between Major Releases<br />

6.5.1 Basic C<strong>on</strong>versi<strong>on</strong><br />

To migrate an existing <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>-1 project <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> new <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>-2 <strong>the</strong> following steps are <str<strong>on</strong>g>to</str<strong>on</strong>g> be d<strong>on</strong>e:<br />

To c<strong>on</strong>vert a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>-1 project in<str<strong>on</strong>g>to</str<strong>on</strong>g> a <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>-2 project simply copy your old ptxc<strong>on</strong>fig file in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> files<br />

selected_ptxc<strong>on</strong>fig and selected_platform.<br />

After that, run<br />

~/my_bsp# ptxdist --force platformc<strong>on</strong>fig<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>figure <strong>the</strong> platform specific part and check if everything is set up correctly and save <strong>the</strong>se settings. All in <strong>the</strong><br />

platform unused symbols will now be discarded and <strong>the</strong> remaining required symbols and <strong>the</strong>ir values are saved<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> selected_platform file.<br />

Repeat <strong>the</strong> same step with<br />

~/my_bsp# ptxdist --force menuc<strong>on</strong>fig<br />

In this case all for userland c<strong>on</strong>figurati<strong>on</strong> unused symbols are discarded from <strong>the</strong> original ptxc<strong>on</strong>fig file settings<br />

and <strong>the</strong> remaining are saved <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> selected_ptxc<strong>on</strong>fig file. Check carefully if everything is set up correctly 1<br />

Now you have successfully separated platform and userland c<strong>on</strong>figurati<strong>on</strong>. This is <strong>the</strong> main c<strong>on</strong>figurati<strong>on</strong> ptxdist-<br />

2 uses in a single platform project.<br />

6.5.2 Adapti<strong>on</strong> of Rules Files<br />

A few adapti<strong>on</strong>s in <strong>the</strong> project local rules files are required, <str<strong>on</strong>g>to</str<strong>on</strong>g> also migrate <strong>the</strong>m <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> new <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> infrastructure.<br />

Variables<br />

The names of a few variables have changed.<br />

• PTXCONF_HOST_PREFIX must be replaced by PTXCONF_SYSROOT_HOST<br />

• PTXCONF_ARCH must be replaced by PTXCONF_ARCH_STRING<br />

• IMAGEDIR must be replaced by PKGDIR<br />

Local Source Handling<br />

To retain <strong>the</strong> old behaviour of ptxdist-1 in handling local sources simply keep <strong>the</strong> _SOURCE variable<br />

empty in <strong>the</strong> corresp<strong>on</strong>ding local source rule file.<br />

1 At least if you are using Busybox as your shell envir<strong>on</strong>ment you must check carefully if all settings in <strong>the</strong> previous Busybox versi<strong>on</strong> are<br />

still present. Each versi<strong>on</strong> of Busybox changes various used symbolnames, so it could happen that some settings are lost during <strong>the</strong><br />

transiti<strong>on</strong>.<br />

61


6 Various Aspects of Daily Work<br />

6.5.3 <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>-1 Look and Feel<br />

To keep <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>-1 feeling use <strong>the</strong> following rules:<br />

• Omit <strong>the</strong> platform name (e.g. keep this menu entry empty) when running pxtdist platformc<strong>on</strong>fig<br />

• Open <strong>the</strong> selected_platformc<strong>on</strong>fig file with an edi<str<strong>on</strong>g>to</str<strong>on</strong>g>r and search for SYSROOT_TARGET, SYSROOT_HOST<br />

and SYSROOT_CROSS. Replace <strong>the</strong>ir default settings with:<br />

– For SYSROOT_TARGET: $PTXDIST_WORKSPACE/local/$PTXCONF_ARCH_STRING<br />

– For SYSROOT_HOST: $PTXDIST_WORKSPACE/local-host<br />

– For SYSROOT_CROSS: $PTXDIST_WORKSPACE/local-cross<br />

With <strong>the</strong>se settings you get <strong>the</strong> same direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry structure in a ptxdist-2 project as in ptxdist-1.<br />

6.6 Software Installati<strong>on</strong> and Upgrade<br />

Root filesystems for Linux are usually built as a flash image and pushed in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> respective root medium. <str<strong>on</strong>g>How</str<strong>on</strong>g>ever,<br />

when working with Embedded Linux systems, developers often have <strong>the</strong> need <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

• install new packages<br />

• remove packages<br />

• update packages<br />

• add c<strong>on</strong>figurati<strong>on</strong><br />

Installati<strong>on</strong> of new packages may for example happen if a developer works <strong>on</strong> a new piece of applicati<strong>on</strong> code, or<br />

if a new library is being written for <strong>the</strong> embedded system. Package updating may be a requirement even during<br />

<strong>the</strong> system’s life cycle, for example for updating a cus<str<strong>on</strong>g>to</str<strong>on</strong>g>mer applicati<strong>on</strong> in <strong>the</strong> field.<br />

C<strong>on</strong>venti<strong>on</strong>al Linux distributi<strong>on</strong>s like Debian, SuSE or Fedora use package systems like RPM or DEB <str<strong>on</strong>g>to</str<strong>on</strong>g> organize<br />

<strong>the</strong>ir software packages. Unfortunately, <strong>the</strong>se methods require huge packet databases in <strong>the</strong> root system, which<br />

is bad for space c<strong>on</strong>strained embedded systems. So what we need is a packet system that<br />

• offers installati<strong>on</strong>/removement of packages<br />

• has no big database but a very low overhead<br />

• allows packet management features like pre/post scripts (i.e. shutdown a web server, <strong>the</strong>n upgrade it and<br />

start it again)<br />

ipkg is such a packet system and it is being used in ptxdist. Originally developed for <strong>the</strong> IBM Itsy, ipkg is meanwhile<br />

being used <strong>on</strong> all kinds of embedded Linux projects. The c<strong>on</strong>cept of ipkg archives is based <strong>on</strong> <strong>the</strong> well<br />

known Debian packet management format: ipkg archives are “ar” archives, c<strong>on</strong>taining a tarball with <strong>the</strong> binary<br />

files for <strong>the</strong> target box, plus management scripts which can be run <strong>on</strong> pre-install, post-install, pre-rm and postrm.<br />

So even if no ipkg management utilities are available, developers can modify <strong>the</strong> archives with standard shell<br />

and c<strong>on</strong>sole <str<strong>on</strong>g>to</str<strong>on</strong>g>ols.<br />

6.6.1 ipkg Usage in <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g><br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> end users and packet developers d<strong>on</strong>’t have <str<strong>on</strong>g>to</str<strong>on</strong>g> care directly about ipkg. Packages are being created<br />

during <strong>the</strong> targetinstall stage, <strong>the</strong>n put in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> platform-versatilepb/packages/direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. After <strong>the</strong> targetinstall<br />

62


6 Various Aspects of Daily Work<br />

stage of a packet was d<strong>on</strong>e, this direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry c<strong>on</strong>tains <strong>the</strong> ipkg packet itself plus, for most packages, a direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry with<br />

<strong>the</strong> file c<strong>on</strong>tent.<br />

The ipkg packets c<strong>on</strong>tain <strong>the</strong> binaries for <strong>the</strong> root filesystem as well as start/s<str<strong>on</strong>g>to</str<strong>on</strong>g>p scripts and meta data about<br />

<strong>the</strong> Unix filesystem permissi<strong>on</strong>s; when <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> creates <strong>the</strong> root filesystem which is later flashed in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> <strong>on</strong>board<br />

flash of an embedded system, it takes <strong>the</strong> informati<strong>on</strong> from <strong>the</strong> ipkg packets as <strong>the</strong> source, in order <str<strong>on</strong>g>to</str<strong>on</strong>g> make sure<br />

that <strong>the</strong> image is c<strong>on</strong>sistent <str<strong>on</strong>g>to</str<strong>on</strong>g> what <strong>the</strong> packages c<strong>on</strong>tain.<br />

Internally, <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> always uses ipkg packets <str<strong>on</strong>g>to</str<strong>on</strong>g> s<str<strong>on</strong>g>to</str<strong>on</strong>g>re it’s target data. <str<strong>on</strong>g>How</str<strong>on</strong>g>ever, <strong>the</strong> ipkg functi<strong>on</strong>ality is not always<br />

exposed <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> target itself. So in order <str<strong>on</strong>g>to</str<strong>on</strong>g> use packets, navigate <str<strong>on</strong>g>to</str<strong>on</strong>g> Disk and File Utilities and enable ipkg. In <strong>the</strong><br />

ipkg sub menu, make sure that <strong>the</strong> install /etc/ipkg.c<strong>on</strong>f switch is active. This c<strong>on</strong>fig file is necessary <str<strong>on</strong>g>to</str<strong>on</strong>g> make ipkg<br />

work at runtime system.<br />

The ipkg <str<strong>on</strong>g>to</str<strong>on</strong>g>ol can <strong>on</strong>ly be used in images created by ptxdist images. It’s not fully working within<br />

<strong>the</strong> platform-versatilepb/root/ subdirec<str<strong>on</strong>g>to</str<strong>on</strong>g>ry used as NFS root filesystem.<br />

6.6.2 Packet Installati<strong>on</strong><br />

A comm<strong>on</strong> use case for ipkg packets is <str<strong>on</strong>g>to</str<strong>on</strong>g> push new software <str<strong>on</strong>g>to</str<strong>on</strong>g> an already deployed target. There must be<br />

a communicati<strong>on</strong> channel <str<strong>on</strong>g>to</str<strong>on</strong>g> transfer <strong>the</strong> packet itself <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> embedded system, i.e. by using FTP or a secure<br />

c<strong>on</strong>necti<strong>on</strong> via SFTP or SSH, so it has <str<strong>on</strong>g>to</str<strong>on</strong>g> be made sure that such a service is installed and c<strong>on</strong>figured <strong>on</strong> <strong>the</strong> target.<br />

It is necessary that enough free space is available, in order <str<strong>on</strong>g>to</str<strong>on</strong>g> s<str<strong>on</strong>g>to</str<strong>on</strong>g>re <strong>the</strong> packet itself. A good rule of thumb is <str<strong>on</strong>g>to</str<strong>on</strong>g><br />

have twice <strong>the</strong> size of <strong>the</strong> installed package: while <strong>the</strong> packet is being installed, <strong>the</strong> archive as well as it’s c<strong>on</strong>tents<br />

must fit in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> system s<str<strong>on</strong>g>to</str<strong>on</strong>g>rage. This may be a problem <strong>on</strong> space c<strong>on</strong>strained systems.<br />

If <strong>the</strong> packet was transferred, it is necessary <str<strong>on</strong>g>to</str<strong>on</strong>g> have remote shell access <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> box, ei<strong>the</strong>r via telnet or, if security<br />

is an issue, by using SSH. It is also possible <str<strong>on</strong>g>to</str<strong>on</strong>g> au<str<strong>on</strong>g>to</str<strong>on</strong>g>mate this process by using an intelligent update mechanism.<br />

The shell is being used <str<strong>on</strong>g>to</str<strong>on</strong>g> start <strong>the</strong> necessary commands. If <strong>the</strong> packet was installed, <strong>the</strong> ipkg archive can be<br />

removed again.<br />

6.6.3 Au<str<strong>on</strong>g>to</str<strong>on</strong>g>matic Packet Download<br />

It is also possible <str<strong>on</strong>g>to</str<strong>on</strong>g> let <strong>the</strong> embedded system download ipkg packets au<str<strong>on</strong>g>to</str<strong>on</strong>g>matically from a network source, without<br />

pushing <strong>the</strong> packets from <strong>the</strong> outside. In order <str<strong>on</strong>g>to</str<strong>on</strong>g> do so, a valid URL must be written in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> /etc/ipkg.c<strong>on</strong>f<br />

file. In this case <strong>on</strong>e of <strong>the</strong> wget implementati<strong>on</strong>s in <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> must be selected, ei<strong>the</strong>r <strong>the</strong> <strong>on</strong>e in busybox (Shell &<br />

C<strong>on</strong>sole Tools, BusyBox, Networking Utilities) or <strong>the</strong> native implementati<strong>on</strong> (Networking Tools).<br />

6.6.4 The ipkg Command<br />

The following secti<strong>on</strong>s describe <strong>the</strong> ipkg features.<br />

What’s Installed <strong>on</strong> <strong>the</strong> System?<br />

To get a list of installed packages, use list_installed:<br />

63


6 Various Aspects of Daily Work<br />

# ipkg list_installed<br />

busybox - 1.1.3 -<br />

figlet - 222 -<br />

gcclibs - 4.1.1 -<br />

gdbserver - 6.4 -<br />

glib - 2.8.6 -<br />

glibc - 2.5 -<br />

ipkg - 0.99.163 -<br />

ixp-firmware - 1 -<br />

kernel-modules - 2.6.18 -<br />

libxml2 - 2.6.27 -<br />

mc - 4.6.1 -<br />

memedit - 0.7 -<br />

ncurses - 5.5 -<br />

pciutils - 2.2.1 -<br />

pureftpd - 1.0.21 -<br />

readline - 5.0 -<br />

rootfs - 1.0.0 -<br />

strace - 4.5.14-20061101 -<br />

udev - 088 -<br />

zlib - 1.2.3 -<br />

Successfully terminated.<br />

C<strong>on</strong>tent of a Package<br />

To see what files are in an installed package, use files:<br />

# ipkg files udev<br />

Package udev (106) is installed <strong>on</strong> root and has <strong>the</strong> following files:<br />

/etc/init.d/udev<br />

/sbin/udevtrigger<br />

/etc/udev/udev.c<strong>on</strong>f<br />

/etc/rc.d/S00_udev<br />

/sbin/udevd<br />

/sbin/udevsettle<br />

Successfully terminated.<br />

Adding a Package<br />

Adding a new packet or replacing an already installed <strong>on</strong>e is d<strong>on</strong>e by<br />

# ipkg install .ipk<br />

Note <strong>the</strong> trailing .ipk. This extensi<strong>on</strong> must be given if <strong>the</strong> package file is already part of <strong>the</strong> filesystem. O<strong>the</strong>rwise<br />

ipkg tries <str<strong>on</strong>g>to</str<strong>on</strong>g> download it from <strong>the</strong> URL c<strong>on</strong>figured in /etc/ipkg.c<strong>on</strong>f.<br />

Removing a Package<br />

To remove <strong>the</strong> c<strong>on</strong>tents of a package from <strong>the</strong> running system, ensure that nothing from <strong>the</strong> package is currently<br />

in use. Find out <strong>the</strong> precise packet name with<br />

64


6 Various Aspects of Daily Work<br />

# ipkg list<br />

and remove it’s c<strong>on</strong>tents from <strong>the</strong> runtime system with<br />

# ipkg remove <br />

Upgrading a Package<br />

To upgrade a package, first remove it’s current c<strong>on</strong>tents from <strong>the</strong> runtime system. In a sec<strong>on</strong>d step, install <strong>the</strong><br />

c<strong>on</strong>tents of <strong>the</strong> new ipkg package.<br />

# ipkg list<br />

# ipkg remove <br />

# ipkg [.ipk]<br />

6.7 Downloading Packages from <strong>the</strong> Web<br />

Sometimes it makes sense <str<strong>on</strong>g>to</str<strong>on</strong>g> get all required source archives at <strong>on</strong>ce. For example prior <str<strong>on</strong>g>to</str<strong>on</strong>g> a shipment we want<br />

<str<strong>on</strong>g>to</str<strong>on</strong>g> also include all source archives, <str<strong>on</strong>g>to</str<strong>on</strong>g> free <strong>the</strong> user from downloading it by him/herself.<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> supports this requirement by <strong>the</strong> export_src parameter. It collects all required source archives in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>on</strong>e<br />

given single direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. To do so, <strong>the</strong> current project must be set up correctly, e.g. <strong>the</strong> select and platform commands<br />

must be ran prior <strong>the</strong> export_src step.<br />

If everything is set up correctly we can run <strong>the</strong> following commands <str<strong>on</strong>g>to</str<strong>on</strong>g> get <strong>the</strong> full list of required archives <str<strong>on</strong>g>to</str<strong>on</strong>g> build<br />

<strong>the</strong> project again without a internet c<strong>on</strong>necti<strong>on</strong>.<br />

$ mkdir my_archives<br />

$ ptxdist export_src my_archives<br />

<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> will now collect all source archives <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> my_archives/ direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry.<br />

Note: If <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> is c<strong>on</strong>figured <str<strong>on</strong>g>to</str<strong>on</strong>g> share <strong>on</strong>e source archive direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry for all projects, this step will simply copy <strong>the</strong><br />

source archives from <strong>the</strong> shared source archive direc<str<strong>on</strong>g>to</str<strong>on</strong>g>ry. O<strong>the</strong>rwise <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> will start <str<strong>on</strong>g>to</str<strong>on</strong>g> download <strong>the</strong>m from<br />

<strong>the</strong> world wide web.<br />

65


7 Document Revisi<strong>on</strong>s<br />

2010/01/08 Initial Revisi<strong>on</strong><br />

2010/01/11 Secti<strong>on</strong> ”Adding simple Files <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> Build Process” added<br />

2010/01/11 Secti<strong>on</strong> ”Variables reference” added<br />

2010/01/20 Secti<strong>on</strong> ”Debugging with CPU emulati<strong>on</strong>” added<br />

2010/01/21 Secti<strong>on</strong> ”<str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> parameter reference” added<br />

2010/04/15 Secti<strong>on</strong> ”Adding new Packages” extended<br />

2010/04/16 Secti<strong>on</strong> ”Using Existing Toolchains” extended<br />

2010/05/20 Secti<strong>on</strong> ”Adding binary <strong>on</strong>ly Files” added<br />

2010/05/20 Secti<strong>on</strong> ”Adding Files in<str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> Build” foldet in<str<strong>on</strong>g>to</str<strong>on</strong>g> ”Adding binary <strong>on</strong>ly Files”<br />

2010/05/20 Secti<strong>on</strong> ”Adapting Userland Settings” extended<br />

2011/01/27 Secti<strong>on</strong> ”Rule File Macro Reference”, ’install_tree’ documentati<strong>on</strong> added<br />

2011/01/27 Secti<strong>on</strong> ”Rule File Macro Reference”, ’install_alternative’ search order fixed<br />

2011/01/27 Secti<strong>on</strong> ”Variables Reference”, some more useful variables added<br />

2011/01/27 Secti<strong>on</strong> ”Adding new Packages”, documentati<strong>on</strong> adapted <str<strong>on</strong>g>to</str<strong>on</strong>g> current ptxdist behaviour<br />

×<br />

66


8 Getting help<br />

Below is a list of locati<strong>on</strong>s where you can get help in case of trouble. For questi<strong>on</strong>s how <str<strong>on</strong>g>to</str<strong>on</strong>g> do something special<br />

with <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> or general questi<strong>on</strong>s about Linux in <strong>the</strong> embedded world, try <strong>the</strong>se.<br />

8.1 Mailing Lists<br />

8.1.1 About <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> in Particular<br />

This is an English language public mailing list for questi<strong>on</strong>s about <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>. See<br />

http://www.pengutr<strong>on</strong>ix.de/mailinglists/index_en.html<br />

how <str<strong>on</strong>g>to</str<strong>on</strong>g> subscribe <str<strong>on</strong>g>to</str<strong>on</strong>g> this list. If you want <str<strong>on</strong>g>to</str<strong>on</strong>g> search through <strong>the</strong> mailing list archive, visit<br />

http://www.mail-archive.com/<br />

and search for <strong>the</strong> list ptxdist. Please note again that this mailing list is just related <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> as a software.<br />

For questi<strong>on</strong>s regarding your specific BSP, see <strong>the</strong> following items.<br />

8.1.2 About Embedded Linux in General<br />

This is a German language public mailing list for general questi<strong>on</strong>s about Linux in embedded envir<strong>on</strong>ments. See<br />

http://www.pengutr<strong>on</strong>ix.de/mailinglists/index_de.html<br />

how <str<strong>on</strong>g>to</str<strong>on</strong>g> subscribe <str<strong>on</strong>g>to</str<strong>on</strong>g> this list. Note: You can also send mails in English.<br />

8.2 News Groups<br />

8.2.1 About Linux in Embedded Envir<strong>on</strong>ments<br />

This is an English newsgroup for general questi<strong>on</strong>s about Linux in embedded envir<strong>on</strong>ments.<br />

comp.os.linux.embedded<br />

8.2.2 About General Unix/Linux Questi<strong>on</strong>s<br />

This is a German newsgroup for general questi<strong>on</strong>s about Unix/Linux programming.<br />

de.comp.os.unix.programming<br />

67


8 Getting help<br />

8.3 Chat/IRC<br />

About <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g> in particular<br />

irc.freenode.net:6667<br />

Create a c<strong>on</strong>necti<strong>on</strong> <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>the</strong> irc.freenode.net:6667 server and enter <strong>the</strong> chatroom #ptxdist. This is an English<br />

room <str<strong>on</strong>g>to</str<strong>on</strong>g> answer questi<strong>on</strong>s about <str<strong>on</strong>g>PTXdist</str<strong>on</strong>g>. Best time <str<strong>on</strong>g>to</str<strong>on</strong>g> meet somebody <strong>the</strong>re is at European daytime.<br />

8.4 Commercial Support<br />

You can order immediate support through cus<str<strong>on</strong>g>to</str<strong>on</strong>g>mer specific mailing lists, by teleph<strong>on</strong>e or also <strong>on</strong> site. Ask our<br />

sales representative for a price quotati<strong>on</strong> for your special requirements.<br />

C<strong>on</strong>tact us at:<br />

Pengutr<strong>on</strong>ix<br />

Peiner Str. 6-8<br />

31137 Hildesheim<br />

Germany<br />

Ph<strong>on</strong>e: +49 - 51 21 / 20 69 17 - 0<br />

Fax: +49 - 51 21 / 20 69 17 - 55 55<br />

or by electr<strong>on</strong>ic mail:<br />

sales@pengutr<strong>on</strong>ix.de<br />

68

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!