Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mfg: account for updated bootloader path in mfg command #440

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newt/builder/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
7 changes: 6 additions & 1 deletion newt/mfg/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
31 changes: 23 additions & 8 deletions newt/mfg/emit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down