143d9616cSwdenkPower-On-Self-Test support in U-Boot 243d9616cSwdenk------------------------------------ 343d9616cSwdenk 443d9616cSwdenkThis project is to support Power-On-Self-Test (POST) in U-Boot. 543d9616cSwdenk 643d9616cSwdenk1. High-level requirements 743d9616cSwdenk 87152b1d0SwdenkThe key requirements for this project are as follows: 943d9616cSwdenk 1043d9616cSwdenk1) The project shall develop a flexible framework for implementing 1143d9616cSwdenk and running Power-On-Self-Test in U-Boot. This framework shall 1243d9616cSwdenk possess the following features: 1343d9616cSwdenk 1443d9616cSwdenk o) Extensibility 1543d9616cSwdenk 1643d9616cSwdenk The framework shall allow adding/removing/replacing POST tests. 1743d9616cSwdenk Also, standalone POST tests shall be supported. 1843d9616cSwdenk 1943d9616cSwdenk o) Configurability 2043d9616cSwdenk 2143d9616cSwdenk The framework shall allow run-time configuration of the lists 2243d9616cSwdenk of tests running on normal/power-fail booting. 2343d9616cSwdenk 2443d9616cSwdenk o) Controllability 2543d9616cSwdenk 2643d9616cSwdenk The framework shall support manual running of the POST tests. 2743d9616cSwdenk 2843d9616cSwdenk2) The results of tests shall be saved so that it will be possible to 2943d9616cSwdenk retrieve them from Linux. 3043d9616cSwdenk 3143d9616cSwdenk3) The following POST tests shall be developed for MPC823E-based 3243d9616cSwdenk boards: 3343d9616cSwdenk 3443d9616cSwdenk o) CPU test 3543d9616cSwdenk o) Cache test 3643d9616cSwdenk o) Memory test 3743d9616cSwdenk o) Ethernet test 3843d9616cSwdenk o) Serial channels test 3943d9616cSwdenk o) Watchdog timer test 4043d9616cSwdenk o) RTC test 4143d9616cSwdenk o) I2C test 4243d9616cSwdenk o) SPI test 4343d9616cSwdenk o) USB test 4443d9616cSwdenk 4543d9616cSwdenk4) The LWMON board shall be used for reference. 4643d9616cSwdenk 4743d9616cSwdenk2. Design 4843d9616cSwdenk 4943d9616cSwdenkThis section details the key points of the design for the project. 5043d9616cSwdenkThe whole project can be divided into two independent tasks: 5143d9616cSwdenkenhancing U-Boot/Linux to provide a common framework for running POST 5243d9616cSwdenktests and developing such tests for particular hardware. 5343d9616cSwdenk 5443d9616cSwdenk2.1. Hardware-independent POST layer 5543d9616cSwdenk 5643d9616cSwdenkA new optional module will be added to U-Boot, which will run POST 5743d9616cSwdenktests and collect their results at boot time. Also, U-Boot will 5843d9616cSwdenksupport running POST tests manually at any time by executing a 5943d9616cSwdenkspecial command from the system console. 6043d9616cSwdenk 6143d9616cSwdenkThe list of available POST tests will be configured at U-Boot build 6243d9616cSwdenktime. The POST layer will allow the developer to add any custom POST 6343d9616cSwdenktests. All POST tests will be divided into the following groups: 6443d9616cSwdenk 6543d9616cSwdenk 1) Tests running on power-on booting only 6643d9616cSwdenk 6743d9616cSwdenk This group will contain those tests that run only once on 6843d9616cSwdenk power-on reset (e.g. watchdog test) 6943d9616cSwdenk 7043d9616cSwdenk 2) Tests running on normal booting only 7143d9616cSwdenk 7243d9616cSwdenk This group will contain those tests that do not take much 7343d9616cSwdenk time and can be run on the regular basis (e.g. CPU test) 7443d9616cSwdenk 757152b1d0Swdenk 3) Tests running in special "slow test mode" only 7643d9616cSwdenk 7743d9616cSwdenk This group will contain POST tests that consume much time 78cb4dbb7bSwdenk and cannot be run regularly (e.g. strong memory test, I2C test) 7943d9616cSwdenk 8043d9616cSwdenk 4) Manually executed tests 8143d9616cSwdenk 8243d9616cSwdenk This group will contain those tests that can be run manually. 8343d9616cSwdenk 8443d9616cSwdenkIf necessary, some tests may belong to several groups simultaneously. 85cb4dbb7bSwdenkFor example, SDRAM test may run in both normal and "slow test" mode. 86cb4dbb7bSwdenkIn normal mode, SDRAM test may perform a fast superficial memory test 87cb4dbb7bSwdenkonly, while running in slow test mode it may perform a full memory 88cb4dbb7bSwdenkcheck-up. 8943d9616cSwdenk 9043d9616cSwdenkAlso, all tests will be discriminated by the moment they run at. 9143d9616cSwdenkSpecifically, the following groups will be singled out: 9243d9616cSwdenk 9343d9616cSwdenk 1) Tests running before relocating to RAM 9443d9616cSwdenk 957152b1d0Swdenk These tests will run immediately after initializing RAM 9643d9616cSwdenk as to enable modifying it without taking care of its 9743d9616cSwdenk contents. Basically, this group will contain memory tests 9843d9616cSwdenk only. 9943d9616cSwdenk 10043d9616cSwdenk 2) Tests running after relocating to RAM 10143d9616cSwdenk 10243d9616cSwdenk These tests will run immediately before entering the main 10343d9616cSwdenk loop as to guarantee full hardware initialization. 10443d9616cSwdenk 10543d9616cSwdenkThe POST layer will also distinguish a special group of tests that 10643d9616cSwdenkmay cause system rebooting (e.g. watchdog test). For such tests, the 10743d9616cSwdenklayer will automatically detect rebooting and will notify the test 10843d9616cSwdenkabout it. 10943d9616cSwdenk 11043d9616cSwdenk2.1.1. POST layer interfaces 11143d9616cSwdenk 11243d9616cSwdenkThis section details the interfaces between the POST layer and the 11343d9616cSwdenkrest of U-Boot. 11443d9616cSwdenk 11543d9616cSwdenkThe following flags will be defined: 11643d9616cSwdenk 117cb4dbb7bSwdenk#define POST_POWERON 0x01 /* test runs on power-on booting */ 118cb4dbb7bSwdenk#define POST_NORMAL 0x02 /* test runs on normal booting */ 119cb4dbb7bSwdenk#define POST_SLOWTEST 0x04 /* test is slow, enabled by key press */ 120cb4dbb7bSwdenk#define POST_POWERTEST 0x08 /* test runs after watchdog reset */ 121cb4dbb7bSwdenk#define POST_ROM 0x100 /* test runs in ROM */ 122cb4dbb7bSwdenk#define POST_RAM 0x200 /* test runs in RAM */ 123cb4dbb7bSwdenk#define POST_MANUAL 0x400 /* test can be executed manually */ 124cb4dbb7bSwdenk#define POST_REBOOT 0x800 /* test may cause rebooting */ 125cb4dbb7bSwdenk#define POST_PREREL 0x1000 /* test runs before relocation */ 12643d9616cSwdenk 12743d9616cSwdenkThe POST layer will export the following interface routines: 12843d9616cSwdenk 12943d9616cSwdenk o) int post_run(bd_t *bd, char *name, int flags); 13043d9616cSwdenk 13143d9616cSwdenk This routine will run the test (or the group of tests) specified 13243d9616cSwdenk by the name and flag arguments. More specifically, if the name 13343d9616cSwdenk argument is not NULL, the test with this name will be performed, 13443d9616cSwdenk otherwise all tests running in ROM/RAM (depending on the flag 13543d9616cSwdenk argument) will be executed. This routine will be called at least 13643d9616cSwdenk twice with name set to NULL, once from board_init_f() and once 13743d9616cSwdenk from board_init_r(). The flags argument will also specify the 13843d9616cSwdenk mode the test is executed in (power-on, normal, power-fail, 13943d9616cSwdenk manual). 14043d9616cSwdenk 14143d9616cSwdenk o) void post_reloc(ulong offset); 14243d9616cSwdenk 14343d9616cSwdenk This routine will be called from board_init_r() and will 14443d9616cSwdenk relocate the POST test table. 14543d9616cSwdenk 14643d9616cSwdenk o) int post_info(char *name); 14743d9616cSwdenk 14843d9616cSwdenk This routine will print the list of all POST tests that can be 14943d9616cSwdenk executed manually if name is NULL, and the description of a 15043d9616cSwdenk particular test if name is not NULL. 15143d9616cSwdenk 15243d9616cSwdenk o) int post_log(char *format, ...); 15343d9616cSwdenk 15443d9616cSwdenk This routine will be called from POST tests to log their 15543d9616cSwdenk results. Basically, this routine will print the results to 15643d9616cSwdenk stderr. The format of the arguments and the return value 15743d9616cSwdenk will be identical to the printf() routine. 15843d9616cSwdenk 15943d9616cSwdenkAlso, the following board-specific routines will be called from the 16043d9616cSwdenkU-Boot common code: 16143d9616cSwdenk 162cb4dbb7bSwdenk o) int post_hotkeys_pressed(gd_t *gd) 163cb4dbb7bSwdenk 164cb4dbb7bSwdenk This routine will scan the keyboard to detect if a magic key 165cb4dbb7bSwdenk combination has been pressed, or otherwise detect if the 166cb4dbb7bSwdenk power-on long-running tests shall be executed or not ("normal" 167cb4dbb7bSwdenk versus "slow" test mode). 168cb4dbb7bSwdenk 16943d9616cSwdenkThe list of available POST tests be kept in the post_tests array 17043d9616cSwdenkfilled at U-Boot build time. The format of entry in this array will 17143d9616cSwdenkbe as follows: 17243d9616cSwdenk 17343d9616cSwdenkstruct post_test { 17443d9616cSwdenk char *name; 17543d9616cSwdenk char *cmd; 17643d9616cSwdenk char *desc; 17743d9616cSwdenk int flags; 17843d9616cSwdenk int (*test)(bd_t *bd, int flags); 17943d9616cSwdenk}; 18043d9616cSwdenk 18143d9616cSwdenk o) name 18243d9616cSwdenk 18343d9616cSwdenk This field will contain a short name of the test, which will be 18443d9616cSwdenk used in logs and on listing POST tests (e.g. CPU test). 18543d9616cSwdenk 18643d9616cSwdenk o) cmd 18743d9616cSwdenk 18843d9616cSwdenk This field will keep a name for identifying the test on manual 18943d9616cSwdenk testing (e.g. cpu). For more information, refer to section 19043d9616cSwdenk "Command line interface". 19143d9616cSwdenk 19243d9616cSwdenk o) desc 19343d9616cSwdenk 19443d9616cSwdenk This field will contain a detailed description of the test, 19543d9616cSwdenk which will be printed on user request. For more information, see 19643d9616cSwdenk section "Command line interface". 19743d9616cSwdenk 19843d9616cSwdenk o) flags 19943d9616cSwdenk 20043d9616cSwdenk This field will contain a combination of the bit flags described 20143d9616cSwdenk above, which will specify the mode the test is running in 20243d9616cSwdenk (power-on, normal, power-fail or manual mode), the moment it 20343d9616cSwdenk should be run at (before or after relocating to RAM), whether it 20443d9616cSwdenk can cause system rebooting or not. 20543d9616cSwdenk 20643d9616cSwdenk o) test 20743d9616cSwdenk 20843d9616cSwdenk This field will contain a pointer to the routine that will 20943d9616cSwdenk perform the test, which will take 2 arguments. The first 21043d9616cSwdenk argument will be a pointer to the board info structure, while 21143d9616cSwdenk the second will be a combination of bit flags specifying the 21243d9616cSwdenk mode the test is running in (POST_POWERON, POST_NORMAL, 2138564acf9Swdenk POST_SLOWTEST, POST_MANUAL) and whether the last execution of 21443d9616cSwdenk the test caused system rebooting (POST_REBOOT). The routine will 21543d9616cSwdenk return 0 on successful execution of the test, and 1 if the test 21643d9616cSwdenk failed. 21743d9616cSwdenk 21843d9616cSwdenkThe lists of the POST tests that should be run at power-on/normal/ 21943d9616cSwdenkpower-fail booting will be kept in the environment. Namely, the 22043d9616cSwdenkfollowing environment variables will be used: post_poweron, 2218564acf9Swdenkpowet_normal, post_slowtest. 22243d9616cSwdenk 22343d9616cSwdenk2.1.2. Test results 22443d9616cSwdenk 22543d9616cSwdenkThe results of tests will be collected by the POST layer. The POST 22643d9616cSwdenklog will have the following format: 22743d9616cSwdenk 22843d9616cSwdenk... 22943d9616cSwdenk-------------------------------------------- 23043d9616cSwdenkSTART <name> 23143d9616cSwdenk<test-specific output> 23243d9616cSwdenk[PASSED|FAILED] 23343d9616cSwdenk-------------------------------------------- 23443d9616cSwdenk... 23543d9616cSwdenk 23643d9616cSwdenkBasically, the results of tests will be printed to stderr. This 23743d9616cSwdenkfeature may be enhanced in future to spool the log to a serial line, 23843d9616cSwdenksave it in non-volatile RAM (NVRAM), transfer it to a dedicated 23943d9616cSwdenkstorage server and etc. 24043d9616cSwdenk 24143d9616cSwdenk2.1.3. Integration issues 24243d9616cSwdenk 24343d9616cSwdenkAll POST-related code will be #ifdef'ed with the CONFIG_POST macro. 24443d9616cSwdenkThis macro will be defined in the config_<board>.h file for those 24543d9616cSwdenkboards that need POST. The CONFIG_POST macro will contain the list of 24643d9616cSwdenkPOST tests for the board. The macro will have the format of array 24743d9616cSwdenkcomposed of post_test structures: 24843d9616cSwdenk 24943d9616cSwdenk#define CONFIG_POST \ 25043d9616cSwdenk { 25143d9616cSwdenk "On-board peripherals test", "board", \ 25243d9616cSwdenk " This test performs full check-up of the " \ 25343d9616cSwdenk "on-board hardware.", \ 2548564acf9Swdenk POST_RAM | POST_SLOWTEST, \ 25543d9616cSwdenk &board_post_test \ 25643d9616cSwdenk } 25743d9616cSwdenk 25843d9616cSwdenkA new file, post.h, will be created in the include/ directory. This 25943d9616cSwdenkfile will contain common POST declarations and will define a set of 26043d9616cSwdenkmacros that will be reused for defining CONFIG_POST. As an example, 26143d9616cSwdenkthe following macro may be defined: 26243d9616cSwdenk 26343d9616cSwdenk#define POST_CACHE \ 26443d9616cSwdenk { 26543d9616cSwdenk "Cache test", "cache", \ 26643d9616cSwdenk " This test verifies the CPU cache operation.", \ 26743d9616cSwdenk POST_RAM | POST_NORMAL, \ 26843d9616cSwdenk &cache_post_test \ 26943d9616cSwdenk } 27043d9616cSwdenk 27143d9616cSwdenkA new subdirectory will be created in the U-Boot root directory. It 27243d9616cSwdenkwill contain the source code of the POST layer and most of POST 27343d9616cSwdenktests. Each POST test in this directory will be placed into a 27443d9616cSwdenkseparate file (it will be needed for building standalone tests). Some 27543d9616cSwdenkPOST tests (mainly those for testing peripheral devices) will be 27643d9616cSwdenklocated in the source files of the drivers for those devices. This 27743d9616cSwdenkway will be used only if the test subtantially uses the driver. 27843d9616cSwdenk 27943d9616cSwdenk2.1.4. Standalone tests 28043d9616cSwdenk 28143d9616cSwdenkThe POST framework will allow to develop and run standalone tests. A 28243d9616cSwdenkuser-space library will be developed to provide the POST interface 28343d9616cSwdenkfunctions to standalone tests. 28443d9616cSwdenk 28543d9616cSwdenk2.1.5. Command line interface 28643d9616cSwdenk 28743d9616cSwdenkA new command, diag, will be added to U-Boot. This command will be 28843d9616cSwdenkused for listing all available hardware tests, getting detailed 28943d9616cSwdenkdescriptions of them and running these tests. 29043d9616cSwdenk 29143d9616cSwdenkMore specifically, being run without any arguments, this command will 29243d9616cSwdenkprint the list of all available hardware tests: 29343d9616cSwdenk 29443d9616cSwdenk=> diag 29543d9616cSwdenkAvailable hardware tests: 29643d9616cSwdenk cache - cache test 29743d9616cSwdenk cpu - CPU test 29843d9616cSwdenk enet - SCC/FCC ethernet test 29943d9616cSwdenkUse 'diag [<test1> [<test2>]] ... ' to get more info. 30043d9616cSwdenkUse 'diag run [<test1> [<test2>]] ... ' to run tests. 30143d9616cSwdenk=> 30243d9616cSwdenk 30343d9616cSwdenkIf the first argument to the diag command is not 'run', detailed 30443d9616cSwdenkdescriptions of the specified tests will be printed: 30543d9616cSwdenk 30643d9616cSwdenk=> diag cpu cache 30743d9616cSwdenkcpu - CPU test 30843d9616cSwdenk This test verifies the arithmetic logic unit of CPU. 30943d9616cSwdenkcache - cache test 31043d9616cSwdenk This test verifies the CPU cache operation. 31143d9616cSwdenk=> 31243d9616cSwdenk 31343d9616cSwdenkIf the first argument to diag is 'run', the specified tests will be 31443d9616cSwdenkexecuted. If no tests are specified, all available tests will be 31543d9616cSwdenkexecuted. 31643d9616cSwdenk 31743d9616cSwdenkIt will be prohibited to execute tests running in ROM manually. The 31843d9616cSwdenk'diag' command will not display such tests and/or run them. 31943d9616cSwdenk 32043d9616cSwdenk2.1.6. Power failure handling 32143d9616cSwdenk 32243d9616cSwdenkThe Linux kernel will be modified to detect power failures and 32343d9616cSwdenkautomatically reboot the system in such cases. It will be assumed 32443d9616cSwdenkthat the power failure causes a system interrupt. 32543d9616cSwdenk 32643d9616cSwdenkTo perform correct system shutdown, the kernel will register a 32743d9616cSwdenkhandler of the power-fail IRQ on booting. Being called, the handler 32843d9616cSwdenkwill run /sbin/reboot using the call_usermodehelper() routine. 32943d9616cSwdenk/sbin/reboot will automatically bring the system down in a secure 33043d9616cSwdenkway. This feature will be configured in/out from the kernel 33143d9616cSwdenkconfiguration file. 33243d9616cSwdenk 33343d9616cSwdenkThe POST layer of U-Boot will check whether the system runs in 33443d9616cSwdenkpower-fail mode. If it does, the system will be powered off after 33543d9616cSwdenkexecuting all hardware tests. 33643d9616cSwdenk 33743d9616cSwdenk2.1.7. Hazardous tests 33843d9616cSwdenk 33943d9616cSwdenkSome tests may cause system rebooting during their execution. For 34043d9616cSwdenksome tests, this will indicate a failure, while for the Watchdog 34143d9616cSwdenktest, this means successful operation of the timer. 34243d9616cSwdenk 34343d9616cSwdenkIn order to support such tests, the following scheme will be 34443d9616cSwdenkimplemented. All the tests that may cause system rebooting will have 34543d9616cSwdenkthe POST_REBOOT bit flag set in the flag field of the correspondent 34643d9616cSwdenkpost_test structure. Before starting tests marked with this bit flag, 34743d9616cSwdenkthe POST layer will store an identification number of the test in a 34843d9616cSwdenklocation in IMMR. On booting, the POST layer will check the value of 34943d9616cSwdenkthis variable and if it is set will skip over the tests preceding the 35043d9616cSwdenkfailed one. On second execution of the failed test, the POST_REBOOT 35143d9616cSwdenkbit flag will be set in the flag argument to the test routine. This 35243d9616cSwdenkwill allow to detect system rebooting on the previous iteration. For 35343d9616cSwdenkexample, the watchdog timer test may have the following 35443d9616cSwdenkdeclaration/body: 35543d9616cSwdenk 35643d9616cSwdenk... 35743d9616cSwdenk#define POST_WATCHDOG \ 35843d9616cSwdenk { 35943d9616cSwdenk "Watchdog timer test", "watchdog", \ 36043d9616cSwdenk " This test checks the watchdog timer.", \ 36143d9616cSwdenk POST_RAM | POST_POWERON | POST_REBOOT, \ 36243d9616cSwdenk &watchdog_post_test \ 36343d9616cSwdenk } 36443d9616cSwdenk... 36543d9616cSwdenk 36643d9616cSwdenk... 36743d9616cSwdenkint watchdog_post_test(bd_t *bd, int flags) 36843d9616cSwdenk{ 36943d9616cSwdenk unsigned long start_time; 37043d9616cSwdenk 37143d9616cSwdenk if (flags & POST_REBOOT) { 37243d9616cSwdenk /* Test passed */ 37343d9616cSwdenk return 0; 37443d9616cSwdenk } else { 37543d9616cSwdenk /* disable interrupts */ 37643d9616cSwdenk disable_interrupts(); 37743d9616cSwdenk /* 10-second delay */ 37843d9616cSwdenk ... 37943d9616cSwdenk /* if we've reached this, the watchdog timer does not work */ 38043d9616cSwdenk enable_interrupts(); 38143d9616cSwdenk return 1; 38243d9616cSwdenk } 38343d9616cSwdenk} 38443d9616cSwdenk... 38543d9616cSwdenk 38643d9616cSwdenk2.2. Hardware-specific details 38743d9616cSwdenk 38843d9616cSwdenkThis project will also develop a set of POST tests for MPC8xx- based 38943d9616cSwdenksystems. This section provides technical details of how it will be 39043d9616cSwdenkdone. 39143d9616cSwdenk 39243d9616cSwdenk2.2.1. Generic PPC tests 39343d9616cSwdenk 39443d9616cSwdenkThe following generic POST tests will be developed: 39543d9616cSwdenk 39643d9616cSwdenk o) CPU test 39743d9616cSwdenk 39843d9616cSwdenk This test will check the arithmetic logic unit (ALU) of CPU. The 39943d9616cSwdenk test will take several milliseconds and will run on normal 40043d9616cSwdenk booting. 40143d9616cSwdenk 40243d9616cSwdenk o) Cache test 40343d9616cSwdenk 40443d9616cSwdenk This test will verify the CPU cache (L1 cache). The test will 40543d9616cSwdenk run on normal booting. 40643d9616cSwdenk 40743d9616cSwdenk o) Memory test 40843d9616cSwdenk 40943d9616cSwdenk This test will examine RAM and check it for errors. The test 41043d9616cSwdenk will always run on booting. On normal booting, only a limited 41143d9616cSwdenk amount of RAM will be checked. On power-fail booting a fool 41243d9616cSwdenk memory check-up will be performed. 41343d9616cSwdenk 41443d9616cSwdenk2.2.1.1. CPU test 41543d9616cSwdenk 41643d9616cSwdenkThis test will verify the following ALU instructions: 41743d9616cSwdenk 41843d9616cSwdenk o) Condition register istructions 41943d9616cSwdenk 42043d9616cSwdenk This group will contain: mtcrf, mfcr, mcrxr, crand, crandc, 42143d9616cSwdenk cror, crorc, crxor, crnand, crnor, creqv, mcrf. 42243d9616cSwdenk 42343d9616cSwdenk The mtcrf/mfcr instructions will be tested by loading different 42443d9616cSwdenk values into the condition register (mtcrf), moving its value to 42543d9616cSwdenk a general-purpose register (mfcr) and comparing this value with 42643d9616cSwdenk the expected one. The mcrxr instruction will be tested by 42743d9616cSwdenk loading a fixed value into the XER register (mtspr), moving XER 42843d9616cSwdenk value to the condition register (mcrxr), moving it to a 42943d9616cSwdenk general-purpose register (mfcr) and comparing the value of this 43043d9616cSwdenk register with the expected one. The rest of instructions will be 43143d9616cSwdenk tested by loading a fixed value into the condition register 43243d9616cSwdenk (mtcrf), executing each instruction several times to modify all 43343d9616cSwdenk 4-bit condition fields, moving the value of the conditional 43443d9616cSwdenk register to a general-purpose register (mfcr) and comparing it 43543d9616cSwdenk with the expected one. 43643d9616cSwdenk 43743d9616cSwdenk o) Integer compare instructions 43843d9616cSwdenk 43943d9616cSwdenk This group will contain: cmp, cmpi, cmpl, cmpli. 44043d9616cSwdenk 44143d9616cSwdenk To verify these instructions the test will run them with 44243d9616cSwdenk different combinations of operands, read the condition register 44343d9616cSwdenk value and compare it with the expected one. More specifically, 44443d9616cSwdenk the test will contain a pre-built table containing the 44543d9616cSwdenk description of each test case: the instruction, the values of 44643d9616cSwdenk the operands, the condition field to save the result in and the 44743d9616cSwdenk expected result. 44843d9616cSwdenk 44943d9616cSwdenk o) Arithmetic instructions 45043d9616cSwdenk 45143d9616cSwdenk This group will contain: add, addc, adde, addme, addze, subf, 45243d9616cSwdenk subfc, subfe, subme, subze, mullw, mulhw, mulhwu, divw, divwu, 45343d9616cSwdenk extsb, extsh. 45443d9616cSwdenk 45543d9616cSwdenk The test will contain a pre-built table of instructions, 45643d9616cSwdenk operands, expected results and expected states of the condition 45743d9616cSwdenk register. For each table entry, the test will cyclically use 45843d9616cSwdenk different sets of operand registers and result registers. For 45943d9616cSwdenk example, for instructions that use 3 registers on the first 46043d9616cSwdenk iteration r0/r1 will be used as operands and r2 for result. On 46143d9616cSwdenk the second iteration, r1/r2 will be used as operands and r3 as 46243d9616cSwdenk for result and so on. This will enable to verify all 46343d9616cSwdenk general-purpose registers. 46443d9616cSwdenk 46543d9616cSwdenk o) Logic instructions 46643d9616cSwdenk 46743d9616cSwdenk This group will contain: and, andc, andi, andis, or, orc, ori, 46843d9616cSwdenk oris, xor, xori, xoris, nand, nor, neg, eqv, cntlzw. 46943d9616cSwdenk 47043d9616cSwdenk The test scheme will be identical to that from the previous 47143d9616cSwdenk point. 47243d9616cSwdenk 47343d9616cSwdenk o) Shift instructions 47443d9616cSwdenk 47543d9616cSwdenk This group will contain: slw, srw, sraw, srawi, rlwinm, rlwnm, 47643d9616cSwdenk rlwimi 47743d9616cSwdenk 47843d9616cSwdenk The test scheme will be identical to that from the previous 47943d9616cSwdenk point. 48043d9616cSwdenk 48143d9616cSwdenk o) Branch instructions 48243d9616cSwdenk 48343d9616cSwdenk This group will contain: b, bl, bc. 48443d9616cSwdenk 48543d9616cSwdenk The first 2 instructions (b, bl) will be verified by jumping to 486*a6f70a3dSVagrant Cascadian a fixed address and checking whether control was transferred to 48743d9616cSwdenk that very point. For the bl instruction the value of the link 48843d9616cSwdenk register will be checked as well (using mfspr). To verify the bc 48943d9616cSwdenk instruction various combinations of the BI/BO fields, the CTR 49043d9616cSwdenk and the condition register values will be checked. The list of 49143d9616cSwdenk such combinations will be pre-built and linked in U-Boot at 49243d9616cSwdenk build time. 49343d9616cSwdenk 49443d9616cSwdenk o) Load/store instructions 49543d9616cSwdenk 49643d9616cSwdenk This group will contain: lbz(x)(u), lhz(x)(u), lha(x)(u), 49743d9616cSwdenk lwz(x)(u), stb(x)(u), sth(x)(u), stw(x)(u). 49843d9616cSwdenk 49943d9616cSwdenk All operations will be performed on a 16-byte array. The array 50043d9616cSwdenk will be 4-byte aligned. The base register will point to offset 50143d9616cSwdenk 8. The immediate offset (index register) will range in [-8 ... 50243d9616cSwdenk +7]. The test cases will be composed so that they will not cause 50343d9616cSwdenk alignment exceptions. The test will contain a pre-built table 50443d9616cSwdenk describing all test cases. For store instructions, the table 50543d9616cSwdenk entry will contain: the instruction opcode, the value of the 50643d9616cSwdenk index register and the value of the source register. After 50743d9616cSwdenk executing the instruction, the test will verify the contents of 50843d9616cSwdenk the array and the value of the base register (it must change for 50943d9616cSwdenk "store with update" instructions). For load instructions, the 51043d9616cSwdenk table entry will contain: the instruction opcode, the array 51143d9616cSwdenk contents, the value of the index register and the expected value 51243d9616cSwdenk of the destination register. After executing the instruction, 51343d9616cSwdenk the test will verify the value of the destination register and 51443d9616cSwdenk the value of the base register (it must change for "load with 51543d9616cSwdenk update" instructions). 51643d9616cSwdenk 51743d9616cSwdenk o) Load/store multiple/string instructions 51843d9616cSwdenk 51943d9616cSwdenk 52043d9616cSwdenkThe CPU test will run in RAM in order to allow run-time modification 52143d9616cSwdenkof the code to reduce the memory footprint. 52243d9616cSwdenk 52343d9616cSwdenk2.2.1.2 Special-Purpose Registers Tests 52443d9616cSwdenk 52543d9616cSwdenkTBD. 52643d9616cSwdenk 52743d9616cSwdenk2.2.1.3. Cache test 52843d9616cSwdenk 52943d9616cSwdenkTo verify the data cache operation the following test scenarios will 53043d9616cSwdenkbe used: 53143d9616cSwdenk 53243d9616cSwdenk 1) Basic test #1 53343d9616cSwdenk 53443d9616cSwdenk - turn on the data cache 53543d9616cSwdenk - switch the data cache to write-back or write-through mode 53643d9616cSwdenk - invalidate the data cache 53743d9616cSwdenk - write the negative pattern to a cached area 53843d9616cSwdenk - read the area 53943d9616cSwdenk 54043d9616cSwdenk The negative pattern must be read at the last step 54143d9616cSwdenk 54243d9616cSwdenk 2) Basic test #2 54343d9616cSwdenk 54443d9616cSwdenk - turn on the data cache 54543d9616cSwdenk - switch the data cache to write-back or write-through mode 54643d9616cSwdenk - invalidate the data cache 54743d9616cSwdenk - write the zero pattern to a cached area 54843d9616cSwdenk - turn off the data cache 54943d9616cSwdenk - write the negative pattern to the area 55043d9616cSwdenk - turn on the data cache 55143d9616cSwdenk - read the area 55243d9616cSwdenk 55343d9616cSwdenk The negative pattern must be read at the last step 55443d9616cSwdenk 55543d9616cSwdenk 3) Write-through mode test 55643d9616cSwdenk 55743d9616cSwdenk - turn on the data cache 55843d9616cSwdenk - switch the data cache to write-through mode 55943d9616cSwdenk - invalidate the data cache 56043d9616cSwdenk - write the zero pattern to a cached area 56143d9616cSwdenk - flush the data cache 56243d9616cSwdenk - write the negative pattern to the area 56343d9616cSwdenk - turn off the data cache 56443d9616cSwdenk - read the area 56543d9616cSwdenk 56643d9616cSwdenk The negative pattern must be read at the last step 56743d9616cSwdenk 56843d9616cSwdenk 4) Write-back mode test 56943d9616cSwdenk 57043d9616cSwdenk - turn on the data cache 57143d9616cSwdenk - switch the data cache to write-back mode 57243d9616cSwdenk - invalidate the data cache 57343d9616cSwdenk - write the negative pattern to a cached area 57443d9616cSwdenk - flush the data cache 57543d9616cSwdenk - write the zero pattern to the area 57643d9616cSwdenk - invalidate the data cache 57743d9616cSwdenk - read the area 57843d9616cSwdenk 57943d9616cSwdenk The negative pattern must be read at the last step 58043d9616cSwdenk 58143d9616cSwdenkTo verify the instruction cache operation the following test 58243d9616cSwdenkscenarios will be used: 58343d9616cSwdenk 58443d9616cSwdenk 1) Basic test #1 58543d9616cSwdenk 58643d9616cSwdenk - turn on the instruction cache 58743d9616cSwdenk - unlock the entire instruction cache 58843d9616cSwdenk - invalidate the instruction cache 58943d9616cSwdenk - lock a branch instruction in the instruction cache 59043d9616cSwdenk - replace the branch instruction with "nop" 59143d9616cSwdenk - jump to the branch instruction 59243d9616cSwdenk - check that the branch instruction was executed 59343d9616cSwdenk 59443d9616cSwdenk 2) Basic test #2 59543d9616cSwdenk 59643d9616cSwdenk - turn on the instruction cache 59743d9616cSwdenk - unlock the entire instruction cache 59843d9616cSwdenk - invalidate the instruction cache 59943d9616cSwdenk - jump to a branch instruction 60043d9616cSwdenk - check that the branch instruction was executed 60143d9616cSwdenk - replace the branch instruction with "nop" 60243d9616cSwdenk - invalidate the instruction cache 60343d9616cSwdenk - jump to the branch instruction 60443d9616cSwdenk - check that the "nop" instruction was executed 60543d9616cSwdenk 60643d9616cSwdenkThe CPU test will run in RAM in order to allow run-time modification 60743d9616cSwdenkof the code. 60843d9616cSwdenk 60943d9616cSwdenk2.2.1.4. Memory test 61043d9616cSwdenk 61143d9616cSwdenkThe memory test will verify RAM using sequential writes and reads 61243d9616cSwdenkto/from RAM. Specifically, there will be several test cases that will 61343d9616cSwdenkuse different patterns to verify RAM. Each test case will first fill 61443d9616cSwdenka region of RAM with one pattern and then read the region back and 61543d9616cSwdenkcompare its contents with the pattern. The following patterns will be 61643d9616cSwdenkused: 61743d9616cSwdenk 61843d9616cSwdenk 1) zero pattern (0x00000000) 61943d9616cSwdenk 2) negative pattern (0xffffffff) 62043d9616cSwdenk 3) checkerboard pattern (0x55555555, 0xaaaaaaaa) 62143d9616cSwdenk 4) bit-flip pattern ((1 << (offset % 32)), ~(1 << (offset % 32))) 62243d9616cSwdenk 5) address pattern (offset, ~offset) 62343d9616cSwdenk 62443d9616cSwdenkPatterns #1, #2 will help to find unstable bits. Patterns #3, #4 will 62543d9616cSwdenkbe used to detect adherent bits, i.e. bits whose state may randomly 62643d9616cSwdenkchange if adjacent bits are modified. The last pattern will be used 62743d9616cSwdenkto detect far-located errors, i.e. situations when writing to one 62843d9616cSwdenklocation modifies an area located far from it. Also, usage of the 62943d9616cSwdenklast pattern will help to detect memory controller misconfigurations 63043d9616cSwdenkwhen RAM represents a cyclically repeated portion of a smaller size. 63143d9616cSwdenk 63243d9616cSwdenkBeing run in normal mode, the test will verify only small 4Kb regions 63343d9616cSwdenkof RAM around each 1Mb boundary. For example, for 64Mb RAM the 63443d9616cSwdenkfollowing areas will be verified: 0x00000000-0x00000800, 63543d9616cSwdenk0x000ff800-0x00100800, 0x001ff800-0x00200800, ..., 0x03fff800- 63643d9616cSwdenk0x04000000. If the test is run in power-fail mode, it will verify the 63743d9616cSwdenkwhole RAM. 63843d9616cSwdenk 63943d9616cSwdenkThe memory test will run in ROM before relocating U-Boot to RAM in 64043d9616cSwdenkorder to allow RAM modification without saving its contents. 64143d9616cSwdenk 64243d9616cSwdenk2.2.2. Common tests 64343d9616cSwdenk 64443d9616cSwdenkThis section describes tests that are not based on any hardware 64543d9616cSwdenkpeculiarities and use common U-Boot interfaces only. These tests do 64643d9616cSwdenknot need any modifications for porting them to another board/CPU. 64743d9616cSwdenk 64843d9616cSwdenk2.2.2.1. I2C test 64943d9616cSwdenk 65043d9616cSwdenkFor verifying the I2C bus, a full I2C bus scanning will be performed 65160aaaa07SPeter Tyserusing the i2c_probe() routine. If a board defines 65260aaaa07SPeter TyserCONFIG_SYS_POST_I2C_ADDRS the I2C test will pass if all devices 65360aaaa07SPeter Tyserlisted in CONFIG_SYS_POST_I2C_ADDRS are found, and no additional 65460aaaa07SPeter Tyserdevices are detected. If CONFIG_SYS_POST_I2C_ADDRS is not defined 65560aaaa07SPeter Tyserthe test will pass if any I2C device is found. 65643d9616cSwdenk 6579d921f19SPeter TyserThe CONFIG_SYS_POST_I2C_IGNORES define can be used to list I2C 6589d921f19SPeter Tyserdevices which may or may not be present when using 6599d921f19SPeter TyserCONFIG_SYS_POST_I2C_ADDRS. The I2C POST test will pass regardless 6609d921f19SPeter Tyserif the devices in CONFIG_SYS_POST_I2C_IGNORES are found or not. 6619d921f19SPeter TyserThis is useful in cases when I2C devices are optional (eg on a 6629d921f19SPeter Tyserdaughtercard that may or may not be present) or not critical 6639d921f19SPeter Tyserto board operation. 6649d921f19SPeter Tyser 66543d9616cSwdenk2.2.2.2. Watchdog timer test 66643d9616cSwdenk 66743d9616cSwdenkTo test the watchdog timer the scheme mentioned above (refer to 66843d9616cSwdenksection "Hazardous tests") will be used. Namely, this test will be 66943d9616cSwdenkmarked with the POST_REBOOT bit flag. On the first iteration, the 67043d9616cSwdenktest routine will make a 10-second delay. If the system does not 67143d9616cSwdenkreboot during this delay, the watchdog timer is not operational and 67243d9616cSwdenkthe test fails. If the system reboots, on the second iteration the 67343d9616cSwdenkPOST_REBOOT bit will be set in the flag argument to the test routine. 67443d9616cSwdenkThe test routine will check this bit and report a success if it is 67543d9616cSwdenkset. 67643d9616cSwdenk 67743d9616cSwdenk2.2.2.3. RTC test 67843d9616cSwdenk 67943d9616cSwdenkThe RTC test will use the rtc_get()/rtc_set() routines. The following 68043d9616cSwdenkfeatures will be verified: 68143d9616cSwdenk 68243d9616cSwdenk o) Time uniformity 68343d9616cSwdenk 68443d9616cSwdenk This will be verified by reading RTC in polling within a short 68543d9616cSwdenk period of time (5-10 seconds). 68643d9616cSwdenk 68743d9616cSwdenk o) Passing month boundaries 68843d9616cSwdenk 68943d9616cSwdenk This will be checked by setting RTC to a second before a month 69043d9616cSwdenk boundary and reading it after its passing the boundary. The test 69143d9616cSwdenk will be performed for both leap- and nonleap-years. 69243d9616cSwdenk 69343d9616cSwdenk2.2.3. MPC8xx peripherals tests 69443d9616cSwdenk 69543d9616cSwdenkThis project will develop a set of tests verifying the peripheral 69643d9616cSwdenkunits of MPC8xx processors. Namely, the following controllers of the 69743d9616cSwdenkMPC8xx communication processor module (CPM) will be tested: 69843d9616cSwdenk 69943d9616cSwdenk o) Serial Management Controllers (SMC) 70043d9616cSwdenk 70143d9616cSwdenk o) Serial Communication Controllers (SCC) 70243d9616cSwdenk 70343d9616cSwdenk2.2.3.1. Ethernet tests (SCC) 70443d9616cSwdenk 70543d9616cSwdenkThe internal (local) loopback mode will be used to test SCC. To do 70643d9616cSwdenkthat the controllers will be configured accordingly and several 70743d9616cSwdenkpackets will be transmitted. These tests may be enhanced in future to 70843d9616cSwdenkuse external loopback for testing. That will need appropriate 70943d9616cSwdenkreconfiguration of the physical interface chip. 71043d9616cSwdenk 71143d9616cSwdenkThe test routines for the SCC ethernet tests will be located in 712a47a12beSStefan Roesearch/powerpc/cpu/mpc8xx/scc.c. 71343d9616cSwdenk 71443d9616cSwdenk2.2.3.2. UART tests (SMC/SCC) 71543d9616cSwdenk 71643d9616cSwdenkTo perform these tests the internal (local) loopback mode will be 71743d9616cSwdenkused. The SMC/SCC controllers will be configured to connect the 71843d9616cSwdenktransmitter output to the receiver input. After that, several bytes 71943d9616cSwdenkwill be transmitted. These tests may be enhanced to make to perform 72043d9616cSwdenk"external" loopback test using a loopback cable. In this case, the 72143d9616cSwdenktest will be executed manually. 72243d9616cSwdenk 72343d9616cSwdenkThe test routine for the SMC/SCC UART tests will be located in 724a47a12beSStefan Roesearch/powerpc/cpu/mpc8xx/serial.c. 72543d9616cSwdenk 72643d9616cSwdenk2.2.3.3. USB test 72743d9616cSwdenk 72843d9616cSwdenkTBD 72943d9616cSwdenk 73043d9616cSwdenk2.2.3.4. SPI test 73143d9616cSwdenk 73243d9616cSwdenkTBD 733