# FreeBSD 8.1 and 8.3 kernels



## s_gammons (Aug 21, 2013)

I've been working on trying to get a Nokia IP380 firewall appliance to work with a more recent version of FreeBSD and have had some luck.  After building a custom kernel with USB support removed, I can get 8.1 to boot and I'm able to login, but the Ethernet ports all have FF as the MAC address.  I suspect this is because there's a starting MAC address somewhere in the firmware and each NIC is assigned a MAC on the fly based on that address. 

Having said that, I was wondering what all changed between FreeBSD 8.1 and 8.3 as I can't 8.3 to boot even with USB support removed.  Here's the pciconf output and devinfo from 8.1 followed by the output from 8.3

Any ideas why 8.3 crashes?

Stan


```
pciconf -l
hostb0@pci0:0:0:0:      class=0x060000 card=0x00000000 chip=0x00091166 rev=0x06 hdr=0x00
hostb1@pci0:0:0:1:      class=0x060000 card=0x00000000 chip=0x00091166 rev=0x06 hdr=0x00
cbb0@pci0:0:9:0:        class=0x060700 card=0x00000000 chip=0xac51104c rev=0x00 hdr=0x02
cbb1@pci0:0:9:1:        class=0x060700 card=0x00000000 chip=0xac51104c rev=0x00 hdr=0x02
none0@pci0:0:10:0:      class=0x0b4000 card=0x00000000 chip=0x580214e4 rev=0x01 hdr=0x00
isab0@pci0:0:15:0:      class=0x060100 card=0x02001166 chip=0x02001166 rev=0x51 hdr=0x00
atapci0@pci0:0:15:1:    class=0x01018a card=0x00000000 chip=0x02111166 rev=0x00 hdr=0x00
none1@pci0:0:15:2:      class=0x0c0310 card=0x02201166 chip=0x02201166 rev=0x04 hdr=0x00
pcib2@pci0:1:0:0:       class=0x060400 card=0x00000000 chip=0xb1548086 rev=0x00 hdr=0x01
pcib3@pci0:1:2:0:       class=0x060400 card=0x00000000 chip=0xb1548086 rev=0x00 hdr=0x01
fxp0@pci0:2:3:0:        class=0x020000 card=0x00000000 chip=0x12098086 rev=0x10 hdr=0x00
fxp1@pci0:2:4:0:        class=0x020000 card=0x00000000 chip=0x12098086 rev=0x10 hdr=0x00
fxp2@pci0:2:5:0:        class=0x020000 card=0x00000000 chip=0x12098086 rev=0x10 hdr=0x00
fxp3@pci0:2:6:0:        class=0x020000 card=0x00000000 chip=0x12098086 rev=0x10 hdr=0x00
dc0@pci0:3:5:0: class=0x020000 card=0x61e00040 chip=0x00191011 rev=0x41 hdr=0x00
dc1@pci0:3:6:0: class=0x020000 card=0x61e00040 chip=0x00191011 rev=0x41 hdr=0x00

Interrupt request lines:
    0 (root0)
    1 (atkbd0)
    3 (uart1)
    4 (uart0)
    5-7 (root0)
    8 (atrtc0)
    9 (root0)
    10 (dc1)
    10 (dc0)
    11 (fxp3)
    11 (fxp2)
    11 (fxp1)
    11 (fxp0)
    12-13 (root0)
    14 (ata0)
    15 (ata1)
DMA request lines:
    0-7 (root0)
I/O ports:
    0x0-0x5f (root0)
    0x60 (atkbdc0)
    0x61-0x63 (root0)
    0x64 (atkbdc0)
    0x65-0x6f (root0)
    0x70-0x71 (atrtc0)
    0x72-0x16f (root0)
    0x170-0x177 (atapci0)
    0x178-0x1ef (root0)
    0x1f0-0x1f7 (atapci0)
    0x1f8-0x2f7 (root0)
    0x2f8-0x2ff (uart1)
    0x300-0x375 (root0)
    0x376 (atapci0)
    0x377-0x3f5 (root0)
    0x3f6 (atapci0)
    0x3f7 (root0)
    0x3f8-0x3ff (uart0)
    0x400-0x57f (root0)
    0x580-0x58f (pci0)
    0x590-0xd7ff (root0)
    0xd800-0xd87f (dc1)
    0xd880-0xdbff (root0)
    0xdc00-0xdc7f (dc0)
    0xdc80-0xdfff (root0)
    0xe000-0xe03f (pci2)
    0xe040-0xe3ff (root0)
    0xe400-0xe43f (pci2)
    0xe440-0xe7ff (root0)
    0xe800-0xe83f (pci2)
    0xe840-0xebff (root0)
    0xec00-0xec3f (pci2)
    0xec40-0xf7ff (root0)
    0xf800-0xf80f (atapci0)
    0xf810-0xffff (root0)
I/O memory addresses:
    0x0-0x9efff (ram0)
    0x9f000-0xfffff (root0)
    0x100000-0x3fffffff (ram0)
    0x40000000-0xbfffffff (root0)
    0xc0000000-0xc000ffff (pci0)
    0xc0010000-0xc00fffff (root0)
    0xc0100000-0xc0100fff (fxp0)
    0xc0101000-0xc011ffff (root0)
    0xc0120000-0xc013ffff (pci2)
    0xc0140000-0xc0140fff (fxp1)
    0xc0141000-0xc015ffff (root0)
    0xc0160000-0xc017ffff (pci2)
    0xc0180000-0xc0180fff (fxp2)
    0xc0181000-0xc019ffff (root0)
    0xc01a0000-0xc01bffff (pci2)
    0xc01c0000-0xc01c0fff (fxp3)
    0xc01c1000-0xc01dffff (root0)
    0xc01e0000-0xc01fffff (pci2)
    0xc0200000-0xc02003ff (pci3)
    0xc0200400-0xc02007ff (pci3)
    0xc0200800-0xffffffff (root0)


MAP type=01 base=0000000000000000 len=000000000009f400
SMAP type=02 base=000000000009f400 len=0000000000000c00
SMAP type=01 base=0000000000100000 len=000000003ff00000
SMAP type=01 base=0000000000100000 len=000000003ff00000
Overlapping memory regions, ignoring second region
SMAP type=02 base=00000000fff00000 len=0000000000100000
Copyright (c) 1992-2012 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
    The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 8.3-RELEASE #1: Wed Aug 21 16:37:11 CDT 2013
    root@gateway.home.pc:/usr/obj/usr/src/sys/MYKERNEL i386
Preloaded elf kernel "/boot/kernel/kernel" at 0xc0b02000.
Timecounter "i8254" frequency 1193182 Hz quality 0
Calibrating TSC clock ... TSC clock: 866425759 Hz
CPU: Intel Pentium III (866.43-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x68a  Family = 6  Model = 8  Stepping = 10
  Features=0x387f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,PN,MMX,FXSR,SSE>

Instruction TLB: 4 KB pages, 4-way set associative, 32 entries
Instruction TLB: 4 MB pages, fully associative, 2 entries
Data TLB: 4 KB pages, 4-way set associative, 64 entries
2nd-level cache: 256 KB, 8-way set associative, 32 byte line size
1st-level instruction cache: 16 KB, 4-way set associative, 32 byte line size
Data TLB: 4 MB Pages, 4-way set associative, 8 entries
1st-level data cache: 16 KB, 4-way set associative, 32 byte line size
real memory  = 1073741824 (1024 MB)
Physical memory chunk(s):
0x0000000000001000 - 0x000000000009efff, 647168 bytes (158 pages)
0x0000000000100000 - 0x00000000003fffff, 3145728 bytes (768 pages)
0x0000000000c26000 - 0x000000003edb4fff, 1041821696 bytes (254351 pages)
avail memory = 1041715200 (993 MB)
bios32: Found BIOS32 Service Directory header at 0xc00e7640
bios32: Entry = 0xe7650 (c00e7650)  Rev = 0  Len = 1
pcibios: PCI BIOS entry at 0xe76c0+0x57e
Other BIOS signatures found:
x86bios:   IVT 0x000000-0x0004ff at 0xc0000000
x86bios:  SSEG 0x010000-0x01ffff at 0xc3b79000
x86bios:  EBDA 0x09f000-0x09ffff at 0xc009f000
x86bios:   ROM 0x0a0000-0x0effff at 0xc00a0000
ULE: setup cpu 0
random: <entropy source, Software, Yarrow>
nfslock: pseudo-device
mem: <memory>
Pentium Pro MTRR support enabled
io: <I/O>
null: <null device, zero device>
panic: ram_attach: resource 2 failed to attach
KDB: stack backtrace:
#0 0xc06737b7 at kdb_backtrace+0x47
#1 0xc064770f at panic+0xaf
#2 0xc08ce7c6 at ram_attach+0x116
#3 0xc066dabf at device_attach+0x36f
#4 0xc066ed9c at device_probe_and_attach+0x2c
#5 0xc066edc9 at bus_generic_attach+0x19
#6 0xc08ce69e at nexus_attach+0x7e
#7 0xc066dabf at device_attach+0x36f
#8 0xc066ed9c at device_probe_and_attach+0x2c
#9 0xc066efa5 at bus_generic_new_pass+0xc5
#10 0xc066e841 at bus_set_pass+0x81
#11 0xc066e872 at root_bus_configure+0x12
#12 0xc089d96c at configure+0xc
#13 0xc05fe44c at mi_startup+0xac
#14 0xc04566b5 at begin+0x2c
```


