Skip to content

Commit 5880865

Browse files
committed
Add needed setup for s1 board
1 parent 6fe4e61 commit 5880865

File tree

4 files changed

+313
-0
lines changed

4 files changed

+313
-0
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# BeagleV-Fire Platform Support
2+
3+
ESP-Hosted support for BeagleV-Fire (Microchip PolarFire SoC RISC-V platform).
4+
5+
## Hardware
6+
7+
- **Board**: BeagleV-Fire
8+
- **SoC**: Microchip PolarFire SoC (RISC-V)
9+
- **Interface**: SPI0
10+
- **ESP32**: Any ESP32 module (ESP32-WROOM-32, DevKitC, etc.)
11+
12+
## Pin Connections
13+
14+
| Function | ESP32 GPIO | ESP32 Physical Pin | BeagleV-Fire Pin | BeagleV GPIO | Description |
15+
| -------------- | ---------- | ------------------ | ---------------- | ------------ | --------------- |
16+
| **SPI MOSI** | GPIO 13 | D13 | P9_18 | SPI0_MOSI | SPI Master Out |
17+
| **SPI MISO** | GPIO 12 | D12 | P9_21 | SPI0_MISO | SPI Master In |
18+
| **SPI CLK** | GPIO 14 | D14 | P9_22 | SPI0_CLK | SPI Clock |
19+
| **SPI CS** | GPIO 15 | D15 | P9_17 | SPI0_CS0 | SPI Chip Select |
20+
| **Handshake** | GPIO 26 | D26 | P8_03 | 512 | MSS GPIO_2[0] |
21+
| **Data Ready** | GPIO 25 | D25 | P8_04 | 513 | MSS GPIO_2[1] |
22+
| **Reset** | EN | EN | P8_05 | 514 | MSS GPIO_2[2] |
23+
| **Ground** | GND | GND | P9_1 or P9_2 | GND | Common Ground |
24+
25+
## Configuration Details
26+
27+
### Hardware Configuration
28+
29+
- **SPI Interface**: SPI0 on BeagleV-Fire
30+
- **GPIO Chip**: MSS GPIO_2 (base 512)
31+
- **Reset Pin**: GPIO 514 (configured in `beaglev_init.sh`)
32+
- **Handshake Pin**: GPIO 512 (configured in `spi/esp_spi.h`)
33+
- **Data Ready Pin**: GPIO 513 (configured in `spi/esp_spi.h`)
34+
35+
## Files in This Directory
36+
37+
- **beaglev_init.sh** - Modified initialization script for BeagleV-Fire
38+
- **beaglev-esp-hosted.dts** - Device tree overlay for SPI configuration
39+
- **patches/esp_spi.h.patch** - GPIO pin modifications
40+
41+
## Quick Setup
42+
43+
### 1. Apply Device Tree Overlay
44+
45+
```bash
46+
# Compile overlay
47+
dtc -O dtb -o beaglev-esp-hosted.dtbo -b 0 -@ beaglev-esp-hosted.dts
48+
49+
# Copy to firmware directory
50+
sudo cp beaglev-esp-hosted.dtbo /lib/firmware/
51+
52+
# Apply overlay
53+
sudo mkdir -p /sys/kernel/config/device-tree/overlays/esp-hosted
54+
echo beaglev-esp-hosted.dtbo | sudo tee /sys/kernel/config/device-tree/overlays/esp-hosted/path
55+
56+
# Verify
57+
cat /sys/kernel/config/device-tree/overlays/esp-hosted/status # Should show "applied"
58+
ls /dev/spidev0.0 # Should exist
59+
```
60+
61+
### 2. Apply GPIO Pin Patch (Optional)
62+
63+
If not already applied in your fork:
64+
65+
```bash
66+
cd ~/esp-hosted
67+
patch -p1 < esp_hosted_ng/host/platforms/beaglev-fire/patches/esp_spi.h.patch
68+
```
69+
70+
Or manually edit `esp_hosted_ng/host/linux/host_driver/esp32/spi/esp_spi.h`:
71+
72+
```c
73+
#define HANDSHAKE_PIN 513 // Changed from 22
74+
#define SPI_DATA_READY_PIN 514 // Changed from 27
75+
```
76+
77+
### 3. Copy Init Script
78+
79+
```bash
80+
cp esp_hosted_ng/host/platforms/beaglev-fire/beaglev_init.sh \
81+
esp_hosted_ng/host/beaglev_init.sh
82+
chmod +x esp_hosted_ng/host/beaglev_init.sh
83+
```
84+
85+
### 4. Build and Load Driver
86+
87+
```bash
88+
cd esp_hosted_ng/host
89+
sudo ./beaglev_init.sh spi
90+
```
91+
92+
### 5. Verify
93+
94+
```bash
95+
# Check module loaded
96+
lsmod | grep esp32_spi
97+
98+
# Check interface
99+
ip link show wlan0
100+
101+
# Test WiFi
102+
sudo iw dev wlan0 scan
103+
```
104+
105+
## Platform Differences vs Raspberry Pi
106+
107+
| Aspect | Raspberry Pi | BeagleV-Fire |
108+
| --------------- | ----------------------- | ------------------ |
109+
| Architecture | ARM | RISC-V |
110+
| Build | ARCH=arm, CROSS_COMPILE | ARCH=riscv, native |
111+
| Handshake GPIO | 22 | 513 |
112+
| Data Ready GPIO | 27 | 514 |
113+
| Reset GPIO | 6 | 512 |
114+
| GPIO Tool | raspi-gpio | Device tree |
115+
| SPI Driver | bcm2835 | spi-microchip-core |
116+
117+
## Automated Setup
118+
119+
For automated setup, see: https://github.com/YOUR-ORG/s0-wifi-setup
120+
121+
## Troubleshooting
122+
123+
**No /dev/spidev0.0**:
124+
125+
```bash
126+
# Load SPI modules
127+
sudo modprobe spidev
128+
sudo modprobe spi-microchip-core
129+
sudo modprobe spi-microchip-core-qspi
130+
131+
# Reboot if needed
132+
sudo reboot
133+
```
134+
135+
**Module won't load**:
136+
137+
```bash
138+
# Check kernel headers
139+
ls /lib/modules/$(uname -r)/build/include/linux/module.h
140+
141+
# If missing, rebuild kernel headers
142+
```
143+
144+
**No wlan0 interface**:
145+
146+
```bash
147+
# Check ESP32 is powered and connected
148+
# Check kernel logs
149+
dmesg | grep -i esp
150+
151+
# Look for "ESP peripheral capabilities"
152+
```
153+
154+
## Performance
155+
156+
- **WiFi Throughput**: 5-10 Mbps (SPI limited at 10 MHz)
157+
- **Latency**: 20-50 ms
158+
- **SPI Speed**: Default 10 MHz (configurable to 20 MHz in device tree)
159+
160+
## Notes
161+
162+
- Bluetooth requires `bluetooth` kernel module (not in default BeagleV kernel)
163+
- WiFi works independently of Bluetooth
164+
- SPI speed can be increased to 20 MHz for better performance (experimental)
165+
166+
## Support
167+
168+
For issues specific to BeagleV-Fire integration:
169+
170+
- Issues: https://github.com/YOUR-ORG/esp-hosted/issues
171+
- Tag: `platform:beaglev-fire`
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/dts-v1/;
2+
/plugin/;
3+
4+
/ {
5+
compatible = "microchip,mpfs-icicle-kit";
6+
7+
fragment@0 {
8+
target = <&spi0>;
9+
__overlay__ {
10+
#address-cells = <1>;
11+
#size-cells = <0>;
12+
13+
status = "okay";
14+
15+
spidev@0 {
16+
compatible = "rohm,dh2228fv";
17+
reg = <0>;
18+
spi-max-frequency = <10000000>;
19+
};
20+
};
21+
};
22+
};
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0-only
3+
#
4+
# Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD
5+
#
6+
# This is modified version of rpi_init.sh for BeagleV-Fire (RISC-V)
7+
#
8+
9+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+
11+
# Platform-specific settings for BeagleV-Fire
12+
resetpin=512 # BeagleV GPIO for ESP32 reset (was 6 for RPi)
13+
14+
# WLAN/BT initialization
15+
wlan_init() {
16+
echo "WLAN init"
17+
18+
cd "$SCRIPT_DIR" || exit 1
19+
20+
# Build for RISC-V architecture (not ARM)
21+
make target=$IF_TYPE \
22+
ARCH=riscv \
23+
KERNEL=/lib/modules/$(uname -r)/build
24+
25+
if [ $? -ne 0 ]; then
26+
echo "Failed to build driver"
27+
exit 1
28+
fi
29+
30+
# Insert module
31+
sudo insmod esp32_spi.ko
32+
33+
if [ $? -ne 0 ]; then
34+
echo "Failed to insert module"
35+
exit 1
36+
fi
37+
38+
sleep 2
39+
echo "esp32_spi module loaded"
40+
}
41+
42+
bt_init() {
43+
echo "Bluetooth init"
44+
45+
# Note: raspi-gpio commands removed (BeagleV doesn't have this utility)
46+
# GPIO configuration is handled by device tree
47+
48+
echo "Bluetooth initialization skipped (requires kernel support)"
49+
}
50+
51+
# Main execution
52+
if [ "$#" -ne 1 ]; then
53+
echo "Usage: $0 <spi|sdio>"
54+
exit 1
55+
fi
56+
57+
IF_TYPE=$1
58+
59+
if [ "$IF_TYPE" != "spi" ] && [ "$IF_TYPE" != "sdio" ]; then
60+
echo "Error: Interface type must be 'spi' or 'sdio'"
61+
exit 1
62+
fi
63+
64+
echo "Interface type: $IF_TYPE"
65+
66+
# Note: spidev_disabler not needed on BeagleV-Fire
67+
# SPI device configuration is handled by custom device tree overlay
68+
69+
# Reset ESP32
70+
if [ -d /sys/class/gpio/gpio$resetpin ]; then
71+
echo "GPIO $resetpin already exported"
72+
else
73+
echo $resetpin > /sys/class/gpio/export
74+
fi
75+
76+
echo out > /sys/class/gpio/gpio$resetpin/direction
77+
echo "Resetting ESP32 using GPIO $resetpin"
78+
echo 0 > /sys/class/gpio/gpio$resetpin/value
79+
sleep 1
80+
echo 1 > /sys/class/gpio/gpio$resetpin/value
81+
sleep 2
82+
83+
# Load kernel modules
84+
if [ $(lsmod | grep bluetooth | wc -l) = "0" ]; then
85+
echo "Attempting to load bluetooth module..."
86+
sudo modprobe bluetooth 2>/dev/null || echo "Bluetooth not available, skipping"
87+
fi
88+
89+
if [ $(lsmod | grep cfg80211 | wc -l) = "0" ]; then
90+
echo "Attempting to load cfg80211 module..."
91+
sudo modprobe cfg80211 2>/dev/null || echo "cfg80211 not available, will try to build anyway"
92+
fi
93+
94+
# Initialize WLAN (always attempt, even if bluetooth failed)
95+
wlan_init
96+
97+
echo "Setup complete!"
98+
echo "Check dmesg for ESP32 initialization messages:"
99+
echo " dmesg | grep -i esp"
100+
echo ""
101+
echo "If successful, wlan0 interface should be available:"
102+
echo " ip link show wlan0"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
diff --git a/esp_hosted_ng/host/linux/host_driver/esp32/spi/esp_spi.h b/esp_hosted_ng/host/linux/host_driver/esp32/spi/esp_spi.h
2+
index abcdef1..1234567 100644
3+
--- a/esp_hosted_ng/host/linux/host_driver/esp32/spi/esp_spi.h
4+
+++ b/esp_hosted_ng/host/linux/host_driver/esp32/spi/esp_spi.h
5+
@@ -17,11 +17,11 @@
6+
#include "esp_api.h"
7+
8+
#ifndef HANDSHAKE_PIN
9+
-#define HANDSHAKE_PIN 22
10+
+#define HANDSHAKE_PIN 513
11+
#endif
12+
13+
#ifndef SPI_DATA_READY_PIN
14+
-#define SPI_DATA_READY_PIN 27
15+
+#define SPI_DATA_READY_PIN 514
16+
#endif
17+
18+
#ifndef RESETPIN

0 commit comments

Comments
 (0)