Lines Matching refs:err

67         if (err != ESP_OK) return err; \
153 static esp_err_t spiflash_end_default(esp_flash_t *chip, esp_err_t err);
155 static esp_err_t flash_end_flush_cache(esp_flash_t* chip, esp_err_t err, bool bus_acquired, uint32_…
160 esp_err_t (*end)(esp_flash_t *chip, esp_err_t err);
162 …esp_err_t (*flash_end_flush_cache)(esp_flash_t* chip, esp_err_t err, bool bus_acquired, uint32_t a…
189 esp_err_t err = chip->os_func->start(chip->os_func_data); in spiflash_start_default() local
190 if (err != ESP_OK) { in spiflash_start_default()
191 return err; in spiflash_start_default()
200 static esp_err_t IRAM_ATTR spiflash_end_default(esp_flash_t *chip, esp_err_t err) in spiflash_end_default() argument
205 if (err == ESP_OK) { in spiflash_end_default()
206 err = end_err; // Only return the 'end' error if we haven't already failed in spiflash_end_default()
209 return err; in spiflash_end_default()
226 static IRAM_ATTR esp_err_t flash_end_flush_cache(esp_flash_t* chip, esp_err_t err, bool bus_acquire… in flash_end_flush_cache() argument
232 return (err == ESP_OK)? acquire_err: err; in flash_end_flush_cache()
238 if (err == ESP_OK) { in flash_end_flush_cache()
239 err = flush_err; in flash_end_flush_cache()
242 return rom_spiflash_api_funcs->end(chip, err); in flash_end_flush_cache()
263 esp_err_t err = ESP_OK; in esp_flash_init() local
273 err = esp_flash_read_chip_id(chip, &flash_id); in esp_flash_init()
274 } while (err == ESP_ERR_FLASH_NOT_INITIALISED && retries-- > 0); in esp_flash_init()
276 if (err != ESP_OK) { in esp_flash_init()
277 return err; in esp_flash_init()
283 err = detect_spi_flash_chip(chip); in esp_flash_init()
284 if (err != ESP_OK) { in esp_flash_init()
285 return err; in esp_flash_init()
291 err = esp_flash_get_physical_size(chip, &size); in esp_flash_init()
292 if (err != ESP_OK) { in esp_flash_init()
294 return err; in esp_flash_init()
308 err = rom_spiflash_api_funcs->start(chip); in esp_flash_init()
309 if (err != ESP_OK) { in esp_flash_init()
310 return err; in esp_flash_init()
313 if (err == ESP_OK) { in esp_flash_init()
315 err = chip->chip_drv->set_io_mode(chip); in esp_flash_init()
316 if (err == ESP_ERR_FLASH_NO_RESPONSE && !esp_flash_is_quad_mode(chip)) { in esp_flash_init()
318 err = ESP_OK; in esp_flash_init()
322 return rom_spiflash_api_funcs->end(chip, err); in esp_flash_init()
334 esp_err_t err = ESP_OK; in esp_flash_init_main() local
352 err = esp_flash_read_chip_id(chip, &flash_id); in esp_flash_init_main()
353 } while (err == ESP_ERR_FLASH_NOT_INITIALISED && retries-- > 0); in esp_flash_init_main()
356 if (err != ESP_OK) { in esp_flash_init_main()
357 return err; in esp_flash_init_main()
363 err = detect_spi_flash_chip(chip); in esp_flash_init_main()
364 if (err != ESP_OK) { in esp_flash_init_main()
365 return err; in esp_flash_init_main()
371 err = esp_flash_get_physical_size(chip, &size); in esp_flash_init_main()
372 if (err != ESP_OK) { in esp_flash_init_main()
374 return err; in esp_flash_init_main()
388 err = rom_spiflash_api_funcs->start(chip); in esp_flash_init_main()
389 if (err != ESP_OK) { in esp_flash_init_main()
390 return err; in esp_flash_init_main()
393 if (err == ESP_OK && !octal_mode) { in esp_flash_init_main()
395 err = chip->chip_drv->set_io_mode(chip); in esp_flash_init_main()
396 if (err == ESP_ERR_FLASH_NO_RESPONSE && !esp_flash_is_quad_mode(chip)) { in esp_flash_init_main()
398 err = ESP_OK; in esp_flash_init_main()
402 return rom_spiflash_api_funcs->end(chip, err); in esp_flash_init_main()
408 esp_err_t err = rom_spiflash_api_funcs->start(chip); in read_id_core() local
409 if (err != ESP_OK) { in read_id_core()
410 return err; in read_id_core()
425 err = read_id_func(read_id_arg, out_id); in read_id_core()
427 if (sanity_check && err == ESP_OK) { in read_id_core()
430 err = read_id_func(read_id_arg, &new_id); in read_id_core()
431 if (err == ESP_OK && (new_id != *out_id)) { in read_id_core()
432 err = ESP_ERR_FLASH_NOT_INITIALISED; in read_id_core()
436 return rom_spiflash_api_funcs->end(chip, err); in read_id_core()
449 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_read_id() local
451 if (err != ESP_OK && !(err == ESP_ERR_FLASH_NOT_INITIALISED && chip != NULL)) return err; in esp_flash_read_id()
460 esp_err_t err = rom_spiflash_api_funcs->start(chip); in read_unique_id() local
461 if (err != ESP_OK) { in read_unique_id()
462 return err; in read_unique_id()
465 err = chip->chip_drv->read_unique_id(chip, out_uid); in read_unique_id()
467 return rom_spiflash_api_funcs->end(chip, err); in read_unique_id()
472 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_read_unique_chip_id() local
473 if (err != ESP_OK) { in esp_flash_read_unique_chip_id()
474 return err; in esp_flash_read_unique_chip_id()
495 esp_err_t err; in detect_spi_flash_chip() local
506 err = rom_spiflash_api_funcs->start(chip); in detect_spi_flash_chip()
507 if (err != ESP_OK) { in detect_spi_flash_chip()
508 return err; in detect_spi_flash_chip()
517 err = rom_spiflash_api_funcs->end(chip, err); in detect_spi_flash_chip()
518 if (err != ESP_OK) { in detect_spi_flash_chip()
519 return err; in detect_spi_flash_chip()
531 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_get_physical_size() local
532 if (err != ESP_OK) { in esp_flash_get_physical_size()
533 return err; in esp_flash_get_physical_size()
540 err = rom_spiflash_api_funcs->start(chip); in esp_flash_get_physical_size()
541 if (err != ESP_OK) { in esp_flash_get_physical_size()
542 return err; in esp_flash_get_physical_size()
545 err = chip->chip_drv->detect_size(chip, &detect_size); in esp_flash_get_physical_size()
546 if (err == ESP_OK) { in esp_flash_get_physical_size()
553 return rom_spiflash_api_funcs->end(chip, err); in esp_flash_get_physical_size()
563 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_get_size() local
564 if (err != ESP_OK) { in esp_flash_get_size()
565 return err; in esp_flash_get_size()
581 esp_err_t err = ESP_OK; in esp_flash_erase_chip() local
583 err = esp_flash_get_size(chip, &size); in esp_flash_erase_chip()
584 if (err != ESP_OK) { in esp_flash_erase_chip()
585 ESP_LOGE(TAG, "esp_flash_get_size failed, flash error code: %d", err); in esp_flash_erase_chip()
586 return err; in esp_flash_erase_chip()
588 err = esp_flash_erase_region(chip, 0, size); in esp_flash_erase_chip()
589 return err; in esp_flash_erase_chip()
594 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_erase_region() local
618 err = ESP_OK; in esp_flash_erase_region()
623 err = rom_spiflash_api_funcs->start(chip); in esp_flash_erase_region()
624 if (err != ESP_OK) { in esp_flash_erase_region()
625 return err; in esp_flash_erase_region()
628 err = chip->chip_drv->get_protected_regions(chip, &protected); in esp_flash_erase_region()
629 if (err == ESP_OK && protected != 0) { in esp_flash_erase_region()
630 for (int i = 0; i < chip->chip_drv->num_protectable_regions && err == ESP_OK; i++) { in esp_flash_erase_region()
634 err = ESP_ERR_FLASH_PROTECTED; in esp_flash_erase_region()
639 err = rom_spiflash_api_funcs->end(chip, err); in esp_flash_erase_region()
641 if (err != ESP_OK) { in esp_flash_erase_region()
642 return err; in esp_flash_erase_region()
652 err = chip->chip_drv->yield(chip, 0); in esp_flash_erase_region()
653 if (err != ESP_OK) { in esp_flash_erase_region()
654 return err; in esp_flash_erase_region()
658 err = rom_spiflash_api_funcs->start(chip); in esp_flash_erase_region()
659 if (err != ESP_OK) { in esp_flash_erase_region()
667 err = chip->chip_drv->erase_block(chip, erase_addr); in esp_flash_erase_region()
675 err = chip->chip_drv->erase_sector(chip, erase_addr); in esp_flash_erase_region()
683 if (err != ESP_OK || len_remain == 0) { in esp_flash_erase_region()
691 err = rom_spiflash_api_funcs->end(chip, ESP_OK); in esp_flash_erase_region()
692 if (err != ESP_OK) { in esp_flash_erase_region()
700 return rom_spiflash_api_funcs->flash_end_flush_cache(chip, err, bus_acquired, start, len); in esp_flash_erase_region()
727 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_get_chip_write_protect() local
733 err = rom_spiflash_api_funcs->start(chip); in esp_flash_get_chip_write_protect()
734 if (err != ESP_OK) { in esp_flash_get_chip_write_protect()
735 return err; in esp_flash_get_chip_write_protect()
738 err = chip->chip_drv->get_chip_write_protect(chip, out_write_protected); in esp_flash_get_chip_write_protect()
740 return rom_spiflash_api_funcs->end(chip, err); in esp_flash_get_chip_write_protect()
745 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_set_chip_write_protect() local
749 err = rom_spiflash_api_funcs->start(chip); in esp_flash_set_chip_write_protect()
750 if (err != ESP_OK) { in esp_flash_set_chip_write_protect()
751 return err; in esp_flash_set_chip_write_protect()
754 err = chip->chip_drv->set_chip_write_protect(chip, write_protect); in esp_flash_set_chip_write_protect()
756 return rom_spiflash_api_funcs->end(chip, err); in esp_flash_set_chip_write_protect()
764 esp_err_t err = rom_spiflash_api_funcs->chip_check((esp_flash_t **)&chip); in esp_flash_get_protectable_regions() local
794 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_get_protected_region() local
802 err = find_region(chip, region, &index); in esp_flash_get_protected_region()
803 if (err != ESP_OK) { in esp_flash_get_protected_region()
804 return err; in esp_flash_get_protected_region()
808 err = rom_spiflash_api_funcs->start(chip); in esp_flash_get_protected_region()
809 if (err != ESP_OK) { in esp_flash_get_protected_region()
810 return err; in esp_flash_get_protected_region()
813 err = chip->chip_drv->get_protected_regions(chip, &protection_mask); in esp_flash_get_protected_region()
814 if (err == ESP_OK) { in esp_flash_get_protected_region()
818 return rom_spiflash_api_funcs->end(chip, err); in esp_flash_get_protected_region()
823 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_set_protected_region() local
827 err = find_region(chip, region, &index); in esp_flash_set_protected_region()
828 if (err != ESP_OK) { in esp_flash_set_protected_region()
829 return err; in esp_flash_set_protected_region()
833 err = rom_spiflash_api_funcs->start(chip); in esp_flash_set_protected_region()
834 if (err != ESP_OK) { in esp_flash_set_protected_region()
835 return err; in esp_flash_set_protected_region()
838 err = chip->chip_drv->get_protected_regions(chip, &protection_mask); in esp_flash_set_protected_region()
839 if (err == ESP_OK) { in esp_flash_set_protected_region()
845 err = chip->chip_drv->set_protected_regions(chip, protection_mask); in esp_flash_set_protected_region()
848 return rom_spiflash_api_funcs->end(chip, err); in esp_flash_set_protected_region()
853 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_read() local
887 err = ESP_OK; in esp_flash_read()
889 err = rom_spiflash_api_funcs->start(chip); in esp_flash_read()
890 if (err != ESP_OK) { in esp_flash_read()
899 if (err == ESP_OK) { in esp_flash_read()
900 err = chip->chip_drv->read(chip, buffer_to_read, address, length_to_read); in esp_flash_read()
902 if (err != ESP_OK) { in esp_flash_read()
903 rom_spiflash_api_funcs->end(chip, err); in esp_flash_read()
907 err = rom_spiflash_api_funcs->end(chip, err); in esp_flash_read()
917 } while (err == ESP_OK && length > 0); in esp_flash_read()
924 return err; in esp_flash_read()
930 esp_err_t err = ESP_FAIL; in s_check_setting_zero_to_one() local
937 err = chip->chip_drv->read(chip, verify_buffer, verify_address, this_len); in s_check_setting_zero_to_one()
938 if (err != ESP_OK) { in s_check_setting_zero_to_one()
939 … ESP_DRAM_LOGE(TAG, "failed to read flash to verify if setting zero to one, err: 0x%x", err); in s_check_setting_zero_to_one()
940 return err; in s_check_setting_zero_to_one()
969 esp_err_t err = ESP_FAIL; in s_verify_write() local
977 err = esp_flash_read_encrypted(chip, verify_address, verify_buffer, this_len); in s_verify_write()
979 err = chip->chip_drv->read(chip, verify_buffer, verify_address, this_len); in s_verify_write()
981 if (err != ESP_OK) { in s_verify_write()
982 ESP_DRAM_LOGE(TAG, "failed to read flash to verify previous write, err: 0x%x", err); in s_verify_write()
983 return err; in s_verify_write()
1012 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_write() local
1031 err = ESP_OK; in esp_flash_write()
1056 err = chip->chip_drv->yield(chip, 0); in esp_flash_write()
1057 if (err != ESP_OK) { in esp_flash_write()
1058 return err; in esp_flash_write()
1062 err = rom_spiflash_api_funcs->start(chip); in esp_flash_write()
1063 if (err != ESP_OK) { in esp_flash_write()
1069 err = s_check_setting_zero_to_one(chip, write_addr, write_len, write_buf, is_encrypted); in esp_flash_write()
1070 if (err != ESP_OK) { in esp_flash_write()
1076 err = chip->chip_drv->write(chip, write_buf, write_addr, write_len); in esp_flash_write()
1081 if (err != ESP_OK) { in esp_flash_write()
1088 err = s_verify_write(chip, write_addr, write_len, write_buf, is_encrypted); in esp_flash_write()
1089 if (err != ESP_OK) { in esp_flash_write()
1101 err = rom_spiflash_api_funcs->end(chip, err); in esp_flash_write()
1102 if (err != ESP_OK) { in esp_flash_write()
1112 err = rom_spiflash_api_funcs->flash_end_flush_cache(chip, err, bus_acquired, address, length); in esp_flash_write()
1114 return err; in esp_flash_write()
1118 ret = rom_spiflash_api_funcs->flash_end_flush_cache(chip, err, bus_acquired, address, length); in esp_flash_write()
1123 return err; in esp_flash_write()
1135 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_read_encrypted() local
1136 if (err != ESP_OK) return err; in esp_flash_read_encrypted()
1153 err = spi_flash_mmap(map_src, map_size, SPI_FLASH_MMAP_DATA, (const void **)&map, &map_handle); in esp_flash_read_encrypted()
1154 if (err != ESP_OK) { in esp_flash_read_encrypted()
1155 return err; in esp_flash_read_encrypted()
1162 return err; in esp_flash_read_encrypted()
1168 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_get_io_mode() local
1172 err = rom_spiflash_api_funcs->start(chip); in esp_flash_get_io_mode()
1173 if (err != ESP_OK) { in esp_flash_get_io_mode()
1174 return err; in esp_flash_get_io_mode()
1176 err = chip->chip_drv->get_io_mode(chip, &io_mode); in esp_flash_get_io_mode()
1177 err = rom_spiflash_api_funcs->end(chip, err); in esp_flash_get_io_mode()
1178 if (err == ESP_OK) { in esp_flash_get_io_mode()
1181 return err; in esp_flash_get_io_mode()
1186 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_set_io_mode() local
1190 err = rom_spiflash_api_funcs->start(chip); in esp_flash_set_io_mode()
1191 if (err != ESP_OK) { in esp_flash_set_io_mode()
1192 return err; in esp_flash_set_io_mode()
1194 err = chip->chip_drv->set_io_mode(chip); in esp_flash_set_io_mode()
1195 return rom_spiflash_api_funcs->end(chip, err); in esp_flash_set_io_mode()
1207 esp_err_t err = rom_spiflash_api_funcs->end(chip, ESP_OK); in s_encryption_write_unlock() local
1211 return err; in s_encryption_write_unlock()
1226 esp_err_t err = rom_spiflash_api_funcs->chip_check(&chip); in esp_flash_write_encrypted() local
1294 err = s_encryption_write_lock(chip); in esp_flash_write_encrypted()
1295 if (err != ESP_OK) { in esp_flash_write_encrypted()
1297 return err; in esp_flash_write_encrypted()
1345 err = s_check_setting_zero_to_one(chip, row_addr, encrypt_byte, NULL, is_encrypted); in esp_flash_write_encrypted()
1346 if (err != ESP_OK) { in esp_flash_write_encrypted()
1357 err = s_encryption_write_lock(chip); in esp_flash_write_encrypted()
1358 if (err != ESP_OK) { in esp_flash_write_encrypted()
1364err = chip->chip_drv->write_encrypted(chip, (uint32_t *)encrypt_buf, row_addr, encrypt_byte); in esp_flash_write_encrypted()
1365 if (err!= ESP_OK) { in esp_flash_write_encrypted()
1370 err = s_encryption_write_unlock(chip); in esp_flash_write_encrypted()
1371 if (err != ESP_OK) { in esp_flash_write_encrypted()
1382 err = s_verify_write(chip, row_addr, encrypt_byte, (uint32_t *)encrypt_buf, is_encrypted); in esp_flash_write_encrypted()
1383 if (err != ESP_OK) { in esp_flash_write_encrypted()
1391 err = s_encryption_write_unlock(chip); in esp_flash_write_encrypted()
1392 if (err != ESP_OK) { in esp_flash_write_encrypted()
1402 err = rom_spiflash_api_funcs->flash_end_flush_cache(chip, err, bus_acquired, address, length); in esp_flash_write_encrypted()
1404 return err; in esp_flash_write_encrypted()
1410 ret = rom_spiflash_api_funcs->flash_end_flush_cache(chip, err, bus_acquired, address, length); in esp_flash_write_encrypted()
1415 return err; in esp_flash_write_encrypted()