----------



## tingo (Aug 22, 2013)

It doesn't boot in safe mode either?


----------



## s_gammons (Aug 23, 2013)

It won't boot in safe mode either.  I've since updated 8.3 to patch level 10, with the drive in another machine, and recompiled the kernel.  Still no luck though. Below is the output when booting in safe mode.

On another note, I've had a little luck with Fedora 19. It crashes too though.  I'm about ready to give up and toss the IP380 on the recycle pile.


```
SMAP type=01 base=0000000000000000 len=000000000009f400                         
SMAP type=02 base=000000000009f400 len=0000000000000c00                         
SMAP type=01 base=0000000000100000 len=000000003ff00000                         
SMAP type=01 base=0000000000100000 len=000000003ff00000                         
Overlapping memory regions, ignoring second region                              
SMAP type=02 base=00000000fff00000 len=0000000000100000                         
Copyright (c) 1992-2012 The FreeBSD Project.                                    
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994        
        The Regents of the University of California. All rights reserved.       
FreeBSD is a registered trademark of The FreeBSD Foundation.                    
FreeBSD 8.3-RELEASE-p10 #3: Wed Aug 21 21:27:26 CDT 2013                        
    root@gateway.home.pc:/usr/obj/usr/src/sys/MYKERNEL i386                     
Preloaded elf kernel "/boot/kernel/kernel" at 0xc0aa6000.                       
Timecounter "i8254" frequency 1193182 Hz quality 0                              
Calibrating TSC clock ... TSC clock: 866425780 Hz                               
CPU: Intel Pentium III (866.43-MHz 686-class CPU)                               
  Origin = "GenuineIntel"  Id = 0x68a  Family = 6  Model = 8  Stepping = 10     
  Features=0x387f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,P>
                                                                                
Instruction TLB: 4 KB pages, 4-way set associative, 32 entries                  
Instruction TLB: 4 MB pages, fully associative, 2 entries                       
Data TLB: 4 KB pages, 4-way set associative, 64 entries                         
2nd-level cache: 256 KB, 8-way set associative, 32 byte line size               
1st-level instruction cache: 16 KB, 4-way set associative, 32 byte line size    
Data TLB: 4 MB Pages, 4-way set associative, 8 entries                          
1st-level data cache: 16 KB, 4-way set associative, 32 byte line size           
real memory  = 1073741824 (1024 MB)                                             
Physical memory chunk(s):                                                       
0x0000000000001000 - 0x000000000009efff, 647168 bytes (158 pages)               
0x0000000000100000 - 0x00000000003fffff, 3145728 bytes (768 pages)              
0x0000000000c26000 - 0x000000003edb4fff, 1041821696 bytes (254351 pages)        
avail memory = 1041719296 (993 MB)                                              
bios32: Found BIOS32 Service Directory header at 0xc00e7640                     
bios32: Entry = 0xe7650 (c00e7650)  Rev = 0  Len = 1                            
pcibios: PCI BIOS entry at 0xe76c0+0x57e                                        
Other BIOS signatures found:                                                    
x86bios:   IVT 0x000000-0x0004ff at 0xc0000000                                  
x86bios:  SSEG 0x010000-0x01ffff at 0xc3b79000                                  
x86bios:  EBDA 0x09f000-0x09ffff at 0xc009f000                                  
x86bios:   ROM 0x0a0000-0x0effff at 0xc00a0000                                  
ULE: setup cpu 0                                                                
null: <null device, zero device>                                                
random: <entropy source, Software, Yarrow>                                      
io: <I/O>                                                                       
mem: <memory>                                                                   
Pentium Pro MTRR support enabled                                                
panic: ram_attach: resource 2 failed to attach                                  
KDB: stack backtrace:                                                           
#0 0xc066cf17 at kdb_backtrace+0x47                                             
#1 0xc0640e6f at panic+0xaf                                                     
#2 0xc0887936 at ram_attach+0x116                                               
#3 0xc066721f at device_attach+0x36f                                            
#4 0xc06684fc at device_probe_and_attach+0x2c                                   
#5 0xc0668529 at bus_generic_attach+0x19                                        
#6 0xc088780e at nexus_attach+0x7e                                              
#7 0xc066721f at device_attach+0x36f                                            
#8 0xc06684fc at device_probe_and_attach+0x2c                                   
#9 0xc0668705 at bus_generic_new_pass+0xc5                                      
#10 0xc0667fa1 at bus_set_pass+0x81                                             
#11 0xc0667fd2 at root_bus_configure+0x12                                       
#12 0xc0856adc at configure+0xc                                                 
#13 0xc05f7bac at mi_startup+0xac                                               
#14 0xc04526f5 at begin+0x2c                                                    
Uptime: 1s                                                                      
Automatic reboot in 15 seconds - press a key on the console to abort            
--> Press a key on the console to reboot,                                       
--> or switch off the system now.
```


