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

newt: Allow third linker script to maximize split image size #414

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions newt/builder/targetbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,13 @@ func (t *TargetBuilder) buildLoader() error {
/* Tentatively link the app (using the normal single image linker
* script)
*/
if err := t.AppBuilder.TentativeLink(t.bspPkg.LinkerScripts,
var appLinkerScripts []string
if len(t.bspPkg.WholeAppLinkerScripts) > 0 {
appLinkerScripts = t.bspPkg.WholeAppLinkerScripts
} else {
appLinkerScripts = t.bspPkg.LinkerScripts
}
if err := t.AppBuilder.TentativeLink(appLinkerScripts,
t.extraADirs()); err != nil {

return err
Expand Down Expand Up @@ -579,7 +585,7 @@ func (t *TargetBuilder) Build() error {
if err := t.buildLoader(); err != nil {
return err
}
linkerScripts = t.bspPkg.Part2LinkerScripts
linkerScripts = t.bspPkg.SplitAppLinkerScripts
}

// Execute the set of pre-link user scripts.
Expand Down
41 changes: 28 additions & 13 deletions newt/pkg/bsp_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,18 @@ const BSP_YAML_FILENAME = "bsp.yml"

type BspPackage struct {
*LocalPackage
CompilerName string
Arch string
LinkerScripts []string
Part2LinkerScripts []string /* scripts to link app to second partition */
DownloadScript string
DebugScript string
OptChkScript string
ImageOffset int
ImagePad int
FlashMap flashmap.FlashMap
BspV ycfg.YCfg
CompilerName string
Arch string
LinkerScripts []string
WholeAppLinkerScripts []string /* scripts to tentatively link app for split image as though it had full use of both slots */
SplitAppLinkerScripts []string /* scripts to link app to second partition */
DownloadScript string
DebugScript string
OptChkScript string
ImageOffset int
ImagePad int
FlashMap flashmap.FlashMap
BspV ycfg.YCfg
}

func (bsp *BspPackage) BspYamlPath() string {
Expand Down Expand Up @@ -145,12 +146,26 @@ func (bsp *BspPackage) Reload(settings map[string]string) error {
return err
}

bsp.Part2LinkerScripts, err = bsp.resolveLinkerScriptSetting(
settings, "bsp.part2linkerscript")
bsp.WholeAppLinkerScripts, err = bsp.resolveLinkerScriptSetting(
settings, "bsp.wholeapplinkerscript")
if err != nil {
return err
}

bsp.SplitAppLinkerScripts, err = bsp.resolveLinkerScriptSetting(
settings, "bsp.splitapplinkerscript")
if err != nil {
return err
}

if len(bsp.SplitAppLinkerScripts) == 0 {
bsp.SplitAppLinkerScripts, err = bsp.resolveLinkerScriptSetting(
settings, "bsp.part2linkerscript")
if err != nil {
return err
}
}

bsp.DownloadScript, err = bsp.resolvePathSetting(
settings, "bsp.downloadscript")
if err != nil {
Expand Down