forked from espressif/esp-hosted
-
Notifications
You must be signed in to change notification settings - Fork 2
NOISSUE-Add needed setup for s1 board #1
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
Open
dorcaslitunya
wants to merge
2
commits into
absmach:master
Choose a base branch
from
dorcaslitunya:dorcaslitunya/add-inaugral-configs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
22 changes: 22 additions & 0 deletions
22
esp_hosted_ng/host/platforms/beaglev-fire/beaglev-esp-hosted.dts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /dts-v1/; | ||
| /plugin/; | ||
|
|
||
| / { | ||
| compatible = "microchip,mpfs-icicle-kit"; | ||
|
|
||
| fragment@0 { | ||
| target = <&spi0>; | ||
| __overlay__ { | ||
| #address-cells = <1>; | ||
| #size-cells = <0>; | ||
|
|
||
| status = "okay"; | ||
|
|
||
| spidev@0 { | ||
| compatible = "rohm,dh2228fv"; | ||
| reg = <0>; | ||
| spi-max-frequency = <10000000>; | ||
| }; | ||
| }; | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #!/bin/bash | ||
|
|
||
| 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" |
18 changes: 18 additions & 0 deletions
18
esp_hosted_ng/host/platforms/beaglev-fire/patches/esp_spi.h.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 logs after some commands so that the user can see the expected results?