Group: Hardware/RepairsRefurbishingAndMaintenance

From LibrePlanet
< Group:Hardware
Revision as of 06:26, 15 September 2022 by GNUtoo (talk | contribs) (Reink: fix some english)
Jump to: navigation, search

Introduction

This page is meant to list free software applications or code that can be used to either:

  • Repair devices
  • Do regular device maintenance to keep the devices functional
  • Repurpose devices

Software for specific hardware

People that have to repair or maintain computers can benefit from various tools that can interact with hardware, be used to debug problems, repair specific issues, track hardware health over time, etc.

When storage devices (like HDDs, SSDs, etc) are breaking it's also useful to recover and/or erase the data on it.

Batteries

Linux /sys/class/power_supply/*/

X86 Laptops batteries often have a nonfree firmware somewhere and calibration data. The computer embedded controller usually interfaces with that firmware. And Linux has drivers to talk to the embedded controller to get data about the battery used by laptops.

We can usually get battery information through Linux standard interfaces:

$ grep . /sys/class/power_supply/BAT0/uevent 
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
[...]
POWER_SUPPLY_POWER_NOW=15191000
POWER_SUPPLY_ENERGY_FULL_DESIGN=84240000
POWER_SUPPLY_ENERGY_FULL=32310000
POWER_SUPPLY_ENERGY_NOW=9690000
POWER_SUPPLY_CAPACITY=29
POWER_SUPPLY_CAPACITY_LEVEL=Normal
[...]

So not only we can see if charging works (here it's Discharging) but in a lot of cases, we can even understand how much the battery would last compared to the amount of time it lasted when manufactured.

Here we can simply calculate that by dividing POWER_SUPPLY_ENERGY_FULL by POWER_SUPPLY_ENERGY_FULL_DESIGN:

$ python3
Python 3.9.9 (main, Jan  1 1970, 00:00:01) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 100 * (32310000 / 84240000)
38.35470085470086

Note that this information is only accurate if the calibration data is correct. Batteries typically have I2C interfaces, so it's possible to talk to the battery firmware and it's probably possible to modify its calibration data too in some way.

So the battery I'm using will last 38% of the original battery. So if the battery lasted 5 hours after being manufactured, it will now last about 1 hours and 55 minutes.

In contrast with x86 laptops smartphones also have calibration data (typically in the battery gauge chip), but they often don't have any information on how much the battery would last compared to the original battery life.

A way to find out could be to develop a procedure that drains the battery as fast as possible (for instance using cpuburn to use the CPU as much as possible) and look how much different batteries last.

It might also be possible to caracterize the battery directly with hardware meant to discharge it and measure its voltage with multimeters and sigrok (a free software tool that can retrieve information from some multimeters).

Cooling

cpuburn

The cpuburn software tries to use a CPU core as much as possible so that can be used to test the cooling of a device, or the CPUs. If you have 8 cores, you need to run 8 instances of that software.

Implementations exists for multiple CPU for at least ARM and x86.

Linux

  • Linux has an hwmon subsystem and it can be used to manually control fans
  • Linux can also report various temperature sensors data through the hwmon subsystem

lm_sensors

lm_sensors can use data exported by Linux to print temperatures etc

Ethernet controllers

Ethtool and Linux drivers

Some ethernet controller have some (usually I2C) flash chip used to hold their configuration data.

Sometimes the content of this chip is corrupted, making the Ethernet controller useless (for instance because the driver refuses to load.

For some e1000 or e1000e compatible controllers, it's possible to patch Linux to make sure that the driver loads, and then use ethtool to reprogram the flash chip.

For that to work, the flash chip needs to be directly connected to the Ethernet controller. This is the case with computers like the Thinkpad X60.

Flashrom, bincfg, ich9gen and ifdtool

On some computers (like the Thinkpad X200), the Ethernet controller configuration data is not on a dedicated flash chip, but it's in a partition of the flash chip that also holds the BIOS.

For that, flashrom can be used to dump the flash chip content (that can usually be done on the laptop itself if it runs Libreboot or Coreboot).

Once this is done, ifdtool (which is available in Parabola in the libreboot-utils package) can extract the content of the Ethernet controller partition.

Its content can either be recreated with Libreboot's ich9gen, or with bincfg (part of libreboot-utils in Parabola).

The ich9gen tool is way easier to use as it only asks the MAC address on the command line:

ich9gen --macaddress XX:XX:XX:XX:XX:XX

the mac address is often found on a sticker on the bottom of the laptop. The ich9gen tool then produces a file that has the intel flash descriptor (the partition table of the flash chip) and the Ethernet controller partition. The later can be extracted with ifdtool again, for instance with

ifdtool -x ich9fdgbe_8m.bin

The bincfg tool can instead edit all the configuration of the Ethernet controller partition, but it requires users to download the datasheet (easily found online and/or on the Intel website) and to understand each field to modify. So it's way harder to use.

Flash chips

Flashrom

Flashrom can read and write various flash chips (With Parallel, SPI, FWH, LPC interfaces) so it can potentially be used to repair many devices. You also need a compatible flash programmer (that works with a compatible voltage level) to program flash chips conveniently.

On some computers it can also read/write the computer flash chip that holds the boot software (like the BIOS or UEFI). It can also read/write the flash chip of various cards (like GPUs, network cards, etc). In both cases it's not always able to read/write the full flash chip as sometimes the hardware configuration can prevent that (in case of laptops for instance), and other times the code is not stable enough to write the flash chip (for some GPUs and/or network cards).

Since we can read/write flash chip, we can also erase the data on them too.

Website: https://www.flashrom.org/

Linux + flashrom or mtd-utils

Linux can also read various flash chips. For instance you might be able to use a single board computer that runs GNU/Linux and connect a flash chip to it, modify the device tree to take it into account, and use the Linux driver along with mtd-utils or flashrom with the linux_mtd driver to read/write it.

Another option would be to only enable the SPI bus that has the flash chip in the device tree and use then use flashrom to read/write it through flashrom's linux_spi driver.

Since we can read/write flash chip, we can also erase the data on them too.

GPUs

Games

Various free software 3D games can be used to test GPUs.

Some games need a big quantity of RAM to run (Xonotic and supertuxkart probably require 2GiB of RAM or more for instance).

Many old computers cannot have that much RAM (due to chipset limitations). Even some modern computers have soldered RAM, so in that case RAM can't easily be increased either.

For cases like that, extreme Tux racer uses 3D acceleration and don't require a big quantity of RAM, so it could be used to test GPUs on such computers. It is available in several FSDG compliant distributions like Parabola and Guix.

Phoronix test suite

Phoronix test suite can also be used to test GPUs. Note that by default many tests are nonfree.

Both Guix and Parabola's phoronix-test-suite have free tests.

The Guix version is probably more advanced as Parabola's version is old and lack games (it's limited to compilation tests), at least until volunteers fix that in Parabola.

Flashrom and sgabios

Some broken GPUs can probably be repurposed with flashrom and sgabios.

Sgabios can be used to redirect the output of the computer in the BIOS on a serial port. This could be useful to people with visual deficiencies or for people administrating servers.

Reprogramming the flash chip of modern GPUs might need to be done with flashrom and an external programmer (because flashrom doesn't have support for recent ATI or AMD GPUs).

HDDs and SSDs

With storage devices like HDDs and SSDs there is often a wide variety of action done with them:

  • Organization that repair computers often also do data recovery. So it is interesting to recover data.
  • Organization that refurbish hardware often erase the data before refurbishing the hardware.
  • There are tools to see if HDDs and SSDs are breaking (due to age, or other issues).

cryptsetup

According to the cryptsetup FAQ, in the "2.19 How can I wipe a device with crypto-grade randomness?" section, it is possible to erase a disk with cryptsetup. It is also very fast compared to other methods like wipe or ddrescue -f /dev/zero /dev/sdZ.

ddrescue

GNU ddrescue can be used to rescue data from an SSD or hard disk that will soon break. It's obtimized for rescuing as much data as possible before the device break.

There are also associated graphical and command line tools to handle partial dumps, or to combine several dumps.

GNU ddrescue can also be used to rescue CD or DVDs that contain errors. In that case, the sector size might need to be changed to 2048 (ddrescue -b 2048 [...]). It is also a good idea to either combine several images made with different CD/DVD readers or to try to continue rescuing a given CD/DVD with different readers to capture as much data as possible.

ddrescue can also be used to wipe the data on a storage device. For instance:

ddrescue /dev/urandom /dev/sdZ

would erase all the data on /dev/sdZ

ext4magic and extundelete

In some cases ext4magic or extundelete are able to recover deleted files with their full paths. It doesn't always work though.

dmraid

Sometimes people use hard disk controller cards (also known as fake raid cards) to configure their hard disks as RAID.

These cards usually have a flash chip with a nonfree program inside that is then executed by the BIOS/UEFI. That software can then be used to configure the cards to combine several disks as a single raid device.

When users do that, the cards add additional data on the disks to combine them together. Usually that also requires additional drivers for the card in order for the OS to take that into account.

When the card break, users are usually unable to reconstruct the array.

Though the dmraid program has support for the format used by several fake RAID cards (like the Adaptec HostRAID ASR, Highpoint HPT37X, Highpoint HPT45X, etc).

So with dmraid we can recover data from these fake raid arrays.

Flashrom

Flashrom can also be used to dump and restore some HDDs and SSDs firmwares as the flash chips holding the firmwares are often easily accessible on the hard disk PCB.

Gnome disks

Gnome disks can test HDDs and SSDs to see if they are broken or not.

Gnome disks can also make images of what is on a given HDDs/SSD usb key, etc. It probably requires the HDDs/SSD usb key to work fine to do that. If the HDD/SSD is breaking, using ddrescue might be better.

Website: https://apps.gnome.org/en/app/org.gnome.DiskUtility/

NAND reader

There is hardware schematics and GPLv3(+?) software for a NAND reader that available here: https://spritesmods.com/?art=ftdinand

That might be useful to recover data from an SSD (SSDs use NAND).

There will probably be data used by the SSD firmware as well on the NAND, like checksums for the data being written, bad block information, or block usage information, etc.

So we would probbaly need to reverse engineer to recover the data.

photorec and testdisk

The testdisk program can recreate disk partitions that have been erased.

It can also sometimes recover files that were deleted from:

  • FAT partitions,
  • NTFS partitions
  • ext2 partitions

with their filenames and paths.

The photorec program can recover data from disks by looking for pattern on the raw disk data. For instance jpeg files have a jpeg header, so even if all the partition data and metadata is destroyed somehow, photorec can still recover some files. Though it cannot recover file names or paths.

smartmontools

Smartmontools can test HDDs and SSD to see if they are broken or not.

Website: http://smartmontools.sourceforge.net

Modems

simtrace and simtrace2

Simtrace and Simtrace2 can trace the communication between a SIM card and a mode. Thanks to that it is possible to gain some information on what is going on, for instance:

  • If the screen is broken we might see some acvitivy through that
  • It might be useful to debug a SIM card reported as not found: if there is some traffic, the modem sees the SIM card

Osmocom GSM stack

It might be possible to use OpenBSC and so on to emulate a GSM network to see if a phone is working well, however the hardware to do that is probably expensive.

In addition it would require special cables between the phone and the GSM network to ensure that the GSM network doesn't emit ouside of the cable (to not require a (test) license).

network manager / modem manager / oFono etc

The various GNU/linux modem stacks can obviously be used to test some modems.

The test suites of these modem stacks or network test suites like Titan_TTCN3_Testsuites might be able to be repurposed to run automatic tests.

Printers

Reink

The reink support certain Epson printers.

On these printers there is no real cartridge level indicator. Instead the cartridge have a counter and that counter counts the number of impressions. So often there is some ink left. The issue is that once the counter reaches a threshold, the printer will refuse to print if we don't change the cartridge. So without resetting the counter, we can't refill the cartridges ourselves. This software enable to reset the counter to 0 on supported printers.

These printer also has a waste ink pad and in here there is also a counter (that is probably incremented at each time we print, and also when we ask the printer to cleanup it's print heads). The issue is that when this counter reaches a threshold, the printer asks us to contact the vendor and the price of repair is probably higher than a new printer, assuming it's still available for old printers. A solution for this problem would be to order some new ink pads, change them ourselves or ask people to help us change them (in repair cafe, through friends, etc) and then use that software to reset the ink pad counters.

RAM

Memtest86+

Memtest86+ is an application that can be launched in GRUB and that can test the RAM.

For that to work the computer needs to be able to boot up to GRUB so if the RAM module under test is very broken, you might have more luck with two RAM modules: one good and the one under test.

Libreboot or Coreboot on Libreboot supported devices

Libreboot supports laptops with DDR2 (I945) and DDR3 (GM45).

It also supports some desktop computers.

If one hook up a serial port (on compatible computers, through the dock) it is possible to get some diagnostics even if the RAM isn't working at all.

They also has a fork of Memtest86+ that works over an UART.

Coreboot on Libreboot supported devices

On some of these computers the RAM initialization isn't free software so it might not give much information on what is going wrong. Note that Coreboot contains nonfree software. That is why Libreboot was made in the first place. Libreboot contains script to produce deblobed versions of Coreboot. Some vendors selling RYF certified hardware have also released deblobbed Coreboot as part of their RYF certification.

Novena + u-boot

The novena laptop also has slots for RAM modules and in u-boot, the RAM intialization code for that laptop is free software. Though u-boot itself might need to be deblobbed as some of its versions contain nonfree software (like nonfree firmwares and/or binaries under nonfree licenses).

Parabola has already some packages for some computers using an I.MX6 system on a chip, so it might be possible to ask Parabola developers to add support for the novena if you accept to test the resulting package.

wipe

The wipe program is available in Parabola and Replicant 6.0 and can erase data on specific partitions or storage devices (HDDs, SSDs, etc).

WiFi

Linux + hostapd or LibreCMC

For debugging WiFi issues, it can be useful to have a configurable WiFi access point.

This can be done with regular GNU/Linux distributions like Parabola, an ath9k compatible WiFi card, hostapd, and regular software to create networks (like dhcpd, netctl or ifconfig, etc).

This setup enable to have more detailed logs on what is going on and to tweak various parameters to debug things.

For instance networks without passwords or that don't handle WiFi power management can be created.

It might be more convenient and easier to do with LibreCMC and a supported device though as there is a nice web interface for configuring WiFi. Logs might be harder to get though. They may be available through the logread command or the web interface.

iwleeprom

iwleeprom can be used to workaround scandalous restrictions on computers that prevent users from changing the WiFi card.

The Mini PCIe slot restrictions on wireless cards article has more details on the issue and on iwleeprom.

Software for characterizing hardware

People dealing with refurbishing hardware often need to know what's inside the computer. There are many free software projects that can find hardware inside computers.

dmesg

The dmesg program can print Linux logs. So it can also be used to understand what hardware is in the computer as the kernel often gives a lot of information about that in its logs.

If Linux is configured to print new USB devices being connected in its logs, 'dmesg -w' can be used to see if new USB devices are connected.

dmidecode

Dmidecode can be used to get information on some of the hardware. For instance it can tell the amount of RAM and the number of RAM slots being used.

h-client

The h-client program can be useful to not only find what's in the computer, but it can even send information about what works and what doesn't (with 100% free software distributions) to h-node.

It can be installed in Guix, so it's even possible to make a special Guix image (to be installed on an USB key) or to make a Debian package (with guix) to install it on top of 100% free software distributions.

Note that h-node only accepts information if the computer is being tested on 100% free distributions (that includes all FSDG compliant distributions, obviously with no additional nonfree software, and Debian with only the main repository and no additional nonfree software)

Inventory software

There is several free software inventory programs (like OCS Inventory for instance). Some are pretty well adapted to large organizations.

Something to look for would be to understand the level of details needed and see if it fit well what organization that refurbish hardware need.

lshw

The lshw program can not only list what hardware is in the computer it's running on, but it can also output that information in a wide variety of format, like for instance json or even in an sqlite database.

That makes it easy to reuse that data in a more global system that tracks what hardware there is in the organization that refurbish hardware.

lspci

lspci can be handy to see basic information about PCI devices, for instance to see if a PCI card is detected or what GPU is being used.

lsusb

The lsusb command can be used to list the USB devices inside the computer.

That can also be very useful to see if the computer sees a given USB device (like a smartphone, an USB key, etc). If the computer doesn't see the device being plugged, the device could be completely broken for instance, or the USB port of that computer could be broken too.

memtest86+

Memtest86+ prints the detected RAM quantity, number of slots, and various information on the RAM modules.

Linux and /sys/class/dmi/id/

/sys/class/dmi/id/ has various information on the computer, like the model, BIOS version, serial number, etc.

Software for automatizing installations

Often refurbishing organizations need to install GNU/Linux distributions on existing computers to refurbish it. Special software can often help to do that.

Distribution specific software

Often it's possible to automatize installations of GNU/Linux. For instance Trisquel can be installed with Trisquel's fai (fully automated installer) or through Trisquel's debian-installer. Trisquel has also an OEM installation mode where it is installed but the users can then customize the username, and various settings during the first boot. Guix works completely differently for instance. Since these programs are distribution specific, it might be best to consult distribution specific information to learn about them.

However note that completely automatized installations that are customized tend to work well when the computer is known in advance or for fleets of similar computers. If the computer needs hardware specific tweaks to work well, tweaks are harder to automatize.

ipxe

Ipxe can be used to boot computers from the network.

Software for general purpose debug and repair tools

People doing hardware repairs often use debug tools like osciloscopes, power supplies, etc.

Free software to implement these tools or interact with them tools also exist.

That can be really handy in repairs.

Sigrok

Sigrok can interface with a wide variety of hardware like:

  • Digital analyzers
  • Multimeters
  • Osciloscopes
  • Power supplies
  • etc

So it can be super useful for debugging hardware issues.