samples/tree-wide: remove flash_write_protection_set() usage
This patch removes scenario which was testing deprecated API behaviors. Needed as As flash_write_protection_set() was deprecated and became no-operation. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
This commit is contained in:
parent
bd48673fb5
commit
c5cc990cb3
|
@ -60,16 +60,12 @@ static int cmd_write_mcux(const struct shell *shell, size_t argc, char *argv[])
|
|||
|
||||
PR_SHELL(shell, "write address: 0x%x\n", offset);
|
||||
|
||||
flash_write_protection_set(flash_dev, false);
|
||||
|
||||
if (flash_write(flash_dev, offset, value,
|
||||
sizeof(value)) != 0) {
|
||||
PR_ERROR(shell, "Flash write failed!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
flash_write_protection_set(flash_dev, true);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -90,15 +86,11 @@ static int cmd_write_stm32(const struct shell *shell, size_t argc, char *argv[])
|
|||
|
||||
PR_SHELL(shell, "write address: 0x%x\n", offset);
|
||||
|
||||
flash_write_protection_set(flash_dev, false);
|
||||
|
||||
if (flash_write(flash_dev, offset, &value, sizeof(value)) != 0) {
|
||||
PR_ERROR(shell, "Flash write failed!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
flash_write_protection_set(flash_dev, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -193,53 +193,32 @@ static int do_read(const struct shell *shell, off_t offset, size_t len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Erase area, handling write protection and printing on error. */
|
||||
/* Erase area and printing on error. */
|
||||
static int do_erase(const struct shell *shell, off_t offset, size_t size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = flash_write_protection_set(flash_device, false);
|
||||
if (ret) {
|
||||
PR_ERROR(shell, "Failed to disable flash protection (err: %d)."
|
||||
"\n", ret);
|
||||
return ret;
|
||||
}
|
||||
ret = flash_erase(flash_device, offset, size);
|
||||
if (ret) {
|
||||
PR_ERROR(shell, "flash_erase failed (err:%d).\n", ret);
|
||||
return ret;
|
||||
}
|
||||
ret = flash_write_protection_set(flash_device, true);
|
||||
if (ret) {
|
||||
PR_ERROR(shell, "Failed to enable flash protection (err: %d)."
|
||||
"\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Write bytes, handling write protection and printing on error. */
|
||||
/* Write bytes and printing on error. */
|
||||
static int do_write(const struct shell *shell, off_t offset, uint8_t *buf,
|
||||
size_t len, bool read_back)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = flash_write_protection_set(flash_device, false);
|
||||
if (ret) {
|
||||
PR_ERROR(shell, "Failed to disable flash protection (err: %d)."
|
||||
"\n", ret);
|
||||
return ret;
|
||||
}
|
||||
ret = flash_write(flash_device, offset, buf, len);
|
||||
if (ret) {
|
||||
PR_ERROR(shell, "flash_write failed (err:%d).\n", ret);
|
||||
return ret;
|
||||
}
|
||||
ret = flash_write_protection_set(flash_device, true);
|
||||
if (ret) {
|
||||
PR_ERROR(shell, "Failed to enable flash protection (err: %d)."
|
||||
"\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (read_back) {
|
||||
PR_SHELL(shell, "Reading back written bytes:\n");
|
||||
ret = do_read(shell, offset, len);
|
||||
|
@ -262,23 +241,12 @@ static int do_write_unaligned(const struct shell *shell, off_t offset, uint8_t *
|
|||
char *before_data;
|
||||
char *after_data;
|
||||
|
||||
ret = flash_write_protection_set(flash_device, false);
|
||||
if (ret) {
|
||||
PR_ERROR(shell, "Failed to disable flash protection (err: %d)."
|
||||
"\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (0 == size_before && 0 == size_after) {
|
||||
/* Aligned write */
|
||||
flash_erase(flash_device, offset, len);
|
||||
flash_write(flash_device, offset, buf, len);
|
||||
ret = flash_write_protection_set(flash_device, true);
|
||||
if (ret) {
|
||||
PR_ERROR(shell, "Failed to enable flash protection (err: %d)."
|
||||
"\n", ret);
|
||||
}
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
before_data = k_malloc(page_size);
|
||||
|
@ -371,13 +339,6 @@ free_buffers:
|
|||
k_free(before_data);
|
||||
k_free(after_data);
|
||||
|
||||
int ret1 = flash_write_protection_set(flash_device, true);
|
||||
if (ret1) {
|
||||
PR_ERROR(shell, "Failed to enable flash protection (err: %d)."
|
||||
"\n", ret1);
|
||||
return ret1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ void main(void)
|
|||
}
|
||||
|
||||
printf("\nTest 1: Flash erase page at 0x%x\n", FLASH_TEST_OFFSET);
|
||||
flash_write_protection_set(flash_dev, false);
|
||||
if (flash_erase(flash_dev, FLASH_TEST_OFFSET, FLASH_PAGE_SIZE) != 0) {
|
||||
printf(" Flash erase failed!\n");
|
||||
} else {
|
||||
|
@ -61,7 +60,6 @@ void main(void)
|
|||
}
|
||||
|
||||
printf("\nTest 2: Flash write (word array 1)\n");
|
||||
flash_write_protection_set(flash_dev, false);
|
||||
for (i = 0U; i < ARRAY_SIZE(buf_array_1); i++) {
|
||||
offset = FLASH_TEST_OFFSET + (i << 2);
|
||||
printf(" Attempted to write %x at 0x%x\n", buf_array_1[i],
|
||||
|
@ -94,7 +92,6 @@ void main(void)
|
|||
}
|
||||
|
||||
printf("\nTest 4: Flash write (word array 2)\n");
|
||||
flash_write_protection_set(flash_dev, false);
|
||||
for (i = 0U; i < ARRAY_SIZE(buf_array_2); i++) {
|
||||
offset = FLASH_TEST_OFFSET + (i << 2);
|
||||
printf(" Attempted to write %x at 0x%x\n", buf_array_2[i],
|
||||
|
@ -126,7 +123,6 @@ void main(void)
|
|||
}
|
||||
|
||||
printf("\nTest 6: Non-word aligned write (word array 3)\n");
|
||||
flash_write_protection_set(flash_dev, false);
|
||||
for (i = 0U; i < ARRAY_SIZE(buf_array_3); i++) {
|
||||
offset = FLASH_TEST_OFFSET + (i << 2) + 1;
|
||||
printf(" Attempted to write %x at 0x%x\n", buf_array_3[i],
|
||||
|
@ -149,7 +145,6 @@ void main(void)
|
|||
printf(" Data read does not match data written!\n");
|
||||
}
|
||||
}
|
||||
flash_write_protection_set(flash_dev, true);
|
||||
|
||||
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
|
||||
struct flash_pages_info info;
|
||||
|
|
|
@ -63,7 +63,6 @@ void main(void)
|
|||
* operations.
|
||||
*/
|
||||
printf("\nTest 1: Flash erase\n");
|
||||
flash_write_protection_set(flash_dev, false);
|
||||
|
||||
rc = flash_erase(flash_dev, FLASH_TEST_REGION_OFFSET,
|
||||
FLASH_SECTOR_SIZE);
|
||||
|
@ -74,7 +73,6 @@ void main(void)
|
|||
}
|
||||
|
||||
printf("\nTest 2: Flash write\n");
|
||||
flash_write_protection_set(flash_dev, false);
|
||||
|
||||
printf("Attempting to write %u bytes\n", len);
|
||||
rc = flash_write(flash_dev, FLASH_TEST_REGION_OFFSET, expected, len);
|
||||
|
|
Loading…
Reference in New Issue