<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

Fab4 Kernel Unit Tests

From SqueezeboxWiki

Revision as of 08:45, 23 June 2010 by Soulkeeper (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Introduction

This document describes the device driver interfaces and tests for fab4. It is intended to be used for kernel development, hardware validation and development of factory tests.

Most of the tests can be performed from the command prompt over the serial port. Before you run some of the tests it will be necessary to kill the jive application.

CPU

No specific tests have been implemented for the CPU.

DDR2

TODO: write about DDR2 memory via jtag and peedi.

NAND Flash

The NAND flash driver is from the Freescale i.MX35 BSP.

Linux stores a bad block table at the end of the flash chip. If this bad block table is missing a scan is performed during boot and the table created.

The flash partitions on Fab4 are (128MB parts):

Partition	Erase Blocks	Start Block	Start Address	Length
redboot        4               0               0x00000000      0x00080000
ubi            1014            4               0x00080000      0x07EC0000
redboot config 1               1018            0x07F40000      0x00020000
FIS directory  1               1019            0x07F60000      0x00020000
Linux BBT      4               1020            0x07F80000      0x00080000
End                            1024            0x08000000

Note: ubi is used to store the kernel and filesystem in virtual partitions. Note: FIS directory is not used in production systems, but it can be useful on development systems.

Note: redboot partition is smaller for PA2

Unit Tests

There are NAND flash tests available from git://git.infradead.org/~ahunter/nand-tests.git. The tests need cross compiling:

export KERNEL_PATH=/home/richard/imx35/linux-2.6.24
make ARCH=arm CROSS_COMPILE=arm-poky-linux-gnueabi-

To run the tests first boot the target using an nfs mounted filesystem, with the test kernel modules available. Then run:

insmod oobtest.ko dev=1
insmod pagetest.ko dev=1
insmod scantest.ko dev=1
insmod speedtest.ko dev=1
insmod stresstest.ko dev=1 count=8096
insmod subpagetest.ko dev=1
insmod torture.ko dev=1 cycles_count=1000

Note: the following warning for the torture test "This program may kill your device"! May be best to only run this test with socketed flash :). By default this modules will torture the flash until it goes bad.

These tests were run on 24 September 2006. All the tests pass, apart from the OOB test. This needs further investigation.

The speed reports (running with jtag):

eraseblock write speed is 1094 KiB/s
eraseblock read speed is 3399 KiB/s
page write speed is 966 KiB/s
page read speed is 3123 KiB/s
2 page write speed is 1026 KiB/s
2 page read speed is 3260 KiB/s
erase speed is 8575 KiB/s

Note: the following warning for the torture test "This program may kill your device"! May be best to only run this test with socketed flash :)

The speed reports (running with jtag):

eraseblock write speed is 1094 KiB/s
eraseblock read speed is 3399 KiB/s
page write speed is 966 KiB/s
page read speed is 3123 KiB/s
2 page write speed is 1026 KiB/s
2 page read speed is 3260 KiB/s
erase speed is 8575 KiB/s

Factory Tests

The factory tests should parse the kernel log and make sure the flash is correctly detected, and that the number of bad blocks are within acceptable limits.

Kernel Log

Detecting the NAND flash:

NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)

Scanning for bad blocks:

Bad block table not found for chip 0
Scanning device for bad blocks

Reporting bad blocks:

XXX

UBI/UBIFS

The UBI block device is used to store the kernel, root filesystem and overlay filesystem in virtual partitions. It provides support for bad block management and wear levelling. The UBI device by default is be mounted during boot (ubi.mtd=1 on the kernel command line). Information about the device and it's partitions can be found using 'ubinfo -a'. This includes information about the flash bad blocks, etc:

# ubinfo -a
UBI version:                    1
Count of UBI devices:           1
UBI control device major/minor: 10:63
Present UBI devices:            ubi0

ubi0:
Volumes count:                           3
Logical eraseblock size:                 129024
Total amount of logical eraseblocks:     1015 (130959360 bytes, 124.9 MiB)
Amount of available logical eraseblocks: 739 (95348736 bytes, 90.9 MiB)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       1
Count of reserved physical eraseblocks:  10
Current maximum erase counter value:     2
Minimum input/output unit size:          2048 bytes
Character device major/minor:            252:0
Present volumes:                         0, 1, 2

