# Debugging the boot process



## balanga (Mar 21, 2017)

Is there any way to trace what is going on whilst booting if the process suddenly hangs?

ie like a 'safe mode'... I don't suppose there is anything like single step booting....


----------



## Maxnix (Mar 21, 2017)

You can set rc_info or rc_debug in /etc/rc.conf. Give a read to rc.conf(5).


----------



## balanga (Mar 22, 2017)

Didn't realise there was so much to rc.conf(5)().... It would probably take me a year to under stand that... In did enter rc_debug in/etc/rc.conf but didn't see anything... There was nothing in /var/run/dmesg.booteither...

The system only runs for about 10 secs before hanging.. I did try Linux Mint on this system and that booted up successfully


----------



## Maxnix (Mar 22, 2017)

balanga said:


> In did enter rc_debug in/etc/rc.conf but didn't see anything... There was nothing in /var/run/dmesg.booteither...



Both rc_debug and rc_info have boolean values, as stated in rc.conf(5). To turn them on, you must use

```
rc_debug="YES"
rc_info="YES"
```
and you will see the diagnostic messages.


----------



## balanga (Mar 22, 2017)

Just tried.... and only got the normal boot msgs nothing else.... What should I expect to see?

Maybe I need something in loader.conf....


----------



## Maxnix (Mar 22, 2017)

Choose the boot verbose option from the boot menu (or in alternative, type `boot -v` at the loader prompt). Possibly post what you get, or a screenshot. It could be an ACPI problem.


----------



## balanga (Mar 22, 2017)

Never heard of this option, but it does show lots of information, none of which I understand, but just near the hang it says

```
pcib0: allocated type 3 (0xf80000-0xf87ff) for rid of orm0
pcib0: allocated type 3 (0xff8800-0xf8fff) for rid of orm0

*******************lots of lines like this*******************

pcib0: allocated type 3 (0xff0000-0xf7fff) for rid of orm0
pcib0: allocated type 3 (0xff8000-0xfffff) for rid of orm0
isa_probe_children: disabling PnP devices
atrtc: atrtc0 already exists; skipping it
attimer: attimer0 already exists; skipping it
sc: sc0 already exists; skipping it
uart: uart0 already exists; skipping it
isa_probe_children: probing non-PnP devices
sc0 failed to probe on isa0
vga0 failed to probe on isa0
pcib0: allocated type 4 (0x60-0x60) for rid 0 of atkbdc0
pcib0: allocated type 4 (0x64-0x64) for rid 1 of atkbdc0
atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0
pcib0: allocated type 4 (0x60-0x60) for rid 0 of atkbdc0
pcib0: allocated type 4 (0x64-0x64) for rid 1 of atkbdc0
atkbdc0: <AT Keyboard> irq1 on atkbdc0
kbd0 at atkbd0
kbd0: atkbd0. generic (0), config:0x0, flags:0x1f0000
ioapic0: routing intpin 1 (ISA IRQ 1) to lapic 0 vector 55
atkbd0: [GIANT-LOCKED]
random: harvesting attach, 8 bytes (4 bits) from atkbd0
psm0: unable to allocate IRQ
random: harvesting attach, 8 bytes (4 bits) from atkbdc0
pcib0: allocated type 4 (0x3f0-0x3f5) for rid 0 of fdc0
pcib0: allocated type 4 (0x3f7-0x3f7) for rid 1 of fdc0
fdc0: failed to probe at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
ppc0: cannot reserve I/O port range
ppc0 failed to probe at irq 7 on isa0
pcib0: allocated type 4 (0x2f8-0x2f8) for rid 0 of uart1
```

Apologies for any typos that was manually typed...


----------



## balanga (Mar 23, 2017)

This guy seemed to have a similar problem...

https://forum.opnsense.org/index.php?topic=3927.0

His solution:-

```
Adding hint.uart.1.disabled="1" to /boot/device.hints does the trick: OPNsense installer successfully starts up :-)
```
...didn't work for me....

