Problems to use rpmb partition


i am trying to use the rpmb partition on the R2 (/dev/mmcblk1rpmb) using mmc-tools. I am using Debian image 4.14.120.

I followed the example from the mmc-tools man page. Step 1, writing the key using the “mmc rpmb write-key” command works aparently ok, there is no error and exit code is 0.

Step 2, writing data to the rpmb with " mmc rpmb write-block" fails with error “RPMB read counter operation failed, retcode 0xe000” and exit code 1. The read-counter command fails with “RPMB operation failed, retcode 0xc4c2” and exit code 1. A “mmc rpmb read-block” returns a string of 0 bytes and exit code 0. I have tried the operations with both stdin/out as in the samples as well as using files for the key and data. Results are the same.

Do i need to perform some sort of initialisation other than wrting the key with “mmc rpmb write-key” to use the rpmb partition? What else may i do wrong?

Thanks a lot


Maybe you need to enable rw-mode like for bootx

echo 0 > /sys/block/mmcblk1boot0/force_ro

What do you try to write on that partition? Have you set a count of bytes to read? Please post full commands

Hello Frank

i would like to use the rpmb partition to store some persistent data (counters and identification) that should survive a complete reflash of the linux partion.

Enabling r/w mode did not help, i tried: echo 0 > /sys/block/mmcblk1rpmb/force_ro

I use the exact syntax as in the mmc documentation, only changed the device from /dev/mmcblk0rpmb to the correct /dev/mmcblk1rpmb

   Program authentication key from stdin:
          echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | mmc rpmb write-key /dev/mmcblk1rpmb -

   Write a block of 256 bytes of data to an rpmb device:
          $ (awk 'BEGIN {while (c++<256) printf "a"}' | echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH) | mmc rpmb
          write-block /dev/mmcblk1rpmb 0x02 - -

   Read a block of 256 bytes of data from an rpmb device to stdout:
            $ echo -n  AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH  |  mmc  rpmb  read-block  /dev/mmcblk1rpmb  0x02  2
          /tmp/block -

I also tried to use files for the key and data, the key is in the file rpbm.key (32 bytes) , the data in a the file (256 bytes). The commands are then:

/usr/bin/mmc rpmb write-key /dev/mmcblk1rpmb rpbm.key

/usr/bin/mmc rpmb write-block /dev/mmcblk1rpmb 0x02 rpbm.key

/usr/bin/mmc rpmb read-block /dev/mmcblk1rpmb 0x01 1 rpbm.output


P.S. the syntax for the write command in the man file is not correct for debian, this is ok:

awk ‘BEGIN {while (c++<256) printf “a”}’ | echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | mmc rpmb write-block /dev/mmcblk1rpmb 0x02 - -