Sunday, March 18, 2012

HowTo: Enabling Broadcom BCM4318 wireless on Linux Mint

After a HDD failure my wife asked for a Linux distribution (!) for her old HP dv5000 laptop. I picked Linux Mint due to its multimedia friendliness and restricted firmware support.

Funny enough it didn't attach a driver to the wireless chipset nor offered one through the restricted firmware pop-up.

lspci allowed me to identify the chipset, a Broadcom BCM4318 wireless device:

$ sudo lspci
00:00.0 Host bridge: ATI Technologies Inc RS480 Host Bridge (rev 01)
00:01.0 PCI bridge: ATI Technologies Inc RS480 PCI Bridge
00:05.0 PCI bridge: ATI Technologies Inc RS480 PCI Bridge
00:13.0 USB Controller: ATI Technologies Inc IXP SB400 USB Host Controller
00:13.1 USB Controller: ATI Technologies Inc IXP SB400 USB Host Controller
00:13.2 USB Controller: ATI Technologies Inc IXP SB400 USB2 Host Controller
00:14.0 SMBus: ATI Technologies Inc IXP SB400 SMBus Controller (rev 11)
00:14.1 IDE interface: ATI Technologies Inc IXP SB400 IDE Controller
00:14.3 ISA bridge: ATI Technologies Inc IXP SB400 PCI-ISA Bridge
00:14.4 PCI bridge: ATI Technologies Inc IXP SB400 PCI-PCI Bridge
00:14.5 Multimedia audio controller: ATI Technologies Inc IXP SB400 AC'97 Audio Controller (rev 02)
00:14.6 Modem: ATI Technologies Inc SB400 AC'97 Modem Controller (rev 02)
00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map
00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
01:05.0 VGA compatible controller: ATI Technologies Inc Radeon XPRESS 200M 5955 (PCIE)
06:02.0 Network controller: Broadcom Corporation BCM4318 [AirForce 54g] 802.11a/b/g PCI Express Transceiver (rev 02)
06:04.0 CardBus bridge: Texas Instruments PCIxx21/x515 Cardbus Controller
06:04.2 FireWire (IEEE 1394): Texas Instruments OHCI Compliant IEEE 1394 Host Controller
06:04.3 Mass storage controller: Texas Instruments PCIxx21 Integrated FlashMedia Controller
06:04.4 SD Host controller: Texas Instruments PCI6411/6421/6611/6621/7411/7421/7611/7621 Secure Digital Controller
06:06.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)

To fix the problem run the following commands:
$ sudo apt-get install b43-fwcutter
$ wget http://mirror2.openwrt.org/sources/broadcom-wl-4.150.10.5.tar.bz2
$ tar xf broadcom-wl-4.150.10.5.tar.bz2
$ cd broadcom-wl-4.150.10.5/driver/
$ sudo b43-fwcutter -w /lib/firmware/ wl_apsta_mimo.o
$ sudo modprobe b43
$ sudo echo "b43" >> /etc/modules

With this we've installed the proper driver and added it at boot time.

Bottom line: there's so much a pretty GUI can do ;)

Tip: Fix Enemy Territory empty server list

Ever since my desktop's northbridge fan died I stopped playing Enemy Territory. Luckily I've finally replaced the fan so fired ET up and noticed that no server was listed.

It seems that as of late the Enemy Territory's masterlist is down. As a workaround edit the hosts file and add a new masterlist provided by etmaster.net.

In FreeBSD and Linux distributions, run the following command:
# echo "91.220.53.73 etmaster.idsoftware.com" >> /etc/hosts

Fire up ET as a new list of servers will be available.

Major thanks Paul at the Splash Damage forums for providing a solution ;)

HowTo: nForce2 sound on FreeBSD

I finally got around to replace the northbridge fan of my ABIT AN-7 powered desktop and with it boot its old FreeBSD 7.4-STABLE install. Though I have a Creative SoundBlaster Audigy 4 I wanted to make sure I could go by with just the motherboard's nForce2 integrated sound system, so bellow I'll explain how to enable the nForce2 sound on FreeBSD.

Let's check if FreeBSD recognized and assigned a sound driver to the device:
$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2007061600/i386)
Installed devices:

# dmesg | grep -i audio
pci0: at device 5.0 (no driver attached)
pci0: at device 6.0 (no driver attached)

# cd /usr/ports/sysutils/pciutils ; make install clean ; rehash

# lspci | grep -i audio
00:05.0 Multimedia audio controller: nVidia Corporation nForce Audio Processing Unit (rev a2)
00:06.0 Multimedia audio controller: nVidia Corporation nForce2 AC97 Audio Controler (MCP) (rev a1)

Ok. So no sound driver is attached to the device. To use the sound device load the proper driver which in this case is snd_ich according to FreeBSD 7 Relase Notes

