
一 概述
QNX支持的芯片分为两类,一是X86体系结构的CPU,二是ARM-v7体系结构的CPU。由于不同体系结构的CPU芯片的上电启动方式不同,所以实现QNX的上电自启动也分为两种不同的方式。
二 基于X86体系的QNX上电自启动
在x86体系结构的板卡中,QNX是通过BIOS被引导启动,具体实现步骤如下所示。
- 生成IFS镜像文件
一般QNX用户可在官网的BSP列表中获取与自己板卡相近的Board Support Package,然后完成定制化BSP的开发工作,例如:
- 修改mages/x86-generic.build文件,可完成对QNX操作系统的镜像进行配置;
- 添加原BSP中不包含的驱动程序或者修改已有的驱动程序;
- 完成其他修改;
- 转换IFS文件格式
有过Windows装机经验的开发者都做过U盘启动,QNX也与之类似,我们需要转换IFS镜像文件的格式,并将其烧录到U盘中。转换格式的方法如下(摘自QNX官方技术手册)
To create a bootable USB image:
- Go to the BSP's /imagesdirectory. If you are in the BSP root directory:
cd images
- Create a plain text file root.buildfile to describe the root file system contents for your USB disk image. This file should have the following contents, where boardis the name of your hardware platform (e.g., adi-rcc-c2000):
[num_sectors=524288]
.boot/ifs-board.bin=ifs-board-graphics.bin
# .boot/ifs-board.bin=ifs-board.bin
If you are building a system without Screen, use this:
[num_sectors=524288]
# .boot/ifs-board.bin=ifs-board-graphics.bin
.boot/ifs-board.bin=ifs-board.bin
- Create the QNX6 partition image:
mkxfs -t qnx6fsimg root.build partition.img
- Create a plain text file disk.cfgwith the following contents that describe the partition layout of your
USB disk image:
[heads=64]
[sectors_per_track=32]
[sector_size=512]
[cylinders=513]
[start_at_cylinder=1]
[partition=1 type=177 num_sectors=524288 boot=true]
"partition.img"
- Create the USB disk image:
diskimage -o usb.img -c disk.cfg -b $QNX_TARGET/x86/boot/sys/ipl-diskpc1
- 烧录到U盘,并启动QNX
使用工具软件Win32 Disk Imager将镜像usb.img烧录到一个大于256M的U盘。将U盘插到工控机的USB接口,启动工控机,直到QNX操作系统启动。
- 挂载硬盘到QNX中
硬盘到QNX中(默认BSP中包含硬盘驱动)
1. 将硬盘格式化成QNX格式
一般采用如下命令:
check if your disk driver(devb-* ) is running
# pidin a | grep devb
Check if it's mounted
# mount
check the device file
# ls -l /dev/hd*
check current partition
# fdisk /dev/hd0 /show
You can add partition. Please refer to QNX manual for meaning of options.
# fdisk /dev/hd0 add -s3 -t177
# fdisk /dev/hd0 /show
# mount -e
Format the partition
# mkqnx6fs /dev/hd0t177
2. 重新启动设备
3. 挂载硬盘到根目录(完成1和2后此步骤在build文件中实现,以实现上电自动执行)
mount -t qnx6 /dev/hd0t177 /
- 在磁盘上根据需要,创建自己的文件系统
三 基于ARM-v7体系的QNX上电自启动
ARM-v7体系结构的板卡引导方式有两种,一是通过U-boot引导QNX启动,二是通过IPL引导QNX启动;前者与引导Linux操作系统相同,后者由QNX提供,一般在BSP中会包含对应的实现。
- 基于U-BOOT引导的QNX上电自启动
烧录U-BOOT到FLASH中;
烧录对应的MLO文件到FLASH中;
烧录IFS镜像文件到FLASH指定位置;
修改U-BOOT环境变量,让U-boot到IFS存储位置获取镜像文件,并引导镜像文件正确执行;
- 基于IPL引导的QNX上电自启动
修改IPL源代码,指定IPL获取IFS镜像文件的FLASH地址;
转化IPL可执行文件的格式,即从raw文件转换成bin文件;
烧录IPL到FLASH上电向量指定地址;
烧录IFS镜像文件到FLASH指定位置;
重新上电,启动QNX;