psa_ps_set() returning -135 ERROR

Hi,

I need to create partition of size 4kb but using psa_ps_set() I could not able create partition of size more than 1Kb, If I try to create 4 kb Partition it's throwing -135 error 

I am working in TFM application

here providing you snippet of our pm_static.yml file

could you please help me to resolve the issue ASAP

####################################################################################################
# NOTE: Any partition size should be aligned with the SPU secure block size 0x4000
####################################################################################################

b0:
  address: 0x0
  end_address: 0x8000
  placement:
    after:
    - start
  region: flash_primary
  size: 0x8000
b0_container:
  address: 0x0
  end_address: 0x8000
  orig_span: &id002
  - b0
  region: flash_primary
  size: 0x8000
  span: *id002
s0:
  address: 0x8000
  end_address: 0x14000
  orig_span: &id006
  - s0_pad
  - mcuboot
  region: flash_primary
  size: 0xc000
  span: *id006
s0_pad:
  address: 0x8000
  end_address: 0x8200
  placement:
    after:
    - b0_container
    align:
      start: 0x4000
  region: flash_primary
  share_size:
  - mcuboot_pad
  size: 0x200
s0_image:
  address: 0x8200
  end_address: 0x14000
  orig_span: &id007
  - mcuboot
  region: flash_primary
  size: 0xbe00
  span: *id007
mcuboot:
  address: 0x8200
  end_address: 0x14000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  sharers: 0x1
  size: 0xbe00
s1:
  address: 0x14000
  end_address: 0x20000
  orig_span: &id008
  - s1_pad
  - s1_image
  region: flash_primary
  size: 0xc000
  span: *id008
s1_pad:
  address: 0x14000
  end_address: 0x14200
  placement:
    after:
    - s0
    align:
      start: 0x4000
  region: flash_primary
  share_size:
  - mcuboot_pad
  size: 0x200
s1_image:
  address: 0x14200
  end_address: 0x20000
  placement:
    after:
    - s1_pad
    - s0
  region: flash_primary
  share_size:
  - mcuboot
  size: 0xbe00
mcuboot_primary:
  address: 0x20000
  end_address: 0x94000
  orig_span: &id003
  - app
  - tfm
  - mcuboot_pad
  region: flash_primary
  sharers: 0x1
  size: 0x74000
  span: *id003
mcuboot_pad:
  address: 0x20000
  end_address: 0x20200
  placement:
    align:
      start: 0x4000
    before:
    - mcuboot_primary_app
  region: flash_primary
  sharers: 0x2
  size: 0x200
mcuboot_primary_app:
  address: 0x20200
  end_address: 0x94000
  orig_span: &id004
  - app
  - tfm
  region: flash_primary
  size: 0x73e00
  span: *id004
app_image:
  address: 0x20200
  end_address: 0x94000
  orig_span: &id001
  - tfm
  - app
  region: flash_primary
  size: 0x73e00
  span: *id001
tfm_secure:
  address: 0x20000
  end_address: 0x50000
  orig_span: &id012
  - mcuboot_pad
  - tfm
  region: flash_primary
  size: 0x30000
  span: *id012
tfm:
  address: 0x20200
  end_address: 0x50000
  inside:
  - mcuboot_primary_app
  placement:
    before:
    - app
  region: flash_primary
  size: 0x2fe00
tfm_nonsecure:
  address: 0x50000
  end_address: 0x94000
  orig_span: &id011
  - app
  region: flash_primary
  size: 0x44000
  span: *id011
app:
  address: 0x50000
  end_address: 0x88000
  region: flash_primary
  size: 0x38000
tfm_storage:
  address: 0x88000
  end_address: 0x94000
  orig_span: &id013
  - tfm_ps
  - tfm_its
  - tfm_otp_nv_counters
  region: flash_primary
  size: 0xc000
  span: *id013
tfm_its:
  address: 0x88000
  end_address: 0x8a000
  inside:
  - tfm_storage
  placement:
    before:
    - tfm_otp_nv_counters
  region: flash_primary
  size: 0x2000
tfm_otp_nv_counters:
  address: 0x8a000
  end_address: 0x8c000
  inside:
  - tfm_storage
  placement:
    before:
    - tfm_ps
  region: flash_primary
  size: 0x2000