----------



## tingo (Aug 25, 2013)

Have you tried reseating the memory in the machine? (taking out the modules and putting them in again).


----------



## s_gammons (Aug 26, 2013)

No. I gave up on trying to get a later version of FreeBSD to work. 

With the help of some of the OpenBSD guys, we managed to get OpenBSD 5.3 to work.  It seems as though there's a BIOS issue that causes a memory addressing problem. When you do a mach mem, it shows two regions assigned to the same memory range. If one does a `mach mem -0x3ff00000@0x100000` the OS will try to load. One still has to disable OHCI in order to get the OS to load though. So, the question would be does the older FreeBSD kernel detect the BIOS issue and ignore it and the 8.3 and newer kernels don't?

I've since found what I think is either an intermittent connection or a hard drive controller problem. Some times the OS will load and at times it gives error indicating a hardware problem.

Stan


----------



## Simba7 (Feb 27, 2014)

I have been trying to do the exact same thing, except with FreeBSD 10.0-RELEASE. So far, it fails to attach the RAM. Here's what the smap says:

```
SMAP type=01 base=0000000000000000 len=000000000009f400
SMAP type=02 base=000000000009f400 len=0000000000000c00
SMAP type=01 base=0000000000100000 len=000000003ff00000   <Duplicates
SMAP type=01 base=0000000000100000 len=000000003ff00000   <Duplicates
SMAP type=02 base=00000000fff00000 len=0000000000100000
```
Is there a way to remove the single duplicate? I tried the mach mem removal with OpenBSD and it works perfectly. Hopefully there's a similar function in FreeBSD.


