Elbert S7 FPGA Development module

SD card test on Elbert S7

5 views April 16, 2025 akash-s 0

Introduction

In this article, we’ll explore the process of creating an SD card test project using Vivado and Vitis Unified IDE for the Elbert S7 FPGA Development Board. Our design will feature a MicroBlaze soft processor, which will be integrated with an SD card interface via the AXI bus. This project will allow us to perform basic read and write operations on the SD card, helping to verify the functionality of the SD card interface on the Elbert S7. Although MicroBlaze designs can utilize either PLB or AXI bus systems, we’ll focus on the AXI bus for this tutorial. For detailed information on MicroBlaze and additional resources, including the datasheet, please visit AMD’s dedicated MicroBlaze page.

Prerequisites:

Hardware:

  • Elbert S7 FPGA Development Board.
  • SD card.
  • USB Type C cable.

Software:

  • AMD Vivado Design Suite 2024.1
  • Vitis Unified IDE 2024.1.
Creating Microblaze based Hardware Platform for Elbert S7

The following steps will walk you through the process of creating a new project with Vivado and building a hardware platform with MicroBlaze soft processor using an IP integrator. Numato Lab’s Elbert S7 FPGA Development Board is used in this example, but any compatible FPGA platform can be used with minor changes to the steps. Screenshots are added wherever possible to make the process easier for the reader.

Step 1:

Download and install Vivado Board Support Package files for Elbert S7 from here.

Step 2:

Launch Vivado Design Suite, and go to “File->Project->New” to create a new project. The “New project” wizard will pop up. Click “Next” to continue.

Step 3:

In the “Project Name” wizard, type in a name for the project and save it at a convenient location. For this example, we shall use “SD_card” as the project name (feel free to use any name). Select the checkbox below to keep all project files in a single folder. Click “Next” to proceed.

Step 4:

In the Project Type window, select RTL Project and check the option “Do not specify sources at this time”. Click Next.

Step 5:

At the “Default Part” wizard, select “Boards” and then select the “Elbert” board. Click “Next” to continue. If Elbert is not displayed in the Boards list, you need to install Elbert board support files appropriately and retry this step. You can download Elbert board support files for Vivado here. Follow the readme in the link on how to install the Vivado board files in your system.

In the next wizard, click “Finish” to create a new project. When the new project wizard exits, a new project will open up in Vivado with the selected settings.

Step 6:

In the “Flow Navigator” panel, select “Create Block Design” under the IP integrator section. Give an appropriate name (Eg: “SD_card“) to the design and click “OK“.

Step 7:

Go to Diagram window, right click and select “Add IP” from the popup menu. Search for “MicroBlaze” and add it to the design by double-clicking it.

Click “Run Block Automation” present in the “Designer Assistance available” bar on the top left corner of the window to complete the design. Select the settings as shown in the following image. Click “OK” for Vivado to automatically configure the blocks for you.

Step 8:

Double click “Clocking Wizard” IP and customize “Board” and “Output Clocks” settings as shown in the following image.

Step 9:

Run “Connection Automation” and select all the pins.

Step 10:

Go to the Board section, Drag and drop the USB UART from the Board section to the design.

Click on “Run Connection Automation” select all the pins and Click ok.

Connect interrupt output lines from “AXI Uartlite” to the “Concat” block as shown in the below figure.

Step 11:

Add the SD card IP repository to Vivado IP catalog from here.
Open IP Catalog under PROJECT MANAGER, right click on Vivado Repository -> Add
Repository.

Provide the Directory path of the IP and click Select.
And Add the SDcard IP to the Block Design

Step 12 :

After adding the SD card Ip to the Block design, click on Run Block Automation.

Now, connect the clock_32 pin of the SD card IP to the clk_SD pin of the Clocking wizard as shown in the below figure.

Step 13 :

Right click on Sdcard ip and click on Make External.

Step 14 :

In Sources tab of Vivado, Right-Click on ‘Constraints’ and click ‘Add Sources’.

Step 15:

Once the “Add Sources” tab opens select “Add or create constraints”  and click on “Next“.

Click on ‘Create File’ and give ‘SD_test’ as File name. Click ‘OK’ and ‘Finish

Step 16:

Copy the following constraints in your constrains file and save it.

set_property -dict {PACKAGE_PIN F14 IOSTANDARD LVCMOS33} [get_ports sdcard_if_1_0_sd_clk] 
set_property -dict {PACKAGE_PIN F15 IOSTANDARD LVCMOS33} [get_ports sdcard_if_1_0_sd_cs] 
set_property -dict {PACKAGE_PIN D18 IOSTANDARD LVCMOS33} [get_ports sdcard_if_1_0_sd_miso] 
set_property -dict {PACKAGE_PIN C18 IOSTANDARD LVCMOS33} [get_ports sdcard_if_1_0_sd_mosi]

 

