1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Revert "periph/flashpage: extend API"

This reverts commit 72d47013dd.
This commit is contained in:
Ollrogge 2022-05-12 08:58:14 +02:00
parent 6a8bbe0240
commit 10c987eb66
2 changed files with 24 additions and 43 deletions

View File

@ -236,28 +236,6 @@ unsigned flashpage_page(const void *addr);
*/
void flashpage_erase(unsigned page);
/**
* @brief Get number of first free flashpage
* @deprecated Use @ref FLASH_WRITABLE_INIT instead, which is usable in modules
* as well as applications. The function will be removed after
* the 2022.04 release.
*
* If riotboot is used in two slot mode, this number will change across
* firmware updates as the firmware slots alternate.
*/
unsigned flashpage_first_free(void);
/**
* @brief Get number of last free flashpage
* @deprecated Use @ref FLASH_WRITABLE_INIT instead, which is usable in modules
* as well as applications. The function will be removed after
* the 2022.04 release.
*
* If riotboot is used in two slot mode, this number will change across
* firmware updates as the firmware slots alternate.
*/
unsigned flashpage_last_free(void);
/**
* @brief Write the given page with the given data
*

View File

@ -32,6 +32,14 @@
#define LINE_LEN (16)
/* For MSP430 cpu's the last page holds the interrupt vector, although the api
should not limit erasing that page, we don't want to break when testing */
#if defined(CPU_CC430) || defined(CPU_MSP430FXYZ)
#define TEST_LAST_AVAILABLE_PAGE (FLASHPAGE_NUMOF - 2)
#else
#define TEST_LAST_AVAILABLE_PAGE (FLASHPAGE_NUMOF - 1)
#endif
/* When writing raw bytes on flash, data must be correctly aligned. */
#define ALIGNMENT_ATTR __attribute__((aligned(FLASHPAGE_WRITE_BLOCK_ALIGNMENT)))
@ -99,27 +107,24 @@ static int cmd_info(int argc, char **argv)
(void)argc;
(void)argv;
printf("Flash start addr:\t\t0x%08x\n", (int)CPU_FLASH_BASE);
printf("Flash start addr:\t0x%08x\n", (int)CPU_FLASH_BASE);
#ifdef FLASHPAGE_SIZE
printf("Page size:\t\t\t%i\n", (int)FLASHPAGE_SIZE);
printf("Page size:\t\t%i\n", (int)FLASHPAGE_SIZE);
#else
puts("Page size:\t\t\tvariable");
puts("Page size:\t\tvariable");
#endif
printf("Number of pages:\t\t%i\n", (int)FLASHPAGE_NUMOF);
printf("Number of pages:\t%i\n", (int)FLASHPAGE_NUMOF);
#ifdef FLASHPAGE_RWWEE_NUMOF
printf("RWWEE Flash start addr:\t\t0x%08x\n", (int)CPU_FLASH_RWWEE_BASE);
printf("RWWEE Number of pages:\t\t%i\n", (int)FLASHPAGE_RWWEE_NUMOF);
printf("RWWEE Flash start addr:\t0x%08x\n", (int)CPU_FLASH_RWWEE_BASE);
printf("RWWEE Number of pages:\t%i\n", (int)FLASHPAGE_RWWEE_NUMOF);
#endif
#ifdef NVMCTRL_USER
printf("AUX page size:\t\t%i\n", FLASH_USER_PAGE_AUX_SIZE + sizeof(nvm_user_page_t));
printf(" user area:\t\t%i\n", FLASH_USER_PAGE_AUX_SIZE);
printf("AUX page size:\t%i\n", FLASH_USER_PAGE_AUX_SIZE + sizeof(nvm_user_page_t));
printf(" user area:\t%i\n", FLASH_USER_PAGE_AUX_SIZE);
#endif
printf("Number of first free page: \t%u \n", flashpage_first_free());
printf("Number of last free page: \t%u \n", flashpage_last_free());
return 0;
}
@ -321,7 +326,6 @@ static int cmd_test_last(int argc, char **argv)
(void) argc;
(void) argv;
char fill = 'a';
unsigned last_free = flashpage_last_free();
for (unsigned i = 0; i < sizeof(page_mem); i++) {
page_mem[i] = (uint8_t)fill++;
@ -329,10 +333,10 @@ static int cmd_test_last(int argc, char **argv)
fill = 'a';
}
}
#ifdef __MSP430__
printf("The last page holds the ISR vector, so test page %u\n", last_free);
#if defined(CPU_CC430) || defined(CPU_MSP430FXYZ)
printf("The last page holds the ISR vector, so test page %d\n", TEST_LAST_AVAILABLE_PAGE);
#endif
if (flashpage_write_and_verify(last_free, page_mem) != FLASHPAGE_OK) {
if (flashpage_write_and_verify(TEST_LAST_AVAILABLE_PAGE, page_mem) != FLASHPAGE_OK) {
puts("error verifying the content of last page");
return 1;
}
@ -409,23 +413,22 @@ static int cmd_test_last_raw(int argc, char **argv)
{
(void) argc;
(void) argv;
unsigned last_free = flashpage_last_free();
memset(raw_buf, 0, sizeof(raw_buf));
/* try to align */
memcpy(raw_buf, "test12344321tset", 16);
#ifdef __MSP430__
printf("The last page holds the ISR vector, so test page %u\n", last_free);
#if defined(CPU_CC430) || defined(CPU_MSP430FXYZ)
printf("The last page holds the ISR vector, so test page %d\n", TEST_LAST_AVAILABLE_PAGE);
#endif
/* erase the page first */
flashpage_erase(last_free);
flashpage_erase(TEST_LAST_AVAILABLE_PAGE);
flashpage_write(flashpage_addr(last_free), raw_buf, sizeof(raw_buf));
flashpage_write(flashpage_addr(TEST_LAST_AVAILABLE_PAGE), raw_buf, sizeof(raw_buf));
/* verify that previous write_raw effectively wrote the desired data */
if (memcmp(flashpage_addr(last_free), raw_buf, strlen(raw_buf)) != 0) {
if (memcmp(flashpage_addr(TEST_LAST_AVAILABLE_PAGE), raw_buf, strlen(raw_buf)) != 0) {
puts("error verifying the content of last page");
return 1;
}