Skip to content

Commit 8956afb

Browse files
committed
boards: sifli: add sf32lb52_devkit_lcd revisions
- declare n16r8 (default) and a128r8 revisions in board.yml - add revision.cmake to validate BOARD_REVISION and keep n16r8 as fallback - teach board.cmake to append --memory nor/nand for sftool based on the active revision - extend the sftool west runner with an optional --memory argument so the flag is passed through Signed-off-by: Haoran Jiang <[email protected]>
1 parent 80be486 commit 8956afb

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

MAINTAINERS.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4685,6 +4685,7 @@ SiFli SF32LB Platforms:
46854685
collaborators:
46864686
- cameled
46874687
- ck-telecom
4688+
- halfsweet
46884689
files:
46894690
- boards/sifli/
46904691
- drivers/*/*sf32lb*

boards/sifli/sf32lb52_devkit_lcd/board.cmake

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# keep first
5-
board_runner_args(sftool "--chip=SF32LB52")
5+
set(_sf32lb52_sftool_args "--chip=SF32LB52")
6+
7+
if(DEFINED BOARD_REVISION)
8+
if(BOARD_REVISION STREQUAL "n16r8")
9+
list(APPEND _sf32lb52_sftool_args "--memory=nor")
10+
elseif(BOARD_REVISION STREQUAL "a128r8")
11+
list(APPEND _sf32lb52_sftool_args "--memory=nand")
12+
endif()
13+
endif()
14+
15+
board_runner_args(sftool ${_sf32lb52_sftool_args})
616

717
# keep first
818
include(${ZEPHYR_BASE}/boards/common/sftool.board.cmake)

boards/sifli/sf32lb52_devkit_lcd/board.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,11 @@ board:
55
name: sf32lb52_devkit_lcd
66
full_name: SF32LB52-DevKit-LCD
77
vendor: sifli
8+
revision:
9+
format: custom
10+
default: "n16r8"
11+
revisions:
12+
- name: "n16r8"
13+
- name: "a128r8"
814
socs:
915
- name: sf32lb525uc6
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(BOARD_REVISIONS "n16r8" "a128r8")
2+
3+
if(NOT DEFINED BOARD_REVISION)
4+
set(BOARD_REVISION "n16r8")
5+
else()
6+
if(NOT BOARD_REVISION IN_LIST BOARD_REVISIONS)
7+
message(FATAL_ERROR "${BOARD_REVISION} is not a valid revision for sf32lb52_devkit_lcd. Accepted revisions: ${BOARD_REVISIONS}")
8+
endif()
9+
endif()

scripts/west_commands/runners/sftool.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ def __init__(
1818
erase: bool,
1919
dt_flash: bool,
2020
tool_opt: list[str],
21+
memory: str | None,
2122
) -> None:
2223
super().__init__(cfg)
2324

2425
self._chip = chip
2526
self._port = port
2627
self._erase = erase
2728
self._dt_flash = dt_flash
29+
self._memory = memory
2830

2931
self._tool_opt: list[str] = []
3032
for opts in [shlex.split(opt) for opt in tool_opt]:
@@ -54,6 +56,12 @@ def do_add_parser(cls, parser):
5456
help="Serial port device, e.g. /dev/ttyUSB0",
5557
)
5658

59+
parser.add_argument(
60+
"--memory",
61+
choices=("nor", "nand"),
62+
help="Internal flash target (e.g. NOR or NAND)",
63+
)
64+
5765
@classmethod
5866
def do_create(cls, cfg: RunnerConfig, args: argparse.Namespace) -> "SftoolRunner":
5967
return SftoolRunner(
@@ -63,12 +71,15 @@ def do_create(cls, cfg: RunnerConfig, args: argparse.Namespace) -> "SftoolRunner
6371
erase=args.erase,
6472
dt_flash=args.dt_flash,
6573
tool_opt=args.tool_opt,
74+
memory=args.memory,
6675
)
6776

6877
def do_run(self, command: str, **kwargs):
6978
sftool = self.require("sftool")
7079

7180
cmd = [sftool, "--chip", self._chip, "--port", self._port]
81+
if self._memory:
82+
cmd += ["--memory", self._memory]
7283
cmd += self._tool_opt
7384

7485
if self._erase:

0 commit comments

Comments
 (0)