Das U-Boot Power On Self Tests (POST)

http://docs.blackfin.uclinux.org/doku.php?id=bootloaders:u-boot:post


Starting with the 2011R1 release, Das U-Boot has built-in support for POSTs. There are many standard tests already included, and support for adding arbitrary board-specific tests.

Currently, the POSTs are executed after U-Boot has relocated to external memory and otherwise is up and running. There is no support yet for executing POSTs out of flash in the Blackfin port.

CONFIG

There are two important defines to be familiar with for all POST code:

#define CONFIG_POST (CONFIG_SYS_POST_xxx|CONFIG_SYS_POST_yyy|...)
#define CONFIG_CMD_DIAG

The first define (CONFIG_POST) is a bit field of which tests to enable. You can see the list of available tests in the include/post.h header file. The BSPEC tests are reserved for board specific tests.

file: include/post.h

/* line 174 to 199 */
#define CONFIG_SYS_POST_RTC		0x00000001
#define CONFIG_SYS_POST_WATCHDOG	0x00000002
#define CONFIG_SYS_POST_MEMORY		0x00000004
#define CONFIG_SYS_POST_CPU		0x00000008
#define CONFIG_SYS_POST_I2C		0x00000010
#define CONFIG_SYS_POST_CACHE		0x00000020
#define CONFIG_SYS_POST_UART		0x00000040
#define CONFIG_SYS_POST_ETHER		0x00000080
#define CONFIG_SYS_POST_SPI		0x00000100
#define CONFIG_SYS_POST_USB		0x00000200
#define CONFIG_SYS_POST_SPR		0x00000400
#define CONFIG_SYS_POST_SYSMON		0x00000800
#define CONFIG_SYS_POST_DSP		0x00001000
#define CONFIG_SYS_POST_OCM		0x00002000
#define CONFIG_SYS_POST_FPU		0x00004000
#define CONFIG_SYS_POST_ECC		0x00008000
#define CONFIG_SYS_POST_BSPEC1		0x00010000
#define CONFIG_SYS_POST_BSPEC2		0x00020000
#define CONFIG_SYS_POST_BSPEC3		0x00040000
#define CONFIG_SYS_POST_BSPEC4		0x00080000
#define CONFIG_SYS_POST_BSPEC5		0x00100000
#define CONFIG_SYS_POST_CODEC		0x00200000
#define CONFIG_SYS_POST_COPROC		0x00400000
#define CONFIG_SYS_POST_FLASH		0x00800000
#define CONFIG_SYS_POST_MEM_REGIONS	0x01000000

  
  
  
  

The second define (CONFIG_CMD_DIAG) enables the diag command at runtime so you can execute specific tests on the fly.

POST BUTTON

You can optionally execute POST when booting up. This is also the only way to execute some tests (like memory).

You can either define the int post_hotkeys_pressed(void) function in your own board code (return 1 if the button is pushed, or 0 otherwise).

If you have a button connected to a GPIO line to signal things, you can use the common implementation. Simply define CONFIG_SYS_POST_HOTKEYS_GPIO to theGPIO you wish to use.

file: include/configs/bf537-stamp.h

/* line 258 to 259 */
#define CONFIG_SYS_POST_HOTKEYS_GPIO	GPIO_PF5

SPECIAL TEST

  
  
  
  

All Blackfin boards have BSPEC1 and BSPEC2 reserved for LED and button tests respectively.

Flash

The flash test requires you to declare the range of sectors that you wish to have tested.

file: include/configs/bf537-stamp.h

/* line 265 to 267 */
#define CONFIG_SYS_POST_FLASH_START	11
#define CONFIG_SYS_POST_FLASH_END	71
If your board has more than one flash part, then define CONFIG_SYS_POST_FLASH_NUM to the one you wish to test.
GPIO leds

Define CONFIG_POST_BSPEC1_GPIO_LEDS to a list of GPIOs which are connected to LEDs:

file: include/configs/bf537-stamp.h

/* line 259 to 261 */
#define CONFIG_POST_BSPEC1_GPIO_LEDS \
	GPIO_PF6, GPIO_PF7, GPIO_PF8, GPIO_PF9, GPIO_PF10, GPIO_PF11,

GPIO buttons

Define CONFIG_POST_BSPEC2_GPIO_BUTTONS to a list of GPIOs which are connected to buttons, and CONFIG_POST_BSPEC2_GPIO_NAMES to a list of their names:

file: include/configs/bf537-stamp.h

/* line 261 to 265 */
#define CONFIG_POST_BSPEC2_GPIO_BUTTONS \
	GPIO_PF5, GPIO_PF4, GPIO_PF3, GPIO_PF2,
#define CONFIG_POST_BSPEC2_GPIO_NAMES \
	10, 11, 12, 13,
RUNTIME
POST BUTTON

Note that the hotkey check does not wait for you to push the button. So you most likely will need to hold it down before the board powers on so that it has a chance to trigger.

Here is a helpful list for some ADI boards with known buttons:

Board Button
BF537-STAMP SW10
Dialog command

At runtime, you can execute some tests with the diag command.

To see which tests are available:

bfin> diag

To see more info about specific tests:

bfin> diag rtc flash …

To execute all tests:

bfin> diag run

To execute specific tests:

bfin> diag run rtc flash …

Board specia test

You can use BSPEC3BSPEC4, and BSPEC5 for board specific tests. You will need to do a few things:

  • add the respective  CONFIG_SYS_POST_BSPEC# to your  CONFIG_POST
  • define  CONFIG_POST_BSPEC# in your board config
  • add a prototype for the callback function to  post/tests.c
  • define the callback function in your boards directory ( boards/<boardname>/)

You can see an example of CONFIG_POST_BSPEC# in the Blackfin code:

file: arch/blackfin/include/asm/config.h

/* line 175 to 181 */
# define CONFIG_POST_BSPEC2 \
	{ \
		"Button test", "button", "This test verifies buttons on the board.", \
		POST_MEM | POST_ALWAYS, &button_post_test, NULL, NULL, \
		CONFIG_SYS_POST_BSPEC2, \
	}

The implementation of this test:

file: arch/blackfin/lib/post.c

/* line 42 to 84 */
#if CONFIG_POST & CONFIG_SYS_POST_BSPEC2
int button_post_test(int flags)
{
	unsigned buttons[] = { CONFIG_POST_BSPEC2_GPIO_BUTTONS };
	unsigned int sws[] = { CONFIG_POST_BSPEC2_GPIO_NAMES };
	int i, delay = 5;
	unsigned short value = 0;
	int result = 0;
 
	for (i = 0; i < ARRAY_SIZE(buttons); ++i) {
		if (gpio_request(buttons[i], "post")) {
			printf("could not request gpio %u\n", buttons[i]);
			continue;
		}
		gpio_direction_input(buttons[i]);
 
		delay = 5;
		printf("\n--------Press SW%i: %2d ", sws[i], delay);
		while (delay--) {
			int j;
			for (j = 0; j < 100; j++) {
				value = gpio_get_value(buttons[i]);
				if (value != 0)
					break;
				udelay(10000);
			}
			printf("\b\b\b%2d ", delay);
		}
		if (value != 0)
			puts("\b\bOK");
		else {
			result = -1;
			puts("\b\bfailed");
		}
 
		gpio_free(buttons[i]);
	}
 
	puts("\n");
 
	return result;
}


你可能感兴趣的:(Das U-Boot Power On Self Tests (POST))