SylixOS启动初体验
通过前面的学习,我们已经完成了SylixOS内核入口文件设置、内核VMM映射表设置和串口SIO驱动这几个比较重要的功能,这下我们可以再次编译内核启动,这次内核是可以成功输出SylixOS的Logo并进入shell命令行的。不过在这之前,我们还有一些小小的工作需要做一下。
1. 修改BSP字符串信息
在bspLib.c文件的开始处,通过几个全局变量定义了BSP和Cache等一些信息,需要根据开发板实际情况进行修改:
/********************************************************************************************************* BSP 信息 *********************************************************************************************************/ /* * TODO: 修改以下字符串为目标板的 CPU 信息 */ static const CHAR _G_pcCpuInfo[] = "Allwinner R16, Quad-core Cortex-A7 Up to 1.2GHz"; /* * TODO: 修改以下字符串为目标板的 CACHE 信息 */ static const CHAR _G_pcCacheInfo[] = "128KBytes(D-32K/I-32K) L1-Cache per core,512KBytes L2-Cache"; /* * TODO: 修改以下字符串为目标板的信息 */ static const CHAR _G_pcPacketInfo[] = "ClockworkPI (CPI v3.1) development board"; /* * TODO: 修改以下字符串为 BSP 的版本信息 */ static const CHAR _G_pcVersionInfo[] = "BSP version 1.0.0 for "__SYLIXOS_RELSTR;
2. 创建串口tty设备
在bspInit.c中的halDevInit 函数中添加创建调试串口tty设备的代码:
static VOID halDevInit (VOID) { /* * 创建根文件系统时, 将自动创建 dev, mnt, var 目录. */ rootFsDevCreate(); /* 创建根文件系统 */ procFsDevCreate(); /* 创建 proc 文件系统 */ shmDevCreate(); /* 创建共享内存设备 */ randDevCreate(); /* 创建随机数文件 */ /* * TODO: 加入你的处理代码, 参考代码如下: */ #if 1 /* 参考代码开始 */ SIO_CHAN *psio0 = uartSioChanCreate(); /* 创建串口 0 通道 */ ttyDevCreate("/dev/ttyS0", psio0, 30, 50); /* add tty device */ #endif /* 参考代码结束 */ yaffsDevCreate("/yaffs2"); /* create yaffs device(only fs)*/ }
首先通过uartSioChanCreate 接口获取到串口的SIO通道数据结构指针,然后通过ttyDevCreate 接口来创建tty设备。其中30和50分别表示tty设备对应的输入缓冲区和输出缓冲区的大小,这两个值实际使用时建议设置的大点,这里为了演示直接使用默认的大小。
3. 关闭执行启动脚本
注释掉halBootThread 函数对tshellStartup 接口的调用代码:
启动脚本用于系统启动时自动运行一些程序或者加载驱动模块等等,tshellStartup 接口会获取用户的串口输入,如果接收到字符'n'则跳过自动执行脚本,如果在1秒内没有接收到这个字符则自动执行启动脚本。由于会使用到系统的定时接口,而我们现在还没有实现中断和定时器的驱动,所以这个接口调用后会将当前线程挂起而不会返回,而且在本次的BSP系列教程中我们并不需要关心启动脚本,所以这里就直接将这个调用注释掉。
重新编译SylixOS内核镜像,复制到SD卡中,并在U-Boot下引导启动,一起正常的话就会看到SylixOS的Logo了:
=> fatload mmc 0:1 40000000 bsp_allwinner_r16.bin reading bsp_allwinner_r16.bin 3232056 bytes read in 175 ms (17.6 MiB/s) => go 40000000 ## Starting application at 0x40000000 ... longwing(TM) kernel initialize... kernel low level initialize... kernel heap build... semaphore "heap_lock" has been create. kernel heap has been create 0x40f08cd8 (47149736 Bytes). system heap build... system heap has been create 0x0 (0 Bytes). kernel interrupt vector initialize... kernel high level initialize... semaphore "sigfdsel_lock" has been create. thread "t_idle0" has been initialized. thread "t_idle0" has been start. thread "t_itimer" has been initialized. thread "t_itimer" has been start. semaphore "job_sync" has been create. thread "t_isrdefer" has been initialized. thread "t_isrdefer" has been start. semaphore "job_sync" has been create. thread "t_except" has been create. msgqueue "log_msg" has been create. partition "printk_pool" has been create. thread "t_log" has been initialized. semaphore "ios_mutex" has been create. semaphore "evtfdsel_lock" has been create. semaphore "bmsgsel_lock" has been create. semaphore "bmsgd_lock" has been create. semaphore "semfdsel_lock" has been create. semaphore "semfd_lock" has been create. semaphore "tmrfdsel_lock" has been create. semaphore "hstmrfdsel_lock" has been create. semaphore "gpiofdsel_lock" has been create. semaphore "blkio_lock" has been create. semaphore "autom_lock" has been create. semaphore "mount_lock" has been create. semaphore "bus_listlock" has been create. semaphore "blk_lock" has been create. semaphore "power_lock" has been create. semaphore "sel_wakeup" has been create. thread "t_power" has been create. semaphore "job_sync" has been create. semaphore "hotplug_lock" has been create. semaphore "sel_wakeup" has been create. thread "t_hotplug" has been create. semaphore "hpsel_lock" has been create. semaphore "hotplug_lock" has been create. system initialized. semaphore "cpprt_lock" has been create. semaphore "cond_signal" has been create. c++ run time lib initialized. kernel primary cpu usrStartup... ARM(R) A7 vfpv3 FPU pri-core initialization. FPU initilaized. semaphore "vmm_lock" has been create. semaphore "vmmap_lock" has been create. ARM(R) A7 MMU initialization. partition "pgd_pool" has been create. partition "pte_pool" has been create. mmu initialize. start memory pagination... MMU initilaized. ARM(R) A7 L1 cache controller initialization. ARM(R) A7 L2 cache controller initialization. ARMv7 I-Cache line size = 32 bytes, Way size = 16384 bytes. ARMv7 D-Cache line size = 64 bytes, Way size = 8192 bytes. CACHE initilaized. I-CACHE enable. D-CACHE enable. semaphore "sel_wakeup" has been create. thread "t_boot" has been create. msgqueue "res_reclaim" has been create. semaphore "sel_wakeup" has been create. thread "t_reclaim" has been create. semaphore "resh_lock" has been create. semaphore "resraw_lock" has been create. kernel ticks initialize... semaphore "ints_lock" has been create. IRQ 0 : tick_timer connect : 0x400003f8 primary cpu multi-task start... semaphore "tshell_lock" has been create. semaphore "heap_trace_lock" has been create. semaphore "proc_lock" has been create. semaphore "shm_lock" has been create. semaphore "pipe_ropen" has been create. semaphore "pipe_wopen" has been create. SylixOS tpsFs file system installed. ISO9660 file system installed. microsoft FAT file system installed. ram file system installed. rom file system installed. semaphore "nfs_lock" has been create. nfs file system installed. yaffs2 file system installed. semaphore "yaffs_oplock" has been create. semaphore "randsel_lock" has been create. semaphore "ty_rsync" has been create. semaphore "ty_wsync" has been create. semaphore "ty_drain" has been create. semaphore "ty_lock" has been create. semaphore "sellist_lock" has been create. semaphore "sel_wakeup" has been create. thread "t_sync" has been create. yaffs "/yaffs2" has been create. thread "t_log" has been start. semaphore "ramvol_lock" has been create. target "/dev/ram" mount ok. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. environment variables load from /etc/profile fail, error: No such file or directory semaphore "if_list" has been create. semaphore "job_sync" has been create. semaphore "sel_wakeup" has been create. thread "t_netjob" has been create. semaphore "nevt_lock" has been create. semaphore "sellist_lock" has been create. msgqueue "net_msg" has been create. semaphore "net_mutex" has been create. semaphore "sel_wakeup" has been create. thread "t_netproto" has been initialized. thread "t_netproto" has been start. semaphore "afunix_lock" has been create. partition "unix_256" has been create. partition "unix_512" has been create. semaphore "afpacket_lock" has been create. partition "afpacket_nodes" has been create. semaphore "socksel_lock" has been create. semaphore "vnd_lock" has been create. semaphore "vnd_sel" has been create. semaphore "net_mutex" has been create. semaphore "net_sem" has been create. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "net_libc" has been create. semaphore "hosttable_lock" has been create. semaphore "sel_wakeup" has been create. thread "t_snmp" has been initialized. thread "t_snmp" has been start. semaphore "net_mutex" has been create. semaphore "net_mutex" has been create. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "ftpsession_lock" has been create. semaphore "sel_wakeup" has been create. thread "t_ftpd" has been create. semaphore "sel_wakeup" has been create. thread "t_telnetd" has been create. timer "nat_timer" has been create. semaphore "sem_npflcok" has been create. semaphore "sem_qoslcok" has been create. semaphore "px_lock" has been create. semaphore "aio_mutex" has been create. semaphore "cond_signal" has been create. semaphore "pseminit" has been create. semaphore "pmutexinit" has been create. semaphore "prwinit" has been create. semaphore "pcondinit" has been create. semaphore "syslog_lock" has been create. semaphore "symtable_lock" has been create. semaphore "loader_lock" has been create. semaphore "execshare_lock" has been create. semaphore "kvproc_lock" has been create. semaphore "sel_wakeup" has been create. thread "t_main" has been create. semaphore "sel_wakeup" has been delete. thread "t_boot" has been delete. msgqueue "net_msg" has been create. semaphore "net_tsem" has been create. msgqueue "net_msg" has been create. semaphore "net_tsem" has been create. msgqueue "net_msg" has been delete. msgqueue "net_msg" has been create. msgqueue "net_msg" has been create. semaphore "net_tsem" has been create. msgqueue "net_msg" has been delete. msgqueue "net_msg" has been create. sysname : sylixos nodename : sylixos release : Tangram version : 1.12.9 machine : Allwinner R16, Quad-core Cortex-A7 Up to 1.2GHz ttiny shell system initialize... semaphore "sel_wakeup" has been create. thread "t_tshell" has been initialized. thread "t_tshell" has been start. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. semaphore "fd_node_lock" has been create. semaphore "fd_node_lock" has been delete. [[ (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 R16, Quad-core Cortex-A7 Up to 1.2GHz CACHE : 128KBytes(D-32K/I-32K) L1-Cache per core,512KBytes L2-Cache PACKET : ClockworkPI (CPI v3.1) development board ROM SIZE: 0x00400000 Bytes (0x00000000 - 0x003fffff) RAM SIZE: 0x40000000 Bytes (0x40000000 - 0x7fffffff) BSP : BSP version 1.0.0 for Tangram [root@sylixos:/root]# semaphore "sel_wakeup" has been delete. thread "t_main" has been delete.
2021年4月5日 16:10 1F
这章节有点水啊
2021年4月5日 21:02 B1
@ iloverr 不就是log有点长吗🤪
2021年5月10日 15:49 2F
支持蛋哥
2021年11月23日 19:03 3F
看到这里已经又来躯壳了