视频介绍 https://www.bilibili.com/video/BV1JP4y1X7Uz
开源地址https://github.com/hsinyuwang/X-Boy
非常感谢哇酷网和司徒大佬开源的资料!!!
图片展示
电路板
视频介绍 https://www.bilibili.com/video/BV1JP4y1X7Uz
开源地址https://github.com/hsinyuwang/X-Boy
非常感谢哇酷网和司徒大佬开源的资料!!!
图片展示
电路板
CONFIGURE_ARGS += \
--enable-static=no \
--disable-video-directfb \
--enable-input-tslib=no \
同时在 menuconfig 中也关掉 directfb
PKG_NAME:=libsdl-ttf
PKG_VERSION:=2.0.11
PKG_RELEASE:=2
PKG_SOURCE:=SDL_ttf-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.libsdl.org/projects/SDL_ttf/release/
PKG_MD5SUM:=61e29bd9da8d245bc2471d1b2ce591aa
PKG_BUILD_DIR:=$(COMPILE_DIR)/SDL_ttf-$(PKG_VERSION)
-I/home/hsinyuwang/t113/tina-d1-h/out/t113-nezha/staging_dir/target/usr/include/SDL -I/home/hsinyuwang/t113/tina-d1-h/out/t113-nezha/staging_dir/target/usr/include
-L/home/hsinyuwang/t113/tina-d1-h/out/t113-nezha/staging_dir/target/usr/lib
-lfreetype -lbz2
完整的 makefile
TARGET = gpsp
CC = arm-openwrt-linux-gnueabi-gcc-6.4.1
VPATH = .. ../arm
OBJS = main.o cpu.o memory.o video.o input.o sound.o cheats.o zip.o arm_stub.o warm.o cpu_threaded.o video_blend.o sha1.o imageio.o gui_xboy.o #gui.o
CFLAGS = -DARM_ARCH -DPC_BUILD -march=armv7-a -mtune=cortex-a7 -mfloat-abi=hard -mfpu=neon -ffast-math -Ofast -I/home/hsinyuwang/t113/tina-d1-h/out/t113-nezha/staging_dir/target/usr/include/SDL -I/home/hsinyuwang/t113/tina-d1-h/out/t113-nezha/staging_dir/target/usr/include
LDFLAGS = -L/home/hsinyuwang/t113/tina-d1-h/out/t113-nezha/staging_dir/target/usr/lib
LIBS = -lSDL -lSDL_ttf -lz -lpng -lfreetype -lbz2
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(TARGET)
%.o: %.S
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f *.o $(TARGET)
导入环境变量后编译
export PATH=$PATH:/home/hsinyuwang/t113/tina-d1-h/out/t113-nezha/staging_dir/toolchain/bin/
export STAGING_DIR=/home/hsinyuwang/t113/tina-d1-h/out/t113-nezha/staging_dir/
OK了
因为 t113 的屏幕驱动没有调,所以还没办法验证
完整的 gpsp 代码 https://github.com/hsinyuwang/gpsp 切换到 t113 分支
过程遇到了很多问题,感谢司徒大佬指点!
主控:全志V3s
屏幕:2.4寸 320x240 SPI+RGB666 驱动方案
PCB尺寸:10x6.8cm 双层板
PCB打样中,暂未验证
原理图
sdl_ttf 的完整 makefile
#
# Copyright (C) 2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libsdl-ttf
PKG_VERSION:=2.0.11
PKG_RELEASE:=2
PKG_SOURCE:=SDL_ttf-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.libsdl.org/projects/SDL_ttf/release/
PKG_MD5SUM:=61e29bd9da8d245bc2471d1b2ce591aa
PKG_BUILD_DIR:=$(COMPILE_DIR)/SDL_ttf-$(PKG_VERSION)
PKG_INSTALL:=1
include $(BUILD_DIR)/package.mk
include $(BUILD_DIR)/nls.mk
define Package/libsdl-ttf
SECTION:=libs
CATEGORY:=Libraries
TITLE:=Simple DirectMedia Layer True Font
URL:=http://www.libsdl.org/projects/SDL_ttf/
DEPENDS:=+sdl +libfreetype $(ICONV_DEPENDS) $(INTL_DEPENDS)
endef
define Package/libsdl-ttf/description
SDL_ttf is a TrueType font rendering library that is used with the SDL library, and almost as portable. It depends on freetype2 to handle the TrueType font data. It allows a programmer to use multiple TrueType fonts without having to code a font rendering routine themselves. With the power of outline fonts and antialiasing, high quality text output can be obtained without much effort.
endef
PKG_FIXUP:=libtool
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/SDL
CONFIGURE_ARGS += \
--with-sdl-exec-prefix=$(STAGING_DIR) \
--without-x \
LIBS="-lSDL -liconv"
TARGET_LDFLAGS+= \
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib
define Build/InstallDev
$(INSTALL_DIR) \
$(1)/usr/include/SDL \
$(1)/usr/lib
$(CP) \
$(PKG_INSTALL_DIR)/usr/include/SDL/SDL_ttf.h \
$(1)/usr/include/SDL/
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/libSDL_ttf*.{a,so*} \
$(1)/usr/lib/
endef
define Package/libsdl-ttf/install
$(INSTALL_DIR) \
$(1)/usr/lib
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/libSDL_ttf*.so* \
$(1)/usr/lib/
endef
$(eval $(call BuildPackage,libsdl-ttf))
补充:sdl_ttf 的 makefile 需要把 DEPENDS:=+libsdl 改成 DEPENDS:=+sdl +libfreetype
fb0_format = <10>;
lcd_x = <480>;
lcd_y = <320>;
lcd_width = <72>;
lcd_height = <48>;
lcd_dclk_freq = <10>;
lcd_hbp = <2>;
lcd_ht = <486>;
lcd_hspw = <2>;
lcd_vbp = <20>;
lcd_vt = <342>;
lcd_vspw = <2>;
lcd_cpu_mode = <1>;
lcd_cpu_te = <1>;
紧跟晕哥和司徒大佬的脚步
基于全志T113-S3自制GBA游戏机
视频介绍 https://www.bilibili.com/video/BV1Gu411V7ar
开源地址 https://github.com/hsinyuwang/X-Boy-Plus
为了方便使用嘉立创免费打样,依旧分开设计PCB,每块PCB尺寸都在10x10cm以内
因为时间有限还没有画3D外壳
在上一篇文章已经搞定了 T113 tina linux 移植 gpsp 模拟器 接下来适配屏幕驱动。
因为 GBA 原生分辨率是 240x160,所以屏幕选用的是 480x320 的 ili9488,正好可以整数倍缩放。
先从 tina linux 自带的驱动中 copy 一份 st7789v_cpu 的代码,然后对照 ili9488 屏幕厂商提供的初始化代码做修改
完整代码
/*
* drivers/video/fbdev/sunxi/disp2/disp/lcd/ili9488_cpu.c
*
* Copyright (c) 2007-2018 Allwinnertech Co., Ltd.
* Author: zhengxiaobin <zhengxiaobin@allwinnertech.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
*/
#include "ili9488_cpu.h"
#define CPU_TRI_MODE
#define DBG_INFO(format, args...) (printk("[ILI9488 LCD INFO] LINE:%04d-->%s:"format, __LINE__, __func__, ##args))
#define DBG_ERR(format, args...) (printk("[ILI9488 LCD ERR] LINE:%04d-->%s:"format, __LINE__, __func__, ##args))
#define panel_reset(val) sunxi_lcd_gpio_set_value(sel, 0, val)
#define lcd_cs(val) sunxi_lcd_gpio_set_value(sel, 1, val)
static void lcd_panel_ili9488_init(u32 sel, struct disp_panel_para *info);
static void LCD_power_on(u32 sel);
static void LCD_power_off(u32 sel);
static void LCD_bl_open(u32 sel);
static void LCD_bl_close(u32 sel);
static void LCD_panel_init(u32 sel);
static void LCD_panel_exit(u32 sel);
static void LCD_cfg_panel_info(struct panel_extend_para *info)
{
#if 0
u32 i = 0, j = 0;
u32 items;
u8 lcd_gamma_tbl[][2] = {
//{input value, corrected value}
{0, 0}, {15, 15}, {30, 30}, {45, 45}, {60, 60},
{75, 75}, {90, 90}, {105, 105}, {120, 120}, {135, 135},
{150, 150}, {165, 165}, {180, 180}, {195, 195}, {210, 210},
{225, 225}, {240, 240}, {255, 255},
};
u32 lcd_cmap_tbl[2][3][4] = {
{
{LCD_CMAP_G0, LCD_CMAP_B1, LCD_CMAP_G2, LCD_CMAP_B3},
{LCD_CMAP_B0, LCD_CMAP_R1, LCD_CMAP_B2, LCD_CMAP_R3},
{LCD_CMAP_R0, LCD_CMAP_G1, LCD_CMAP_R2, LCD_CMAP_G3},
},
{
{LCD_CMAP_B3, LCD_CMAP_G2, LCD_CMAP_B1, LCD_CMAP_G0},
{LCD_CMAP_R3, LCD_CMAP_B2, LCD_CMAP_R1, LCD_CMAP_B0},
{LCD_CMAP_G3, LCD_CMAP_R2, LCD_CMAP_G1, LCD_CMAP_R0},
},
};
items = sizeof(lcd_gamma_tbl) / 2;
for (i = 0; i < items - 1; i++) {
u32 num = lcd_gamma_tbl[i + 1][0] - lcd_gamma_tbl[i][0];
for (j = 0; j < num; j++) {
u32 value = 0;
value =
lcd_gamma_tbl[i][1] +
((lcd_gamma_tbl[i + 1][1] - lcd_gamma_tbl[i][1]) *
j) /
num;
info->lcd_gamma_tbl[lcd_gamma_tbl[i][0] + j] =
(value << 16) + (value << 8) + value;
}
}
info->lcd_gamma_tbl[255] = (lcd_gamma_tbl[items - 1][1] << 16) +
(lcd_gamma_tbl[items - 1][1] << 8) +
lcd_gamma_tbl[items - 1][1];
memcpy(info->lcd_cmap_tbl, lcd_cmap_tbl, sizeof(lcd_cmap_tbl));
#endif
}
static s32 LCD_open_flow(u32 sel)
{
LCD_OPEN_FUNC(sel, LCD_power_on, 120);
#ifdef CPU_TRI_MODE
LCD_OPEN_FUNC(sel, LCD_panel_init, 100);
LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 50);
#else
LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 100);
LCD_OPEN_FUNC(sel, LCD_panel_init, 50);
#endif
LCD_OPEN_FUNC(sel, LCD_bl_open, 0);
return 0;
}
static s32 LCD_close_flow(u32 sel)
{
LCD_CLOSE_FUNC(sel, LCD_bl_close, 20);
#ifdef CPU_TRI_MODE
LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable, 10);
LCD_CLOSE_FUNC(sel, LCD_panel_exit, 50);
#else
LCD_CLOSE_FUNC(sel, LCD_panel_exit, 10);
LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable, 10);
#endif
LCD_CLOSE_FUNC(sel, LCD_power_off, 0);
return 0;
}
static void LCD_power_on(u32 sel)
{
/*config lcd_power pin to open lcd power0 */
sunxi_lcd_power_enable(sel, 0);
sunxi_lcd_pin_cfg(sel, 1);
}
static void LCD_power_off(u32 sel)
{
/*lcd_cs, active low */
lcd_cs(1);
sunxi_lcd_delay_ms(10);
/*lcd_rst, active hight */
panel_reset(1);
sunxi_lcd_delay_ms(10);
sunxi_lcd_pin_cfg(sel, 0);
/*config lcd_power pin to close lcd power0 */
sunxi_lcd_power_disable(sel, 0);
}
static void LCD_bl_open(u32 sel)
{
sunxi_lcd_pwm_enable(sel);
/*config lcd_bl_en pin to open lcd backlight */
sunxi_lcd_backlight_enable(sel);
}
static void LCD_bl_close(u32 sel)
{
/*config lcd_bl_en pin to close lcd backlight */
sunxi_lcd_backlight_disable(sel);
sunxi_lcd_pwm_disable(sel);
}
/*static int bootup_flag = 0;*/
static void LCD_panel_init(u32 sel)
{
struct disp_panel_para *info =
kmalloc(sizeof(struct disp_panel_para), GFP_KERNEL);
DBG_INFO("\n");
bsp_disp_get_panel_info(sel, info);
lcd_panel_ili9488_init(sel, info);
kfree(info);
return;
}
static void LCD_panel_exit(u32 sel)
{
sunxi_lcd_cpu_write_index(0, 0x28);
sunxi_lcd_delay_ms(10);
sunxi_lcd_cpu_write_index(0, 0x10);
sunxi_lcd_delay_ms(120);
}
static void lcd_panel_ili9488_init(u32 sel, struct disp_panel_para *info)
{
DBG_INFO("\n");
/*lcd_cs, active low */
lcd_cs(0);
sunxi_lcd_delay_ms(10);
panel_reset(1);
sunxi_lcd_delay_ms(20);
panel_reset(0);
sunxi_lcd_delay_ms(20);
panel_reset(1);
sunxi_lcd_delay_ms(120);
sunxi_lcd_cpu_write_index(0, 0xF7);
sunxi_lcd_cpu_write_data(0, 0xA9);
sunxi_lcd_cpu_write_data(0, 0x51);
sunxi_lcd_cpu_write_data(0, 0x2C);
sunxi_lcd_cpu_write_data(0, 0x82);
sunxi_lcd_cpu_write_index(0, 0xC0);
sunxi_lcd_cpu_write_data(0, 0x11);
sunxi_lcd_cpu_write_data(0, 0x09);
sunxi_lcd_cpu_write_index(0, 0xC1);
sunxi_lcd_cpu_write_data(0, 0x41);
sunxi_lcd_cpu_write_index(0, 0xC5);
sunxi_lcd_cpu_write_data(0, 0x00);
sunxi_lcd_cpu_write_data(0, 0x2A);
sunxi_lcd_cpu_write_data(0, 0x80);
sunxi_lcd_cpu_write_index(0, 0xB1);
sunxi_lcd_cpu_write_data(0, 0xB0);
sunxi_lcd_cpu_write_data(0, 0x11);
sunxi_lcd_cpu_write_index(0, 0xB4);
sunxi_lcd_cpu_write_data(0, 0x02);
sunxi_lcd_cpu_write_index(0, 0xB6);
sunxi_lcd_cpu_write_data(0, 0x02);
sunxi_lcd_cpu_write_data(0, 0x22);
sunxi_lcd_cpu_write_index(0, 0xB7);
sunxi_lcd_cpu_write_data(0, 0xC6);
sunxi_lcd_cpu_write_index(0, 0xBE);
sunxi_lcd_cpu_write_data(0, 0x00);
sunxi_lcd_cpu_write_data(0, 0x04);
sunxi_lcd_cpu_write_index(0, 0xE9);
sunxi_lcd_cpu_write_data(0, 0x00);
sunxi_lcd_cpu_write_index(0, 0x3A);
sunxi_lcd_cpu_write_data(0, 0x55);
sunxi_lcd_cpu_write_index(0, 0xE0);
sunxi_lcd_cpu_write_data(0, 0x00);
sunxi_lcd_cpu_write_data(0, 0x07);
sunxi_lcd_cpu_write_data(0, 0x12);
sunxi_lcd_cpu_write_data(0, 0x0B);
sunxi_lcd_cpu_write_data(0, 0x18);
sunxi_lcd_cpu_write_data(0, 0x0B);
sunxi_lcd_cpu_write_data(0, 0x3F);
sunxi_lcd_cpu_write_data(0, 0x9B);
sunxi_lcd_cpu_write_data(0, 0x4B);
sunxi_lcd_cpu_write_data(0, 0x0B);
sunxi_lcd_cpu_write_data(0, 0x0F);
sunxi_lcd_cpu_write_data(0, 0x0B);
sunxi_lcd_cpu_write_data(0, 0x15);
sunxi_lcd_cpu_write_data(0, 0x17);
sunxi_lcd_cpu_write_data(0, 0x0F);
sunxi_lcd_cpu_write_index(0, 0xE1);
sunxi_lcd_cpu_write_data(0, 0x00);
sunxi_lcd_cpu_write_data(0, 0x16);
sunxi_lcd_cpu_write_data(0, 0x1B);
sunxi_lcd_cpu_write_data(0, 0x02);
sunxi_lcd_cpu_write_data(0, 0x0F);
sunxi_lcd_cpu_write_data(0, 0x06);
sunxi_lcd_cpu_write_data(0, 0x34);
sunxi_lcd_cpu_write_data(0, 0x46);
sunxi_lcd_cpu_write_data(0, 0x48);
sunxi_lcd_cpu_write_data(0, 0x04);
sunxi_lcd_cpu_write_data(0, 0x0D);
sunxi_lcd_cpu_write_data(0, 0x0D);
sunxi_lcd_cpu_write_data(0, 0x35);
sunxi_lcd_cpu_write_data(0, 0x36);
sunxi_lcd_cpu_write_data(0, 0x0F);
sunxi_lcd_cpu_write_index(0, 0x2A);
sunxi_lcd_cpu_write_data(0, 0x00);
sunxi_lcd_cpu_write_data(0, 0x00);
sunxi_lcd_cpu_write_data(0, 0x01);
sunxi_lcd_cpu_write_data(0, 0xDF);
sunxi_lcd_cpu_write_index(0, 0x2B);
sunxi_lcd_cpu_write_data(0, 0x00);
sunxi_lcd_cpu_write_data(0, 0x00);
sunxi_lcd_cpu_write_data(0, 0x01);
sunxi_lcd_cpu_write_data(0, 0x3F);
sunxi_lcd_cpu_write_index(0, 0x36);
sunxi_lcd_cpu_write_data(0, 0x68);
#if defined(CPU_TRI_MODE)
/* enable te, mode 0 */
sunxi_lcd_cpu_write_index(0, 0x35);
sunxi_lcd_cpu_write_data(0, 0x00);
#endif
sunxi_lcd_cpu_write_index(0, 0x11);
sunxi_lcd_delay_ms(120);
sunxi_lcd_cpu_write_index(0, 0x29);
sunxi_lcd_cpu_write_index(0, 0x2c);
}
/* panel driver name, must mach the name of lcd_drv_name in sys_config.fex */
struct __lcd_panel ili9488_cpu_panel = {
.name = "ili9488_cpu",
.func = {
.cfg_panel_info = LCD_cfg_panel_info,
.cfg_open_flow = LCD_open_flow,
.cfg_close_flow = LCD_close_flow,
},
};
Kconfig 添加
config LCD_SUPPORT_ILI9488_CPU
bool "LCD support ili9488_cpu panel"
default n
---help---
If you want to support ili9488_cpu panel for display driver, select it.
Makefile 添加
disp-$(CONFIG_LCD_SUPPORT_ILI9488_CPU) += lcd/ili9488_cpu.o
panels.c 添加
#ifdef CONFIG_LCD_SUPPORT_ILI9488_CPU
&ili9488_cpu_panel,
#endif
panels.h 添加
#ifdef CONFIG_LCD_SUPPORT_ILI9488_CPU
extern struct __lcd_panel ili9488_cpu_panel;
#endif
再打开 m kernel_menuconfig
Device Drivers --->
Graphics support --->
Frame buffer Devices --->
Video support for sunxi --->
LCD panels select --->
[*] LCD support ili9488_cpu panel
disp
&disp {
disp_init_enable = <1>;
disp_mode = <0>;
screen0_output_type = <1>;
screen0_output_mode = <4>;
screen1_output_type = <3>;
screen1_output_mode = <4>;
screen1_output_format = <0>;
screen1_output_bits = <0>;
screen1_output_eotf = <4>;
screen1_output_cs = <257>;
screen1_output_dvi_hdmi = <2>;
screen1_output_range = <2>;
screen1_output_scan = <0>;
screen1_output_aspect_ratio = <8>;
dev0_output_type = <1>;
dev0_output_mode = <4>;
dev0_screen_id = <0>;
dev0_do_hpd = <0>;
dev1_output_type = <4>;
dev1_output_mode = <10>;
dev1_screen_id = <1>;
dev1_do_hpd = <1>;
def_output_dev = <1>;
hdmi_mode_check = <3>;
disp_rotation_used = <1>;
degree0 = <0>;
fb0_format = <10>;
fb0_buffer_num = <1>;
/*fb0_width = <800>;*/
/*fb0_height = <480>;*/ /*read from lcd*/
fb1_format = <0>;
fb1_width = <0>;
fb1_height = <0>;
chn_cfg_mode = <1>;
disp_para_zone = <1>;
/*VCC-LCD*/
/* dc1sw-supply = <®_dc1sw>;*/
/*VCC-DSI*/
/* eldo3-supply = <®_eldo3>;*/
/*VCC-PD*/
/* dcdc1-supply = <®_dcdc1>;*/
};
lcd0
&lcd0 {
/* part 1 */
lcd_used = <1>;
lcd_driver_name = "ili9488_cpu";
/* part 2 */
lcd_if = <1>;
lcd_cpu_if = <8>;
/* part 3 */
lcd_x = <480>;
lcd_y = <320>;
lcd_width = <72>;
lcd_height = <48>;
lcd_dclk_freq = <10>;
lcd_hbp = <2>;
lcd_ht = <486>;
lcd_hspw = <2>;
lcd_vbp = <20>;
lcd_vt = <342>;
lcd_vspw = <2>;
/* part 4 */
lcd_pwm_used = <1>;
lcd_pwm_ch = <8>;
lcd_pwm_freq = <50000>;
lcd_pwm_pol = <1>;
lcd_pwm_max_limit = <255>;
lcd_bright_curve_en = <0>;
/* part 5 */
lcd_cpu_mode = <1>;
lcd_cpu_te = <1>;
/* part 6 */
lcd_frm = <2>;
lcd_gamma_en = <0>;
lcd_cmap_en = <0>;
lcd_rb_swap = <0>;
/* part 7 */
// reset pin
lcd_gpio_0 = <&pio PD 0 GPIO_ACTIVE_HIGH>;
// cs pin
lcd_gpio_1 = <&pio PD 9 GPIO_ACTIVE_HIGH>;
pinctrl-0 = <&rgb16_pins_a>;
pinctrl-1 = <&rgb16_pins_b>;
};
然后在pio中添加
rgb16_pins_a: rgb16@0 {
pins = "PD1", "PD2","PD3","PD4","PD5","PD6", "PD7", "PD8", \
"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", \
"PD18", "PD19", "PD20", "PD21";
function = "lcd0";
drive-strength = <30>;
bias-disable;
};
rgb16_pins_b: rgb16@1 {
pins = "PD1", "PD2","PD3","PD4","PD5","PD6", "PD7", "PD8", \
"PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", \
"PD18", "PD19", "PD20", "PD21";
function = "io_disabled";
bias-disable;
};