----------



## Chris_H (Mar 3, 2014)

Greetings,
 Have either of you (@s_gammons, and @Simba7) brought this up on the stable@ mailing list? Have either of you considered sending a pr()? It's hard to get the attention something like this deserves, if the issue(s) don't get sent to the people best suited to handle such things. 

On another note; have either of you attempted to get the latest BIOS version for your hardware? Sometimes it's as simple as that.

Anyway, just thought it was worth mentioning.

Best wishes.

--Chris


----------



## Simba7 (Dec 30, 2014)

Well, I think I found a solution. I was examining the bootlog and saw that there seems to be some changes in the /usr/src/sys/x86/x86/nexus.c file. So, I went to look and found that if I deleted the smap chunk, the IP380 boots to FreeBSD 10.1 just fine. The chunks I deleted are in _*italicized bold*_:

```
/* Placeholder for system RAM. */
static void
ram_identify(driver_t *driver, device_t parent)
{
if (resource_disabled("ram", 0))
return;
if (BUS_ADD_CHILD(parent, 0, "ram", 0) == NULL)
panic("ram_identify");
}
static int
ram_probe(device_t dev)
{
device_quiet(dev);
device_set_desc(dev, "System RAM");
return (0);
}
static int
ram_attach(device_t dev)
{
[I][B]struct bios_smap *smapbase, *smap, *smapend;[/B][/I]
struct resource *res;
vm_paddr_t *p;
[B][I]caddr_t kmdp;
uint32_t smapsize;[/I][/B]
int error, rid;
[B][I]/* Retrieve the system memory map from the loader. */
kmdp = preload_search_by_type("elf kernel");
If (kmdp == NULL)
kmdp = preload_search_by_type(ELF_KERN_STR); 
if (kmdp != NULL)
smapbase = (struct bios_smap *)preload_search_info(kmdp,
MODINFO_METADATA | MODINFOMD_SMAP);
else
smapbase = NULL;
if (smapbase != NULL) {
smapsize = *((u_int32_t *)smapbase - 1);
smapend = (struct bios_smap *)((uintptr_t)smapbase + smapsize);[/I][/B]

[B][I]rid = 0;
for (smap = smapbase; smap < smapend; smap++) {
if (smap->type != SMAP_TYPE_MEMORY ||
smap->length == 0)
continue;
#ifdef __i386__
/*
  * Resources use long's to track resources, so
  * we can't include memory regions above 4GB.
  */
if (smap->base > ~0ul)
continue;
#endif
error = bus_set_resource(dev, SYS_RES_MEMORY, rid,
  smap->base, smap->length);
if (error)
panic(
  "ram_attach: resource %d failed set with %d",
  rid, error);
res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
  0);
if (res == NULL)
panic("ram_attach: resource %d failed to attach",
  rid);
rid++;
}
return (0);
}[/I][/B]
/*
  * If the system map is not available, fall back to using
  * dump_avail[].  We use the dump_avail[] array rather than
  * phys_avail[] for the memory map as phys_avail[] contains
  * holes for kernel memory, page 0, the message buffer, and
  * the dcons buffer.  We test the end address in the loop
  * instead of the start since the start address for the first
  * segment is 0.
  */
for (rid = 0, p = dump_avail; p[1] != 0; rid++, p += 2) {
```
I'm not sure if this will fix other platforms as well. I haven't tested it on that old Digital system to see if it will work, but it does work great on the Nokia IP380.

EDIT: It does boot, but I can't get any of the network interfaces to work. I'll continue tweaking the code, or I'll restore it and comment out the panic routines.


----------

