/* Read data from an area on a Flash to data buffer in RAM */
int32_t hal_flash_read(hal_partition_t in_partition, uint32_t *off_set, void *out_buf, uint32_t in_buf_len)
/* Read data from an area on a Flash to data buffer in RAM */
int32_t hal_flash_read(hal_partition_t in_partition, uint32_t *off_set, void *out_buf, uint32_t in_buf_len)
{
    int32_t ret = 0;
    uint32_t start_addr;
    hal_logic_partition_t info;
    hal_partition_t operate_partition_id = 0;
    ENTER_FUNCTION();
    if (hal_flash_info_get(in_partition, &info) != 0) {
        TRACEME("hal_flash_info_get fail\n");
        ret = -1;
        goto RETURN;
    }
    start_addr = info.partition_start_addr + *off_set;
    operate_partition_id = bes_get_operate_partition(in_partition);
    ret = bes_hal_flash_read(operate_partition_id, start_addr, out_buf, in_buf_len);
    if(ret == 0) {
        *off_set += in_buf_len;
    }
RETURN:
    LEAVE_FUNCTION();
    return ret;
}