Let's attach the driver to the device:

# kldload snd_ich

To be sure that the sound driver was correctly loaded run:

$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2007061600/i386)
Installed devices:
pcm0: at io 0xb400, 0xb800 irq 22 bufsz 16384 kld snd_ich [MPSAFE] (1p:1v/1r:1v channels duplex default)

To attach the appropriate driver at boot, we need to add it to loader.conf(5) like so:
# echo 'snd_ich_load="YES"' >> /boot/loader.conf

To setup sound output levels for various audio sources and frequency ranges you can use the FreeBSD mixer. To display the current mixer values do the following:

$ mixer
Mixer vol      is currently set to  75:75
Mixer pcm      is currently set to  75:75
Mixer speaker  is currently set to  75:75
Mixer line     is currently set to  75:75
Mixer mic      is currently set to   0:0
Mixer cd       is currently set to  75:75
Mixer rec      is currently set to   0:0
Mixer igain    is currently set to   0:0
Mixer ogain    is currently set to  50:50
Mixer line1    is currently set to  75:75
Mixer phin     is currently set to   0:0
Recording source: mic

To change mixer values you can type mixer followed by the name of the device and the desired level. If you wanted to change the CD output volume to 95 percent on left channel and 85 on the right channel:

$ mixer cd 95:85

And that's it. As a side note, though I mention FreeBSD 7.4-STABLE these instructions apply to earlier version of FreeBSD.

For additional information consult sound(4) and snd_ich(4) man pages.

Thursday, January 26, 2012

HowTo: Mounting NTFS partition in write mode on FreeBSD

My brother's old laptop died and I got to keep its hard-drive. Being a Windows machine, it had a bunch of NTFS partitions. So this post explains how to identify a NTFS partition, mount it as read-only and finally learn how to mount it in write mode. I should mention that the FreeBSD machine run FreeBSD 7.4 but the same step should apply to latter versions of the OS.

