Skip to content

Commit

Permalink
trunner: mutualisation of jjfs2
Browse files Browse the repository at this point in the history
JIRA CI-301
  • Loading branch information
mateusz-bloch committed Jul 20, 2023
1 parent f0c4a5d commit 59ffe0c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
2 changes: 2 additions & 0 deletions trunner/harness/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
PloHarness,
PloImageLoader,
PloImageProperty,
PloJffsImageProperty,
)
from .psh import ShellHarness
from .pyharness import PyHarness
Expand All @@ -41,5 +42,6 @@
"PloInterface",
"PloJffs2CleanmarkerSpec",
"PloImageProperty",
"PloJffsImageProperty",
"unity_harness",
]
12 changes: 12 additions & 0 deletions trunner/harness/plo.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ class PloImageProperty:
memory_bank: str


@dataclass(frozen=True)
class PloJffsImageProperty(PloImageProperty):
"""Image wchich needs jffs2 erase with cleanmarkers before writing actual image"""

flash_device_id: str
cleanmarkers_args: PloJffs2CleanmarkerSpec
timeout: int


class PloImageLoader(TerminalHarness, PloInterface):
"""Harness to load the image to the memory using plo bootloader and phoenixd program.
Expand Down Expand Up @@ -248,6 +257,9 @@ def __call__(self):
self.rebooter(flash=True, hard=True)
self.plo_loader()

if isinstance(self.image, PloJffsImageProperty):
self.jffs2(self.image.flash_device_id, True, self.image.cleanmarkers_args, self.image.timeout)

with self.phoenixd.run():
self.copy_file2mem(
src=self.image.source,
Expand Down
30 changes: 15 additions & 15 deletions trunner/target/armv7a7.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
HarnessBuilder,
PloInterface,
PloImageLoader,
PloImageProperty,
PloJffsImageProperty,
ShellHarness,
Rebooter,
RebooterHarness,
PloJffs2CleanmarkerSpec,
)

#
from trunner.harness import TerminalHarness
from trunner.host import Host
from trunner.tools import Phoenixd, Psu
Expand All @@ -37,9 +37,6 @@ def __call__(self):
self.psu.run()
self.wait_prompt()

# Device id and cleanmarkers arguments are set based on target configuration in _targets/_projects.
self.jffs2(self.flash_device_id, True, self.cleanmarkers_args, 90)


class ARMv7A7Target(TargetBase, PloInterface, Rebooter):
plo_psu_script = "plo-ram.sdp"
Expand All @@ -58,8 +55,6 @@ def flash_dut(self):
plo_loader = PsuPloLoader(
dut=self.dut,
psu=Psu(self.plo_psu_script, self.boot_dir()),
flash_device_id=self.flash_device_id,
cleanmarkers_args=self.cleanmarkers_spec,
)

loader = PloImageLoader(
Expand Down Expand Up @@ -89,15 +84,20 @@ def build_test(self, test: TestOptions) -> Callable[[], Optional[TestResult]]:

class IMX6ULLEvkTarget(ARMv7A7Target):
# IMX6ULL with system jffs2 use nor0 as space to hold data
image = PloImageProperty(file="phoenix.disk", source="usb0", memory_bank="nor0")
name = "armv7a7-imx6ull-evk"
cleanmarkers_spec = PloJffs2CleanmarkerSpec(
start_block=0x10,
number_of_blocks=0x1F0,
block_size=0x10000,
cleanmarker_size=0x10,
image = PloJffsImageProperty(
file="phoenix.disk",
source="usb0",
memory_bank="nor0",
flash_device_id="2.0",
cleanmarkers_args=PloJffs2CleanmarkerSpec(
start_block=0x10,
number_of_blocks=0x1F0,
block_size=0x10000,
cleanmarker_size=0x10,
),
timeout=90,
)
flash_device_id = "2.0"
name = "armv7a7-imx6ull-evk"

def __init__(self, host: Host, port: Optional[str] = None, baudrate: int = 115200):
if not port:
Expand Down
32 changes: 14 additions & 18 deletions trunner/target/armv7a9.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from trunner.harness import (
HarnessBuilder,
PloInterface,
PloJffsImageProperty,
PloImageLoader,
PloImageProperty,
ShellHarness,
Rebooter,
RebooterHarness,
Expand Down Expand Up @@ -45,17 +45,13 @@ def __init__(
self,
dut: Dut,
script: str,
flash_device_id: str,
cleanmarkers_args: PloJffs2CleanmarkerSpec,
cwd: Optional[str] = None,
):
TerminalHarness.__init__(self)
PloInterface.__init__(self, dut)
self.script = script
self.cwd = cwd
self.gdbserver = JLinkGdbServer("Zynq 7020")
self.flash_device_id = flash_device_id
self.cleanmarkers_args = cleanmarkers_args

def __call__(self):
"""Loads plo image to RAM using gdb."""
Expand All @@ -81,9 +77,6 @@ def __call__(self):
self.enter_bootloader()
self.wait_prompt()

# Erase using jjfs2 command with cleanmarkers
self.jffs2(self.flash_device_id, True, self.cleanmarkers_args, 140) # ?Huge erase time?


class ARMv7A9Target(TargetBase):
def __init__(self, host: Host, port: str, baudrate: int = 115200):
Expand All @@ -99,8 +92,6 @@ def flash_dut(self):
plo_loader = ZynqGdbPloLoader(
dut=self.dut,
script=f"{self._project_dir()}/phoenix-rtos-build/scripts/upload-zynq7000.gdb",
flash_device_id=self.flash_device_id,
cleanmarkers_args=self.cleanmarkers_spec,
cwd=self.boot_dir(),
)

Expand Down Expand Up @@ -130,15 +121,20 @@ def build_test(self, test: TestOptions) -> Callable[[], Optional[TestResult]]:

class Zynq7000ZedboardTarget(ARMv7A9Target):
# Zynq7000Zedboard with system jffs2 use flash0 as space to hold data
image = PloImageProperty(file="phoenix.disk", source="usb0", memory_bank="flash0")
name = "armv7a9-zynq7000-zedboard"
cleanmarkers_spec = PloJffs2CleanmarkerSpec(
start_block=0x80,
number_of_blocks=0x100,
block_size=0x10000,
cleanmarker_size=0x10,
image = PloJffsImageProperty(
file="phoenix.disk",
source="usb0",
memory_bank="flash0",
flash_device_id="2.0",
cleanmarkers_args=PloJffs2CleanmarkerSpec(
start_block=0x80,
number_of_blocks=0x100,
block_size=0x10000,
cleanmarker_size=0x10,
),
timeout=140,
)
flash_device_id = "2.0"
name = "armv7a9-zynq7000-zedboard"

def __init__(self, host: Host, port: Optional[str] = None, baudrate: int = 115200):
if port is None:
Expand Down

0 comments on commit 59ffe0c

Please sign in to comment.