Esempio n. 1
0
static int stm32l475_ota_init(hal_ota_module_t *m, void *something)
{
    hal_logic_partition_t *partition_info;
    hal_partition_t pno = HAL_PARTITION_OTA_TEMP;

    stm32l475_ota_module.init = stm32l475_ota_init;
    stm32l475_ota_module.ota_write = stm32l475_ota_write;
    stm32l475_ota_module.ota_read = stm32l475_ota_read;
    stm32l475_ota_module.ota_set_boot = stm32l475_ota_set_boot;

    LOG("set ota init---------------\n");
    _off_set = *(uint32_t*)something;
    ota_info.ota_len=_off_set;

    if (!FLASH_bank1_enabled()) {
        pno = HAL_PARTITION_APPLICATION;
    }
    
    if(_off_set==0) {
        partition_info = hal_flash_get_info( pno );
        hal_flash_erase(pno, 0 ,partition_info->partition_length);
        CRC16_Init( &contex );
    } else {
        contex.crc=hal_ota_get_crc16();
        LOG("--------get crc16 context.crc=%d!--------\n",contex.crc);
    }

    return 0;
}
Esempio n. 2
0
int32_t hal_flash_write(hal_partition_t pno, uint32_t* poff, const void* buf ,uint32_t buf_size)
{
    uint32_t addr;
    uint32_t start_addr, end_addr;
    int32_t ret = 0;
    hal_logic_partition_t *partition_info;

    partition_info = hal_flash_get_info( pno );
    start_addr = partition_info->partition_start_addr + *poff;
    ret = spi_flash_write(start_addr, buf, buf_size);

    *poff += buf_size;
    return ret;
}
Esempio n. 3
0
int32_t hal_flash_read(hal_partition_t pno, uint32_t* poff, void* buf, uint32_t buf_size)
{
    int32_t ret = 0;
    uint32_t start_addr;
    hal_logic_partition_t *partition_info;

    partition_info = hal_flash_get_info( pno );

    if(poff == NULL || buf == NULL || *poff + buf_size > partition_info->partition_length)
        return -1;
    start_addr = partition_info->partition_start_addr + *poff;
    ret = spi_flash_read(start_addr, buf, buf_size);
    *poff += buf_size;

    return ret;
}
Esempio n. 4
0
int32_t hal_flash_erase(hal_partition_t pno, uint32_t off_set,
                        uint32_t size)
{
    uint32_t addr;
    uint32_t start_addr, end_addr;
    int32_t ret = 0;
    hal_logic_partition_t *partition_info;

    partition_info = hal_flash_get_info( pno );
    if(size + off_set > partition_info->partition_length)
        return -1;

    start_addr = ROUND_DOWN((partition_info->partition_start_addr + off_set), SPI_FLASH_SEC_SIZE);
    end_addr = ROUND_DOWN((partition_info->partition_start_addr + off_set + size - 1), SPI_FLASH_SEC_SIZE);

    for (addr = start_addr; addr <= end_addr; addr += SPI_FLASH_SEC_SIZE) {
        ret = spi_flash_erase_range(addr, SPI_FLASH_SEC_SIZE);
        if (ret != 0)
            return ret;
    }

    return 0;
}
Esempio n. 5
0
File: audio.c Progetto: wosayttn/aos
static uint32_t get_audio_part_len(void)
{
	hal_logic_partition_t *audio_part = hal_flash_get_info(PART_FOR_AUDIO);

	return audio_part->partition_length;
}