Volume ID:   0 (on ubi0)
Type:        static
Alignment:   1
Size:        17 LEBs (2193408 bytes, 2.1 MiB)
Data bytes:  1841968 bytes (1.8 MiB)
State:       OK
Name:        kernel
Character device major/minor: 252:1
-----------------------------------
Volume ID:   1 (on ubi0)
Type:        static
Alignment:   1
Size:        163 LEBs (21030912 bytes, 20.1 MiB)
Data bytes:  6668288 bytes (6.4 MiB)
State:       OK
Name:        cramfs
Character device major/minor: 252:2
-----------------------------------
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        82 LEBs (10579968 bytes, 10.1 MiB)
State:       OK
Name:        ubifs
Character device major/minor: 252:3

Unit Tests

The mtd-utils fs-tests can be run on the ubifs filesystem. The tests need to be cross-compiled and the filesystem under test mounted. The following commands can be used to run the tests on the target:

# export TEST_FILE_SYSTEM_MOUNT_DIR=/mnt
# export TEST_FILE_SYSTEM_TYPE=ubifs
# cd fs-tests
# ./run_all.sh

Most of these tests were run on 24 September 2008. The stress_3 test failed (the filesystem being tested was not big enough for this test). stress00.sh and stress01.sh were not run at this time.

Factory Tests

The factory tests should confirm that the UBI block device and UBIFS filesystem are mounted without errors by inspecting the kernel logs and ubinfo.

Kernel Log

Failure: corrupt UBI filesystem:

UBI warning: init_volumes: static volume 0 misses 78 LEBs - corrupted

Serial Console

Serial console access is available in both RedBoot and the Linux kernel using the debug board on PA2. The settings needed are baud rate: 115200, data: 8-bit, parity: none, stop: 1 bit, flow control: none.

FEC

TODO: write about Ethernet tests

LCD

TODO: write about LCD tests.

LCD Backlight

The LCD backlight driver is provided in the Freescale BSP.

Unit Tests

The backlight level can be changed by modifying a file in /sys:

# cat /sys/class/backlight/mxc_ipu_bl.0/brightness
127
# echo "0" > /sys/class/backlight/mxc_ipu_bl.0/brightness
# echo "255" > /sys/class/backlight/mxc_ipu_bl.0/brightness
# echo "127" > /sys/class/backlight/mxc_ipu_bl.0/brightness

Factory Test

A visual check should be made to make sure the LCD backlight is working.

Clearpad

The clearpad kernel driver was developed in house. It reports absolute position and flick gestures using the Linux input subsystem. A future extension may support ChiralMotion for scrolling.

The following input events are reported by the driver (these are subject to change):

ABS_X, ABS_Y X,Y finger position
ABS_MISC number of fingers
ABS_PRESSURE finger pressure
ABS_TOOL_WIDTH finger width
REL_X, REL_Y flick gesture

The Clearpad support other gesture recognition (for press, tap, tap and hold and double tap). These are not currently implemented in the driver.

Unit Tests

The evtest program can be used to verify the driver:

# ./evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "Synaptics ClearPad"
Supported events:
  Event type 0 (Sync)
  Event type 2 (Relative)
    Event code 0 (X)
    Event code 1 (Y)
  Event type 3 (Absolute)
    Event code 0 (X)
      Value   4146
      Min        0
      Max     7552
    Event code 1 (Y)
      Value   3642
      Min        0
      Max     4248
    Event code 24 (Pressure)
      Value     26
      Min        0
      Max      255
    Event code 28 (Tool Width)
      Value      4
      Min        0
      Max       15
    Event code 40 (Misc)
      Value      0
      Min        0
      Max        3
