Skip to content

Commit

Permalink
flashmap: Add support for linker script generation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kasjer authored and Jerzy Kasenberg committed Jan 5, 2024
1 parent a5165a8 commit f11e033
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions newt/flashmap/flashmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f11e033

Please sign in to comment.