How to create a simple "Hello, World!" application with PTXdist
In this tutorial we use the STKa6x and BSP Rev.0109, but you can easily adapt this example to any other TQ staterkit and BSP.
Make sure you are in the BSP root directory
user@ubuntu-vm:~$ cd workspace/TQMa6x-BSP-REV.0109/ user@ubuntu-vm:~/workspace/TQMa6x-BSP-REV.0109$
To create a new package, we will use the command ptxdist newpackage
.
user@ubuntu-vm:~/workspace/TQMa6x-BSP-REV.0109$ ptxdist newpackage usage: 'ptxdist newpackage <type>', where type is: host create package for development host target create package for embedded target cross create cross development package klibc create package for initramfs built against klibc src-autoconf-lib create autotoolized library src-autoconf-prog create autotoolized binary src-autoconf-proglib create autotoolized binary+library src-cmake-prog create cmake binary src-qmake-prog create qmake binary src-linux-driver create a linux kernel driver src-make-prog create a plain makefile binary src-stellaris create stellaris firmware font create a font package file create package to install existing files kernel create package for an extra kernel barebox create package for an extra barebox image-tgz create package for a tgz image image-genimage create package for a genimage image blspec-entry create package for a bootloader spec entry user@ubuntu-vm:~/workspace/TQMa6x-BSP-REV.0109$
For further details on adding packages please see the PTXdist manual
"How to become a PTXdist Guru", section 4.2 Adding new Packages.
In this tutorial we will create a package of type src-make-prog (which simply consists of a Makefile and a single C source file) by executing:
user@ubuntu-vm:~/workspace/TQMa6x-BSP-REV.0109$ ptxdist newpackage src-make-prog
You need to provide some basic details regarding your package, namely package name, version number, package author and the package section1)
ptxdist: creating a new 'src-make-prog' package: ptxdist: enter package name...........: hello-world ptxdist: enter version number.........: 0.1 ptxdist: enter package author.........: TQ-Embedded <support@tq-group.com> ptxdist: enter package section........: project_specific
After entering the required information two files are created within the BSP's local rules/
directory.
generating rules/hello-world.make generating rules/hello-world.in
rules/hello-world.make | so called “rule file”, controls the build process |
rules/hello-world.in | so called “menu file”, defines menu entries, dynamic configuration and dependencies |
Unless it alread exists, PTXdist asks if it should create a folder local_src/hello-world
.
If you say Y here (or just confirm the preset [Y/n] by hitting *ENTER*) PTXdist will create a skeleton for our package:
local_src/hello-world does not exist, create? [Y/n] y ./ ./Makefile ./wizard.sh ./@name@.c user@ubuntu-vm:~/workspace/TQMa6x-BSP-REV.0109$
Makefile | Makefile used by the make program |
@name@.c | source file (where name is actually the name of our package) |
Let's have a look at the contents of local_src/hello-world/hello-world.c
:
user@ubuntu-vm:~/workspace/TQMa6x-BSP-REV.0109$ cat local_src/hello-world/hello-world.c
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { printf("Hello World, I'm hello-world!\n"); exit(EXIT_SUCCESS); } user@ubuntu-vm:~/workspace/TQMa6x-BSP-REV.0109$
In order to have our new application built by PTXdist, you have to select it in the ptxdist software configuration. Please execute ptxdist menuconfig
and select hello-world <NEW>
:
user@ubuntu-vm:~/workspace/TQMa6x-BSP-REV.0109$ ptxdist menuconfig
.config - PTXdist 2015.05.0 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ┌───────────────────────────────────────────────────── PTXdist 2015.05.0 ─────────────────────────────────────────────────────┐ │ Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----). Highlighted letters are hotkeys. │ │ Pressing <Y> includes, <N> excludes, <M> modularizes features. Press <Esc><Esc> to exit, <?> for Help, </> for Search. │ │ Legend: [*] built-in [ ] excluded <M> module < > module capable │ │ │ │ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ │ │ < > Enable DVI on startup │ │ │ │ <*> eGalax touchscreen support │ │ │ │ [*] eGalax for HardFloat toolchain │ │ │ │ <*> gpio service scripts │ │ │ │ < > hello-world (NEW) │ │ │ │ <*> kmsfbwrap │ │ │ │ [*] netperf │ │ │ │ <*> phyio │ │ │ │ <*> regmon │ │ │ │ < > smsc9303 │ │ │ │ <*> configure SMSC95xx MAC on MBa6x REV.0200 on startup │ │ │ │ <*> spidev_test │ │ │ │ < > stm32flash │ │ │ │ <*> stress-ng │ │ │ │ <*> tq-systems-media │ │ │ │ < > collection of small examples (Qt5) │ │ │ │ --- ------------------------------------ │ │ │ │ Project Name & Version ---> │ │ │ │ --- --------- Host Options ------------- │ │ │ │ PTXdist Options ---> │ │ │ │ Host Tools ---> │ │ │ │ Cross Tools ---- │ │ │ │ Debug Tools ---> │ │ │ │ --- ------------------------------------ │ │ │ │ Root Filesystem ---> │ │ │ │ Core (libc, locales) ---> │ │ │ │ [ ] Core (initramfs) ---- │ │ │ │ --- ------------------------------------ │ │ │ │ Shell & Console Tools ---> │ │ │ └─────────────────────────┴(+)────────────────────────────────────────────────────────────────────────────────────────────┘ │ ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ <Select> < Exit > < Help > < Save > < Load > │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
To actually build the hello-world application you have to execute ptxdist go –git
2)
user@ubuntu-vm:~/workspace/TQMa6x-BSP-REV.0109$ ptxdist go --git
After that execute ptxdist images
to create a new SD/eMMC image with the “Hello, World!” application included.
user@ubuntu-vm:~/workspace/TQMa6x-BSP-REV.0109$ ptxdist images
Now you can boot the target using the newly created image and run the “Hello, World!” application:
root@MBa6x:~ hello-world Hello World, I'm hello-world!
ptxdist menuconfig
) of our BSP–git
is optional, however, it proves useful in certain situations