├── LICENSE ├── README.md └── ESP32_SEA_SPIFFS_Loader.ino /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Cellgalvano 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESP32_SEA_SPIFFS_Loader 2 | SPIFFS Bitstreamloader for the Spartan Edge Accelerator Board (no SD Card required) 3 | 4 | The Spartan Edge Accelerator Boards loads the bitstream into the fpga via the onboard ESP32. 5 | Default Sketch: 6 | Micro SD Card --> ESP32 --> Spartan-7 (via Slave Serial Configuration Mode) 7 | 8 | This sketch simply uses the onboard SPI flash chip (W25Q32JV, 4MB) to store the bitstream next to the ESP32 code. 9 | By default the ESP32 allows you to use the normaly unused space on the flash to store files using [SPIFFS](https://github.com/pellepl/spiffs). 10 | ESP32_SEA_SPIFFS_Loader: 11 | SPI flash (SPIFFS) --> ESP32 --> Spartan-7 (via Slave Serial Configuration Mode) 12 | 13 | 14 | ### Installation 15 | 1. Clone the repository to your Arduino Sketchbook folder 16 | 2. Install the [ESP32 Arduino Core](https://github.com/espressif/arduino-esp32) 17 | 3. Install the [ESP32 SPIFFS Upload Plugin](https://github.com/me-no-dev/arduino-esp32fs-plugin) 18 | 4. Compile the Sketch and upload it to the Spartan Edge Board (select the "DOIT ESP32 DEVKIT" board from the tools menu) 19 | 5. Set the switch "K5" to the "Slave" position 20 | 6. Create a folder called "data" within the Sketch folder 21 | 7. Place your bitstream for the Spartan-7 FPGA in the "data" folder an name it "default.bit" 22 | 8. Upload the SPIFFS filesystem to the ESP32 via the Arduino IDE Plugin in the tools menu 23 | 24 | If you want to update the bitstream just replace the file in the data folder and reupload the filesystem. 25 | 26 | ### Sources 27 | * https://github.com/sea-s7/spartan-edge-esp32-boot 28 | * https://www.xilinx.com/support/documentation/user_guides/ug470_7Series_Config.pdf 29 | * https://github.com/espressif/arduino-esp32/tree/master/libraries/SPIFFS 30 | -------------------------------------------------------------------------------- /ESP32_SEA_SPIFFS_Loader.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ESP32_SEA_SPIFFS_Loader 3 | Version 1.1 4 | Loads a bitstream named "default.bit" from the SPIFFS to the Spartan-7 FPGA on the Spartan Edge Accelerator Board. 5 | This makes the board usable without a sd card. 6 | */ 7 | 8 | #include "FS.h" 9 | #include "SPIFFS.h" 10 | 11 | #define XFPGA_CCLK_PIN 17 12 | #define XFPGA_DIN_PIN 27 13 | #define XFPGA_PROGRAM_PIN 25 14 | #define XFPGA_INTB_PIN 26 15 | #define XFPGA_DONE_PIN 34 16 | 17 | char buf[8192]; 18 | 19 | void setup() { 20 | Serial.begin(115200); 21 | Serial.println(); 22 | Serial.println("ESP32-SEA-SPIFFS-Loader V1.1"); 23 | if(!SPIFFS.begin(true)){ 24 | Serial.println("SPIFFS Mount Failed!"); 25 | while(true){ 26 | Serial.println("Please upload a valid SPIFFS filesystem!"); 27 | delay(1000); 28 | } 29 | } 30 | 31 | Serial.println(); 32 | 33 | pinMode(XFPGA_INTB_PIN, INPUT); 34 | pinMode(XFPGA_DONE_PIN, INPUT); 35 | pinMode(XFPGA_PROGRAM_PIN, OUTPUT); 36 | 37 | Serial.print("FPGA: Resetting ... "); 38 | // reset FPGA configuration logic 39 | digitalWrite(XFPGA_PROGRAM_PIN, LOW); 40 | pinMode(XFPGA_CCLK_PIN, OUTPUT); 41 | digitalWrite(XFPGA_CCLK_PIN, LOW); 42 | digitalWrite(XFPGA_PROGRAM_PIN, HIGH); 43 | 44 | // wait until FPGA reports reset complete 45 | while(digitalRead(XFPGA_INTB_PIN) == 0) {} 46 | Serial.println("DONE!"); 47 | 48 | loadBitstream(); 49 | } 50 | 51 | void loop() { 52 | 53 | } 54 | 55 | void loadBitstream(){ 56 | Serial.println("Opening bitstream file: default.bit"); 57 | 58 | File file = SPIFFS.open("/default.bit"); 59 | if(!file || file.isDirectory()){ 60 | Serial.println("Could not open default.bit!"); 61 | while(true){} 62 | } 63 | 64 | long startTime = millis(); 65 | 66 | // we dont need to skip the header in the bit file, the configuration logic will ignore data until the sync word 0xAA995566 is received 67 | 68 | Serial.print("Loading FPGA ... "); 69 | pinMode(XFPGA_DIN_PIN, OUTPUT); 70 | 71 | while(file.available()){ 72 | int cnt = file.readBytes(buf, sizeof(buf)); 73 | for(int i=0; i