QNX on Raspberry Pi - Unable to mount SD card partition

Hi,

I’m running QNX 7.1 on the Raspberry Pi 4B (BSP_raspberrypi-bcm2711-rpi4_br-710_be-710_SVN946248_JBN18) from an SD card. I can see the Internal File System and the SD card file systems as shown below.

# df -h -P
Filesystem                  Size      Used Available Capacity  Mounted on
ifs                          22M       22M         0     100%  /
/dev/sd0                     30G       30G         0     100%

However, I’m unable to mount an SD card partition and enable read/write to the filesystem (mkdir doesn’t work in ifs). These are the commands I used with the console output:

1. Create a FAT32 partition

# fdisk /dev/sd0 add -t 12
# fdisk /dev/sd0 show

     _____OS_____     Start      End     ______Number______   Size    Boot
     name    type    Cylinder  Cylinder  Cylinders   Blocks

1.   FAT32     12          0      30527     30528    62521312  30527 MB
2.   ------   ---   --------   --------   -------  --------  -----
3.   ------   ---   --------   --------   -------  --------  -----
4.   ------   ---   --------   --------   -------  --------  -----

2. Enumerate the partitions

# mount -e /dev/sd0
# ls /dev/sd0
/dev/sd0       /dev/sd0t12
# df -h -P
Filesystem                  Size      Used Available Capacity  Mounted on
ifs                          22M       22M         0     100%  /
/dev/sd0                     30G       30G         0     100%  /dev/sd0t12
/dev/sd0                     30G       30G         0     100%

3. Mount the partition

# mount -t dos /dev/sd0t12 /sd0
# ls /sd0
ls: Corrupted file system detected (/sd0)

It errors out with corrupted file system detected when accessing the mount point. Am I missing any steps here?

Thanks for the help!

You forgot to format the partition :

mkdosfs /dev/sd0t12

You might nee to refresh the partitions after partitioning and before formatting :

mount -e /dev/sd0

Thanks for the response.

I tried formatting using mkdosfs /dev/sd0t12 but the command froze for a couple of hours without completion and I had to kill it with Ctrl+C. I’m assuming it should not take that long to format the partition.

Shouldn’t adding the partition with fdisk /dev/sd0 add -t 12 already format it for the correct type? Is there any other command I can use rather than mkdosfs if that keeps hanging?

Shouldn’t adding the partition with fdisk /dev/sd0 add -t 12 already format it for the correct type?

No, Partitioning and formatting are two different actions.

Here are the steps I use when initializing a SDcard :

echo Unmounting device
umount -f /dev/sd0

echo Cleaning device partition
fdisk /dev/sd0 delete -a

echo Creating device partition
fdisk /dev/sd0 add -t 12

echo Enumerate device
mount -e /dev/sd0

echo Formating device
mkdosfs  /dev/sd0t12

echo Mounting partition
mount -t dos /dev/sd0t12 /sdcard

echo Checking device
chkdosfs /dev/sd0t12

Why not just format the SD card under Windows or Linux if you are just using it as FAT32. You don’t need QNX to format FAT32.

It takes a lot longer than expected to format large drives under QNX. I think it’s a lot of error checking. I know on our systems that we use hard drives and these days they all come in terrabyte sizes and if we format the whole drive it takes a LONG time so we always partition into a small chunk (3-4 gigs) since that’s all we use anyway.

Tim

Thanks for your replies @Tim @nico04 .

I did try formatting the SD card to FAT32 under Windows but after booting to QNX, I did not see any partitions in the partition table.

# df -h -P
Filesystem                  Size      Used Available Capacity  Mounted on
ifs                          22M       22M         0     100%  /
/dev/sd0                     30G       30G         0     100%
# mount -e /dev/sd0
# fdisk /dev/sd0 show

     _____OS_____     Start      End     ______Number______   Size    Boot
     name    type    Cylinder  Cylinder  Cylinders   Blocks