Step 17:

Right-click “SD_card” in the “Sources” window, and select “Create HDL Wrapper” from the popup menu. Click “OK” on the window that appears to finish generating a wrapper.

Step 18:

Click “Generate Bitstream” under the “Program And Debug” section to synthesize, implement and generate a bitstream.

Step 20:

After generating the bitstream successfully, select Export -> Export Hardware from the File menu. Click Next.

Select the “include bitstream” checkbox and click Next.

Provide the XSA file name and save it at a suitable location. Click Next and click Finish in the next dialog box.

Step 21:

Select Launch Vitis IDE from the Tools menu.

Step 22:

After Vitis Unified IDE window opens, click on “Open Workspace” and select necessary folder to keep the Vitis files.

Step 23:

Create a new platform for the project, by selecting “Create Platform Component”,  click “Next”, in the Flow tab select the XSA file saved using the step 20 and finally click “Next” and “Finish” respectively.

After successful creation of the platform, build the platform.

Step 18:

Next create the Helloworld Application component by selecting the “Helloworld” template from the “examples”,

In “Create Application Component” tab specify project name and location, click “Next”

Select newly created Platform and click “Next”.

Select the domain as “Standalone_microblaze_0” and click “Next” and click on “Finish

Step 25:

Copy the given source file to the helloworld.c file to test SD card .

#include <stdio.h>
#include "xparameters.h"
#include "xil_types.h"
#include "xstatus.h"
#include "xil_testmem.h"
#include "xil_io.h"
#include "platform.h"
#include "xil_printf.h"

/* SD Card defines */
#define Card_Not_Found            0x04
#define Card_Version_x1           0x01
#define Card_Version_x2           0x02
/* SD Card */
void delay(uint32_t);
void putnum(unsigned int num);
int test_sdcard() 
{    
 print("\r\n\r\n\e[1;33mMicroSD Card Test\e[0m\r\n");   
 print("\e[1;33m*****************\e[0m\r\n\r\n");  

 unsigned int i = 0xffffff;   
 while (i--) {    
} 

u32 baseaddr; 
u32 DataRead;
baseaddr = XPAR_SDCARD_0_BASEADDR;
Xil_Out32((baseaddr) + (0x00) + (0x00), (u32)0x00); 

DataRead = 0; DataRead = Xil_In32((baseaddr) + (0x04) + (0x00));
if (DataRead == Card_Not_Found) { 
 print("\e[1;31mERROR:\e[0m Card Found! Error occurred \r\n\r\n"); 
 return -1;    
} else if (DataRead == Card_Version_x1) {  
     print("\e[1;32mPASSED:\e[0m Card Found! Card inserted is of version \e[1;32mx1\e[0m\r\n");
} else if (DataRead == Card_Version_x2) {       
    print("\e[1;32mPASSED:\e[0m Card Found! Card inserted is of version \e[1;32mx2\e[0m\r\n");   
} else if (DataRead == 0x00) {        
   print("\e[1;31mERROR:\e[0m SD Card not inserted!!\r\n");
   return -2;  
 }    
print("SD Card Test Finished.\r\n");
Xil_Out32((baseaddr) + (0x00000004) + (0x00), (u32)(0x01));
 print("\n\r");   
return 0;
}

int main() {    
init_platform(); 

print("\r\n\r\n\e[1;36mELBERT S7 SD Card Test Suite\e[0m\r\n"); print("\e[1;36m_____________________\e[0m\r\n\r\n");
printf("Welcome to ELBERT S7 SD Card Test Suite\r\n\n");

 // Run SD Card test   
 test_sdcard(); 

print("\r\n\r\nELBERT S7 SD Card Test Finished. Thank You.\r\n\n");  
cleanup_platform();    
return 0;
}

 

After adding the source file build the Project.

Step 26:

Once the build is completed successfully, power up Elbert S7 FPGA Development Board using an USB type C cable. and insert the SD card into the micro SD card slot of Elbert S7 FPGA Development Board.

Step 27:

Program the FPGA on Elbert S7 with a simple boot loop program by selecting the Program Device option from the Vitis menu.

Once the “Program Device” window opens click on “Program“.

Step 28:

Meanwhile, open any serial terminal program (such as PuTTY, Teraterm etc) and open the port corresponding to Elbert S7 with a 9600 baud rate (the default baud rate given in UART IP).  Program the board by selecting the “Run”.

Step 29:

If everything went well, Serial terminal would show the execution is Successful.

Was this helpful?

Leave A Comment
*
*