Apalis imx6q - extra partitions

I’m trying to change the default layout of apalis imx6q partitions to what you can see below:


#    0                      -> IMAGE_ROOTFS_ALIGNMENT         - reserved (not partitioned)
#    IMAGE_ROOTFS_ALIGNMENT -> BOOT_SPACE                     - u-boot + u-boot env
#    BOOT_SPACE             -> ROOTFS_A_SIZE                  - rootfs + kernel + dtb (A)
#    ROOTFS_A_SIZE          -> ROOTFS_B_SIZE                  - rootfs + kernel + dtb (B)
#    ROOTFS_B_SIZE          -> RESTORE_SIZE                   - persistent "restore" partition
#    RESTORE_SIZE           -> DATA_SIZE                      - persistent data partition
#
#            4MiB               16MiB          512MiB         512MiB         100MiB        Rest
# <-----------------------> <----------> <---------------> <---------------> <--------------> <------------>
#  ------------------------ ------------ -----------------------------------------------------------
# | IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE |  ROOTFS_A_SIZE  |  ROOTFS_B_SIZE  |  RESTORE_SIZE  |  DATA_SIZE  |
#  ------------------------ ------------ -----------------------------------------------------------
# ^                        ^            ^                 ^                 ^                ^             ^
# |                        |            |                 |                 |                |             |
# 0                      4MiB    4MiB + 16MiB    20MiB + 512MiB   532MiB + 512MiB   1044MiB + 100MiB     EMMC_SIZE

Unfortunately if I’m unable to add any new partitions.

At the beginning I tried to only add one new “persistent data” partition. It seemed to work, but after executing run setupdate and run update in u-boot and then restarting the device I got the Kernel Panic ( [ 3.438726 ] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,10) ).

Is that possible to change the partition layout on the board?

If so- how can I achieve that?

Hi

If I count correctly you did define 5 partitions. Since with the MBR partitioning only 4 primary partitions can be created you likely had to use ‘extended partitioning’.
That may or may not have moved the partition numbering around, so that you now have to change the root=/dev/mmcblk0p2 parameter in emmcargs to whatever the new device name for the rootfs is.

Additionally you might have run in to this problem depending on how you did use the extended partitioning. I expect that having the first three partitions as primary partition gives numbers them mmcblk0p[1-3], then having the 4th primary partition as the extended partition container with partition 4 & 5 would give them numbers mmcblk0p[5-6] and thus stay within the limits of 8.
Alternatively you could change the kernel config MMC_BLOCK_MINORS to a number bigger than 8.

Max

Hi @max.tx,

Thanks for responding.
The issue is that it happened also when I have created only one extra primary partition. But let’s focus on the 5 partitions setup.

I’m using latest toradex yocto branches (now it is morty), I’m building angstrom-lxde-image and I have changed the file meta-toradex-demos/recipes-images/images/files/library/imx6/update.sh (I know I should put it into separate layer- I’ll do it later when it is working).

The code of changed update.sh is following:

# Boot partition [in sectors of 512]
BOOT_START=$(expr 1024 \* 4 \* 2)
# Rootfs partition [in sectors of 512]
ROOTFS_A_START=$(expr 1024 \* 20 \* 2)
ROOTFS_B_START=$(expr 1024 \* 532 \* 2)
RESTORE_START=$(expr 1024 \* 1044 \* 2)
DATA_START=$(expr 1024 \* 1144 \* 2)
# Boot partition volume id
BOOTDD_VOLUME_ID="boot"

