DockerPi RISCV ProtoType Board SKU: EP-0117

From 52Pi Wiki
Jump to navigation Jump to search

DockerPi RISCV ProtoType Board

Description

This is a control board with onboard RISC-V microprocessor (GD32VF103), which belongs to the DockerPi series expansion board.
It communicates with the Raspberry Pi (or similar SBC) through I2C.
The factory program allows the user to control the changes of the two LEDs.
The software is fully open source, allowing users to program in JTAG mode.
There are 2 user indication LEDs, power LEDs, and all IOs.
It is suitable for coprocessors, analog conversions, low-power computing and other occasions.
You can customize a dockper pi-like device by using the RISCV prototype board, with a custom I2C address, and make it a coprocessor for your Raspberry Pi.
Warning:

Please pay attention to the working characteristics of the microprocessor's GPIO during secondary development. Some pins cannot be compatible with 5V level, and some pins do not support high current drive.
The RISC-V architecture is very different from ARM.
You must read related manuals carefully before performing secondary development on it.

Features

  • DockerPi series expansion board
  • Communicate with Raspberry Pi (or similar SBC) through I2C interface
  • Secondary development through JTAG interface, open source.
  • The factory preset program has the following characteristics
    • I2C control LED through program
    • I2C control LED by command
  • Support synergy with other DockerPi series
  • Low power consumption, high performance, and high energy efficiency

Specifications

  • On-board reset button / TAMP button
  • 32.768kHz crystal on board
  • 8MHz crystal on board
  • RISC-V architecture
  • Multiple extension pins on board
  • Jlink/JTAG program interface
  • Device default address: 0x41

Gallery

Package Includes

Getting Start

Development and debugging methods

  • 1. How to connect the JTAG debugger on the hardware.
Debugger recommendation: JLink V9
Debugger protocol: JTAG
  • 2. Install Platform IO using Visual Studio Code.