Testing ... (interrupt to exit)
Event: time 6972.673141, type 3 (Absolute), code 40 (Misc), value 1
Event: time 6972.673157, type 3 (Absolute), code 0 (X), value 4870
Event: time 6972.673163, type 3 (Absolute), code 1 (Y), value 2747
Event: time 6972.673169, type 3 (Absolute), code 24 (Pressure), value 32
Event: time 6972.673174, type 3 (Absolute), code 28 (Tool Width), value 2
Event: time 6972.673179, -------------- Report Sync ------------
Event: time 6972.684797, type 3 (Absolute), code 0 (X), value 4877
Event: time 6972.684808, type 3 (Absolute), code 1 (Y), value 2729
Event: time 6972.684814, type 3 (Absolute), code 24 (Pressure), value 37
Event: time 6972.684819, type 3 (Absolute), code 28 (Tool Width), value 1
Event: time 6972.684824, -------------- Report Sync ------------
Event: time 6972.696289, type 3 (Absolute), code 0 (X), value 4884
Event: time 6972.696300, type 3 (Absolute), code 1 (Y), value 2700
Event: time 6972.696306, type 3 (Absolute), code 24 (Pressure), value 38
Event: time 6972.696313, -------------- Report Sync ------------
Event: time 6972.708552, type 3 (Absolute), code 0 (X), value 4892
Event: time 6972.708565, type 3 (Absolute), code 1 (Y), value 2665
Event: time 6972.708576, -------------- Report Sync ------------ 
Event: time 6972.719257, type 3 (Absolute), code 0 (X), value 4896
Event: time 6972.719269, type 3 (Absolute), code 1 (Y), value 2627
Event: time 6972.719277, type 3 (Absolute), code 28 (Tool Width), value 2
Event: time 6972.719283, -------------- Report Sync ------------
Event: time 6972.730611, type 3 (Absolute), code 0 (X), value 4904
Event: time 6972.730622, type 3 (Absolute), code 1 (Y), value 2593
Event: time 6972.730627, type 3 (Absolute), code 24 (Pressure), value 42
Event: time 6972.730633, type 3 (Absolute), code 28 (Tool Width), value 1
Event: time 6972.730638, -------------- Report Sync ------------

Factory Tests

The kernel log should be check to make sure the clearpad is detected. A squeezeplay applet will be written to allow a manual test of the clearpad functions.

Kernel Log

The touchpad is detected during boot:

Clearpad: TM1199Logitech (7552,4248)
input: Synaptics ClearPad as /class/input/input0

Audio Tests

Fab4 includes several audio drivers:

  1. AK4420 a 24-bit high performance stereo DAC.
  2. SPDIF digital output.
  3. WM8974 codec with internal speaker and microphone.
  4. optionally USB audio (for example Alberti Z5 speakers).

Unit Test

Aliases for the different drivers are defined in /etc/asound.conf. You can use:

hw:0,0 # direct access to card 0
hw:1,0 # direct access to card 1
digial # direct access to spdif/tosl digital outputs
ak4420 # direct access to ak4420 analogue outputs
plughifi # access (via plug converter) to digtial output and ak4420 outputs

To play a test .wav file on both the digital output and ak4420 use:

aplay -D plughifi test.wav

For example to play a test .wav only on the ak4420 use (note this direct access does not support sample format/rate conversion):

aplay -D ak4420 test.wav


The Headphone detect and DAC mute for the AK4420 can be tested using the GPIO tests below.

Kernel Log

Displayed when the sound drivers are initialized (note this does not necessarily mean that the hardware has been detected):

ALSA device list:
  #0: MXC Freescale with SPDIF
  #1: fab4 (ak4420)

Factory Test

The factory tests should use aplay to verify all the outputs work correctly.

TMP100 (temp sensor)

The tmp100 sensor driver is from the linux hardware monitor subsystem.

Note this is not supported on the first build of PA2 as the component was SMT incorrectly.

Unit Test

The temperature can be read via the /sys filesystem:

# cat /sys/devices/platform/i2c-adapter\:i2c-0/0-0048/temp1_input
29000

Kernel Log

Displayed when the temperature sensor is detected:

lm75 0-0048: hwmon0: sensor 

TSL2569 (ambient light sensor)

The TSL2569 kernel driver was developed by Logitech. It reports the ambient light.

Unit Test

The raw adc values are displayed via the /sys filesystem:

# cat /sys/bus/i2c/devices/0-0039/adc
14018,7288
# cat /sys/bus/i2c/devices/0-0039/adc
1767,1138

The calculated lux value is displayed via the /sys filesystem (note this is a place holder and the lux is not yet calculated):

# cat /sys/bus/i2c/devices/0-0039/lux
0

Kernel Log

Displayed when the ambient light sensor is detected:

