Skip to content

Commit 710f712

Browse files
SorinOlarikr-t
andauthored
Add ethernet shield support for b_u585i_iot02a (#164)
* supervisor(zephyr): add ethernet shield support for W5500 and enc28j60 * docs: add documentation for b_u585i_iot02a.md --------- Signed-off-by: SorinO <sorin.olari2@gmail.com> Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com> Co-authored-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
1 parent d9eed5d commit 710f712

12 files changed

Lines changed: 312 additions & 12 deletions

File tree

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
# Zephyr Board: `b_u585i_iot02a`
2+
3+
The [Discovery Kit for IoT Node with STM32U5 Series](https://www.st.com/en/evaluation-tools/b-u585i-iot02a.html) is a demonstration and development board featuring the **STM32U585AIUx** MCU.
4+
5+
Apart from the SoC, internal 2MB flash (which usually holds the application), there is an external 64MB flash chip (which is usually used for the storage_partition). And also features an 8MB PSRAM which we use for the container memory.
6+
7+
It is well supported by Zephyr, and more information can be found in Zephyr's [B-U585I-IOT02A Discovery kit](https://docs.zephyrproject.org/latest/boards/st/b_u585i_iot02a/doc/index.html) documentation.
8+
9+
## Networking
10+
11+
### Wi-Fi Module Not Supported
12+
13+
The onboard EMW3080 Wi-Fi module is **not supported** by Zephyr. For network connectivity, you **must use an Ethernet shield**.
14+
15+
### Supported Ethernet Shields
16+
17+
The board supports the following Ethernet shields, which connect via **SPI1**:
18+
19+
#### ENC28J60 (Microchip)
20+
21+
- **References**:
22+
- [Microchip ENC28J60 Datasheet](https://ww1.microchip.com/downloads/en/DeviceDoc/39662e.pdf)
23+
- [Zephyr ENC28J60 Driver Documentation](https://docs.zephyrproject.org/latest/hardware/peripherals/ethernet.html#microchip-enc28j60)
24+
25+
#### W5500 (WizNet)
26+
27+
- **References**:
28+
- [WizNet W5500 Datasheet](https://docs.wiznet.io/Product/iEthernet/W5500/Datasheet)
29+
- [Zephyr W5500 Driver Documentation](https://docs.zephyrproject.org/latest/hardware/peripherals/ethernet.html#wiznet-w5500)
30+
31+
### Hardware Connections
32+
33+
The Ethernet shields connect to the board via **SPI1** (Serial Peripheral Interface bus 1). This is the Ocre supported communication interface for these shields.
34+
35+
#### SPI1 Pin Configuration
36+
37+
All Ethernet shields use the same SPI1 pins on the b_u585i_iot02a board:
38+
39+
| Function | Pin name | STM32U5 pin | Connector |
40+
| --------- | ------------ | ----------- | --------- |
41+
| SPI1_NSS | PWM/CS/D10 | PE12 | CN13 |
42+
| SPI1_SCK | SCK/D13 | PE13 | CN13 |
43+
| SPI1_MISO | MISO/D12 | PE14 | CN13 |
44+
| SPI1_MOSI | PWM/MOSI/D11 | PE15 | CN13 |
45+
| GND | GND | - | CN13 |
46+
| VCC | 5V | - | CN17 |
47+
48+
#### Important:
49+
50+
Each shield type uses a different interrupt GPIO pin:
51+
52+
- **ENC28J60 Shield**: Interrupt on **PC1** (Pin name: **D8**) on **CN13**
53+
- **W5500 Shield**: Interrupt on **PD15** (Pin name: **D2**) on **CN14**
54+
55+
### Detailed Connection Instructions
56+
57+
#### Power and Ground
58+
59+
1. Connect shield **GND** pin to any **GND** pin on the board
60+
2. Connect shield **5V** pin to any **5V** pin on the board
61+
62+
#### SPI1 Connections
63+
64+
3. Connect shield **CS** pin to board **PE12** (SPI1 Chip Select)
65+
4. Connect shield **CLK** pin to board **PE13** (SPI1 Serial Clock)
66+
5. Connect shield **MISO**/**SO** pin to board **PE14** (SPI1 Data In)
67+
6. Connect shield **MOSI**/**SI** pin to board **PE15** (SPI1 Data Out)
68+
69+
#### Interrupt Connection
70+
71+
For **ENC28J60 shields**: 7. Connect shield **INT** pin to board **PC1**
72+
73+
For **W5500 shields**: 7. Connect shield **INT** pin to board **PD15**
74+
75+
More detailed information can be found in [User Manual](https://www.st.com/resource/en/user_manual/um2839-discovery-kit-for-iot-node-with-stm32u5-series-stmicroelectronics.pdf).
76+
77+
## Build Instructions
78+
79+
### Prerequisites
80+
81+
Start with [Getting Started with Zephyr](../../GetStartedZephyr.md) to get a working build environment.
82+
83+
### Building Without Shield (No Networking)
84+
85+
For development or testing without networking:
86+
87+
```bash
88+
west build -p always -b b_u585i_iot02a src/samples/supervisor/zephyr/
89+
```
90+
91+
### Building with ENC28J60 Ethernet Shield
92+
93+
To build with the ENC28J60 shield:
94+
95+
```bash
96+
west build -p always -b b_u585i_iot02a --shield enc28j60 src/samples/supervisor/zephyr/
97+
```
98+
99+
Replace `enc28j60` with `wiznet_w5500` if WIZnet W5500 ethernet shield is used.
100+
101+
## Flashing
102+
103+
### First Flash (with Preloaded Images)
104+
105+
To flash the application and preloaded container images in the storage partition:
106+
107+
```bash
108+
west flash --hex-file build/zephyr/merged.hex
109+
```
110+
111+
This writes both:
112+
113+
- Application code to internal flash (2 MB)
114+
- 16MB of storage partition to external flash (64 MB total) with preloaded WASM images
115+
116+
**Time**: May take 1-2 minutes depending on image size.
117+
118+
For more information about preloaded images, see [Build System Zephyr](../../BuildSystemZephyr.md).
119+
120+
### Subsequent Flashes (Development)
121+
122+
After the first flash with `merged.hex`, you can flash just the application code:
123+
124+
```bash
125+
west flash
126+
```
127+
128+
This only updates the application, leaving the storage partition intact.
129+
130+
## Serial Console
131+
132+
The serial console can be accessed using `picocom`.
133+
This works both on native Linux and WSL, with a small setup.
134+
135+
### Native Linux
136+
137+
The board usually appears as:
138+
139+
```bash
140+
/dev/ttyACM0
141+
```
142+
143+
Check with:
144+
145+
```bash
146+
ls /dev/ttyACM*
147+
```
148+
149+
### WSL (Windows Subsystem for Linux)
150+
151+
WSL does not automatically expose USB serial devices.
152+
You must attach the ST-Link device using `usbipd`.
153+
154+
**1. Install usbipd on Windows**
155+
156+
From PowerShell (Admin):
157+
158+
```bash
159+
winget install usbipd
160+
```
161+
162+
**2. List USB devices**
163+
164+
```bash
165+
usbipd list
166+
```
167+
168+
**3. Attach device to WSL (look for ST-Link / STMicroelectronics)**
169+
170+
```bash
171+
usbipd attach --busid <BUS_ID> --wsl
172+
```
173+
174+
Example:
175+
176+
```bash
177+
usbipd attach --busid 1-4 --wsl
178+
```
179+
180+
**4. Verify in WSL**
181+
182+
```bash
183+
ls /dev/ttyACM*
184+
```
185+
186+
You should now see:
187+
188+
```bash
189+
/dev/ttyACM0
190+
```
191+
192+
### Connect to the serial console
193+
194+
Open the serial console
195+
Run picocom with 115200 baud (default Zephyr):
196+
197+
```bash
198+
picocom -b 115200 /dev/ttyACM0
199+
```
200+
201+
Exit with:
202+
203+
```bash
204+
Ctrl + A, then Ctrl + X
205+
```
206+
207+
## Test Network Connectivity
208+
209+
If the steps above were followed, you should see in the console:
210+
211+
```bash
212+
ethernet@0: Link up
213+
```
214+
215+
The board automatically gets an IPv4 address, to see it type in the console:
216+
217+
```bash
218+
ocre:~$ net iface
219+
```
220+
221+
**Output:**
222+
223+
```bash
224+
Interface eth0 (index 1)
225+
===========================
226+
Device : ethernet@0
227+
Link state: UP
228+
IPv4 unicast addresses (1):
229+
192.168.18.17/255.255.255.0 DHCP preferred
230+
```
231+
232+
## References
233+
234+
- [Zephyr B-U585I-IOT02A Documentation](https://docs.zephyrproject.org/latest/boards/st/b_u585i_iot02a/doc/index.html)
235+
- [Board Schematics and Datasheet](https://www.st.com/en/evaluation-tools/b-u585i-iot02a.html) (available from ST)
236+
- [Supervisor Sample Documentation](../../samples/supervisor.md)
237+
238+
See the main documentation for:
239+
240+
- [Zephyr Build System](../../BuildSystemZephyr.md)
241+
- [Get started Zephyr](../../GetStartedZephyr.md)

src/samples/supervisor/zephyr/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ cmake_minimum_required(VERSION 3.20.0)
1111
# comment out to use the ocre module provided by zephyr
1212
list(APPEND ZEPHYR_EXTRA_MODULES ${CMAKE_CURRENT_LIST_DIR}/../../../..)
1313

14+
# Include custom boards and shields
15+
list(APPEND BOARD_ROOT ${CMAKE_CURRENT_LIST_DIR})
16+
1417
# append the fstab overlay file to the list of DTC overlay files
1518
list(APPEND EXTRA_DTC_OVERLAY_FILE fstab.overlay)
1619

src/samples/supervisor/zephyr/boards/b_u585i_iot02a.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ CONFIG_OCRE_MERGE_HEX=y
1010
CONFIG_MEMC=y
1111
CONFIG_MEMC_STM32_OSPI_PSRAM=y
1212
CONFIG_SHARED_MULTI_HEAP=y
13+
14+
# Networking
15+
CONFIG_NET_CONNECTION_MANAGER=y
16+
CONFIG_NET_CONFIG_SETTINGS=y

src/samples/supervisor/zephyr/boards/b_u585i_iot02a.overlay

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,6 @@
8181
};
8282
};
8383

84-
&spi1 {
85-
eth0: ethernet@0 {
86-
status = "okay";
87-
reg = <0>;
88-
// W5500 Ethernet Shield
89-
compatible = "wiznet,w5500";
90-
int-gpios = <&gpiod 15 GPIO_ACTIVE_LOW>;
91-
spi-max-frequency = <32000000>;
92-
local-mac-address = [ 00 80 00 01 02 03 ];
93-
};
94-
};
95-
9684
/* Flash partitions - 2MB total, no MCUboot */
9785
&flash0 {
9886
/delete-node/ partitions;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
if SHIELD_ENC28J60
3+
4+
config NET_L2_ETHERNET
5+
default y
6+
7+
config ETH_ENC28J60
8+
default y
9+
10+
config ETH_ENC28J60_RX_THREAD_STACK_SIZE
11+
default 2048
12+
13+
endif # SHIELD_ENC28J60
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
config SHIELD_ENC28J60
2+
def_bool $(shields_list_contains,enc28j60)
3+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
&spi1 {
2+
eth0: ethernet@0 {
3+
status = "okay";
4+
compatible = "microchip,enc28j60";
5+
reg = <0>;
6+
spi-max-frequency = <10000000>;
7+
int-gpios = <&gpioc 1 GPIO_ACTIVE_LOW>;
8+
local-mac-address = [ 00 80 00 01 02 03 ];
9+
};
10+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
shield:
2+
name: enc28j60
3+
full_name: Microchip ENC28J60 Ethernet Shield
4+
vendor: microchip
5+
supported_features:
6+
- ethernet
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
if SHIELD_WIZNET_W5500
3+
4+
config NET_L2_ETHERNET
5+
default y
6+
7+
config ETH_W5500
8+
default y
9+
10+
config ETH_W5500_RX_THREAD_STACK_SIZE
11+
default 2048
12+
13+
endif # SHIELD_WIZNET_W5500
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
config SHIELD_WIZNET_W5500
2+
def_bool $(shields_list_contains,wiznet_w5500)

0 commit comments

Comments
 (0)