Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
.\"	$NetBSD: prep,v 1.31 2022/09/28 06:09:14 charlotte Exp $
.
.Ss2 Configuring your PROM
.
Before you start, you should configure your PROM. There are three
categories of PROM:
.Dq sunmon
(sometimes called Restricted Prompt, sun monitor, or old command mode),
OpenBoot PROM 1, and OpenBoot PROM 2.
The sun4 machines only have sunmon. Some of the early sun4c models
default to sunmon but have OpenBoot PROM 1.
The later sun4c models and all sun4m models have OpenBoot PROM 2.
.Pp
First, you need to stop your system from automatically booting when
powered on. Pressing the
.Key STOP
key (sometimes called the
.Key L1
key, found on the left side of your keyboard) and the
.Key a
key will halt your system and give you a PROM prompt. If you are using a
Tadpole SPARCbook, you press the
.Key Pause
and
.Key a
keys. If you are using a serial console, send a
.Dq BREAK
signal from your terminal (the method of sending
.Dq BREAK
varies from terminal to terminal).
.Pp
If the ethernet address of your \*M system is
.Li ff:ff:ff:ff:ff:ff ,
then your NVRAM battery is dead and you will have trouble using
ethernet (among other problems).  Read the
.Lk https://web.archive.org/web/20150611091616/https://www.squirrel.com/squirrel/sun-nvram-hostid.faq.html "Sun NVRAM/Hostid FAQ" .
.Pp
If you have a valid ethernet address and you plan to netboot, write down
your system's ethernet address.
.Pp
Next, you should set your system to always use the OpenBoot PROM
(sometimes called
.Dq "new command mode" )
if it defaults to sunmon. The
.Nx
kernel relies on some of the functionality provided by the OpenBoot PROM.
If your machine gives you a `\*[Gt]' prompt instead of an `ok' prompt,
type:
.Pp
.(disp
.No \*[Gt] Ic n
.No ok Ic "setenv sunmon-compat? false"
.No ok
.disp)
.Pp
Next, if you are using any security features of OpenBoot PROM, you should
turn them off \(em
.Nx
can't deal well with this.
.Pp
.(disp
.No ok Ic "setenv security-mode none"
.disp)
.Pp
If you are using a serial console, the
.Nx*M
installer defaults to using 9600 bps, 8N1 settings.  You may want to 
configure your system and serial terminal like this prior to booting the 
installer.  Additionally, a new installation of
.Nx*M
will default to these settings as well.
.Pp
The OpenBoot PROM 1 machines (SPARCstation/server 1, SPARCstation/server 1+,
IPC, and SLC) have an odd SCSI quirk you should be aware of.
There are three SCSI addressing schemes used by your
system: SCSI target ID (set by physical jumpers on the device), PROM
.Sq unit
number (set by OpenBoot PROM 1, based on its SCSI target ID), and the name
you reference within an operating system (set by the kernel, based on the PROM
.Sq unit
number).
.Pp
Sun shipped these systems with the internal drives set to SCSI target IDs
3 and 1.  The default value of the OpenBoot PROM variable
.Sq Li sd-targets
is
.Sq Li 31204567.
This variable maps how the OpenBoot PROM 1 assigns
.Sq unit
numbers based on the SCSI target ID.
Thus the device at SCSI target ID 3 is considered
.Sq unit
0, and the SCSI device at target ID 0 is
.Sq unit
3.  When you type
.Dq Ic boot scsi(0,0,0) ,
the OpenBoot PROM will boot from
.Sq unit
0 (which is SCSI target ID 3, the internal hard drive).  The
.Tn SunOS
kernel is hard-wired to map
.Li sd0
to SCSI target 3, and
.Li sd3
to SCSI target 0.
.Bl -column -offset indent PROM\ Unit# SCSI\ Target SunOS\ name
.It Em PROM\ Unit# Ta Em SCSI\ Target Ta Em SunOS\ name
.It \~\~\~0 Ta \~\~\~3 Ta \~\~\~sd0
.It \~\~\~1 Ta \~\~\~1 Ta \~\~\~sd1
.It \~\~\~2 Ta \~\~\~2 Ta \~\~\~sd2
.It \~\~\~3 Ta \~\~\~0 Ta \~\~\~sd3
.It \~\~\~4 Ta \~\~\~4 Ta \~\~\~st0
.It \~\~\~5 Ta \~\~\~5 Ta \~\~\~st1
.It \~\~\~6 Ta \~\~\~6 Ta \~\~\~cdrom
.El
.Pp
The
.Nx*M
.Li GENERIC
kernel does not wire things down as does
.Tn SunOS .
It names the disks in the order
that the SCSI targets are probed (01234567). If you only have one disk,
it is always
.Li sd0
regardless of its SCSI target ID or its PROM
.Sq unit
number, and there are no problems. If you have two disks, one at
SCSI ID 2
.Pf ( Sq unit
2) and SCSI ID 3
.Pf ( Sq unit
0), then they are recognized as
.Li sd0
and
.Li sd1
respectively. This can be a problem if you are not
aware of it, particularly when creating an fstab.
.Pp
There are two approaches to fixing this problem: changing the
mapping that OpenBoot PROM 1 does, and changing the
.Nx
kernel configuration.
To get OpenBoot PROM 1 to number the SCSI
.Sq unit
numbers the same as the SCSI target IDs, you need to run this command:
.Pp
.(disp
.No ok Ic "setenv sd-targets 01234567"
.disp)
.Pp
This may, however, cause problems if you were to later attempt to use
.Tn SunOS
on this machine or if you reset the OpenBoot PROM variables.
.Pp
The other approach is to use a
.Nx
kernel that matches the PROM's odd target mapping by treating
.Sq unit
0 (i.e. SCSI target ID 3) as
.Li sd0
and
.Sq unit
3 (i.e. SCSI target ID 0) as
.Li sd3 .
The
.Li GENERIC_SCSI3
kernel performs this target mapping, but the
.Li GENERIC
and
.Li INSTALL
kernels do not.
.Pp
.(Note
This is also a concern when you start building your own customised kernels.
.Note)
.Pp
The machines with OpenBoot PROM 2 (SPARCstation/server 2,
ELC, IPX, and all sun4m models) have a similar SCSI target mapping in the
form of a
.Ic devalias
entry.  That is, the device alias
.Ic disk
is shorthand for the disk at SCSI ID 3 on the internal SCSI controller.
Normally, the
.Ic disk
device alias is what the PROM uses as the default boot device, i.e. in the
absence of a
.Ar device
argument to the
.Ic boot
command.
Note that there are also pre-configured device alias entries for
.Ic disk0,
.Ic disk1,
.Ic disk2
and
.Ic disk3 ,
which are in fact a one-to-one mapping to the SCSI targets
.Ic 0
to
.Ic 3
.Pq all on the internal SCSI controller .
.Pp
Again, it may be advantageous to use a fixed
.Dq SCSI target
to
.Dq Nx "" disk unit
mapping in your kernel configuration file (such as is done in the
.Li GENERIC_SCSI3
kernel) to ensure that your disks remain showing up at the same
.Nx
device unit numbers even if you add disks to your system at a later time.
.
.Ss2 Determining how to access your SCSI disk from the PROM
.
sunmon and OpenBoot PROM 1 use an archaic
.Li sd( Ns Ar c,u,p Ns Ic \&)
syntax to address SCSI devices. OpenBoot PROM 2 uses a more intuitive
syntax using device aliases.
.Pp
To calculate the parameters for sunmon and OpenBoot PROM 1:
.(tag xcc -offset indent
.It Ar c
specifies the SCSI controller number (first is 0, second is 1, ...)
.It Ar u
the hexadecimal number obtained from evaluating
the expression
.Em (8 * TARGET) + LUN
.It Ar p
the partition number from which to boot
.Pf ( Sq Li 0
=
.Sq Li a ,
.Sq Li 1
=
.Sq Li b ,
etc.)
.tag)
.Pp
Therefore, to boot from the swap partition on the internal hard drive
(first SCSI bus, target 0, lun 0, partition 1), one would use:
.Pp
.(disp
.No ok Ic "boot sd(0,0,1)"
.disp)
.Pp
To boot from a CD-ROM (first SCSI bus, target 6,
lun 0, partition dynamically determined), one would use:
.Pp
.(disp
.No ok Ic "boot sd(0,30,)"
.disp)
.Pp
And, to boot from a kernel named
.Li netbsd-GENERIC
on the fourth partition
.Pf ( Sq Li d ,
often the
.Pa /usr
partition) on an external hard drive (first SCSI bus, target 2, lun 0,
partition 3), one would use:
.Pp
.(disp
.No ok Ic "boot sd(0,10,3)netbsd-GENERIC"
.disp)
.Pp
Now, for OpenBoot PROM 2, SCSI devices are specified by an OpenBOOT
.Ic devalias
which provides simple mnemonics for the full path to the device. Type
.Ic devalias
in OpenBoot PROM 2 to get a list of all of the available aliases.
Just the alias and partition are necessary when booting.
.Pp
Therefore, to boot from the swap partition on the internal hard drive
(OpenBoot PROM 2 assumes the internal hard drive is at target 3), one would
use:
.Pp
.(disp
.No ok Ic "boot disk:b"
.disp)
.Pp
To boot from a CD-ROM (OpenBoot PROM 2 assumes the CD-ROM is at target 6),
one would use:
.Pp
.(disp
.No ok Ic "boot cdrom"
.disp)
.Pp
And, to boot from a kernel named
.Li netbsd-GENERIC
on the fourth partition
.Pf ( Sq Li d ,
often the
.Pa /usr
partition) on an external hard drive (target 2, partition 3), one would use:
.Pp
.(disp
.No ok Ic "boot disk2:d netbsd-GENERIC"
.disp)
.Pp
The full device path specifier for OpenBoot PROM 2 depends on how OpenBoot
PROM 2 recognizes
your SCSI controller. Typically, one would use something like:
.Pa /sbus/esp/sd@ Ns Ar t,p
where t is the SCSI target and p is the partition number.
.
.Ss2 Determining how to boot from an SBUS card
.
Some SBUS cards have firmware that lets you use them as a boot device.
These cards do not automatically create a
.Ic devalias
entry, so you must traverse the device tree to figure out what the
OpenBoot PROM calls your card.  You will be using OpenBoot PROM commands
at the `ok' prompt. First `cd' to the top of the device tree and list the
nodes there.  The following is the procedure to boot from an HME card in a
SPARC Classic.
.(disp
.No ok Ic "cd /"
.No ok Ic "ls"
ffd3b790 TI,TMS390S10@0,f8fffffc
ffd2d254 virtual-memory@0,0
ffd2d198 memory@0,0
ffd2b65c obio
ffd2b310 iommu@0,10000000
ffd2b2a0 openprom
ffd24af0 aliases
ffd24abc options
ffd24a88 packages
.disp)
Usually, you can simply type in the name before the at (@) sign and the
OpenBoot PROM will fill in the rest.
.(disp
.No ok Ic "cd iommu"
.No ok Ic "ls"
ffd2b454 sbus@0,10001000
.No ok Ic "cd sbus"
.No ok Ic "ls"
ffd467e8 cgthree@3,0
ffd42a1c SUNW,hme@1,8c00000
ffd4297c le@0,c00000
ffd40d28 ledma@4,8400010
ffd40c9c SUNW,bpp@4,c800000
ffd40c00 audio@4,1300000
ffd3dc68 espdma@4,8400000
.No ok Ic "cd SUNW,hme"
.No ok Ic "ls"
.No ok Ic "pwd"
/iommu@0,10000000/sbus@0,10001000/SUNW,hme@1,8c00000
.disp)
OK, now we know the path to the HME device in this example.  Now, we need
to determine if it's capable of booting.  If it is, it will have the
.Ic word
`open'.
.(disp
.No ok Ic "words"
reset         seek          load          open          close
watch-net     selftest      obp-selftest  write         read
preamble-32   enable-link-pulse           disable-link-pulse
force-speeds  reset-transceiver           use-bit-bang-mode
use-frame-mode              dump-phys     transfer-speed=10
transfer-speed=100          mii-write     mii-read
create-rev-id
.disp)
Great!
Also, in case you're interested in further details about your
hardware, you can use the `.attributes' command.
.(disp
.No ok Ic ".attributes"
hm-rev                   00000022
version                  1.18
model                    SUNW,501-2919
device_type              network
intr                     00000037  00000000
interrupts               00000004
address-bits             00000030
max-frame-size           00004000
reg                      00000001  08c00000  00000108
                         00000001  08c02000  00002000
                         00000001  08c04000  00002000
                         00000001  08c06000  00002000
                         00000001  08c07000  00000020
name                     SUNW,hme
ok
.disp)
So, when it's time to type in a boot command, use the shortened version of the
.Ic pwd
command.  In this example, you'd type:
.(disp
.No ok Ic "boot /iommu/sbus/SUNW,hme"
.disp)
And when the kernel is done booting, it may not automatically use your
card as the root device -- you may need to type in the
.Nx*M
name for
that device:
.(disp
root on sd0a dumps on sd0b
no file system for sd0 (dev 0x700)
cannot mount root, error = 79
.No "root device (default sd0a):" Ic "?"
use one of: fd0[a-h] le0 le1 hme0 sd0[a-h] halt
.No "root device (default sd0a):" Ic "hme0"
.No "dump device:" Ic "hme0"
.No "file system (default generic):" Ic "nfs"
root on hme0
.disp)
.
.Ss2 Deciding on partition sizes
.
If you're installing
.Nx*M
for the first time it's a good idea
to look at the partition sizes of disk you intend installing
.Nx*M
on.
.Pp
A minimal installation of
.Nx
requires about 140 MB.
A full installation requires considerably more.
A good initial size for the swap partition is twice the amount
of physical memory in your machine (unlike
.Tn SunOS 4.x ,
there are no restrictions on the size of the swap partition that would render
part of your memory unusable).
.Pp
Note that there are limitations on the size of the root partition for
various models.
.Pp
On sun4 machines, the
.Nx
sparc boot loader can only boot from RAID partitions that start at the
beginning of the disk.
.Pp
On sun4 and early PROM version sun4c machines, the PROM can only boot from
the first 1Gb of the disk.
.Pp
On later PROM version sun4c and early PROM version sun4m machines, the PROM
can only boot from the first 2Gb of the disk.
.Pp
On later PROM version sun4m machines, the PROM can only boot from the first
4Gb of the disk.
.
.Ss2 Configuration of network interfaces
.
Some network devices (i.e. the built-in
.Em le
interface on sun4m machines)
allow a choice between operating on a UTP or a AUI port once the
.Nx
kernel is running. The
.Em le
driver supports automatic detection of the port which is actually connected to
the wire. Additionally, some of the Fast ethernet devices (such as
.Em be ,
.Em hme ,
.Em qec ,
and
.Em qfe )
support selection of various speeds and options.
The default is to attempt to automatically detect the speed.
.Pp
If automatic detection is not available or not working properly in your
environment, you may have to specify the type connection using the
.Ic media
parameter of
.Xr ifconfig 8 .
During installation, you'll get the opportunity to specify the appropriate
medium. Use
.Li 10base5
or
.Li AUI
to select the AUI connector, or
.Li 10baseT
or
.Li UTP
to select the UTP connector.
Fast ethernet interfaces default to
.Li auto ,
which usually does not detect properly and runs at
.Sq 10BaseT
speed.
The options are
.Li 10baseT ,
.Li 10baseTX ,
and
.Li auto .
The
.Em hme
and
.Em qfe
interfaces also allow
.Li 10baseT-FDX
and
.Li 100baseT-FDX .