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

Merge pull request #18093 from Ollrogge/remove_flashpage_free_funcs

periph/flashpage: remove deprecated flashpage_*_free functions
This commit is contained in:
Teufelchen 2024-04-16 08:47:11 +00:00 committed by GitHub
commit 5bc8ca5318
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 24 additions and 202 deletions

View File

@ -212,10 +212,6 @@ SECTIONS
_sram = ORIGIN(ram);
_eram = ORIGIN(ram) + LENGTH(ram);
/* Populate information about rom size */
_srom = ORIGIN(rom);
_erom = ORIGIN(rom) + LENGTH(rom);
_sbackup_data_load = LOADADDR(.backup.data);
.backup.data : ALIGN(4) {
_sbackup_data = .;
@ -241,8 +237,4 @@ SECTIONS
.flash_writable (NOLOAD) : {
KEEP(*(SORT(.flash_writable.*)))
} > rom
.end_fw (NOLOAD) : ALIGN(4) {
_end_fw = . ;
} > rom
}

View File

@ -1,37 +0,0 @@
/*
* Copyright (C) 2021 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup cpu_cortexm_common
* @ingroup drivers_periph_flashpage
* @{
* @file
* @brief common periph/flashpage functions
*
* @author Nils Ollrogge <nils.ollrogge@fu-berlin.de>
* @}
*/
#include "periph/flashpage.h"
/**
* @brief Memory markers, defined in the linker script
* @{
*/
extern uint32_t _end_fw;
extern uint32_t _erom;
unsigned flashpage_first_free(void)
{
return flashpage_page(&_end_fw) + 1;
}
unsigned flashpage_last_free(void)
{
return flashpage_page(&_erom) - 1;
}

View File

@ -207,10 +207,6 @@ SECTIONS
_sram = ORIGIN(ram);
_eram = ORIGIN(ram) + LENGTH(ram);
/* Populate information about rom size */
_srom = ORIGIN(rom);
_erom = ORIGIN(rom) + LENGTH(rom);
.heap1 ALIGN(4) (NOLOAD) :
{
_sheap1 = ORIGIN(ram_ethernet);
@ -250,8 +246,4 @@ SECTIONS
_sheap3 = . ;
_eheap3 = ORIGIN(ram_battery) + LENGTH(ram_battery);
} > ram_battery
.end_fw (NOLOAD) : ALIGN(4) {
_end_fw = . ;
} > rom
}

View File

@ -34,13 +34,6 @@
typedef void (*IAP)(unsigned int[], unsigned int[]);
static const IAP IAP_Entry = (IAP)0x7ffffff1;
/**
* @brief Memory markers, defined in the linker script
* @{
*/
extern uint32_t _end_fw;
extern uint32_t _erom;
static uint32_t iap(uint32_t code, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4)
{
/* contains parameters for IAP command */
@ -258,13 +251,3 @@ void flashpage_write(void *target_addr, const void *data, size_t len)
DEBUG("ERROR: COPY_RAM_TO_FLASH: %u\n", err);
}
}
unsigned flashpage_first_free(void)
{
return flashpage_page(&_end_fw) + 1;
}
unsigned flashpage_last_free(void)
{
return flashpage_page(&_erom) - 1;
}

View File

@ -6,21 +6,6 @@
* directory for more details.
*/
SECTIONS
{
/* Populate information about rom size */
_srom = ORIGIN(ROM);
_erom = ORIGIN(ROM) + LENGTH(ROM);
.flash_writable (NOLOAD) : {
KEEP(*(SORT(.flash_writable.*)))
} > ROM
.end_fw (NOLOAD) : ALIGN(4) {
_end_fw = . ;
} > ROM
}
/* provide address for register maps by taking the address of the first
* register (as provided by the vendor files) */

View File

@ -26,13 +26,6 @@
#include "irq.h"
#include "periph/flashpage.h"
/**
* @brief Memory markers, defined in the linker script
* @{
*/
extern uint32_t _end_fw;
extern uint32_t _erom;
static inline int _unlock(void)
{
int state;
@ -104,15 +97,3 @@ void flashpage_write(void *target_addr, const void *data, size_t len)
/* lock flash and re-enable interrupts */
_lock(state);
}
unsigned flashpage_first_free(void)
{
return flashpage_page(&_end_fw) + 1;
}
/* MSP430 cpu's last page holds the interrupt vector, so flashpage_last_free
is the one before last */
unsigned flashpage_last_free(void)
{
return flashpage_page(&_erom) - 1;
}

View File

@ -61,13 +61,3 @@ void flashpage_write(void *target_addr, const void *data, size_t len)
_flash_write(target_addr, data, len);
}
unsigned flashpage_first_free(void)
{
return flashpage_page(&_native_flash[0]);
}
unsigned flashpage_last_free(void)
{
return flashpage_page(&_native_flash[FLASHPAGE_SIZE * FLASHPAGE_NUMOF - 1]);
}

View File

@ -34,10 +34,6 @@ SECTIONS
{
__stack_size = DEFINED(__stack_size) ? __stack_size : 256;
/* Populate information about rom size */
_srom = ORIGIN(flash);
_erom = ORIGIN(flash) + LENGTH(flash);
.init :
{
KEEP (*(SORT_NONE(.init)))
@ -234,8 +230,4 @@ SECTIONS
.flash_writable (NOLOAD) : {
KEEP(*(SORT(.flash_writable.*)))
} > flash
.end_fw (NOLOAD) : ALIGN(4) {
_end_fw = . ;
} > flash
}

View File

@ -1,37 +0,0 @@
/*
* Copyright (C) 2021 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup cpu_riscv_common
* @ingroup drivers_periph_flashpage
* @{
* @file
* @brief common periph/flashpage functions
*
* @author Nils Ollrogge <nils.ollrogge@fu-berlin.de>
* @}
*/
#include "periph/flashpage.h"
/**
* @brief Memory markers, defined in the linker script
* @{
*/
extern uint32_t _end_fw;
extern uint32_t _erom;
unsigned flashpage_first_free(void)
{
return flashpage_page(&_end_fw) + 1;
}
unsigned flashpage_last_free(void)
{
return flashpage_page(&_erom) - 1;
}

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;
}