(Can't help wondering why we need another FreeBSD based router/firewalll....)


----------



## HL1234 (Mar 25, 2017)

I can not say what your problem is, but for some time I has created a list for the acronym what can make the boot information more clearer. I like to share it here:
(on other hardware would be other results, but you see the the main principle)

```
driver  description (alphabetic order)
   ------+----------------------------------------------------------------------------------------
   xxx0    -- driver for device no "0"
   xxx0    -- driver for device no "1"

   acpi    -- ACPI - Advanced Configuration and Power Management support
              (The acpi driver provides support for the Intel/Microsoft/Compaq/Toshiba ACPI standard)
   acpi_button -- Power Button
   ada0    -- WDC WD800JB-00JJC0 05.01C05 / ATA-6 device
              66.700MB/s transfers (UDMA4, PIO 8192bytes)
              76319MB (156301488 512 byte sectors: 15H 63S/T 16383C)
   ada1    -- ST380215A 3.AAD / ATA-7 device
              66.700MB/s transfers (UDMA4, PIO 8192bytes)
              76319MB (156301488 512 byte sectors: 15H 63S/T 16383C)
   agp     -- generic interface to the Accelerated Graphics Port (AGP)
   ata     -- generic ATA/SATA controller driver for ATA channel 0/1
   atapci  -- Intel ICH UDMA66 controller:
   atkbdc0 -- the AT keyboard controller interface
   atkbd   -- the AT keyboard interfac / IRQ 1
   atrtc   -- AT Real-Time Clock (RTC) driver
   attimer -- i8254 Programmable Interval Timer (AT Timer) driver for Timecounter / Event Timer
   cd0       -- MATSHITA DVD-ROM SR-8585 1W21 / Removable CD-ROM SCSI-0 device
              33.300MB/s transfers (UDMA2, ATAPI 12bytes, PIO 65534bytes)
   fdc     -- PC architecture floppy disk controller driver for fd0/1
   isab    -- PCI-ISA bridge
   isa     -- ISA bus
   miibus  -- IEEE 802.3 Media Independent Interface network bus
   orm     -- ISA Option ROM - ISA I/O space option ROM(s) driver
   pcib    -- PCI bridge driver for:
   pcib0   -- ACPI Host-PCI bridge
   pcib1   -- ACPI PCI-PCI bridge
   pci     -- generic PCI driver for
   pci0    -- ACPI PCI bus on pcib0
   pci1    -- ACPI PCI bus on pcib1
   ppc     -- Parallel Port Chipset driver
   psm     -- PS/2 mouse style pointing device driver / IRQ 12
   sc        -- the console driver for the System console (VGA <16 virtual consoles, flags=0x300>)
   uart    -- driver for Universal Asynchronous Receiver/Transmitter (UART)
              for EIA RS-232C (CCITT V.24) serial communications interface
              (16550 or compatible uart0 - IRQ 4 / uart1 - IRQ 3)
   ugen    -- USB generic device support
   uhci    -- UHCI USB Host Controller driver (supports all UHCI v1.1 compliant controllers)
   uhub    -- Intel UHCI root HUB (class 9/0, rev 1.00/1.00, addr 1)
              uhub0 = 2 ports with 2 removable, self powered
              uhub1 = 4 ports with 4 removable, self powered
   usbus   -- Intel 82801AA (ICH) USB controller [port 0x1020-0x103f / IRQ 9] for
              usbus0 = 12Mbps Full Speed USB v1.0
   vgapci  -- VGA-compatible display / IRG 11
   xl        -- 3Com Etherlink XL and Fast Etherlink XL Ethernet device driver
              xl0 = Ethernet address: 00:01:02:22:0f:17
   xlphy   -- Broadcom 3c905C internal PHY / PHY 24 on miibus0
              10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto, auto-flow
```


----------



## balanga (Mar 27, 2017)

Just wondered if Linux has something like a `dmesg` so that I could find out what it sees, since it boots up successfully. It may give me a clue about what FreeBSD can't handle...


----------



## HL1234 (Mar 27, 2017)

Maybe this can help you. 
https://www.freebsd.org/relnotes/CURRENT/hardware/support.html
It's a list of Supported Devices whether it would be a hardware problem.

I remember that I hat, for a long time, in
/boot/device.hints set some settings to configure a legacy device; i.e. my old network card:

```
hint.ed.0.at=isa
hint.ed.0.irq="5"          //changed
hint.ed.0.port="0x340"     //changed
hint.ed.0.maddr="0xd8000
```
So I thing this could be the right place to do some changes if it has some problems to boot because of specific hardware. But I remember I had self asked for that solution in https://forums.freebsd.org/forums/32/


----------



## balanga (Mar 30, 2017)

It's over a week since I started looking at this and have not made any progress into how I can determine why FreeBSD just suddenly halts in the middle of the boot process. Debugging does give any indication.

It's particularly galling to see Linux Mint boot up without any problems... Can I use Linux's `dmesg` to provide some indication as to where FreeBSD is getting stuck?


----------



## balanga (Mar 30, 2017)

Could anyone check https://pastebin.com/nKBYpmMz which is the output from Linux's `lshw` command, to see if FreeBSD might struggle with the hardware being used?


----------



## Terry_Kennedy (Mar 31, 2017)

balanga said:


> It's over a week since I started looking at this and have not made any progress into how I can determine why FreeBSD just suddenly halts in the middle of the boot process. Debugging does give any indication.


I don't see that you provided the FreeBSD version you're running. That will be at the very beginning of the kernel boot messages, though it will probably scroll off your screen before you can catch it. You might want to download the latest snapshot for the release you're running (10.3 or 11.0) and see if it boots successfully. There are a lot of files in those directories - you probably want the newest amd64 snapshot. Get the memstick image if you're booting from USB, otherwise get the ISO image and burn it to CD-R. If you're going to use 10.3, you'll probably want the UEFI image (see below). 11.0 uses a single image for UEFI and BIOS. You can get by with the mini-memstick or bootonly file, since you just want to see if the system can boot.

Based on the complaints about sc0 / vga0 in the boot messages you provided, I think you're running in UEFI mode. Can you try switching to BIOS mode in your motherboard's setup menus, if it offers that option? I saw a bunch of UEFI commits come through recently, though I think they were fixes for boot panics, not hangs.


----------



## balanga (Mar 31, 2017)

I have tried both 11.0-RELEASE and the latest 12.0 using a mini-memstick image. This particular problem relates to a Z83 Mini PC. Other problems related to graphics on various ThinkPads and were not at all related. This unit is very new and finding my way round the BIOS/UEFI is not easy, in fact being exposed to a UEFI shell is something I haven't had to contend with before.  It does boot Linux Mint, so I am hopeful that it will be able to run FreeBSD at some point, but it is frustrating being unable to discover exactly where it hangs. I thought the output from Linux's `lshw`command might indicate where FreeBSD was missing a driver, but nothing came to mind.


----------



## Terry_Kennedy (Mar 31, 2017)

balanga said:


> I have tried both 11.0-RELEASE and the latest 12.0 using a mini-memstick image. I am hopeful that it will be able to run FreeBSD at some point, but it is frustrating being unable to discover exactly where it hangs.


r308926 was not MFC'd to 11-STABLE, so 11.0 definitely won't work. Can you try setting both of:

```
hint.uart.0.disabled="1"
hint.uart.1.disabled="1"
```
in /boot/device.hints, or interactively by escaping to the loader prompt and doing:

```
set hint.uart.0.disabled=1
set hint.uart.1.disabled=1
boot
```
and see if that works?


----------



## balanga (Mar 31, 2017)

That's great! Thank you soooooooooooo much.


----------

