Add support for the Blueberry development board.

This commit is contained in:
2026-07-27 08:25:25 +08:00
parent 1261d3facb
commit 17b5408cc3
6 changed files with 3575 additions and 7 deletions
File diff suppressed because it is too large Load Diff
+1
View File
@@ -53,6 +53,7 @@ unsigned char getGpioNum(void)
case PI_MODEL_CM4:
case PI_MODEL_3B:
case PI_MODEL_ZERO_2_W:
case PI_MODEL_BLUEBERRY:
case PI_MODEL_ZERO_3_W:
case PI_MODEL_3_PLUS:
case PI_MODEL_RV:
+11
View File
@@ -45,6 +45,17 @@ static void set_pwm_info(int pin)
pwm_info_t.div = 1;
pwm_info_t.div_stepping = 1;
break;
case PI_MODEL_BLUEBERRY:
/* DT pwm1-pi11: wPi 3=PI11; also PI12/PI14/PI13 = wPi 2/9/22 */
if (pin != 2 && pin != 3 && pin != 9 && pin != 22) {
fprintf (stderr, "the pin you choose doesn't support hardware PWM\n") ;
exit(1);
}
pwm_info_t.ccr = 512;
pwm_info_t.arr = 1024;
pwm_info_t.div = 1;
pwm_info_t.div_stepping = 1;
break;
case PI_MODEL_3_PLUS:
if (pin != 2 && pin != 16) {
fprintf (stderr, "the pin you choose doesn't support hardware PWM\n") ;
+64
View File
@@ -869,6 +869,60 @@ static char * physNames_ZERO_2_W[64] =
" GND", "PI03 ",
};
/* Blueberry H1 — DT overlays: i2c0-pi, spidev1_1, pwm1-pi11, ir, uart5 (phys 27 GND) */
static int physToWpi_BLUEBERRY[64] =
{
-1, // 0
-1, -1, // 1, 2
0, -1, // 3, 4
1, -1, // 5, 6
2, 3, // 7, 8
-1, 4, // 9, 10
5, 6, //11, 12
7, -1, //13, 14
8, 9, //15, 16
-1, 10, //17, 18
11, -1, //19, 20
12, 13, //21, 22
14, 15, //23, 24
-1, 16, //25, 26
-1, 18, //27, 28 phys27=GND, wPi17 unused
19, -1, //29, 30
20, 21, //31, 32
22, -1, //33, 34
23, 24, //35, 36
25, 26, //37, 38
-1, 27, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
};
static char * physNames_BLUEBERRY[64] =
{
NULL,
" 3.3V", "5V ",
" PI10", "5V ",
" PI15", "GND ",
" PI12", "PWM.1 ", /* PI11 — overlay pwm1-pi11 */
" GND", "SCL.0 ", /* PI5 — overlay i2c0-pi */
" PI4", "SDA.0 ", /* PI6 */
" PI7", "GND ",
" PI16", "PI14 ",
" 3.3V", "PI0 ",
" PI2", "GND ",
" MISO.1", "RXD.0 ", /* PH8 SPI1 / PH1 UART0 */
" TXD.0", "MOSI.1 ", /* PH0 UART0 / PH7 SPI1 */
" GND", "IR-RX ", /* PH10 — overlay ir */
" GND", "CE.1 ", /* PH9 SPI1 CS1 (not PH5 LED) */
" PI3", "GND ",
" PI9", "PI1 ",
" PI13", "GND ",
" PH4", "PI8 ",
" TXD.5", "SCLK.1 ", /* PH2 UART5 / PH6 SPI1 */
" GND", "RXD.5 ", /* PH3 UART5 */
};
static int physToWpi_RK3399[64] =
{
-1, //0
@@ -2247,6 +2301,12 @@ void OrangePiReadAll(int model)
physNames = physNames_ZERO_2_W;
alts = alts_common;
break;
case PI_MODEL_BLUEBERRY:
printf (" +------+-----+----------+--------+---+Blueberry +---+--------+----------+-----+------+\n");
physToWpi = physToWpi_BLUEBERRY;
physNames = physNames_BLUEBERRY;
alts = alts_common;
break;
case PI_MODEL_ZERO_3_W:
printf (" +------+-----+----------+--------+---+ ZERO3W +---+--------+----------+-----+------+\n");
physToWpi = physToWpi_ZERO_3_W;
@@ -2443,6 +2503,7 @@ void OrangePiReadAll(int model)
case PI_MODEL_CM4:
case PI_MODEL_3B:
case PI_MODEL_ZERO_2_W:
case PI_MODEL_BLUEBERRY:
case PI_MODEL_ZERO_3_W:
case PI_MODEL_3_PLUS:
case PI_MODEL_AI_PRO:
@@ -2524,6 +2585,9 @@ void OrangePiReadAll(int model)
case PI_MODEL_ZERO_2_W:
printf (" +------+-----+----------+--------+---+ ZERO2W +---+--------+----------+-----+------+\n");
break;
case PI_MODEL_BLUEBERRY:
printf (" +------+-----+----------+--------+---+Blueberry +---+--------+----------+-----+------+\n");
break;
case PI_MODEL_ZERO_3_W:
printf (" +------+-----+----------+--------+---+ ZERO3W +---+--------+----------+-----+------+\n");
break;
+170 -7
View File
@@ -252,6 +252,27 @@ static int ORANGEPI_PIN_MASK_ZERO_2_W[12][32] = //[BANK] [INDEX]
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PE
};
/*
* Blueberry H1 (PLL-IO.NET + board DT):
* Always-on: UART0 PH0/PH1, LED PH5 (not in mask)
* Overlays: I2C0 PI5/6, SPI1 PH6-9 (CS1), PWM1 PI11, IR PH10, UART5 PH2/3
*/
static int ORANGEPI_PIN_MASK_BLUEBERRY[12][32] = //[BANK] [INDEX]
{
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PB
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PC
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PD
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PE
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PF
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PG
{ 0, 1, 2, 3, 4,-1, 6, 7, 8, 9,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PH (PH5 = kernel LED)
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PI
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PJ
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PK
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PL
};
static int ORANGEPI_PIN_MASK_ZERO_3_PLUS[12][32] = //[BANK] [INDEX]
{
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA
@@ -956,6 +977,31 @@ int pinToGpio_ZERO_2_W[64] =
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
};
/* Blueberry H1 — classic wiringPi phys→wPi; phys 27 is GND so wPi 17 unused */
int pinToGpio_BLUEBERRY[64] =
{
266, 271, // 0, 1 PI10, PI15
268, 267, // 2, 3 PI12, PI11
261, 260, // 4, 5 PI5, PI4
262, 263, // 6, 7 PI6, PI7
272, 270, // 8, 9 PI16, PI14
256, 258, //10,11 PI0, PI2
232, 225, //12,13 PH8, PH1
224, 231, //14,15 PH0, PH7
234, -1, //16,17 PH10, (phys27 GND)
233, 259, //18,19 PH9, PI3
265, 257, //20,21 PI9, PI1
269, 228, //22,23 PI13, PH4
264, 226, //24,25 PI8, PH2
230, 227, //26,27 PH6, PH3
-1, -1, //28,29
-1, -1, //30,31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
};
int pinToGpio_ZERO_3_PLUS[64] =
{
229, 228, 72, 226, 227, 73, 65,
@@ -1833,7 +1879,7 @@ int physToGpio_ZERO_2[64] =
int physToGpio_ZERO_2_W[64] =
{
-1,
-1,
-1, -1,
264, -1,
263, -1,
@@ -1859,6 +1905,35 @@ int physToGpio_ZERO_2_W[64] =
-1, -1, -1, -1, -1, -1, -1, // ... 63
};
/* Blueberry H1 phys→GPIO (board DT + PLL-IO.NET) */
int physToGpio_BLUEBERRY[64] =
{
-1, // 0
-1, -1, // 1, 2 3.3V, VBUS
266, -1, // 3, 4 PI10, VBUS
271, -1, // 5, 6 PI15, GND
268, 267, // 7, 8 PI12, PI11
-1, 261, // 9,10 GND, PI5
260, 262, //11,12 PI4, PI6
263, -1, //13,14 PI7, GND
272, 270, //15,16 PI16, PI14
-1, 256, //17,18 3.3V, PI0
258, -1, //19,20 PI2, GND
232, 225, //21,22 PH8, PH1
224, 231, //23,24 PH0, PH7
-1, 234, //25,26 GND, PH10
-1, 233, //27,28 GND, PH9
259, -1, //29,30 PI3, GND
265, 257, //31,32 PI9, PI1
269, -1, //33,34 PI13, GND
228, 264, //35,36 PH4, PI8
226, 230, //37,38 PH2, PH6
-1, 227, //39,40 GND, PH3
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 56
-1, -1, -1, -1, -1, -1, -1, // ... 63
};
int physToGpio_ZERO_3_PLUS[64] =
{
-1, // 0
@@ -2890,10 +2965,74 @@ void piGpioLayoutOops (const char *why)
void piBoardId (int * model)
{
FILE *cpuFd ;
char line [40] ;
char line [128] ;
char *c;
char revision[40];
unsigned int i = 0;
const char *env;
*model = -1;
/* Blueberry overrides (no /etc/orangepi-release on this board) */
env = getenv ("WIRINGPI_MODEL");
if (env != NULL && (strcmp (env, "blueberry") == 0 || strcmp (env, "Blueberry") == 0))
{
*model = PI_MODEL_BLUEBERRY;
if (wiringPiDebug)
printf ("piBoardId: model = %d (WIRINGPI_MODEL)\n", *model);
return;
}
if ((cpuFd = fopen ("/proc/device-tree/model", "r")) != NULL)
{
memset (line, 0, sizeof (line));
if (fread (line, 1, sizeof (line) - 1, cpuFd) > 0)
{
if (strstr (line, "Blueberry") != NULL || strstr (line, "blueberry") != NULL)
{
fclose (cpuFd);
*model = PI_MODEL_BLUEBERRY;
if (wiringPiDebug)
printf ("piBoardId: model = %d (device-tree: %s)\n", *model, line);
return;
}
}
fclose (cpuFd);
}
if ((cpuFd = fopen ("/etc/blueberry-release", "r")) != NULL)
{
line [0] = 0;
while (fgets (line, sizeof (line), cpuFd) != NULL)
if (strncmp (line, "BOARD=", 6) == 0)
break ;
fclose (cpuFd);
if (strncmp (line, "BOARD=", 6) == 0)
{
for (c = &line [strlen (line) - 1] ; (c >= line) && ((*c == '\n') || (*c == '\r')) ; --c)
*c = 0 ;
for (c = line ; *c ; ++c)
if (*c == '=')
break ;
if (*c == '=')
{
c++;
i = 0;
while (*c && i < sizeof (revision) - 2)
revision[i++] = *c++;
revision[i] = '.';
revision[i + 1] = 0;
if (strncmp (revision, "blueberry.", 10) == 0)
{
*model = PI_MODEL_BLUEBERRY;
if (wiringPiDebug)
printf ("piBoardId: model = %d (blueberry-release)\n", *model);
return;
}
}
}
}
if ((cpuFd = fopen ("/etc/orangepi-release", "r")) == NULL)
if ((cpuFd = fopen ("/etc/armbian-release", "r")) == NULL)
@@ -3138,6 +3277,7 @@ void sunxi_pwm_set_enable(int en)
case PI_MODEL_ZERO_2:
case PI_MODEL_ZERO_2_W:
case PI_MODEL_ZERO_3_PLUS:
case PI_MODEL_BLUEBERRY:
if(SUNXI_PWM_TYPE == SUNXI_V2_PWM_TYPE) {
sunxi_pwm_set_enable_v2(en);
@@ -3275,6 +3415,7 @@ void orangepi_pwm_set_tone(int pin,int freq)
case PI_MODEL_ZERO_2:
case PI_MODEL_ZERO_2_W:
case PI_MODEL_ZERO_3_PLUS:
case PI_MODEL_BLUEBERRY:
H618_set_pwm_reg(pin,&sunxi_gpio_info_t);
@@ -3522,6 +3663,7 @@ void orangepi_pwm_set_clk(int pin,int clk)
case PI_MODEL_ZERO_2:
case PI_MODEL_ZERO_2_W:
case PI_MODEL_ZERO_3_PLUS:
case PI_MODEL_BLUEBERRY:
if ((clk < 1) || (clk > 256)) {
fprintf (stderr, "gpio: clock must be between 1 and 256\n") ;
@@ -3751,6 +3893,7 @@ void orangepi_pwm_set_period(int pin, unsigned int period_cys)
case PI_MODEL_ZERO_2:
case PI_MODEL_ZERO_2_W:
case PI_MODEL_ZERO_3_PLUS:
case PI_MODEL_BLUEBERRY:
if ((period_cys < 1) || (period_cys > 65536)) {
fprintf (stderr, "gpio: range must be between 1 and 65536\n") ;
@@ -3932,6 +4075,7 @@ void orangepi_pwm_set_act(int pin, int act_cys)
case PI_MODEL_ZERO_2:
case PI_MODEL_ZERO_2_W:
case PI_MODEL_ZERO_3_PLUS:
case PI_MODEL_BLUEBERRY:
if ((act_cys < 0) || (act_cys > 65535)) {
fprintf (stderr, "gpio: range must be between 0 and 65535\n");
@@ -4098,7 +4242,7 @@ void orangepi_pwm_set_act(int pin, int act_cys)
void pwmSetMode(int pin,int mode)
{
if (OrangePiModel == PI_MODEL_ZERO_2 || OrangePiModel == PI_MODEL_ZERO_2_W \
|| OrangePiModel == PI_MODEL_ZERO_3_PLUS) {
|| OrangePiModel == PI_MODEL_ZERO_3_PLUS || OrangePiModel == PI_MODEL_BLUEBERRY) {
H618_set_pwm_reg(pin,&sunxi_gpio_info_t);
}
@@ -5157,6 +5301,7 @@ void set_soc_info(void)
case PI_MODEL_ZERO_2:
case PI_MODEL_ZERO_2_W:
case PI_MODEL_ZERO_3_PLUS:
case PI_MODEL_BLUEBERRY:
sunxi_gpio_info_t.gpio_base_addr = H6_GPIO_BASE_ADDR;
sunxi_gpio_info_t.r_gpio_base_addr = H6_R_GPIO_BASE_ADDR;
sunxi_gpio_info_t.gpio_base_offset = 0x0;
@@ -5233,6 +5378,7 @@ void set_soc_info(void)
case PI_MODEL_ZERO_2:
case PI_MODEL_ZERO_2_W:
case PI_MODEL_ZERO_3_PLUS:
case PI_MODEL_BLUEBERRY:
sunxi_gpio_info_t.pwm_en = SUNXI_V2_PWM_EN_REG;
sunxi_gpio_info_t.pwm_type = SUNXI_V2_PWM_TYPE; // H616
sunxi_gpio_info_t.pwm_bit_act = SUNXI_V2_PWM_ACT_STA;
@@ -5335,6 +5481,11 @@ int wiringPiSetup (void)
physToGpio = physToGpio_ZERO_2_W;
ORANGEPI_PIN_MASK = ORANGEPI_PIN_MASK_ZERO_2_W;
break;
case PI_MODEL_BLUEBERRY:
pinToGpio = pinToGpio_BLUEBERRY;
physToGpio = physToGpio_BLUEBERRY;
ORANGEPI_PIN_MASK = ORANGEPI_PIN_MASK_BLUEBERRY;
break;
case PI_MODEL_ZERO_3_W:
pinToGpio = pinToGpio_ZERO_3_W;
physToGpio = physToGpio_ZERO_3_W;
@@ -5500,7 +5651,7 @@ int wiringPiSetup (void)
case PI_MODEL_ZERO: case PI_MODEL_ZERO_PLUS_2: case PI_MODEL_WIN:
case PI_MODEL_PRIME: case PI_MODEL_PC_2: case PI_MODEL_ZERO_PLUS:
case PI_MODEL_H3: case PI_MODEL_ZERO_2_W: case PI_MODEL_4A:
case PI_MODEL_ZERO_3_PLUS: case PI_MODEL_4_PRO: case PI_MODEL_ZERO_3_W:
case PI_MODEL_ZERO_3_PLUS: case PI_MODEL_BLUEBERRY: case PI_MODEL_4_PRO: case PI_MODEL_ZERO_3_W:
sunxi_gpio_info_t.pwm = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, sunxi_gpio_info_t.pwm_base_addr & (0xfffff000));
if ((int32_t)(unsigned long)sunxi_gpio_info_t.pwm == -1)
@@ -5982,6 +6133,10 @@ int wiringPiSetupSys (void)
pinToGpio = pinToGpio_ZERO_2_W;
physToGpio = physToGpio_ZERO_2_W;
break;
case PI_MODEL_BLUEBERRY:
pinToGpio = pinToGpio_BLUEBERRY;
physToGpio = physToGpio_BLUEBERRY;
break;
case PI_MODEL_ZERO_3_W:
pinToGpio = pinToGpio_ZERO_3_W;
physToGpio = physToGpio_ZERO_3_W;
@@ -8424,6 +8579,13 @@ int orangepi_set_gpio_mode(int pin, int mode)
printf("OPI:you can select wiringPi pin 267,268,269,270 for PWM pin\n");
printf("or you can use it in softPwm mode\n");
exit(1);
} else if (OrangePiModel == PI_MODEL_BLUEBERRY \
&& pin != 267 && pin != 268 && pin != 269 && pin != 270) {
/* DT overlay pwm1-pi11 = PI11; avoid PH0-3 (UART0/UART5) */
printf("the pin you choose doesn't support hardware PWM\n");
printf("Blueberry: use GPIO 267 (PI11/PWM1) or 268-270 (PI12-14)\n");
printf("or you can use it in softPwm mode\n");
exit(1);
}
H618_set_pwm_reg(pin,&sunxi_gpio_info_t);
@@ -8432,8 +8594,8 @@ int orangepi_set_gpio_mode(int pin, int mode)
regval &= ~(sunxi_gpio_info_t.gpio_cfg_mask << offset);
if (OrangePiModel == PI_MODEL_ZERO_2 || OrangePiModel == PI_MODEL_ZERO_3_PLUS)
regval |= (0x4 << offset); // ALT4 PWM
else if (OrangePiModel == PI_MODEL_ZERO_2_W)
regval |= (0x5 << offset);
else if (OrangePiModel == PI_MODEL_ZERO_2_W || OrangePiModel == PI_MODEL_BLUEBERRY)
regval |= (0x5 << offset); // ALT5 PWM (PI bank)
else
regval |= (0x3 << offset); // ALT3 PWM
if (wiringPiDebug)
@@ -8455,7 +8617,8 @@ int orangepi_set_gpio_mode(int pin, int mode)
orangepi_pwm_set_act(pin,512);
sunxi_pwm_set_mode(PWM_MODE_MS);
if (OrangePiModel == PI_MODEL_ZERO_2 || OrangePiModel == PI_MODEL_ZERO_2_W || OrangePiModel == PI_MODEL_ZERO_3_PLUS)
if (OrangePiModel == PI_MODEL_ZERO_2 || OrangePiModel == PI_MODEL_ZERO_2_W \
|| OrangePiModel == PI_MODEL_ZERO_3_PLUS || OrangePiModel == PI_MODEL_BLUEBERRY)
orangepi_pwm_set_clk(pin,1); //default clk:24M
else
orangepi_pwm_set_clk(pin,PWM_CLK_DIV_120); //default clk:24M/120
+1
View File
@@ -838,6 +838,7 @@ extern int wiringPiDebug;
#define PI_MODEL_ZERO_2 9
#define PI_MODEL_ZERO_2_W 10
#define PI_MODEL_ZERO_3_PLUS 11
#define PI_MODEL_BLUEBERRY 12
/* Rockchip RK3399 */