This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
     new a567542e flashmap: Add support for linker script generation
a567542e is described below

commit a567542e70787c140e19023c5345634801b65cf1
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Thu Nov 23 12:57:21 2023 +0100

    flashmap: Add support for linker script generation
    
    Flash map form bsp.yml could easily be inconsistent with linker scrip 
memory regions.
    
    This change aims to allow usage of sysflash.h header generate by newt tool 
to be used by c preprocessor to automatically generate linker scrips that are 
consistent with flash description from bsp.yml.
    This simply excludes part of the header so only constants are exported.
---
 newt/flashmap/flashmap.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/newt/flashmap/flashmap.go b/newt/flashmap/flashmap.go
index 517ad720..d0c0446c 100644
--- a/newt/flashmap/flashmap.go
+++ b/newt/flashmap/flashmap.go
@@ -245,12 +245,15 @@ func writeFlashMapHeader(w io.Writer, fm FlashMap) {
        fmt.Fprintf(w, "#ifndef H_MYNEWT_SYSFLASH_\n")
        fmt.Fprintf(w, "#define H_MYNEWT_SYSFLASH_\n")
        fmt.Fprintf(w, "\n")
-       fmt.Fprintf(w, "#include \"flash_map/flash_map.h\"\n")
-       fmt.Fprintf(w, "\n")
        fmt.Fprintf(w, "#define FLASH_AREA_COUNT %d\n", len(fm.Areas))
        fmt.Fprintf(w, "\n")
+       fmt.Fprintf(w, "/* MYNEWT_SYSFLASH_ONLY_CONST is defined when this 
header is used for linker script generation */\n")
+       fmt.Fprintf(w, "#ifndef MYNEWT_SYSFLASH_ONLY_CONST\n")
+       fmt.Fprintf(w, "#include \"flash_map/flash_map.h\"\n")
+       fmt.Fprintf(w, "\n")
        fmt.Fprintf(w, "%s", C_VAR_COMMENT)
        fmt.Fprintf(w, "extern %s;\n", flashMapVarDecl(fm))
+       fmt.Fprintf(w, "#endif\n")
        fmt.Fprintf(w, "\n")
        fmt.Fprintf(w, "/* Flash map was defined in %s */\n", fm.PkgName)
        fmt.Fprintf(w, "\n")

Reply via email to