Pad memory to the alignment value?

Comments

1 comment

  • Avatar
    Craig McQueen

    I would like to do something like this too, in my case, pad the end of the file to a multiple of 16.

    I've managed to "nearly" achieve this by adding the following into the flash_placement.xml, at the end of the <MemorySegment name="$(FLASH_NAME:FLASH)" >:

     

       <ProgramSection alignment="0x10" load="Yes" keep="Yes" size="0" fill="0x00" name=".padding" />

     

    Then in my program, I added:

     

    const uint8_t file_padding[1] __attribute__ ((section(".padding"))) =
    {
        0x00,
    };

     

    However, this always results in an extra 16 bytes of zeros at the end, in addition to the minimal 0 to 15 bytes of padding that is strictly necessary.

    0
    Comment actions Permalink

Please sign in to leave a comment.