通过前面的学习,我们已经完成了SylixOS内核入口文件设置、内核VMM映射表设置和串口SIO驱动这几个比较重要的功能,这下我们可以再次编译内核启动,这次内核应该是是可以成功输出SylixOS的Logo并进入shell命令行的。在此之前,我们需要做两件事:1.BSP字符串信息修改,2.创建tty设备。
在bspLib.c文件的开始处,通过几个全局变量定义了BSP和Cache等一些信息,需要根据开发板实际情况进行修改:下图是我修改后的

我们之前在介绍串口去的时候就已经说过了,每个串口设备都要创建自己的tty设备。先介绍一下tty设备驱动安装。
tty 驱动相关信息位于“libsylixos/SylixOS/system/device/ty”目录下,系统在创建 tty 设备之前需要先安装 tty 设备相关的驱动。tty 设备驱动安装函数原型如下:
#include
INT API_TtyDrvInstall(VOID);
函数 API_TtyDrvInstall 原型分析:
API_TtyDrvInstall 的主要实现如下:
INT API_TtyDrvInstall(VOID)
{
_G_iTycoDrvNum = iosDrvInstall(_ttyOpen,
(FUNCPTR)LW_NULL,
_ttyOpen,
_ttyClose,
_TyRead,
_TyWrite,
_ttyIoctl);
return ((_G_iTycoDrvNum > 0) ? (ERROR_NONE) : (PX_ERROR));
}
G_iTycoDrvNum 是全局的驱动号,驱动安装成功后系统将为 tty 设备驱动分配一个驱动号,然后系统即可实现对 tty 设备进行打开、关闭、读写以及控制等操作。
tty 设备创建函数原形如下:
#include
INT API_TtyDevCreate (PCHAR pcName,
SIO_CHAN *psiochan,
size_t stRdBufSize,
size_t stWrtBufSize)
函数 API_TtyDevCreate 原型分析:
函数 API_TtyDevCreate 使用结构体 SIO_CHAN 来向内核提供串口操作函数集合,而参数 psiochan 是串口通道创建函数的返回值,其中主要提供了串口驱动实现的对串口进行操作的方法。tty 设备创建完成之后,可通过串口终端与设备进行信息交互。
在bspInit.c中的halDevInit 函数中添加创建调试串口tty设备的代码。我们先去看看默认的

编辑我们T3的
/*********************************************************************************************************
** 函数名称: halDevInit
** 功能描述: 初始化目标系统静态设备组件
** 输 入 : NONE
** 输 出 : NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
#if LW_CFG_DEVICE_EN > 0
static VOID halDevInit (VOID)
{
/*
* 创建根文件系统时, 将自动创建 dev, mnt, var 目录.
*/
rootFsDevCreate(); /* 创建根文件系统 */
procFsDevCreate(); /* 创建 proc 文件系统 */
shmDevCreate(); /* 创建共享内存设备 */
randDevCreate(); /* 创建随机数文件 */
/*
* TODO: 加入你的处理代码, 参考代码如下:
*/
#if 1 /* 参考代码开始 */
SIO_CHAN *psio0 = uartSioChanCreate(); /* 创建串口通道 */
ttyDevCreate("/dev/ttyS0", psio0, 30, 50); /* add tty device */
#endif /* 参考代码结束 */
yaffsDevCreate("/yaffs2"); /* create yaffs device(only fs)*/
}
#endif
首先通过uartSioChanCreate 接口获取到串口的SIO通道数据结构指针,然后通过ttyDevCreate 接口来创建tty设备。其中30和50分别表示tty设备对应的输入缓冲区和输出缓冲区的大小,我们这里就直接使用默认值了。在设置的时候要根据实际大小来配。

把我们编译好的bin文件复制到我们的SD卡里(图中的项目名称发现和我最初的不一样了。是被我改了,因为我怕直接改会出错,所以我每成功一步就会保留当前的bsp项目,然后再新建一个复现我前面的内容,然后继续下一步)

把刚刚拷贝新bin文件的SD卡插入我们的T3开发板中,然后用ttl转usb接口工具连接我们的笔记本电脑,打开我们笔记本电脑的串口工具。


