Following is the command in my openocd script (not tested) for hifive1-revb board.
flash bank spi0 fespi 0x20010000 0 0 0 riscv.cpu.0 0x10014000
How to check in my openocd scriipt if the flash is protected or not before performing any read or write command? The fespi driver code for opened is here: The fespi flash driver here: https://github.com/riscv/riscv-openocd/blob/riscv/src/flash/nor/fespi.c