Alternative Raspberry Pi Board

For several months now, it has become impossible to buy a Raspberry Pi from official resellers, this situation has a very heavy impact on the world of makers and industries, also on our business.

After weeks of searching we have found an alternative Single Board Computer compliant with a part of our boards ROCK 4 SE.

ROCK 4 SE Top view
ROCK 4 SE Bottom view

ROCK 4 SE is a Single Board Computer (SBC) in an ultra small form factor that offers class leading performance and an extensive range of expansion ports . The ROCK 4 SE offers professionals, industrial OEMs, IoT enthusiasts, hobbyists, PC DIY enthusiasts and makers a reliable and extremely capable platform for building and tinkering their ideas into reality. ROCK 4 SE is available in 4GB LPDDR4 RAM option.

ROCK 4 SE Product Brief

The complete features are described on official wiki

Processor64bits hexa core processor Rockchip RK3399-T Dual Cortex-72, frequency 1.5GHz with qual Cortex-A53, frequency 1.0GHz Mali T860MP4 gpu, support OpenGL ES 1.1/2.0/3.0/3.1/3.2, Vulkan 1.0, Open CL 1.1 1.2, DX11.
MemoryLPDDR4 64bit dual channel LPDDR4@3200Mb/s, 1GB/2GB/4GB optioal
StorageeMMC connector, μSD card (μSD slot supports up to 256 GB μSD card), M.2 SSD (M.2 connector supports up to 2T M2 NVME SSD)
DisplayStandard HDMI 2.0 up to 4k@60, MIPI DSI 2 lanes via FPC connector. HDMI and MIPI DSI can work at the same time, support mirror mode or extend mode.
Audio3.5mm jack with mic HD codec that supports up to 24-bit/96KHz audio.
CameraMIPI CSI 2 lanes via FPC connector, support up to 800 MP camera(1mm pitch connector).
Wireless802.11 ac wifi, BT 5.0 with on board or external antenna
USBUSB 3.0 OTG X1, hardware switch for host/device switch, upper one USB 3.0 HOST X1, dedicated USB 3.0 channel, lower one USB 2.0 HOST X2
EthernetGbE LAN with Power over Ethernet (PoE) support additional HAT is required for powering from PoE
IO40-pin expansion header
2 x UART
2 x SPI bus
3 x I2C bus
1 x PCM/I2S
1 x SPDIF
2 x PWM
1 x ADC
6 x GPIO
2 x 5V DC power in
2 x 3.3V DC power in
OthersRTC, RTC battery connector for time backup(optional)
PowerUSB PD, support USB Type C PD 2.0, 9V/2A, 12V/2A. Qualcomm® Quick ChargeTM: Supports QC 3.0/2.0 adapter, 9V/2A, 12V/1.5A
Size85mm x 54mm

If you check the Rock 4 board pinout carefully, you can discover that it is not fully complaint with Raspberry Pi, our boards Dual Can requires the following peripherals:

  • SPI with 2 Chip select on pins 19, 21, 23, 24 and 26
  • I2C for RTC on pins 3 and 5
  • 2 interrupts on pins 15 and 22

On the following table you can see that the second SPI chip select is not available on pin 26 for ROCK 4 SE board.

   
ROCK 4 SERPIPIN LPIN R RPIROCK 4 SE
3V33V3125V5V
SDA_I2C7 / GPIO2_A7SDA_I2C1 / GPIO2345V5V
SCL_I2C7 / GPIO2_B0SCL_I2C1 / GPIO356GNDGND
GPIO2_B3GPIO478UART0_TXD / GPIO14UART2_TXD / GPIO4_C4
GNDGND910UART0_RXD / GPIO15UART2_RXD / GPIO4_C3
GPIO4_C2GPIO171112GPIO18GPIO4_A3
GPIO4_C6GPIO271314GNDGND
GPIO4_C5GPIO221516GPIO23GPIO4_D2
3V3 3V3 1718GPIO24GPIO4_D4
SPI1_TXD / GPIO1_B0SPI0_MOSI / GPIO101920GNDGND
SPI1_RXD / GPIO1_A7SPI0_MISO / GPIO092122GPIO25GPIO4_D5
SPI1_CLK / GPIO1_B1SPI0_SCLK / GPIO112324SPI0_CE0 / GPIO08SPI1_CSn / GPIO1_B2
GNDGND2526SPI0_CE1 / GPIO07ADC_IN0
GPIO2_A0ID_SD / GPIO002728ID_SC / GPIO01GPIO2_A1
GPIO2_B2GPIO052930GNDGND
GPIO2_B1GPIO063132GPIO12GPIO3_C0
GPIO2_B4GPIO133334GNDGND
GPIO4_A5GPIO193536GPIO16GPIO4_A4
GPIO4_D6GPIO263738GPIO20GPIO4_A6
GNDGND3940GPIO21GPIO4_A7
Pinout comparison Raspberry PI vs Rock 4 SE

