Tuesday, April 29, 2025

Running QNX on emulated cortex-a15 using QEMU

Running QNX on emulated cortex-a15 using QEMU

General information:
- Host (for running QEMU) OS: Ubuntu 24.04.2 LTS
- QEMU: QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.6)
- QNX 6.5 SP1 on Windows 10 LTSC

Build minimal QNX Image File System (IFS) on Windows 10

Checkout bsp-qnx65-qemu-virt-a15 and build on Windows 10 with QNX 6.5 SP1
C:\prj>git clone https://github.com/myQNX/bsp-qnx65-qemu-virt-a15.git
C:\prj>cd bsp-qnx65-qemu-virt-a15
C:\prj\bsp-qnx65-qemu-virt-a15>make
This will generate, among many other things, "C:\prj\bsp-qnx65-qemu-virt-a15\images\bsp-qemu-virt.bin"

Build u-boot that supports virtualized Cortex-A15 machine on Ubuntu 24.04
Install dependencies
$ sudo apt update
$ sudo apt install build-essential gcc-arm-linux-gnueabihf flex bison libssl-dev device-tree-compiler qemu-system-arm libgnutls28-dev
Get U-Boot source and checkout latest stable. As of this writing, the latest is v2025.04
$ git clone https://source.denx.de/u-boot/u-boot.git
$ cd u-boot
$ git checkout v2025.04
Set cross compiler
$ export CROSS_COMPILE=arm-linux-gnueabihf-
Confirm cross compiler
$ ${CROSS_COMPILE}gcc --version
My machine shows
arm-linux-gnueabihf-gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Configure U-Boot for virt
$ make qemu_arm_defconfig
This will generate .config in u-boot git repo root.
Edit .config
u1@m1:~/u-boot$ nvim .config
Add a line of CONFIG_BOOTCOMMAND
CONFIG_BOOTCOMMAND="virtio scan; fatload virtio 0:1 0x40200000 bsp-qemu-virt.bin; go 0x40200000"
Modify CONFIG_BOOTDELAY to zero, default is 2. This loads QNX directly without delay.
CONFIG_BOOTDELAY=0
Save .config and quit your editor. Below is my Github gist for .config, see line 414 for the CONFIG_BOOTDELAY and line 437 for CONFIG_BOOTCOMMAND Then do a build
u1@m1:~/u-boot$ make -j$(nproc)
Create a VM files to be used by QEMU
u1@m1:~/u-boot$ mkdir -p ~/vmtest/images
u1@m1:~/u-boot$ cp u-boot.bin ~/vmtest/images
Copy "C:\prj\bsp-qnx65-qemu-virt-a15\images\bsp-qemu-virt.bin" from Windows 10 to ~/vmtest/images/bsp-qemu-virt.bin
~/vmtest/images should have files like below -
u1@m1:~/vmtest$ ls images
bsp-qemu-virt.bin  u-boot.bin
Run it
u1@m1:~/vmtest$ qemu-system-arm -M virt -m 256 -cpu cortex-a15 -bios ./images/u-boot.bin -hda fat:rw:./images -vga none -serial mon:stdio -nographic
Mines shows something like below-
u1@m1:~/vmtest$ qemu-system-arm -M virt -m 256 -cpu cortex-a7 -bios ./images/u-boot.bin -hda fat:rw:./images -vga none -serial mon:stdio -nographi
c
WARNING: Image format was not specified for 'json:{"fat-type": 0, "dir": "./images", "driver": "vvfat", "floppy": false, "rw": true, "write-target": {"driver"
: "qcow", "file": {"driver": "file", "filename": "/var/tmp/vl.TH4052"}}}' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
Bloblist at 0 not found (err=-2)
alloc space exhausted ptr 400 limit 0
Bloblist at 0 not found (err=-2)


U-Boot 2025.04 (Apr 29 2025 - 12:45:47 -0500)

DRAM:  256 MiB
using memory 0x4e69b000-0x4f6db000 for malloc()
Core:  51 devices, 14 uclasses, devicetree: board
Flash: 64 MiB
Loading Environment from Flash... *** Warning - bad CRC, using default environment

In:    serial,usbkbd
Out:   serial,vidconsole
Err:   serial,vidconsole
No USB controllers found
Net:   eth0: virtio-net#32

starting USB...
No USB controllers found
Net:   eth0: virtio-net#32

starting USB...
No USB controllers found
Hit any key to stop autoboot:  0
2700652 bytes read in 4 ms (643.9 MiB/s)
## Starting application at 0x40200000 ...
CPUID=1091551349 ;
> init_intrinfo:
> init_cacheattr:
> init_cpuinfo:
CPUID=1091551349 ;
CPU0: L1 Icache: 512x64
CPU0: L1 Dcache: 512x64 WB
CPU0: L2 Dcache: 36864x64 WB
CPU0: VFP-d32 FPSID=41023075
CPU0: NEON MVFR0=10110222 MVFR1=11111111
CPU0: 410fc075: Cortex A7 rev 5 500MHz
init_hwinfo:Loading IFS...done
elf_map: 1M va=fe000000 pa=40200000 sz=00100000
elf_map: 1M va=fe000000 pa=40200000 sz=00100000
Header size=0x0000009c, Total Size=0x000005d0, #Cpu=1, Type=4
Section:system_private offset:0x000001f0 size:0x00000068
  syspage ptr user:fc404000 kernel:fc404000
  cpupage ptr user:fc404948 kernel:fc404948 spacing:84
  kdebug info:00000000 callback:00000000
  boot pgms: idx=0
    0) base paddr:40211000 start addr:fe043024
  ramsize:00000000 pagesize:00001000
