Flash MTD
bflb_mtd_init()
Initialize MTD (Flash storage abstraction, includes boot2)
Return value: None
bflb_mtd_open(name, handle, flags)
Open an MTD device by partition name
📎 Device name lookup: Supported Device Names (BL616)
Return value: see the SDK header
bflb_mtd_close(handle)
Close an MTD device and free the handle
Return value: see the SDK header
bflb_mtd_info(handle, info)
Get MTD device info (name/address/size)
Return value: see the SDK header
bflb_mtd_erase(handle, addr, size)
Erase a region of the MTD device
Return value: see the SDK header
bflb_mtd_erase_all(handle)
Erase the whole MTD partition
Return value: see the SDK header
bflb_mtd_write(handle, addr, size, data)
Write data to the MTD device
Return value: see the SDK header
bflb_mtd_read(handle, addr, size, data)
Read data from the MTD device
Return value: see the SDK header
bflb_mtd_size(handle, size)
Get the MTD partition size
Return value: see the SDK header
EasyFlash KV
easyflash_init()
Initialize EasyFlash (key-value storage)
Return value: see the SDK header
ef_get_env_blob(key, value_buf, buf_len, saved_value_len)
Read a key-value blob
Return value: see the SDK header
ef_get_env_blob_offset(key, value_buf, buf_len, saved_value_len, offset)
Read a key-value blob at an offset
Return value: see the SDK header
ef_set_env_blob(key, value_buf, buf_len)
Write a key-value blob
Return value: see the SDK header
ef_set_env(key, value)
Write a string key-value pair
Return value: see the SDK header
ef_del_env(key)
Delete a key-value pair
Return value: see the SDK header
ef_save_env()
Save environment variables to Flash
Return value: see the SDK header
ef_env_set_default()
Restore key-value defaults
Return value: see the SDK header
ef_set_and_save_env(key, value)
Write and save a key-value pair
Return value: see the SDK header
ef_del_and_save_env(key)
Delete and save a key-value pair
Return value: see the SDK header
ef_print_env()
Print all key-value pairs
Return value: see the SDK header
ef_foreach_env(cb, arg)
Iterate all key-value pairs
Return value: see the SDK header
FATFS
f_open(fp, path, mode)
Open or create a file
Return value: see the SDK header
f_close(fp)
Close a file
Return value: see the SDK header
f_read(fp, buff, btr, br)
Read from a file
Return value: see the SDK header
f_write(fp, buff, btw, bw)
Write to a file
Return value: see the SDK header
f_lseek(fp, ofs)
Move the file read/write pointer
Return value: see the SDK header
f_truncate(fp)
Truncate a file at the current pointer
Return value: see the SDK header
f_sync(fp)
Flush file buffers to disk
Return value: see the SDK header
f_opendir(dp, path)
Open a directory
Return value: see the SDK header
f_closedir(dp)
Close a directory
Return value: see the SDK header
f_readdir(dp, fno)
Read a directory entry
Return value: see the SDK header
f_findfirst(dp, fno, path, pattern)
Find the first matching file
Return value: see the SDK header
f_findnext(dp, fno)
Find the next matching file
Return value: see the SDK header
f_mkdir(path)
Create a directory
Return value: see the SDK header
f_unlink(path)
Delete a file or directory
Return value: see the SDK header
f_rename(path_old, path_new)
Rename a file or directory
Return value: see the SDK header
f_stat(path, fno)
Get file information
Return value: see the SDK header
f_chmod(path, attr, mask)
Change file attributes
Return value: see the SDK header
f_utime(path, fno)
Change file timestamps
Return value: see the SDK header
f_chdir(path)
Change the current directory
Return value: see the SDK header
f_chdrive(path)
Change the current drive
Return value: see the SDK header
f_getcwd(buff, len)
Get the current working directory
Return value: see the SDK header
f_getfree(path, nclst, fatfs)
Get the free space
Return value: see the SDK header
f_getlabel(path, label, vsn)
Get the volume label
Return value: see the SDK header
f_setlabel(label)
Set the volume label
Return value: see the SDK header
f_expand(fp, fsz, opt)
Pre-allocate contiguous space
Return value: see the SDK header
f_mount(fs, path, opt)
Mount/unmount a volume
Return value: see the SDK header
f_mkfs(path, opt, work, len)
Format a volume
Return value: see the SDK header
f_fdisk(pdrv, ptbl, work)
Partition a disk
Return value: see the SDK header
f_setcp(cp)
Set the code page
Return value: see the SDK header
f_putc(c, fp)
Write a single character
Return value: see the SDK header
f_puts(str, cp)
Write a string
Return value: see the SDK header
f_printf(fp, str, ...)
Write a formatted string
Return value: see the SDK header
get_fattime()
Get the current time (FAT timestamp callback)
Return value: see the SDK header
ff_oem2uni(oem, cp)
Convert an OEM character to Unicode
Return value: see the SDK header
ff_uni2oem(uni, cp)
Convert Unicode to an OEM character
Return value: see the SDK header
ff_wtoupper(uni)
Convert a character to uppercase
Return value: see the SDK header
ff_memfree(mblock)
Memory free hook
Return value: None
ff_mutex_create(vol)
Mutex create hook
Return value: see the SDK header
ff_mutex_delete(vol)
Mutex delete hook
Return value: None
ff_mutex_take(vol)
Mutex take hook
Return value: see the SDK header
ff_mutex_give(vol)
Mutex give hook
Return value: None
LittleFS
lfs_format(lfs, config)
Format a littlefs filesystem
Return value: see the SDK header
lfs_mount(lfs, config)
Mount littlefs
Return value: see the SDK header
lfs_unmount(lfs)
Unmount littlefs
Return value: see the SDK header
lfs_remove(lfs, path)
Remove a file or directory
Return value: see the SDK header
lfs_rename(lfs, oldpath, newpath)
Rename a file or directory
Return value: see the SDK header
lfs_stat(lfs, path, info)
Get file/directory info
Return value: see the SDK header
lfs_getattr(lfs, path, type, buffer, size)
Read a custom attribute
Return value: see the SDK header
lfs_setattr(lfs, path, type, buffer, size)
Write a custom attribute
Return value: see the SDK header
lfs_removeattr(lfs, path, type)
Remove a custom attribute
Return value: see the SDK header
lfs_file_open(lfs, file, path, flags)
Open a file
Return value: see the SDK header
lfs_file_opencfg(lfs, file, path, flags, config)
Open a file with configuration
Return value: see the SDK header
lfs_file_close(lfs, file)
Close a file
Return value: see the SDK header
lfs_file_sync(lfs, file)
Sync a file to storage
Return value: see the SDK header
lfs_file_read(lfs, file, buffer, size)
Read from a file
Return value: see the SDK header
lfs_file_write(lfs, file, buffer, size)
Write to a file
Return value: see the SDK header
lfs_file_seek(lfs, file, off, whence)
Move the file pointer
Return value: see the SDK header
lfs_file_truncate(lfs, file, size)
Truncate a file
Return value: see the SDK header
lfs_file_tell(lfs, file)
Get the file pointer position
Return value: see the SDK header
lfs_file_rewind(lfs, file)
Rewind the file pointer
Return value: see the SDK header
lfs_file_size(lfs, file)
Get the file size
Return value: see the SDK header
lfs_mkdir(lfs, path)
Create a directory
Return value: see the SDK header
lfs_dir_open(lfs, dir, path)
Open a directory
Return value: see the SDK header
lfs_dir_close(lfs, dir)
Close a directory
Return value: see the SDK header
lfs_dir_read(lfs, dir, info)
Read a directory entry
Return value: see the SDK header
lfs_dir_seek(lfs, dir, off)
Move the directory pointer
Return value: see the SDK header
lfs_dir_tell(lfs, dir)
Get the directory pointer position
Return value: see the SDK header
lfs_dir_rewind(lfs, dir)
Rewind the directory pointer
Return value: see the SDK header
lfs_fs_stat(lfs, fsinfo)
Get filesystem statistics
Return value: see the SDK header
lfs_fs_size(lfs)
Get the filesystem used size
Return value: see the SDK header
lfs_fs_gc(lfs)
Trigger garbage collection/wear leveling
Return value: see the SDK header
lfs_fs_mkconsistent(lfs)
Make the filesystem consistent (power-loss recovery)
Return value: see the SDK header
lfs_fs_grow(lfs, block_count)
Grow the filesystem size
Return value: see the SDK header
lfs_migrate(lfs, cfg)
Migrate an old filesystem to littlefs
Return value: see the SDK header
Coredump
coredump_print(addr, lma_addr, len, desc)
Print crash dump data
Return value: None
coredump_run()
Run the coredump flow (save context to Flash)
Return value: None
core_partition_init(flash_addr, flash_size)
Initialize the coredump Flash partition (address/size)
Return value: None
coredump_xip_flash_write(lma, lma_xip, len)
Write XIP buffer data to the coredump Flash
Return value: see the SDK header
core_bin_start_hook(lma, len)
Coredump binary start hook
Return value: None
core_bin_sections_hook(lma, lma_xip, len)
Coredump memory-section hook
Return value: None
core_bin_end_hook(header_lma)
Coredump binary end hook
Return value: None
Async Events
async_event_loop()
Run the async event loop (dispatch queued events)
Return value: None
async_post_general_event(event)
Post a general async event to the queue
Return value: see the SDK header
async_post_event(type, code, value)
Post an async event by type/code/value
Return value: see the SDK header
async_register_event_filter(type, cb, priv)
Register an event filter (callback)
Return value: see the SDK header
async_unregister_event_filter(type, cb, priv)
Unregister an event filter
Return value: see the SDK header
OTA Upgrade
bflb_ota_start(file_size)
Start an OTA upgrade (pass the total firmware size)
Return value: see the SDK header
bflb_ota_update(filesize, offset, buf, buf_len)
Write an OTA firmware data block
Return value: see the SDK header
bflb_ota_finish(check_hash)
Finish OTA and complete the write (optional hash check)
Return value: see the SDK header
bflb_ota_read(offset, buf, buf_len)
Read back written OTA firmware data
Return value: see the SDK header
bflb_ota_check()
Verify the OTA firmware hash
Return value: see the SDK header
bflb_ota_apply()
Apply the OTA firmware (switch to the new image)
Return value: see the SDK header
bflb_ota_abort()
Abort the OTA upgrade and clean up
Return value: None
Have questions?
For any other questions, visit the unified Q&A and discussion board: Ai-Thinker Discussions