The result is that only one can bus interface can work…

Can Bus board on Radxa Rock board

Software configuration

It is possible to install 3 different Operating Systems: Android, Debian and Ubuntu Server.

For our test we have downloaded Ubuntu Server 20, follow the official wiki for SD card preparation.

Login with user rock and password rock

Modify file /boot/hw_intfc.conf. Set “on” to enable the optional hardware interfaces while set “off” to disable.

sudo nano /boot/hw_intfc.conf

Enable the following overlays:

intfc:i2c7=on
intfc:spi1=on
intfc:dtoverlay=mcp2515-can0-SG

Save and exit and reboot the board with sudo reboot

Overlay customization

The Ubuntu image contains the following overlay dtbo files (dts file download)

/boot
   |--rockpi-4b-linux.dtb
   |--hw_intfc.conf
   |--overlays
     |--at24c02.dtbo 
     |--console-on-ttyS4.dtbo 
     |--console-on-ttyS2.dtbo 
     |--cpufreq.dtbo 
     |--devspi1.dtbo 
     |--devspi2.dtbo 
     |--imx219.dtbo 
     |--pcie-gen2.dtbo 
     |--raspberrypi-7-inch-lcd.dtbo 
     |--rk3399-usb-host.dtbo 
     |--rk3399-usb-otg.dtbo 
     |--rock-4c-plus-raspberrypi-7inch-touchscreen.dtbo 
     |--rock-4c-plus-radxa-display-8hd.dtbo 
     |--rock-4c-plus-radxa-display-10hd.dtbo 
     |--spi1-waveshare35c.dtbo 
     |--spi1-waveshare35b-v2.dtbo 
     |--spi1-flash.dtbo 
     |--spi1-mcp2515-can0.dtbo 
     |--two-color-led.dtbo 
     |--w1-gpio4-30.dtbo

The spi1-mcp2515-can0.dtbo is not correct for the following problem: clock-frequency = <12000000>;

Our board works with a 16 Mhz oscillator, then we must generate a custom file mcp2515-can0-SG.dtbo.

/* This devicetree overlay is INT pin 15 is GPIO4_C5 --> 4 A= 0, B = 1, C=2, D=3
* Pin is 4 C*8+5 ---> rockchip,pins = <4 21 0 &pcfg_pull_none>;
* Device tree overlay for mcp251x/can0
*/
/dts-v1/;
/plugin/;

/ {
        compatible = "rockchip,rockpi","rockchip,rk3399", "rockchip,rk3399-pinctrl";

        fragment@0 {
                target = <&pinctrl>;

                __overlay__ {
                        mcp2515_int_pin: mcp2515_int_pin {
                                rockchip,pins = <4 21 0 &pcfg_pull_none>;
                        };
                };
        };

        fragment@1 {
                target-path = "/";
                __overlay__ {
                        can_mcp2515_osc: can-mcp2515-osc {
                                compatible = "fixed-clock";
                                clock-frequency = <16000000>;
                                #clock-cells = <0>;
                        };
                };
        };

        fragment@2 {
                target = <&spi1>;

                __overlay__ {
                        status = "okay";
                        max-freq = <10000000>;
                        #address-cells = <1>;
                        #size-cells = <0>;

                        can_mcp2515: can-mcp2515@0 {
                                status = "okay";
                                compatible = "microchip,mcp2515";
                                reg = <0>;
                                interrupt-parent = <&gpio4>;
                                interrupts = <21 2>;
                                spi-max-frequency = <10000000>;
                                clocks = <&can_mcp2515_osc>;
                                vdd-supply = <&vcc3v3_sys>;
                                xceiver-supply = <&vcc3v3_sys>;
                                pinctrl-names = "default";
                                pinctrl-0 = <&mcp2515_int_pin>;
                        };
                };
        };
};

For dtbo generation you must install the device tree compiler

sudo apt update
sudo apt install device-tree-compiler
sudo apt install can-utils
cd /boot/overlays
sudo /usr/bin/dtc -I dts -O dtb -o mcp2515-can0-SG.dtbo -I dts mcp2515-can0-SG.dts
sudo reboot

After the board startup use the following command to start can0 interface

sudo ip link set can0 up type can bitrate 1000000
ifconfig

CAN BUS Test

Test 1: Raspberry Pi CAN TX —-> Rock Pi CAN RX

Raspberry Pi run the command

cangen can1

instead on Rock Pi run

candump can0

Test 2: Rock Pi CAN TX —-> Raspberry Pi CAN RX

Rock Pi run the command

cangen can0

Raspberry Pi run the command

candump can1

If the device trees on both boards are correctly configured and the can adapters are correctly connected you can see the message log under candump terminal.

I2C DETECT

It is possible to detect the RTC with i2cdetect command

rock@rockpi-4b:~$ sudo i2cdetect -y 7
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.