Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

periph/flashpage: extend API #16972

Merged
merged 7 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cpu/msp430_common: extend flashpage API
  • Loading branch information
Ollrogge committed Oct 25, 2021
commit 741943f021f3c8b552acaff49f75f455497333ae
18 changes: 18 additions & 0 deletions cpu/msp430_common/ldscripts/msp430_common.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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.
*/

SECTIONS
{
/* Populate information about rom size */
_srom = ORIGIN(ROM);
_erom = ORIGIN(ROM) + LENGTH(ROM);

.end_fw (NOLOAD) : ALIGN(4) {
_end_fw = . ;
} > ROM
}
19 changes: 19 additions & 0 deletions cpu/msp430_common/periph/flashpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
#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;
Expand Down Expand Up @@ -97,3 +104,15 @@ 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;
}
1 change: 1 addition & 0 deletions makefiles/arch/msp430.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ASFLAGS += $(CFLAGS_CPU) --defsym $(CPU_MODEL)=1 $(CFLAGS_DBG)
LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT)
LINKFLAGS += -Wl,--gc-sections -Wl,-L$(MSP430_SUPPORT_FILES)/include
LINKFLAGS += -T $(MSP430_SUPPORT_FILES)/include/$(CPU_MODEL).ld
LINKFLAGS += -T $(RIOTCPU)/msp430_common/ldscripts/msp430_common.ld
LINKFLAGS += $(RIOTCPU)/msp430_common/ldscripts/xfa.ld

OPTIONAL_CFLAGS_BLACKLIST += -fdiagnostics-color
Expand Down