Skip to content

Commit

Permalink
platform: add Radxa ROCK 5B platform support
Browse files Browse the repository at this point in the history
Signed-off-by: Nascs <nascs@radxa.com>
  • Loading branch information
nascs authored and tingleby committed Oct 12, 2023
1 parent f7b8799 commit db1f520
Show file tree
Hide file tree
Showing 8 changed files with 339 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ARM
* [ADLINK IPi-SMARC ARM](../master/docs/adlink_ipi_arm.md)
* [Radxa ROCK 3C](../master/docs/radxa_rock_3c.md)
* [Radxa ROCK 5A](../master/docs/radxa_rock_5a.md)
* [Radxa ROCK 5B](../master/docs/radxa_rock_5b.md)
* [Rock Pi 4](../master/docs/rockpi4.md)

MIPS
Expand Down
37 changes: 36 additions & 1 deletion api/mraa/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ typedef enum {
MRAA_SIEMENS_IOT2050 = 26, /**< Siemens IOT2050 board */
MRAA_RADXA_ROCK_3C = 27, /**< Radxa ROCK 3 Model C */
MRAA_VISIONFIVE = 28, /**< StarFive VisionFive board */
MRAA_RADXA_ROCK_5A = 29, /**< Radxa ROCK 5 Model A */
MRAA_RADXA_ROCK_5A = 29, /**< Radxa ROCK 5 Model A */
MRAA_RADXA_ROCK_5B = 30, /**< Radxa ROCK 5 Model B */

// USB platform extenders start at 256
MRAA_FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
Expand Down Expand Up @@ -213,6 +214,40 @@ typedef enum {
MRAA_RADXA_ROCK_5A_PIN40 = 40
} mraa_radxa_rock_5a_wiring_t;

/**
* Radxa ROCK 5 Model B GPIO numbering enum
*/
typedef enum {
MRAA_RADXA_ROCK_5B_PIN3 = 3,
MRAA_RADXA_ROCK_5B_PIN5 = 5,
MRAA_RADXA_ROCK_5B_PIN7 = 7,
MRAA_RADXA_ROCK_5B_PIN8 = 8,
MRAA_RADXA_ROCK_5B_PIN10 = 10,
MRAA_RADXA_ROCK_5B_PIN11 = 11,
MRAA_RADXA_ROCK_5B_PIN12 = 12,
MRAA_RADXA_ROCK_5B_PIN13 = 13,
MRAA_RADXA_ROCK_5B_PIN15 = 15,
MRAA_RADXA_ROCK_5B_PIN16 = 16,
MRAA_RADXA_ROCK_5B_PIN18 = 18,
MRAA_RADXA_ROCK_5B_PIN19 = 19,
MRAA_RADXA_ROCK_5B_PIN21 = 21,
MRAA_RADXA_ROCK_5B_PIN22 = 22,
MRAA_RADXA_ROCK_5B_PIN23 = 23,
MRAA_RADXA_ROCK_5B_PIN24 = 24,
MRAA_RADXA_ROCK_5B_PIN26 = 26,
MRAA_RADXA_ROCK_5B_PIN27 = 27,
MRAA_RADXA_ROCK_5B_PIN28 = 28,
MRAA_RADXA_ROCK_5B_PIN29 = 29,
MRAA_RADXA_ROCK_5B_PIN31 = 31,
MRAA_RADXA_ROCK_5B_PIN32 = 32,
MRAA_RADXA_ROCK_5B_PIN33 = 33,
MRAA_RADXA_ROCK_5B_PIN35 = 35,
MRAA_RADXA_ROCK_5B_PIN36 = 36,
MRAA_RADXA_ROCK_5B_PIN37 = 37,
MRAA_RADXA_ROCK_5B_PIN38 = 38,
MRAA_RADXA_ROCK_5B_PIN40 = 40
} mraa_radxa_rock_5b_wiring_t;

/**
* Radxa ROCK 3 Model C GPIO numbering enum
*/
Expand Down
35 changes: 35 additions & 0 deletions api/mraa/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ typedef enum {
RADXA_ROCK_3C = 27, /**< Radxa ROCK 3 Model C */
VISIONFIVE = 28, /**< StarFive VisionFive board */
RADXA_ROCK_5A = 29, /**< Radxa ROCK 5 Model A */
RADXA_ROCK_5B = 30, /**< Radxa ROCK 5 Model B */

FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */

Expand Down Expand Up @@ -204,6 +205,40 @@ typedef enum {
RADXA_ROCK_5A_PIN40 = 40
} RadxaRock5AWiring;

/**
* Radxa ROCK 5 Model B GPIO numbering enum
*/
typedef enum {
RADXA_ROCK_5B_PIN3 = 3,
RADXA_ROCK_5B_PIN5 = 5,
RADXA_ROCK_5B_PIN7 = 7,
RADXA_ROCK_5B_PIN8 = 8,
RADXA_ROCK_5B_PIN10 = 10,
RADXA_ROCK_5B_PIN11 = 11,
RADXA_ROCK_5B_PIN12 = 12,
RADXA_ROCK_5B_PIN13 = 13,
RADXA_ROCK_5B_PIN15 = 15,
RADXA_ROCK_5B_PIN16 = 16,
RADXA_ROCK_5B_PIN18 = 18,
RADXA_ROCK_5B_PIN19 = 19,
RADXA_ROCK_5B_PIN21 = 21,
RADXA_ROCK_5B_PIN22 = 22,
RADXA_ROCK_5B_PIN23 = 23,
RADXA_ROCK_5B_PIN24 = 24,
RADXA_ROCK_5B_PIN26 = 26,
RADXA_ROCK_5B_PIN27 = 27,
RADXA_ROCK_5B_PIN28 = 28,
RADXA_ROCK_5B_PIN29 = 29,
RADXA_ROCK_5B_PIN31 = 31,
RADXA_ROCK_5B_PIN32 = 32,
RADXA_ROCK_5B_PIN33 = 33,
RADXA_ROCK_5B_PIN35 = 35,
RADXA_ROCK_5B_PIN36 = 36,
RADXA_ROCK_5B_PIN37 = 37,
RADXA_ROCK_5B_PIN38 = 38,
RADXA_ROCK_5B_PIN40 = 40
} RadxaRock5BWiring;

/**
* Radxa ROCK 3 Model C GPIO numbering enum
*/
Expand Down
47 changes: 47 additions & 0 deletions docs/radxa_rock_5b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Radxa ROCK 5 Model B {#_Radxa}
====================

Radxa ROCK 5 Model B is a Rockchip RK3588 based SBC(Single Board Computer) by Radxa. It can run Android or Linux. Radxa ROCK 5 Model B features a four core ARM processor, 64bit dual channel 5500Mb/s LPDDR5, HDMI up to 8K60fps, MIPI DSI, MIPI CSI, 3.5mm combo audio jack, Wi-Fi 6, Bluetooth 5.0, USB, GbE LAN, and 40-pin color expansion header. Radxa ROCK 5 Model B is powered by the USB Type-C port, and supports 5V input only. The recommended power adapter is 5V/3A without SSD, or 5V/5A with SSD.

Interface notes
---------------

- UART2 is enabled as the default console.
- All UART ports support baud up to 1500000.

Pin Mapping
-----------

Radxa ROCK 5 Model B has a 40-pin expansion header. Each pin is distinguished by the color.

| Function5| Function4| Function3| Function2| Function1| PIN | PIN | Function1| Function2| Function3| Function4|
|-----------|-------------|-------------|-------------|-----------|:------|------:|----------|-------------|------------|------------|
| | | | | 3V3| 1 | 2 | +5.0V| | | |
| | | I2C7_SDA_M3| PWM15_IR_M1| GPIO4_B3| 3 | 4 | +5.0V| | | |
| | | I2C7_SCL_M3| PWM14_M1| GPIO4_B2| 5 | 6 | GND| | | |
|SPI1_CS1_M1| I2C8_SDA_M4|UART7_CTSN_M1| PWM15_IR_M0| GPIO3_C3| 7 | 8 | GPIO0_B5| UART2_TX_M0| I2C1_SCL_M0| |
| | | | | GND| 9 | 10 | GPIO0_B6| UART2_RX_M0| I2C1_SDA_M0| |
| | | SPI1_CLK_M1| UART7_RX_M1| GPIO3_C1| 11 | 12 | GPIO3_B5| PWM12_M0| UART3_TX_M1| |
| | | SPI1_MOSI_M1| I2C3_SCL_M1| GPIO3_B7| 13 | 14 | GND| | | |
| | UART7_TX_M1| SPI1_MISO_M1| I2C3_SDA_M1| GPIO3_C0| 15 | 16 | GPIO3_A4| UART4_RX_M1| | |
| | | | | +3.3V| 17 | 18 | GPIO4_C4| UART4_TX_M1| PWM5_M2| |
| | | UART4_RX_M2| SPI0_MOSI_M2| GPIO1_B2| 19 | 20 | GND| | | |
| | | PWM12_M1| SPI0_MISO_M2| GPIO1_B1| 21 | 22 |SARADC_IN4| | | |
| | | UART4_TX_M2| SPI0_CLK_M2| GPIO1_B3| 23 | 24 | GPIO1_B4| UART7_RX_M2| SPI0_CS0_M2| UART9_RX_M1|
| | | | | GND| 25 | 26 | GPIO1_B5| UART7_TX_M2| SPI0_CS1_M2| |
| | SPI3_CLK_M0| I2C0_SDA_M1| PWM7_IR_M3| GPIO4_C6| 27 | 28 | GPIO4_C5| |SPI3_MOSI_M0| |
| | | | PWM15_IR_M3| GPIO1_D7| 29 | 30 | GND| | | |
| | | | PWM13_M2| GPIO1_B7| 31 | 32 | GPIO3_C2| PWM14_M0| I2C8_SCL_M4| |
| | | | PWM8_M0| GPIO3_A7| 33 | 34 | GND| | | |
| | | UART3_RX_M1| PWM13_M0| GPIO3_B6| 35 | 36 | GPIO3_B1| PWM2_M1| UART2_TX_M2| |
| | | | | NC| 37 | 38 | GPIO3_B2| PWM3_IR_M1| UART2_RX_M2| |
| | | | | GND| 39 | 40 | GPIO3_B3| | | |

Supports
--------

You can find additional product support in the following channels:

- [Product Info](https://docs.radxa.com/en/rock5/rock5b)
- [Forums](https://forum.radxa.com/c/rock5)
- [Github](https://github.com/radxa)
30 changes: 30 additions & 0 deletions include/arm/radxa_rock_5b.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Author: Nascs <nascs@radxa.com>
* Copyright (c) Radxa Limited.
*
* SPDX-License-Identifier: MIT
*/

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include "mraa_internal.h"

#define MRAA_RADXA_ROCK_5B_GPIO_COUNT 26
#define MRAA_RADXA_ROCK_5B_I2C_COUNT 4
#define MRAA_RADXA_ROCK_5B_SPI_COUNT 2
#define MRAA_RADXA_ROCK_5B_UART_COUNT 4
#define MRAA_RADXA_ROCK_5B_PWM_COUNT 10
#define MRAA_RADXA_ROCK_5B_AIO_COUNT 1
#define MRAA_RADXA_ROCK_5B_PIN_COUNT 40
#define PLATFORM_NAME_RADXA_ROCK_5B "Radxa ROCK 5B"

mraa_board_t *
mraa_radxa_rock_5b();

#ifdef __cplusplus
}
#endif
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ set (mraa_LIB_ARM_SRCS_NOAUTO
${PROJECT_SOURCE_DIR}/src/arm/de_nano_soc.c
${PROJECT_SOURCE_DIR}/src/arm/radxa_rock_3c.c
${PROJECT_SOURCE_DIR}/src/arm/radxa_rock_5a.c
${PROJECT_SOURCE_DIR}/src/arm/radxa_rock_5b.c
${PROJECT_SOURCE_DIR}/src/arm/rockpi4.c
${PROJECT_SOURCE_DIR}/src/arm/adlink_ipi.c
${PROJECT_SOURCE_DIR}/src/arm/siemens/iot2050.c
Expand Down
6 changes: 6 additions & 0 deletions src/arm/arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "arm/96boards.h"
#include "arm/radxa_rock_3c.h"
#include "arm/radxa_rock_5a.h"
#include "arm/radxa_rock_5b.h"
#include "arm/rockpi4.h"
#include "arm/de_nano_soc.h"
#include "arm/banana.h"
Expand Down Expand Up @@ -97,6 +98,8 @@ mraa_arm_platform()
platform_type = MRAA_RADXA_ROCK_3C;
else if (mraa_file_contains("/proc/device-tree/model", PLATFORM_NAME_RADXA_ROCK_5A))
platform_type = MRAA_RADXA_ROCK_5A;
else if (mraa_file_contains("/proc/device-tree/model", PLATFORM_NAME_RADXA_ROCK_5B))
platform_type = MRAA_RADXA_ROCK_5B;
else if (mraa_file_contains("/proc/device-tree/model", "ROCK Pi 4") ||
mraa_file_contains("/proc/device-tree/model", "ROCK PI 4") ||
mraa_file_contains("/proc/device-tree/model", "ROCK 4")
Expand Down Expand Up @@ -132,6 +135,9 @@ mraa_arm_platform()
case MRAA_RADXA_ROCK_5A:
plat = mraa_radxa_rock_5a();
break;
case MRAA_RADXA_ROCK_5B:
plat = mraa_radxa_rock_5b();
break;
case MRAA_ROCKPI4:
plat = mraa_rockpi4();
break;
Expand Down
Loading

0 comments on commit db1f520

Please sign in to comment.