xref: /openbmc/openbmc-test-automation/oem/nuvoton/test_jtag_master.robot (revision 066162563efb3d54c8af3c11baf03f92747a7800)
1*** Settings ***
2Documentation    Module to test npcm750 JTAG Master.
3
4Resource         ../../lib/openbmc_ffdc.robot
5Resource         ../../lib/connection_client.robot
6
7Test Tags       JTAG_Master
8
9Suite Setup      Suite Setup Execution
10
11*** Variables ***
12${wrong_cpld}         0
13${program_cpld}       0
14
15*** Test Cases ***
16
17Test Read CPLD ID
18    [Documentation]  Test Read CPLD ID.
19    [Tags]  Test_Read_CPLD_ID
20
21    ${cmd}=  Catenate  loadsvf -d ${jtag_dev} -s /var/${readid_svf}
22    ${output}  ${stderr}  ${rc}=  BMC Execute Command  ${cmd}
23    Set Global Variable  ${wrong_cpld}  1
24    Should Not Contain  ${stderr}  tdo check error
25    Set Global Variable  ${wrong_cpld}  0
26
27
28Test Program CPLD
29    [Documentation]  Test Program CPLD.
30    [Tags]  Test_Program_CPLD
31
32    Pass Execution If  ${wrong_cpld}==1  Wrong CPLD chip
33    Pass Execution If  ${program_cpld}==0  skip programming cpld
34
35    Program CPLD  ${cpld_firmware2}  ${firmware_version2}
36    Program CPLD  ${cpld_firmware1}  ${firmware_version1}
37
38*** Keywords ***
39
40Get File From SFTP Server
41    [Documentation]  SCP Get File.
42    [Arguments]      ${filename}
43
44    # Description of argument(s):
45    # filename   The file to be downloaded.
46
47    Shell Cmd
48    ...  scp ${SFTP_USER}@${SFTP_SERVER}:${SFTP_PATH}/${filename} ${filename}
49
50
51Put File To BMC
52    [Documentation]  SCP Put File.
53    [Arguments]      ${filename}
54
55    # Description of argument(s):
56    # filename   The file to be uploaded.
57
58    scp.Put File  ${filename}  /var/${filename}
59
60Suite Setup Execution
61    [Documentation]  Suite Setup Execution.
62
63    ${status}=  Run Keyword And Return Status  Variable Should Exist
64    ...  ${TEST_PROGRAM_CPLD}
65    ${value}=  Set Variable if  ${status} == ${TRUE}  ${TEST_PROGRAM_CPLD}  0
66    Set Global Variable  ${program_cpld}  ${value}
67
68    ${code_base_dir_path}=  Get Code Base Dir Path
69    ${olympus_json}=  Evaluate
70    ...  json.load(open('${code_base_dir_path}data/oem/nuvoton/olympus.json'))  modules=json
71
72    ${cpld_firmware1}=  Set Variable  ${olympus_json["npcm7xx"]["cpld"]["fw1"]}
73    ${cpld_firmware2}=  Set Variable  ${olympus_json["npcm7xx"]["cpld"]["fw2"]}
74    ${firmware_version1}=  Set Variable  ${olympus_json["npcm7xx"]["cpld"]["fw1ver"]}
75    ${firmware_version2}=  Set Variable  ${olympus_json["npcm7xx"]["cpld"]["fw2ver"]}
76    ${readusercode_svf}=  Set Variable  ${olympus_json["npcm7xx"]["cpld"]["readusercode"]}
77    ${readid_svf}=  Set Variable  ${olympus_json["npcm7xx"]["cpld"]["readid"]}
78    ${jtag_dev}=  Set Variable  ${olympus_json["npcm7xx"]["jtag_dev"]}
79    ${power_cycle_cmd}=  Set Variable  ${olympus_json["npcm7xx"]["power_cycle_cmd"]}
80
81    Set Suite Variable  ${cpld_firmware1}
82    Set Suite Variable  ${cpld_firmware2}
83    Set Suite Variable  ${firmware_version1}
84    Set Suite Variable  ${firmware_version2}
85    Set Suite Variable  ${readusercode_svf}
86    Set Suite Variable  ${readid_svf}
87    Set Suite Variable  ${jtag_dev}
88    Set Suite Variable  ${power_cycle_cmd}
89
90    Get File From SFTP Server  ${readid_svf}
91    IF  ${program_cpld} == 1
92        Get File From SFTP Server  ${readusercode_svf}
93        Get File From SFTP Server  ${cpld_firmware1}
94        Get File From SFTP Server  ${cpld_firmware2}
95    END
96
97    scp.Open connection  ${OPENBMC_HOST}  username=${OPENBMC_USERNAME}
98    ...  password=${OPENBMC_PASSWORD}
99    Put File To BMC  ${readid_svf}
100    IF  ${program_cpld} == 1
101        Put File To BMC  ${readusercode_svf}
102        Put File To BMC  ${cpld_firmware1}
103        Put File To BMC  ${cpld_firmware2}
104    END
105    Sleep  5s
106    scp.Close Connection
107
108Program CPLD
109    [Documentation]  Program CPLD.
110    [Arguments]      ${svf_file}  ${version}
111
112    # Description of argument(s):
113    # svf_file   The firmware file.
114    # version    The firmware version.
115
116    ${cmd}=  Catenate  loadsvf -d ${jtag_dev} -s /var/${svf_file}
117    ${output}  ${stderr}  ${rc}=  BMC Execute Command  ${cmd}
118    Should Not Contain  ${stderr}  tdo check error
119
120    # control hot swap controller to power cycle whole system
121    BMC Execute Command  ${power_cycle_cmd}  ignore_err=1  fork=1
122
123    Sleep  10s
124    Run Keyword  Wait For Host To Ping  ${OPENBMC_HOST}  5 mins
125    ${cmd}=  Catenate  loadsvf -d ${jtag_dev} -s /var/${readusercode_svf}
126    ${output}  ${stderr}  ${rc}=  BMC Execute Command  ${cmd}
127    Should Contain  ${output}  ${version}
128