1*** Variables ***
2${UART0}                            sysbus.uart0
3
4${DTC_ADDR}                         0xfe00000
5
6${URL_BASE}                         @https://dl.antmicro.com/projects/renode
7${XEN_DTC}                          ${URL_BASE}/xen_zephyr_cortex-r52.dtc-s_1961-4e8eefe98742e2860ca28cf82e75ae8d8c6c2a5d
8${XEN_BIN}                          ${URL_BASE}/xen_cortex-r52.bin-s_950280-5abcd07806d4f8d33b370020342470c15bf499b5
9${ZEPHYR_PHILOSOPHERS}              ${URL_BASE}/zephyr_philosophers_xen_cortex-r52.bin-s_42884-05ca319e43ca33a124c51f84319229815acc654f
10${ZEPHYR_HELLO_WORLD}               ${URL_BASE}/zephyr_hello_world_xen_cortex-r52.bin-s_26052-d55e84265d9a51fe5522abc959ce7f31b68510a6
11
12*** Keywords ***
13Create Machine
14    [Arguments]                     @{}  ${zephyr_bin}
15
16    ${python_script}=               Catenate  SEPARATOR=\n
17    ...                             python
18    ...                             """
19    ...                             from System.Runtime.CompilerServices import RuntimeHelpers
20    ...                             from Antmicro.Renode.Peripherals.CPU import RegisterValue
21    ...                             ZEPHYR_IMAGE_BASE = 0xd00080
22    ...                             ZEPHYR_BASE = 0xb00000
23    ...                             def mc_load_zephyr(zephyr_bin):
24    ...                             ${SPACE*4}sysbus = self.Machine["sysbus"]
25    ...                             ${SPACE*4}image_len = System.IO.FileInfo(zephyr_bin).Length
26    ...                             ${SPACE*4}sysbus.LoadBinary(zephyr_bin, ZEPHYR_BASE)
27    ...                             ${SPACE*4}# Patch the Zephyr header
28    ...                             ${SPACE*4}sysbus.WriteDoubleWord(ZEPHYR_BASE + 0x2c, ZEPHYR_IMAGE_BASE + image_len)
29    ...                             """
30
31    Execute Command                 mach create
32    Execute Command                 machine LoadPlatformDescription @platforms/cpus/cortex-r52.repl
33    Execute Command                 ${python_script}
34
35    Execute Command                 sysbus LoadBinary ${XEN_BIN} 0x0
36    Execute Command                 sysbus LoadBinary ${XEN_DTC} ${DTC_ADDR}
37
38    Execute Command                 load_zephyr ${zephyr_bin}
39    Execute Command                 sysbus.cpu SetRegister 102 ${DTC_ADDR}
40    Create Terminal Tester          ${UART0}  defaultPauseEmulation=True
41
42*** Test Cases ***
43Run Zephyr Hello World Sample
44    [Tags]                          Demos
45
46    Create Machine                  zephyr_bin=${ZEPHYR_HELLO_WORLD}
47
48    Wait For Line On Uart           (XEN) DOM1: *** Booting Zephyr OS build  includeUnfinishedLine=True
49    Wait For Line On Uart           (XEN) DOM1: Hello World! fvp_baser_aemv8r_aarch32
50
51Run Zephyr Philosophers Sample
52    [Tags]                          Demos
53
54    Create Machine                  zephyr_bin=${ZEPHYR_PHILOSOPHERS}
55
56    Wait For Line On Uart           (XEN) Xen dom0less mode detected
57
58    Wait For Line On Uart           Philosopher 0.*THINKING  treatAsRegex=true
59    Wait For Line On Uart           Philosopher 0.*HOLDING  treatAsRegex=true
60    Wait For Line On Uart           Philosopher 0.*EATING  treatAsRegex=true
61    Wait For Line On Uart           Philosopher 1.*THINKING  treatAsRegex=true
62    Wait For Line On Uart           Philosopher 1.*HOLDING  treatAsRegex=true
63    Wait For Line On Uart           Philosopher 1.*EATING  treatAsRegex=true
64    Wait For Line On Uart           Philosopher 2.*THINKING  treatAsRegex=true
65    Wait For Line On Uart           Philosopher 2.*HOLDING  treatAsRegex=true
66    Wait For Line On Uart           Philosopher 2.*EATING  treatAsRegex=true
67    Wait For Line On Uart           Philosopher 3.*THINKING  treatAsRegex=true
68    Wait For Line On Uart           Philosopher 3.*HOLDING  treatAsRegex=true
69    Wait For Line On Uart           Philosopher 3.*EATING  treatAsRegex=true
70    Wait For Line On Uart           Philosopher 4.*THINKING  treatAsRegex=true
71    Wait For Line On Uart           Philosopher 4.*HOLDING  treatAsRegex=true
72    Wait For Line On Uart           Philosopher 4.*EATING  treatAsRegex=true
73    Wait For Line On Uart           Philosopher 5.*THINKING  treatAsRegex=true
74    Wait For Line On Uart           Philosopher 5.*HOLDING  treatAsRegex=true
75    Wait For Line On Uart           Philosopher 5.*EATING  treatAsRegex=true
76