echo ""
echo "Creating MBR file and do the partitioning"
# Initialize a sparse file
dd if=/dev/zero of=${BINARIES}/mbr.bin bs=512 count=0 seek=${EMMC_SIZE}
${PARTED} -s ${BINARIES}/mbr.bin mklabel msdos
${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary fat32 ${BOOT_START} $(expr ${ROOTFS_A_START} - 1 )
# the partition of rootfs+kernel+dtb A and B are greater than the fs size
# on the target the file systems are then grown to the full size of the partitions
${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary ext4 ${ROOTFS_A_START} $(expr ${ROOTFS_B_START} \- 1)
${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary ext4 ${ROOTFS_B_START} $(expr ${RESTORE_START} \- 1)
${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart extended ${RESTORE_START} $(expr ${EMMC_SIZE} \- 1)
${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart logical $(expr ${RESTORE_START} \+ 1) $(expr ${DATA_START} \- 1)
${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart logical $(expr ${DATA_START} \+ 1) $(expr ${EMMC_SIZE} \- 1)
#${PARTED} -s ${BINARIES}/mbr.bin set 1 boot on
${PARTED} -s ${BINARIES}/mbr.bin unit GiB print

# the partition spans to the end of the disk, even though the fs size will be smaller
# on the target the fs is then grown to the full size
${PARTED} -s ${BINARIES}/mbr.bin unit s print 
# get the size of the VFAT partition
BOOT_BLOCKS=$(LC_ALL=C ${PARTED} -s ${BINARIES}/mbr.bin unit b print \
	| awk '/ 1 / { print int(substr($4, 1, length($4 -1)) / 1024) }')
## now crop the file to only the MBR size
IMG_SIZE=512
truncate -s $IMG_SIZE ${BINARIES}/mbr.bin

Now with this I was able to create an SD card needed for update and perform run setupdate and run update, but after that during boot I get the following error:

[    3.202083 ] EXT4-fs (mmcblk0p2): bad geometry: block count 146688 exceeds size of device (131072 blocks)
[    3.215488 ] List of all partitions:
[    3.222780 ] 0100           65536 ram0  (driver?)
(.. here some linex are cut out ..)
[    3.344589 ] 010f           65536 ram15  (driver?)
[    3.352439 ] b300         7643136 mmcblk1  driver: mmcblk
[    3.360886 ]   b301         7642112 mmcblk1p1 0dffdf73-01
[    3.369324 ] b308         3817472 mmcblk0  driver: mmcblk
[    3.377757 ]   b309           16384 mmcblk0p1 d901a873-01
[    3.386201 ]   b30a          524288 mmcblk0p2 d901a873-02
[    3.394652 ]   b30b          524288 mmcblk0p3 d901a873-03
[    3.403037 ]   b30c               1 mmcblk0p4
[    3.410394 ] b318            2048 mmcblk0boot1  (driver?)
[    3.418715 ] b310            2048 mmcblk0boot0  (driver?)
[    3.426982 ] No filesystem could mount root, tried:  ext4
[    3.435273 ] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,10)
[    3.446820 ] CPU1: stopping
[    3.452555 ] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.1.44-2.7.4+gb1555bf #1
[    3.462873 ] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[    3.472514 ] Backtrace:
[    3.478062 ] [<80012ec8>] (dump_backtrace) from [<800130e8>] (show_stack+0x18/0x1c)

Sorry for such a long logs.

Now there is a couple of problems/questions I have:

  1. Do I create the extended partition in the correct way? Somehow in the kernel log it does not show up (mmcblk0p4 - size 1?? and nothing more)
  2. Why do I get 2 more extra partitions mmcblk0boot0 and mmcblk0boot1? Can those be the problem?
  3. rootfs should be located in the same partition as it was before I have changed the layout (i.e. mmcblk0p2) so the bootup should not cause problems.

Do you know what may be an issue here?

  1. Do I create the extended partition in the correct way? Somehow in the kernel log it does not show up (mmcblk0p4 - size 1?? and nothing more)

We don’t know as we never actually tried it.

  1. Why do I get 2 more extra partitions mmcblk0boot0 and mmcblk0boot1? Can those be the problem?

No, those are the regular hardware area boot partitions containing the U-Boot boot loader, its environment and the Toradex factory configuration block (e.g. with MAC address resp. serial number).

  1. rootfs should be located in the same partition as it was before I have changed the layout (i.e. mmcblk0p2) so the bootup should not cause problems.

I don’t think so.

Do you know what may be an issue here?

Rather than changing those legacy update scripts I would recommend using the Toradex Easy Installer.