一、开机图像
方法: 文件系统划分部分空间用来存放图片数据,通过修改内核启动参数进行设置显示图片
1. 烧录固件
出厂固件为:1M fastboot、4M kernel、26M rtoofs
先分出1M用于存储图片数据,由于内存分配的单位必须是M为单位,所以需要根据图片大小向上取整
2. 设置环境变量
# 原始
setenv bootargs 'mem=128M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 rw mtdparts=hi_sfc:1M(boot),4M(kernel),25M(rootfs)'
setenv bootcmd 'sf probe 0;sf read 0x96000000 0x100000 0x400000;bootm 0x96000000'
saveenv
# logo可以显示,内核可以启动
setenv bootargs 'mem=128M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 rw mtdparts=hi_sfc:1M(boot),4M(kernel),25M(rootfs),1M(logo)'
setenv bootcmd 'sf probe 0;sf read 0x82000000 0x1E00000 0x100000;setenv jpeg_addr 0x82000000;setenv jpeg_size 0x100000;setenv jpeg_emar_buf 0x82200000;setenv vobuf 0x90000000;decjpg 0;startvo 0 32 10;startvl 0 0x90000000 1920 0 0 1920 1080;sf read 0x96000000 0x100000 0x400000;bootm 0x96000000'
saveenv
二、开机进度条
1. 使用内核定时器实现显示进度条实现
systimer.c
/* linux/arch/arm/mach-hi3515_v100/systimer.c
*
* Copyright (c) 2006 Hisilicon Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
//#include <linux/autoconf.h>
#include <linux/init.h>
#include <linux/device.h>
//#include <linux/sysdev.h>
#include <linux/interrupt.h>
#include <asm/irq.h>
#include <linux/leds.h>
#include <asm/system_misc.h>
//#include <asm/hardware.h>
#include <asm/io.h>
#include <linux/amba/bus.h>
#include <linux/amba/clcd.h>
#include <asm/arch_timer.h>
#include <linux/clk.h>
#include <asm/irq.h>
//#include <asm/mach-types.h>
//#include <asm/arch.h>
#include <asm/arch_timer.h>
//#include <asm/flash.h>
#include <asm/dma-mapping.h>
//#include <asm/arch/platform.h>
//#include <asm/arch/irqs.h>
//#include <asm/arch/io.h>
//#include <asm/arch/timer.h>
//#include <asm/arch/clock.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/timer.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/console.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/major.h>
#include <linux/param.h>
#include <linux/seq_file.h>
#include <linux/serial.h>
#include <linux/uaccess.h>
#include <asm/irq.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
//#include <asm/arch/led.h>
//#include <asm/arch/early-debug.h>
//
#define BOOTTIME (24)
#define PRO_WIDTH 960
#define COORDINATE_SYSTEM
//
struct timer_list s_timer;
void second_timer_handle(unsigned long);
static int count=0;
static void * pbase_logo=NULL;
#undef COORDINATE_SYSTEM
static int __init __system_timer_init(void)
{
int i=0,j=0;
//映射绘图地址
pbase_logo=ioremap_nocache(0x90000000,1920*1080*2);
#if 0
//绘制进度条边框
for(i=480;i<1440;i++){
*((unsigned short*)(pbase_logo)+1920*860+i)=0xe71c;
*((unsigned short*)(pbase_logo)+1920*861+i)=0xe71c;
*((unsigned short*)(pbase_logo)+1920*880+i)=0xe71c;
*((unsigned short*)(pbase_logo)+1920*881+i)=0xe71c;
}
for(j=860;j<881;j++){
*((unsigned short*)(pbase_logo)+480+j*1920)=0xe71c;
*((unsigned short*)(pbase_logo)+481+j*1920)=0xe71c;
*((unsigned short*)(pbase_logo)+1439+j*1920)=0xe71c;
*((unsigned short*)(pbase_logo)+1440+j*1920)=0xe71c;
}
#endif
//开启内核定时器,划线
setup_timer(&s_timer, second_timer_handle, 0);
s_timer.expires = jiffies + 20;
add_timer(&s_timer);
return 0;
}
static int draw_line(int process)
{
int i,j;
int n = 0;
for(i=2;i<process;i++)
{
for(j=2;j<40;j++)
*((unsigned char*)(pbase_logo)+1920*(850+j)+480+i)=0xff;
}
return (int)pbase_logo;
}
void second_timer_handle(unsigned long unused)
{
#if 1
if(++count <= BOOTTIME*1)
{
if(pbase_logo==NULL)
{
printk("------------------logo--------123--------------\n");
}
else
{
if(count==(BOOTTIME))
{
draw_line(count*PRO_WIDTH/(BOOTTIME));
mod_timer(&s_timer, jiffies + 500);
}
else
{
draw_line(count*PRO_WIDTH/(BOOTTIME));
mod_timer(&s_timer, jiffies + 50);
}
}
}
else
{
del_timer(&s_timer);
iounmap(pbase_logo);
}
#endif
}
//---------------
module_init(__system_timer_init);
2. 直接编译进kernel
- 进入内核源码目录linux-4.9.y/arch/arm/mach-hibvt/ 下添加
systimer.c
- 修改
Makefile
, 添加obj-y += systimer.o