tsl2569 0-0039: support ver. 1.0 enabled

WLAN

TODO: when the WLAN works.

SD Card

The SD Card driver is provided in the Freescale BSP. The card detect and write protect gpio's have been customized for the fab4 board.

Unit Test

To mount a SD card:

# mount -t vfat -o sync -o noatime /dev/mmcblk0p1 /mnt/mmc
# umount /mnt/mmc/

To mount a read-only SD card, note the write-protected message should appear:

# mount -t vfat -o sync -o noatime /dev/mmcblk0p1 /mnt/mmc
mount: /dev/mmcblk0p1 is write-protected, mounting read-only
# umount /mnt/mmc/

Factory Test

The factory tests should verify that the SD card is mounted. The SD card is mounted automatically at boot, and you can check using 'mount' and parsing for /mnt/mmc in the output.

USB Host

USB_HOST_EN (GPIO)

USB_HOST_OC (GPIO)

Reset button (GPIO)

Pressing the reset button will reset the board and boot into RedBoot.

IR

The IR is processed by a micro controller and signals are sent to the CPU using I2C.

Unit Test

You can test the IR input using evtest:

# evtest /dev/input/event1&
Input driver version is 1.0.0
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "FAB4 IR"
Supported events:
  Event type 0 (Sync)
  Event type 4 (Misc)
    Event code 3 (RawData)
Testing ... (interrupt to exit)
Event: time 2826290.867939, type 4 (Misc), code 3 (RawData), value 7689e01f
Event: time 2826290.867954, -------------- Report Sync ------------
Event: time 2826290.989109, type 4 (Misc), code 3 (RawData), value 7689e01f
Event: time 2826290.989125, -------------- Report Sync ------------
Event: time 2826291.493399, type 4 (Misc), code 3 (RawData), value 7689b04f
Event: time 2826291.493414, -------------- Report Sync ------------

Factory Test

When the micro controller is upgrade the following messages will be in the kernel boot log (the checksum values will differ depending on the version of the micro controller firmware):

FAB4 IR: programming fw (checksum was 0)
... some seconds later ...
FAB4 IR: fw programming ok (checksum 90eb)

If the micro controller firmware is up to date the following message will appear:

FAB4 IR: fw checksum ok 90eb

Watchdog

The MX35 has a built in watchdog timer.

Unit Test

To test the watchdog run:

# watchdog -t 10 /dev/watchdog
# killall -9 watchdog
mxc_wdt: Unexpected close, not stopping!

After 10 seconds the system should reboot.

Factory Test

The watchdog does not require a factory test.

System Clock

Unit Test

To check the system clock is running at the correct speed:

# date; sleep 10; date
Thu Jan  1 02:57:19 UTC 1970
Thu Jan  1 02:57:29 UTC 1970

The command should take 10 seconds to run and the date stamps should be 10 seconds apart.

Factory Test

The system clock does not require a factory test.

GPIO

A driver has been written to allow unit testing of the gpios. To read the current state of a gpio:

# cat /sys/devices/platform/fab4_gpio.0/LCD_DISP
name:   LCD_DISP
datain: 1
gdir:   output
dr:     1
psr:    0
input:  5

To set the state of a gpio:

# echo "0" > /sys/devices/platform/fab4_gpio.0/LCD_DISP
# echo "1" > /sys/devices/platform/fab4_gpio.0/LCD_DISP

Unit Test

The following gpio's have been tested on PA2:

FAIL_SAFE# [tested by stopping the boatloader]
LCD_DISP
I2C_ATTN1#
I2C_ATTN2#
SD_CD#
SD_WP#
DAC1_SMUTE
HDP_EN
WIFI_PD#
WIFI_RESET#
OSC_SEL1
OSC_SEL2
USB_HOST_OC# [linux is reporting correctly over-current when USB power supply is shorted]

The following gpio's need testing:

HDP_DET [BUG on PA2: missing pull-up]
IR_LED
IR_SENSOR#
USB_HOST_EN#

Note in a future firmware update when FAIL_SAFE# is asserted the bootloader will stop booting, so this gpio won't be testable in the kernel.

Firmware Upgrades

See http://embargo.wiki.slimdevices.com/index.php/Fab4_Firmware_Upgrades_and_Recovery