Section:qtime offset:0x00000148 size:0x00000060
  boot:00000000 CPS:00000000016e3600 rate/scale:83333333/-15 intr:1
  flags:00000001 load:0 epoch:1970 rr_mul:0 adj count/inc:0/0
Section:callout offset:0x000000a0 size:0x00000048
  reboot:00000000 power:fc4047ec
  timer_load:fc40480c reload:fc404834 value:fc404850
  0) display:fc404868 poll:fc40488c break:fc4048b0
  1) display:00000000 poll:00000000 break:00000000
Section:cpuinfo offset:0x000001a8 size:0x00000020
  0) cpu:410fc075 flags:c0000076 speed:000001f4 cache i/d:0/1 name:72
Section:cacheattr offset:0x00000590 size:0x00000040
  0) flags:01 size:0040 #lines:0200 control:fc4045d8 next:255
  1) flags:22 size:0040 #lines:0200 control:fc404638 next:255
Section:meminfo offset:0x000005d0 size:0x00000000
Section:asinfo offset:0x00000330 size:0x00000220
  0000) 0000000000000000-00000000ffffffff o:ffff a:0010 p:100 c:00000000 n:21
  0020) 0000000000000000-00000000ffffffff o:0000 a:0010 p:100 c:00000000 n:28
  0040) 0000000048000000-0000000048ffffff o:0000 a:0013 p:100 c:00000000 n:36
  0060) 0000000048000000-0000000048ffffff o:0040 a:0013 p:100 c:00000000 n:44
  0080) 0000000040000000-0000000047ffffff o:0020 a:0037 p:100 c:00000000 n:47
  00a0) 0000000048000000-0000000048ffffff o:0060 a:0037 p:100 c:00000000 n:47
  00c0) 0000000049000000-000000004fffffff o:0020 a:0017 p:100 c:00000000 n:47
  00e0) 0000000000000000-00000000ffffffff o:ffff a:0010 p:100 c:00000000 n:21
  0100) 0000000040000000-0000000047ffffff o:00e0 a:0007 p:100 c:00000000 n:51
  0120) 0000000040210110-000000004049356b o:0000 a:0005 p:100 c:00000000 n:82
  0140) 0000000040200008-000000004021010f o:0000 a:0007 p:100 c:00000000 n:90
  0160) 0000000040210110-000000004049356b o:0000 a:0007 p:100 c:00000000 n:98
  0180) 0000000040000000-0000000040007fff o:0080 a:0007 p:100 c:00000000 n:106
  01a0) 000000004001099c-0000000040200007 o:0080 a:0007 p:100 c:00000000 n:106
  01c0) 000000004049356c-0000000047ffffff o:0080 a:0027 p:100 c:00000000 n:106
  01e0) 0000000048000000-0000000048ffffff o:00a0 a:0027 p:100 c:00000000 n:106
  0200) 0000000049000000-000000004fffffff o:00c0 a:0007 p:100 c:00000000 n:106
Section:hwinfo offset:0x000002e8 size:0x00000048
  0) size:3 tag:3(Group) isize:3, iname:0(hw), owner:65535, kids:1
  12) size:3 tag:17(Bus) isize:3, iname:9(unknown), owner:0, kids:1
  24) size:3 tag:3(Group) isize:3, iname:56(rtc), owner:12, kids:1
  36) size:4 tag:65(Device) isize:4, iname:60(NONE), owner:24, kids:0
     00 00 00 00
Section:typed_strings offset:0x00000258 size:0x00000018
  off:0 type:2 string:'localhost'
Section:strings offset:0x00000270 size:0x00000078
  [0]'hw' [3]'Group' [9]'unknown' [17]'Bus' [21]'memory' [28]'below4G'
  [36]'L4-Ctrl' [44]'io' [47]'ram' [51]'1to1' [56]'rtc' [60]'NONE' [65]'Device'
  [72]'Cortex A7' [82]'imagefs' [90]'startup' [98]'bootram' [106]'sysram'
Section:intrinfo offset:0x00000550 size:0x00000040
  0) vector_base:00000000, #vectors:160, cascade_vector:7fffffff
     cpu_intr_base:00000000, cpu_intr_stride:0, flags:0000
      id => flags:8000, size:005c, rtn:fc4046dc
     eoi => flags:9000, size:003c, rtn:fc404738
     mask:fc404774, unmask:fc4047a8, config:fc4047dc
Section:smp offset:0x000005d0 size:0x00000000
Section:pminfo offset:0x000005d0 size:0x00000000
Section:mdriver offset:0x000005d0 size:0x00000000
Section:boxinfo offset:0x000001c8 size:0x00000028
  hw_flags:00000000
Section:cpu offset:0x00000128 size:0x00000020
  page_flush:fc404688 page_flush_deferred:fc4046d8
  upte_ro:00000e6e upte_rw:00000c7e
  kpte_ro:0000065e kpte_rw:0000045e
  mask_nc:000001cc
  mmu_cr1:00c51870 set:00803c7f clr:00000000 -> 00c53c7f

System page at phys:40010000 user:fc404000 kern:fc404000
Starting next program at vfe043024
cpu_startnext: cpu0 -> fe043024
vstart: 1075845408
flags:1VFPv3: fpsid=41023075
coproc_attach(10): replacing fe05a8b4 with fe06826c
coproc_attach(11): replacing fe05a8b4 with fe06826c
Welcome to QNX Neutrino 6.5.0 on the QEMU ARMv7 virt
Serial opened...
#

No comments:

Fedora install screen chronicle

Fedora install screen chronicle Below are links to Fedora installation screens. It is interesting to see how it has evolved over time. Fe...