Buildfile structure and contents
The buildfile for a bootable image includes three major sections: a bootstrap loader (which includes an operating system), a script, and included files such as executables and shared libraries.
- Executables aren't strictly required, but without them the system won't actually do anything!
- In most cases, the bootable image needs libc.so, which is required to run an executable.
Below is a simple buildfile example that is based on the Honeycomb LX2 BSP and includes only basic OS capabilities.
Many sample buildfiles provide a /tmp that links to /dev/shmem as a temporary in-memory filesystem that is useful for demonstration systems that do not have a persistent filesystem. However, it is not a fully-featured filesystem (e.g., mkdir is not supported) and should not be used as /tmp in a deployed system. For example, a system configuration can have a /tmp based on devb-ram or devf-ram.
Also, given the union mount capabilities of QNX OS, having both /dev/shmem and another resource manager mapped to /tmp at the same time may cause unexpected behaviour.
[image=0x80200000]
[virtual=aarch64le,elf] .boot = {
# Startup parameters:
# '-W' -> enable watchdog
startup-honeycomb_lx2 -W
PATH=/proc/boot:/sbin:/bin:/usr/bin:/usr/sbin:/usr/libexec
LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll
procnto-smp-instr -v
}
[+script] .script = {
SYSNAME=nto
TERM=qansi
ENV=/etc/profile
procmgr_symlink ../../proc/boot/ldqnx-64.so.2 /usr/lib/ldqnx-64.so.2
## Needed for ksh to run the echo command below
pipe
display_msg " "
ksh -c "echo Welcome to QNX $(uname -r) on $(uname -m) !"
## Serial driver
devc-serpl011 -b115200 -c174974400 -e -F -u1 0x21c0000,64
waitfor /dev/ser1 4
reopen /dev/ser1
display_msg "Starting shell ..."
[+session] ksh &
}
# Redirect console messages
[type=link] /bin/sh=/bin/ksh
[type=link] /tmp=/dev/shmem
[type=link] /dev/console=/dev/ser1
[type=link] /var/log=/tmp
[type=link] /usr/tmp=/tmp
# Shared libraries
ldqnx-64.so.2=ldqnx-64.so.2
/lib/libc.so=libc.so
/lib/libcatalog.so=libcatalog.so
/lib/libdevice-publisher.so=libdevice-publisher.so
/lib/libgcc_s.so=libgcc_s.so
/lib/libm.so=libm.so
[+optional] /lib/libfsnotify.so=libfsnotify.so
/usr/lib/libbacktrace.so=libbacktrace.so
/usr/lib/libc++.so=libc++.so
/usr/lib/libiconv.so=libiconv.so
/usr/lib/libintl.so=libintl.so
/usr/lib/libpanelw.so=libpanelw.so
/usr/lib/libz.so=libz.so
# General commands
/bin/confstr=confstr
/bin/df=df
/bin/hostname=hostname
/bin/kill=kill
/bin/ksh=ksh
/bin/mount=mount
/bin/on=on
/bin/pidin=pidin
/bin/slay=slay
/bin/slog2info=slog2info
/bin/slogger2=slogger2
/bin/sync=sync
/bin/umount=umount
/bin/waitfor=waitfor
/sbin/mqueue=mqueue
/sbin/pipe=pipe
/sbin/shutdown=shutdown
/usr/bin/getconf=getconf
/usr/bin/hd=hd
/usr/bin/ldd=ldd
/usr/bin/setconf=setconf
/usr/bin/top=top
/usr/bin/use=use
/usr/sbin/dumper=dumper
/usr/sbin/random=random
/usr/sbin/tracelogger=tracelogger
# Set up environment
/etc/profile = {
export HOME=/
export SYSNAME=nto
export TERM=qansi
export PATH=/proc/boot:/sbin:/bin:/usr/bin:/usr/sbin:/usr/libexec
export LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll
}
# Customized startup
customize_startup.sh = {
#!/bin/ksh
if [ -e /scripts/startup.sh ]; then
echo "Starting board customize script ..."
ksh /scripts/startup.sh
fi
}
- the offset in memory where the bootable image starts, specified by the
image
attribute; this offset applies to the bootstrap section that immediately follows, and is particular to this board - a bootstrap loader (also called a bootfile), which includes an operating
system — starting with
[virtual=aarch64le,elf]
- a script of commands to execute after the OS loads — starting with
[+script]
- a list of links and files to include in the image — starting with
[type=link] /bin/sh=/bin/ksh
For details about different parts of the buildfile, see the The bootstrap file
, Scripts
, and
The rest of the buildfile
topics.
For information on making an image from this buildfile, see Building an OS image
.
Sample buildfiles
For sample buildfiles, use the ones that come with your BSP and refer to the
Sample Buildfiles
appendix in this guide. See also the
examples in the mkifs entry in the Utilities Reference.