source: rtems/bsps/i386/pc386/HOWTO @ eb36d11

5
Last change on this file since eb36d11 was eb36d11, checked in by Sebastian Huber <sebastian.huber@…>, on 04/25/18 at 13:06:08

bsps: Move documentation, etc. files to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 14.6 KB
Line 
1+-----------------------------------------------------------------------------+
2| RTEMS 4.6.0 PC386 BSP HOWTO - 2003/05/08                                    |
3|                                                                             |
4+-----------------------------------------------------------------------------+
5| (C) Copyright 1998 -                                                        |
6| - NavIST Group - Real-Time Distributed Systems and Industrial Automation    |
7|                                                                             |
8| http://pandora.ist.utl.pt                                                   |
9|                                                                             |
10| Instituto Superior Tecnico * Lisboa * PORTUGAL                              |
11+-----------------------------------------------------------------------------+
12| Disclaimer:                                                                 |
13|                                                                             |
14| This file is provided "AS IS" without warranty of any kind, either          |
15| expressed or implied.                                                       |
16+-----------------------------------------------------------------------------+
17| History:                                                                    |
18|  12 June 2000 - Updated to 4.5 (Joel)                                       |
19|   8 May  2003 - PXE GRUB (Chris Johns)                                      |
20+-----------------------------------------------------------------------------+
21
22
231. Introduction
24---------------
25
26    This tries to explain how to setup the RTEMS host environment so
27that RTEMS applications can be built for and run in a bare PC 386 or
28above.
29
30    It covers essentially the aspects of loading images, since
31information concerning other issues such as building the development
32tools and the RTEMS distribution can be found in the 'RTEMS 4.6.0
33On-Line Library' under 'Getting Started with RTEMS for C/C++ Users'.
34
35    Please note that everything in the following text using the
36notation '<...>' is just an alias to something and should always be
37substituted by the real thing!
38
39
402. Building the GNU C/C++ Cross Compiler Toolset
41------------------------------------------------
42
43    Obtaining, building and installing the tools for building the
44PC386 BSP of RTEMS is covered in detail in the 'RTEMS 4.6.0 On-Line
45Library' -> 'Getting Started with RTEMS for C/C++ Users'.  You can
46either use pre-built toolset executables or build your own from
47the instructions given there.
48
49    This BSP is designed to work only with ELF toolset configurations.
50This is format used by the i386-rtems target.
51
52
534. Building RTEMS
54-----------------
55    Obtaining, building and installing the tools for building the
56PC386 BSP is covered in detail in the 'RTEMS 4.6.0 On-Line Library' ->
57'Getting Started with RTEMS for C/C++ Users' -> 'Building RTEMS'.
58
59    When running configure, use the following values for the listed
60options with an i386-rtems toolset:
61
62          --target=i386-rtems
63          --enable-rtemsbsp=pc386
64
65 
665. RTEMS Tests
67--------------
68
69    If you've completed the last step successfully, you'll find the
70RTEMS sample and test files that can be loaded with GRUB in the
71'<build_point>/pc386/tests' directory, RTEMS sample and test files in
72a format suitable for use with NetBoot in the
73'<build_point>/pc386/BootImgs' directory.
74
75
766. Loading RTEMS PC386 applications
77-----------------------------------
78
796.1. Unarchiving
80----------------
81
82    Files which have been "tarred, gzipped" (i.e. .tar.gz or .tgz
83extension) may be unarchived with a command similar to one of the
84following:
85
86      zcat <file>.tgz | tar xvof -
87
88    OR
89
90      gunzip -c <file>.tgz | tar xvof -
91
92    OR
93
94      tar xzvf <file>.tgz
95
96    NOTE: gunzip -c is equivalent to zcat. On commercial (non-Linux)
97Unices, since the GNU utilities are not the standard 'tar' will be
98gtar (GNU tar) and 'zcat' will be 'gzcat'.
99
100    Given that the necessary utility programs are installed, any of
101the above commands will extract the contents of <file>.tar.gz into the
102current directory. To view the contents of an archive without
103restoring any files, use a command similar to the following:
104
105      zcat <file>.tgz | tar tvf -
106
107
1086.2 Using GRUB to load RTEMS PC386 applications from Floppy
109-----------------------------------------------------------
110
111    Using GRUB (GRand Unified Bootloader) is the simplest way to load
112and run your PC386 BSP samples, tests and programs. You will need to build GRUB
113so you need a working GCC and friends. The online documentation for GRUB lists
114what you need:
115
116    - http://www.gnu.org/manual/grub/html_node/index.html
117
118    You can get the latest release of GRUB from its homepage:
119
120    - http://www.gnu.org/software/grub/
121
122    Once you obtain the .tar.gz archive from:
123
124    - ftp://alpha.gnu.org/gnu/grub/
125
126Download the lastest version (grub-0.93.tar.gz), change to a temporary
127directory (you won't need the grub files after this and can just go ahead and
128delete the whole directory structure that was generated) and unarchive
129'grub-0.93.tar.gz' following the instructions given above in [2. Unarchiving].
130
131      $ cd /tmp
132      $ mkdir grub
133      $ cd grub
134      $ cat grub-0.93.tar.gz | gzip -d | tar xf -
135
136after this is done create a build directory and decend into it:
137
138      $ mkdir build
139      $ cd build
140
141then configure GRUB with the standard options:
142
143      $ ../grub-0.93/configure
144
145and if successful run make:
146
147      $ make
148
149    Once complete you should have the 'stage1' and 'stage2' files. They will be
150in the directories with the same name.
151
152    You should have two (2) formatted diskettes available. One of
153these will only be used temporarily to create the other one, and we'll
154refer to it as 'RAW GRUB' diskette (you can label it accordingly if
155you wish). The other diskette, which we will refer to as 'GRUB FS'
156should be high-level formatted with one of GRUB's supported file
157systems, which are: DOS FAT, BSD FFS, and Linux ext2fs.
158
159    A DOS FAT diskette can, obviously, be created under DOS with the
160'FORMAT' command. Under Linux, the following commands are available to
161add file systems to low-level formatted diskettes:
162
163    1. To add a DOS FAT file system to a low-level formatted diskette:
164
165      a) If you have mtools installed:
166
167           'mformat a:'.
168
169      b) Assuming that you are formatting the diskette in the first
170         floppy disk drive ('/dev/fd0' under Linux):
171
172           'mkdosfs /dev/fd0' or
173
174           'mkfs.msdos /dev/fd0'.
175
176    2. To add a Linux ext2fs file system to a low-level formatted
177       diskette, assuming that you are formatting the diskette in the
178       first floppy disk drive ('/dev/fd0' under Linux):
179
180         'mke2fs /dev/fd0' or
181
182         'mkfs.ext2 /dev/fd0'.
183
184   Next we will install using 'rawrite' or 'dd' to the 'GRUB RAW'
185diskette.
186
187   NOTE: This will destroy any data currently on the diskette.
188
189   Execute your OS's equivalent of (this should work for recent
190FreeBSD versions and Linux just fine):
191
192     dd if=stage1/stage1 of=/dev/fd0 bs=512 count=1
193     dd if=stage2/stage2 of=/dev/fd0 bs=512 seek=1
194
195   Under DOS/Windows/NT, courtesy of Eric Hanchrow (erich@microsoft.com):
196
197     * Use the copy /b command to binary concatenate the stage1 and
198       stage2 files together via:
199
200         copy /b stage1\stage1 stage2\stage2 grub.raw
201
202     * Use rawrite.exe (which is available in many places on the net and
203       in some Linux distributions) to write grub.raw to a diskette.
204
205(CCJ: I am not sure about the Windows location etc)
206
207   Next stage: copy the 'stage1' and 'stage2' files to the 'GRUB FS'
208diskette (if you are using Linux you can mount the diskette in an
209appropriate mount point and then 'cp' the files to it, if it is either
210a DOS FAT or an EXT2FS diskette, or in the case of a DOS FAT diskette
211you can use 'mcopy' from 'mtools'.)
212
213   After this is done boot a PC using the 'GRUB RAW' diskette. After
214this is done, you will get GRUB's command line interface. Exchange
215'GRUB RAW' with the 'GRUB FS' diskette in the drive and issue the
216following command from GRUB's prompt:
217
218     install=(fd0)/stage1 (fd0) (fd0)/stage2 0x8000 (fd0)/grubmenu
219
220   This command will make the 'GRUB FS' diskette bootable. After this
221is done, you won't require the 'GRUB RAW' diskette anymore and you can
222delete the 'stage1' file from the 'GRUB FS' diskette.
223
224   Next copy all the files you wish to load to the diskette. The GRUB
225loadable test and sample files in the RTEMS distribution have '.exe'
226extension and can be found under the build point in the 'pc386/tests'
227directory. You can compress this files with gzip to save space if you
228wish. GRUB loads 'gzipped' files transparently.
229
230   Finally you have to create a GRUB menu configuration file. We will
231call this file 'grubmenu'. You can call it anything as long as you use
232the correct name in the 'install' command where we used 'grubmenu'.
233
234   The 'grubmenu' file, as far as we are interested has the following
235syntax:
236
237     title=  Hello World Test
238     kernel= (fd0)/hello.exe.gz
239
240   You can add as many of this entries as you want to the 'grubmenu'
241file. There should be one for each program you wish to load. The
242'title=' line provides a description for the program that will appear
243after boot in the GRUB menu for the user to choose and the 'kernel='
244line describes where the file can be found by GRUB (you should leave
245the '(fd0)/' part and just substitute the rest if you've copied the
246files to the root directory of the diskette.
247
248   Just boot the PC with the 'GRUB FS' diskette and you will be able
249to choose which program you want to load from GRUB's menu.
250
251   The GRUB documentation is available in HTML format in the 'docs'
252directory of the GRUB tree starting with the 'index.html' file.
253
254
2556.3 Using GRUB to load RTEMS PC386 applications via PXE NetBoot
256----------------------------------------------------------------
257
258PXE is the Intel Preboot Execution Environment. A number of PC
259manufactures provide a PXE option in the BIOS. This is usually a
260Net Boot option in a BIOS configuration screen. The simplist way to
261load an RTEMS application via PXE is to use GRUB as a first stage
262loader.
263
264You will need to determine your network card, and have a working
265network with a DHCP (or BOOTP), and TFTP server.
266
267You may to find a TFTP server that does not support option
268negotiations. A google search shows a number of PC's have a buggy
269PXE loader. Supressing option negotiations seems to make them
270work.
271
272You will need to build GRUB for your network card. Follow the
273procedure in item 6.2 up to the configure point. At this point
274run the following configure command:
275
276    $ ../grub-0.93/configure --enable-diskless --enable-eepro100
277
278for an Etherexpress Pro 100 network card, then run make:
279
280    $ make
281
282    Once complete you should have the 'stage2/pxegrub' file. Copy
283this to your TFTP server's download directory. Configure your
284DHCP server to provide an IP address and download the image. For
285the ISC server found on operating systems such as Linux something
286like the following should do:
287
288  #
289  # PC loading RTEMS via PXE and GRUB
290  #
291
292  group
293  {
294    filename "/tftpboot/pxeboot";
295    host rtems-pc { hardware ethernet 00:08:c7:73:41:65; }
296  }
297
298If all works your PC should boot and load GRUB over the network:
299
300    GRUB  version 0.93  (639K lower / 64512K upper memory)
301
302  Address: 10.10.10.10
303  NetMask: 255.255.255.0
304  Server: 10.10.10.1
305  Gateway: 10.10.10.1
306
307   [ Minimal BASH-like line editing is supported.  For the first word, TAB
308     lists possible command completions.  Anywhere else TAB lists the possible
309     completions of a device/filename. ]
310
311  grub>
312
313Copy your RTEMS executable to the TFTP server directory then enter
314the following GRUB commands:
315
316  grub> root (nd)
317    Filesystem type is tftp, using whole disk
318
319  grub> kernel ticker.exe
320     [Multiboot-elf, <0x100000:0x1e5a4:0x2b08>, shtab=0x122140, entry=0x10000c]
321
322  grub> boot
323
324The GRUB documents how to get GRUB to load a configuration file.
325
326
3276.4 Using NetBoot to load RTEMS PC386 applications
328---------------------------------------------------
329
330    To load the '*.bt' files you can
331
332    Alternatively, if you have a PC connected to a network with a
333BOOTP server and a TFTP server (this can very well be you're Linux
334RTEMS host system), you can use Gero Kuhlmann's NetBoot loader, to
335load RTEMS to a diskless PC across a network. You can get it from:
336
337   ftp://sunsite.unc.edu/pub/Linux/system/boot/ethernet/netboot-0.7.3.tar.gz
338
339or in any of Sunsite's mirrors. It is also available from NetBoot's
340homepage:
341
342      http://www.han.de/~gero/netboot
343
344    After unarchiving 'netboot-0.7.3.tar.gz' you should change to the
345base directory of this and run:
346
347      ./configure --disable-mknbi-dos --disable-mknbi-linux --disable-mknbi-mgl
348
349    Afterwards, you should follow the instructions contained in the
350'INSTALL' file also contained in the base directory, on how to setup the
351server(s) and to build a boot ROM for the client PC network card, or a
352boot diskette, and the PC client should be able to load the '*.bt' files
353from the server.
354
355    The important sections to check in the 'INSTALL FILE' are the last two:
356
357    - Setup of the server (only the BOOTP and TFTP parts - ignore NFS).
358      ===================
359
360    - Setup of the client including building the bootrom
361      ==================================================
362
363all the rest can be safely ignored if you don't care to examine it.
364
365 
3667. Technical Information
367------------------------
368
369    NOTE: All the following paths are relative to the base directory
370of the RTEMS distribution.
371
372    As of the writing of this HOWTO, PC386 images can be loaded either
373in low memory 0x10000 (64KB) until 0x97C00 (607K) using NetBoot or in
374high memory from 0x100000 (1024KB) until the top of the available
375memory using either NetBoot or GRUB.
376
377    If you want to change the default loading address from 1024KB to
378something else, just change the value of the variable RELOCADDR in the
379'make/custom/pc386.cfg' file to the new value you want (make sure you
380follow the instructions indicated before the definition of RELOCADDR).
381
382    Remember that GRUB restricts the loading addresses to values above
3830x100000 (1024KB), only NetBoot can load images in low memory.
384
385    After you make any changes to RELOCADDR and if you are using
386NetLoader, you'll have to recompile the
387'c/src/lib/libbsp/i386/pc386/start/start16.s' file. The easiest way to
388achieve this is just to 'make clean' and the 'make all' again. The
389quickest way is to change to
390'<build_point>/c/src/lib/libbsp/i386/pc386/start' and 'make
391RTEMS_BSP=pc386 clean all'.
392
393    When programming interrupt handlers take into account that the PIC
394is reprogrammed and so you should use the interface functions provided
395in '<build_point>/pc386/lib/include/irq.h> to guarantee that everything
396works ok.
Note: See TracBrowser for help on using the repository browser.