diff --git a/esp_hosted_ng/host/platforms/beaglev-fire/README.md b/esp_hosted_ng/host/platforms/beaglev-fire/README.md new file mode 100644 index 0000000000..207b418464 --- /dev/null +++ b/esp_hosted_ng/host/platforms/beaglev-fire/README.md @@ -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) diff --git a/esp_hosted_ng/host/platforms/beaglev-fire/beaglev-esp-hosted.dts b/esp_hosted_ng/host/platforms/beaglev-fire/beaglev-esp-hosted.dts new file mode 100644 index 0000000000..fa1f6cc451 --- /dev/null +++ b/esp_hosted_ng/host/platforms/beaglev-fire/beaglev-esp-hosted.dts @@ -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 */ + }; +}; diff --git a/esp_hosted_ng/host/platforms/beaglev-fire/beaglev_init.sh b/esp_hosted_ng/host/platforms/beaglev-fire/beaglev_init.sh new file mode 100644 index 0000000000..ff43264781 --- /dev/null +++ b/esp_hosted_ng/host/platforms/beaglev-fire/beaglev_init.sh @@ -0,0 +1,102 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD +# +# 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 " + 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" diff --git a/esp_hosted_ng/host/platforms/beaglev-fire/patches/esp_spi.h.patch b/esp_hosted_ng/host/platforms/beaglev-fire/patches/esp_spi.h.patch new file mode 100644 index 0000000000..a5674465b1 --- /dev/null +++ b/esp_hosted_ng/host/platforms/beaglev-fire/patches/esp_spi.h.patch @@ -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 diff --git a/s1-wifi-setup/README.md b/s1-wifi-setup/README.md new file mode 100644 index 0000000000..b49beafcb6 --- /dev/null +++ b/s1-wifi-setup/README.md @@ -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 + +```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 + +# Check SPI +ls /dev/spidev0.0 + +# Check interface +ip link show wlan0 +``` diff --git a/s1-wifi-setup/boot files/boot.cmd b/s1-wifi-setup/boot files/boot.cmd new file mode 100644 index 0000000000..443f2e78b8 --- /dev/null +++ b/s1-wifi-setup/boot files/boot.cmd @@ -0,0 +1,25 @@ +# this assumes ${scriptaddr} is already set!! + +# Boot with separate Image and DTB +setenv fdt_high 0xffffffffffffffff +setenv initrd_high 0xffffffffffffffff + +# Load kernel +load mmc 0:${distro_bootpart} ${kernel_addr_r} Image + +# Load modified DTB +load mmc 0:${distro_bootpart} ${fdt_addr_r} modified.dtb + +# Set bootargs +setenv bootargs "root=/dev/mmcblk0p3 ro rootfstype=ext4 rootwait console=ttyS0,115200 crashkernel=256M earlycon uio_pdrv_genirq.of_id=generic-uio net.ifnames=0" + +# Set MAC addresses +fdt addr ${fdt_addr_r} +fdt set /soc/ethernet@20112000 mac-address ${icicle_mac_addr0} +fdt set /soc/ethernet@20110000 mac-address ${icicle_mac_addr1} + +# Run overlays +run design_overlays + +# Boot +booti ${kernel_addr_r} - ${fdt_addr_r} \ No newline at end of file diff --git a/s1-wifi-setup/boot files/boot.scr.test b/s1-wifi-setup/boot files/boot.scr.test new file mode 100755 index 0000000000..0d139b1b3e Binary files /dev/null and b/s1-wifi-setup/boot files/boot.scr.test differ diff --git a/s1-wifi-setup/boot files/esp_included.dts b/s1-wifi-setup/boot files/esp_included.dts new file mode 100755 index 0000000000..9bb0ae2fe7 --- /dev/null +++ b/s1-wifi-setup/boot files/esp_included.dts @@ -0,0 +1,977 @@ +/dts-v1/; + +/ { + #address-cells = <0x02>; + #size-cells = <0x02>; + model = "BeagleBoard BeagleV-Fire"; + compatible = "beagle,beaglev-fire\0microchip,mpfs"; + + cpus { + #address-cells = <0x01>; + #size-cells = <0x00>; + timebase-frequency = <0xf4240>; + + cpu@0 { + compatible = "sifive,e51\0sifive,rocket0\0riscv"; + device_type = "cpu"; + i-cache-block-size = <0x40>; + i-cache-sets = <0x80>; + i-cache-size = <0x4000>; + reg = <0x00>; + riscv,isa = "rv64imac"; + riscv,isa-base = "rv64i"; + riscv,isa-extensions = "i\0m\0a\0c\0zicntr\0zicsr\0zifencei\0zihpm"; + clocks = <0x01 0x00>; + status = "disabled"; + phandle = <0x03>; + + interrupt-controller { + #interrupt-cells = <0x01>; + compatible = "riscv,cpu-intc"; + interrupt-controller; + phandle = <0x0b>; + }; + }; + + cpu@1 { + compatible = "sifive,u54-mc\0sifive,rocket0\0riscv"; + d-cache-block-size = <0x40>; + d-cache-sets = <0x40>; + d-cache-size = <0x8000>; + d-tlb-sets = <0x01>; + d-tlb-size = <0x20>; + device_type = "cpu"; + i-cache-block-size = <0x40>; + i-cache-sets = <0x40>; + i-cache-size = <0x8000>; + i-tlb-sets = <0x01>; + i-tlb-size = <0x20>; + mmu-type = "riscv,sv39"; + reg = <0x01>; + riscv,isa = "rv64imafdc"; + riscv,isa-base = "rv64i"; + riscv,isa-extensions = "i\0m\0a\0f\0d\0c\0zicntr\0zicsr\0zifencei\0zihpm"; + clocks = <0x01 0x00>; + tlb-split; + next-level-cache = <0x02>; + status = "okay"; + phandle = <0x04>; + + interrupt-controller { + #interrupt-cells = <0x01>; + compatible = "riscv,cpu-intc"; + interrupt-controller; + phandle = <0x0c>; + }; + }; + + cpu@2 { + compatible = "sifive,u54-mc\0sifive,rocket0\0riscv"; + d-cache-block-size = <0x40>; + d-cache-sets = <0x40>; + d-cache-size = <0x8000>; + d-tlb-sets = <0x01>; + d-tlb-size = <0x20>; + device_type = "cpu"; + i-cache-block-size = <0x40>; + i-cache-sets = <0x40>; + i-cache-size = <0x8000>; + i-tlb-sets = <0x01>; + i-tlb-size = <0x20>; + mmu-type = "riscv,sv39"; + reg = <0x02>; + riscv,isa = "rv64imafdc"; + riscv,isa-base = "rv64i"; + riscv,isa-extensions = "i\0m\0a\0f\0d\0c\0zicntr\0zicsr\0zifencei\0zihpm"; + clocks = <0x01 0x00>; + tlb-split; + next-level-cache = <0x02>; + status = "okay"; + phandle = <0x05>; + + interrupt-controller { + #interrupt-cells = <0x01>; + compatible = "riscv,cpu-intc"; + interrupt-controller; + phandle = <0x0d>; + }; + }; + + cpu@3 { + compatible = "sifive,u54-mc\0sifive,rocket0\0riscv"; + d-cache-block-size = <0x40>; + d-cache-sets = <0x40>; + d-cache-size = <0x8000>; + d-tlb-sets = <0x01>; + d-tlb-size = <0x20>; + device_type = "cpu"; + i-cache-block-size = <0x40>; + i-cache-sets = <0x40>; + i-cache-size = <0x8000>; + i-tlb-sets = <0x01>; + i-tlb-size = <0x20>; + mmu-type = "riscv,sv39"; + reg = <0x03>; + riscv,isa = "rv64imafdc"; + riscv,isa-base = "rv64i"; + riscv,isa-extensions = "i\0m\0a\0f\0d\0c\0zicntr\0zicsr\0zifencei\0zihpm"; + clocks = <0x01 0x00>; + tlb-split; + next-level-cache = <0x02>; + status = "okay"; + phandle = <0x06>; + + interrupt-controller { + #interrupt-cells = <0x01>; + compatible = "riscv,cpu-intc"; + interrupt-controller; + phandle = <0x0e>; + }; + }; + + cpu@4 { + compatible = "sifive,u54-mc\0sifive,rocket0\0riscv"; + d-cache-block-size = <0x40>; + d-cache-sets = <0x40>; + d-cache-size = <0x8000>; + d-tlb-sets = <0x01>; + d-tlb-size = <0x20>; + device_type = "cpu"; + i-cache-block-size = <0x40>; + i-cache-sets = <0x40>; + i-cache-size = <0x8000>; + i-tlb-sets = <0x01>; + i-tlb-size = <0x20>; + mmu-type = "riscv,sv39"; + reg = <0x04>; + riscv,isa = "rv64imafdc"; + riscv,isa-base = "rv64i"; + riscv,isa-extensions = "i\0m\0a\0f\0d\0c\0zicntr\0zicsr\0zifencei\0zihpm"; + clocks = <0x01 0x00>; + tlb-split; + next-level-cache = <0x02>; + status = "okay"; + phandle = <0x07>; + + interrupt-controller { + #interrupt-cells = <0x01>; + compatible = "riscv,cpu-intc"; + interrupt-controller; + phandle = <0x0f>; + }; + }; + + cpu-map { + + cluster0 { + + core0 { + cpu = <0x03>; + }; + + core1 { + cpu = <0x04>; + }; + + core2 { + cpu = <0x05>; + }; + + core3 { + cpu = <0x06>; + }; + + core4 { + cpu = <0x07>; + }; + }; + }; + }; + + mssrefclk { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x7735940>; + phandle = <0x1c>; + }; + + syscontroller { + compatible = "microchip,mpfs-sys-controller"; + mboxes = <0x08 0x00>; + microchip,bitstream-flash = <0x09>; + status = "okay"; + }; + + mssclkclk { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x4c4b400>; + phandle = <0x1b>; + }; + + soc { + #address-cells = <0x02>; + #size-cells = <0x02>; + compatible = "simple-bus"; + ranges; + dma-ranges = <0x14 0x00 0x00 0x80000000 0x00 0x4000000 0x14 0x4000000 0x00 0xc4000000 0x00 0x6000000 0x14 0xa000000 0x00 0x8a000000 0x00 0x8000000 0x14 0x12000000 0x14 0x12000000 0x00 0x10000000 0x14 0x22000000 0x10 0x22000000 0x00 0x5e000000>; + + cache-controller@2010000 { + compatible = "microchip,mpfs-ccache\0sifive,fu540-c000-ccache\0cache"; + reg = <0x00 0x2010000 0x00 0x1000>; + cache-block-size = <0x40>; + cache-level = <0x02>; + cache-sets = <0x400>; + cache-size = <0x200000>; + cache-unified; + interrupt-parent = <0x0a>; + interrupts = <0x01 0x03 0x04 0x02>; + phandle = <0x02>; + }; + + clint@2000000 { + compatible = "sifive,fu540-c000-clint\0sifive,clint0"; + reg = <0x00 0x2000000 0x00 0xc000>; + interrupts-extended = <0x0b 0xffffffff 0x0b 0xffffffff 0x0c 0x03 0x0c 0x07 0x0d 0x03 0x0d 0x07 0x0e 0x03 0x0e 0x07 0x0f 0x03 0x0f 0x07>; + }; + + interrupt-controller@c000000 { + compatible = "sifive,fu540-c000-plic\0sifive,plic-1.0.0"; + reg = <0x00 0xc000000 0x00 0x4000000>; + #address-cells = <0x00>; + #interrupt-cells = <0x01>; + interrupt-controller; + interrupts-extended = <0x0b 0xffffffff 0x0c 0xffffffff 0x0c 0x09 0x0d 0xffffffff 0x0d 0x09 0x0e 0xffffffff 0x0e 0x09 0x0f 0xffffffff 0x0f 0x09>; + riscv,ndev = <0xba>; + phandle = <0x0a>; + }; + + dma-controller@3000000 { + compatible = "microchip,mpfs-pdma\0sifive,fu540-c000-pdma"; + reg = <0x00 0x3000000 0x00 0x8000>; + interrupt-parent = <0x0a>; + interrupts = <0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c>; + #dma-cells = <0x01>; + }; + + syscon@20002000 { + compatible = "microchip,mpfs-mss-top-sysreg\0syscon\0simple-mfd"; + reg = <0x00 0x20002000 0x00 0x1000>; + #reset-cells = <0x01>; + #address-cells = <0x01>; + #size-cells = <0x01>; + phandle = <0x18>; + + interrupt-controller@54 { + compatible = "microchip,mpfs-gpio-irq-mux"; + reg = <0x54 0x04>; + interrupt-parent = <0x0a>; + interrupt-controller; + #interrupt-cells = <0x01>; + interrupts = <0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2a 0x2b 0x2c 0x2d 0x2e 0x2f 0x30 0x31 0x32 0x33 0x34 0x35>; + phandle = <0x1a>; + }; + }; + + syscon@20003000 { + compatible = "microchip,mpfs-sysreg-scb\0syscon"; + reg = <0x00 0x20003000 0x00 0x1000>; + }; + + clock-controller@38010000 { + compatible = "microchip,mpfs-ccc"; + reg = <0x00 0x38010000 0x00 0x1000 0x00 0x38020000 0x00 0x1000 0x00 0x39010000 0x00 0x1000 0x00 0x39020000 0x00 0x1000>; + #clock-cells = <0x01>; + status = "disabled"; + }; + + clock-controller@38040000 { + compatible = "microchip,mpfs-ccc"; + reg = <0x00 0x38040000 0x00 0x1000 0x00 0x38080000 0x00 0x1000 0x00 0x39040000 0x00 0x1000 0x00 0x39080000 0x00 0x1000>; + #clock-cells = <0x01>; + status = "disabled"; + }; + + clock-controller@38100000 { + compatible = "microchip,mpfs-ccc"; + reg = <0x00 0x38100000 0x00 0x1000 0x00 0x38200000 0x00 0x1000 0x00 0x39100000 0x00 0x1000 0x00 0x39200000 0x00 0x1000>; + #clock-cells = <0x01>; + status = "okay"; + clocks = <0x10 0x10 0x10 0x10 0x10 0x10>; + clock-names = "pll0_ref0\0pll0_ref1\0pll1_ref0\0pll1_ref1\0dll0_ref\0dll1_ref"; + phandle = <0x1f>; + }; + + clock-controller@38400000 { + compatible = "microchip,mpfs-ccc"; + reg = <0x00 0x38400000 0x00 0x1000 0x00 0x38800000 0x00 0x1000 0x00 0x39400000 0x00 0x1000 0x00 0x39800000 0x00 0x1000>; + #clock-cells = <0x01>; + status = "disabled"; + }; + + serial@20000000 { + compatible = "ns16550a"; + reg = <0x00 0x20000000 0x00 0x400>; + reg-io-width = <0x04>; + reg-shift = <0x02>; + interrupt-parent = <0x0a>; + interrupts = <0x5a>; + current-speed = <0x1c200>; + clocks = <0x01 0x08>; + status = "okay"; + }; + + serial@20100000 { + compatible = "ns16550a"; + reg = <0x00 0x20100000 0x00 0x400>; + reg-io-width = <0x04>; + reg-shift = <0x02>; + interrupt-parent = <0x0a>; + interrupts = <0x5b>; + current-speed = <0x1c200>; + clocks = <0x01 0x09>; + status = "okay"; + }; + + serial@20102000 { + compatible = "ns16550a"; + reg = <0x00 0x20102000 0x00 0x400>; + reg-io-width = <0x04>; + reg-shift = <0x02>; + interrupt-parent = <0x0a>; + interrupts = <0x5c>; + current-speed = <0x1c200>; + clocks = <0x01 0x0a>; + status = "disabled"; + }; + + serial@20104000 { + compatible = "ns16550a"; + reg = <0x00 0x20104000 0x00 0x400>; + reg-io-width = <0x04>; + reg-shift = <0x02>; + interrupt-parent = <0x0a>; + interrupts = <0x5d>; + current-speed = <0x1c200>; + clocks = <0x01 0x0b>; + status = "disabled"; + }; + + serial@20106000 { + compatible = "ns16550a"; + reg = <0x00 0x20106000 0x00 0x400>; + reg-io-width = <0x04>; + reg-shift = <0x02>; + interrupt-parent = <0x0a>; + interrupts = <0x5e>; + clocks = <0x01 0x0c>; + current-speed = <0x1c200>; + status = "disabled"; + }; + + mmc@20008000 { + compatible = "microchip,mpfs-sd4hc\0cdns,sd4hc"; + reg = <0x00 0x20008000 0x00 0x1000>; + interrupt-parent = <0x0a>; + interrupts = <0x58>; + clocks = <0x01 0x06>; + max-frequency = <0xbebc200>; + status = "okay"; + dma-noncoherent; + bus-width = <0x04>; + disable-wp; + cap-sd-highspeed; + cap-mmc-highspeed; + mmc-ddr-1_8v; + mmc-hs200-1_8v; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + }; + + spi@20108000 { + compatible = "microchip,mpfs-spi"; + #address-cells = <0x01>; + #size-cells = <0x00>; + reg = <0x00 0x20108000 0x00 0x1000>; + interrupt-parent = <0x0a>; + interrupts = <0x36>; + clocks = <0x01 0x0d>; + status = "okay"; + + esp32@0 { + compatible = "espressif,esp32"; + reg = <0x00>; + spi-max-frequency = <0x989680>; + spi-cpha; + spi-cpol; + reset-gpios = <0x11 0x02 0x01>; + interrupt-parent = <0x11>; + interrupts = <0x01 0x02>; + interrupt-names = "data-ready"; + handshake-gpios = <0x11 0x00 0x00>; + }; + }; + + spi@20109000 { + compatible = "microchip,mpfs-spi"; + #address-cells = <0x01>; + #size-cells = <0x00>; + reg = <0x00 0x20109000 0x00 0x1000>; + interrupt-parent = <0x0a>; + interrupts = <0x37>; + clocks = <0x01 0x0e>; + status = "okay"; + }; + + spi@21000000 { + compatible = "microchip,mpfs-qspi\0microchip,coreqspi-rtl-v2"; + #address-cells = <0x01>; + #size-cells = <0x00>; + reg = <0x00 0x21000000 0x00 0x1000>; + interrupt-parent = <0x0a>; + interrupts = <0x55>; + clocks = <0x01 0x16>; + status = "okay"; + cs-gpios = <0x12 0x11 0x01 0x13 0x0c 0x01>; + num-cs = <0x02>; + + adc@0 { + compatible = "microchip,mcp3464r"; + reg = <0x00>; + spi-cpol; + spi-cpha; + spi-max-frequency = <0x4c4b40>; + microchip,hw-device-address = <0x01>; + #address-cells = <0x01>; + #size-cells = <0x00>; + status = "okay"; + + channel@0 { + reg = <0x00>; + label = "CH0"; + }; + + channel@1 { + reg = <0x01>; + label = "CH1"; + }; + + channel@2 { + reg = <0x02>; + label = "CH2"; + }; + + channel@3 { + reg = <0x03>; + label = "CH3"; + }; + + channel@4 { + reg = <0x04>; + label = "CH4"; + }; + + channel@5 { + reg = <0x05>; + label = "CH5"; + }; + + channel@6 { + reg = <0x06>; + label = "CH6"; + }; + + channel@7 { + reg = <0x07>; + label = "CH7"; + }; + }; + + mmc@1 { + compatible = "mmc-spi-slot"; + reg = <0x01>; + gpios = <0x11 0x1f 0x01>; + voltage-ranges = <0xce4 0xce4>; + spi-max-frequency = <0x4c4b40>; + disable-wp; + }; + }; + + i2c@2010a000 { + compatible = "microchip,mpfs-i2c\0microchip,corei2c-rtl-v7"; + reg = <0x00 0x2010a000 0x00 0x1000>; + #address-cells = <0x01>; + #size-cells = <0x00>; + interrupt-parent = <0x0a>; + interrupts = <0x3a>; + clocks = <0x01 0x0f>; + clock-frequency = <0x186a0>; + status = "okay"; + }; + + i2c@2010b000 { + compatible = "microchip,mpfs-i2c\0microchip,corei2c-rtl-v7"; + reg = <0x00 0x2010b000 0x00 0x1000>; + #address-cells = <0x01>; + #size-cells = <0x00>; + interrupt-parent = <0x0a>; + interrupts = <0x3d>; + clocks = <0x01 0x10>; + clock-frequency = <0x186a0>; + status = "okay"; + + eeprom@50 { + compatible = "at,24c32"; + reg = <0x50>; + }; + + sensor@10 { + compatible = "sony,imx219"; + reg = <0x10>; + clocks = <0x14>; + VANA-supply = <0x15>; + VDIG-supply = <0x16>; + VDDL-supply = <0x17>; + + port { + + endpoint { + data-lanes = <0x01 0x02>; + clock-noncontinuous; + link-frequencies = <0x00 0x1b2e0200>; + }; + }; + }; + }; + + can@2010c000 { + compatible = "microchip,mpfs-can"; + reg = <0x00 0x2010c000 0x00 0x1000>; + clocks = <0x01 0x11 0x01 0x25>; + interrupt-parent = <0x0a>; + interrupts = <0x38>; + resets = <0x18 0x11>; + status = "disabled"; + }; + + can@2010d000 { + compatible = "microchip,mpfs-can"; + reg = <0x00 0x2010d000 0x00 0x1000>; + clocks = <0x01 0x12 0x01 0x25>; + interrupt-parent = <0x0a>; + interrupts = <0x39>; + resets = <0x18 0x12>; + status = "disabled"; + }; + + ethernet@20110000 { + compatible = "microchip,mpfs-macb\0cdns,macb"; + reg = <0x00 0x20110000 0x00 0x2000>; + #address-cells = <0x01>; + #size-cells = <0x00>; + interrupt-parent = <0x0a>; + interrupts = <0x40 0x41 0x42 0x43 0x44 0x45>; + local-mac-address = [00 00 00 00 00 00]; + clocks = <0x01 0x04 0x01 0x02>; + clock-names = "pclk\0hclk"; + resets = <0x18 0x04>; + status = "okay"; + dma-noncoherent; + phy-mode = "sgmii"; + phy-handle = <0x19>; + + ethernet-phy@0 { + reg = <0x00>; + phandle = <0x19>; + }; + }; + + ethernet@20112000 { + compatible = "microchip,mpfs-macb\0cdns,macb"; + reg = <0x00 0x20112000 0x00 0x2000>; + #address-cells = <0x01>; + #size-cells = <0x00>; + interrupt-parent = <0x0a>; + interrupts = <0x46 0x47 0x48 0x49 0x4a 0x4b>; + local-mac-address = [00 00 00 00 00 00]; + clocks = <0x01 0x05 0x01 0x02>; + clock-names = "pclk\0hclk"; + resets = <0x18 0x05>; + status = "disabled"; + }; + + gpio@20120000 { + compatible = "microchip,mpfs-gpio"; + reg = <0x00 0x20120000 0x00 0x1000>; + interrupt-parent = <0x1a>; + interrupt-controller; + #interrupt-cells = <0x02>; + interrupts = <0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c 0x0d>; + clocks = <0x01 0x17>; + gpio-controller; + #gpio-cells = <0x02>; + ngpios = <0x0e>; + status = "okay"; + gpio-line-names = "\0\0\0\0\0\0\0\0\0\0\0\0SD_CARD_CS\0USER_BUTTON"; + phandle = <0x13>; + + user-button-hog { + gpio-hog; + gpios = <0x0d 0x0d>; + input; + line-name = "USER_BUTTON"; + }; + }; + + gpio@20121000 { + compatible = "microchip,mpfs-gpio"; + reg = <0x00 0x20121000 0x00 0x1000>; + interrupt-parent = <0x1a>; + interrupt-controller; + #interrupt-cells = <0x02>; + interrupts = <0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2a 0x2b 0x2c 0x2d 0x2e 0x2f 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37>; + clocks = <0x01 0x18>; + gpio-controller; + #gpio-cells = <0x02>; + ngpios = <0x18>; + status = "okay"; + gpio-line-names = [00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 44 43 5f 49 52 51 6e 00 00 00 55 53 42 5f 4f 43 6e 00]; + phandle = <0x12>; + + adc-irqn-hog { + gpio-hog; + gpios = <0x14 0x14>; + input; + line-name = "ADC_IRQn"; + }; + + usb-ocn-hog { + gpio-hog; + gpios = <0x17 0x17>; + input; + line-name = "USB_OCn"; + }; + }; + + gpio@20122000 { + compatible = "microchip,mpfs-gpio"; + reg = <0x00 0x20122000 0x00 0x1000>; + interrupt-parent = <0x1a>; + interrupt-controller; + #interrupt-cells = <0x02>; + interrupts = <0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4a 0x4b 0x4c 0x4d 0x4e 0x4f 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5a 0x5b 0x5c 0x5d 0x5e 0x5f>; + clocks = <0x01 0x19>; + gpio-controller; + #gpio-cells = <0x02>; + ngpios = <0x20>; + status = "okay"; + gpio-line-names = "P8_PIN3_USER_LED_0\0P8_PIN4_USER_LED_1\0P8_PIN5_USER_LED_2\0P8_PIN6_USER_LED_3\0P8_PIN7_USER_LED_4\0P8_PIN8_USER_LED_5\0P8_PIN9_USER_LED_6\0P8_PIN10_USER_LED_7\0P8_PIN11_USER_LED_8\0P8_PIN12_USER_LED_9\0P8_PIN13_USER_LED_10\0P8_PIN14_USER_LED_11\0P8_PIN15\0P8_PIN16\0P8_PIN17\0P8_PIN18\0P8_PIN19\0P8_PIN20\0P8_PIN21\0P8_PIN22\0P8_PIN23\0P8_PIN24\0P8_PIN25\0P8_PIN26\0P8_PIN27\0P8_PIN28\0P8_PIN29\0P8_PIN30\0M2_W_DISABLE1\0M2_W_DISABLE2\0VIO_ENABLE\0SD_DET"; + phandle = <0x11>; + + vio-enable-hog { + gpio-hog; + gpios = <0x1e 0x1e>; + output-high; + line-name = "VIO_ENABLE"; + }; + }; + + rtc@20124000 { + compatible = "microchip,mpfs-rtc"; + reg = <0x00 0x20124000 0x00 0x1000>; + interrupt-parent = <0x0a>; + interrupts = <0x50 0x51>; + clocks = <0x01 0x15 0x01 0x21>; + clock-names = "rtc\0rtcref"; + status = "okay"; + }; + + usb@20201000 { + compatible = "microchip,mpfs-musb"; + reg = <0x00 0x20201000 0x00 0x1000>; + interrupt-parent = <0x0a>; + interrupts = <0x56 0x57>; + clocks = <0x01 0x13>; + interrupt-names = "dma\0mc"; + status = "okay"; + dma-noncoherent; + dr_mode = "otg"; + }; + + syscon@37020000 { + compatible = "microchip,mpfs-control-scb\0syscon\0simple-mfd"; + reg = <0x00 0x37020000 0x00 0x100>; + }; + + mailbox@37020800 { + compatible = "microchip,mpfs-mailbox"; + reg = <0x00 0x37020800 0x00 0x100>; + interrupt-parent = <0x0a>; + interrupts = <0x60>; + #mbox-cells = <0x01>; + status = "okay"; + phandle = <0x08>; + }; + + spi@37020100 { + compatible = "microchip,mpfs-qspi\0microchip,coreqspi-rtl-v2"; + #address-cells = <0x01>; + #size-cells = <0x00>; + reg = <0x00 0x37020100 0x00 0x100>; + interrupt-parent = <0x0a>; + interrupts = <0x6e>; + clocks = <0x1b>; + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + #address-cells = <0x01>; + #size-cells = <0x01>; + spi-max-frequency = <0x1312d00>; + spi-rx-bus-width = <0x01>; + reg = <0x00>; + phandle = <0x09>; + }; + }; + + clkcfg@3e001000 { + compatible = "microchip,mpfs-clkcfg"; + reg = <0x00 0x3e001000 0x00 0x1000>; + clocks = <0x1c>; + #clock-cells = <0x01>; + phandle = <0x01>; + }; + }; + + fabric-bus@22000000 { + compatible = "simple-bus"; + reg = <0x00 0x22000000 0x00 0x10000>; + #address-cells = <0x02>; + #size-cells = <0x02>; + ranges; + + crypto@22000000 { + compatible = "microchip,mpfs-crypto"; + reg = <0x00 0x22000000 0x00 0x10000>; + clocks = <0x01 0x1f 0x01 0x23>; + interrupt-parent = <0x0a>; + interrupts = <0x70>; + status = "disabled"; + }; + }; + + fabric-clk3 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x2faf080>; + phandle = <0x1d>; + }; + + fabric-clk1 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x7735940>; + }; + + fabric-bus@40000000 { + compatible = "simple-bus"; + #address-cells = <0x02>; + #size-cells = <0x02>; + ranges = <0x00 0x40000000 0x00 0x40000000 0x00 0x20000000 0x00 0x60000000 0x00 0x60000000 0x00 0x20000000 0x00 0xe0000000 0x00 0xe0000000 0x00 0x20000000 0x20 0x00 0x20 0x00 0x10 0x00 0x30 0x00 0x30 0x00 0x10 0x00>; + + gpio@41100000 { + compatible = "microchip,coregpio-rtl-v3"; + reg = <0x00 0x41100000 0x00 0x1000>; + clocks = <0x1d>; + gpio-controller; + #gpio-cells = <0x02>; + ngpios = <0x10>; + gpio-line-names = "P8_PIN31\0P8_PIN32\0P8_PIN33\0P8_PIN34\0P8_PIN35\0P8_PIN36\0P8_PIN37\0P8_PIN38\0P8_PIN39\0P8_PIN40\0P8_PIN41\0P8_PIN42\0P8_PIN43\0P8_PIN44\0P8_PIN45\0P8_PIN46"; + }; + + gpio@41200000 { + compatible = "microchip,coregpio-rtl-v3"; + reg = <0x00 0x41200000 0x00 0x1000>; + clocks = <0x1d>; + gpio-controller; + #gpio-cells = <0x02>; + ngpios = <0x14>; + gpio-line-names = "P9_PIN11\0P9_PIN12\0P9_PIN13\0P9_PIN14\0P9_PIN15\0P9_PIN16\0P9_PIN17\0P9_PIN18\0P9_PIN21\0P9_PIN22\0P9_PIN23\0P9_PIN24\0P9_PIN25\0P9_PIN26\0P9_PIN27\0P9_PIN28\0P9_PIN29\0P9_PIN31\0P9_PIN41\0P9_PIN42"; + }; + + gpio@44000000 { + compatible = "microchip,coregpio-rtl-v3"; + reg = <0x00 0x44000000 0x00 0x1000>; + clocks = <0x1d>; + gpio-controller; + #gpio-cells = <0x02>; + ngpios = <0x14>; + gpio-line-names = "B0_HSIO70N\0B0_HSIO71N\0B0_HSIO83N\0B0_HSIO73N_C2P_CLKN\0B0_HSIO70P\0B0_HSIO71P\0B0_HSIO83P\0B0_HSIO73N_C2P_CLKP\0XCVR1_RX_VALID\0XCVR1_LOCK\0XCVR1_ERROR\0XCVR2_RX_VALID\0XCVR2_LOCK\0XCVR2_ERROR\0XCVR3_RX_VALID\0XCVR3_LOCK\0XCVR3_ERROR\0XCVR_0B_REF_CLK_PLL_LOCK\0XCVR_0C_REF_CLK_PLL_LOCK\0B0_HSIO81N"; + }; + }; + + mailbox { + compatible = "microchip,miv-ihc"; + interrupt-parent = <0x0a>; + interrupts = <0xb4>; + microchip,miv-ihc-remote-context-id = <0x06>; + #mbox-cells = <0x01>; + status = "disabled"; + }; + + fabric-pcie-bus@3000000000 { + compatible = "simple-bus"; + #address-cells = <0x02>; + #size-cells = <0x02>; + ranges = <0x00 0x40000000 0x00 0x40000000 0x00 0x20000000 0x30 0x00 0x30 0x00 0x10 0x00>; + dma-ranges = <0x00 0x00 0x00 0x80000000 0x00 0x4000000 0x00 0x4000000 0x00 0xc4000000 0x00 0x6000000 0x00 0xa000000 0x00 0x8a000000 0x00 0x8000000 0x00 0x12000000 0x14 0x12000000 0x00 0x10000000 0x00 0x22000000 0x10 0x22000000 0x00 0x5e000000>; + + pcie@3000000000 { + compatible = "microchip,pcie-host-1.0"; + #address-cells = <0x03>; + #interrupt-cells = <0x01>; + #size-cells = <0x02>; + device_type = "pci"; + dma-noncoherent; + reg = <0x30 0x00 0x00 0x8000000 0x00 0x43004000 0x00 0x2000 0x00 0x43006000 0x00 0x2000>; + reg-names = "cfg\0bridge\0ctrl"; + bus-range = <0x00 0x7f>; + interrupt-parent = <0x0a>; + interrupts = <0x77>; + interrupt-map = <0x00 0x00 0x00 0x01 0x1e 0x00 0x00 0x00 0x00 0x02 0x1e 0x01 0x00 0x00 0x00 0x03 0x1e 0x02 0x00 0x00 0x00 0x04 0x1e 0x03>; + interrupt-map-mask = <0x00 0x00 0x00 0x07>; + clocks = <0x1f 0x05 0x1f 0x07>; + clock-names = "fic1\0fic3"; + ranges = <0x43000000 0x00 0x9000000 0x30 0x9000000 0x00 0xf000000 0x1000000 0x00 0x8000000 0x30 0x8000000 0x00 0x1000000 0x3000000 0x00 0x18000000 0x30 0x18000000 0x00 0x70000000>; + dma-ranges = <0x3000000 0x00 0x80000000 0x00 0x00 0x00 0x4000000 0x3000000 0x00 0x84000000 0x00 0x4000000 0x00 0x6000000 0x3000000 0x00 0x8a000000 0x00 0xa000000 0x00 0x8000000 0x3000000 0x00 0x92000000 0x00 0x12000000 0x00 0x10000000 0x3000000 0x00 0xa2000000 0x00 0x22000000 0x00 0x5e000000>; + msi-parent = <0x20>; + msi-controller; + status = "disabled"; + phandle = <0x20>; + + interrupt-controller { + #address-cells = <0x00>; + #interrupt-cells = <0x01>; + interrupt-controller; + phandle = <0x1e>; + }; + }; + }; + + cccrefclk { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x2faf080>; + phandle = <0x10>; + }; + + aliases { + serial0 = "/soc/serial@20000000"; + serial1 = "/soc/serial@20100000"; + serial2 = "/soc/serial@20102000"; + serial3 = "/soc/serial@20104000"; + serial4 = "/soc/serial@20106000"; + mmc0 = "/soc/mmc@20008000"; + mmc1 = "/soc/spi@21000000/mmc@1"; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + memory@80000000 { + device_type = "memory"; + reg = <0x00 0x80000000 0x00 0x4000000>; + }; + + memory@8a000000 { + device_type = "memory"; + reg = <0x00 0x8a000000 0x00 0x8000000>; + }; + + memory@c4000000 { + device_type = "memory"; + reg = <0x00 0xc4000000 0x00 0x6000000>; + }; + + memory@1022000000 { + device_type = "memory"; + reg = <0x10 0x22000000 0x00 0x5e000000>; + }; + + memory@1412000000 { + device_type = "memory"; + reg = <0x14 0x12000000 0x00 0x10000000>; + }; + + reserved-memory { + #address-cells = <0x02>; + #size-cells = <0x02>; + ranges; + + hss-buffer@103fc00000 { + compatible = "shared-dma-pool"; + reg = <0x10 0x3fc00000 0x00 0x400000>; + no-map; + }; + + non-cached-low-buffer { + compatible = "shared-dma-pool"; + size = <0x00 0x4000000>; + no-map; + alloc-ranges = <0x00 0xc4000000 0x00 0x4000000>; + }; + + non-cached-high-buffer { + compatible = "shared-dma-pool"; + size = <0x00 0x10000000>; + no-map; + linux,dma-default; + alloc-ranges = <0x14 0x12000000 0x00 0x10000000>; + }; + + ramoops@d0000000 { + compatible = "ramoops"; + reg = <0x00 0xd0000000 0x00 0x100000>; + record-size = <0x4000>; + console-size = <0x4000>; + ftrace-size = <0x4000>; + pmsg-size = <0x4000>; + max-reason = <0x02>; + ecc-size = <0x10>; + }; + }; + + fixedregulator-0 { + compatible = "regulator-fixed"; + regulator-name = "imx219_vana"; + regulator-min-microvolt = <0x2ab980>; + regulator-max-microvolt = <0x2ab980>; + phandle = <0x15>; + }; + + fixedregulator-1 { + compatible = "regulator-fixed"; + regulator-name = "imx219_vdig"; + regulator-min-microvolt = <0x1b7740>; + regulator-max-microvolt = <0x1b7740>; + phandle = <0x16>; + }; + + fixedregulator-2 { + compatible = "regulator-fixed"; + regulator-name = "imx219_vddl"; + regulator-min-microvolt = <0x124f80>; + regulator-max-microvolt = <0x124f80>; + phandle = <0x17>; + }; + + camera-clk { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x16e3600>; + phandle = <0x14>; + }; +}; diff --git a/s1-wifi-setup/boot files/modified.dtb b/s1-wifi-setup/boot files/modified.dtb new file mode 100755 index 0000000000..5310780ea4 Binary files /dev/null and b/s1-wifi-setup/boot files/modified.dtb differ diff --git a/s1-wifi-setup/esp-firmware/flash-esp32.sh b/s1-wifi-setup/esp-firmware/flash-esp32.sh new file mode 100644 index 0000000000..f02abb497a --- /dev/null +++ b/s1-wifi-setup/esp-firmware/flash-esp32.sh @@ -0,0 +1,240 @@ +#!/bin/bash +# +# ESP32 Firmware Flashing Script +# +# This script automates the process of building and flashing +# ESP-Hosted firmware to ESP32 for SPI mode operation. +# +# Usage: ./flash-esp32.sh [port] +# port: Serial port (e.g., /dev/ttyUSB0, COM3) +# If not specified, script will attempt to detect +# + +set -e + +# Color codes +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +echo "===========================================" +echo " ESP32 Firmware Flashing" +echo " ESP-Hosted SPI Mode" +echo "===========================================" +echo "" + +# Detect or use provided serial port +if [ -n "$1" ]; then + PORT="$1" + log_info "Using specified port: $PORT" +else + log_info "Attempting to auto-detect serial port..." + + # Try common Linux ports + if [ -e /dev/ttyUSB0 ]; then + PORT="/dev/ttyUSB0" + elif [ -e /dev/ttyACM0 ]; then + PORT="/dev/ttyACM0" + elif [ -e /dev/cu.usbserial-* ]; then + PORT=$(ls /dev/cu.usbserial-* | head -n 1) + else + log_error "Could not auto-detect serial port" + echo "" + echo "Available ports:" + ls /dev/tty* 2>/dev/null | grep -E "(USB|ACM|usbserial)" || echo " None found" + echo "" + echo "Usage: $0 " + echo "Example: $0 /dev/ttyUSB0" + exit 1 + fi + + log_success "Detected port: $PORT" +fi + +# Verify port exists +if [ ! -e "$PORT" ]; then + log_error "Port $PORT not found" + echo "" + echo "Available ports:" + ls /dev/tty* 2>/dev/null | grep -E "(USB|ACM|usbserial)" || echo " None found" + exit 1 +fi + +echo "" + +# Check for ESP-IDF +log_info "Checking for ESP-IDF..." + +if [ -z "$IDF_PATH" ]; then + log_warning "ESP-IDF environment not loaded" + + # Try to find and source ESP-IDF + if [ -f "$HOME/esp-idf/export.sh" ]; then + log_info "Found ESP-IDF at $HOME/esp-idf" + log_info "Sourcing ESP-IDF environment..." + source "$HOME/esp-idf/export.sh" + else + log_error "ESP-IDF not found" + echo "" + echo "Please install ESP-IDF first:" + echo " cd ~" + echo " git clone --recursive https://github.com/espressif/esp-idf.git" + echo " cd esp-idf" + echo " ./install.sh esp32" + echo " source ./export.sh" + echo "" + echo "Then run this script again" + exit 1 + fi +fi + +log_success "ESP-IDF found: $IDF_PATH" + +# Check for idf.py +if ! command -v idf.py &> /dev/null; then + log_error "idf.py not found in PATH" + log_error "Please source ESP-IDF environment: source ~/esp-idf/export.sh" + exit 1 +fi + +echo "" + +# Check for ESP-Hosted repository +ESP_HOSTED_DIR="$HOME/esp-hosted/esp_hosted_ng/esp/esp_driver" +ESP_HOSTED_REPO="${ESP_HOSTED_REPO:-https://github.com/absmach/esp-hosted.git}" + +if [ ! -d "$ESP_HOSTED_DIR" ]; then + log_warning "ESP-Hosted repository not found" + log_info "Cloning ESP-Hosted from $ESP_HOSTED_REPO..." + + cd "$HOME" + git clone --recurse-submodules "$ESP_HOSTED_REPO" + + if [ $? -ne 0 ]; then + log_error "Failed to clone ESP-Hosted" + exit 1 + fi + + log_success "ESP-Hosted cloned" +fi + +cd "$ESP_HOSTED_DIR" +log_info "Working directory: $ESP_HOSTED_DIR" +echo "" + +# Set target to ESP32 +log_info "Setting target to ESP32..." +idf.py set-target esp32 + +if [ $? -ne 0 ]; then + log_error "Failed to set target" + exit 1 +fi + +log_success "Target set to ESP32" +echo "" + +# Check if already configured for SPI +if [ -f sdkconfig ]; then + if grep -q "CONFIG_ESP_SPI_HOST_INTERFACE=y" sdkconfig 2>/dev/null; then + log_info "Already configured for SPI mode" + else + log_warning "Configuration may not be set for SPI mode" + log_info "You may want to run: idf.py menuconfig" + log_info "And verify: Example Configuration → Transport layer → SPI" + echo "" + read -p "Continue anyway? (y/N): " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + log_info "Aborting. Please configure and run again." + exit 1 + fi + fi +fi + +# Build firmware +log_info "Building firmware..." +log_warning "This may take 5-15 minutes on first build..." +echo "" + +idf.py build + +if [ $? -ne 0 ]; then + log_error "Build failed" + log_error "Check error messages above" + exit 1 +fi + +log_success "Firmware built successfully" +echo "" + +# Check firmware size +FIRMWARE_SIZE=$(ls -lh build/network_adapter.bin 2>/dev/null | awk '{print $5}') +if [ -n "$FIRMWARE_SIZE" ]; then + log_info "Firmware size: $FIRMWARE_SIZE" +fi + +echo "" + +# Flash firmware +log_info "Flashing firmware to ESP32..." +log_info "Port: $PORT" +log_warning "Make sure ESP32 is connected and powered" +echo "" + +read -p "Press Enter to start flashing (Ctrl+C to cancel)..." + +idf.py -p "$PORT" flash + +if [ $? -ne 0 ]; then + log_error "Flashing failed" + echo "" + echo "Troubleshooting:" + echo " 1. Check USB connection" + echo " 2. Try holding BOOT button and pressing RESET" + echo " 3. Try different USB port or cable" + echo " 4. Check port permissions: sudo usermod -a -G dialout $USER" + exit 1 +fi + +log_success "Firmware flashed successfully" +echo "" + +# Monitor output +log_info "Starting serial monitor to verify firmware..." +log_warning "Press Ctrl+] to exit monitor" +echo "" + +sleep 2 + +idf.py -p "$PORT" monitor + +echo "" +echo "===========================================" +echo " ✅ ESP32 Flashing Complete" +echo "===========================================" +echo "" +log_info "Next steps:" +echo " 1. Disconnect ESP32 from computer" +echo " 2. Connect ESP32 to BeagleV-Fire (see main README)" +echo " 3. Power on both devices" +echo " 4. Load ESP-Hosted driver on BeagleV-Fire" +echo "" diff --git a/s1-wifi-setup/kernel/build-kernel-modules.sh b/s1-wifi-setup/kernel/build-kernel-modules.sh new file mode 100644 index 0000000000..62a0080e3d --- /dev/null +++ b/s1-wifi-setup/kernel/build-kernel-modules.sh @@ -0,0 +1,242 @@ +#!/bin/bash +# +# Kernel Module Build Environment Setup for BeagleV-Fire +# +# This script prepares the kernel build environment necessary +# for compiling the ESP-Hosted driver kernel module. +# + +set -e + +# Color codes +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +echo "===========================================" +echo " Kernel Build Environment Setup" +echo " for BeagleV-Fire ESP32 Integration" +echo "===========================================" +echo "" + +# Get current kernel version +KERNEL_VERSION=$(uname -r) +log_info "Current kernel version: $KERNEL_VERSION" + +# Check if kernel headers already exist +KERNEL_BUILD_DIR="/lib/modules/$KERNEL_VERSION/build" + +if [ -f "$KERNEL_BUILD_DIR/include/linux/module.h" ]; then + log_success "Kernel headers already present at $KERNEL_BUILD_DIR" + echo "" + log_info "You can skip the rest of this setup." + log_info "Your system is ready to build kernel modules." + exit 0 +fi + +log_warning "Kernel headers not found. Starting setup..." +echo "" + +# Check for required tools +log_info "Checking for required tools..." +REQUIRED_TOOLS="git make gcc bc flex bison" +MISSING_TOOLS="" + +for tool in $REQUIRED_TOOLS; do + if ! command -v $tool &> /dev/null; then + MISSING_TOOLS="$MISSING_TOOLS $tool" + fi +done + +if [ -n "$MISSING_TOOLS" ]; then + log_error "Missing required tools:$MISSING_TOOLS" + log_info "Install with: sudo apt-get install$MISSING_TOOLS" + exit 1 +fi + +log_success "All required tools found" +echo "" + +# Clone Microchip kernel if not present +KERNEL_SOURCE_DIR="$HOME/microchip-kernel" + +if [ -d "$KERNEL_SOURCE_DIR" ]; then + log_info "Kernel source already exists at $KERNEL_SOURCE_DIR" +else + log_info "Cloning Microchip Linux kernel..." + log_warning "This will download ~1.5 GB and may take 5-15 minutes" + + cd ~ + git clone --depth=1 -b linux4microchip+fpga-2025.03 \ + https://github.com/linux4microchip/linux.git microchip-kernel + + if [ $? -ne 0 ]; then + log_error "Failed to clone kernel repository" + exit 1 + fi + + log_success "Kernel source cloned successfully" +fi + +cd "$KERNEL_SOURCE_DIR" +echo "" + +# Extract running kernel configuration +log_info "Extracting running kernel configuration..." + +if [ -f /proc/config.gz ]; then + zcat /proc/config.gz > .config + log_success "Configuration extracted from /proc/config.gz" +elif [ -f /boot/config-$KERNEL_VERSION ]; then + cp /boot/config-$KERNEL_VERSION .config + log_success "Configuration copied from /boot" +else + log_error "Cannot find kernel configuration" + log_error "Please ensure your kernel is compiled with CONFIG_IKCONFIG_PROC=y" + exit 1 +fi + +echo "" + +# Update configuration for new kernel version +log_info "Updating configuration for current kernel..." +make ARCH=riscv olddefconfig > /dev/null 2>&1 + +if [ $? -ne 0 ]; then + log_error "Failed to update kernel configuration" + exit 1 +fi + +log_success "Configuration updated" +echo "" + +# Prepare kernel module build environment +log_info "Preparing kernel module build environment..." +log_warning "This may take 2-5 minutes..." + +make ARCH=riscv modules_prepare + +if [ $? -ne 0 ]; then + log_error "Failed to prepare kernel modules" + log_error "Check error messages above" + exit 1 +fi + +log_success "Kernel module environment prepared" +echo "" + +# Install kernel headers system-wide +log_info "Installing kernel headers to /usr/include..." + +sudo make ARCH=riscv headers_install INSTALL_HDR_PATH=/usr > /dev/null 2>&1 + +if [ $? -ne 0 ]; then + log_warning "Failed to install kernel headers (non-critical)" +else + log_success "Kernel headers installed" +fi + +echo "" + +# Create symlink for module builds +log_info "Creating kernel build symlink..." + +if [ -L "$KERNEL_BUILD_DIR" ]; then + log_info "Removing old symlink..." + sudo rm "$KERNEL_BUILD_DIR" +fi + +sudo ln -sf "$KERNEL_SOURCE_DIR" "$KERNEL_BUILD_DIR" + +if [ $? -ne 0 ]; then + log_error "Failed to create symlink" + exit 1 +fi + +log_success "Symlink created: $KERNEL_BUILD_DIR -> $KERNEL_SOURCE_DIR" +echo "" + +# Verify installation +log_info "Verifying installation..." + +ERROR_COUNT=0 + +# Check for module.h +if [ ! -f "$KERNEL_BUILD_DIR/include/linux/module.h" ]; then + log_error "module.h not found" + ERROR_COUNT=$((ERROR_COUNT + 1)) +else + log_success "module.h found" +fi + +# Check for Makefile +if [ ! -f "$KERNEL_BUILD_DIR/Makefile" ]; then + log_error "Makefile not found" + ERROR_COUNT=$((ERROR_COUNT + 1)) +else + log_success "Makefile found" +fi + +# Check for Module.symvers +if [ ! -f "$KERNEL_BUILD_DIR/Module.symvers" ]; then + log_warning "Module.symvers not found (may be OK)" +else + log_success "Module.symvers found" +fi + +# Check version match +KERNEL_RELEASE=$(cat "$KERNEL_BUILD_DIR/include/config/kernel.release" 2>/dev/null | tr -d '\n') +if [ "$KERNEL_RELEASE" != "$KERNEL_VERSION" ]; then + log_warning "Kernel version mismatch detected" + log_warning " Running: $KERNEL_VERSION" + log_warning " Build: $KERNEL_RELEASE" + log_warning "This may cause module loading issues" +else + log_success "Kernel version matches: $KERNEL_VERSION" +fi + +echo "" + +if [ $ERROR_COUNT -eq 0 ]; then + echo "===========================================" + echo " ✅ Setup Complete!" + echo "===========================================" + echo "" + log_success "Your system is ready to build kernel modules" + echo "" + log_info "Next steps:" + echo " 1. Continue with device tree overlay setup" + echo " 2. Flash ESP32 firmware" + echo " 3. Build and load ESP-Hosted driver" + echo "" + log_info "See: docs/host-driver.md for next steps" +else + echo "===========================================" + echo " ⚠️ Setup Completed with Warnings" + echo "===========================================" + echo "" + log_warning "$ERROR_COUNT error(s) detected" + log_info "Module building may not work correctly" + log_info "Please review errors above and fix before continuing" +fi + +echo "" +log_info "Disk space used: $(du -sh $KERNEL_SOURCE_DIR | cut -f1)" diff --git a/s1-wifi-setup/overlays/beaglev-esp-hosted.dts b/s1-wifi-setup/overlays/beaglev-esp-hosted.dts new file mode 100644 index 0000000000..77321d693a --- /dev/null +++ b/s1-wifi-setup/overlays/beaglev-esp-hosted.dts @@ -0,0 +1,27 @@ +/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 */ + }; +}; + diff --git a/s1-wifi-setup/scripts/setup-device-tree.sh b/s1-wifi-setup/scripts/setup-device-tree.sh new file mode 100644 index 0000000000..4d3bb94390 --- /dev/null +++ b/s1-wifi-setup/scripts/setup-device-tree.sh @@ -0,0 +1,149 @@ +#!/bin/bash +# +# Device Tree Overlay Setup Script +# +# This script compiles and applies the device tree overlay for ESP-Hosted +# SPI communication on BeagleV-Fire. +# + +set -e + +# Color codes +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Check if running as root +if [ "$EUID" -ne 0 ]; then + log_error "Please run as root (use sudo)" + exit 1 +fi + +echo "===========================================" +echo " Device Tree Overlay Setup" +echo "===========================================" +echo "" + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" +OVERLAY_DIR="$SCRIPT_DIR/overlays" +DTS_FILE="$OVERLAY_DIR/beaglev-esp-hosted.dts" +DTBO_FILE="$OVERLAY_DIR/beaglev-esp-hosted.dtbo" + +# Step 1: Compile device tree overlay (if source exists and binary doesn't) +if [ -f "$DTS_FILE" ]; then + if [ ! -f "$DTBO_FILE" ] || [ "$DTS_FILE" -nt "$DTBO_FILE" ]; then + log_info "Compiling device tree overlay..." + + dtc -O dtb -o "$DTBO_FILE" -b 0 -@ "$DTS_FILE" + + if [ $? -ne 0 ]; then + log_error "Failed to compile device tree overlay" + exit 1 + fi + + log_success "Device tree overlay compiled" + else + log_info "Device tree overlay already compiled" + fi +elif [ ! -f "$DTBO_FILE" ]; then + log_error "Neither source ($DTS_FILE) nor compiled overlay ($DTBO_FILE) found" + exit 1 +fi + +# Step 2: Load SPI modules +log_info "Loading SPI kernel modules..." + +modprobe spidev 2>/dev/null || log_warning "spidev module not available" +modprobe spi-microchip-core 2>/dev/null || log_warning "spi-microchip-core not available" +modprobe spi-microchip-core-qspi 2>/dev/null || log_warning "spi-microchip-core-qspi not available" + +log_success "SPI modules loaded" + +# Step 3: Copy overlay to firmware directory +log_info "Installing device tree overlay..." + +mkdir -p /boot/overlays +mkdir -p /lib/firmware + +cp "$DTBO_FILE" /lib/firmware/ + +if [ $? -ne 0 ]; then + log_error "Failed to copy overlay to /lib/firmware" + exit 1 +fi + +log_success "Overlay installed to /lib/firmware" + +# Step 4: Apply overlay +log_info "Applying device tree overlay..." + +# Remove old overlay if it exists +if [ -d /sys/kernel/config/device-tree/overlays/esp-hosted ]; then + log_info "Removing existing overlay..." + rmdir /sys/kernel/config/device-tree/overlays/esp-hosted 2>/dev/null || true +fi + +# Create overlay directory +mkdir -p /sys/kernel/config/device-tree/overlays/esp-hosted + +# Apply overlay +echo "beaglev-esp-hosted.dtbo" > /sys/kernel/config/device-tree/overlays/esp-hosted/path + +if [ $? -ne 0 ]; then + log_error "Failed to apply device tree overlay" + log_error "Check dmesg for details: dmesg | tail -20" + exit 1 +fi + +# Give it a moment to apply +sleep 1 + +# Step 5: Verify overlay status +OVERLAY_STATUS=$(cat /sys/kernel/config/device-tree/overlays/esp-hosted/status 2>/dev/null || echo "unknown") + +if [ "$OVERLAY_STATUS" = "applied" ]; then + log_success "Device tree overlay applied successfully" +else + log_warning "Overlay status: $OVERLAY_STATUS" +fi + +# Step 6: Verify SPI device +log_info "Verifying SPI device..." + +if [ -e /dev/spidev0.0 ]; then + log_success "SPI device /dev/spidev0.0 is present" + ls -l /dev/spidev0.0 +else + log_error "SPI device /dev/spidev0.0 not found" + log_error "Try: sudo reboot (overlay may require reboot to take effect)" + exit 1 +fi + +echo "" +echo "===========================================" +echo " ✅ Device Tree Setup Complete" +echo "===========================================" +echo "" +log_info "Next steps:" +echo " 1. Verify ESP32 is flashed with SPI firmware" +echo " 2. Connect hardware (see main README for pinout)" +echo " 3. Build and load ESP-Hosted driver" +echo "" diff --git a/s1-wifi-setup/scripts/verify-setup.sh b/s1-wifi-setup/scripts/verify-setup.sh new file mode 100644 index 0000000000..62ba1ac732 --- /dev/null +++ b/s1-wifi-setup/scripts/verify-setup.sh @@ -0,0 +1,214 @@ +#!/bin/bash +# +# Setup Verification Script +# +# This script verifies that all components of the ESP-Hosted +# setup are properly installed and configured. +# + +# Color codes +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +PASS_COUNT=0 +FAIL_COUNT=0 +WARN_COUNT=0 + +check_pass() { + echo -e "${GREEN}✓${NC} $1" + PASS_COUNT=$((PASS_COUNT + 1)) +} + +check_fail() { + echo -e "${RED}✗${NC} $1" + FAIL_COUNT=$((FAIL_COUNT + 1)) +} + +check_warn() { + echo -e "${YELLOW}⚠${NC} $1" + WARN_COUNT=$((WARN_COUNT + 1)) +} + +echo "===========================================" +echo " ESP-Hosted Setup Verification" +echo "===========================================" +echo "" + +# Check 1: Kernel headers +echo "1. Checking kernel headers..." +if [ -f "/lib/modules/$(uname -r)/build/include/linux/module.h" ]; then + check_pass "Kernel headers present" +else + check_fail "Kernel headers missing" + echo " Run: kernel/build-kernel-modules.sh" +fi +echo "" + +# Check 2: Device tree overlay +echo "2. Checking device tree overlay..." +if [ -f /sys/kernel/config/device-tree/overlays/esp-hosted/status ]; then + STATUS=$(cat /sys/kernel/config/device-tree/overlays/esp-hosted/status) + if [ "$STATUS" = "applied" ]; then + check_pass "Device tree overlay applied" + else + check_warn "Device tree overlay status: $STATUS" + fi +else + check_fail "Device tree overlay not applied" + echo " Run: scripts/setup-device-tree.sh" +fi +echo "" + +# Check 3: SPI device +echo "3. Checking SPI device..." +if [ -e /dev/spidev0.0 ]; then + check_pass "SPI device /dev/spidev0.0 present" + ls -l /dev/spidev0.0 | awk '{print " " $0}' +else + check_fail "SPI device /dev/spidev0.0 not found" + echo " Try: sudo reboot (overlay may require reboot)" +fi +echo "" + +# Check 4: SPI kernel modules +echo "4. Checking SPI kernel modules..." +if lsmod | grep -q "spi.*microchip"; then + check_pass "Microchip SPI modules loaded" + lsmod | grep "spi.*microchip" | awk '{print " " $1}' +else + check_warn "Microchip SPI modules not loaded" + echo " Try: sudo modprobe spi-microchip-core" +fi +echo "" + +# Check 5: ESP-Hosted kernel module +echo "5. Checking ESP-Hosted driver..." +if lsmod | grep -q esp32_spi; then + check_pass "ESP32 SPI driver loaded" + lsmod | grep esp32 | awk '{print " " $0}' +else + check_warn "ESP32 SPI driver not loaded" + echo " This is expected if you haven't run beaglev_init.sh yet" +fi +echo "" + +# Check 6: Network interface +echo "6. Checking WiFi interface..." +if ip link show wlan0 &>/dev/null; then + check_pass "wlan0 interface present" + ip link show wlan0 | awk '{print " " $0}' +else + check_warn "wlan0 interface not present" + echo " This will appear after ESP-Hosted driver loads and ESP32 responds" +fi +echo "" + +# Check 7: cfg80211 module +echo "7. Checking wireless support..." +if lsmod | grep -q cfg80211; then + check_pass "cfg80211 wireless module loaded" +else + check_warn "cfg80211 module not loaded" + echo " Try: sudo modprobe cfg80211" +fi +echo "" + +# Check 8: ESP-Hosted repository +echo "8. Checking ESP-Hosted repository..." +if [ -d "$HOME/esp-hosted/esp_hosted_ng/host" ]; then + check_pass "ESP-Hosted repository present" + + # Check for beaglev_init.sh + if [ -f "$HOME/esp-hosted/esp_hosted_ng/host/beaglev_init.sh" ]; then + check_pass "beaglev_init.sh script present" + else + check_warn "beaglev_init.sh not found" + echo " You need to create this from rpi_init.sh" + fi +else + check_fail "ESP-Hosted repository not found" + echo " Clone with: git clone --recurse-submodules https://github.com/espressif/esp-hosted.git" +fi +echo "" + +# Check 9: Kernel logs +echo "9. Checking kernel logs for ESP messages..." +if dmesg | grep -qi esp; then + ESP_MESSAGES=$(dmesg | grep -i esp | tail -5) + if echo "$ESP_MESSAGES" | grep -qi "error\|fail\|timeout"; then + check_warn "Found error messages in kernel log" + echo "$ESP_MESSAGES" | tail -3 | awk '{print " " $0}' + else + check_pass "No errors in recent ESP kernel messages" + echo "$ESP_MESSAGES" | tail -2 | awk '{print " " $0}' + fi +else + check_warn "No ESP messages in kernel log" + echo " This is normal if driver hasn't been loaded yet" +fi +echo "" + +# Summary +echo "===========================================" +echo " Verification Summary" +echo "===========================================" +echo -e "${GREEN}Passed:${NC} $PASS_COUNT" +echo -e "${YELLOW}Warnings:${NC} $WARN_COUNT" +echo -e "${RED}Failed:${NC} $FAIL_COUNT" +echo "" + +if [ $FAIL_COUNT -eq 0 ] && [ $WARN_COUNT -eq 0 ]; then + echo -e "${GREEN}✅ All checks passed!${NC}" + echo "Your system is fully configured." + echo "" + echo "If you haven't already:" + echo " 1. Flash ESP32 firmware (esp-firmware/flash-esp32.sh)" + echo " 2. Connect hardware (see main README)" + echo " 3. Load driver (sudo ~/esp-hosted/esp_hosted_ng/host/beaglev_init.sh spi)" + echo " 4. Connect to WiFi" +elif [ $FAIL_COUNT -eq 0 ]; then + echo -e "${YELLOW}⚠️ Setup mostly complete with warnings${NC}" + echo "Some components are not yet loaded, which may be normal" + echo "depending on your setup stage." + echo "" + echo "Review warnings above and:" + echo " - Load missing kernel modules if needed" + echo " - Run beaglev_init.sh to load ESP-Hosted driver" +else + echo -e "${RED}❌ Setup incomplete${NC}" + echo "Please fix the failed checks above." + echo "" + echo "Common fixes:" + echo " - Kernel headers: Run kernel/build-kernel-modules.sh" + echo " - Device tree: Run scripts/setup-device-tree.sh" + echo " - SPI device: Reboot after applying overlay" +fi + +echo "" + +# Additional diagnostic info +if [ $FAIL_COUNT -gt 0 ] || [ $WARN_COUNT -gt 2 ]; then + echo "===========================================" + echo " Diagnostic Information" + echo "===========================================" + echo "" + + echo "Kernel version:" + uname -r + echo "" + + echo "Loaded kernel modules (SPI/ESP related):" + lsmod | grep -E "spi|esp|cfg80211" || echo " None found" + echo "" + + echo "Available SPI devices:" + ls -l /dev/spi* 2>/dev/null || echo " None found" + echo "" + + echo "Network interfaces:" + ip link show | grep -E "^[0-9]:" | awk '{print " " $2}' + echo "" +fi diff --git a/s1-wifi-setup/setup-s1.sh b/s1-wifi-setup/setup-s1.sh new file mode 100644 index 0000000000..0f43dc056e --- /dev/null +++ b/s1-wifi-setup/setup-s1.sh @@ -0,0 +1,280 @@ +#!/bin/bash +# +# S0 Board ESP32-Hosted Complete Setup Script +# +# This script performs the complete setup of ESP32-Hosted on S0 (BeagleV-Fire + ESP32): +# 1. Checks prerequisites +# 2. Builds kernel modules if needed +# 3. Applies device tree overlay +# 4. Loads required modules +# 5. Builds and loads ESP-Hosted driver +# +# Usage: sudo ./setup-s0.sh +# + +set -e # Exit on error + +# Color codes for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Logging functions +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Check if running as root +if [ "$EUID" -ne 0 ]; then + log_error "Please run as root (use sudo)" + exit 1 +fi + +echo "===========================================" +echo " S0 Board ESP32-Hosted Setup" +echo "===========================================" +echo "" + +# Get the script directory +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$SCRIPT_DIR" + +# Step 1: Check Prerequisites +log_info "Checking prerequisites..." + +# Check for required commands +REQUIRED_CMDS="git make gcc dtc modprobe" +for cmd in $REQUIRED_CMDS; do + if ! command -v $cmd &> /dev/null; then + log_error "Required command '$cmd' not found. Please install it." + exit 1 + fi +done +log_success "All required commands found" + +# Check kernel version +KERNEL_VERSION=$(uname -r) +log_info "Kernel version: $KERNEL_VERSION" + +# Check if kernel headers are available +if [ ! -d "/lib/modules/$KERNEL_VERSION/build" ]; then + log_warning "Kernel headers not found. Will attempt to set up..." + + if [ -f "$SCRIPT_DIR/kernel/build-kernel-modules.sh" ]; then + log_info "Running kernel setup script..." + bash "$SCRIPT_DIR/kernel/build-kernel-modules.sh" + else + log_error "Kernel headers missing and setup script not found" + log_error "Please manually install kernel headers or run kernel setup" + exit 1 + fi +else + log_success "Kernel headers found at /lib/modules/$KERNEL_VERSION/build" +fi + +# Step 2: Install Required Packages +log_info "Installing required packages..." +apt-get update -qq +apt-get install -y -qq bluetooth bluez bluez-tools rfkill dtc 2>&1 | grep -v "^Reading\|^Building" +log_success "Required packages installed" + +# Step 3: Setup Device Tree Overlay +log_info "Setting up device tree overlay..." + +if [ -f "$SCRIPT_DIR/scripts/setup-device-tree.sh" ]; then + bash "$SCRIPT_DIR/scripts/setup-device-tree.sh" +else + log_warning "Device tree setup script not found, applying manually..." + + # Load spidev module + log_info "Loading spidev module..." + modprobe spidev || log_warning "spidev module not available" + + # Load Microchip SPI drivers + log_info "Loading Microchip SPI drivers..." + modprobe spi-microchip-core || log_warning "spi-microchip-core not available" + modprobe spi-microchip-core-qspi || log_warning "spi-microchip-core-qspi not available" + + # Apply device tree overlay + if [ -f "$SCRIPT_DIR/overlays/beaglev-esp-hosted.dtbo" ]; then + log_info "Applying device tree overlay..." + mkdir -p /boot/overlays + mkdir -p /lib/firmware + cp "$SCRIPT_DIR/overlays/beaglev-esp-hosted.dtbo" /lib/firmware/ + + mkdir -p /sys/kernel/config/device-tree/overlays/esp-hosted + echo "beaglev-esp-hosted.dtbo" > /sys/kernel/config/device-tree/overlays/esp-hosted/path + + # Check if overlay was applied + OVERLAY_STATUS=$(cat /sys/kernel/config/device-tree/overlays/esp-hosted/status 2>/dev/null || echo "unknown") + if [ "$OVERLAY_STATUS" = "applied" ]; then + log_success "Device tree overlay applied successfully" + else + log_warning "Device tree overlay status: $OVERLAY_STATUS" + fi + else + log_error "Device tree overlay not found at $SCRIPT_DIR/overlays/beaglev-esp-hosted.dtbo" + log_error "Please compile the overlay first" + exit 1 + fi +fi + +# Step 4: Verify SPI Device +log_info "Verifying SPI device..." +if [ -e /dev/spidev0.0 ]; then + log_success "SPI device found at /dev/spidev0.0" +else + log_error "SPI device not found at /dev/spidev0.0" + log_error "Please check hardware connections and device tree overlay" + exit 1 +fi + +# Step 5: Clone and Setup ESP-Hosted (if not already present) +ESP_HOSTED_REPO="${ESP_HOSTED_REPO:-https://github.com/absmach/esp-hosted.git}" + +if [ ! -d "$HOME/esp-hosted" ]; then + log_info "Cloning ESP-Hosted repository from $ESP_HOSTED_REPO..." + cd "$HOME" + git clone --recurse-submodules "$ESP_HOSTED_REPO" + log_success "ESP-Hosted cloned successfully" +else + log_info "ESP-Hosted repository already exists at $HOME/esp-hosted" +fi + +# Step 6: Apply BeagleV-Specific Patches +log_info "Applying BeagleV-specific configuration..." + +ESP_HOSTED_DIR="$HOME/esp-hosted/esp_hosted_ng/host" +PLATFORM_DIR="$HOME/esp-hosted/esp_hosted_ng/host/platforms/beaglev-fire" + +# Check if beaglev_init.sh already exists in main directory +if [ -f "$ESP_HOSTED_DIR/beaglev_init.sh" ]; then + log_success "beaglev_init.sh already present in host directory" +# Check if it exists in platform directory and copy it +elif [ -f "$PLATFORM_DIR/beaglev_init.sh" ]; then + log_info "Copying beaglev_init.sh from platform directory..." + cp "$PLATFORM_DIR/beaglev_init.sh" "$ESP_HOSTED_DIR/beaglev_init.sh" + chmod +x "$ESP_HOSTED_DIR/beaglev_init.sh" + log_success "beaglev_init.sh copied from platform directory" +else + # Fallback: create from rpi_init.sh (requires manual editing) + log_warning "beaglev_init.sh not found in your esp-hosted fork" + + # Backup original files if not already backed up + if [ ! -f "$ESP_HOSTED_DIR/rpi_init.sh.backup" ]; then + cp "$ESP_HOSTED_DIR/rpi_init.sh" "$ESP_HOSTED_DIR/rpi_init.sh.backup" + fi + + log_info "Creating beaglev_init.sh from rpi_init.sh..." + cp "$ESP_HOSTED_DIR/rpi_init.sh" "$ESP_HOSTED_DIR/beaglev_init.sh" + chmod +x "$ESP_HOSTED_DIR/beaglev_init.sh" + + log_warning "Please manually edit $ESP_HOSTED_DIR/beaglev_init.sh with the following changes:" + echo " 1. Change ARCH=arm to ARCH=riscv in make command" + echo " 2. Remove CROSS_COMPILE parameter" + echo " 3. Set resetpin=512" + echo " 4. Comment out all raspi-gpio commands" + echo " 5. Comment out spidev_disabler section" + echo "" + log_info "See docs/host-driver.md for detailed instructions" + + read -p "Press Enter after making these changes to continue..." +else + log_info "beaglev_init.sh already exists" +fi + +# Update GPIO pins in esp_spi.h if needed +ESP_SPI_H="$ESP_HOSTED_DIR/linux/host_driver/esp32/spi/esp_spi.h" +PLATFORM_PATCH="$PLATFORM_DIR/patches/esp_spi.h.patch" + +if [ -f "$ESP_SPI_H" ]; then + # Check if already modified + if grep -q "HANDSHAKE_PIN.*513" "$ESP_SPI_H"; then + log_success "GPIO pins already configured in esp_spi.h" + # Check if patch exists and apply it + elif [ -f "$PLATFORM_PATCH" ]; then + log_info "Applying GPIO pin patch from platform directory..." + cd "$HOME/esp-hosted" + patch -p1 < "$PLATFORM_PATCH" || log_warning "Patch may already be applied or failed" + log_success "GPIO pin patch applied" + else + log_warning "Please manually edit $ESP_SPI_H to set:" + echo " #define HANDSHAKE_PIN 513" + echo " #define SPI_DATA_READY_PIN 514" + echo "" + read -p "Press Enter after making these changes to continue..." + fi +fi + +# Step 7: Build and Load ESP-Hosted Driver +log_info "Building and loading ESP-Hosted driver..." + +cd "$ESP_HOSTED_DIR" + +# Try to load with error handling +log_info "Running beaglev_init.sh spi..." +if ./beaglev_init.sh spi; then + log_success "ESP-Hosted driver loaded successfully" +else + log_warning "Driver loading completed with warnings (this may be normal)" +fi + +# Step 8: Verification +log_info "Performing final verification..." + +echo "" +echo "===========================================" +echo " Verification Results" +echo "===========================================" + +# Check SPI device +if [ -e /dev/spidev0.0 ]; then + echo -e "${GREEN}✓${NC} SPI device: /dev/spidev0.0 exists" +else + echo -e "${RED}✗${NC} SPI device: /dev/spidev0.0 NOT found" +fi + +# Check kernel modules +if lsmod | grep -q esp32_spi; then + echo -e "${GREEN}✓${NC} Kernel module: esp32_spi loaded" +else + echo -e "${YELLOW}⚠${NC} Kernel module: esp32_spi NOT loaded (check dmesg)" +fi + +# Check network interface +if ip link show wlan0 &>/dev/null; then + echo -e "${GREEN}✓${NC} Network interface: wlan0 present" +else + echo -e "${YELLOW}⚠${NC} Network interface: wlan0 NOT present (may appear after ESP32 connection)" +fi + +# Check overlay status +OVERLAY_STATUS=$(cat /sys/kernel/config/device-tree/overlays/esp-hosted/status 2>/dev/null || echo "unknown") +echo -e "${GREEN}✓${NC} Device tree overlay: $OVERLAY_STATUS" + +echo "" +echo "===========================================" +echo " Setup Complete!" +echo "===========================================" +echo "" +log_info "Next steps:" +echo " 1. Verify ESP32 is powered and connected" +echo " 2. Check kernel logs: dmesg | grep -i esp" +echo " 3. Try scanning for WiFi: sudo iw dev wlan0 scan" +echo "" +log_info "For troubleshooting, see: docs/troubleshooting.md" +echo ""