You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2021/07/20 21:58:21 UTC

[mynewt-newt] branch master updated: mfg: account for updated bootloader path in mfg command

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

vipulrahane 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 67de80e  mfg: account for updated bootloader path in mfg command
     new 9009682  Merge pull request #440 from vikrant-proxy/mfg-create
67de80e is described below

commit 67de80e3a247f2ec9b678e6c3aeffb52e34a23ae
Author: Vikrant More <vi...@proxy.com>
AuthorDate: Sun Jul 11 14:16:59 2021 -0700

    mfg: account for updated bootloader path in mfg command
---
 newt/builder/paths.go |  1 +
 newt/mfg/build.go     |  7 ++++++-
 newt/mfg/emit.go      | 31 +++++++++++++++++++++++--------
 3 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/newt/builder/paths.go b/newt/builder/paths.go
index cc5c2d3..46b61c6 100644
--- a/newt/builder/paths.go
+++ b/newt/builder/paths.go
@@ -28,6 +28,7 @@ import (
 	"mynewt.apache.org/newt/util"
 )
 
+const BUILD_NAME_BOOT = "app/@mcuboot"
 const BUILD_NAME_APP = "app"
 const BUILD_NAME_LOADER = "loader"
 
diff --git a/newt/mfg/build.go b/newt/mfg/build.go
index e13b93c..ac04172 100644
--- a/newt/mfg/build.go
+++ b/newt/mfg/build.go
@@ -223,7 +223,12 @@ func newMfgBuildTarget(dt DecodedTarget,
 		t.App().Name())
 	man, err := manifest.ReadManifest(mpath)
 	if err != nil {
-		return MfgBuildTarget{}, util.FmtNewtError("%s", err.Error())
+		mpath = builder.ManifestPath(dt.Name, builder.BUILD_NAME_BOOT,
+			t.App().Name())
+		man, err = manifest.ReadManifest(mpath)
+		if err != nil {
+			return MfgBuildTarget{}, util.FmtNewtError("%s", err.Error())
+		}
 	}
 
 	isBoot := parse.ValueIsTrue(man.Syscfg["BOOT_LOADER"])
diff --git a/newt/mfg/emit.go b/newt/mfg/emit.go
index 7a8068f..e6632d7 100644
--- a/newt/mfg/emit.go
+++ b/newt/mfg/emit.go
@@ -99,7 +99,7 @@ type MfgEmitter struct {
 // `.bin` files; image targets use `.img`.
 func targetSrcBinPath(t *target.Target, isBoot bool) string {
 	if isBoot {
-		return builder.AppBinPath(t.Name(), builder.BUILD_NAME_APP,
+		return builder.AppBinPath(t.Name(), builder.BUILD_NAME_BOOT,
 			t.App().Name())
 	} else {
 		return builder.AppImgPath(t.Name(), builder.BUILD_NAME_APP,
@@ -108,26 +108,41 @@ func targetSrcBinPath(t *target.Target, isBoot bool) string {
 }
 
 // Calculates the source path of a target's `.elf` file.
-func targetSrcElfPath(t *target.Target) string {
-	return builder.AppElfPath(t.Name(), builder.BUILD_NAME_APP, t.App().Name())
+func targetSrcElfPath(t *target.Target, isBoot bool) string {
+	if isBoot {
+		return builder.AppElfPath(t.Name(), builder.BUILD_NAME_BOOT, t.App().Name())
+	} else {
+		return builder.AppElfPath(t.Name(), builder.BUILD_NAME_APP, t.App().Name())
+	}
 }
 
 // Calculates the source path of a target's manifest file.
-func targetSrcManifestPath(t *target.Target) string {
-	return builder.ManifestPath(t.Name(), builder.BUILD_NAME_APP,
-		t.App().Name())
+func targetSrcManifestPath(t *target.Target, isBoot bool) string {
+	if isBoot {
+		return builder.ManifestPath(t.Name(), builder.BUILD_NAME_BOOT,
+			t.App().Name())
+	} else {
+		return builder.ManifestPath(t.Name(), builder.BUILD_NAME_APP,
+			t.App().Name())
+	}
 }
 
 func newMfgEmitTarget(bt MfgBuildTarget) (MfgEmitTarget, error) {
+	var build_name string
+	if bt.IsBoot {
+		build_name = builder.BUILD_NAME_BOOT
+	} else {
+		build_name = builder.BUILD_NAME_APP
+	}
 	return MfgEmitTarget{
 		Name:    bt.Target.FullName(),
 		Offset:  bt.Area.Offset + bt.Offset,
 		Size:    bt.Size,
 		IsBoot:  bt.IsBoot,
 		BinPath: targetSrcBinPath(bt.Target, bt.IsBoot),
-		ElfPath: targetSrcElfPath(bt.Target),
+		ElfPath: targetSrcElfPath(bt.Target, bt.IsBoot),
 		ManifestPath: builder.ManifestPath(bt.Target.Name(),
-			builder.BUILD_NAME_APP, bt.Target.App().Name()),
+			build_name, bt.Target.App().Name()),
 		ExtraManifest: bt.ExtraManifest,
 	}, nil
 }