Skip to content

Commit 73e99f8

Browse files
committed
system/i3c: added i3c tools
usage: i3c options... options: -b --bus <bus> bus to use. -m --manufid <manufid> manufacturer ID (upper 16 bits of PID). -p --partid <partid> part ID (lower 32 bits of PID). -r --read <data length> read data. -w --write <data block> Write data block. -g --get <data block> get a dev info. -h --help Output usage message and exit.)) Signed-off-by: dongjiuzhu1 <[email protected]>
1 parent 60f5a68 commit 73e99f8

File tree

6 files changed

+609
-0
lines changed

6 files changed

+609
-0
lines changed

system/i3c/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ##############################################################################
2+
# apps/system/i3c/CMakeLists.txt
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
5+
# license agreements. See the NOTICE file distributed with this work for
6+
# additional information regarding copyright ownership. The ASF licenses this
7+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
8+
# use this file except in compliance with the License. You may obtain a copy of
9+
# the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations under
17+
# the License.
18+
#
19+
# ##############################################################################
20+
21+
if(CONFIG_SYSTEM_I3CTOOL)
22+
set(SRCS i3c_main.c)
23+
nuttx_add_application(NAME i3c SRCS ${SRCS} STACKSIZE
24+
${CONFIG_DEFAULT_TASK_STACKSIZE})
25+
endif()

system/i3c/Kconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
menuconfig SYSTEM_I3CTOOL
7+
tristate "I3C tool"
8+
default n
9+
depends on I3C
10+
select I3C_DRIVER
11+
---help---
12+
Enable support for the I3C tool.
13+
14+
if SYSTEM_I3CTOOL
15+
16+
config I3CTOOL_DEF_TARGETADDR
17+
hex "Default I3C device target address"
18+
default 0xffff
19+
---help---
20+
Default I3C device target address (default: 0xffff)
21+
22+
config I3CTOOL_DEFBUS
23+
int "Default I2C bus number"
24+
default 0
25+
---help---
26+
Default I3C bus number (default: 0)
27+
28+
endif

system/i3c/Make.defs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
############################################################################
2+
# apps/system/i3c/Make.defs
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
ifneq ($(CONFIG_SYSTEM_I3CTOOL),)
22+
CONFIGURED_APPS += $(APPDIR)/system/i3c
23+
endif

system/i3c/Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
############################################################################
2+
# apps/system/i3c/Makefile
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
include $(APPDIR)/Make.defs
22+
23+
MAINSRC = i3c_main.c
24+
25+
PROGNAME = i3c
26+
PRIORITY = SCHED_PRIORITY_DEFAULT
27+
STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE)
28+
MODULE = $(CONFIG_SYSTEM_I3CTOOL)
29+
30+
include $(APPDIR)/Application.mk

system/i3c/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# System / `i3c` I3C Tool
2+
3+
The I3C tool provides a way to debug I3C related problems. This README file will
4+
provide usage information for the I3C tools.
5+
6+
- System Requirements
7+
- I3C Driver
8+
- I2C Driver, If Has I2C Device
9+
- Configuration Options
10+
11+
# Configuration Options
12+
13+
- `CONFIG_NSH_BUILTIN_APPS` – Build the tools as an NSH built-in command.
14+
- `CONFIG_I3CTOOL_DEFBUS` – A default bus number (default `0`).
15+
16+
# Usage:
17+
18+
Write one data byte in single private transfer
19+
20+
i3c -b bus -m manufid -p partid -w 0xde
21+
22+
Write multiple data bytes in single private transfer
23+
24+
i3c -b bus -m manufid -p partid -w "0xde,0xad,0xbe,0xef"
25+
26+
Write multiple data bytes in multiple private transfers
27+
28+
i3c -b bus -m manufid -p partid -w "0xde,0xad" -w "0xbe,0xef"
29+
30+
Read multiple data bytes in single private transfer
31+
32+
i3c -b bus -m manufid -p partid -r <data_length>
33+
34+
Read multiple data bytes in multiple private transfer
35+
36+
i3c -b bus -m manufid -p partid -r <data_length> -r <data_length>
37+
38+
Read and write multiple data bytes in multiple private transfer
39+
40+
i3c -b bus -m manufid -p partid -w "0xde,0xad,0xbe,0xef" -r <data_length>
41+
42+
Get device information using PID
43+
44+
i3c -b bus -m manufid -p partid -g
45+
46+
Parameters:
47+
48+
1) bus: I3C bus number
49+
2) manufid: Manufacturer ID (upper 16 bits of device PID)
50+
3) partid: Part ID (middle 16 bits of device PID)
51+
4) <data_length>: Data length to read on this message
52+
53+
Note: The manufid and partid are extracted from the device's 48-bit Provisional
54+
ID (PID). To find these values, first use the -g option to get device information,
55+
then extract:
56+
- manufid = (PID >> 32) & 0xFFFF
57+
- partid = (PID >> 16) & 0xFFFF
58+
59+
# Example
60+
1. i3c -b 0 -m 0x01E0 -p 0x0001 -w 0xde
61+
2. i3c -b 0 -m 0x01E0 -p 0x0001 -w "0xde,0xad,0xbe,0xef"
62+
3. i3c -b 0 -m 0x01E0 -p 0x0001 -w "0xde,0xad" -w "0xbe,0xef"
63+
4. i3c -b 0 -m 0x01E0 -p 0x0001 -r 0x10
64+
5. i3c -b 0 -m 0x01E0 -p 0x0001 -r 0x10 -r 0x10
65+
6. i3c -b 0 -m 0x01E0 -p 0x0001 -w "0xde,0xad,0xbe,0xef" -r 0x10
66+
7. i3c -b 0 -m 0x01E0 -p 0x0001 -g
67+
68+
# Migration from target_addr
69+
70+
Previous versions used `-d targetaddr` to specify the device address. The new
71+
version uses `-m manufid -p partid` to identify devices by their unique PID.
72+
73+
To migrate:
74+
1. Get device PID using the old command (if available):
75+
```
76+
i3c -b 0 -d <addr> -g
77+
```
78+
Output: `i3c_device_info - pid 0x01E000010000XXXX`
79+
80+
2. Extract manufid and partid from PID:
81+
```
82+
manufid = 0x01E0 (bits 47-32)
83+
partid = 0x0001 (bits 31-16)
84+
```
85+
86+
3. Use new command format:
87+
```
88+
i3c -b 0 -m 0x01E0 -p 0x0001 -r 0x10
89+
```

0 commit comments

Comments
 (0)