tfm_ps:
  address: 0x8c000
  end_address: 0x94000
  inside:
  - tfm_storage
  placement:
    before:
    - end
  region: flash_primary
  size: 0x8000
mcuboot_secondary:
  address: 0x94000
  end_address: 0x100000
  placement:
    after:
    - mcuboot_primary
    align:
      start: 0x4000
    align_next: 0x4000
  region: flash_primary
  share_size:
  - mcuboot_primary
  size: 0x6c000

mcuboot_sram:
  address: 0x20000000
  end_address: 0x20020000
  orig_span: &id005
  - tfm_sram
  region: sram_primary
  size: 0x20000
  span: *id005
sram_secure:
  address: 0x20000000
  end_address: 0x20040000
  orig_span: &id010
  - tfm_sram
  region: sram_primary
  size: 0x40000
  span: *id010
tfm_sram:
  address: 0x20000000
  end_address: 0x20040000
  inside:
  - sram_secure
  placement:
    after:
    - start
  region: sram_primary
  size: 0x40000
sram_nonsecure:
  address: 0x20040000
  end_address: 0x20080000
  orig_span: &id009
  - sram_primary
  - rpmsg_nrf53_sram
  region: sram_primary
  size: 0x40000
  span: *id009
sram_primary:
  address: 0x20040000
  end_address: 0x20070000
  region: sram_primary
  size: 0x30000
rpmsg_nrf53_sram:
  address: 0x20070000
  end_address: 0x20080000
  placement:
    before:
    - end
  region: sram_primary
  size: 0x10000

Parents Reply
  •   for your reference i am sending snippet if you find any mistake let me know

    #define RESP_INFO_BUF_SZ = 4096
    psa_storage_uid_t uid2 = UID_RESPONSE_INFO_DATABASE;
    	psa_storage_create_flags_t uid2_flag = PSA_STORAGE_FLAG_NONE;
        psa_status_t status = PSA_ERROR_DOES_NOT_EXIST;
        size_t read_len = 0;
        
    typedef union {
        uint8_t buf[RESP_INFO_BUF_SZ];
        uint16_t len;
    
    } response_info_t;
    
    response_info_t response_info;
    
    memset((uint8_t *)&response_info, 0, sizeof(response_info));	
    for(uint8_t off = 0; off < 100; off++){
                response_info.buf[off] = off;
    }
    
    status = psa_ps_set(uid2,  sizeof(response_info), (uint8_t *)&response_info, uid2_flag);
    
    if (status != PSA_SUCCESS) {
             return APP_INIT_ERROR;
    }

Children
  • Hi,

    Here you are calling psa_ps_set() with an asset which is too large and cannot work. I suggest you split it in two.

    Another unrelated issue is the union you have of buf and len (response_info_t). Note that in C, all members of the union are in the same address space, so it is difficult to see what the intention here was. Perhaps this should have been a struct?

  • Before i tried with struct i changed that to union due to size issue, what you exactly mean by spliting do i need to split buffer or have other partition of 2 KB

  • Hi,

    RAGHAV_M said:
    Before i tried with struct i changed that to union due to size issue

    I see. Union is not what you want here. It has it's uses in C, but not here.

    RAGHAV_M said:
    what you exactly mean by spliting do i need to split buffer or have other partition of 2 KB

    The maximum size you can write is 4024 byte. So if you need to write more (like 4096), you need to split that in two (or more) chunks. So for instance, that could be one 4024 buffer and the remaining 72 bytes in another buffer, or y ou can split in a different way. The main thing is that you cannot store an asset larger than 4024 bytes. If this is difficult, what about just making two 2048 byte buffers and memcypy into thouse, and store those? Then when you read the two buffers, you can memcpy into a larger buffer again if needed.

    Note that in order to be able to store 4024 you need to allocate some larger buffers in TF-M, using CONFIG_TFM_CRYPTO_IOVEC_BUFFER_SIZE. So when I tested, I used these additional configs:

    CONFIG_TFM_PS_MAX_ASSET_SIZE=4024
    CONFIG_TFM_CRYPTO_IOVEC_BUFFER_SIZE=16384

Related