GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing learn.sparkfun.com — RED-V Development Guide - SparkFun Learn
≡ Pages
Contributors:
Share
Use this URL to share:
IntroductionThis guide will help you get the RED-V RedBoard or Thing Plus up and running for the exhaust port. Depending on personal preference, there are a few environments to get started with the boards. All wings report in... we're going in full-throttle. Warning: Do NOT attempt to reprogram the NXP K22 ARM Cortex-M4. It has proprietary Segger firmware flashed onto the chip, which allows it to upload programs to the SiFive Freedom E310 core. Reprogramming the NXP K22 ARM Cortex-M4 will overwrite the firmware and you will no longer be able to reprogram the board. To replace the firmware, you will need to purchase a license from Segger along with one of their programmers.
Required SoftwareComputer with Freedom Studio installed on it or a Zephyr RTOS build environment set up - that is how we will program the board and interface with it. Suggested ReadingIf you aren't familiar with the RED-V hardware, we recommend checking out these tutorials before continuing. RED-V RedBoard Hookup GuideNovember 22, 2019
This guide will go over the hardware of the RED-V RedBoard.
RED-V Thing Plus Hookup GuideNovember 22, 2019
This guide will go over the hardware of the RED-V Thing Plus.
What is RISC-V?RISC-V (pronounced “risk-five”) is a free and open instruction set architecture (ISA) developed by the Computer Science Division of the University of California, Berkeley. The RISC-V ISA is designed to provide "a new level of free, extensible software and hardware freedom on architecture." According to the RISC-V Foundation, the key benefits of RISC-V are:
For more information about RISC-V, head to the RISC-V Foundation website. Software Installation (Freedom Studio)
Troubleshooting Tip: The Freedom Studio and E SDK has been tested to work with Windows 10, 64-bit. You are free to follow the open source guides to use the OS of your choice, but our technical knowledge is limited to the content of this tutorial.
In this section, we're going to figure out how to get started developing on our SparkFun RED-V development board. There are a handful of development environments out there that are compatible with the RED-V but we're going to be checking out Freedom Studio and Zephyr RTOS. Both development environments have a decent assembly of example code to help get you up and learning RISC-V. Installing Freedom StudioThe quickest way to get started programming your RED-V is through SiFive's Eclipse-based Freedom Studio. If you have not already, head over to SiFive's website to download Freedom Studio for your operating system and unzip the files.
Heads up! When unzipping the Freedom Studio software, make sure that there are no spaces in the file paths.
You'll need to scroll down to the section where it says Freedom Studio and click on your respective operating system. Click on image for a closer view.
Note: For advanced users using command line, we also have a GitHub branch of the Freedom E SDK with the RED-V and RED-V Thing board support package (BSP). This has been tested to enable/disable I/O pins with the sparkfun-welcome.c example.
This is useful if you were to compile code for the boards using command line. To build and upload an example using the branched SDK, the target boards are sparkfun-redv and
sparkfun-redv-thing. The command below is for the RED-V board:
The example below is for the RED-V Thing board:
For the scope of this tutorial, we will focus on the Freedom Studio software.
The Freedom Studio bundle contains some pretty lengthy paths in our system which can occasionally cause problems during extraction on Windows systems. Due to this, it's important to enable long paths as well as unzip to a location like C:/FreedomStudio/ to keep your paths as short as possible. To enable long paths, simply download and double click the below registry file. This is only necessary on a Windows machine. Follow the prompts to install the paths. Drivers (Freedom Studio)With the software installed, you'll need to make sure that the drivers are installed for your computer. If you have a Windows operating system, you will need to install the drivers in order to upload code or send serial data to the FE310. WindowsTo install the drivers, head to the Freedom Studio program's driver folder. The drivers should be located under the following path:
The drivers are dependent on the operating system that you are using. For 64-bit based OS, you'll need to click on the Windows version with the x64 in the folder name. For 32-bit based OS, you'll need to click on the one with the x86 in the folder name. We'll be using a Windows 10 64-bit based OS, so we'll click on the folder named x64 and then dpinst_x64.exe Click on image for a closer view.
After clicking on the driver executable, follow the prompts to install the drivers for your Windows. Examples (Freedom Studio)Example: Hello World!Once everything is unzipped, you'll simply need to run 'FreedomStudio.exe' to install the application. Upon opening Freedom Studio, we'll want to create a new project from one of our example templates. To do this, go to File > New > Freedom E SDK Software Project. Click on image for a closer view.
SparkFun's RED-V RedBoard and Thing Plus are very similar to to SiFive's HiFive1 RevB, so we'll be selecting the HiFive1 Rev B (sifive-hifive-revb) as our target board selection. Click on image for a closer view.
To start, let's keep it simple by flashing the "Hello World" example to our RED-V and see some serial output. Click on image for a closer view.
Select hello from the drop down menu. Hit Finish to load the example. You'll need to wait a little as the example project builds. Click on image for a closer view.
Run
Heads up! Make sure to give the USB-to-JTAG converter some time to enumerate on your computer before uploading the example to your board.
After the sketch builds, a window will open to edit the debug configuration. For now, click on the Close button. Now that the example is built, hit the run button to upload and execute the code on the RED-V. If you have more than one project saved, simply click on the drop down menu next to the run button to select the project to compile and run. Click on the image for a closer view.
Freedom Studio will then attempt to flash and run the sketch. However, your GDB server might be configured incorrectly to be able to flash code through Freedom Studio. To fix this, go to Run Click on the image for a closer view.
Open the SiFive GDB SEGGER J-Link Debugging tree on the left hand side of the window, select your project, and hit the Run button. This will flash the code over USB and begin running your code as well. Click on the image for a closer view.
Drag and DropAnother way to flash is using the shortcut CTRL+B to build all the files; this will generate a *.hex file in the Project Explorer under src Click on the image for a closer view.
You may have noticed that the RED-V shows up as a flash drive when you plug it into your computer. With the window for the drive opened, drag and drop the *.hex directly onto this drive to program the RED-V. Click on the image for a closer view.
What You Should SeeThe program will begin running once the code has been uploaded to the RED-V RedBoard. To see the serial output, you'll need a serial terminal. While you could connect using your favorite serial terminal, we'll use the one built into the Freedom Studio. In the Freedom Studio software, you'll notice a window on the bottom right of the software. Click on the tab labeled as Terminal and then the icon with the monitor. Click on the image for a closer view.
A new window will pop up asking for you to choose your serial terminal and the settings. Click on the Choose terminal: menu and select Serial Terminal. The board will show up as two COM ports on your computer: one for the bootloader and another one for the example program. Most likely the COM port will show up as the one with the second to highest number. The default baud rate of the example projects are set to 115200 baud (8 data bits, no parity, 1 stop bit, default encoding). With the correct settings, hit the OK button to connect. The example code will print " You'll some serial output as the RED-V boots up. Once it enters the example program, the RED-V RedBoard will output the familiar message that all programmers know and love: "
Click on the image for a closer view.
Heads up! If you do not see the output, it's possible that you selected the wrong COM port. Try closing the terminal window and reopening a new session with a different COM port.
Example: Blink
Heads up! When defining pins for the RED-V, you'll need to reference the GPIO pin of the FE310 as opposed to the silkscreen on the board. Also, make sure to start the index for the GPIO at
0. In order to properly use a pin as an output, make sure to also follow the sequence to disable and enable the I/O pin in the code.
Now that we have output some serial to a terminal window, let's try to blink the LED on the RED-V. Let's just use the example project that we have open already in Freedom Studio. Copy and paste the example below into the text editor.
When ready, hit the run button to compile and upload. You can also compile and drag the *.hex into the drive.
Note: Looking for more information about the Freedom Metal Library? Check out the docs for the API Reference.
What You Should SeeThere'll be an output on the terminal window indicating that we are using the blink code. What we are more interested in is if the LED is turning on and off. Check your board and you should see the built-in LED begin to blink about once a second! Make sure to check out the comments in the example code. Toggling the LED is not as intuitive and straight forward as controlling an LED on an Arduino. Software Installation (Zephyr RTOS)
Troubleshooting Tip: The Zephyr RTOS has been tested to work with Linux (Ubuntu v18.04.3, 64-bit) . You are free to follow the open source guides to use the OS of your choice, but our technical knowledge is limited to the content of this tutorial.
Again, there are a handful of development environments out there that are compatible with the RED-V but for the scope of this tutorial, we're going to be checking out Freedom Studio and Zephyr RTOS. Both development environments have a decent assembly of example code to help get you up and learning RISC-V. Let's check out the Zephyr RTOS software. Installing PythonThe next method to get started is using Zephyr RTOS. We've had the best luck using Zephyr on Linux-based operating systems, so we'd recommend using your favorite Linux distro. From there, we want to make sure we have Python 3 and pip installed, so run the following commands.
Installing CMake and NinjaWe'll need quite a few things like CMake and Ninja to compile things, so run the below code to get all of your dependencies set up.
We'll also need to update CMake on our system, go ahead and download the package here. We used version 3.15.4 on Ubuntu v18.04.3 when writing this tutorial. Run the below commands to extract, make, and install it.
Installing West and Zephyr RTOSZephyr uses a tool called west to build code for and flash the RED-V, we'll want to install this as root to avoid any permissions issues. We used version 0.6.3 on Ubuntu v18.04.3 when writing this tutorial.
Note: When using
west init zephyrproject, make sure to avoid using sudo. Otherwise, you may get an error during compiling. The GitHub issue linked uses a different board but you may run into the same issue.
We'll then want to create and initialize our west project, to do this, run the following.
We'll need the Zephyr SDK as well as this is where all of our toolchains are bundled. Grab it from GitHub and install it in your home directory. If you'd like to install a different version of the SDK, simply change the version number everywhere it shows up.
We'll also need to update our device tree compiler, follow the link below to find an appropriate download. Run the commands below to install the new DTC. Drivers (Zephyr RTOS)
Note: If you are using a Windows or MacOS, there are also drivers available on the Download page. Simply click on the executable or package to install the drivers on the respective operating system.
We'll need some J-Link software so we can communicate with the Segger J-Link OB on the RED-V. Head to Segger to download the software under "J-Link Software and Documentation pack for Linux, DEB installer, 64-bit." Read through the license agreement before accepting the terms and hit the "Download software" button. We used version 6.56a on Ubuntu v18.04.3 when writing this tutorial. We should still be in the Downloads folder, so installing the software is as simple as running the below command. Depending on the software package, you may need to update the version name. Examples (Zephyr RTOS)Examples: Hello WorldPhew, that's all done. Now we can move to the directory that was earlier created when we ran west init zephyrproject and build a project.
We can now check to make sure our RED-V is connected. You should see a SEGGER device pop up when you run lsusb. If it's connected, go ahead and run west flash. Note that this may take a couple of tries, sometimes it helps to give the ol' reset button a tap or two and try again.
What You Should SeeOnce uploaded, try opening a serial terminal to connect to the RED-V. Let's use the GNU screen. If you don't have it installed yet, type the following in the command line.
There are two serial ports that the RED-V enumerates to when inserted into the USB port. Type the following command to view the serial ports connected.
Unplug and replug the RED-V to your USB port and type the command again. The messages that appear multiple times will be the RED-V. In this case, it should either be ttyACM0 or ttyACM1. Connect to one of the ports using the following command set at 115200 baud.
Since the example code only prints the message once, we'll need to hit the reset button once on the RED-V. You should see something similar to the Hello Wold example in Freedom Studio.
Note: If you do not see the following message, try connecting to the other serial port by adjusting the port number. Make sure to terminate the session using the following instructions listed below.
To disconnect CTRL + A and then \. You'll be asked by the application if you would like to exit. Type y and ENTER to exit the session. If you want to build a different project, simply delete the build directory using the following command to delete the folder. Then run west build again for your other project.
For those that prefer the GUI, just head to the folder and to manually delete. Examples: BlinkyLet's try to control the build-in LED on the RED-V. Head to the blink example and modify for GPIO pin 5.
You can also navigate to the example using the GUI to open the blink example. Once the modified.c file is open, change the definition for
After changing, save the changes and hit CTRL+C in the terminal window. Head back to the zephyr folder to delete the build folder if you have not already. Then recompile the blink example and flash it to your RED-V board.
What You Should SeeCheck the built-in LED on the RED-V board. You should see the build-in LED blink every second! TroubleshootingFreedom StudioBelow is an issue that you may run into when using the RED-V in Freedom Studio. Issues Uploading to the RED-V AgainThere are a few reasons why if you have problems uploading code. If you recently uploaded code and the board is still connected to your computer, you'll need to make sure to hit terminate (i.e. the button that looks like a red square) before uploading again. This is because Freedom Studio is still connected to the board in debug mode. If you uploaded several times to the board and have issues uploading after clicking on the terminate button, try disconnecting the RED-V from your USB port. Then re-insert the board back. Zephyr RTOSBelow is one issue that you may run into when using the RED-V in Zephry RTOS. Issues CompilingIf you have issues compiling, you may have missed a step when installing the software for the Zephry RTOS. Try going through the command lines again to ensure that the software and tools are installed correctly. You also may need to run the west build command a few more times to compile. Resources and Going FurtherNow that you've successfully got your RED-V up and running, it's time to incorporate it into your own project! For more information, check out the resources below:
Or check out the RISC-V assembly and C programming tutorial by Martin Fink from Western Digital using PlatformIO IDE. The board HiFive1 development board which is similar to the RED-V development board. You may need to adjust the values so that the code applies to the GPIO pins on the RED-V's FE310-002. Or check out this blog post for ideas.
Share
Use this URL to share:
Sections
Introduction
What is RISC-V?
Software Installation (Freedom Studio)
Drivers (Freedom Studio)
Examples (Freedom Studio)
Software Installation (Zephyr RTOS)
Drivers (Zephyr RTOS)
Examples (Zephyr RTOS)
Troubleshooting
Resources and Going Further
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |