-
Notifications
You must be signed in to change notification settings - Fork 2
NOISSUE-Add WiFi to Beagleboard via Esp32 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
26da6af
326c834
24a849a
7c1edf1
25d3af9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| # BeagleV-Fire Platform Support | ||
|
|
||
| ESP-Hosted support for BeagleV-Fire (Microchip PolarFire SoC RISC-V platform). | ||
|
|
||
| ## Hardware | ||
|
|
||
| - **Board**: BeagleV-Fire | ||
| - **SoC**: Microchip PolarFire SoC (RISC-V) | ||
| - **Interface**: SPI0 | ||
| - **ESP32**: Any ESP32 module (ESP32-WROOM-32, DevKitC, etc.) | ||
|
|
||
| ## Pin Connections | ||
|
|
||
| | Function | ESP32 GPIO | ESP32 Physical Pin | BeagleV-Fire Pin | BeagleV GPIO | Description | | ||
| | -------------- | ---------- | ------------------ | ---------------- | ------------ | --------------- | | ||
| | **SPI MOSI** | GPIO 13 | D13 | P9_18 | SPI0_MOSI | SPI Master Out | | ||
| | **SPI MISO** | GPIO 12 | D12 | P9_21 | SPI0_MISO | SPI Master In | | ||
| | **SPI CLK** | GPIO 14 | D14 | P9_22 | SPI0_CLK | SPI Clock | | ||
| | **SPI CS** | GPIO 15 | D15 | P9_17 | SPI0_CS0 | SPI Chip Select | | ||
| | **Handshake** | GPIO 26 | D26 | P8_03 | 512 | MSS GPIO_2[0] | | ||
| | **Data Ready** | GPIO 25 | D25 | P8_04 | 513 | MSS GPIO_2[1] | | ||
| | **Reset** | EN | EN | P8_05 | 514 | MSS GPIO_2[2] | | ||
| | **Ground** | GND | GND | P9_1 or P9_2 | GND | Common Ground | | ||
|
|
||
| ## Configuration Details | ||
|
|
||
| ### Hardware Configuration | ||
|
|
||
| - **SPI Interface**: SPI0 on BeagleV-Fire | ||
| - **GPIO Chip**: MSS GPIO_2 (base 512) | ||
| - **Reset Pin**: GPIO 514 (configured in `beaglev_init.sh`) | ||
| - **Handshake Pin**: GPIO 512 (configured in `spi/esp_spi.h`) | ||
| - **Data Ready Pin**: GPIO 513 (configured in `spi/esp_spi.h`) | ||
|
|
||
| ## Files in This Directory | ||
|
|
||
| - **beaglev_init.sh** - Modified initialization script for BeagleV-Fire | ||
| - **beaglev-esp-hosted.dts** - Device tree overlay for SPI configuration | ||
| - **patches/esp_spi.h.patch** - GPIO pin modifications | ||
|
|
||
| ## Quick Setup | ||
|
|
||
| ### 1. Apply Device Tree Overlay | ||
|
|
||
| ```bash | ||
| # Compile overlay | ||
| dtc -O dtb -o beaglev-esp-hosted.dtbo -b 0 -@ beaglev-esp-hosted.dts | ||
|
|
||
| # Copy to firmware directory | ||
| sudo cp beaglev-esp-hosted.dtbo /lib/firmware/ | ||
|
|
||
| # Apply overlay | ||
| sudo mkdir -p /sys/kernel/config/device-tree/overlays/esp-hosted | ||
| echo beaglev-esp-hosted.dtbo | sudo tee /sys/kernel/config/device-tree/overlays/esp-hosted/path | ||
|
|
||
| # Verify | ||
| cat /sys/kernel/config/device-tree/overlays/esp-hosted/status # Should show "applied" | ||
| ls /dev/spidev0.0 # Should exist | ||
| ``` | ||
|
|
||
| ### 2. Apply GPIO Pin Patch | ||
|
|
||
| If not already applied in your fork: | ||
|
|
||
| ```bash | ||
| cd ~/esp-hosted | ||
| patch -p1 < esp_hosted_ng/host/platforms/beaglev-fire/patches/esp_spi.h.patch | ||
| ``` | ||
|
|
||
| Or manually edit `esp_hosted_ng/host/linux/host_driver/esp32/spi/esp_spi.h`: | ||
|
|
||
| ```c | ||
| #define HANDSHAKE_PIN 513 // Changed from 22 | ||
| #define SPI_DATA_READY_PIN 514 // Changed from 27 | ||
| ``` | ||
|
|
||
| ### 3. Copy Init Script | ||
|
|
||
| ```bash | ||
| cp esp_hosted_ng/host/platforms/beaglev-fire/beaglev_init.sh \ | ||
| esp_hosted_ng/host/beaglev_init.sh | ||
| chmod +x esp_hosted_ng/host/beaglev_init.sh | ||
| ``` | ||
|
|
||
| ### 4. Build and Load Driver | ||
|
|
||
| ```bash | ||
| cd esp_hosted_ng/host | ||
| sudo ./beaglev_init.sh spi | ||
| ``` | ||
|
|
||
| ### 5. Verify | ||
|
|
||
| ```bash | ||
| # Check module loaded | ||
| lsmod | grep esp32_spi | ||
|
|
||
| # Check interface | ||
| ip link show wlan0 | ||
|
|
||
| # Test WiFi | ||
| sudo iw dev wlan0 scan | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| **No /dev/spidev0.0**: | ||
|
|
||
| ```bash | ||
| # Load SPI modules | ||
| sudo modprobe spidev | ||
| sudo modprobe spi-microchip-core | ||
| sudo modprobe spi-microchip-core-qspi | ||
|
|
||
| # Reboot if needed | ||
| sudo reboot | ||
| ``` | ||
|
|
||
| **Module won't load**: | ||
|
|
||
| ```bash | ||
| # Check kernel headers | ||
| ls /lib/modules/$(uname -r)/build/include/linux/module.h | ||
|
|
||
| # If missing, rebuild kernel headers | ||
| ``` | ||
|
|
||
| **No wlan0 interface**: | ||
|
|
||
| ```bash | ||
| # Check ESP32 is powered and connected | ||
| # Check kernel logs | ||
| dmesg | grep -i esp | ||
|
|
||
| # Look for "ESP peripheral capabilities" | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| - Bluetooth requires `bluetooth` kernel module (not in default BeagleV kernel) | ||
| - WiFi works independently of Bluetooth | ||
| - SPI speed can be increased to 20 MHz for better performance (experimental) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /dts-v1/; | ||
| /plugin/; | ||
|
|
||
| /* ESP32 WiFi on SPI0 - BeagleV-Fire */ | ||
|
|
||
| / { | ||
| compatible = "microchip,mpfs-beaglev-fire"; | ||
| }; | ||
|
|
||
| &{/soc/spi@20108000} { | ||
| status = "okay"; | ||
|
|
||
| esp32@0 { | ||
| compatible = "espressif,esp32"; | ||
| reg = <0>; | ||
| spi-max-frequency = <10000000>; | ||
| spi-cpha; | ||
| spi-cpol; | ||
|
|
||
| /* GPIO_2 control pins */ | ||
| reset-gpios = <0x13 0x02 0x01>; /* P8_05 */ | ||
| handshake-gpios = <0x13 0x00 0x00>; /* P8_03 */ | ||
| interrupt-parent = <0x13>; | ||
| interrupts = <0x01 0x02>; /* P8_04 */ | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| #!/bin/bash | ||
| # SPDX-License-Identifier: GPL-2.0-only | ||
| # | ||
| # Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD | ||
dorcaslitunya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # | ||
| # This is modified version of rpi_init.sh for BeagleV-Fire (RISC-V) | ||
| # | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| # Platform-specific settings for BeagleV-Fire | ||
| resetpin=512 # BeagleV GPIO for ESP32 reset (was 6 for RPi) | ||
|
|
||
| # WLAN/BT initialization | ||
| wlan_init() { | ||
| echo "WLAN init" | ||
|
|
||
| cd "$SCRIPT_DIR" || exit 1 | ||
|
|
||
| # Build for RISC-V architecture (not ARM) | ||
| make target=$IF_TYPE \ | ||
| ARCH=riscv \ | ||
| KERNEL=/lib/modules/$(uname -r)/build | ||
|
|
||
| if [ $? -ne 0 ]; then | ||
| echo "Failed to build driver" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Insert module | ||
| sudo insmod esp32_spi.ko | ||
|
|
||
| if [ $? -ne 0 ]; then | ||
| echo "Failed to insert module" | ||
| exit 1 | ||
| fi | ||
|
|
||
| sleep 2 | ||
| echo "esp32_spi module loaded" | ||
| } | ||
|
|
||
| bt_init() { | ||
| echo "Bluetooth init" | ||
|
|
||
| # Note: raspi-gpio commands removed (BeagleV doesn't have this utility) | ||
| # GPIO configuration is handled by device tree | ||
|
|
||
| echo "Bluetooth initialization skipped (requires kernel support)" | ||
| } | ||
|
|
||
| # Main execution | ||
| if [ "$#" -ne 1 ]; then | ||
| echo "Usage: $0 <spi|sdio>" | ||
| exit 1 | ||
| fi | ||
|
|
||
| IF_TYPE=$1 | ||
|
|
||
| if [ "$IF_TYPE" != "spi" ] && [ "$IF_TYPE" != "sdio" ]; then | ||
| echo "Error: Interface type must be 'spi' or 'sdio'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Interface type: $IF_TYPE" | ||
|
|
||
| # Note: spidev_disabler not needed on BeagleV-Fire | ||
| # SPI device configuration is handled by custom device tree overlay | ||
|
|
||
| # Reset ESP32 | ||
| if [ -d /sys/class/gpio/gpio$resetpin ]; then | ||
| echo "GPIO $resetpin already exported" | ||
| else | ||
| echo $resetpin > /sys/class/gpio/export | ||
| fi | ||
|
|
||
| echo out > /sys/class/gpio/gpio$resetpin/direction | ||
| echo "Resetting ESP32 using GPIO $resetpin" | ||
| echo 0 > /sys/class/gpio/gpio$resetpin/value | ||
| sleep 1 | ||
| echo 1 > /sys/class/gpio/gpio$resetpin/value | ||
| sleep 2 | ||
|
|
||
| # Load kernel modules | ||
| if [ $(lsmod | grep bluetooth | wc -l) = "0" ]; then | ||
| echo "Attempting to load bluetooth module..." | ||
| sudo modprobe bluetooth 2>/dev/null || echo "Bluetooth not available, skipping" | ||
| fi | ||
|
|
||
| if [ $(lsmod | grep cfg80211 | wc -l) = "0" ]; then | ||
| echo "Attempting to load cfg80211 module..." | ||
| sudo modprobe cfg80211 2>/dev/null || echo "cfg80211 not available, will try to build anyway" | ||
| fi | ||
|
|
||
| # Initialize WLAN (always attempt, even if bluetooth failed) | ||
| wlan_init | ||
|
|
||
| echo "Setup complete!" | ||
| echo "Check dmesg for ESP32 initialization messages:" | ||
| echo " dmesg | grep -i esp" | ||
| echo "" | ||
| echo "If successful, wlan0 interface should be available:" | ||
| echo " ip link show wlan0" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| 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 | ||
| index abcdef1..1234567 100644 | ||
| --- 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 | ||
| @@ -17,11 +17,11 @@ | ||
| #include "esp_api.h" | ||
|
|
||
| #ifndef HANDSHAKE_PIN | ||
| -#define HANDSHAKE_PIN 22 | ||
| +#define HANDSHAKE_PIN 513 | ||
| #endif | ||
|
|
||
| #ifndef SPI_DATA_READY_PIN | ||
| -#define SPI_DATA_READY_PIN 27 | ||
| +#define SPI_DATA_READY_PIN 514 | ||
| #endif | ||
|
|
||
| #ifndef RESETPIN |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # s1 Board WiFi Setup | ||
|
|
||
| Automated WiFi setup for s1 board (BeagleV-Fire + ESP32). | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```bash | ||
| # On s1 board | ||
| sudo ./setup-s1.sh | ||
|
|
||
| # On dev machine (for ESP32) | ||
| cd esp-firmware | ||
| ./flash-esp32.sh /dev/ttyUSB0 | ||
| ``` | ||
|
|
||
| ## What's Included | ||
|
|
||
| - **setup-s1.sh** - Complete automated setup for s1 | ||
| - **kernel/build-kernel-modules.sh** - Kernel headers and build environment | ||
| - **esp-firmware/flash-esp32.sh** - ESP32 firmware flashing automation | ||
| - **overlays/beaglev-esp-hosted.dts** - Device tree overlay for SPI | ||
| - **scripts/setup-device-tree.sh** - DT compilation and application | ||
| - **scripts/verify-setup.sh** - Verify everything works | ||
|
|
||
| ## Hardware Connections (s1 Board) | ||
|
|
||
| | ESP32 Pin | s1 Board Pin | Function | | ||
| | --------- | ------------ | --------- | | ||
| | GPIO13 | SPI0_MOSI | MOSI | | ||
| | GPIO12 | SPI0_MISO | MISO | | ||
| | GPIO14 | SPI0_CLK | Clock | | ||
| | GPIO15 | SPI0_CS0 | CS | | ||
| | GPIO2 | GPIO 513 | Handshake | | ||
| | GPIO4 | GPIO 514 | Data Rdy | | ||
| | EN | GPIO 512 | Reset | | ||
| | GND | GND | Ground | | ||
|
|
||
| ## Key Changes from Upstream esp-hosted | ||
|
|
||
| ### For BeagleV-Fire (RISC-V) | ||
|
|
||
| 1. **Architecture**: `ARCH=arm` → `ARCH=riscv` | ||
| 2. **GPIO pins**: Updated in `esp_spi.h` | ||
| - `HANDSHAKE_PIN` → 513 | ||
| - `SPI_DATA_READY_PIN` → 514 | ||
| 3. **Reset pin**: `resetpin=6` → `resetpin=512` in init script | ||
| 4. **Removed**: ARM-specific raspi-gpio commands | ||
| 5. **Added**: Device tree overlay for Microchip PolarFire SoC | ||
|
|
||
| ### Files Modified in esp-hosted Fork | ||
|
|
||
| ```bash | ||
| esp_hosted_ng/host/ | ||
| ├── beaglev_init.sh # Created from rpi_init.sh | ||
| └── linux/host_driver/esp32/spi/ | ||
| └── esp_spi.h # GPIO pins changed to 513, 514 | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it work?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Working on it tomorrow with Drasko..currently still hanging |
||
|
|
||
| ```bash | ||
| # After setup, connect to WiFi: | ||
| sudo ip link set wlan0 up | ||
| sudo iw dev wlan0 scan | ||
| wpa_passphrase "SSID" "password" | sudo tee /etc/wpa_supplicant.conf | ||
| sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf | ||
| sudo dhclient wlan0 | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ```bash | ||
| # Check status | ||
| ./scripts/verify-setup.sh | ||
|
|
||
| # View logs | ||
| dmesg | grep -i esp | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attach sample logs so that the user can see expected logs |
||
|
|
||
| # Check SPI | ||
| ls /dev/spidev0.0 | ||
|
|
||
| # Check interface | ||
| ip link show wlan0 | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attach sample logs so that the user can see expected logs