<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DM-Crypt with CAAM key Encrypted Filesystem Corrupt After Reboot in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1532434#M195975</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/206957"&gt;@nsleung&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've just followed up the guide to experiment it again. there is no such issue arise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There would be probably required tools missed liek "coreutils keyutils lvm2 e2fsprogs-mke2fs util-linux"" which states in&lt;/P&gt;
&lt;P&gt;section 8. Add required tools to build by editing conf/local.conf file and appending.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;Harvey&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2022 04:44:29 GMT</pubDate>
    <dc:creator>Harvey021</dc:creator>
    <dc:date>2022-10-05T04:44:29Z</dc:date>
    <item>
      <title>DM-Crypt with CAAM key Encrypted Filesystem Corrupt After Reboot</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1529848#M195760</link>
      <description>&lt;P&gt;Hello, I am using the iMX8M Mini SoC and am going through the app note (Rev 1 11/2020) Section 3.2 Usage (&lt;A href="https://www.mouser.com/pdfDocs/AN12714.pdf" target="_blank"&gt;https://www.mouser.com/pdfDocs/AN12714.pdf&lt;/A&gt;). Kernel version is 5.4.70. I am able to complete everything (create tagged key, dummy image, ext4 filesystem, encrypt using dmsetup target crypt, etc). However, after the reboot and following the steps to mount the encrypted image fails. This is what is shown:&lt;/P&gt;&lt;LI-CODE lang="c"&gt; sudo mount /dev/mapper/encrypted /mnt/encrypted/
mount: /mnt/encrypted: wrong fs type, bad option, bad superblock on /dev/mapper/encrypted, missing codepage or helper program, or other error.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;And when checking the integrity of the filesystem using fsck, it also reports bad superblock, leading me to believe something might be corrupted after rebooting.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;e2fsck /dev/mapper/encrypted
e2fsck 1.44.5 (15-Dec-2018)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/mapper/encrypted

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 &amp;lt;device&amp;gt;
 or
    e2fsck -b 32768 &amp;lt;device&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Any suggestions or thoughts would be appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 22:56:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1529848#M195760</guid>
      <dc:creator>nsleung</dc:creator>
      <dc:date>2022-09-28T22:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: DM-Crypt with CAAM key Encrypted Filesystem Corrupt After Reboot</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1532434#M195975</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/206957"&gt;@nsleung&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've just followed up the guide to experiment it again. there is no such issue arise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There would be probably required tools missed liek "coreutils keyutils lvm2 e2fsprogs-mke2fs util-linux"" which states in&lt;/P&gt;
&lt;P&gt;section 8. Add required tools to build by editing conf/local.conf file and appending.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;Harvey&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 04:44:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1532434#M195975</guid>
      <dc:creator>Harvey021</dc:creator>
      <dc:date>2022-10-05T04:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: DM-Crypt with CAAM key Encrypted Filesystem Corrupt After Reboot</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1535851#M196237</link>
      <description>&lt;P&gt;Thanks for the suggestion, I do have those additional utilities built in&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 21:44:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1535851#M196237</guid>
      <dc:creator>nsleung</dc:creator>
      <dc:date>2022-10-11T21:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: DM-Crypt with CAAM key Encrypted Filesystem Corrupt After Reboot</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1535969#M196249</link>
      <description>&lt;P&gt;Have you run caam-keygen import: # ./caam-keygen import /data/caam/randomkey.bb importKey&lt;/P&gt;
&lt;P&gt;before running: # cat /data/caam/importKey | keyctl padd logon logkey2: @s&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because this key has to be re-injected every time it is powered up&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;Harvey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 04:08:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1535969#M196249</guid>
      <dc:creator>Harvey021</dc:creator>
      <dc:date>2022-10-12T04:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: DM-Crypt with CAAM key Encrypted Filesystem Corrupt After Reboot</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1536419#M196280</link>
      <description>&lt;P&gt;Yes, I'm able to import the key and add to keyctl from blob after rebooting every time. I can also create the encrypted device mapper device using the same block device before the power cycle but when mounting, it will report 'corrupted filesystem'. Do I need to boot in Secure Mode? I don't believe I am doing that.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 17:34:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1536419#M196280</guid>
      <dc:creator>nsleung</dc:creator>
      <dc:date>2022-10-12T17:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: DM-Crypt with CAAM key Encrypted Filesystem Corrupt After Reboot</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1799951#M219524</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;SPAN&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/206957"&gt;@nsleung&lt;/a&gt;&amp;nbsp;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;were you ever able to solve the problem? I see the exact same issue when using CAAM+dmcrypt on a iMX8MP running Yocto kirkstone &amp;amp; kernel 5.15.x&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 13:36:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/1799951#M219524</guid>
      <dc:creator>lfant</dc:creator>
      <dc:date>2024-02-01T13:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: DM-Crypt with CAAM key Encrypted Filesystem Corrupt After Reboot</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/2316427#M243974</link>
      <description>&lt;P class=""&gt;Hi NXP team,&lt;/P&gt;&lt;P class=""&gt;We have an i.MX 8MP based device where a dm-crypt encrypted ext4 partition became unreadable after a power cycle. The exact same OS/image (same rootfs and provisioning process) is deployed across many devices, and those devices have definitely experienced power cycles without issue. We suspect a powerdown/up event may have triggered this failure on this particular device, but power cycling alone is not new in this fleet.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Unlock flow and exact commands:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# Only import key if keyhandle doesn't exist
if [ ! -f /tmp/keyhandle ]; then
    # Import key using CAAM
    caam-keygen import /uboot/black_blob.bb keyhandle

    # Add key to kernel keyring
    cat /tmp/keyhandle | keyctl padd logon logkey: @s
fi

# Create dm-crypt mapping
dmsetup -v create ${ENCRYPTED_NAME} --table "0 $(blockdev --getsz ${DEVICE}) crypt capi:tk(cbc(aes))-plain :36:logon:logkey: 0 ${DEVICE} 0 1 sector_size:512"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;What we see:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN class=""&gt;dmsetup&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;succeeds and mapping is ACTIVE&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;mount&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;fails with “wrong fs type / bad superblock”&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;dmesg&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;shows:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;EXT4-fs (dm-0): VFS: Can't find ext4 filesystem&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;e2fsck&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;reports invalid superblock (no valid ext2/3/4 found)&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P class=""&gt;We have verified the CAAM black blob on the device is still identical to what was flashed during manufacturing, so the key material itself does not appear to have changed. This makes us suspect either:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;encrypted partition corruption due to power loss, or&lt;/LI&gt;&lt;LI&gt;a subtle CAAM/dm-crypt/driver issue that only manifests after reboot or power loss.&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;STRONG&gt;Environment:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Linux 6.6.23 (Yocto-based)&lt;/LI&gt;&lt;LI&gt;i.MX 8MP platform using CAAM key import&lt;/LI&gt;&lt;LI&gt;dm-crypt mapping created with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;capi:tk(cbc(aes))-plain&lt;/SPAN&gt;, sector_size:512&lt;/LI&gt;&lt;LI&gt;ext4 filesystem&lt;/LI&gt;&lt;LI&gt;eMMC storage&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;STRONG&gt;Yocto layers / repo hashes used:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN class=""&gt;poky&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;02eacd385eca7aa9cf25aaaa61427aa9c126e0bc&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-openembedded&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;a72010b414ee3d73888ac9cb4e310e8f05e13aea&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-arm&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;8aa8a1f17f5b64bc691544f989f04fc83df98adb&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-security&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;11ea91192d43d7c2b0b95a93aa63ca7e73e38034&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-timesys&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;b96d8de949939ad08094f71ed6ed4f88eaf41d5e&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-virtualization&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;1a547c0aa0d75c4143cbb66de6e653d51cdc8bda&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-clang&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;66414c17ae60e489bef9a97031323e92c247fbe1&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-freescale&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;41b923e59e048b9b2942ff737a4ddac386954c62&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-freescale-3rdparty&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;8b61684f0b1ba8bacdf3a69d993445e9791d4932&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-freescale-distro&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;158cc55b6ee30d09957b380859dba52c0f6af68d&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-imx&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;239073c47124f41f46581871afbde643f48d6a3b&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;meta-nxp-security-reference-design&lt;/SPAN&gt;:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;15d4eccdc503ea07634b869af0df7e4e2917ebf1&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;STRONG&gt;Questions for NXP:&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Are there known issues with CAAM + dm-crypt (CBC-AES with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;capi:tk(cbc(aes))-plain&lt;/SPAN&gt;) that can cause irrecoverable filesystem corruption after reboot/power loss?&lt;/LI&gt;&lt;LI&gt;Are there newer drivers or recommended crypt schemes/configs for CAAM-backed dm-crypt on i.MX 8MP that are more robust?&lt;/LI&gt;&lt;LI&gt;Since this is eMMC, do you have any recommendations for write-reliability settings, dm-crypt block size, flush behavior, mount options, or other mitigation techniques to reduce the chance of corruption after power loss?&lt;/LI&gt;&lt;/OL&gt;&lt;P class=""&gt;If you need additional logs or details, I can provide them.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 11 Feb 2026 11:46:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/DM-Crypt-with-CAAM-key-Encrypted-Filesystem-Corrupt-After-Reboot/m-p/2316427#M243974</guid>
      <dc:creator>woow</dc:creator>
      <dc:date>2026-02-11T11:46:35Z</dc:date>
    </item>
  </channel>
</rss>

