Skip to content
This repository was archived by the owner on Sep 21, 2025. It is now read-only.

Creating Boot Images

linguini1 edited this page Oct 27, 2023 · 5 revisions

SD Card Setup

The SD card inserted into the Raspberry Pi 4 is the Pi's "hard disk" or long-term storage. The file system for the operating system will be located here, as well as the boot file system.

By default, the QNX file system will exist in RAM and disappear. We want a writable file system, which is why we need to partition the SD card into a boot partition and file system partition.

At the time of writing the CUInSpace design bay has an Ubuntu machine which can be used to run the partitioning tool, fdisk. If you know how to follow the below partitioning steps using another tool, you may do so. Otherwise, there are other ways to access fdisk, such as using Windows Subsystem for Linux.

  1. Plug the SD card into the computer.
  2. Identify the name of the SD card assigned by Linux by running the lsblk command. It will likely be something like sda. The rest of the steps will assume that name. Be sure to verify the name by running lsblk before and after the SD card is plugged in.
  3. Run fdisk /dev/sda. You made need to use sudo.
  4. Press d and Enter repeatedly until fdisk tells you that all partitions are deleted.
  5. Press u to change the size to cylinders.
  6. Press o to create a new disk label.
  7. Press n to make a new partition and select p for primary. It will be partition 1.
  8. Hit enter to use the default start cylinder.
  9. Put enough cylinders after to be about 50MB (1000~ to be safe).
  10. Press a to mark partition 1 as bootable.
  11. Press t to set the type of the partition as W95 FAT32. This will be hex code c.
  12. Press n to create another new partition. Select p for primary. It will be partition 2.
  13. Hit enter to use the default start cylinder.
  14. Hit enter to give partition 2 all the remaining cylinder space. The type of partition 2 will be Linux (hex code 83).
  15. sudo mkfs.vfat /dev/sda1 will format the boot partition to FAT32.
  16. sudo mkfs.ext2 /dev/sda2 will format the second partition to be Linux.

You can now remove the SD card!

Creating the Image

Make sure you've followed the instructions in Installing QNX Development Tools before attempting this. You will also need to install the wireless driver mentioned in that guide.

You will need:

  • TTL USB Cable
  • Ethernet Cable
  • Raspberry Pi 4 Model B
  • Raspberry Pi power cord

First follow the instructions listed in Research Computing Service's Video, but don't upload files onto the Pi's SD card yet.

You'll need these files mentioned in the video:

Grab the rpi4.build file from the qnx-guide repository and put it into the qnx710/bsp/images directory to overwrite the previous build file. If you haven't already, you'll need to unzip the BSP package for this.

  1. Launch the QNX Momentics IDE.
  2. Select File > Import > QNX > QNX Source Package and BSP, then click Next.
  3. Select the qnx710\bsp folder you unzipped before.
  4. Once it opens in the Project Explorer along the lefthand side, right click the project (top-level directory) and select Clean Project.
  5. Once that completes (see status near the bottom in the console), right click again and select Build Project. There should not be any build errors.
  6. Once the project is built, you will follow the last steps of the video (copying files to the SD card).
  7. You will copy over all the files in qnx710/bsp/images/tools/sdboot_images, as well as the ifs-rpi4.bin file in your Momentics IDE workspace.
  8. As in the video, eject the SD card and put it in the Pi.
  9. Connect the TTL USB to the correct pins.
  10. List the currently connected serial device using py -m serial.tools.list_ports (python3 -m ... for Linux).
  11. Open a connection to the Pi using py -m serial.tools.miniterm <port> 115200.

You should see QNX boot up, and there will be a message Starting WIFI Network driver... with no errors. You can check if the Pi connected to WiFi correctly using ifconfig and checking for an IP address under the bcm0 entry. Note that the Pi will only connect to networks that are configured in the build file under the "WPA Supplicant configuration" heading.

Setting Up SSH on a New Image

The build file created by CUInSpace contains a script to automatically start the SSH daemon using sshd. This script is located on the PATH, so you will only need to run start_ssh.sh from your shell on the Pi.

This command will prompt you to generate an RSA SSH key if ssh_host_rsa_key isn't already present in /etc/ssh/. Please run the command you are prompted with to generate the key, and then attempt to run the SSH server again.

To learn more about the OpenSSH Daemon on QNX, please take a look at the QNX provided guide.

Clone this wiki locally