diff --git a/newt/flashmap/flashmap.go b/newt/flashmap/flashmap.go index 517ad720c..d0c0446c3 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")