Download Visual Studio Code: [ https://code.visualstudio.com/ ] and install it.

  • 3. Install the GD32V library using Platform IO.

platformio platform install gd32v

  • 4. Create a new example in PIO Home
  • 5. Modify the debug and download protocol of platform.ini file as following parameters.
 upload_protocol = jlink
 debug_tool = jlink
 board = sipeed-longan-nano-lite
  • 6. Download Zadig and replace the JLink driver.
  • 7. Replace the main.c file with following code.
#include "gd32vf103.h"
#include "systick.h"
#include <stdio.h>
#include <stdint.h>
 
/* This address will generate I2C address: 0x41, you can detect this address by using "i2cdetect -y 1" on Raspberry Pi  
It will convert 8 bit address to 7bit address, for example, 0x82 binary is 1000 0010 ,shift right 1 bit, it became to 0100 0001, convert it to hex is 0x41
*/
#define I2C0_SLAVE_ADDRESS7 0x82
 
uint8_t ubRegIndex = 0;
uint8_t aReceiveBuffer[255];
 
/* GD32VF103 I2C event handler */
void I2C0_EV_IRQHandler(void)
{
    /* Received request */
    if (i2c_interrupt_flag_get(I2C0, I2C_INT_FLAG_ADDSEND))
    {
        i2c_interrupt_flag_clear(I2C0, I2C_INT_FLAG_ADDSEND);
        /* here are 2 possibilities for receiving a host write, write address / write data. */
    }
    else if (i2c_interrupt_flag_get(I2C0, I2C_INT_FLAG_RBNE))
    {
        if (ubRegIndex == 0)
        {
            ubRegIndex = i2c_data_receive(I2C0);
        }
        else
        {
            aReceiveBuffer[ubRegIndex++] = i2c_data_receive(I2C0);
        }
        /* After receiving the host read signal, you should send the read content */
    }
    else if (i2c_interrupt_flag_get(I2C0, I2C_INT_FLAG_TBE))
    {
        i2c_data_transmit(I2C0, aReceiveBuffer[ubRegIndex++]);
        /* If the host is stopped, it should stop. */
    }
    else if (i2c_interrupt_flag_get(I2C0, I2C_INT_FLAG_STPDET))
    {
        i2c_stop_on_bus(I2C0);
        ubRegIndex = 0;
        /* If you receive a NACK, it also means that the host does not want to send any more data.. */
    }
    else if (i2c_interrupt_flag_get(I2C0, I2C_INT_FLAG_AERR))
    {
        ubRegIndex = 0;
    }
}
/* IRQ handler, if you want to add some interrupt request put here */
void I2C0_ER_IRQHandler(void)
{
}
 
int main(void)
{
    /* Clock initialization */
    rcu_periph_clock_enable(RCU_GPIOA);
    rcu_periph_clock_enable(RCU_GPIOB);
    rcu_periph_clock_enable(RCU_GPIOC);
    rcu_periph_clock_enable(RCU_I2C0);
    /* Init 1 x button */
    gpio_init(GPIOC, GPIO_MODE_IPU, GPIO_OSPEED_50MHZ, GPIO_PIN_13);
    /* Init 2 x LED */
    gpio_init(GPIOA, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_1 | GPIO_PIN_2);
    gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_0);
    /* I2C GPIO initialization : PB6 => I2C0_SCL,PB7 => I2C0_SDA */
    gpio_init(GPIOB, GPIO_MODE_AF_OD, GPIO_OSPEED_50MHZ, GPIO_PIN_6 | GPIO_PIN_7);
    /* Reset I2C peripheral */
    i2c_software_reset_config(I2C0, I2C_SRESET_SET);
    i2c_software_reset_config(I2C0, I2C_SRESET_RESET);
    /* I2C clock configuration, as a slave, this is not important, you do not need to modify this line. */
    i2c_clock_config(I2C0, 100000, I2C_DTCY_2);
    /* I2C address configuration */
    i2c_mode_addr_config(I2C0, I2C_I2CMODE_ENABLE, I2C_ADDFORMAT_7BITS, I2C0_SLAVE_ADDRESS7);
    /* Enable I2C funtion */
    i2c_enable(I2C0);
    /* Allow ACK */
    i2c_ack_config(I2C0, I2C_ACK_ENABLE);
    /* Turn on interrupt transactions */
    i2c_interrupt_enable(I2C0, I2C_INT_ERR);
    i2c_interrupt_enable(I2C0, I2C_INT_EV);
    i2c_interrupt_enable(I2C0, I2C_INT_BUF);
 
    eclic_global_interrupt_enable();
    eclic_irq_enable(I2C0_EV_IRQn, 1, 0);
 
/* It is a loop to blink. (2 LED shifting) */
    while (1)
    {
        if(SET ==  gpio_input_bit_get(GPIOC, GPIO_PIN_13)){    
            if (aReceiveBuffer[3] % 2){
                gpio_bit_set(GPIOB, GPIO_PIN_0);
            }else{
                gpio_bit_reset(GPIOB, GPIO_PIN_0);
            }
            gpio_bit_set(GPIOA, GPIO_PIN_1);               /* Turn on  LED */
            gpio_bit_reset(GPIOA, GPIO_PIN_2);             /* Turn off  LED */
            delay_1ms(aReceiveBuffer[1] * 50 + 100);       /*  delay for a while */
            gpio_bit_set(GPIOA, GPIO_PIN_2);               /* Turn on  LED */
            gpio_bit_reset(GPIOA, GPIO_PIN_1);             /* Turn off  LED */
            delay_1ms(aReceiveBuffer[1] * 50 + 100);       /*  delay for a while */
        }
    }
}
  • 8. Compile and download to DockerPi RISCV prototype board by using J-link programmer.
  • 9. Enter debugging mode and end debugging mode.
  • 10.Test on Raspberry Pi.
    • Connect RISCV prototype board to Raspberry Pi via GPIO Pins.
    • Power on Raspberry Pi which already flashed latest Raspbian OS on TF card and open a terminal and typing this command:
i2cdetect -y 1 

you should see following picture:

Riscvi2c.jpg


Keywords

  • RISCV, DockerPi series, GeeekPi, RISCV prototype board, PIO, GD32VF103, Raspberry Pi 4B, Raspberry Pi cooperate MCU