1.   ------   ---   --------   --------   -------  --------  -----
2.   ------   ---   --------   --------   -------  --------  -----
3.   ------   ---   --------   --------   -------  --------  -----
4.   ------   ---   --------   --------   -------  --------  -----

I get the same problem even when I create more than one FAT32 partition in Windows. The partition table for the SD card in QNX still contains no entries. If I transfer the SD card back to the Windows host, I’m able to see the formatted FAT32 partition(s) again. Am I missing something here?

It should also be noted that I’m copying the BSP and required firmware files to the FAT32 partition on the SD card and booting QNX from there. Can this possibly affect the FAT32 partition on the filesystem after booting into QNX?

On my targets, I use QNX 6.6.0, not QNX 7.1 but this should not make any difference.

My targets also boots from the SDcard.
There is a FAT16 partition for the OS (IFS file) and a QNX6 partition for data storage (PPS persistence files, database files…). There is also a reserved area for the IPL.

The boot sequence is : The µP loads the IPL content which itself loads the IFS (from FAT16 partition) which itself boots QNX.

Is your device driver correctly configured (pin muxing, I/O address, interrupt…) ?

Here is the command I use for one of the SDcard interfaces of my targets :
devb-sdmmc-mx6_generic dos sfn=windows disk name=hd_sd_usr_u cam pnp,verbose sdio addr=0x02190000,irq=54,bs=cd_base=0x0209c000:cd_pin=1:cd_irq=161 blk rw,cache=2M,automount=hd_sd_usr_u0@dos:/mnt/sdhc-user-up

Note : My targets have 3 SDcard interfaces. One for system (embedded µSD) and 2 for user data (externally accessible SD).

I’ve honestly don’t recall ever using or needing ‘mount -e’ option. I wonder if running it is confusing things.

At this point below, everything looks fine since you can see /dev/sd0.

# df -h -P
Filesystem                  Size      Used Available Capacity  Mounted on
ifs                          22M       22M         0     100%  /
/dev/sd0                     30G       30G         0     100%

Since you know it’s already formatted FAT32 from windows, you should be able to mount it directly now via the the command you were doing in your 1st post.

mount -t dos /dev/sd0t12 /sd0

Tim

I was not starting the SD card driver prior to enumerating and mounting it. I get the following error when running the driver:

# devb-sdmmc-bcm2711
# xpt_configure:  sdmmc SIM attach failure

I’m assuming this is because I’m not specifying the required options for the SD card interface on the Raspberry Pi 4B. How can I find the correct options that are required for this target device?

Use the PCI utilities

‘pci -v’
‘pci-tool’

Note, QNX requires legacy boot options in the BIOS (not sure what the your board has) as it doesn’t support UEFI (unless something changed really recently).

Tim

I hope I can help a bit.

  1. Unless you need a DOS partition, I would try mkqnx6fs.
  2. The issue with formatting on Windows might have to do with the type of partition table. I’m not sure if QNX has move beyond the old IBM-PC BIOS version, though I know there is supposed to be support for UEFI. I’ve not been able to get it to work.
  3. Running “mount -e” to enumeriate is always needed, but not necessarily manually. There are driver parameters that will cause it to happen automatically as well as mounting the partition into the file system. You would have to look up the docs as I am unfamiliar with the details.

Thanks for the response @maschoen.

mkqnx6fs command hangs as well. I tried formatting a small 128 MB QNX6 partition (created with fdisk /dev/sd0 add -t 177 -c 0,128) and it still didn’t get to completion.

I think the DOS partition formatted on Windows is not detected in QNX since I’m unable to initialize the SD card driver correctly as @nico04 suggested.

# devb-sdmmc-bcm2711
# xpt_configure:  sdmmc SIM attach failure

I’m assuming this is because I’m not specifying any options when running the driver. How can I find the target specific options required to initialize the SD card driver for the Raspberry Pi 4B?

If both formatting programs hang, you probably have a hardware or driver problem.

Can’t you find the information in the reference BSP delivered by QNX ?
image