u-boot-2010.03在LT2440上的移植详解 (十)
郑重声明,这系列文章改写自博客园 黄刚先生的《嵌入式Linux之我行——u-boot-2009.08在2440上的移植详解》
转载时请注明出处
文章出处:
http://www.lt-net.cn
编译系统
Ubuntu10.04
交叉编译器
arm-linux-gcc 4.3.3
硬件设备
LT2440开发板
测试软件
u-boot-2010.03
依赖库
无
uboot下载地址:
http://ftp.denx.de/pub/u-boot/u-boot-2010.03.tar.bz2本次移植在u-boot-2010.03原有功能的基础上增加如下特性:
1.支持2KB page Nand Flash读写
2.支持Nand/Nor Flash启动自动识别
3.支持DM9000AEP 10M/100M自适应网卡
4.支持yaffs文件系统烧写
5.支持USB下载功能
6.支持一键式菜单
7.支持启动Logo
8.支持ubifs(待续)
上接:
u-boot-2010.03在LT2440上的移植详解 (九)
支持启动logo我们将logo编译进u-boot,需要增加显示驱动,还有显示的logo数据,下面先增加显示驱动
# gedit drivers/video/s3c2440_fb.c
- #include
- #include
- #include "lutong_logo.c"
- #define MVAL (13)
- #define MVAL_USED (0) //0=each frame 1=rate by MVAL
- #define INVVDEN (1) //0=normal 1=inverted
- #define BSWP (0) //Byte swap control
- #define HWSWP (1) //Half word swap control
- #define SCR_XSIZE_TFT (LCD_XSIZE_TFT)
- #define SCR_YSIZE_TFT (LCD_YSIZE_TFT)
- #define HOZVAL_TFT ( LCD_XSIZE_TFT - 1 )
- #define LINEVAL_TFT ( LCD_YSIZE_TFT - 1 )
- #define U32 unsigned int
- #define M5D(n) ( ( n ) & 0x1fffff )
- volatile unsigned short tf2440_LCD_BUFFER[SCR_YSIZE_TFT][SCR_XSIZE_TFT] = { 0 } ;
- volatile char vbpd = 1, vfpd = 1, vspw = 1, hbpd = 1, hfpd = 1, hspw = 1, clkval_tft = 1 ;
- /**************************************************************
- Clear TFT LCD With C
- **************************************************************/
- void tf2440_lcd_ClearScr( U32 c)
- {
- unsigned int x,y ;
- for( y = 0 ; y < LCD_YSIZE_TFT ; y++ )
- {
- for( x = 0 ; x < (SCR_XSIZE_TFT) ; x++ )
- {
- tf2440_LCD_BUFFER[y][x] = c;
- }
- }
- }
- /**************************************************************
- TFT LCD指定大小的矩形填充特定颜 {MOD}单元或清屏
- **************************************************************/
- void tf2440_lcd_ClearScr_Rectangle( int x0,int y0,int width,int height, U32 c)
- {
- unsigned int x,y ;
- for( y = y0 ; y < (y0 + height) ; y++ )
- {
- for( x = x0 ; x < (width + x0) ; x++ )
- {
- tf2440_LCD_BUFFER[y][x] = c;
- }
- }
- }
- /**************************************************************
- 在LCD屏幕上指定坐标点画一个指定大小的图片
- **************************************************************/
- void tf2440_paint_Bmp(int x0,int y0,int width,int height, unsigned char bmp[])
- {
- int x, y ;
- U32 c ;
- int p = 0 ;
- for( y = y0 ; y < (height + y0) ; y++ )
- {
- for( x = x0 ; x < (width + x0) ; x++ )
- {
- c = bmp[p+1] | (bmp[p] << 8) ;
- if ( ( x <= (SCR_XSIZE_TFT) ) && ( y <= LCD_YSIZE_TFT ) )
- tf2440_LCD_BUFFER[y][x] = c;
- p = p + 2 ;
- }
- }
- }
- /**************************************************************
- 在坐标(X,Y)画点
- **************************************************************/
- void putPixel(U32 x, U32 y, U32 c)
- {
- if( (x < LCD_XSIZE_TFT) && (y < LCD_YSIZE_TFT))
- tf2440_LCD_BUFFER[y][x] = c;
- }
- U32 currWidth = 0;
- void drawProcessBar(U32 total, U32 current )
- {
- U32 const bar_height = 8;
- U32 bar_base = LCD_YSIZE_TFT - bar_height;
- int i = (int) LCD_XSIZE_TFT / 8;
- U32 j;
- int pbcolor ;
- if(total != -1)
- {
- j = 0;
- int bar_width = (int) LCD_XSIZE_TFT * ((current * 1.0) / total);
- if (bar_width <= i)
- pbcolor = 0x7FF;
- //sky blue
- else if((bar_width > i) && (bar_width <= i * 2))
- pbcolor = 0x1F;
- //blue
- else if((bar_width > i * 2) && (bar_width <= i * 3))
- pbcolor = 0x0;
- //black
- else if((bar_width > i * 3) && (bar_width <= i * 4))
- pbcolor = 0xF81F;
- //purple
- else if((bar_width > i * 4) && (bar_width <= i * 5))
- pbcolor = 0xFFFF;
- //white
- else if((bar_width > i * 5) && (bar_width <= i * 6))
- pbcolor = 0xF800;
- //red
- else if((bar_width > i * 6) && (bar_width <= i * 7))
- pbcolor = 0xFFE0;
- //yellow
- else if((bar_width > i * 7) && (bar_width <= i * 8))
- pbcolor = 0x7E0;
- //green
- if(bar_width > currWidth)
- {
- for ( ; j < bar_height; j++)
- {
- putPixel(bar_width, j + bar_base, pbcolor);
- }
- currWidth = bar_width;
- }
- }
- }
- /**************************************************************
- LCD PWREN
- **************************************************************/
- void tf2440_lcd_PowerEnable(int invpwren , int pwren)
- {
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
- struct s3c24x0_lcd * const lcd = s3c24x0_get_base_lcd();
- gpio -> GPGUP = gpio -> GPGUP & ( ~( 1 << 4) ) | ( 1 << 4) ;
- gpio -> GPGCON = gpio -> GPGCON & ( ~( 3 << 8) ) | ( 3 << 8) ;
- gpio -> GPGDAT = gpio -> GPGDAT | (1 << 4 ) ;
- lcd -> LCDCON5 = lcd -> LCDCON5 & ( ~( 1 << 3 ) ) | ( pwren << 3 ) ;
- lcd -> LCDCON5 = lcd -> LCDCON5 & ( ~( 1 << 5 ) ) | ( invpwren << 5 ) ;
- }
- /**************************************************************
- LCD ON//OFF
- **************************************************************/
- void tf2440_lcd_EnvidOnOff(int onoff)
- {
- struct s3c24x0_lcd * const lcd = s3c24x0_get_base_lcd();
- if( onoff == 1 )
- lcd -> LCDCON1 |= 1 ;
- elselcd -> LCDCON1 = lcd -> LCDCON1 & 0x3fffe ;
- }
- /**************************************************************
- LCD Init
- **************************************************************/
- void tf2440_lcd_init(void)
- {
- int x, y ;
- U32 c ;
- int p = 0 ;
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
- struct s3c24x0_lcd * const lcd = s3c24x0_get_base_lcd();
- char *s_lcd;
- lcd -> LCDSADDR1 = ( ( ( U32 ) tf2440_LCD_BUFFER >> 22 ) << 21 ) | M5D ( ( U32 ) tf2440_LCD_BUFFER >> 1 ) ;
- lcd -> LCDSADDR2 = M5D( ( ( U32) tf2440_LCD_BUFFER + ( SCR_XSIZE_TFT * LCD_YSIZE_TFT * 2 ) ) >> 1 ) ;
- lcd -> LCDSADDR3 = ( ( ( SCR_XSIZE_TFT - LCD_XSIZE_TFT ) / 1 ) << 11 ) | ( LCD_XSIZE_TFT /1 ) ;
- vbpd =CONFIG_TF2440_LCD_VBPD;
- vfpd = CONFIG_TF2440_LCD_VFPD;
- vspw = CONFIG_TF2440_LCD_VSPW;
- hbpd =CONFIG_TF2440_LCD_HBPD ;
- hfpd =CONFIG_TF2440_LCD_HFPD;
- hspw = CONFIG_TF2440_LCD_HSPW;
- clkval_tft =CONFIG_TF2440_LCD_CLKVAL ;
- tf2440_lcd_ClearScr( 0x0 ) ;
- gpio -> GPCUP = 0xffffffff ;
- gpio -> GPCCON = 0xaaaaaaaa ;
- //Initialize VD[0:7]
- gpio -> GPDUP = 0xffffffff ;
- gpio -> GPDCON = 0xaaaaaaaa ;
- //Initialize VD[15:8]
- lcd -> LCDCON1 = ( clkval_tft << 8 ) | ( MVAL_USED << 7 ) | (3 << 5 ) | ( 12 << 1 ) | 0 ;
- lcd -> LCDCON2 = ( vbpd << 24 ) | ( LINEVAL_TFT << 14 ) | ( vfpd << 6 ) | ( vspw ) ;
- lcd -> LCDCON3 = ( hbpd << 19 ) | ( HOZVAL_TFT << 8 ) | ( hfpd ) ;
- lcd -> LCDCON4 = ( MVAL << 8 ) | ( hspw ) ;
- lcd -> LCDCON5 = ( 1 << 11) | ( 0 << 10 ) | ( 1 << 9 ) | ( 1 << 8 ) | ( 0 << 7 ) | ( 0 << 6 ) | ( 1 << 3 ) | ( BSWP << 1 ) | ( HWSWP ) ;
- lcd -> LPCSEL &= ( ~7 ) ;
- // Disable LPC3480
- lcd -> TPAL = 0x0 ;
- // Disable Temp Palette
- tf2440_lcd_PowerEnable( 0, 1 ) ;
- }
- void tf2440_logo(void)
- {
- struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
- struct s3c24x0_lcd * const lcd = s3c24x0_get_base_lcd();
- tf2440_lcd_ClearScr(0x0);
- tf2440_paint_Bmp(0, 0, 320, 240, lutong_logo) ;
- tf2440_lcd_EnvidOnOff ( 1 ) ;
- }
复制代码
# gedit drivers/video/Makefile
//在42行添加
COBJS-y += s3c2410_fb.o
# gedit common/main.c
//在启动的时候调用LCD初始化函数然后调用画图函数绘制logo,作如下修改
//在308行添加:
#if defined(CONFIG_TF2440_LOGO)
tf2440_lcd_init();
tf2440_logo();
#endif
# gedit include/configs/lt2440.h
//上面有LOGO的宏定义没添加,需要在lt2440.h添加如下的宏定义
/*-----------------------------------------------------------------------
* LCD CONFIG
*/
#define CONFIG_TF2440_LOGO 1
#ifdef CONFIG_TF2440_LOGO
#define CONFIG_TFT320x240 1
#define CONFIG_TFT480x272 2
#define TFT_LCD CONFIG_TFT320x240
#if (TFT_LCD==CONFIG_TFT320x240)
#define CONFIG_TF2440_LCD_VBPD 15
#define CONFIG_TF2440_LCD_VFPD 4
#define CONFIG_TF2440_LCD_VSPW 3
#define CONFIG_TF2440_LCD_HBPD 38
#define CONFIG_TF2440_LCD_HFPD 20
#define CONFIG_TF2440_LCD_HSPW 30
#define CONFIG_TF2440_LCD_CLKVAL 7
#define LCD_XSIZE_TFT 320
#define LCD_YSIZE_TFT 240
#elif (TFT_LCD==CONFIG_TFT480x272)
#define CONFIG_TF2440_LCD_VBPD 2
#define CONFIG_TF2440_LCD_VFPD 2
#define CONFIG_TF2440_LCD_VSPW 10
#define CONFIG_TF2440_LCD_HBPD 2
#define CONFIG_TF2440_LCD_HFPD 2
#define CONFIG_TF2440_LCD_HSPW 15
#define CONFIG_TF2440_LCD_CLKVAL 5
#define LCD_XSIZE_TFT 480
#define LCD_YSIZE_TFT 272
#endif
#endif
接下来就是制作logo图像数据了图片转换软件可以在这里下载
http://blogimg.chinaunix.net/blog/upfile2/101209150029.rar我们的资料光盘 “光盘资料/windows下工具软件及驱动/BMP图片转换软件” 目录下面有图片转换软件,使用这个软件转换bmp图片文件到数组C文件。转换过程如下:
1.准备一张bmp图片,图片的分辨率小于等于480*272 (4.3寸屏)或者320*240(3.5寸屏)查看图片属性,480*272图片生成的数据量比较大,我们建议您使用320*240的,驱动也是支持320*240的,使用其他的分辨率请修改驱动。
2.打开“位图转换”,点击添加图片
3.点击转换
4.将会值当前目录下生成图片c语言数组代码
5.将会得到lutong_logo.c文件,需要做如下修改
只是掉文件开始的一个包含,还要去读“ALIGN4 ”
/*BMP C file converted from BMP file*/#define WIN32// #include "base.h"const unsigned char lutong_logo[] = { /* image header, 20 bytes */
#if 0 //需要注释掉这个文件头#ifdef WIN32 0x18,0x00,0x00,0x00,0x18,0x58,0x02,0x00,#else 0x00,0x00,0x00,0x18,0x00,0x02,0x58,0x18,#endif#ifdef WIN3264, 1,240, 0, 0, 0,128, 2, 16, 0, 1, 0, 0, 0, 0, 0,#else 1, 64, 0,240, 0, 0, 2,128, 0, 16, 0, 1, 0, 0, 0, 0,#endif#endif将这个修改后lutong_logo.c文件复制到 driver/video/目录下
然后编译u-boot,然后烧写到NandFlash中,开机即可看到logo了