Testing Hardware

From postmarketOS

This page described how to test hardware components of your device (for example if you're mainlining or there's a kernel or firmware change). Previously these topics were hidden across MR instructions and other Wiki pages, so collecting them here to simplify things.

Note Many of the commands suggested here require sudo, so switching to the root user can simplify testing if you're doing a lot of it (sudo su)

All-in-one test

Use hwtest to get an overview of the different sensors, input and output devices detected:

  1. Install hwtestPMOS
  2. run hwtest

Example output from asus-grouper on mainline kernel:

$ hwtest
Category         Model                Path                                    Status     Value
framebuffer      tegradrmfb           /sys/class/graphics/fb0                 working    U:800x1280p-0
drm              -                    /sys/class/drm/card0-LVDS-1             working    800x1280
magnetometer     ami306               /sys/bus/iio/devices/iio:device2        working    0.39, -1.14, -1.64 gauss
accelerometer    mpu6050              /sys/bus/iio/devices/iio:device0        working    0.18, 0.16, -10.11 g
gyroscope        mpu6050              /sys/bus/iio/devices/iio:device0        working    -0.05, -0.02, 0.01 rad/s
temperature      mpu6050              /sys/bus/iio/devices/iio:device0        working    17.3 deg C
illuminance      al3010               /sys/bus/iio/devices/iio:device1        working    0 lux
input            gpio-keys            /dev/input/event0                       working    
input            Elan Touchscreen     /dev/input/event1                       working    
input            ASUS Google Nexus 7 ALC5642 Headphones Jack /dev/input/event2                       working    
speaker          default:CARD=ALC5642                                         working    
mic              sysdefault:CARD=ALC5642                                         working    
speaker          sysdefault:CARD=ALC5642                                         working    
mic              default:CARD=ALC5642                                         working    


Accelerometer

Accelerometers should show up as one of the entries in /sys/bus/iio/devices/. The in_*_raw files can be read from directly to see the raw sensor readings.

Since accelerometers are usually used for orienting the UI, you should also check that the device orientation is correct (see File:PhoneRotation.png for terminology):

  1. Install iio-sensor-proxy
  2. Restart the device
  3. Start the service: rc-service iio-sensor-proxy start
  4. Read orientation (see other command line options for raw values as well) using monitor-sensor

Buttons

Use evtest.

Vibrator

  1. Find the vibrator device with evtest
  2. Install linuxconsoletools
  3. Run e.g. fftest /dev/input/event2

Normally effects "#0 (Periodic sinusoidal)", "#4 (Strong rumble, with heavy motor)" and "#5 (Weak rumble, with light motor)" should be available. They may produce different vibration strengths, or may not.

Alternatively also fbcli -E phone-incoming-call should vibrate the device.

SD card

Check if the SD card shows up via lsblk. Check if dmesg outputs anything when inserting or removing the card.

Random number generator

Adapted from Brian Masney's description.

  1. Install libkcapi-tools
  2. Gather some random data: kcapi-rng -b 9000000 > OUTFILE
  3. Build verification tool: git clone https://github.com/Fourmilab/ent_random_sequence_tester && make -C ent_random_sequence_tester/src/
  4. Verify data is actually random: ./ent_random_sequence_tester/src/ent -c OUTFILE

It should say something like "Chi square distribution for 9000000 samples is 251.61, and randomly would exceed this value 54.83 percent of the times.". If it would say something like "and randomly would exceed this value less than 0.01 percent of the times." then something's quite wrong with the random number generator.

Linux Kernel Crypto API

  1. Install libkcapi-tools
  2. Run kcapi-speed --all

This seems to try all of the registered crypto ciphers, a part of the output may look like the following:

HMAC SHA-1 DRBG NOPR    |d|      20 bytes|               16.12 MB/s|845280 ops/s
HMAC SHA-256 DRBG NOPR  |d|      32 bytes|               24.44 MB/s|800352 ops/s
HMAC SHA-384 DRBG NOPR  |d|      48 bytes|               11.26 MB/s|245754 ops/s
HMAC SHA-512 DRBG NOPR  |d|      64 bytes|                15.1 MB/s|245930 ops/s

Hardware video acceleration

See Hardware_video_acceleration#Testing.