You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/06/08 11:09:37 UTC

[mynewt-newt] branch master updated: flashmap: Define more symbols in sysflash.h

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

andk 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 8ddb63e  flashmap: Define more symbols in sysflash.h
8ddb63e is described below

commit 8ddb63ec5867d753192098cbbecb88e0c43e4ff6
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Wed Jun 8 11:51:18 2022 +0200

    flashmap: Define more symbols in sysflash.h
    
    sysflash.h will now have more symbols defined for each flash area.
---
 newt/flashmap/flashmap.go | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/newt/flashmap/flashmap.go b/newt/flashmap/flashmap.go
index 446c102..5b3c418 100644
--- a/newt/flashmap/flashmap.go
+++ b/newt/flashmap/flashmap.go
@@ -231,6 +231,10 @@ func flashMapVarDecl(fm FlashMap) string {
 
 func writeFlashAreaHeader(w io.Writer, area flash.FlashArea) {
 	fmt.Fprintf(w, "#define %-40s %d\n", area.Name, area.Id)
+	fmt.Fprintf(w, "#define %-40s %d\n", area.Name+"_DEVICE", area.Device)
+	fmt.Fprintf(w, "#define %-40s 0x%08x\n", area.Name+"_OFFSET", area.Offset)
+	fmt.Fprintf(w, "#define %-40s %d\n", area.Name+"_SIZE", area.Size)
+	fmt.Fprintf(w, "\n")
 }
 
 func writeFlashMapHeader(w io.Writer, fm FlashMap) {
@@ -249,7 +253,7 @@ func writeFlashMapHeader(w io.Writer, fm FlashMap) {
 		writeFlashAreaHeader(w, area)
 	}
 
-	fmt.Fprintf(w, "\n#endif\n")
+	fmt.Fprintf(w, "#endif\n")
 }
 
 func sizeComment(size int) string {
@@ -261,12 +265,11 @@ func sizeComment(size int) string {
 }
 
 func writeFlashAreaSrc(w io.Writer, area flash.FlashArea) {
-	fmt.Fprintf(w, "    /* %s */\n", area.Name)
 	fmt.Fprintf(w, "    {\n")
-	fmt.Fprintf(w, "        .fa_id = %d,\n", area.Id)
-	fmt.Fprintf(w, "        .fa_device_id = %d,\n", area.Device)
-	fmt.Fprintf(w, "        .fa_off = 0x%08x,\n", area.Offset)
-	fmt.Fprintf(w, "        .fa_size = %d,%s\n", area.Size,
+	fmt.Fprintf(w, "        .fa_id = %s,\n", area.Name)
+	fmt.Fprintf(w, "        .fa_device_id = %s_DEVICE,\n", area.Name)
+	fmt.Fprintf(w, "        .fa_off = %s_OFFSET,\n", area.Name)
+	fmt.Fprintf(w, "        .fa_size = %s_SIZE, %s\n", area.Name,
 		sizeComment(area.Size))
 	fmt.Fprintf(w, "    },\n")
 }