开发板上电(注意不要按回车):
LO! BOOT0 is starting!
boot0 commit : 8
boot0 version : 4.0
set pll start
set pll end
PMU: AXP221
rtc[0] value = 0x00000000
rtc[1] value = 0x00000000
rtc[2] value = 0x00000000
rtc[3] value = 0x00000000
rtc[4] value = 0x00000000
rtc[5] value = 0x00000000
DRAMC IS FOUR
DRAM BOOT DRIVE INFO: V1.1
the chip id is 0x00000003
the chip id is 0x00000003
the chip id is 0x00000003
the chip id is 0x00000003
the chip id is 0x00000003
PMU: AXP221
ddr voltage = 1500 mv
DRAM CLK =576 MHZ
DRAM Type =3 (2:DDR2,3:DDR3,6:LPDDR2,7:LPDDR3)
DRAM zq value: 0x003b3bfb
DRAM SIZE =1024 M
DRAM simple test OK.
dram size =1024
rtc standby flag is 0x00000000, super standby flag is 0x00000000
card no is 2
sdcard 2 line count 8
[mmc]: mmc driver ver 2016-06-2 17:11
[mmc]: ***Try MMC card 2***
[mmc]: MMC 5.1
[mmc]: HSSDR52/SDR25 8 bit
[mmc]: 50000000 Hz
[mmc]: 7456 MB
[mmc]: ***SD/MMC 2 init OK!!!***
sum=d3bb92b2
src_sum=d3bb92b2
Succeed in loading uboot from sdmmc flash.
Entry_name = u-boot
Ready to disable icache.
0xffffffff 0xffffffff
0xff1bffff 0xffffffff
0xff0e18ff 0xffffffff
0xffffffff 0xffffffff
0xffffffff 0xffffffff
0xffffffff 0xffffffff
Jump to secend Boot.
U-Boot 2014.07 (Nov 29 2016 - 04:02:45) Allwinner Technology
uboot commit : 8
uboot:normal mode
i2c_init ok
[ 0.381]pmbus: ready
[ 0.400]PMU: AXP221
[ 0.400]PMU: AXP22x found
[ 0.401]PMU: dcdc2 1200
[ 0.403]PMU: cpux 1008 Mhz,AXI=336 Mhz
PLL6=600 Mhz,AHB1=200 Mhz, APB1=100Mhz MBus=400Mhz
set power on vol to default
device_type = 3253, onoff=1
dcdc1_vol = 3300, onoff=1
dcdc2_vol = 1200, onoff=1
dcdc3_vol = 1100, onoff=1
dcdc4_vol = 1100, onoff=0
aldo1_vol = 3300, onoff=1
aldo2_vol = 2500, onoff=1
aldo3_vol = 3000, onoff=1
dc1sw_vol = 3000, onoff=0
dc5ldo_vol = 1100, onoff=0
dldo1_vol = 3300, onoff=0
dldo2_vol = 3300, onoff=0
dldo3_vol = 3300, onoff=0
dldo4_vol = 3300, onoff=0
eldo1_vol = 1200, onoff=0
eldo2_vol = 1500, onoff=0
eldo3_vol = 2800, onoff=0
vbus exist
run key detect
no key found
no uart input
DRAM: 1 GiB
fdt addr: 0x76e88b78
Relocation Offset is: 35edf000
In: serial
Out: serial
Err: serial
gic: normal mode
workmode = 0,storage type = 2
[ 0.601]MMC: 2
[mmc]: mmc driver ver 2016-05-20 17:18:00-test0
[mmc]: get sdc_ex_dly_used 2, use auto tuning sdly
SUNXI SD/MMC: 2
[mmc]: 50 MHz...
[mmc]: sample: 57 - 175(ps)
[mmc]: ds: 57 - 175(ps)
[mmc]: 100 MHz...
[mmc]: sample: 29 - 172(ps)
[mmc]: ds: 28 - 178(ps)
[mmc]: 200 MHz...
[mmc]: sample: 14 - 178(ps)
[mmc]: ds: 15 - 166(ps)
[mmc]: media type 0x8000000
[mmc]: ************Try MMC card 2************
[mmc]: host caps: 0x6f
[mmc]: MID 000015 PSN d225b6e5
[mmc]: PNM 8GTF4R -- 0x38-47-54-46-34
[mmc]: PRV 0.6
[mmc]: MDT m-8 y-2020
[mmc]: MMC v5.1
[mmc]: speed mode : HSSDR52/SDR25
[mmc]: clock : 50000000 Hz
[mmc]: bus_width : 8 bit
[mmc]: user capacity : 7456 MB
[mmc]: boot capacity : 4096 KB
[mmc]: rpmb capacity : 512 KB
[mmc]: ************SD/MMC 2 init OK!!!************
[mmc]: ========best spd md: 2-HSDDR52/DDR50, freq: 2-50000000
[mmc]: already at HSSDR52_SDR25 mode
[mmc]: hsddr 2-50000000
[mmc]: get max-frequency ok 150000000 Hz
[mmc]: 1 1 0: 1 1 0
[mmc]: delete mmc-hs400-1_8v from dtb
[mmc]: delete mmc-hs200-1_8v from dtb
[mmc]: get max-frequency ok 50000000 Hz
[mmc]: erase_grp_size : 0x400WrBlk*0x200=0x80000 Byte
[mmc]: secure_feature : 0x55
[mmc]: secure_removal_type : 0x39
[mmc]: EOL Info(Rev blks): Normal
[mmc]: Wear out(type A): 0%-10% life time used
[mmc]: Wear out(type B): 0%-10% life time used
[ 0.844]sunxi flash init ok
[ 0.861]start
drv_disp_init
init_clocks: finish init_clocks.
device name:tve0, par name:pll_video0
pwm_request: reg = 0x1c23400. pwm = 0.
request pwm success, pwm = 0.
tv_init:
tv_init:
drv_disp_init finish
fetch script data disp.dev0_output_type fail. using defval=0
no found any device of disp. num=0
enable power vcc-lcd, ret=0
enable power vcc-pd, ret=0
FDT ERROR:format gpio lcdd2
fdt_setprop_u32 disp.boot_disp(0x100) code:<no error>
fb_id=0, size=2457600, gd->ram_size=1073741824, SUNXI_DISPLAY_FRAME_BUFFER_SIZE=16777216
[ 1.361]end
PowerBus = 3( 2:vBus 3:acBus other: not exist)
no battery, limit to dc
no battery exist
sunxi_bmp_logo_display
bmp_name=bootlogo.bmp
reading bootlogo.bmp
326256 bytes read in 6 ms (51.9 MiB/s)
memset full fb
fdt_setprop_string disp.boot_fb0(7f000000,400,258,20,1000,151,b7,2af,1a0). ret-code:<no error>
--------fastboot partitions--------
-total partitions:5-
-name- -start- -size-
boot-resource: 1000000 2000000
env : 3000000 1000000
boot : 4000000 4000000
rootfs : 8000000 0
UDISK : 8000000 0
-----------------------------------
base bootcmd=run bootsylixos
bootcmd set setargs_mmc
key 0
cant find rcvy value
cant find fstbt value
no misc partition is found
to be run cmd=run bootsylixos
read item0 copy0
Item0 (Map) magic is bad
the secure storage item0 copy0 is bad
read item0 copy1
Item0 (Map) magic is bad
the secure storage item0 copy0 == copy1, the data is good
the secure storage map is empty
no item name mac in the map
sunxi storage read fail
no item name wifi_mac in the map
sunxi storage read fail
no item name bt_mac in the map
sunxi storage read fail
no item name specialstr in the map
sunxi storage read fail
check user data form private
the private part isn't exist
update dtb dram start
update dtb dram end
[ 1.648]inter uboot shell
Hit any key to stop autoboot: 0
reading bspallwinnert3_educational.bin
4364560 bytes read in 56 ms (74.3 MiB/s)
## Starting application at 0x40100000 ...
Block device /dev/blk/sdcard-0 part 1 mount to /media/sdcard0 use vfat file system.
Block device /dev/blk/sdcard-0 part 2 mount to /media/sdcard1 use tpsfs file system.
Block device /dev/blk/sdcard-1 part 0 mount to /media/sdcard2 use vfat file system.
Block device /dev/blk/sdcard-1 part 1 mount to /media/sdcard3 use vfat file system.
<01476> init_clocks: finish init_clocks.
sunxi clock driver inserted!
mount sd memory card successfully.
mount sd memory card successfully.
environment variables load from /etc/profile fail, error: No such file or directory
[ifparam]No network parameter for [emac] from /etc/ifparam.ini, default parameters will be used.
Press <n> to NOT execute /etc/startup.sh (timeout: 1 sec(s))
can not open /etc/startup.sh: No such file or directory
sysname : sylixos
nodename : sylixos
release : Tangram
version : 1.12.9
machine : Allwinner T3 (Quad-core ARM Cortex-A7 1.2GHz VFPv4)
[[ (R)
[[[[ [[[[ [[ [[[[ [[[[
[[ [[ [[ [[ [[ [[ [[
[[ [[ [[ [[ [[[[ [[ [[ [[ [[ [[
[[ [[ [[ [[ [[ [[ [[ [[ [[ [[
[[ [[ [[ [[ [[ [[[[ [[ [[ [[
[[ [[ [[ [[ [[ [[ [[ [[ [[
[[ [[ [[ [[ [[ [[[[ [[ [[ [[
[[ [[ [[ [[ [[ [[ [[ [[ [[ [[ [[ [[
[[[[ [[[[ [[[[[[ [[[[[[ [[ [[ [[[[ [[[[
[[
[[ KERNEL: LongWing(C) 1.12.9
[[[[ COPYRIGHT ACOINFO Co. Ltd. 2006 - 2019
SylixOS license: Commercial & GPL.
SylixOS kernel version: 1.12.9 Code name: Tangram
CPU : Allwinner T3 (Quad-core ARM Cortex-A7 1.2GHz VFPv4)
CACHE : 64KBytes(D-32K/I-32K) L1-Cache per core, 512KBytes L2-Cache
PACKET : CRQ40 ALLWINNER T3 Packet
ROM SIZE: 0x00400000 Bytes (0x00000000 - 0x003fffff)
RAM SIZE: 0x3ff00000 Bytes (0x40100000 - 0x7fffffff)
BSP : BSP version 1.1.0 for Tangram
[root@sylixos:/root]#
最后进入我们的SylixOS系统

进入我们SD卡的文件目录输入命令:
cd /media/sdcard2
拷贝我们的镜像文件到/boot目录下输入命令
cp bsp_T3_uart.bin /boot
展示如下

我们可以去boot目录查看我们的bin 文件有没有拷过去

HELLO! BOOT0 is starting!
boot0 commit : 8
boot0 version : 4.0
set pll start
set pll end
PMU: AXP221
rtc[0] value = 0x00000000
rtc[1] value = 0x00000000
rtc[2] value = 0x00000000
rtc[3] value = 0x00000000
rtc[4] value = 0x00000000
rtc[5] value = 0x00000000
DRAMC IS FOUR
DRAM BOOT DRIVE INFO: V1.1
the chip id is 0x00000003
the chip id is 0x00000003
the chip id is 0x00000003
the chip id is 0x00000003
the chip id is 0x00000003
PMU: AXP221
ddr voltage = 1500 mv
DRAM CLK =576 MHZ
DRAM Type =3 (2:DDR2,3:DDR3,6:LPDDR2,7:LPDDR3)
DRAM zq value: 0x003b3bfb
DRAM SIZE =1024 M
DRAM simple test OK.
dram size =1024
rtc standby flag is 0x00000000, super standby flag is 0x00000000
card no is 2
sdcard 2 line count 8
[mmc]: mmc driver ver 2016-06-2 17:11
[mmc]: ***Try MMC card 2***
[mmc]: MMC 5.1
[mmc]: HSSDR52/SDR25 8 bit
[mmc]: 50000000 Hz
[mmc]: 7456 MB
[mmc]: ***SD/MMC 2 init OK!!!***
sum=d3bb92b2
src_sum=d3bb92b2
Succeed in loading uboot from sdmmc flash.
Entry_name = u-boot
Ready to disable icache.
0xffffffff 0xffffffff
0xff1bffff 0xffffffff
0xff0e18ff 0xffffffff
0xffffffff 0xffffffff
0xffffffff 0xffffffff
0xffffffff 0xffffffff
Jump to secend Boot.
U-Boot 2014.07 (Nov 29 2016 - 04:02:45) Allwinner Technology
uboot commit : 8
uboot:normal mode
i2c_init ok
[ 0.378]pmbus: ready
[ 0.397]PMU: AXP221
[ 0.397]PMU: AXP22x found
[ 0.398]PMU: dcdc2 1200
[ 0.400]PMU: cpux 1008 Mhz,AXI=336 Mhz
PLL6=600 Mhz,AHB1=200 Mhz, APB1=100Mhz MBus=400Mhz
set power on vol to default
device_type = 3253, onoff=1
dcdc1_vol = 3300, onoff=1
dcdc2_vol = 1200, onoff=1
dcdc3_vol = 1100, onoff=1
dcdc4_vol = 1100, onoff=0
aldo1_vol = 3300, onoff=1
aldo2_vol = 2500, onoff=1
aldo3_vol = 3000, onoff=1
dc1sw_vol = 3000, onoff=0
dc5ldo_vol = 1100, onoff=0
dldo1_vol = 3300, onoff=0
dldo2_vol = 3300, onoff=0
dldo3_vol = 3300, onoff=0
dldo4_vol = 3300, onoff=0
eldo1_vol = 1200, onoff=0
eldo2_vol = 1500, onoff=0
eldo3_vol = 2800, onoff=0
vbus exist
run key detect
no key found
no uart input
DRAM: 1 GiB
fdt addr: 0x76e88b78
Relocation Offset is: 35edf000
In: serial
Out: serial
Err: serial
gic: normal mode
workmode = 0,storage type = 2
[ 0.598]MMC: 2
[mmc]: mmc driver ver 2016-05-20 17:18:00-test0
[mmc]: get sdc_ex_dly_used 2, use auto tuning sdly
SUNXI SD/MMC: 2
[mmc]: 50 MHz...
[mmc]: sample: 56 - 178(ps)
[mmc]: ds: 59 - 169(ps)
[mmc]: 100 MHz...
[mmc]: sample: 28 - 178(ps)
[mmc]: ds: 29 - 172(ps)
[mmc]: 200 MHz...
[mmc]: sample: 14 - 178(ps)
[mmc]: ds: 14 - 178(ps)
[mmc]: media type 0x8000000
[mmc]: ************Try MMC card 2************
[mmc]: host caps: 0x6f
[mmc]: MID 000015 PSN d225b6e5
[mmc]: PNM 8GTF4R -- 0x38-47-54-46-34
[mmc]: PRV 0.6
[mmc]: MDT m-8 y-2020
[mmc]: MMC v5.1
[mmc]: speed mode : HSSDR52/SDR25
[mmc]: clock : 50000000 Hz
[mmc]: bus_width : 8 bit
[mmc]: user capacity : 7456 MB
[mmc]: boot capacity : 4096 KB
[mmc]: rpmb capacity : 512 KB
[mmc]: ************SD/MMC 2 init OK!!!************
[mmc]: ========best spd md: 2-HSDDR52/DDR50, freq: 2-50000000
[mmc]: already at HSSDR52_SDR25 mode
[mmc]: hsddr 2-50000000
[mmc]: get max-frequency ok 150000000 Hz
[mmc]: 1 1 0: 1 1 0
[mmc]: delete mmc-hs400-1_8v from dtb
[mmc]: delete mmc-hs200-1_8v from dtb
[mmc]: get max-frequency ok 50000000 Hz
[mmc]: erase_grp_size : 0x400WrBlk*0x200=0x80000 Byte
[mmc]: secure_feature : 0x55
[mmc]: secure_removal_type : 0x39
[mmc]: EOL Info(Rev blks): Normal
[mmc]: Wear out(type A): 0%-10% life time used
[mmc]: Wear out(type B): 0%-10% life time used
[ 0.840]sunxi flash init ok
[ 0.858]start
drv_disp_init
init_clocks: finish init_clocks.
device name:tve0, par name:pll_video0
pwm_request: reg = 0x1c23400. pwm = 0.
request pwm success, pwm = 0.
tv_init:
tv_init:
drv_disp_init finish
fetch script data disp.dev0_output_type fail. using defval=0
no found any device of disp. num=0
enable power vcc-lcd, ret=0
enable power vcc-pd, ret=0
FDT ERROR:format gpio lcdd2
fdt_setprop_u32 disp.boot_disp(0x100) code:<no error>
fb_id=0, size=2457600, gd->ram_size=1073741824, SUNXI_DISPLAY_FRAME_BUFFER_SIZE=16777216
[ 1.358]end
PowerBus = 3( 2:vBus 3:acBus other: not exist)
no battery, limit to dc
no battery exist
sunxi_bmp_logo_display
bmp_name=bootlogo.bmp
reading bootlogo.bmp
326256 bytes read in 6 ms (51.9 MiB/s)
memset full fb
fdt_setprop_string disp.boot_fb0(7f000000,400,258,20,1000,151,b7,2af,1a0). ret-code:<no error>
--------fastboot partitions--------
-total partitions:5-
-name- -start- -size-
boot-resource: 1000000 2000000
env : 3000000 1000000
boot : 4000000 4000000
rootfs : 8000000 0
UDISK : 8000000 0
-----------------------------------
base bootcmd=run bootsylixos
bootcmd set setargs_mmc
key 0
cant find rcvy value
cant find fstbt value
no misc partition is found
to be run cmd=run bootsylixos
read item0 copy0
Item0 (Map) magic is bad
the secure storage item0 copy0 is bad
read item0 copy1
Item0 (Map) magic is bad
the secure storage item0 copy0 == copy1, the data is good
the secure storage map is empty
no item name mac in the map
sunxi storage read fail
no item name wifi_mac in the map
sunxi storage read fail
no item name bt_mac in the map
sunxi storage read fail
no item name specialstr in the map
sunxi storage read fail
check user data form private
the private part isn't exist
update dtb dram start
update dtb dram end
[ 1.645]inter uboot shell
Hit any key to stop autoboot: 0
sunxi#
sunxi#
sunxi#

输入命令
fatload mmc 2:2 40100000 bsp_t3_uart.bin

go 40000000

这里不知道为什么和我的debug串口显示的页面是一样的,感觉和我想象的不太一样。