Physically attached the hard-drive (in my case I plugged an USB HDD) and have a look at /var/log/messages to identify the harddrive.
% su
# tail -n 20 /var/log/messages
Jan 26 21:40:03 flumen kernel: da0: Fixed Direct Access SCSI-4 device
Jan 26 21:40:03 flumen kernel: da0: 40.000MB/s transfers
Jan 26 21:40:03 flumen kernel: da0: 114473MB (234441648 512 byte sectors: 255H 63S/T 14593C)
Similar information can be collected from dmesg.
# dmesg
umass0: on uhub4
da0 at umass-sim0 bus 0 target 0 lun 0
da0: Fixed Direct Access SCSI-4 device
da0: 40.000MB/s transfers
da0: 114473MB (234441648 512 byte sectors: 255H 63S/T 14593C)
Let's find out which is the NTFS partition:
# fdisk /dev/da0
******* Working on device /dev/da0 *******
parameters extracted from in-core disklabel are:
cylinders=14593 heads=255 sectors/track=63 (16065 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=14593 heads=255 sectors/track=63 (16065 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:

The data for partition 1 is:
sysid 18 (0x12),(Compaq diagnostics)
start 63, size 16611147 (8110 Meg), flag 0
beg: cyl 0/ head 1/ sector 1;
end: cyl 1023/ head 254/ sector 63
The data for partition 2 is:
sysid 7 (0x07),(OS/2 HPFS, NTFS, QNX-2 (16 bit) or Advanced UNIX)
start 16611210, size 117194175 (57223 Meg), flag 80 (active)
beg: cyl 1023/ head 0/ sector 1;
end: cyl 1023/ head 254/ sector 63
The data for partition 3 is:
sysid 15 (0x0f),(Extended DOS (LBA))
start 133805385, size 100631160 (49136 Meg), flag 0
beg: cyl 1023/ head 0/ sector 1;
end: cyl 1023/ head 254/ sector 63
The data for partition 4 is:
Issuing the following command will mount a NTFS partition in read-only mode:
# mount -t ntfs /dev/da0s2 /mnt/
To be able to write into a NTFS partition it is required to install the sysutils/fuse-ntfs port:
# cd /usr/ports/sysutils/fusefs-ntfs/ && make install clean
If you use, as described in the man page, mount -t ntfs-3g an error will occurr:
# mount -t ntfs-3g /dev/da0s2 /mnt/
mount: /dev/da0s2 : Operation not supported by device
To mount the NTFS partition in write mode issue:
# ntfs-3g /dev/da0s2 /mnt/
Let's make sure that the partition is mounted:
#mount
/dev/ad4s1a on / (ufs, local)
devfs on /dev (devfs, local)
/dev/ad4s1e on /tmp (ufs, local, soft-updates)
/dev/ad4s1f on /usr (ufs, local, soft-updates)
/dev/ad4s1d on /var (ufs, local, soft-updates)
/dev/ad5s1d on /mnt/1 (ufs, local, soft-updates)
/dev/fuse0 on /mnt/2 (fusefs, local, synchronous)
man ntfs-3g contains some Linuxisms and as such read the man page with a grain of salt ;)

Saturday, July 9, 2011

Tip: Fixing Atheros L2 driver attachment on FreeBSD

My personal server, a low-powered system based on an integrated motherboard ASUS I220GC, is using a D-Link DGE-528 Ethernet PCI card which runs fine on FreeBSD 7.4. However while toying with the system I decided to active the integrated Atheros L2 10/100 Ethernet device that I had disabled a long time ago.

Upon enabling the device on the BIOS and booting the system I came across an odd situation: ae(4) which is Atheros L2 driver wasn't loading properly.
# dmesg | less
Jul 8 22:07:22 flumen kernel: pci2: on pcib2
Jul 8 22:07:22 flumen kernel: pci2: at device 0.0 (no driver attached)
# pciconf -lv
none2@pci0:2:0:0: class=0x020000 card=0x82331043 chip=0x20481969 rev=0xa0 hdr=0x00
vendor = 'Attansic (Now owned by Atheros)'
device = 'Fast Ethernet 10/100 Base-T Controller (Atheros L2)'
class = network
subclass = ethernet
To fix this ae(4) driver has to be loaded and then it will attach himself to the PCI device (pci2 in my system):
# kldload -v if_ae
ae0: mem 0xdffc0000-0xdfffffff irq 17 at device 0.0 on pci2
ae0: Using MSI messages.
miibus1: on ae0
atphy0: PHY 0 on miibus1
atphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
ae0: Ethernet address: 00:1f:c6:dd:15:72
ae0: [FILTER]
Loaded if_ae, id=5
By running pciconf(8) we can confirm that the driver is now successfully attached:
# pciconf -lv
ae0@pci0:2:0:0: class=0x020000 card=0x82331043 chip=0x20481969 rev=0xa0 hdr=0x00
vendor = 'Attansic (Now owned by Atheros)'
device = 'Fast Ethernet 10/100 Base-T Controller (Atheros L2)'
class = network
subclass = ethernet
To load the driver as a module at boot time loader.conf(5) needs to be edited.
# echo 'if_ae_load="YES"' >> /boot/loader.conf
Now that the driver attachment at boot is solved rc.conf(5) needs to be edited so that FreeBSD assigns an interface to Atheros L2 device at boot:
# vim /etc/rc.conf
ifconfig_ae0="inet 192.168.1.1 netmask 255.255.255.0"
The next time the system is booted the next settings are applied and Atheros L2 is properly working (make sure you use your own network settings namely netmask and inet).

Sources:
man ae
man ifconfig
man loader.conf
man pciconf
man rc.conf

Friday, April 23, 2010

Tip: Fixing xorg-server 1.7.6 keyboard and mouse issues on Gentoo

I came across a weird issue on my Gentoo box: both keyboard and mouse weren't working. I immediately though of hal and X11...

A quick stroll to the Gentoo Forums pointed to x11-drivers/xf86-input-keyboard, x11-drivers/xf86-input-mouse and x11-drivers/xf86-input-evdev has the culprits!

Here's how to fix the issue:
  1. $ su
  2. # eix-sync
  3. # emerge -1 $(qlist -IC x11-drivers)
This will rebuild X11 drivers in you system and have you using your keyboard and mouse again. If you don't have qlist installed in your system just emerge app-portage/portage-utils.

Now wasn't that fun?

;)

Thursday, March 25, 2010

HowTo: Upgrade FreeBSD 7.2 to 7.3

Disclaimer: this post is for those that instead of using FreeBSD's excellent documentation maintain the bad habit of googling for things already covered in the project's official documentation. This is more or less a copy-paste of the FreeBSD 7.3-RELEASE Announcement instructions for upgrading 7.2 to 7.3.

These are needed steps to upgrade, through the binary upgrade method, the kernel and userland utilities to 7.3-RELEASE:
  1. % su
  2. # freebsd-update upgrade -r 7.3-RELEASE
  3. # freebsd-update install
  4. # shutdown -r now
  5. % su
  6. # freebsd-update install
  7. # shutdown -r now
On step 1 we've started of by becoming the superuser. Step 2 initiates the freebsd-update utility pointing the upgrade to 7.3-RELEASE, after that we proceed with the installation of the kernel on step 3.

Upon rebooting the new kernel is enabled and we move into step 6. Here we end the upgrade process by updating the userland utilities.

That's it!

If you found this post useful that's actually a bad news: you aren't reading the project's official documentation! So please point to http://www.freebsd.org and educate yourself on FreeBSD ;)