You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/11/10 22:38:13 UTC
[01/50] incubator-mynewt-newt git commit: newt - Create manifest for
manufacturing image.
Repository: incubator-mynewt-newt
Updated Branches:
refs/heads/master c67336507 -> 00ec2a349
newt - Create manifest for manufacturing image.
This manifest currently only contains two fields:
* build_date
* mfg_hash
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/fa889a74
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/fa889a74
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/fa889a74
Branch: refs/heads/master
Commit: fa889a748382f82ebc3c6ad2f8278a4a8afcd7a6
Parents: 5c047ac
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Oct 25 19:38:51 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Oct 25 20:33:51 2016 -0700
----------------------------------------------------------------------
newt/builder/paths.go | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fa889a74/newt/builder/paths.go
----------------------------------------------------------------------
diff --git a/newt/builder/paths.go b/newt/builder/paths.go
index 9a27b80..3f84a62 100644
--- a/newt/builder/paths.go
+++ b/newt/builder/paths.go
@@ -101,11 +101,16 @@ func MfgBinImageDir(mfgPkgName string, imageIdx int) string {
func MfgSectionDir(mfgPkgName string) string {
return MfgBinDir(mfgPkgName) + "/sections"
}
+
func MfgSectionPath(mfgPkgName string, sectionNum int) string {
return fmt.Sprintf("%s/%s-s%d.bin", MfgSectionDir(mfgPkgName),
filepath.Base(mfgPkgName), sectionNum)
}
+func MfgManifestPath(mfgPkgName string) string {
+ return MfgBinDir(mfgPkgName) + "/manifest.json"
+}
+
func (b *Builder) BinDir() string {
return BinDir(b.targetPkg.Name(), b.buildName)
}
[43/50] incubator-mynewt-newt git commit: This closes #26.
Posted by cc...@apache.org.
This closes #26.
Merge branch 'develop' of https://github.com/davidgs/incubator-mynewt-newt into develop
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/a30bf2dc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/a30bf2dc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/a30bf2dc
Branch: refs/heads/master
Commit: a30bf2dcfd9f44174549ab48eb290cfc6b042b17
Parents: 56b708d ef4522e
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Nov 9 10:41:32 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Nov 9 10:41:32 2016 -0800
----------------------------------------------------------------------
newt/newtutil/newtutil.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a30bf2dc/newt/newtutil/newtutil.go
----------------------------------------------------------------------
diff --cc newt/newtutil/newtutil.go
index af949f0,9b99010..ddb2e94
--- a/newt/newtutil/newtutil.go
+++ b/newt/newtutil/newtutil.go
@@@ -33,86 -29,9 +33,86 @@@ import
"mynewt.apache.org/newt/viper"
)
- var NewtVersionStr string = "Apache Newt (incubating) version: 0.9.0"
- var NewtBlinkyTag string = "mynewt_0_9_0_tag"
+ var NewtVersionStr string = "Apache Newt (incubating) version: 1.0.0-develop"
+ var NewtBlinkyTag string = "mynewt_1_0_0_develop_tag"
+const NEWTRC_DIR string = ".newt"
+const REPOS_FILENAME string = "repos.yml"
+
+// Contains general newt settings read from $HOME/.newt
+var newtrc *viper.Viper
+
+func readNewtrc() *viper.Viper {
+ usr, err := user.Current()
+ if err != nil {
+ log.Warn("Failed to obtain user name")
+ return viper.New()
+ }
+
+ dir := usr.HomeDir + "/" + NEWTRC_DIR
+ v, err := util.ReadConfig(dir, strings.TrimSuffix(REPOS_FILENAME, ".yml"))
+ if err != nil {
+ log.Debugf("Failed to read %s/%s file", dir, REPOS_FILENAME)
+ return viper.New()
+ }
+
+ return v
+}
+
+func Newtrc() *viper.Viper {
+ if newtrc != nil {
+ return newtrc
+ }
+
+ newtrc = readNewtrc()
+ return newtrc
+}
+
+func GetSliceFeatures(v *viper.Viper, features map[string]bool,
+ key string) []interface{} {
+
+ val := v.Get(key)
+ vals := []interface{}{val}
+
+ // Process the features in alphabetical order to ensure consistent
+ // results across repeated runs.
+ var featureKeys []string
+ for feature, _ := range features {
+ featureKeys = append(featureKeys, feature)
+ }
+ sort.Strings(featureKeys)
+
+ for _, feature := range featureKeys {
+ overwriteVal := v.Get(key + "." + feature + ".OVERWRITE")
+ if overwriteVal != nil {
+ return []interface{}{overwriteVal}
+ }
+
+ appendVal := v.Get(key + "." + feature)
+ if appendVal != nil {
+ vals = append(vals, appendVal)
+ }
+ }
+
+ return vals
+}
+
+func GetStringMapFeatures(v *viper.Viper, features map[string]bool,
+ key string) map[string]interface{} {
+
+ result := map[string]interface{}{}
+
+ slice := GetSliceFeatures(v, features, key)
+ for _, itf := range slice {
+ sub := cast.ToStringMap(itf)
+ for k, v := range sub {
+ result[k] = v
+ }
+ }
+
+ return result
+}
+
func GetStringFeatures(v *viper.Viper, features map[string]bool,
key string) string {
val := v.GetString(key)
[32/50] incubator-mynewt-newt git commit: MYNEWT-470 - Fix newt test
Posted by cc...@apache.org.
MYNEWT-470 - Fix newt test
My previous commit for this fix assumed the presence of an app builder.
This is an invalid assumption when packages are being unit tested. Now,
only clean artifacts when Build() gets called, rathe than PrepBuild().
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/0fa78952
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/0fa78952
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/0fa78952
Branch: refs/heads/master
Commit: 0fa789525153a297bc1e1375cd652fbfdd73962c
Parents: 035421e
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Nov 4 15:51:23 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Nov 4 15:51:23 2016 -0700
----------------------------------------------------------------------
newt/builder/build.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0fa78952/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index b01e78c..6e2f9b5 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -351,8 +351,6 @@ func (b *Builder) PrepBuild() error {
b.logDepInfo()
- b.CleanArtifacts()
-
// Populate the base set of compiler flags. Flags from the following
// packages get applied to every source file:
// * target
@@ -442,6 +440,8 @@ func (b *Builder) addSysinitBpkg() (*BuildPackage, error) {
}
func (b *Builder) Build() error {
+ b.CleanArtifacts()
+
// Build the packages alphabetically to ensure a consistent order.
bpkgs := b.sortedBuildPackages()
[47/50] incubator-mynewt-newt git commit: newt - Additional bug fixes
for local repo check.
Posted by cc...@apache.org.
newt - Additional bug fixes for local repo check.
These fix additional bugs introduced in commit
dd34193d3c31c5d87161343f160981fb8833c23f. Sorry, my initial commit was
sloppy.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/f9159f5d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/f9159f5d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/f9159f5d
Branch: refs/heads/master
Commit: f9159f5d8135bf6a5551718a33f6d7b3a23686a3
Parents: dd9b644
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Nov 9 15:45:29 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Nov 9 15:45:29 2016 -0800
----------------------------------------------------------------------
newt/project/project.go | 6 +++---
newt/repo/repo.go | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/f9159f5d/newt/project/project.go
----------------------------------------------------------------------
diff --git a/newt/project/project.go b/newt/project/project.go
index 7fb070d..e9c38ad 100644
--- a/newt/project/project.go
+++ b/newt/project/project.go
@@ -292,8 +292,8 @@ func (proj *Project) checkDeps(r *repo.Repo) error {
func (proj *Project) UpdateRepos() error {
repoList := proj.Repos()
- for rname, r := range repoList {
- if rname == repo.REPO_NAME_LOCAL {
+ for _, r := range repoList {
+ if r.IsLocal() {
continue
}
@@ -327,7 +327,7 @@ func (proj *Project) Install(upgrade bool, force bool) error {
}
for rname, r := range proj.Repos() {
- if rname == repo.REPO_NAME_LOCAL {
+ if r.IsLocal() {
continue
}
// Check the version requirements on this repository, and see
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/f9159f5d/newt/repo/repo.go
----------------------------------------------------------------------
diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index bf95dab..369e4ba 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -294,7 +294,7 @@ func (r *Repo) Path() string {
}
func (r *Repo) IsLocal() bool {
- return r.name == REPO_NAME_LOCAL
+ return r.local
}
func (r *Repo) VersionRequirements() []interfaces.VersionReqInterface {
[07/50] incubator-mynewt-newt git commit: newt - Rename a few mfg
entities
Posted by cc...@apache.org.
newt - Rename a few mfg entities
Some of the names for mfg entities turned out to be confusing or
ambiguous. This commite effects the following renames:
* raw section --> raw entry
* device section --> section
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/53574f43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/53574f43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/53574f43
Branch: refs/heads/master
Commit: 53574f43914f4fa0b013e40a8557ea5bf215f8bd
Parents: 09bd4f9
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Oct 26 09:12:05 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Oct 26 09:15:33 2016 -0700
----------------------------------------------------------------------
newt/mfg/create.go | 28 ++++++++++++++--------------
newt/mfg/load.go | 38 +++++++++++++++++++-------------------
newt/mfg/meta.go | 6 +++---
newt/mfg/mfg.go | 10 +++++-----
4 files changed, 41 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/53574f43/newt/mfg/create.go
----------------------------------------------------------------------
diff --git a/newt/mfg/create.go b/newt/mfg/create.go
index 0db4f16..5653b3a 100644
--- a/newt/mfg/create.go
+++ b/newt/mfg/create.go
@@ -101,8 +101,8 @@ func (mi *MfgImage) section0Size() int {
greatest = util.IntMax(greatest, image1Area.Offset+image1Area.Size)
}
- for _, section := range mi.rawSections {
- greatest = util.IntMax(greatest, section.offset+len(section.data))
+ for _, entry := range mi.rawEntries {
+ greatest = util.IntMax(greatest, entry.offset+len(entry.data))
}
return greatest
@@ -161,7 +161,7 @@ func createSectionHeader(deviceId int, offset int, size int) ([]byte, error) {
}
// @return [section0blob, section1blob,...], hash, err
-func (mi *MfgImage) createDeviceSections(parts []mfgPart) (
+func (mi *MfgImage) createSections(parts []mfgPart) (
[][]byte, []byte, error) {
section0Data, hashOff, err := mi.section0Data(parts)
@@ -169,7 +169,7 @@ func (mi *MfgImage) createDeviceSections(parts []mfgPart) (
return nil, nil, err
}
- // XXX: Append additional flash device sections.
+ // XXX: Append additional sections.
// Calculate manufacturing has.
sections := [][]byte{section0Data}
@@ -192,12 +192,12 @@ func areaNameFromImgIdx(imgIdx int) (string, error) {
}
}
-func (mi *MfgImage) rawSectionParts() []mfgPart {
- parts := make([]mfgPart, len(mi.rawSections))
- for i, section := range mi.rawSections {
- parts[i].name = fmt.Sprintf("section-%d (%s)", i, section.filename)
- parts[i].offset = section.offset
- parts[i].data = section.data
+func (mi *MfgImage) rawEntryParts() []mfgPart {
+ parts := make([]mfgPart, len(mi.rawEntries))
+ for i, entry := range mi.rawEntries {
+ parts[i].name = fmt.Sprintf("entry-%d (%s)", i, entry.filename)
+ parts[i].offset = entry.offset
+ parts[i].data = entry.data
}
return parts
@@ -387,7 +387,7 @@ func (mi *MfgImage) SrcPaths() []string {
paths = append(paths, imageBinPaths(mi.images[1])...)
}
- for _, raw := range mi.rawSections {
+ for _, raw := range mi.rawEntries {
paths = append(paths, raw.filename)
}
@@ -405,17 +405,17 @@ func (mi *MfgImage) build() ([][]byte, []byte, error) {
return nil, nil, err
}
- rawParts := mi.rawSectionParts()
+ rawParts := mi.rawEntryParts()
parts := append(targetParts, rawParts...)
sortParts(parts)
- deviceSections, hash, err := mi.createDeviceSections(parts)
+ sections, hash, err := mi.createSections(parts)
if err != nil {
return nil, nil, err
}
- return deviceSections, hash, nil
+ return sections, hash, nil
}
func (mi *MfgImage) createManifest(hash []byte) ([]byte, error) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/53574f43/newt/mfg/load.go
----------------------------------------------------------------------
diff --git a/newt/mfg/load.go b/newt/mfg/load.go
index 703ba78..0ed9bad 100644
--- a/newt/mfg/load.go
+++ b/newt/mfg/load.go
@@ -77,42 +77,42 @@ func (mi *MfgImage) loadTarget(targetName string) (
return tgt, nil
}
-func (mi *MfgImage) loadRawSection(
- entryIdx int, rawEntry map[string]string) (MfgRawSection, error) {
+func (mi *MfgImage) loadRawEntry(
+ entryIdx int, rawEntry map[string]string) (MfgRawEntry, error) {
- section := MfgRawSection{}
+ raw := MfgRawEntry{}
offsetStr := rawEntry["offset"]
if offsetStr == "" {
- return section, mi.loadError(
+ return raw, mi.loadError(
"raw rawEntry %d missing required \"offset\" field", entryIdx)
}
var err error
- section.offset, err = util.AtoiNoOct(offsetStr)
+ raw.offset, err = util.AtoiNoOct(offsetStr)
if err != nil {
- return section, mi.loadError(
+ return raw, mi.loadError(
"raw rawEntry %d contains invalid offset: %s", entryIdx, offsetStr)
}
- section.filename = rawEntry["file"]
- if section.filename == "" {
- return section, mi.loadError(
+ raw.filename = rawEntry["file"]
+ if raw.filename == "" {
+ return raw, mi.loadError(
"raw rawEntry %d missing required \"file\" field", entryIdx)
}
- if !strings.HasPrefix(section.filename, "/") {
- section.filename = mi.basePkg.BasePath() + "/" + section.filename
+ if !strings.HasPrefix(raw.filename, "/") {
+ raw.filename = mi.basePkg.BasePath() + "/" + raw.filename
}
- section.data, err = ioutil.ReadFile(section.filename)
+ raw.data, err = ioutil.ReadFile(raw.filename)
if err != nil {
- return section, mi.loadError(
+ return raw, mi.loadError(
"error loading file for raw rawEntry %d; filename=%s: %s",
- entryIdx, section.filename, err.Error())
+ entryIdx, raw.filename, err.Error())
}
- return section, nil
+ return raw, nil
}
func (mi *MfgImage) areaNameToPart(areaName string) (mfgPart, bool) {
@@ -160,7 +160,7 @@ func (mi *MfgImage) detectOverlaps() error {
}
}
- parts = append(parts, mi.rawSectionParts()...)
+ parts = append(parts, mi.rawEntryParts()...)
sortParts(parts)
overlaps := []overlap{}
@@ -237,13 +237,13 @@ func Load(basePkg *pkg.LocalPackage) (*MfgImage, error) {
slice := cast.ToSlice(itf)
if slice != nil {
for i, entryItf := range slice {
- entry := cast.ToStringMapString(entryItf)
- section, err := mi.loadRawSection(i, entry)
+ yamlEntry := cast.ToStringMapString(entryItf)
+ entry, err := mi.loadRawEntry(i, yamlEntry)
if err != nil {
return nil, err
}
- mi.rawSections = append(mi.rawSections, section)
+ mi.rawEntries = append(mi.rawEntries, entry)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/53574f43/newt/mfg/meta.go
----------------------------------------------------------------------
diff --git a/newt/mfg/meta.go b/newt/mfg/meta.go
index d617369..796f08e 100644
--- a/newt/mfg/meta.go
+++ b/newt/mfg/meta.go
@@ -180,10 +180,10 @@ func insertMeta(section0Data []byte, flashMap flash.FlashMap) (int, error) {
return metaOff + hashSubOff, nil
}
-func calcMetaHash(deviceSections [][]byte) []byte {
- // Concatenate all device sections.
+func calcMetaHash(sections [][]byte) []byte {
+ // Concatenate all sections.
blob := []byte{}
- for _, section := range deviceSections {
+ for _, section := range sections {
blob = append(blob, section...)
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/53574f43/newt/mfg/mfg.go
----------------------------------------------------------------------
diff --git a/newt/mfg/mfg.go b/newt/mfg/mfg.go
index 6c9d93c..f912c33 100644
--- a/newt/mfg/mfg.go
+++ b/newt/mfg/mfg.go
@@ -45,14 +45,14 @@ type mfgImageSectionHeader struct {
Size uint32 // Does not include header.
}
-type MfgRawSection struct {
+type MfgRawEntry struct {
offset int
filename string
data []byte
}
// A chunk of data in the manufacturing image. Can be a firmware image or a
-// raw section (contents of a data file).
+// raw entry (contents of a data file).
type mfgPart struct {
offset int
data []byte
@@ -64,9 +64,9 @@ type MfgImage struct {
bsp *pkg.BspPackage
- boot *target.Target
- images []*target.Target
- rawSections []MfgRawSection
+ boot *target.Target
+ images []*target.Target
+ rawEntries []MfgRawEntry
}
var MFG_IMAGE_HEADER_SIZE = binary.Size(mfgImageHeader{})
[19/50] incubator-mynewt-newt git commit: newt - fix syscfg
restriction error text
Posted by cc...@apache.org.
newt - fix syscfg restriction error text
When a syscfg restriction was violated, the setting history was
incorrect. All req settings appears as though they had the base
setting's history.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/c2fe8057
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/c2fe8057
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/c2fe8057
Branch: refs/heads/master
Commit: c2fe805780b0e272de92ada431693e2f675cc69e
Parents: 4219606
Author: Christopher Collins <cc...@apache.org>
Authored: Sun Oct 30 15:38:34 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Sun Oct 30 15:38:34 2016 -0700
----------------------------------------------------------------------
newt/syscfg/syscfg.go | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/c2fe8057/newt/syscfg/syscfg.go
----------------------------------------------------------------------
diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index fd4a4f5..7b4b00e 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -511,12 +511,14 @@ func (cfg *Cfg) ErrorText() string {
if len(cfg.Violations) > 0 {
str += "Syscfg restriction violations detected:\n"
for settingName, rslice := range cfg.Violations {
- entry := cfg.Settings[settingName]
+ baseEntry := cfg.Settings[settingName]
+ historyMap[settingName] = baseEntry.History
for _, r := range rslice {
for _, name := range r.relevantSettingNames() {
- historyMap[name] = entry.History
+ reqEntry := cfg.Settings[name]
+ historyMap[name] = reqEntry.History
}
- str += " " + cfg.violationText(entry, r) + "\n"
+ str += " " + cfg.violationText(baseEntry, r) + "\n"
}
}
}
[06/50] incubator-mynewt-newt git commit: newt - Remove obsolete mfg
header code
Posted by cc...@apache.org.
newt - Remove obsolete mfg header code
Some unused mfg code remained in the newt tool. This code generated or
parsed the old mfg image header and mfg image section header structures
that are no longer used.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/cd7eec89
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/cd7eec89
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/cd7eec89
Branch: refs/heads/master
Commit: cd7eec89408c509f7aea8e132d9175c8467a2e27
Parents: 53574f4
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Oct 26 09:14:12 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Oct 26 09:15:33 2016 -0700
----------------------------------------------------------------------
newt/mfg/create.go | 31 -------------------------------
newt/mfg/mfg.go | 22 ----------------------
2 files changed, 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/cd7eec89/newt/mfg/create.go
----------------------------------------------------------------------
diff --git a/newt/mfg/create.go b/newt/mfg/create.go
index 5653b3a..46058f3 100644
--- a/newt/mfg/create.go
+++ b/newt/mfg/create.go
@@ -20,8 +20,6 @@
package mfg
import (
- "bytes"
- "encoding/binary"
"encoding/json"
"fmt"
"io/ioutil"
@@ -131,35 +129,6 @@ func (mi *MfgImage) section0Data(parts []mfgPart) ([]byte, int, error) {
}
-func createImageHeader(hashOffset int) ([]byte, error) {
- buf := &bytes.Buffer{}
-
- hdr := mfgImageHeader{
- Version: uint8(MFG_IMAGE_VERSION),
- HashOffset: uint32(hashOffset),
- }
- if err := binary.Write(buf, binary.BigEndian, hdr); err != nil {
- return nil, util.ChildNewtError(err)
- }
-
- return buf.Bytes(), nil
-}
-
-func createSectionHeader(deviceId int, offset int, size int) ([]byte, error) {
- buf := &bytes.Buffer{}
-
- sectionHdr := mfgImageSectionHeader{
- DeviceId: uint8(deviceId),
- Offset: uint32(offset),
- Size: uint32(size),
- }
- if err := binary.Write(buf, binary.BigEndian, sectionHdr); err != nil {
- return nil, util.ChildNewtError(err)
- }
-
- return buf.Bytes(), nil
-}
-
// @return [section0blob, section1blob,...], hash, err
func (mi *MfgImage) createSections(parts []mfgPart) (
[][]byte, []byte, error) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/cd7eec89/newt/mfg/mfg.go
----------------------------------------------------------------------
diff --git a/newt/mfg/mfg.go b/newt/mfg/mfg.go
index f912c33..30e25b2 100644
--- a/newt/mfg/mfg.go
+++ b/newt/mfg/mfg.go
@@ -20,31 +20,12 @@
package mfg
import (
- "encoding/binary"
-
"mynewt.apache.org/newt/newt/pkg"
"mynewt.apache.org/newt/newt/target"
)
const MFG_YAML_FILENAME string = "mfg.yml"
-const MFG_IMAGE_VERSION = 1
-
-type mfgImageHeader struct {
- Version uint8 // 0x01
- _ uint8
- _ uint16
- HashOffset uint32
-}
-
-type mfgImageSectionHeader struct {
- DeviceId uint8
- _ uint8
- _ uint16
- Offset uint32 // Offset within flash device.
- Size uint32 // Does not include header.
-}
-
type MfgRawEntry struct {
offset int
filename string
@@ -68,6 +49,3 @@ type MfgImage struct {
images []*target.Target
rawEntries []MfgRawEntry
}
-
-var MFG_IMAGE_HEADER_SIZE = binary.Size(mfgImageHeader{})
-var MFG_IMAGE_SECTION_HEADER_SIZE = binary.Size(mfgImageSectionHeader{})
[18/50] incubator-mynewt-newt git commit: newt - expose
cli.ResolveMfgPkg
Posted by cc...@apache.org.
newt - expose cli.ResolveMfgPkg
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/4219606d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/4219606d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/4219606d
Branch: refs/heads/master
Commit: 4219606d2504301cfe29bcf2444e99cef4c42e8c
Parents: aa87efd
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Oct 28 13:50:18 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Oct 28 13:50:33 2016 -0700
----------------------------------------------------------------------
newt/cli/mfg_cmds.go | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4219606d/newt/cli/mfg_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/mfg_cmds.go b/newt/cli/mfg_cmds.go
index a8831c6..c306b45 100644
--- a/newt/cli/mfg_cmds.go
+++ b/newt/cli/mfg_cmds.go
@@ -28,7 +28,7 @@ import (
"mynewt.apache.org/newt/util"
)
-func resolveMfgPkg(pkgName string) (*pkg.LocalPackage, error) {
+func ResolveMfgPkg(pkgName string) (*pkg.LocalPackage, error) {
proj, err := project.TryGetProject()
if err != nil {
return nil, err
@@ -92,7 +92,7 @@ func mfgCreateRunCmd(cmd *cobra.Command, args []string) {
}
pkgName := args[0]
- lpkg, err := resolveMfgPkg(pkgName)
+ lpkg, err := ResolveMfgPkg(pkgName)
if err != nil {
NewtUsage(cmd, err)
}
@@ -111,7 +111,7 @@ func mfgLoadRunCmd(cmd *cobra.Command, args []string) {
}
pkgName := args[0]
- lpkg, err := resolveMfgPkg(pkgName)
+ lpkg, err := ResolveMfgPkg(pkgName)
if err != nil {
NewtUsage(cmd, err)
}
@@ -130,7 +130,7 @@ func mfgDeployRunCmd(cmd *cobra.Command, args []string) {
}
pkgName := args[0]
- lpkg, err := resolveMfgPkg(pkgName)
+ lpkg, err := ResolveMfgPkg(pkgName)
if err != nil {
NewtUsage(cmd, err)
}
[37/50] incubator-mynewt-newt git commit: newt - Allow BSP to specify
>1 linker script.
Posted by cc...@apache.org.
newt - Allow BSP to specify >1 linker script.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/8b428356
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/8b428356
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/8b428356
Branch: refs/heads/master
Commit: 8b428356d13727b836e23867dd091e9e9c3f72de
Parents: 5170736
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Nov 7 15:10:45 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Nov 7 15:12:46 2016 -0800
----------------------------------------------------------------------
newt/builder/build.go | 24 +++++++-------
newt/builder/targetbuild.go | 14 ++++-----
newt/pkg/bsp_package.go | 67 +++++++++++++++++++++++++++++++---------
newt/toolchain/compiler.go | 8 ++---
newt/toolchain/deps.go | 4 +--
5 files changed, 77 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8b428356/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index abdba35..276a742 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -48,7 +48,7 @@ type Builder struct {
compilerInfo *toolchain.CompilerInfo
targetBuilder *TargetBuilder
cfg syscfg.Cfg
- linkerScript string
+ linkerScripts []string
buildName string
linkElf string
injectedSettings map[string]string
@@ -310,7 +310,7 @@ func (b *Builder) ExtractSymbolInfo() (error, *symbol.SymbolMap) {
return nil, syms
}
-func (b *Builder) link(elfName string, linkerScript string,
+func (b *Builder) link(elfName string, linkerScripts []string,
keepSymbols []string) error {
c, err := b.newCompiler(b.appPkg, b.FileBinDir(elfName))
@@ -327,9 +327,7 @@ func (b *Builder) link(elfName string, linkerScript string,
}
}
- if linkerScript != "" {
- c.LinkerScript = linkerScript
- }
+ c.LinkerScripts = linkerScripts
err = c.CompileElf(elfName, pkgNames, keepSymbols, b.linkElf)
if err != nil {
return err
@@ -454,14 +452,16 @@ func (b *Builder) Build() error {
return nil
}
-func (b *Builder) Link(linkerScript string) error {
- if err := b.link(b.AppElfPath(), linkerScript, nil); err != nil {
+func (b *Builder) Link(linkerScripts []string) error {
+ if err := b.link(b.AppElfPath(), linkerScripts, nil); err != nil {
return err
}
return nil
}
-func (b *Builder) KeepLink(linkerScript string, keepMap *symbol.SymbolMap) error {
+func (b *Builder) KeepLink(
+ linkerScripts []string, keepMap *symbol.SymbolMap) error {
+
keepSymbols := make([]string, 0)
if keepMap != nil {
@@ -469,14 +469,14 @@ func (b *Builder) KeepLink(linkerScript string, keepMap *symbol.SymbolMap) error
keepSymbols = append(keepSymbols, info.Name)
}
}
- if err := b.link(b.AppElfPath(), linkerScript, keepSymbols); err != nil {
+ if err := b.link(b.AppElfPath(), linkerScripts, keepSymbols); err != nil {
return err
}
return nil
}
-func (b *Builder) TestLink(linkerScript string) error {
- if err := b.link(b.AppTempElfPath(), linkerScript, nil); err != nil {
+func (b *Builder) TestLink(linkerScripts []string) error {
+ if err := b.link(b.AppTempElfPath(), linkerScripts, nil); err != nil {
return err
}
return nil
@@ -525,7 +525,7 @@ func (b *Builder) Test(p *pkg.LocalPackage) error {
testBpkg := b.PkgMap[p]
testFilename := b.TestExePath(testBpkg)
- if err := b.link(testFilename, "", nil); err != nil {
+ if err := b.link(testFilename, nil, nil); err != nil {
return err
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8b428356/newt/builder/targetbuild.go
----------------------------------------------------------------------
diff --git a/newt/builder/targetbuild.go b/newt/builder/targetbuild.go
index b6e6fdd..e044b43 100644
--- a/newt/builder/targetbuild.go
+++ b/newt/builder/targetbuild.go
@@ -293,7 +293,7 @@ func (t *TargetBuilder) PrepBuild() error {
func (t *TargetBuilder) buildLoader() error {
/* Link the app as a test (using the normal single image linker script) */
- if err := t.AppBuilder.TestLink(t.bspPkg.LinkerScript); err != nil {
+ if err := t.AppBuilder.TestLink(t.bspPkg.LinkerScripts); err != nil {
return err
}
@@ -309,7 +309,7 @@ func (t *TargetBuilder) buildLoader() error {
}
/* perform a test link of the loader */
- if err := t.LoaderBuilder.TestLink(t.bspPkg.LinkerScript); err != nil {
+ if err := t.LoaderBuilder.TestLink(t.bspPkg.LinkerScripts); err != nil {
return err
}
@@ -353,18 +353,18 @@ func (t *TargetBuilder) Build() error {
return err
}
- linkerScript := ""
+ var linkerScripts []string
if t.LoaderBuilder == nil {
- linkerScript = t.bspPkg.LinkerScript
+ linkerScripts = t.bspPkg.LinkerScripts
} else {
if err := t.buildLoader(); err != nil {
return err
}
- linkerScript = t.bspPkg.Part2LinkerScript
+ linkerScripts = t.bspPkg.Part2LinkerScripts
}
/* Link the app. */
- if err := t.AppBuilder.Link(linkerScript); err != nil {
+ if err := t.AppBuilder.Link(linkerScripts); err != nil {
return err
}
@@ -506,7 +506,7 @@ func (t *TargetBuilder) RelinkLoader() (error, map[string]bool,
util.StatusMessage(util.VERBOSITY_VERBOSE,
"Migrating %d unused symbols into Loader\n", len(*preserveElf))
- err = t.LoaderBuilder.KeepLink(t.bspPkg.LinkerScript, preserveElf)
+ err = t.LoaderBuilder.KeepLink(t.bspPkg.LinkerScripts, preserveElf)
if err != nil {
return err, nil, nil
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8b428356/newt/pkg/bsp_package.go
----------------------------------------------------------------------
diff --git a/newt/pkg/bsp_package.go b/newt/pkg/bsp_package.go
index c7bbdbb..d381da3 100644
--- a/newt/pkg/bsp_package.go
+++ b/newt/pkg/bsp_package.go
@@ -33,25 +33,26 @@ const BSP_YAML_FILENAME = "bsp.yml"
type BspPackage struct {
*LocalPackage
- CompilerName string
- Arch string
- LinkerScript string
- Part2LinkerScript string /* script to link app to second partition */
- DownloadScript string
- DebugScript string
- FlashMap flash.FlashMap
- BspV *viper.Viper
+ CompilerName string
+ Arch string
+ LinkerScripts []string
+ Part2LinkerScripts []string /* scripts to link app to second partition */
+ DownloadScript string
+ DebugScript string
+ FlashMap flash.FlashMap
+ BspV *viper.Viper
}
func (bsp *BspPackage) resolvePathSetting(
features map[string]bool, key string) (string, error) {
- outVal := newtutil.GetStringFeatures(bsp.BspV, features, key)
- if outVal == "" {
+ proj := interfaces.GetProject()
+
+ val := newtutil.GetStringFeatures(bsp.BspV, features, key)
+ if val == "" {
return "", nil
}
- proj := interfaces.GetProject()
- path, err := proj.ResolvePath(bsp.BasePath(), outVal)
+ path, err := proj.ResolvePath(bsp.BasePath(), val)
if err != nil {
return "", util.PreNewtError(err,
"BSP \"%s\" specifies invalid %s setting",
@@ -60,6 +61,43 @@ func (bsp *BspPackage) resolvePathSetting(
return path, nil
}
+// Interprets a setting as either a single linker script or a list of linker
+// scripts.
+func (bsp *BspPackage) resolveLinkerScriptSetting(
+ features map[string]bool, key string) ([]string, error) {
+
+ paths := []string{}
+
+ // Assume config file specifies a list of scripts.
+ vals := newtutil.GetStringSliceFeatures(bsp.BspV, features, key)
+ if vals == nil {
+ // Couldn't read a list of scripts; try to interpret setting as a
+ // single script.
+ path, err := bsp.resolvePathSetting(features, key)
+ if err != nil {
+ return nil, err
+ }
+
+ paths = append(paths, path)
+ } else {
+ proj := interfaces.GetProject()
+
+ // Read each linker script from the list.
+ for _, val := range vals {
+ path, err := proj.ResolvePath(bsp.BasePath(), val)
+ if err != nil {
+ return nil, util.PreNewtError(err,
+ "BSP \"%s\" specifies invalid %s setting",
+ bsp.Name(), key)
+ }
+
+ paths = append(paths, path)
+ }
+ }
+
+ return paths, nil
+}
+
func (bsp *BspPackage) Reload(features map[string]bool) error {
var err error
@@ -76,13 +114,13 @@ func (bsp *BspPackage) Reload(features map[string]bool) error {
bsp.Arch = newtutil.GetStringFeatures(bsp.BspV,
features, "bsp.arch")
- bsp.LinkerScript, err = bsp.resolvePathSetting(
+ bsp.LinkerScripts, err = bsp.resolveLinkerScriptSetting(
features, "bsp.linkerscript")
if err != nil {
return err
}
- bsp.Part2LinkerScript, err = bsp.resolvePathSetting(
+ bsp.Part2LinkerScripts, err = bsp.resolveLinkerScriptSetting(
features, "bsp.part2linkerscript")
if err != nil {
return err
@@ -126,7 +164,6 @@ func (bsp *BspPackage) Reload(features map[string]bool) error {
func NewBspPackage(lpkg *LocalPackage) (*BspPackage, error) {
bsp := &BspPackage{
CompilerName: "",
- LinkerScript: "",
DownloadScript: "",
DebugScript: "",
BspV: viper.New(),
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8b428356/newt/toolchain/compiler.go
----------------------------------------------------------------------
diff --git a/newt/toolchain/compiler.go b/newt/toolchain/compiler.go
index e1c43a9..c139a28 100644
--- a/newt/toolchain/compiler.go
+++ b/newt/toolchain/compiler.go
@@ -57,8 +57,8 @@ type CompilerInfo struct {
}
type Compiler struct {
- ObjPathList map[string]bool
- LinkerScript string
+ ObjPathList map[string]bool
+ LinkerScripts []string
depTracker DepTracker
ccPath string
@@ -711,8 +711,8 @@ func (c *Compiler) CompileBinaryCmd(dstFile string, options map[string]bool,
/* so we don't get multiple global definitions of the same vartiable */
//cmd += " -Wl,--warn-common "
- if c.LinkerScript != "" {
- cmd += " -T " + c.LinkerScript
+ for _, ls := range c.LinkerScripts {
+ cmd += " -T " + ls
}
if options["mapFile"] {
cmd += " -Wl,-Map=" + dstFile + ".map"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8b428356/newt/toolchain/deps.go
----------------------------------------------------------------------
diff --git a/newt/toolchain/deps.go b/newt/toolchain/deps.go
index e54c255..aad0dd6 100644
--- a/newt/toolchain/deps.go
+++ b/newt/toolchain/deps.go
@@ -363,8 +363,8 @@ func (tracker *DepTracker) LinkRequired(dstFile string,
}
// Check timestamp of the linker script and all input libraries.
- if tracker.compiler.LinkerScript != "" {
- objFiles = append(objFiles, tracker.compiler.LinkerScript)
+ for _, ls := range tracker.compiler.LinkerScripts {
+ objFiles = append(objFiles, ls)
}
for _, obj := range objFiles {
objModTime, err := util.FileModificationTime(obj)
[36/50] incubator-mynewt-newt git commit: newt;
fix build of native targets
Posted by cc...@apache.org.
newt; fix build of native targets
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/51707366
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/51707366
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/51707366
Branch: refs/heads/master
Commit: 517073668c573c62139c5b52fcd6a7d268e02b69
Parents: 22305a3
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Nov 7 11:32:05 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 7 11:32:05 2016 -0800
----------------------------------------------------------------------
newt/pkg/bsp_package.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/51707366/newt/pkg/bsp_package.go
----------------------------------------------------------------------
diff --git a/newt/pkg/bsp_package.go b/newt/pkg/bsp_package.go
index d89149b..c7bbdbb 100644
--- a/newt/pkg/bsp_package.go
+++ b/newt/pkg/bsp_package.go
@@ -47,7 +47,9 @@ func (bsp *BspPackage) resolvePathSetting(
features map[string]bool, key string) (string, error) {
outVal := newtutil.GetStringFeatures(bsp.BspV, features, key)
-
+ if outVal == "" {
+ return "", nil
+ }
proj := interfaces.GetProject()
path, err := proj.ResolvePath(bsp.BasePath(), outVal)
if err != nil {
[13/50] incubator-mynewt-newt git commit: newtmgr oic;
decode to even more generic entity. Return error if COAP response
code says so.
Posted by cc...@apache.org.
newtmgr oic; decode to even more generic entity. Return error if
COAP response code says so.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/2ac611b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/2ac611b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/2ac611b6
Branch: refs/heads/master
Commit: 2ac611b6209c1f7111b2f4089f7e216c7fc0d502
Parents: ef941d4
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Oct 26 15:57:06 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Oct 26 15:57:06 2016 -0700
----------------------------------------------------------------------
newtmgr/protocol/omgr.go | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/2ac611b6/newtmgr/protocol/omgr.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/omgr.go b/newtmgr/protocol/omgr.go
index a0ab05f..29bff4c 100644
--- a/newtmgr/protocol/omgr.go
+++ b/newtmgr/protocol/omgr.go
@@ -30,8 +30,8 @@ import (
)
type OicRsp struct {
- Read map[string]interface{} `codec:"r"`
- Write map[string]interface{} `codec:"w"`
+ Read interface{} `codec:"r"`
+ Write interface{} `codec:"w"`
}
/*
@@ -46,7 +46,12 @@ func DeserializeOmgrReq(data []byte) (*NmgrReq, error) {
return nil, util.NewNewtError(fmt.Sprintf(
"Oicmgr request invalid %s", err.Error()))
}
- log.Debugf("Deserialized COAP %+v", req)
+ if req.Code != coap.Created && req.Code != coap.Deleted &&
+ req.Code != coap.Valid && req.Code != coap.Changed &&
+ req.Code != coap.Content {
+ return nil, util.NewNewtError(fmt.Sprintf(
+ "OIC error rsp: %s", req.Code.String()))
+ }
var rsp OicRsp
err = codec.NewDecoderBytes(req.Payload, new(codec.CborHandle)).Decode(&rsp)
@@ -54,17 +59,19 @@ func DeserializeOmgrReq(data []byte) (*NmgrReq, error) {
return nil, util.NewNewtError(fmt.Sprintf("Invalid incoming cbor: %s",
err.Error()))
}
+ log.Debugf("Deserialized response %+v", rsp)
nmr := &NmgrReq{}
var ndata []byte = make([]byte, 0)
- if len(rsp.Read) != 0 {
+
+ if rsp.Read != nil {
err = codec.NewEncoderBytes(&ndata,
new(codec.CborHandle)).Encode(rsp.Read)
nmr.Op = NMGR_OP_READ_RSP
} else {
err = codec.NewEncoderBytes(&ndata,
- new(codec.CborHandle)).Encode(rsp.Read)
+ new(codec.CborHandle)).Encode(rsp.Write)
nmr.Op = NMGR_OP_WRITE_RSP
}
if err != nil {
[38/50] incubator-mynewt-newt git commit: newt - fix "mfg create"
Posted by cc...@apache.org.
newt - fix "mfg create"
Newt was trying to read binaries from the bin/mfg/... directory before
copying them. Now it copies the files first.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/c71f226e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/c71f226e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/c71f226e
Branch: refs/heads/master
Commit: c71f226e2dcdea00cd02b1ad2d3c4177a7dbefe4
Parents: 8b42835
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Nov 8 12:32:00 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Nov 8 12:32:00 2016 -0800
----------------------------------------------------------------------
newt/mfg/create.go | 4 ++++
newt/mfg/load.go | 4 ----
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/c71f226e/newt/mfg/create.go
----------------------------------------------------------------------
diff --git a/newt/mfg/create.go b/newt/mfg/create.go
index 7eaf982..1257b75 100644
--- a/newt/mfg/create.go
+++ b/newt/mfg/create.go
@@ -216,6 +216,10 @@ func (mi *MfgImage) createSections() (createState, error) {
var err error
+ if err := mi.detectOverlaps(); err != nil {
+ return cs, err
+ }
+
cs.dsMap, err = mi.deviceSectionMap()
if err != nil {
return cs, err
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/c71f226e/newt/mfg/load.go
----------------------------------------------------------------------
diff --git a/newt/mfg/load.go b/newt/mfg/load.go
index ef75d4d..4370cda 100644
--- a/newt/mfg/load.go
+++ b/newt/mfg/load.go
@@ -301,9 +301,5 @@ func Load(basePkg *pkg.LocalPackage) (*MfgImage, error) {
return nil, err
}
- if err := mi.detectOverlaps(); err != nil {
- return nil, err
- }
-
return mi, nil
}
[15/50] incubator-mynewt-newt git commit: newt - Fix spurious bsp
mismatch err for rmt repos
Posted by cc...@apache.org.
newt - Fix spurious bsp mismatch err for rmt repos
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/bc70c6a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/bc70c6a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/bc70c6a6
Branch: refs/heads/master
Commit: bc70c6a6f380953ccc7aa2274d260df6579209f7
Parents: afae040
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Oct 28 11:01:22 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Oct 28 11:01:55 2016 -0700
----------------------------------------------------------------------
newt/mfg/load.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/bc70c6a6/newt/mfg/load.go
----------------------------------------------------------------------
diff --git a/newt/mfg/load.go b/newt/mfg/load.go
index 0ed9bad..d8e660f 100644
--- a/newt/mfg/load.go
+++ b/newt/mfg/load.go
@@ -267,7 +267,7 @@ func Load(basePkg *pkg.LocalPackage) (*MfgImage, error) {
"split image mode (%s is a split build)", imgTarget.Name())
}
- if imgTarget.BspName != mi.bsp.Name() {
+ if imgTarget.Bsp() != mi.bsp.LocalPackage {
return nil, mi.loadError(
"image target \"%s\" specified conflicting BSP; "+
"boot loader uses %s, image uses %s",
[49/50] incubator-mynewt-newt git commit: Merge remote-tracking
branch 'apache/master' into develop
Posted by cc...@apache.org.
Merge remote-tracking branch 'apache/master' into develop
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/48599c13
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/48599c13
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/48599c13
Branch: refs/heads/master
Commit: 48599c13235dfe62b6928849afd8d58a497cd900
Parents: 93cf30f c673365
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Nov 10 11:38:28 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Nov 10 11:38:28 2016 -0800
----------------------------------------------------------------------
newt/newtutil/newtutil.go | 77 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/48599c13/newt/newtutil/newtutil.go
----------------------------------------------------------------------
diff --cc newt/newtutil/newtutil.go
index d7369d9,6e071f6..79b3cef
--- a/newt/newtutil/newtutil.go
+++ b/newt/newtutil/newtutil.go
@@@ -33,52 -33,52 +33,129 @@@ import
"mynewt.apache.org/newt/viper"
)
-var NewtVersionStr string = "Apache Newt (incubating) version: 0.9.0"
-var NewtBlinkyTag string = "mynewt_0_9_0_tag"
+var NewtVersionStr string = "Apache Newt (incubating) version: 1.0.0-develop"
+var NewtBlinkyTag string = "develop"
+
+const NEWTRC_DIR string = ".newt"
+const REPOS_FILENAME string = "repos.yml"
+
+// Contains general newt settings read from $HOME/.newt
+var newtrc *viper.Viper
+
+func readNewtrc() *viper.Viper {
+ usr, err := user.Current()
+ if err != nil {
+ log.Warn("Failed to obtain user name")
+ return viper.New()
+ }
+
+ dir := usr.HomeDir + "/" + NEWTRC_DIR
+ v, err := util.ReadConfig(dir, strings.TrimSuffix(REPOS_FILENAME, ".yml"))
+ if err != nil {
+ log.Debugf("Failed to read %s/%s file", dir, REPOS_FILENAME)
+ return viper.New()
+ }
+
+ return v
+}
+
+func Newtrc() *viper.Viper {
+ if newtrc != nil {
+ return newtrc
+ }
+
+ newtrc = readNewtrc()
+ return newtrc
+}
+
+func GetSliceFeatures(v *viper.Viper, features map[string]bool,
+ key string) []interface{} {
+
+ val := v.Get(key)
+ vals := []interface{}{val}
+
+ // Process the features in alphabetical order to ensure consistent
+ // results across repeated runs.
+ var featureKeys []string
+ for feature, _ := range features {
+ featureKeys = append(featureKeys, feature)
++ }
++ sort.Strings(featureKeys)
++
++ for _, feature := range featureKeys {
++ overwriteVal := v.Get(key + "." + feature + ".OVERWRITE")
++ if overwriteVal != nil {
++ return []interface{}{overwriteVal}
++ }
++
++ appendVal := v.Get(key + "." + feature)
++ if appendVal != nil {
++ vals = append(vals, appendVal)
++ }
++ }
++
++ return vals
++}
++
++func GetStringMapFeatures(v *viper.Viper, features map[string]bool,
++ key string) map[string]interface{} {
++
++ result := map[string]interface{}{}
++
++ slice := GetSliceFeatures(v, features, key)
++ for _, itf := range slice {
++ sub := cast.ToStringMap(itf)
++ for k, v := range sub {
++ result[k] = v
++ }
++ }
++
++ return result
++}
+
+ const NEWTRC_DIR string = ".newt"
+ const REPOS_FILENAME string = "repos.yml"
+
+ // Contains general newt settings read from $HOME/.newt
+ var newtrc *viper.Viper
+
+ func readNewtrc() *viper.Viper {
+ usr, err := user.Current()
+ if err != nil {
+ log.Warn("Failed to obtain user name")
+ return viper.New()
+ }
+
+ dir := usr.HomeDir + "/" + NEWTRC_DIR
+ v, err := util.ReadConfig(dir, strings.TrimSuffix(REPOS_FILENAME, ".yml"))
+ if err != nil {
+ log.Debugf("Failed to read %s/%s file", dir, REPOS_FILENAME)
+ return viper.New()
+ }
+
+ return v
+ }
+
+ func Newtrc() *viper.Viper {
+ if newtrc != nil {
+ return newtrc
+ }
+
+ newtrc = readNewtrc()
+ return newtrc
+ }
+
+ func GetSliceFeatures(v *viper.Viper, features map[string]bool,
+ key string) []interface{} {
+
+ val := v.Get(key)
+ vals := []interface{}{val}
+
+ // Process the features in alphabetical order to ensure consistent
+ // results across repeated runs.
+ var featureKeys []string
+ for feature, _ := range features {
+ featureKeys = append(featureKeys, feature)
}
sort.Strings(featureKeys)
[17/50] incubator-mynewt-newt git commit: mfg - allow number of
images to be queried.
Posted by cc...@apache.org.
mfg - allow number of images to be queried.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/aa87efd4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/aa87efd4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/aa87efd4
Branch: refs/heads/master
Commit: aa87efd4e107b845948922f44175046581c6d68f
Parents: 141160b
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Oct 28 13:47:52 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Oct 28 13:47:52 2016 -0700
----------------------------------------------------------------------
newt/mfg/mfg.go | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/aa87efd4/newt/mfg/mfg.go
----------------------------------------------------------------------
diff --git a/newt/mfg/mfg.go b/newt/mfg/mfg.go
index 6805ab9..ea31f85 100644
--- a/newt/mfg/mfg.go
+++ b/newt/mfg/mfg.go
@@ -84,3 +84,7 @@ func (mi *MfgImage) sectionIds() []int {
return ids
}
+
+func (mi *MfgImage) NumImages() int {
+ return len(mi.images)
+}
[28/50] incubator-mynewt-newt git commit: newt - continue parsing
yaml files on syntax err
Posted by cc...@apache.org.
newt - continue parsing yaml files on syntax err
Newt now warns about bad files, but proceeds to parse files.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/fe7be9fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/fe7be9fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/fe7be9fe
Branch: refs/heads/master
Commit: fe7be9fe50c8451dcea6d5ab134a137ab324a91b
Parents: 8bc10df
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Nov 3 12:14:28 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Nov 3 12:15:11 2016 -0700
----------------------------------------------------------------------
newt/cli/build_cmds.go | 25 ++------
newt/cli/image_cmds.go | 5 +-
newt/cli/mfg_cmds.go | 6 +-
newt/cli/project_cmds.go | 20 ++-----
newt/cli/run_cmds.go | 5 +-
newt/cli/target_cmds.go | 27 ++-------
newt/cli/util.go | 15 +++++
newt/cli/vars.go | 6 +-
newt/newt.go | 5 --
newt/pkg/localpackage.go | 62 ++++++++++++--------
newt/project/project.go | 13 +++-
newt/vendor/mynewt.apache.org/newt/util/util.go | 17 ++++--
util/util.go | 24 ++++----
13 files changed, 109 insertions(+), 121 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/cli/build_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index 50f77c0..e688d16 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -106,9 +106,7 @@ func buildRunCmd(cmd *cobra.Command, args []string) {
NewtUsage(cmd, nil)
}
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
// Verify and resolve each specified package.
targets, all, err := ResolveTargetsOrAll(args...)
@@ -175,9 +173,7 @@ func cleanRunCmd(cmd *cobra.Command, args []string) {
NewtUsage(cmd, util.NewNewtError("Must specify target"))
}
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
cleanAll := false
targets := []*target.Target{}
@@ -217,10 +213,7 @@ func testRunCmd(cmd *cobra.Command, args []string) {
NewtUsage(cmd, nil)
}
- proj, err := project.TryGetProject()
- if err != nil {
- NewtUsage(nil, err)
- }
+ proj := InitProject()
// Verify and resolve each specified package.
testAll := false
@@ -328,9 +321,7 @@ func loadRunCmd(cmd *cobra.Command, args []string) {
NewtUsage(cmd, util.NewNewtError("Must specify target"))
}
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
t := ResolveTarget(args[0])
if t == nil {
@@ -352,9 +343,7 @@ func debugRunCmd(cmd *cobra.Command, args []string) {
NewtUsage(cmd, util.NewNewtError("Must specify target"))
}
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
t := ResolveTarget(args[0])
if t == nil {
@@ -376,9 +365,7 @@ func sizeRunCmd(cmd *cobra.Command, args []string) {
NewtUsage(cmd, util.NewNewtError("Must specify target"))
}
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
t := ResolveTarget(args[0])
if t == nil {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/cli/image_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/image_cmds.go b/newt/cli/image_cmds.go
index 36e481b..dac2fc2 100644
--- a/newt/cli/image_cmds.go
+++ b/newt/cli/image_cmds.go
@@ -24,7 +24,6 @@ import (
"github.com/spf13/cobra"
"mynewt.apache.org/newt/newt/builder"
- "mynewt.apache.org/newt/newt/project"
"mynewt.apache.org/newt/util"
)
@@ -36,9 +35,7 @@ func createImageRunCmd(cmd *cobra.Command, args []string) {
NewtUsage(cmd, util.NewNewtError("Must specify target and version"))
}
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
targetName := args[0]
t := ResolveTarget(targetName)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/cli/mfg_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/mfg_cmds.go b/newt/cli/mfg_cmds.go
index c306b45..78a2299 100644
--- a/newt/cli/mfg_cmds.go
+++ b/newt/cli/mfg_cmds.go
@@ -24,15 +24,11 @@ import (
"mynewt.apache.org/newt/newt/mfg"
"mynewt.apache.org/newt/newt/pkg"
- "mynewt.apache.org/newt/newt/project"
"mynewt.apache.org/newt/util"
)
func ResolveMfgPkg(pkgName string) (*pkg.LocalPackage, error) {
- proj, err := project.TryGetProject()
- if err != nil {
- return nil, err
- }
+ proj := InitProject()
lpkg, err := proj.ResolvePackage(proj.LocalRepo(), pkgName)
if err != nil {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/cli/project_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/project_cmds.go b/newt/cli/project_cmds.go
index e1377a8..7c0d268 100644
--- a/newt/cli/project_cmds.go
+++ b/newt/cli/project_cmds.go
@@ -75,10 +75,7 @@ func newRunCmd(cmd *cobra.Command, args []string) {
}
func installRunCmd(cmd *cobra.Command, args []string) {
- proj, err := project.TryGetProject()
- if err != nil {
- NewtUsage(nil, err)
- }
+ proj := InitProject()
interfaces.SetProject(proj)
if err := proj.Install(false, projectForce); err != nil {
@@ -87,10 +84,7 @@ func installRunCmd(cmd *cobra.Command, args []string) {
}
func upgradeRunCmd(cmd *cobra.Command, args []string) {
- proj, err := project.TryGetProject()
- if err != nil {
- NewtUsage(nil, err)
- }
+ proj := InitProject()
interfaces.SetProject(proj)
if err := proj.Upgrade(projectForce); err != nil {
@@ -104,10 +98,7 @@ func infoRunCmd(cmd *cobra.Command, args []string) {
reqRepoName = strings.TrimPrefix(args[0], "@")
}
- proj, err := project.TryGetProject()
- if err != nil {
- NewtUsage(nil, err)
- }
+ proj := InitProject()
repoNames := []string{}
for repoName, _ := range proj.PackageList() {
@@ -160,10 +151,7 @@ func infoRunCmd(cmd *cobra.Command, args []string) {
}
func syncRunCmd(cmd *cobra.Command, args []string) {
- proj, err := project.TryGetProject()
- if err != nil {
- NewtUsage(nil, err)
- }
+ proj := InitProject()
repos := proj.Repos()
ps, err := project.LoadProjectState()
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/cli/run_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/run_cmds.go b/newt/cli/run_cmds.go
index 22164a7..ee72e87 100644
--- a/newt/cli/run_cmds.go
+++ b/newt/cli/run_cmds.go
@@ -24,7 +24,6 @@ import (
"github.com/spf13/cobra"
"mynewt.apache.org/newt/newt/builder"
- "mynewt.apache.org/newt/newt/project"
"mynewt.apache.org/newt/util"
)
@@ -33,9 +32,7 @@ func runRunCmd(cmd *cobra.Command, args []string) {
NewtUsage(cmd, util.NewNewtError("Must specify target"))
}
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
t := ResolveTarget(args[0])
if t == nil {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/cli/target_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/target_cmds.go b/newt/cli/target_cmds.go
index a91647e..bb82f32 100644
--- a/newt/cli/target_cmds.go
+++ b/newt/cli/target_cmds.go
@@ -32,7 +32,6 @@ import (
"github.com/spf13/cobra"
"mynewt.apache.org/newt/newt/builder"
"mynewt.apache.org/newt/newt/pkg"
- "mynewt.apache.org/newt/newt/project"
"mynewt.apache.org/newt/newt/syscfg"
"mynewt.apache.org/newt/newt/target"
"mynewt.apache.org/newt/util"
@@ -85,9 +84,7 @@ func pkgVarSliceString(pack *pkg.LocalPackage, key string) string {
}
func targetShowCmd(cmd *cobra.Command, args []string) {
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
targetNames := []string{}
if len(args) == 0 {
for name, _ := range target.GetTargets() {
@@ -196,9 +193,7 @@ func targetSetCmd(cmd *cobra.Command, args []string) {
"(target-name & k=v) to set"))
}
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
// Parse target name.
t, err := resolveExistingTargetArg(args[0])
@@ -278,10 +273,7 @@ func targetCreateCmd(cmd *cobra.Command, args []string) {
NewtUsage(cmd, util.NewNewtError("Missing target name"))
}
- proj, err := project.TryGetProject()
- if err != nil {
- NewtUsage(nil, err)
- }
+ proj := InitProject()
pkgName, err := ResolveNewTargetName(args[0])
if err != nil {
@@ -339,9 +331,7 @@ func targetDelCmd(cmd *cobra.Command, args []string) {
"target to delete"))
}
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
targets, err := ResolveTargets(args...)
if err != nil {
@@ -361,10 +351,7 @@ func targetCopyCmd(cmd *cobra.Command, args []string) {
"source target and one destination target"))
}
- proj, err := project.TryGetProject()
- if err != nil {
- NewtUsage(nil, err)
- }
+ proj := InitProject()
srcTarget, err := resolveExistingTargetArg(args[0])
if err != nil {
@@ -471,9 +458,7 @@ func targetConfigCmd(cmd *cobra.Command, args []string) {
NewtUsage(cmd, util.NewNewtError("Must specify target name"))
}
- if _, err := project.TryGetProject(); err != nil {
- NewtUsage(nil, err)
- }
+ InitProject()
t, err := resolveExistingTargetArg(args[0])
if err != nil {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/cli/util.go
----------------------------------------------------------------------
diff --git a/newt/cli/util.go b/newt/cli/util.go
index 31bd5b9..46ee9b0 100644
--- a/newt/cli/util.go
+++ b/newt/cli/util.go
@@ -197,3 +197,18 @@ func ResetGlobalState() error {
return nil
}
+
+func InitProject() *project.Project {
+ var p *project.Project
+ var err error
+
+ if p, err = project.TryGetProject(); err != nil {
+ NewtUsage(nil, err)
+ }
+
+ for _, w := range p.Warnings() {
+ util.ErrorMessage(util.VERBOSITY_QUIET, "* Warning: %s\n", w)
+ }
+
+ return p
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/cli/vars.go
----------------------------------------------------------------------
diff --git a/newt/cli/vars.go b/newt/cli/vars.go
index 91fe4f4..f741b59 100644
--- a/newt/cli/vars.go
+++ b/newt/cli/vars.go
@@ -25,13 +25,15 @@ import (
"sort"
"strings"
- . "mynewt.apache.org/newt/newt/interfaces"
+ "mynewt.apache.org/newt/newt/interfaces"
"mynewt.apache.org/newt/newt/pkg"
"mynewt.apache.org/newt/newt/project"
"mynewt.apache.org/newt/util"
)
-func varsFromPackageType(pt PackageType, fullPath bool) ([]string, error) {
+func varsFromPackageType(
+ pt interfaces.PackageType, fullPath bool) ([]string, error) {
+
values := []string{}
packs := project.GetProject().PackagesOfType(pt)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/newt.go
----------------------------------------------------------------------
diff --git a/newt/newt.go b/newt/newt.go
index 6135aca..64fa13c 100644
--- a/newt/newt.go
+++ b/newt/newt.go
@@ -116,10 +116,6 @@ func newtCmd() *cobra.Command {
func main() {
cmd := newtCmd()
- /* some of the setup code logs which messes with autocomplete */
- hold_lvl := log.GetLevel()
- log.SetLevel(log.FatalLevel)
-
cli.AddBuildCommands(cmd)
cli.AddCompleteCommands(cmd)
cli.AddImageCommands(cmd)
@@ -147,6 +143,5 @@ func main() {
cmd.SilenceUsage = false
}
- log.SetLevel(hold_lvl)
cmd.Execute()
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/pkg/localpackage.go
----------------------------------------------------------------------
diff --git a/newt/pkg/localpackage.go b/newt/pkg/localpackage.go
index 3e8e325..d984a73 100644
--- a/newt/pkg/localpackage.go
+++ b/newt/pkg/localpackage.go
@@ -401,11 +401,13 @@ func LocalPackageSpecialName(dirName string) bool {
func ReadLocalPackageRecursive(repo *repo.Repo,
pkgList map[string]interfaces.PackageInterface, basePath string,
- pkgName string) error {
+ pkgName string) ([]string, error) {
+
+ var warnings []string
dirList, err := repo.FilteredSearchList(pkgName)
if err != nil {
- return util.NewNewtError(err.Error())
+ return warnings, util.NewNewtError(err.Error())
}
for _, name := range dirList {
@@ -413,41 +415,52 @@ func ReadLocalPackageRecursive(repo *repo.Repo,
continue
}
- if err := ReadLocalPackageRecursive(repo, pkgList, basePath,
- filepath.Join(pkgName, name)); err != nil {
- return err
+ subWarnings, err := ReadLocalPackageRecursive(repo, pkgList,
+ basePath, filepath.Join(pkgName, name))
+ warnings = append(warnings, subWarnings...)
+ if err != nil {
+ return warnings, err
}
}
- if util.NodeNotExist(filepath.Join(basePath, pkgName, PACKAGE_FILE_NAME)) {
- return nil
+ if util.NodeNotExist(filepath.Join(basePath, pkgName,
+ PACKAGE_FILE_NAME)) {
+
+ return warnings, nil
}
pkg, err := LoadLocalPackage(repo, filepath.Join(basePath, pkgName))
if err != nil {
- return err
+ warnings = append(warnings, err.Error())
+ return warnings, nil
}
if oldPkg, ok := pkgList[pkg.Name()]; ok {
oldlPkg := oldPkg.(*LocalPackage)
- return util.FmtNewtError("Multiple packages with same pkg.name=%s "+
- "in repo %s; path1=%s path2=%s", oldlPkg.Name(), repo.Name(),
- oldlPkg.BasePath(), pkg.BasePath())
+ warnings = append(warnings,
+ fmt.Sprintf("Multiple packages with same pkg.name=%s "+
+ "in repo %s; path1=%s path2=%s", oldlPkg.Name(), repo.Name(),
+ oldlPkg.BasePath(), pkg.BasePath()))
+
+ return warnings, nil
}
pkgList[pkg.Name()] = pkg
- return nil
+ return warnings, nil
}
-func ReadLocalPackages(repo *repo.Repo,
- basePath string) (*map[string]interfaces.PackageInterface, error) {
+func ReadLocalPackages(repo *repo.Repo, basePath string) (
+ pkgMap *map[string]interfaces.PackageInterface,
+ warnings []string,
+ err error) {
- pkgList := map[string]interfaces.PackageInterface{}
+ pkgMap = &map[string]interfaces.PackageInterface{}
+ warnings = []string{}
searchPaths, err := repo.FilteredSearchList("")
if err != nil {
- return nil, err
+ return
}
for _, path := range searchPaths {
@@ -457,18 +470,21 @@ func ReadLocalPackages(repo *repo.Repo,
continue
}
- dirList, err := repo.FilteredSearchList(path)
- if err != nil {
- return nil, util.NewNewtError(err.Error())
+ var dirList []string
+ if dirList, err = repo.FilteredSearchList(path); err != nil {
+ return
}
for _, subDir := range dirList {
- if err := ReadLocalPackageRecursive(repo, pkgList, basePath,
- filepath.Join(path, subDir)); err != nil {
- return nil, err
+ var subWarnings []string
+ subWarnings, err = ReadLocalPackageRecursive(repo, *pkgMap,
+ basePath, filepath.Join(path, subDir))
+ warnings = append(warnings, subWarnings...)
+ if err != nil {
+ return
}
}
}
- return &pkgList, nil
+ return
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/project/project.go
----------------------------------------------------------------------
diff --git a/newt/project/project.go b/newt/project/project.go
index 857bcfb..95ee367 100644
--- a/newt/project/project.go
+++ b/newt/project/project.go
@@ -58,7 +58,8 @@ type Project struct {
projState *ProjectState
// Repositories configured on this project
- repos map[string]*repo.Repo
+ repos map[string]*repo.Repo
+ warnings []string
localRepo *repo.Repo
@@ -156,6 +157,10 @@ func (proj *Project) LocalRepo() *repo.Repo {
return proj.localRepo
}
+func (proj *Project) Warnings() []string {
+ return proj.warnings
+}
+
func (proj *Project) upgradeCheck(r *repo.Repo, vers *repo.Version,
force bool) (bool, error) {
rdesc, err := r.GetRepoDesc()
@@ -578,12 +583,14 @@ func (proj *Project) loadPackageList() error {
// packages / store them in the project package list.
repos := proj.Repos()
for name, repo := range repos {
- list, err := pkg.ReadLocalPackages(repo, repo.Path())
+ list, warnings, err := pkg.ReadLocalPackages(repo, repo.Path())
if err != nil {
return err
+ } else {
+ proj.packages[name] = list
}
- proj.packages[name] = list
+ proj.warnings = append(proj.warnings, warnings...)
}
return nil
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/newt/vendor/mynewt.apache.org/newt/util/util.go
----------------------------------------------------------------------
diff --git a/newt/vendor/mynewt.apache.org/newt/util/util.go b/newt/vendor/mynewt.apache.org/newt/util/util.go
index d43f709..21c67bb 100644
--- a/newt/vendor/mynewt.apache.org/newt/util/util.go
+++ b/newt/vendor/mynewt.apache.org/newt/util/util.go
@@ -105,11 +105,13 @@ func ChildNewtError(parent error) *NewtError {
}
// Print Silent, Quiet and Verbose aware status messages to stdout.
-func StatusMessage(level int, message string, args ...interface{}) {
+func WriteMessage(f *os.File, level int, message string,
+ args ...interface{}) {
+
if Verbosity >= level {
str := fmt.Sprintf(message, args...)
- os.Stdout.WriteString(str)
- os.Stdout.Sync()
+ f.WriteString(str)
+ f.Sync()
if logFile != nil {
logFile.WriteString(str)
@@ -117,11 +119,14 @@ func StatusMessage(level int, message string, args ...interface{}) {
}
}
+// Print Silent, Quiet and Verbose aware status messages to stdout.
+func StatusMessage(level int, message string, args ...interface{}) {
+ WriteMessage(os.Stdout, level, message, args...)
+}
+
// Print Silent, Quiet and Verbose aware status messages to stderr.
func ErrorMessage(level int, message string, args ...interface{}) {
- if Verbosity >= level {
- fmt.Fprintf(os.Stderr, message, args...)
- }
+ WriteMessage(os.Stderr, level, message, args...)
}
func NodeExist(path string) bool {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/fe7be9fe/util/util.go
----------------------------------------------------------------------
diff --git a/util/util.go b/util/util.go
index 56cb5c0..21c67bb 100644
--- a/util/util.go
+++ b/util/util.go
@@ -105,11 +105,13 @@ func ChildNewtError(parent error) *NewtError {
}
// Print Silent, Quiet and Verbose aware status messages to stdout.
-func StatusMessage(level int, message string, args ...interface{}) {
+func WriteMessage(f *os.File, level int, message string,
+ args ...interface{}) {
+
if Verbosity >= level {
str := fmt.Sprintf(message, args...)
- os.Stdout.WriteString(str)
- os.Stdout.Sync()
+ f.WriteString(str)
+ f.Sync()
if logFile != nil {
logFile.WriteString(str)
@@ -117,11 +119,14 @@ func StatusMessage(level int, message string, args ...interface{}) {
}
}
+// Print Silent, Quiet and Verbose aware status messages to stdout.
+func StatusMessage(level int, message string, args ...interface{}) {
+ WriteMessage(os.Stdout, level, message, args...)
+}
+
// Print Silent, Quiet and Verbose aware status messages to stderr.
func ErrorMessage(level int, message string, args ...interface{}) {
- if Verbosity >= level {
- fmt.Fprintf(os.Stderr, message, args...)
- }
+ WriteMessage(os.Stderr, level, message, args...)
}
func NodeExist(path string) bool {
@@ -384,13 +389,6 @@ func CopyFile(srcFile string, dstFile string) error {
return ChildNewtError(err)
}
- if err := in.Close(); err != nil {
- return err
- }
- if err := out.Close(); err != nil {
- return err
- }
-
return nil
}
[20/50] incubator-mynewt-newt git commit: newt - Fix additional build
errors for sim apps.
Posted by cc...@apache.org.
newt - Fix additional build errors for sim apps.
For builds, newt was ensuring that the BSP specified a linker script.
This is too strict of a requirement, as the native BSP does not use
custom linker scripts.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/54d3c0b8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/54d3c0b8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/54d3c0b8
Branch: refs/heads/master
Commit: 54d3c0b8382200884f0a077b24317d9c86b31933
Parents: c2fe805
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Oct 31 11:06:42 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Oct 31 11:06:42 2016 -0700
----------------------------------------------------------------------
newt/builder/targetbuild.go | 10 ----------
1 file changed, 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/54d3c0b8/newt/builder/targetbuild.go
----------------------------------------------------------------------
diff --git a/newt/builder/targetbuild.go b/newt/builder/targetbuild.go
index 9274a8d..b6e6fdd 100644
--- a/newt/builder/targetbuild.go
+++ b/newt/builder/targetbuild.go
@@ -332,11 +332,6 @@ func (t *TargetBuilder) buildLoader() error {
/* set up the linker elf and linker script for the app */
t.AppBuilder.linkElf = t.LoaderBuilder.AppLinkerElfPath()
- linkerScript := t.bspPkg.Part2LinkerScript
-
- if linkerScript == "" {
- return util.NewNewtError("BSP must specify linker script ")
- }
return nil
@@ -365,12 +360,7 @@ func (t *TargetBuilder) Build() error {
if err := t.buildLoader(); err != nil {
return err
}
-
linkerScript = t.bspPkg.Part2LinkerScript
- if linkerScript == "" {
- return util.NewNewtError(
- "BSP does not specify part 2 linker script for split image")
- }
}
/* Link the app. */
[23/50] incubator-mynewt-newt git commit: newtmgr;
also do oic with newtmgr over ble.
Posted by cc...@apache.org.
newtmgr; also do oic with newtmgr over ble.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/22cf2700
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/22cf2700
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/22cf2700
Branch: refs/heads/master
Commit: 22cf27005d16c278e03c3d75c94aa7294e8e9fa5
Parents: c2fe805
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Nov 1 12:18:33 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Nov 1 12:18:33 2016 -0700
----------------------------------------------------------------------
newtmgr/transport/connble.go | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/22cf2700/newtmgr/transport/connble.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connble.go b/newtmgr/transport/connble.go
index f0ad978..e8bcb66 100644
--- a/newtmgr/transport/connble.go
+++ b/newtmgr/transport/connble.go
@@ -36,6 +36,10 @@ var CharDisc = make(chan bool)
var newtmgrServiceId = gatt.MustParseUUID("8D53DC1D-1DB7-4CD3-868B-8A527460AA84")
var newtmgrServiceCharId = gatt.MustParseUUID("DA2E7828-FBCE-4E01-AE9E-261174997C48")
+
+var newtmgrCoapServiceId = gatt.MustParseUUID("e3f9f9c4-8a83-4055-b647-728b769745d6")
+var newtmgrCoapServiceCharId = gatt.MustParseUUID("e467fee6-d6bb-4956-94df-0090350631f5")
+
var deviceName string
var deviceAddress []byte
var deviceAddressType uint8
@@ -110,15 +114,25 @@ func onPeriphConnected(p gatt.Peripheral, err error) {
return
}
+ var isCoap bool = false
+
for _, service := range services {
- if service.UUID().Equal(newtmgrServiceId) {
+ if service.UUID().Equal(newtmgrServiceId) ||
+ service.UUID().Equal(newtmgrCoapServiceId) {
log.Debugf("Newtmgr Service Found %s", service.Name())
+ if service.UUID().Equal(newtmgrCoapServiceId) {
+ isCoap = true
+ }
+
cs, _ := p.DiscoverCharacteristics(nil, service)
for _, c := range cs {
- if c.UUID().Equal(newtmgrServiceCharId) {
+ if (isCoap == false &&
+ c.UUID().Equal(newtmgrServiceCharId)) ||
+ (isCoap == true &&
+ c.UUID().Equal(newtmgrCoapServiceCharId)) {
log.Debugf("Newtmgr Characteristic Found")
p.SetNotifyValue(c, newtmgrNotifyCB)
deviceChar = c
[25/50] incubator-mynewt-newt git commit: MYNEWT-139: Add runtest
command to newtmgr
Posted by cc...@apache.org.
MYNEWT-139: Add runtest command to newtmgr
Add runtest command to launch test on target devices.
This is a partial checkin which simply allows the tests to run,
future enhancements should include specifying which test suite to run.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/a1cb7024
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/a1cb7024
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/a1cb7024
Branch: refs/heads/master
Commit: a1cb7024e927c7f17601dbc120ca0c5c08acf49c
Parents: c30dc2d
Author: Peter Snyder <pe...@apache.org>
Authored: Tue Nov 1 16:02:00 2016 -0700
Committer: Peter Snyder <pe...@apache.org>
Committed: Tue Nov 1 16:04:13 2016 -0700
----------------------------------------------------------------------
newtmgr/cli/commands.go | 1 +
newtmgr/cli/runtest.go | 92 ++++++++++++++++++++++++++++++++++++++++
newtmgr/protocol/defs.go | 1 +
newtmgr/protocol/runtest.go | 68 +++++++++++++++++++++++++++++
4 files changed, 162 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a1cb7024/newtmgr/cli/commands.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/commands.go b/newtmgr/cli/commands.go
index bbcb4a1..39ede96 100644
--- a/newtmgr/cli/commands.go
+++ b/newtmgr/cli/commands.go
@@ -67,6 +67,7 @@ func Commands() *cobra.Command {
nmCmd.AddCommand(dTimeCmd())
nmCmd.AddCommand(resetCmd())
nmCmd.AddCommand(crashCmd())
+ nmCmd.AddCommand(runtestCmd())
return nmCmd
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a1cb7024/newtmgr/cli/runtest.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/runtest.go b/newtmgr/cli/runtest.go
new file mode 100644
index 0000000..b7a83a3
--- /dev/null
+++ b/newtmgr/cli/runtest.go
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package cli
+
+import (
+ "fmt"
+ "time"
+
+ "github.com/spf13/cobra"
+ "mynewt.apache.org/newt/newtmgr/config"
+ "mynewt.apache.org/newt/newtmgr/protocol"
+ "mynewt.apache.org/newt/newtmgr/transport"
+)
+
+func runtestRunCmd(cmd *cobra.Command, args []string) {
+ cpm, err := config.NewConnProfileMgr()
+ if err != nil {
+ nmUsage(cmd, err)
+ }
+
+ profile, err := cpm.GetConnProfile(ConnProfileName)
+ if err != nil {
+ nmUsage(cmd, err)
+ }
+
+ conn, err := transport.NewConnWithTimeout(profile, time.Second*1)
+ if err != nil {
+ nmUsage(cmd, err)
+ }
+ defer conn.Close()
+
+ runner, err := protocol.NewCmdRunner(conn)
+ if err != nil {
+ nmUsage(cmd, err)
+ }
+
+ runtest, err := protocol.RunTest()
+ if err != nil {
+ nmUsage(cmd, err)
+ }
+
+ nmr, err := runtest.EncodeWriteRequest()
+ if err != nil {
+ nmUsage(cmd, err)
+ }
+
+ if err := runner.WriteReq(nmr); err != nil {
+ nmUsage(cmd, err)
+ }
+
+ rsp, err := runner.ReadResp()
+ if err == nil {
+ cRsp, err := protocol.DecodeRunTestResponse(rsp.Data)
+ if err != nil {
+ nmUsage(cmd, err)
+ }
+ if cRsp.Err != 0 {
+ fmt.Printf("Failed, error:%d\n", cRsp.Err)
+ }
+ }
+ fmt.Println("Done")
+}
+
+func runtestCmd() *cobra.Command {
+ runtestEx := " runtest "
+
+ runtestCmd := &cobra.Command{
+ Use: "runtest ",
+ Short: "Initiate named test on remote endpoint using newtmgr (named test not yet supported)",
+ Example: runtestEx,
+ Run: runtestRunCmd,
+ }
+
+ return runtestCmd
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a1cb7024/newtmgr/protocol/defs.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/defs.go b/newtmgr/protocol/defs.go
index 6724661..8212d7f 100644
--- a/newtmgr/protocol/defs.go
+++ b/newtmgr/protocol/defs.go
@@ -26,6 +26,7 @@ const (
NMGR_GROUP_ID_LOGS = 4
NMGR_GROUP_ID_CRASH = 5
NMGR_GROUP_ID_SPLIT = 6
+ NMGR_GROUP_ID_RUNTEST = 7
NMGR_GROUP_ID_PERUSER = 64
)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a1cb7024/newtmgr/protocol/runtest.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/runtest.go b/newtmgr/protocol/runtest.go
new file mode 100644
index 0000000..4f5693f
--- /dev/null
+++ b/newtmgr/protocol/runtest.go
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package protocol
+
+import (
+ "fmt"
+
+ "github.com/ugorji/go/codec"
+ "mynewt.apache.org/newt/util"
+)
+
+type Test struct {
+ Err int `codec:"rc,omitempty"`
+}
+
+func RunTest() (*Test, error) {
+ c := &Test{ }
+ return c, nil
+}
+
+func (c *Test) EncodeWriteRequest() (*NmgrReq, error) {
+ data := make([]byte, 0)
+ enc := codec.NewEncoderBytes(&data, new(codec.CborHandle))
+ enc.Encode(c)
+
+ fmt.Printf("runtest\n")
+ nmr, err := NewNmgrReq()
+ if err != nil {
+ return nil, err
+ }
+
+ nmr.Op = NMGR_OP_WRITE
+ nmr.Flags = 0
+ nmr.Group = NMGR_GROUP_ID_RUNTEST
+ nmr.Id = 0
+ nmr.Len = uint16(len(data))
+ nmr.Data = data
+
+ return nmr, nil
+}
+
+func DecodeRunTestResponse(data []byte) (*Test, error) {
+ c := &Test{}
+
+ dec := codec.NewDecoderBytes(data, new(codec.CborHandle))
+ if err := dec.Decode(&c); err != nil {
+ return nil, util.NewNewtError(fmt.Sprintf("Invalid response: %s",
+ err.Error()))
+ }
+ return c, nil
+}
[50/50] incubator-mynewt-newt git commit: newt - Remove duplicate
code introduced in merge.
Posted by cc...@apache.org.
newt - Remove duplicate code introduced in merge.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/00ec2a34
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/00ec2a34
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/00ec2a34
Branch: refs/heads/master
Commit: 00ec2a3494d2dc0d64e0f347bae6ba5f184f16ed
Parents: 48599c1
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Nov 10 11:54:29 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Nov 10 11:54:29 2016 -0800
----------------------------------------------------------------------
newt/newtutil/newtutil.go | 77 ------------------------------------------
1 file changed, 77 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/00ec2a34/newt/newtutil/newtutil.go
----------------------------------------------------------------------
diff --git a/newt/newtutil/newtutil.go b/newt/newtutil/newtutil.go
index 79b3cef..d7369d9 100644
--- a/newt/newtutil/newtutil.go
+++ b/newt/newtutil/newtutil.go
@@ -113,83 +113,6 @@ func GetStringMapFeatures(v *viper.Viper, features map[string]bool,
return result
}
-const NEWTRC_DIR string = ".newt"
-const REPOS_FILENAME string = "repos.yml"
-
-// Contains general newt settings read from $HOME/.newt
-var newtrc *viper.Viper
-
-func readNewtrc() *viper.Viper {
- usr, err := user.Current()
- if err != nil {
- log.Warn("Failed to obtain user name")
- return viper.New()
- }
-
- dir := usr.HomeDir + "/" + NEWTRC_DIR
- v, err := util.ReadConfig(dir, strings.TrimSuffix(REPOS_FILENAME, ".yml"))
- if err != nil {
- log.Debugf("Failed to read %s/%s file", dir, REPOS_FILENAME)
- return viper.New()
- }
-
- return v
-}
-
-func Newtrc() *viper.Viper {
- if newtrc != nil {
- return newtrc
- }
-
- newtrc = readNewtrc()
- return newtrc
-}
-
-func GetSliceFeatures(v *viper.Viper, features map[string]bool,
- key string) []interface{} {
-
- val := v.Get(key)
- vals := []interface{}{val}
-
- // Process the features in alphabetical order to ensure consistent
- // results across repeated runs.
- var featureKeys []string
- for feature, _ := range features {
- featureKeys = append(featureKeys, feature)
- }
- sort.Strings(featureKeys)
-
- for _, feature := range featureKeys {
- overwriteVal := v.Get(key + "." + feature + ".OVERWRITE")
- if overwriteVal != nil {
- return []interface{}{overwriteVal}
- }
-
- appendVal := v.Get(key + "." + feature)
- if appendVal != nil {
- vals = append(vals, appendVal)
- }
- }
-
- return vals
-}
-
-func GetStringMapFeatures(v *viper.Viper, features map[string]bool,
- key string) map[string]interface{} {
-
- result := map[string]interface{}{}
-
- slice := GetSliceFeatures(v, features, key)
- for _, itf := range slice {
- sub := cast.ToStringMap(itf)
- for k, v := range sub {
- result[k] = v
- }
- }
-
- return result
-}
-
func GetStringFeatures(v *viper.Viper, features map[string]bool,
key string) string {
val := v.GetString(key)
[29/50] incubator-mynewt-newt git commit: MYNEWT-139: Add TEST log
type.
Posted by cc...@apache.org.
MYNEWT-139: Add TEST log type.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/9a4dd3e0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/9a4dd3e0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/9a4dd3e0
Branch: refs/heads/master
Commit: 9a4dd3e00aec1270c8b5fbd95bc3843b4736cf75
Parents: fe7be9f
Author: Peter Snyder <pe...@apache.org>
Authored: Thu Nov 3 14:28:10 2016 -0700
Committer: Peter Snyder <pe...@apache.org>
Committed: Thu Nov 3 14:28:10 2016 -0700
----------------------------------------------------------------------
newtmgr/cli/logs.go | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/9a4dd3e0/newtmgr/cli/logs.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/logs.go b/newtmgr/cli/logs.go
index e3bae23..978bbbf 100644
--- a/newtmgr/cli/logs.go
+++ b/newtmgr/cli/logs.go
@@ -52,6 +52,7 @@ const (
MODULE_NIMBLE_HOST uint64 = 4
MODULE_NFFS uint64 = 5
MODULE_REBOOT uint64 = 6
+ MODULE_TEST uint64 = 8
MODULE_MAX uint64 = 255
)
@@ -72,6 +73,8 @@ func LogModuleToString(lm uint64) string {
s = "NFFS"
case MODULE_REBOOT:
s = "REBOOT"
+ case MODULE_TEST:
+ s = "TEST"
default:
s = "CUSTOM"
}
[10/50] incubator-mynewt-newt git commit: newt;
native targets don't have linker scripts. Don't error out.
Posted by cc...@apache.org.
newt; native targets don't have linker scripts. Don't error out.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/609bd6a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/609bd6a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/609bd6a0
Branch: refs/heads/master
Commit: 609bd6a044f61bd00121bf50e8961026effbce06
Parents: 059bd7a
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Oct 26 11:57:17 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Oct 26 11:57:17 2016 -0700
----------------------------------------------------------------------
newt/builder/targetbuild.go | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/609bd6a0/newt/builder/targetbuild.go
----------------------------------------------------------------------
diff --git a/newt/builder/targetbuild.go b/newt/builder/targetbuild.go
index 7d1dce3..9274a8d 100644
--- a/newt/builder/targetbuild.go
+++ b/newt/builder/targetbuild.go
@@ -361,9 +361,6 @@ func (t *TargetBuilder) Build() error {
linkerScript := ""
if t.LoaderBuilder == nil {
linkerScript = t.bspPkg.LinkerScript
- if linkerScript == "" {
- return util.NewNewtError("BSP does not specify linker script")
- }
} else {
if err := t.buildLoader(); err != nil {
return err
[35/50] incubator-mynewt-newt git commit: newtmgr;
advertise wdog as a crash option.
Posted by cc...@apache.org.
newtmgr; advertise wdog as a crash option.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/22305a32
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/22305a32
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/22305a32
Branch: refs/heads/master
Commit: 22305a3235e56cd95be2ae3e1bf358d4b7ee6e4e
Parents: 3bee267
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Nov 7 09:53:50 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 7 09:53:50 2016 -0800
----------------------------------------------------------------------
newtmgr/cli/crash.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/22305a32/newtmgr/cli/crash.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/crash.go b/newtmgr/cli/crash.go
index 9f8e6b2..9f740db 100644
--- a/newtmgr/cli/crash.go
+++ b/newtmgr/cli/crash.go
@@ -87,7 +87,7 @@ func crashCmd() *cobra.Command {
crashEx := " newtmgr -c olimex crash div0\n"
crashCmd := &cobra.Command{
- Use: "crash [div0|jump0|ref0|assert]",
+ Use: "crash [div0|jump0|ref0|assert|wdog]",
Short: "Send crash command to remote endpoint using newtmgr",
Example: crashEx,
Run: crashRunCmd,
[11/50] incubator-mynewt-newt git commit: newtmgr connudp;
remove accidentally left in debug message.
Posted by cc...@apache.org.
newtmgr connudp; remove accidentally left in debug message.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/db57da14
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/db57da14
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/db57da14
Branch: refs/heads/master
Commit: db57da14046dd4b18f3a0681210f8ad89d83dfff
Parents: 609bd6a
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Oct 26 12:08:27 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Oct 26 12:08:27 2016 -0700
----------------------------------------------------------------------
newtmgr/transport/connudp.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/db57da14/newtmgr/transport/connudp.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connudp.go b/newtmgr/transport/connudp.go
index 0be57b6..5c5a775 100644
--- a/newtmgr/transport/connudp.go
+++ b/newtmgr/transport/connudp.go
@@ -89,7 +89,7 @@ func (cs *ConnUDP) ReadPacket() (*Packet, error) {
err.Error()))
}
data = data[0:nr]
- fmt.Printf("Received message from %v %d\n", srcAddr, nr)
+
pkt, err := NewPacket(uint16(nr))
if err != nil {
return nil, err
[27/50] incubator-mynewt-newt git commit: newt;
pass additional parameters to download/debug scripts. You can control
whether debug script should start gdb or not.
Posted by cc...@apache.org.
newt; pass additional parameters to download/debug scripts. You can control
whether debug script should start gdb or not.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/8bc10df3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/8bc10df3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/8bc10df3
Branch: refs/heads/master
Commit: 8bc10df343c8c5c248a3f73ea917d06f972f4376
Parents: cc1c2dd
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 3 11:49:36 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Nov 3 11:56:24 2016 -0700
----------------------------------------------------------------------
newt/builder/load.go | 37 ++++++++++++++++++++++++++++++-------
newt/cli/build_cmds.go | 5 ++++-
newt/cli/run_cmds.go | 5 ++++-
3 files changed, 38 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8bc10df3/newt/builder/load.go
----------------------------------------------------------------------
diff --git a/newt/builder/load.go b/newt/builder/load.go
index 2fd4e7f..46cb506 100644
--- a/newt/builder/load.go
+++ b/newt/builder/load.go
@@ -72,6 +72,8 @@ func Load(binBaseName string, bspPkg *pkg.BspPackage,
envSettings += fmt.Sprintf("%s=\"%s\" ", key, extraEnvSettings[key])
}
+ coreRepo := project.GetProject().FindRepo("apache-mynewt-core")
+ envSettings += fmt.Sprintf("CORE_PATH=\"%s\" ", coreRepo.Path())
envSettings += fmt.Sprintf("BSP_PATH=\"%s\" ", bspPath)
envSettings += fmt.Sprintf("BIN_BASENAME=\"%s\" ", binBaseName)
@@ -82,9 +84,8 @@ func Load(binBaseName string, bspPkg *pkg.BspPackage,
util.StatusMessage(util.VERBOSITY_VERBOSE, "Load command: %s\n",
downloadCmd)
- rsp, err := util.ShellCommand(downloadCmd)
+ _, err := util.ShellCommand(downloadCmd)
if err != nil {
- util.StatusMessage(util.VERBOSITY_DEFAULT, "%s", rsp)
return err
}
util.StatusMessage(util.VERBOSITY_VERBOSE, "Successfully loaded image.\n")
@@ -110,17 +111,33 @@ func (b *Builder) Load(imageSlot int, extraJtagCmd string) error {
if extraJtagCmd != "" {
envSettings["EXTRA_JTAG_CMD"] = extraJtagCmd
}
-
features := b.cfg.Features()
+ var flashTargetArea string
if _, ok := features["BOOT_LOADER"]; ok {
+ envSettings["BOOT_LOADER"] = "1"
+
+ flashTargetArea = "FLASH_AREA_BOOTLOADER"
util.StatusMessage(util.VERBOSITY_DEFAULT,
"Loading bootloader\n")
} else {
+ if imageSlot == 0 {
+ flashTargetArea = "FLASH_AREA_IMAGE_0"
+ } else if imageSlot == 1 {
+ flashTargetArea = "FLASH_AREA_IMAGE_1"
+ }
util.StatusMessage(util.VERBOSITY_DEFAULT,
"Loading %s image into slot %d\n", b.buildName, imageSlot+1)
}
+ bspPkg := b.targetBuilder.bspPkg
+ tgtArea := bspPkg.FlashMap.Areas[flashTargetArea]
+ if tgtArea.Name == "" {
+ return util.NewNewtError(fmt.Sprintf("No flash target area %s\n",
+ flashTargetArea))
+ }
+ envSettings["FLASH_OFFSET"] = "0x" + strconv.FormatInt(int64(tgtArea.Offset), 16)
+
if err := Load(b.AppBinBasePath(), b.targetBuilder.bspPkg,
envSettings); err != nil {
@@ -132,7 +149,7 @@ func (b *Builder) Load(imageSlot int, extraJtagCmd string) error {
return nil
}
-func (t *TargetBuilder) Debug(extraJtagCmd string, reset bool) error {
+func (t *TargetBuilder) Debug(extraJtagCmd string, reset bool, noGDB bool) error {
//var additional_libs []string
err := t.PrepBuild()
@@ -141,12 +158,12 @@ func (t *TargetBuilder) Debug(extraJtagCmd string, reset bool) error {
}
if t.LoaderBuilder == nil {
- return t.AppBuilder.Debug(extraJtagCmd, reset)
+ return t.AppBuilder.Debug(extraJtagCmd, reset, noGDB)
}
- return t.LoaderBuilder.Debug(extraJtagCmd, reset)
+ return t.LoaderBuilder.Debug(extraJtagCmd, reset, noGDB)
}
-func (b *Builder) Debug(extraJtagCmd string, reset bool) error {
+func (b *Builder) Debug(extraJtagCmd string, reset bool, noGDB bool) error {
if b.appPkg == nil {
return util.NewNewtError("app package not specified")
}
@@ -163,7 +180,9 @@ func (b *Builder) Debug(extraJtagCmd string, reset bool) error {
binBaseName := b.AppBinBasePath()
featureString := b.FeatureString()
+ coreRepo := project.GetProject().FindRepo("apache-mynewt-core")
envSettings := []string{
+ fmt.Sprintf("CORE_PATH=%s", coreRepo.Path()),
fmt.Sprintf("BSP_PATH=%s", bspPath),
fmt.Sprintf("BIN_BASENAME=%s", binBaseName),
fmt.Sprintf("FEATURES=\"%s\"", featureString),
@@ -175,6 +194,10 @@ func (b *Builder) Debug(extraJtagCmd string, reset bool) error {
if reset == true {
envSettings = append(envSettings, fmt.Sprintf("RESET=true"))
}
+ if noGDB == true {
+ envSettings = append(envSettings, fmt.Sprintf("NO_GDB=1"))
+ }
+
debugScript := filepath.Join(bspPath, b.targetBuilder.bspPkg.DebugScript)
os.Chdir(project.GetProject().Path())
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8bc10df3/newt/cli/build_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index 26f3f07..50f77c0 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -99,6 +99,7 @@ func pkgToUnitTests(pack *pkg.LocalPackage) []*pkg.LocalPackage {
}
var extraJtagCmd string
+var noGDB_flag bool
func buildRunCmd(cmd *cobra.Command, args []string) {
if len(args) < 1 {
@@ -365,7 +366,7 @@ func debugRunCmd(cmd *cobra.Command, args []string) {
NewtUsage(nil, err)
}
- if err := b.Debug(extraJtagCmd, false); err != nil {
+ if err := b.Debug(extraJtagCmd, false, noGDB_flag); err != nil {
NewtUsage(cmd, err)
}
}
@@ -448,6 +449,8 @@ func AddBuildCommands(cmd *cobra.Command) {
cmd.AddCommand(debugCmd)
debugCmd.PersistentFlags().StringVarP(&extraJtagCmd, "extrajtagcmd", "j", "",
"extra commands to send to JTAG software")
+ debugCmd.PersistentFlags().BoolVarP(&noGDB_flag, "noGDB", "n", false,
+ "don't start GDB from command line")
sizeHelpText := "Calculate the size of target components specified by " +
"<target-name>."
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8bc10df3/newt/cli/run_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/run_cmds.go b/newt/cli/run_cmds.go
index 19c3a0e..22164a7 100644
--- a/newt/cli/run_cmds.go
+++ b/newt/cli/run_cmds.go
@@ -73,7 +73,7 @@ func runRunCmd(cmd *cobra.Command, args []string) {
if err := b.Load(extraJtagCmd); err != nil {
NewtUsage(nil, err)
}
- if err := b.Debug(extraJtagCmd, true); err != nil {
+ if err := b.Debug(extraJtagCmd, true, noGDB_flag); err != nil {
NewtUsage(nil, err)
}
}
@@ -99,4 +99,7 @@ func AddRunCommands(cmd *cobra.Command) {
runCmd.PersistentFlags().StringVarP(&extraJtagCmd, "extrajtagcmd", "j", "",
"extra commands to send to JTAG software")
+ runCmd.PersistentFlags().BoolVarP(&noGDB_flag, "noGDB", "n", false,
+ "don't start GDB from command line")
+
}
[42/50] incubator-mynewt-newt git commit: updated version string
Posted by cc...@apache.org.
updated version string
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/ef4522e2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/ef4522e2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/ef4522e2
Branch: refs/heads/master
Commit: ef4522e229743556d6d82b74b503d19aa3be9070
Parents: 38b34ef
Author: David G. Simmons <sa...@mac.com>
Authored: Wed Nov 9 13:27:15 2016 -0500
Committer: David G. Simmons <sa...@mac.com>
Committed: Wed Nov 9 13:27:15 2016 -0500
----------------------------------------------------------------------
newt/newtutil/newtutil.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/ef4522e2/newt/newtutil/newtutil.go
----------------------------------------------------------------------
diff --git a/newt/newtutil/newtutil.go b/newt/newtutil/newtutil.go
index 0daa992..9b99010 100644
--- a/newt/newtutil/newtutil.go
+++ b/newt/newtutil/newtutil.go
@@ -29,8 +29,8 @@ import (
"mynewt.apache.org/newt/viper"
)
-var NewtVersionStr string = "Apache Newt (incubating) version: 0.9.0"
-var NewtBlinkyTag string = "mynewt_0_9_0_tag"
+var NewtVersionStr string = "Apache Newt (incubating) version: 1.0.0-develop"
+var NewtBlinkyTag string = "mynewt_1_0_0_develop_tag"
func GetStringFeatures(v *viper.Viper, features map[string]bool,
key string) string {
[05/50] incubator-mynewt-newt git commit: add a bit of extra time for
these multi-segment frames for the slow platforms to extract them from their
receive buffer and continue processing.
Posted by cc...@apache.org.
add a bit of extra time for these multi-segment frames for the slow platforms to extract them
from their receive buffer and continue processing.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/09bd4f97
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/09bd4f97
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/09bd4f97
Branch: refs/heads/master
Commit: 09bd4f97a3b0431528b608f7f833972b430e315f
Parents: 611d95b
Author: paulfdietrich <pa...@yahoo.com>
Authored: Wed Oct 26 09:10:13 2016 -0700
Committer: paulfdietrich <pa...@yahoo.com>
Committed: Wed Oct 26 09:11:45 2016 -0700
----------------------------------------------------------------------
newtmgr/transport/connserial.go | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/09bd4f97/newtmgr/transport/connserial.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connserial.go b/newtmgr/transport/connserial.go
index 37514a0..b97dd07 100644
--- a/newtmgr/transport/connserial.go
+++ b/newtmgr/transport/connserial.go
@@ -217,6 +217,10 @@ func (cs *ConnSerial) WritePacket(pkt *Packet) error {
if written == 0 {
cs.writeData([]byte{6, 9})
} else {
+ /* slower platforms take some time to process each segment
+ * and have very small receive buffers. Give them a bit of
+ * time here */
+ time.Sleep(20 * time.Millisecond)
cs.writeData([]byte{4, 20})
}
[34/50] incubator-mynewt-newt git commit: newt - Include meta
section+offset in mfg manifest
Posted by cc...@apache.org.
newt - Include meta section+offset in mfg manifest
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/3bee2678
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/3bee2678
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/3bee2678
Branch: refs/heads/master
Commit: 3bee26785ceb293e49b3126b70fe6a7b0608718e
Parents: 9dbb073
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Nov 4 18:56:55 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Nov 4 18:56:55 2016 -0700
----------------------------------------------------------------------
newt/mfg/create.go | 69 ++++++++++++++++++++++++++++++-------------------
newt/mfg/meta.go | 23 ++++++++++-------
2 files changed, 55 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/3bee2678/newt/mfg/create.go
----------------------------------------------------------------------
diff --git a/newt/mfg/create.go b/newt/mfg/create.go
index fc11f75..7eaf982 100644
--- a/newt/mfg/create.go
+++ b/newt/mfg/create.go
@@ -36,8 +36,18 @@ import (
)
type mfgManifest struct {
- BuildTime string `json:"build_time"`
- MfgHash string `json:"mfg_hash"`
+ BuildTime string `json:"build_time"`
+ MfgHash string `json:"mfg_hash"`
+ MetaSection int `json:"meta_section"`
+ MetaOffset int `json:"meta_offset"`
+}
+
+type createState struct {
+ // {0:[section0blob], 1:[section1blob], ...}
+ dsMap map[int][]byte
+ metaOffset int
+ hashOffset int
+ hash []byte
}
func insertPartIntoBlob(blob []byte, part mfgPart) {
@@ -201,37 +211,41 @@ func (mi *MfgImage) deviceSectionMap() (map[int][]byte, error) {
return dsMap, nil
}
-// @return [section0blob, section1blob,...], hash, err
-func (mi *MfgImage) createSections() (map[int][]byte, []byte, error) {
- dsMap, err := mi.deviceSectionMap()
+func (mi *MfgImage) createSections() (createState, error) {
+ cs := createState{}
+
+ var err error
+
+ cs.dsMap, err = mi.deviceSectionMap()
if err != nil {
- return nil, nil, err
+ return cs, err
}
- if dsMap[0] == nil {
+ if cs.dsMap[0] == nil {
panic("Invalid state; no section 0")
}
- hashOffset, err := insertMeta(dsMap[0], mi.bsp.FlashMap)
+ cs.metaOffset, cs.hashOffset, err = insertMeta(cs.dsMap[0],
+ mi.bsp.FlashMap)
if err != nil {
- return nil, nil, err
+ return cs, err
}
// Calculate manufacturing hash.
- devices := make([]int, 0, len(dsMap))
- for device, _ := range dsMap {
+ devices := make([]int, 0, len(cs.dsMap))
+ for device, _ := range cs.dsMap {
devices = append(devices, device)
}
sort.Ints(devices)
sections := make([][]byte, len(devices))
for i, device := range devices {
- sections[i] = dsMap[device]
+ sections[i] = cs.dsMap[device]
}
- hash := calcMetaHash(sections)
- copy(dsMap[0][hashOffset:hashOffset+META_HASH_SZ], hash)
+ cs.hash = calcMetaHash(sections)
+ copy(cs.dsMap[0][cs.hashOffset:cs.hashOffset+META_HASH_SZ], cs.hash)
- return dsMap, hash, nil
+ return cs, nil
}
func areaNameFromImgIdx(imgIdx int) (string, error) {
@@ -403,24 +417,25 @@ func (mi *MfgImage) FromPaths() []string {
return paths
}
-// @return [section0blob, section1blob,...], hash, err
-func (mi *MfgImage) build() (map[int][]byte, []byte, error) {
+func (mi *MfgImage) build() (createState, error) {
if err := mi.copyBinFiles(); err != nil {
- return nil, nil, err
+ return createState{}, err
}
- sections, hash, err := mi.createSections()
+ cs, err := mi.createSections()
if err != nil {
- return nil, nil, err
+ return cs, err
}
- return sections, hash, nil
+ return cs, nil
}
-func (mi *MfgImage) createManifest(hash []byte) ([]byte, error) {
+func (mi *MfgImage) createManifest(cs createState) ([]byte, error) {
manifest := mfgManifest{
- BuildTime: time.Now().Format(time.RFC3339),
- MfgHash: fmt.Sprintf("%x", hash),
+ BuildTime: time.Now().Format(time.RFC3339),
+ MfgHash: fmt.Sprintf("%x", cs.hash),
+ MetaSection: 0,
+ MetaOffset: cs.metaOffset,
}
buffer, err := json.MarshalIndent(manifest, "", " ")
if err != nil {
@@ -462,7 +477,7 @@ func (mi *MfgImage) ToPaths() []string {
// @return [paths-of-artifacts], error
func (mi *MfgImage) CreateMfgImage() ([]string, error) {
- sections, hash, err := mi.build()
+ cs, err := mi.build()
if err != nil {
return nil, err
}
@@ -472,14 +487,14 @@ func (mi *MfgImage) CreateMfgImage() ([]string, error) {
return nil, util.ChildNewtError(err)
}
- for device, section := range sections {
+ for device, section := range cs.dsMap {
sectionPath := MfgSectionBinPath(mi.basePkg.Name(), device)
if err := ioutil.WriteFile(sectionPath, section, 0644); err != nil {
return nil, util.ChildNewtError(err)
}
}
- manifest, err := mi.createManifest(hash)
+ manifest, err := mi.createManifest(cs)
if err != nil {
return nil, err
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/3bee2678/newt/mfg/meta.go
----------------------------------------------------------------------
diff --git a/newt/mfg/meta.go b/newt/mfg/meta.go
index 796f08e..58c3684 100644
--- a/newt/mfg/meta.go
+++ b/newt/mfg/meta.go
@@ -129,37 +129,40 @@ func writeZeroHash(buf *bytes.Buffer) error {
return writeElem(tlv, buf)
}
-// @return Hash offset, error
-func insertMeta(section0Data []byte, flashMap flash.FlashMap) (int, error) {
+// @return meta-offset, hash-offset, error
+func insertMeta(section0Data []byte, flashMap flash.FlashMap) (
+ int, int, error) {
+
buf := &bytes.Buffer{}
if err := writeHeader(buf); err != nil {
- return 0, err
+ return 0, 0, err
}
for _, area := range flashMap.SortedAreas() {
if err := writeFlashArea(area, buf); err != nil {
- return 0, err
+ return 0, 0, err
}
}
if err := writeZeroHash(buf); err != nil {
- return 0, err
+ return 0, 0, err
}
hashSubOff := buf.Len() - META_HASH_SZ
if err := writeFooter(buf); err != nil {
- return 0, err
+ return 0, 0, err
}
// The meta region gets placed at the very end of the boot loader slot.
bootArea, ok := flashMap.Areas[flash.FLASH_AREA_NAME_BOOTLOADER]
if !ok {
- return 0, util.NewNewtError("Required boot loader flash area missing")
+ return 0, 0,
+ util.NewNewtError("Required boot loader flash area missing")
}
if bootArea.Size < buf.Len() {
- return 0, util.FmtNewtError(
+ return 0, 0, util.FmtNewtError(
"Boot loader flash area too small to accommodate meta region; "+
"boot=%d meta=%d", bootArea.Size, buf.Len())
}
@@ -167,7 +170,7 @@ func insertMeta(section0Data []byte, flashMap flash.FlashMap) (int, error) {
metaOff := bootArea.Offset + bootArea.Size - buf.Len()
for i := metaOff; i < bootArea.Size; i++ {
if section0Data[i] != 0xff {
- return 0, util.FmtNewtError(
+ return 0, 0, util.FmtNewtError(
"Boot loader extends into meta region; "+
"meta region starts at offset %d", metaOff)
}
@@ -177,7 +180,7 @@ func insertMeta(section0Data []byte, flashMap flash.FlashMap) (int, error) {
// still zeroed.
copy(section0Data[metaOff:], buf.Bytes())
- return metaOff + hashSubOff, nil
+ return metaOff, metaOff + hashSubOff, nil
}
func calcMetaHash(sections [][]byte) []byte {
[12/50] incubator-mynewt-newt git commit: newtmgr connudp;
add back the msg about source of response, but only if debug flag is
set.
Posted by cc...@apache.org.
newtmgr connudp; add back the msg about source of response, but only
if debug flag is set.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/ef941d4e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/ef941d4e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/ef941d4e
Branch: refs/heads/master
Commit: ef941d4e84c1b4ce26cb6a5fa3c6fee194b778c8
Parents: db57da1
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Oct 26 12:46:37 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Oct 26 12:46:37 2016 -0700
----------------------------------------------------------------------
newtmgr/transport/connudp.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/ef941d4e/newtmgr/transport/connudp.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connudp.go b/newtmgr/transport/connudp.go
index 5c5a775..6bd2da8 100644
--- a/newtmgr/transport/connudp.go
+++ b/newtmgr/transport/connudp.go
@@ -23,6 +23,8 @@ import (
"net"
"time"
+ log "github.com/Sirupsen/logrus"
+
"mynewt.apache.org/newt/newtmgr/config"
"mynewt.apache.org/newt/util"
)
@@ -89,7 +91,7 @@ func (cs *ConnUDP) ReadPacket() (*Packet, error) {
err.Error()))
}
data = data[0:nr]
-
+ log.Debugf("Received message from %v %d\n", srcAddr, nr)
pkt, err := NewPacket(uint16(nr))
if err != nil {
return nil, err
[22/50] incubator-mynewt-newt git commit: newt - remove extra broken
CopyFile function.
Posted by cc...@apache.org.
newt - remove extra broken CopyFile function.
There were two CopyFile functions (newtutil. and util.). util.CopyFile
was somewhat broken as it did not truncate the destination.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/e2e7083f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/e2e7083f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/e2e7083f
Branch: refs/heads/master
Commit: e2e7083f6dc08152af6a45180e3423e3d10b5599
Parents: f04edf5
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Oct 31 18:03:55 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Oct 31 18:03:55 2016 -0700
----------------------------------------------------------------------
newt/newtutil/newtutil.go | 24 --------------------
newt/vendor/mynewt.apache.org/newt/util/util.go | 10 ++------
util/util.go | 3 ++-
3 files changed, 4 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e2e7083f/newt/newtutil/newtutil.go
----------------------------------------------------------------------
diff --git a/newt/newtutil/newtutil.go b/newt/newtutil/newtutil.go
index 2f52052..af949f0 100644
--- a/newt/newtutil/newtutil.go
+++ b/newt/newtutil/newtutil.go
@@ -21,8 +21,6 @@ package newtutil
import (
"fmt"
- "io"
- "os"
"os/user"
"sort"
"strconv"
@@ -207,28 +205,6 @@ func BuildPackageString(repoName string, pkgName string) string {
}
}
-func CopyFile(dst string, src string) error {
- // open files r and w
- r, err := os.Open(src)
- if err != nil {
- return err
- }
- defer r.Close()
-
- w, err := os.Create(dst)
- if err != nil {
- return err
- }
- defer w.Close()
-
- // do the actual work
- _, err = io.Copy(w, r)
- if err != nil {
- return err
- }
- return nil
-}
-
func GeneratedPreamble() string {
return fmt.Sprintf("/**\n * This file was generated by %s\n */\n\n",
NewtVersionStr)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e2e7083f/newt/vendor/mynewt.apache.org/newt/util/util.go
----------------------------------------------------------------------
diff --git a/newt/vendor/mynewt.apache.org/newt/util/util.go b/newt/vendor/mynewt.apache.org/newt/util/util.go
index fd79c1b..d43f709 100644
--- a/newt/vendor/mynewt.apache.org/newt/util/util.go
+++ b/newt/vendor/mynewt.apache.org/newt/util/util.go
@@ -373,7 +373,8 @@ func CopyFile(srcFile string, dstFile string) error {
return ChildNewtError(err)
}
- out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY, info.Mode())
+ out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC,
+ info.Mode())
if err != nil {
return ChildNewtError(err)
}
@@ -383,13 +384,6 @@ func CopyFile(srcFile string, dstFile string) error {
return ChildNewtError(err)
}
- if err := in.Close(); err != nil {
- return err
- }
- if err := out.Close(); err != nil {
- return err
- }
-
return nil
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e2e7083f/util/util.go
----------------------------------------------------------------------
diff --git a/util/util.go b/util/util.go
index fd79c1b..56cb5c0 100644
--- a/util/util.go
+++ b/util/util.go
@@ -373,7 +373,8 @@ func CopyFile(srcFile string, dstFile string) error {
return ChildNewtError(err)
}
- out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY, info.Mode())
+ out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC,
+ info.Mode())
if err != nil {
return ChildNewtError(err)
}
[31/50] incubator-mynewt-newt git commit: MYNEWT-470 - newt: delete
old bld artifacts
Posted by cc...@apache.org.
MYNEWT-470 - newt: delete old bld artifacts
// Deletes files that should never be reused for a subsequent build.
// This list includes:
// <app>.img
// <app>.elf.bin
// manifest.json
func (b *Builder) CleanArtifacts() {
// ...
}
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/035421ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/035421ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/035421ea
Branch: refs/heads/master
Commit: 035421ea967f4e33d477edc6612621f530d59ce4
Parents: 67dc62a
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Nov 4 15:39:12 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Nov 4 15:39:12 2016 -0700
----------------------------------------------------------------------
newt/builder/build.go | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/035421ea/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index b5f0352..b01e78c 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -351,6 +351,8 @@ func (b *Builder) PrepBuild() error {
b.logDepInfo()
+ b.CleanArtifacts()
+
// Populate the base set of compiler flags. Flags from the following
// packages get applied to every source file:
// * target
@@ -667,3 +669,21 @@ func (b *Builder) CreateImage(version string,
return img, nil
}
+
+// Deletes files that should never be reused for a subsequent build. This
+// list includes:
+// <app>.img
+// <app>.elf.bin
+// manifest.json
+func (b *Builder) CleanArtifacts() {
+ paths := []string{
+ b.AppImgPath(),
+ b.AppBinPath(),
+ b.ManifestPath(),
+ }
+
+ // Attempt to delete each artifact, ignoring errors.
+ for _, p := range paths {
+ os.Remove(p)
+ }
+}
[45/50] incubator-mynewt-newt git commit: newt - Fix issues with
bsp.yml paths.
Posted by cc...@apache.org.
newt - Fix issues with bsp.yml paths.
There are two fixes here:
1. Assume relative paths are relative to the repo base dir. Previously,
this was the package base dir.
2. Add the local repo's name to the repo name map. This allows absolute
repo paths to refer to the local repo by name (e.g., you can use
"@apache-mynewt-core/..." when building within the core repo).
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/dd34193d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/dd34193d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/dd34193d
Branch: refs/heads/master
Commit: dd34193d3c31c5d87161343f160981fb8833c23f
Parents: 6434dad
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Nov 9 14:40:30 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Nov 9 14:43:03 2016 -0800
----------------------------------------------------------------------
newt/interfaces/interfaces.go | 1 +
newt/pkg/bsp_package.go | 4 ++--
newt/project/project.go | 10 +++++++---
3 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/dd34193d/newt/interfaces/interfaces.go
----------------------------------------------------------------------
diff --git a/newt/interfaces/interfaces.go b/newt/interfaces/interfaces.go
index 602c8bb..08e7e7e 100644
--- a/newt/interfaces/interfaces.go
+++ b/newt/interfaces/interfaces.go
@@ -31,6 +31,7 @@ type PackageType int
type RepoInterface interface {
Name() string
IsLocal() bool
+ Path() string
}
type VersionReqInterface interface {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/dd34193d/newt/pkg/bsp_package.go
----------------------------------------------------------------------
diff --git a/newt/pkg/bsp_package.go b/newt/pkg/bsp_package.go
index d381da3..572255c 100644
--- a/newt/pkg/bsp_package.go
+++ b/newt/pkg/bsp_package.go
@@ -52,7 +52,7 @@ func (bsp *BspPackage) resolvePathSetting(
if val == "" {
return "", nil
}
- path, err := proj.ResolvePath(bsp.BasePath(), val)
+ path, err := proj.ResolvePath(bsp.Repo().Path(), val)
if err != nil {
return "", util.PreNewtError(err,
"BSP \"%s\" specifies invalid %s setting",
@@ -84,7 +84,7 @@ func (bsp *BspPackage) resolveLinkerScriptSetting(
// Read each linker script from the list.
for _, val := range vals {
- path, err := proj.ResolvePath(bsp.BasePath(), val)
+ path, err := proj.ResolvePath(bsp.Repo().Path(), val)
if err != nil {
return nil, util.PreNewtError(err,
"BSP \"%s\" specifies invalid %s setting",
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/dd34193d/newt/project/project.go
----------------------------------------------------------------------
diff --git a/newt/project/project.go b/newt/project/project.go
index 45f7405..ae2c0e5 100644
--- a/newt/project/project.go
+++ b/newt/project/project.go
@@ -149,8 +149,12 @@ func (proj *Project) Repos() map[string]*repo.Repo {
}
func (proj *Project) FindRepo(rname string) *repo.Repo {
- r, _ := proj.repos[rname]
- return r
+ if rname == repo.REPO_NAME_LOCAL {
+ return proj.LocalRepo()
+ } else {
+ r, _ := proj.repos[rname]
+ return r
+ }
}
func (proj *Project) LocalRepo() *repo.Repo {
@@ -459,7 +463,7 @@ func (proj *Project) loadConfig() error {
return err
}
- proj.repos[r.Name()] = r
+ proj.repos[proj.name] = r
proj.localRepo = r
for _, ignDir := range ignoreSearchDirs {
r.AddIgnoreDir(ignDir)
[08/50] incubator-mynewt-newt git commit: newtmgr;
oic_serial, oic_ble for newtmgr inside CoAP. Add oic_net, and net
profiles for carrying OIC/newtmgr over UDP.
Posted by cc...@apache.org.
newtmgr; oic_serial, oic_ble for newtmgr inside CoAP.
Add oic_net, and net profiles for carrying OIC/newtmgr over UDP.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/00487272
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/00487272
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/00487272
Branch: refs/heads/master
Commit: 004872724a3fff353316c7c066d15a3edef5baff
Parents: cd7eec8
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Oct 26 11:30:31 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Oct 26 11:31:42 2016 -0700
----------------------------------------------------------------------
newtmgr/protocol/cmdrunner.go | 16 ++++-
newtmgr/protocol/omgr.go | 112 +++++++++++++++++++++++++++++++++++
newtmgr/transport/conn.go | 16 +++++
newtmgr/transport/connble.go | 12 +++-
newtmgr/transport/connserial.go | 9 +++
newtmgr/transport/connudp.go | 99 +++++++++++++++++++++++++++++++
6 files changed, 259 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/00487272/newtmgr/protocol/cmdrunner.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/cmdrunner.go b/newtmgr/protocol/cmdrunner.go
index cbb8427..7ec3d56 100644
--- a/newtmgr/protocol/cmdrunner.go
+++ b/newtmgr/protocol/cmdrunner.go
@@ -42,7 +42,12 @@ func (cr *CmdRunner) ReadResp() (*NmgrReq, error) {
bytes := pkt.GetBytes()
log.Debugf("Rx packet dump:\n%s", hex.Dump(bytes))
- nmrfrag, err := DeserializeNmgrReq(bytes)
+ var nmrfrag *NmgrReq
+ if cr.Conn.GetOICEncoded() == true {
+ nmrfrag, err = DeserializeOmgrReq(bytes)
+ } else {
+ nmrfrag, err = DeserializeNmgrReq(bytes)
+ }
if err != nil {
return nil, err
}
@@ -58,10 +63,15 @@ func (cr *CmdRunner) ReadResp() (*NmgrReq, error) {
func (cr *CmdRunner) WriteReq(nmr *NmgrReq) error {
data := []byte{}
+ var err error
- log.Debugf("Writing netmgr request %+v", nmr)
+ log.Debugf("Writing newtmgr request %+v", nmr)
- data, err := nmr.SerializeRequest(data)
+ if cr.Conn.GetOICEncoded() == true {
+ data, err = nmr.SerializeOmgrRequest(data)
+ } else {
+ data, err = nmr.SerializeRequest(data)
+ }
if err != nil {
return err
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/00487272/newtmgr/protocol/omgr.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/omgr.go b/newtmgr/protocol/omgr.go
new file mode 100644
index 0000000..a0ab05f
--- /dev/null
+++ b/newtmgr/protocol/omgr.go
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package protocol
+
+import (
+ "fmt"
+
+ log "github.com/Sirupsen/logrus"
+ "github.com/dustin/go-coap"
+ "github.com/ugorji/go/codec"
+
+ "mynewt.apache.org/newt/util"
+)
+
+type OicRsp struct {
+ Read map[string]interface{} `codec:"r"`
+ Write map[string]interface{} `codec:"w"`
+}
+
+/*
+ * Not able to install custom decoder for indefite length objects with the codec.
+ * So we need to decode the whole response, and then re-encode the newtmgr response
+ * part.
+ */
+func DeserializeOmgrReq(data []byte) (*NmgrReq, error) {
+ req := coap.Message{}
+ err := req.UnmarshalBinary(data)
+ if err != nil {
+ return nil, util.NewNewtError(fmt.Sprintf(
+ "Oicmgr request invalid %s", err.Error()))
+ }
+ log.Debugf("Deserialized COAP %+v", req)
+
+ var rsp OicRsp
+ err = codec.NewDecoderBytes(req.Payload, new(codec.CborHandle)).Decode(&rsp)
+ if err != nil {
+ return nil, util.NewNewtError(fmt.Sprintf("Invalid incoming cbor: %s",
+ err.Error()))
+ }
+
+ nmr := &NmgrReq{}
+
+ var ndata []byte = make([]byte, 0)
+ if len(rsp.Read) != 0 {
+ err = codec.NewEncoderBytes(&ndata,
+ new(codec.CborHandle)).Encode(rsp.Read)
+ nmr.Op = NMGR_OP_READ_RSP
+ } else {
+ err = codec.NewEncoderBytes(&ndata,
+ new(codec.CborHandle)).Encode(rsp.Read)
+ nmr.Op = NMGR_OP_WRITE_RSP
+ }
+ if err != nil {
+ return nil, util.NewNewtError(fmt.Sprintf("Internal error: %s",
+ err.Error()))
+ }
+
+ nmr.Len = uint16(len(ndata))
+ nmr.Flags = NMGR_F_JSON_RSP_COMPLETE
+ nmr.Group = 0
+ nmr.Seq = 0
+ nmr.Id = 0
+
+ nmr.Data = ndata
+
+ log.Debugf("Deserialized response %+v", nmr)
+
+ return nmr, nil
+}
+
+func (nmr *NmgrReq) SerializeOmgrRequest(data []byte) ([]byte, error) {
+ req := coap.Message{
+ Type: coap.Confirmable,
+ MessageID: uint16(nmr.Seq),
+ }
+ if nmr.Op == NMGR_OP_READ {
+ req.Code = coap.GET
+ } else {
+ req.Code = coap.PUT
+ }
+ req.SetPathString("/omgr")
+ req.AddOption(coap.URIQuery, fmt.Sprintf("gr=%d", nmr.Group))
+ req.AddOption(coap.URIQuery, fmt.Sprintf("id=%d", nmr.Id))
+
+ req.Payload = nmr.Data
+
+ log.Debugf("Serializing request %+v into buffer %+v", nmr, data)
+
+ data, err := req.MarshalBinary()
+ if err != nil {
+ return nil, util.NewNewtError(
+ fmt.Sprintf("Failed to encode: %s\n", err.Error()))
+ }
+ return data, nil
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/00487272/newtmgr/transport/conn.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/conn.go b/newtmgr/transport/conn.go
index 2410ab6..715071d 100644
--- a/newtmgr/transport/conn.go
+++ b/newtmgr/transport/conn.go
@@ -32,6 +32,8 @@ type Conn interface {
ReadPacket() (*Packet, error)
WritePacket(pkt *Packet) error
Close() error
+ SetOICEncoded(bool)
+ GetOICEncoded() bool
}
type Packet struct {
@@ -84,8 +86,22 @@ func newConn(cp config.NewtmgrConnProfile, readTimeout time.Duration) (Conn, err
switch cp.Type() {
case "serial":
c = &ConnSerial{}
+ c.SetOICEncoded(false)
+ case "oic_serial":
+ c = &ConnSerial{}
+ c.SetOICEncoded(true)
case "ble":
c = &ConnBLE{}
+ c.SetOICEncoded(false)
+ case "oic_ble":
+ c = &ConnBLE{}
+ c.SetOICEncoded(true)
+ case "udp":
+ c = &ConnUDP{}
+ c.SetOICEncoded(false)
+ case "oic_udp":
+ c = &ConnUDP{}
+ c.SetOICEncoded(true)
default:
return nil, util.NewNewtError("Invalid conn profile " + cp.Type() +
" not implemented")
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/00487272/newtmgr/transport/connble.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connble.go b/newtmgr/transport/connble.go
index 6160340..f0ad978 100644
--- a/newtmgr/transport/connble.go
+++ b/newtmgr/transport/connble.go
@@ -43,8 +43,8 @@ var deviceAddressType uint8
type ConnBLE struct {
connProfile config.NewtmgrConnProfile
currentPacket *Packet
-
- bleDevice gatt.Device
+ bleDevice gatt.Device
+ isOIC bool
}
var deviceChar *gatt.Characteristic
@@ -135,6 +135,14 @@ func onPeriphDisconnected(p gatt.Peripheral, err error) {
log.Debugf("Disconnected", err)
}
+func (cs *ConnBLE) SetOICEncoded(b bool) {
+ cs.isOIC = b
+}
+
+func (cs *ConnBLE) GetOICEncoded() bool {
+ return cs.isOIC
+}
+
func (cb *ConnBLE) Open(cp config.NewtmgrConnProfile, readTimeout time.Duration) error {
var err error
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/00487272/newtmgr/transport/connserial.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connserial.go b/newtmgr/transport/connserial.go
index b97dd07..4344b67 100644
--- a/newtmgr/transport/connserial.go
+++ b/newtmgr/transport/connserial.go
@@ -44,6 +44,15 @@ type ConnSerial struct {
scanner *bufio.Scanner
serialChannel *serial.Port
+ isOIC bool
+}
+
+func (cs *ConnSerial) SetOICEncoded(b bool) {
+ cs.isOIC = b
+}
+
+func (cs *ConnSerial) GetOICEncoded() bool {
+ return cs.isOIC
}
func newSerialConfig(
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/00487272/newtmgr/transport/connudp.go
----------------------------------------------------------------------
diff --git a/newtmgr/transport/connudp.go b/newtmgr/transport/connudp.go
new file mode 100644
index 0000000..0be57b6
--- /dev/null
+++ b/newtmgr/transport/connudp.go
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package transport
+
+import (
+ "fmt"
+ "net"
+ "time"
+
+ "mynewt.apache.org/newt/newtmgr/config"
+ "mynewt.apache.org/newt/util"
+)
+
+type ConnUDP struct {
+ connProfile config.NewtmgrConnProfile
+ conn *net.UDPConn
+ dst *net.UDPAddr
+ isOIC bool
+}
+
+func (cs *ConnUDP) Open(cp config.NewtmgrConnProfile, readTimeout time.Duration) error {
+ addr, err := net.ResolveUDPAddr("udp", cp.ConnString())
+ if err != nil {
+ return util.NewNewtError(fmt.Sprintf("Name not resolving: %s",
+ err.Error()))
+ }
+ cs.dst = addr
+
+ // bind local endpoint to wait for response afterwards
+ s, err := net.ListenUDP("udp", nil)
+ if err != nil {
+ return util.NewNewtError(fmt.Sprintf("UDP conn failed: %s\n",
+ err.Error()))
+ }
+ cs.conn = s
+ return nil
+}
+
+func (cs *ConnUDP) Close() error {
+ cs.conn.Close()
+ cs.conn = nil
+ return nil
+}
+
+func (cs *ConnUDP) SetOICEncoded(b bool) {
+ cs.isOIC = b
+}
+
+func (cs *ConnUDP) GetOICEncoded() bool {
+ return cs.isOIC
+}
+
+func (cs *ConnUDP) WritePacket(pkt *Packet) error {
+ if cs.conn == nil {
+ return util.NewNewtError("Connection not open")
+ }
+
+ _, err := cs.conn.WriteTo(pkt.GetBytes(), cs.dst)
+ if err != nil {
+ return util.NewNewtError(fmt.Sprintf("failed to write: %s",
+ err.Error()))
+ }
+ return nil
+}
+
+func (cs *ConnUDP) ReadPacket() (*Packet, error) {
+ // cs.conn.SetDeadline(time.Now().Add(time.Second * 4))
+
+ data := make([]byte, 2048)
+ nr, srcAddr, err := cs.conn.ReadFromUDP(data)
+ if err != nil {
+ return nil, util.NewNewtError(fmt.Sprintf("failed to read: %s",
+ err.Error()))
+ }
+ data = data[0:nr]
+ fmt.Printf("Received message from %v %d\n", srcAddr, nr)
+ pkt, err := NewPacket(uint16(nr))
+ if err != nil {
+ return nil, err
+ }
+ pkt.AddBytes(data)
+ return pkt, nil
+}
[04/50] incubator-mynewt-newt git commit: newt - Don't save
individual unittest targets
Posted by cc...@apache.org.
newt - Don't save individual unittest targets
Whenever a unittest package was exeuted via "newt test", a new target
was getting saved as a subdirectory of targets/unittest. This cluttered
the output of "newt target show" with extraneous information.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/611d95bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/611d95bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/611d95bd
Branch: refs/heads/master
Commit: 611d95bd6b52c217d18f48116c567d0efc92c9b1
Parents: 546f9cc
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Oct 26 08:58:39 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Oct 26 08:58:39 2016 -0700
----------------------------------------------------------------------
newt/cli/build_cmds.go | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/611d95bd/newt/cli/build_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index 21ab145..26f3f07 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -290,9 +290,6 @@ func testRunCmd(cmd *cobra.Command, args []string) {
}
t = baseTarget.Clone(proj.LocalRepo(), targetName)
- if err := t.Save(); err != nil {
- NewtUsage(nil, err)
- }
}
b, err := builder.NewTargetTester(t, pack)
[24/50] incubator-mynewt-newt git commit: Merge branch 'develop' of
https://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt into develop
Posted by cc...@apache.org.
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt into develop
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/c30dc2d0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/c30dc2d0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/c30dc2d0
Branch: refs/heads/master
Commit: c30dc2d063aae90f96e1c069c10c77d119c7e752
Parents: 22cf270 e2e7083
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Nov 1 12:19:04 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Nov 1 12:19:04 2016 -0700
----------------------------------------------------------------------
newt/builder/targetbuild.go | 10 --------
newt/mfg/paths.go | 6 ++---
newt/newtutil/newtutil.go | 24 --------------------
newt/vendor/mynewt.apache.org/newt/util/util.go | 10 ++------
util/util.go | 3 ++-
5 files changed, 7 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
[21/50] incubator-mynewt-newt git commit: newt - Fix reporting of bad
boot path for mfg img.
Posted by cc...@apache.org.
newt - Fix reporting of bad boot path for mfg img.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/f04edf54
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/f04edf54
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/f04edf54
Branch: refs/heads/master
Commit: f04edf545f5c1c3d241ea443370fff77dcc87ce8
Parents: 54d3c0b
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Oct 31 13:12:10 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Oct 31 13:12:10 2016 -0700
----------------------------------------------------------------------
newt/mfg/paths.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/f04edf54/newt/mfg/paths.go
----------------------------------------------------------------------
diff --git a/newt/mfg/paths.go b/newt/mfg/paths.go
index cd9d38f..f05abb3 100644
--- a/newt/mfg/paths.go
+++ b/newt/mfg/paths.go
@@ -92,7 +92,7 @@ func (mi *MfgImage) BootBinPath() string {
}
return MfgBootBinPath(mi.basePkg.Name(),
- pkg.ShortName(mi.boot.Package()))
+ pkg.ShortName(mi.boot.App()))
}
func (mi *MfgImage) BootElfPath() string {
@@ -100,7 +100,7 @@ func (mi *MfgImage) BootElfPath() string {
return ""
}
- return MfgBootElfPath(mi.basePkg.Name(), pkg.ShortName(mi.boot.Package()))
+ return MfgBootElfPath(mi.basePkg.Name(), pkg.ShortName(mi.boot.App()))
}
func (mi *MfgImage) BootManifestPath() string {
@@ -109,7 +109,7 @@ func (mi *MfgImage) BootManifestPath() string {
}
return MfgBootManifestPath(mi.basePkg.Name(),
- pkg.ShortName(mi.boot.Package()))
+ pkg.ShortName(mi.boot.App()))
}
func (mi *MfgImage) AppImgPath(imageIdx int) string {
[03/50] incubator-mynewt-newt git commit: mfg - loader and app are
both in image0 dir.
Posted by cc...@apache.org.
mfg - loader and app are both in image0 dir.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/546f9ccb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/546f9ccb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/546f9ccb
Branch: refs/heads/master
Commit: 546f9ccb941e42c46580721a23e0143a09802194
Parents: fa889a7
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Oct 25 21:03:51 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Oct 25 21:03:51 2016 -0700
----------------------------------------------------------------------
newt/mfg/create.go | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/546f9ccb/newt/mfg/create.go
----------------------------------------------------------------------
diff --git a/newt/mfg/create.go b/newt/mfg/create.go
index 55e7364..0db4f16 100644
--- a/newt/mfg/create.go
+++ b/newt/mfg/create.go
@@ -225,6 +225,10 @@ func loaderBinPaths(t *target.Target) []string {
/* <loader>.elf */
builder.AppElfPath(t.Name(), builder.BUILD_NAME_LOADER,
t.Loader().Name()),
+
+ /* <app>.img */
+ builder.AppImgPath(t.Name(), builder.BUILD_NAME_LOADER,
+ t.Loader().Name()),
}
}
@@ -297,25 +301,29 @@ func (mi *MfgImage) dstBootBinPath() string {
pkg.ShortName(mi.boot.App()))
}
-func (mi *MfgImage) dstImgPath(imgIdx int) string {
+func (mi *MfgImage) dstImgPath(slotIdx int) string {
var pack *pkg.LocalPackage
+ var imgIdx int
if len(mi.images) >= 1 {
- switch imgIdx {
+ switch slotIdx {
case 0:
if mi.images[0].LoaderName != "" {
pack = mi.images[0].Loader()
} else {
pack = mi.images[0].App()
}
+ imgIdx = 0
case 1:
if mi.images[0].LoaderName != "" {
pack = mi.images[0].App()
+ imgIdx = 0
} else {
if len(mi.images) >= 2 {
pack = mi.images[1].App()
}
+ imgIdx = 1
}
default:
[41/50] incubator-mynewt-newt git commit: newt - Clarify mfg comments.
Posted by cc...@apache.org.
newt - Clarify mfg comments.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/a7be46a4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/a7be46a4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/a7be46a4
Branch: refs/heads/master
Commit: a7be46a46979825f03bc58c29c8c1f3528533f90
Parents: eb6d081
Author: Christopher Collins <cc...@apache.org>
Authored: Sat Nov 5 11:56:06 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Nov 8 13:28:12 2016 -0800
----------------------------------------------------------------------
newt/flash/flash.go | 2 +-
newt/mfg/meta.go | 86 ++++++++++++++++++++++++++++++++++++++----------
2 files changed, 69 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a7be46a4/newt/flash/flash.go
----------------------------------------------------------------------
diff --git a/newt/flash/flash.go b/newt/flash/flash.go
index ea13e25..97114c5 100644
--- a/newt/flash/flash.go
+++ b/newt/flash/flash.go
@@ -130,7 +130,7 @@ func parseFlashArea(
}
userId, err := util.AtoiNoOct(v)
if err != nil {
- return area, flashAreaErr(name, "invalid id: %s", v)
+ return area, flashAreaErr(name, "invalid user id: %s", v)
}
area.Id = userId + AREA_USER_ID_MIN
idPresent = true
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a7be46a4/newt/mfg/meta.go
----------------------------------------------------------------------
diff --git a/newt/mfg/meta.go b/newt/mfg/meta.go
index 58c3684..8dc4ed5 100644
--- a/newt/mfg/meta.go
+++ b/newt/mfg/meta.go
@@ -28,6 +28,44 @@ import (
"mynewt.apache.org/newt/util"
)
+// The "manufacturing meta region" is located at the end of the boot loader
+// flash area. This region has the following structure.
+//
+// 0 1 2 3
+// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+// |Version (0x01) | 0xff padding |
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+// | TLV type | TLV size | TLV data ("TLV size" bytes) ~
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ~
+// ~ ~
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+// | TLV type | TLV size | TLV data ("TLV size" bytes) ~
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ~
+// ~ ~
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+// | Region size | 0xff padding |
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+// | Magic (0x3bb2a269) |
+// +-+-+-+-+-+--+-+-+-+-end of boot loader area+-+-+-+-+-+-+-+-+-+-+
+//
+// The number of TLVs is variable; two are shown above for illustrative
+// purposes.
+//
+// Fields:
+// <Header>
+// 1. Version: Manufacturing meta version number; always 0x01.
+//
+// <TLVs>
+// 2. TLV type: Indicates the type of data to follow.
+// 3. TLV size: The number of bytes of data to follow.
+// 4. TLV data: TLV-size bytes of data.
+//
+// <Footer>
+// 5. Region size: The size, in bytes, of the entire manufacturing meta region;
+// includes header, TLVs, and footer.
+// 6. Magic: indicates the presence of the manufacturing meta region.
+
const META_MAGIC = 0x3bb2a269
const META_VERSION = 1
const META_TLV_CODE_HASH = 0x01
@@ -39,29 +77,29 @@ const META_TLV_HASH_SZ = META_HASH_SZ
const META_TLV_FLASH_AREA_SZ = 12
type metaHeader struct {
- version uint8
- pad8 uint8
- pad16 uint16
+ version uint8 // 1
+ pad8 uint8 // 0xff
+ pad16 uint16 // 0xffff
}
type metaFooter struct {
size uint16 // Includes header, TLVs, and footer.
- pad16 uint16
- magic uint32
+ pad16 uint16 // 0xffff
+ magic uint32 // META_MAGIC
}
type metaTlvHeader struct {
- code uint8
- size uint8
+ typ uint8 // Indicates the type of data to follow.
+ size uint8 // The number of bytes of data to follow.
}
type metaTlvFlashArea struct {
header metaTlvHeader
- areaId uint8
- deviceId uint8
- pad16 uint16
- offset uint32
- size uint32
+ areaId uint8 // Unique value identifying this flash area.
+ deviceId uint8 // Indicates host flash device (aka section number).
+ pad16 uint16 // 0xffff
+ offset uint32 // The byte offset within the flash device.
+ size uint32 // Size, in bytes, of entire flash area.
}
type metaTlvHash struct {
@@ -70,7 +108,7 @@ type metaTlvHash struct {
}
func writeElem(elem interface{}, buf *bytes.Buffer) error {
- /* XXX: Assume little endian for now. */
+ /* XXX: Assume target platform uses little endian. */
if err := binary.Write(buf, binary.LittleEndian, elem); err != nil {
return util.ChildNewtError(err)
}
@@ -95,18 +133,19 @@ func writeFooter(buf *bytes.Buffer) error {
return writeElem(ftr, buf)
}
-func writeTlvHeader(code uint8, size uint8, buf *bytes.Buffer) error {
+func writeTlvHeader(typ uint8, size uint8, buf *bytes.Buffer) error {
tlvHdr := metaTlvHeader{
- code: code,
+ typ: typ,
size: size,
}
return writeElem(tlvHdr, buf)
}
-func writeFlashArea(area flash.FlashArea, buf *bytes.Buffer) error {
+// Writes a single entry of the flash map TLV.
+func writeFlashMapEntry(area flash.FlashArea, buf *bytes.Buffer) error {
tlv := metaTlvFlashArea{
header: metaTlvHeader{
- code: META_TLV_CODE_FLASH_AREA,
+ typ: META_TLV_CODE_FLASH_AREA,
size: META_TLV_FLASH_AREA_SZ,
},
areaId: uint8(area.Id),
@@ -118,10 +157,13 @@ func writeFlashArea(area flash.FlashArea, buf *bytes.Buffer) error {
return writeElem(tlv, buf)
}
+// Writes a zeroed-out hash TLV. The hash's original value must be zero for
+// the actual hash to be calculated later. After the actual value is
+// calculated, it replaces the zeros in the TLV.
func writeZeroHash(buf *bytes.Buffer) error {
tlv := metaTlvHash{
header: metaTlvHeader{
- code: META_TLV_CODE_HASH,
+ typ: META_TLV_CODE_HASH,
size: META_TLV_HASH_SZ,
},
hash: [META_HASH_SZ]byte{},
@@ -183,6 +225,14 @@ func insertMeta(section0Data []byte, flashMap flash.FlashMap) (
return metaOff, metaOff + hashSubOff, nil
}
+// Calculates the SHA256 hash, using the full manufacturing image as input.
+// Hash-calculation algorithm is as follows:
+// 1. Concatenate sections in ascending order of index.
+// 2. Zero out the 32 bytes that will contain the hash.
+// 3. Apply SHA256 to the result.
+//
+// This function assumes that the 32 bytes of hash data have already been
+// zeroed.
func calcMetaHash(sections [][]byte) []byte {
// Concatenate all sections.
blob := []byte{}
[09/50] incubator-mynewt-newt git commit: newt;
not having download script is ok. Don't error out.
Posted by cc...@apache.org.
newt; not having download script is ok. Don't error out.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/059bd7a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/059bd7a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/059bd7a1
Branch: refs/heads/master
Commit: 059bd7a117bb8719e5c8719cd687e8aad32b4af6
Parents: 0048727
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Oct 26 11:56:32 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Oct 26 11:56:32 2016 -0700
----------------------------------------------------------------------
newt/builder/load.go | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/059bd7a1/newt/builder/load.go
----------------------------------------------------------------------
diff --git a/newt/builder/load.go b/newt/builder/load.go
index b370a4d..2fd4e7f 100644
--- a/newt/builder/load.go
+++ b/newt/builder/load.go
@@ -55,8 +55,7 @@ func Load(binBaseName string, bspPkg *pkg.BspPackage,
extraEnvSettings map[string]string) error {
if bspPkg.DownloadScript == "" {
- return util.FmtNewtError("No download script for BSP %s\n",
- bspPkg.Name())
+ return nil
}
bspPath := bspPkg.BasePath()
[26/50] incubator-mynewt-newt git commit: newt - clean up mfg image
code
Posted by cc...@apache.org.
newt - clean up mfg image code
This code had gone through a few changes in requirements. This commit
rewrites parts of it without changing its behavior.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/cc1c2dd8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/cc1c2dd8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/cc1c2dd8
Branch: refs/heads/master
Commit: cc1c2dd81204baf9235a7377c0d0814f1f35da3d
Parents: a1cb702
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Nov 2 08:12:44 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Nov 2 08:13:49 2016 -0700
----------------------------------------------------------------------
newt/mfg/create.go | 216 +++++++++++++++++++++++++++---------------------
newt/mfg/load.go | 83 +++++++------------
newt/mfg/mfg.go | 3 +-
3 files changed, 153 insertions(+), 149 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/cc1c2dd8/newt/mfg/create.go
----------------------------------------------------------------------
diff --git a/newt/mfg/create.go b/newt/mfg/create.go
index 2a7f36f..fc11f75 100644
--- a/newt/mfg/create.go
+++ b/newt/mfg/create.go
@@ -25,6 +25,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "sort"
"time"
"mynewt.apache.org/newt/newt/builder"
@@ -52,7 +53,10 @@ func insertPartIntoBlob(blob []byte, part mfgPart) {
func (mi *MfgImage) partFromImage(
imgPath string, flashAreaName string) (mfgPart, error) {
- part := mfgPart{}
+ part := mfgPart{
+ // Boot loader and images always go in device 0.
+ device: 0,
+ }
area, ok := mi.bsp.FlashMap.Areas[flashAreaName]
if !ok {
@@ -79,75 +83,155 @@ func (mi *MfgImage) partFromImage(
imgPath, flashAreaName, len(part.data), area.Size, overflow)
}
+ // If an image slot is used, the entire flash area is unwritable. This
+ // restriction comes from the boot loader's need to write status at the end
+ // of an area. Pad out part with unwriten flash (0xff). This probably
+ // isn't terribly efficient...
+ for i := 0; i < -overflow; i++ {
+ part.data = append(part.data, 0xff)
+ }
+
return part, nil
}
-func (mi *MfgImage) section0Size() int {
- greatest := 0
+func partFromRawEntry(entry MfgRawEntry, entryIdx int) mfgPart {
+ return mfgPart{
+ name: fmt.Sprintf("entry-%d (%s)", entryIdx, entry.filename),
+ offset: entry.offset,
+ data: entry.data,
+ }
+}
- bootArea := mi.bsp.FlashMap.Areas[flash.FLASH_AREA_NAME_BOOTLOADER]
- image0Area := mi.bsp.FlashMap.Areas[flash.FLASH_AREA_NAME_IMAGE_0]
- image1Area := mi.bsp.FlashMap.Areas[flash.FLASH_AREA_NAME_IMAGE_1]
+func (mi *MfgImage) targetParts() ([]mfgPart, error) {
+ parts := []mfgPart{}
- if mi.boot != nil {
- greatest = util.IntMax(greatest, bootArea.Offset+bootArea.Size)
- }
- if len(mi.images) >= 1 {
- greatest = util.IntMax(greatest, image0Area.Offset+image0Area.Size)
+ bootPath := mi.dstBootBinPath()
+ if bootPath != "" {
+ bootPart, err := mi.partFromImage(
+ bootPath, flash.FLASH_AREA_NAME_BOOTLOADER)
+ if err != nil {
+ return nil, err
+ }
+
+ parts = append(parts, bootPart)
}
- if len(mi.images) >= 2 {
- greatest = util.IntMax(greatest, image1Area.Offset+image1Area.Size)
+
+ for i := 0; i < 2; i++ {
+ imgPath := mi.dstImgPath(i)
+ if imgPath != "" {
+ areaName, err := areaNameFromImgIdx(i)
+ if err != nil {
+ return nil, err
+ }
+
+ part, err := mi.partFromImage(imgPath, areaName)
+ if err != nil {
+ return nil, err
+ }
+ parts = append(parts, part)
+ }
}
- for _, entry := range mi.rawEntries {
- greatest = util.IntMax(greatest, entry.offset+len(entry.data))
+ return parts, nil
+}
+
+func sectionSize(parts []mfgPart) int {
+ greatest := 0
+
+ for _, part := range parts {
+ end := part.offset + len(part.data)
+ greatest = util.IntMax(greatest, end)
}
return greatest
}
-// @return section-0-blob, hash-offset, error
-func (mi *MfgImage) section0Data(parts []mfgPart) ([]byte, int, error) {
- blobSize := mi.section0Size()
- blob := make([]byte, blobSize)
+func sectionFromParts(parts []mfgPart) []byte {
+ sectionSize := sectionSize(parts)
+ section := make([]byte, sectionSize)
// Initialize section 0's data as unwritten flash (0xff).
- for i, _ := range blob {
- blob[i] = 0xff
+ for i, _ := range section {
+ section[i] = 0xff
}
for _, part := range parts {
- insertPartIntoBlob(blob, part)
+ insertPartIntoBlob(section, part)
+ }
+
+ return section
+}
+
+func (mi *MfgImage) devicePartMap() (map[int][]mfgPart, error) {
+ dpMap := map[int][]mfgPart{}
+
+ // Create parts from the raw entries.
+ for i, entry := range mi.rawEntries {
+ part := partFromRawEntry(entry, i)
+ dpMap[entry.device] = append(dpMap[entry.device], part)
}
- hashOffset, err := insertMeta(blob, mi.bsp.FlashMap)
+ // Insert the boot loader and image parts into section 0.
+ targetParts, err := mi.targetParts()
if err != nil {
- return nil, 0, err
+ return nil, err
}
+ dpMap[0] = append(dpMap[0], targetParts...)
- return blob, hashOffset, nil
+ // Sort each part slice by offset.
+ for device, _ := range dpMap {
+ sortParts(dpMap[device])
+ }
+ return dpMap, nil
+}
+
+func (mi *MfgImage) deviceSectionMap() (map[int][]byte, error) {
+ dpMap, err := mi.devicePartMap()
+ if err != nil {
+ return nil, err
+ }
+
+ // Convert each part slice into a section (byte slice).
+ dsMap := map[int][]byte{}
+ for device, parts := range dpMap {
+ dsMap[device] = sectionFromParts(parts)
+ }
+
+ return dsMap, nil
}
// @return [section0blob, section1blob,...], hash, err
-func (mi *MfgImage) createSections(parts []mfgPart) (
- [][]byte, []byte, error) {
+func (mi *MfgImage) createSections() (map[int][]byte, []byte, error) {
+ dsMap, err := mi.deviceSectionMap()
+ if err != nil {
+ return nil, nil, err
+ }
+
+ if dsMap[0] == nil {
+ panic("Invalid state; no section 0")
+ }
- section0Data, hashOff, err := mi.section0Data(parts)
+ hashOffset, err := insertMeta(dsMap[0], mi.bsp.FlashMap)
if err != nil {
return nil, nil, err
}
- // XXX: Append additional sections.
+ // Calculate manufacturing hash.
+ devices := make([]int, 0, len(dsMap))
+ for device, _ := range dsMap {
+ devices = append(devices, device)
+ }
+ sort.Ints(devices)
- // Calculate manufacturing has.
- sections := [][]byte{section0Data}
+ sections := make([][]byte, len(devices))
+ for i, device := range devices {
+ sections[i] = dsMap[device]
+ }
hash := calcMetaHash(sections)
+ copy(dsMap[0][hashOffset:hashOffset+META_HASH_SZ], hash)
- // Write hash to meta region in section 0.
- copy(section0Data[hashOff:hashOff+META_HASH_SZ], hash)
-
- return sections, hash, nil
+ return dsMap, hash, nil
}
func areaNameFromImgIdx(imgIdx int) (string, error) {
@@ -161,17 +245,6 @@ func areaNameFromImgIdx(imgIdx int) (string, error) {
}
}
-func (mi *MfgImage) rawEntryParts() []mfgPart {
- parts := make([]mfgPart, len(mi.rawEntries))
- for i, entry := range mi.rawEntries {
- parts[i].name = fmt.Sprintf("entry-%d (%s)", i, entry.filename)
- parts[i].offset = entry.offset
- parts[i].data = entry.data
- }
-
- return parts
-}
-
func bootLoaderFromPaths(t *target.Target) []string {
return []string{
/* boot.elf */
@@ -308,39 +381,6 @@ func (mi *MfgImage) dstImgPath(slotIdx int) string {
MfgImageBinDir(mi.basePkg.Name(), imgIdx), pkg.ShortName(pack))
}
-func (mi *MfgImage) targetParts() ([]mfgPart, error) {
- parts := []mfgPart{}
-
- bootPath := mi.dstBootBinPath()
- if bootPath != "" {
- bootPart, err := mi.partFromImage(
- bootPath, flash.FLASH_AREA_NAME_BOOTLOADER)
- if err != nil {
- return nil, err
- }
-
- parts = append(parts, bootPart)
- }
-
- for i := 0; i < 2; i++ {
- imgPath := mi.dstImgPath(i)
- if imgPath != "" {
- areaName, err := areaNameFromImgIdx(i)
- if err != nil {
- return nil, err
- }
-
- part, err := mi.partFromImage(imgPath, areaName)
- if err != nil {
- return nil, err
- }
- parts = append(parts, part)
- }
- }
-
- return parts, nil
-}
-
// Returns a slice containing the path of each file required to build the
// manufacturing image.
func (mi *MfgImage) FromPaths() []string {
@@ -364,22 +404,12 @@ func (mi *MfgImage) FromPaths() []string {
}
// @return [section0blob, section1blob,...], hash, err
-func (mi *MfgImage) build() ([][]byte, []byte, error) {
+func (mi *MfgImage) build() (map[int][]byte, []byte, error) {
if err := mi.copyBinFiles(); err != nil {
return nil, nil, err
}
- targetParts, err := mi.targetParts()
- if err != nil {
- return nil, nil, err
- }
-
- rawParts := mi.rawEntryParts()
-
- parts := append(targetParts, rawParts...)
- sortParts(parts)
-
- sections, hash, err := mi.createSections(parts)
+ sections, hash, err := mi.createSections()
if err != nil {
return nil, nil, err
}
@@ -442,8 +472,8 @@ func (mi *MfgImage) CreateMfgImage() ([]string, error) {
return nil, util.ChildNewtError(err)
}
- for i, section := range sections {
- sectionPath := MfgSectionBinPath(mi.basePkg.Name(), i)
+ for device, section := range sections {
+ sectionPath := MfgSectionBinPath(mi.basePkg.Name(), device)
if err := ioutil.WriteFile(sectionPath, section, 0644); err != nil {
return nil, util.ChildNewtError(err)
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/cc1c2dd8/newt/mfg/load.go
----------------------------------------------------------------------
diff --git a/newt/mfg/load.go b/newt/mfg/load.go
index 6e986ae..ef75d4d 100644
--- a/newt/mfg/load.go
+++ b/newt/mfg/load.go
@@ -28,13 +28,14 @@ import (
"github.com/spf13/cast"
- "mynewt.apache.org/newt/newt/flash"
"mynewt.apache.org/newt/newt/pkg"
"mynewt.apache.org/newt/newt/project"
"mynewt.apache.org/newt/newt/target"
"mynewt.apache.org/newt/util"
)
+const MFG_YAML_FILENAME string = "mfg.yml"
+
type partSorter struct {
parts []mfgPart
}
@@ -129,21 +130,6 @@ func (mi *MfgImage) loadRawEntry(
return raw, nil
}
-func (mi *MfgImage) areaNameToPart(areaName string) (mfgPart, bool) {
- part := mfgPart{}
-
- area, ok := mi.bsp.FlashMap.Areas[areaName]
- if !ok {
- return part, false
- }
-
- part.offset = area.Offset
- part.data = make([]byte, area.Size)
- part.name = area.Name
-
- return part, true
-}
-
func (mi *MfgImage) detectInvalidDevices() error {
sectionIds := mi.sectionIds()
deviceIds := mi.bsp.FlashMap.DeviceIds()
@@ -183,45 +169,33 @@ func (mi *MfgImage) detectOverlaps() error {
part1 mfgPart
}
- parts := []mfgPart{}
-
- // If an image slot is used, the entire flash area is unwritable. This
- // restriction comes from the boot loader's need to write status at the end
- // of an area.
- if mi.boot != nil {
- part, ok := mi.areaNameToPart(flash.FLASH_AREA_NAME_BOOTLOADER)
- if ok {
- parts = append(parts, part)
- }
- }
- if len(mi.images) >= 1 {
- part, ok := mi.areaNameToPart(flash.FLASH_AREA_NAME_IMAGE_0)
- if ok {
- parts = append(parts, part)
- }
- }
- if len(mi.images) >= 2 {
- part, ok := mi.areaNameToPart(flash.FLASH_AREA_NAME_IMAGE_1)
- if ok {
- parts = append(parts, part)
- }
- }
-
- parts = append(parts, mi.rawEntryParts()...)
- sortParts(parts)
-
overlaps := []overlap{}
- for i, part0 := range parts[:len(parts)-1] {
- part0End := part0.offset + len(part0.data)
- for _, part1 := range parts[i+1:] {
- // Parts are sorted by offset, so only one comparison is necessary
- // to detect overlap.
- if part1.offset < part0End {
- overlaps = append(overlaps, overlap{
- part0: part0,
- part1: part1,
- })
+ dpMap, err := mi.devicePartMap()
+ if err != nil {
+ return err
+ }
+
+ // Iterate flash devices in order.
+ devices := make([]int, 0, len(dpMap))
+ for device, _ := range dpMap {
+ devices = append(devices, device)
+ }
+ sort.Ints(devices)
+
+ for _, device := range devices {
+ parts := dpMap[device]
+ for i, part0 := range parts[:len(parts)-1] {
+ part0End := part0.offset + len(part0.data)
+ for _, part1 := range parts[i+1:] {
+ // Parts are sorted by offset, so only one comparison is
+ // necessary to detect overlap.
+ if part1.offset < part0End {
+ overlaps = append(overlaps, overlap{
+ part0: part0,
+ part1: part1,
+ })
+ }
}
}
}
@@ -232,7 +206,8 @@ func (mi *MfgImage) detectOverlaps() error {
part0End := overlap.part0.offset + len(overlap.part0.data)
part1End := overlap.part1.offset + len(overlap.part1.data)
- str += fmt.Sprintf("\n * [%s] (%d - %d) <=> [%s] (%d - %d)",
+ str += fmt.Sprintf("\n * s%d [%s] (%d - %d) <=> [%s] (%d - %d)",
+ overlap.part0.device,
overlap.part0.name, overlap.part0.offset, part0End,
overlap.part1.name, overlap.part1.offset, part1End)
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/cc1c2dd8/newt/mfg/mfg.go
----------------------------------------------------------------------
diff --git a/newt/mfg/mfg.go b/newt/mfg/mfg.go
index ea31f85..999c00f 100644
--- a/newt/mfg/mfg.go
+++ b/newt/mfg/mfg.go
@@ -26,8 +26,6 @@ import (
"mynewt.apache.org/newt/newt/target"
)
-const MFG_YAML_FILENAME string = "mfg.yml"
-
type MfgRawEntry struct {
device int
offset int
@@ -38,6 +36,7 @@ type MfgRawEntry struct {
// A chunk of data in the manufacturing image. Can be a firmware image or a
// raw entry (contents of a data file).
type mfgPart struct {
+ device int
offset int
data []byte
name string
[14/50] incubator-mynewt-newt git commit: newtmgr;
filter out echoed requests when doing oic over serial.
Posted by cc...@apache.org.
newtmgr; filter out echoed requests when doing oic over serial.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/afae040c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/afae040c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/afae040c
Branch: refs/heads/master
Commit: afae040cdffb632b34b422ec7d2f4a04c9ab5f62
Parents: 2ac611b
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Oct 26 16:21:27 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Oct 26 16:21:27 2016 -0700
----------------------------------------------------------------------
newtmgr/protocol/cmdrunner.go | 3 +++
newtmgr/protocol/omgr.go | 3 +++
2 files changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/afae040c/newtmgr/protocol/cmdrunner.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/cmdrunner.go b/newtmgr/protocol/cmdrunner.go
index 7ec3d56..0c2a151 100644
--- a/newtmgr/protocol/cmdrunner.go
+++ b/newtmgr/protocol/cmdrunner.go
@@ -51,6 +51,9 @@ func (cr *CmdRunner) ReadResp() (*NmgrReq, error) {
if err != nil {
return nil, err
}
+ if nmrfrag == nil {
+ continue
+ }
if nmrfrag.Op == NMGR_OP_READ_RSP || nmrfrag.Op == NMGR_OP_WRITE_RSP {
nmr.Data = append(nmr.Data, nmrfrag.Data...)
nmr.Len += nmrfrag.Len
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/afae040c/newtmgr/protocol/omgr.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/omgr.go b/newtmgr/protocol/omgr.go
index 29bff4c..b417546 100644
--- a/newtmgr/protocol/omgr.go
+++ b/newtmgr/protocol/omgr.go
@@ -46,6 +46,9 @@ func DeserializeOmgrReq(data []byte) (*NmgrReq, error) {
return nil, util.NewNewtError(fmt.Sprintf(
"Oicmgr request invalid %s", err.Error()))
}
+ if req.Code == coap.GET || req.Code == coap.PUT {
+ return nil, nil
+ }
if req.Code != coap.Created && req.Code != coap.Deleted &&
req.Code != coap.Valid && req.Code != coap.Changed &&
req.Code != coap.Content {
[16/50] incubator-mynewt-newt git commit: newt - expose paths of mfg
artifacts.
Posted by cc...@apache.org.
newt - expose paths of mfg artifacts.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/141160b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/141160b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/141160b2
Branch: refs/heads/master
Commit: 141160b285ac529cc376c8353a374c0c881db940
Parents: bc70c6a
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Oct 28 13:42:16 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Oct 28 13:42:16 2016 -0700
----------------------------------------------------------------------
newt/builder/paths.go | 22 +-----
newt/cli/mfg_cmds.go | 14 ++--
newt/flash/flash.go | 16 +++++
newt/mfg/create.go | 75 +++++++++++++-------
newt/mfg/load.go | 61 +++++++++++++++--
newt/mfg/mfg.go | 35 ++++++++++
newt/mfg/paths.go | 167 +++++++++++++++++++++++++++++++++++++++++++++
newt/mfg/read.go | 2 +-
8 files changed, 335 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/141160b2/newt/builder/paths.go
----------------------------------------------------------------------
diff --git a/newt/builder/paths.go b/newt/builder/paths.go
index 3f84a62..fa9e940 100644
--- a/newt/builder/paths.go
+++ b/newt/builder/paths.go
@@ -20,9 +20,7 @@
package builder
import (
- "fmt"
"path/filepath"
- "strconv"
"mynewt.apache.org/newt/newt/pkg"
"mynewt.apache.org/newt/newt/project"
@@ -89,28 +87,10 @@ func MfgBinDir(mfgPkgName string) string {
return BinRoot() + "/" + mfgPkgName
}
-func MfgBinBootDir(mfgPkgName string) string {
+func MfgBootDir(mfgPkgName string) string {
return MfgBinDir(mfgPkgName) + "/bootloader"
}
-// Image indices start at 0.
-func MfgBinImageDir(mfgPkgName string, imageIdx int) string {
- return MfgBinDir(mfgPkgName) + "/image" + strconv.Itoa(imageIdx)
-}
-
-func MfgSectionDir(mfgPkgName string) string {
- return MfgBinDir(mfgPkgName) + "/sections"
-}
-
-func MfgSectionPath(mfgPkgName string, sectionNum int) string {
- return fmt.Sprintf("%s/%s-s%d.bin", MfgSectionDir(mfgPkgName),
- filepath.Base(mfgPkgName), sectionNum)
-}
-
-func MfgManifestPath(mfgPkgName string) string {
- return MfgBinDir(mfgPkgName) + "/manifest.json"
-}
-
func (b *Builder) BinDir() string {
return BinDir(b.targetPkg.Name(), b.buildName)
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/141160b2/newt/cli/mfg_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/mfg_cmds.go b/newt/cli/mfg_cmds.go
index ee9d731..a8831c6 100644
--- a/newt/cli/mfg_cmds.go
+++ b/newt/cli/mfg_cmds.go
@@ -55,23 +55,25 @@ func resolveMfgPkg(pkgName string) (*pkg.LocalPackage, error) {
func mfgCreate(mi *mfg.MfgImage) {
pathStr := ""
- for _, path := range mi.SrcPaths() {
+ for _, path := range mi.FromPaths() {
pathStr += " * " + path + "\n"
}
util.StatusMessage(util.VERBOSITY_DEFAULT,
- "Creating a manufacturing image from the following files:\n%s",
+ "Creating a manufacturing image from the following files:\n%s\n",
pathStr)
- sectionPaths, err := mi.CreateMfgImage()
+ outputPaths, err := mi.CreateMfgImage()
if err != nil {
NewtUsage(nil, err)
}
- for _, sectionPath := range sectionPaths {
- util.StatusMessage(util.VERBOSITY_DEFAULT,
- "Created manufacturing section: %s\n", sectionPath)
+ pathStr = ""
+ for _, path := range outputPaths {
+ pathStr += " * " + path + "\n"
}
+ util.StatusMessage(util.VERBOSITY_DEFAULT,
+ "Generated the following files:\n%s", pathStr)
}
func mfgLoad(mi *mfg.MfgImage) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/141160b2/newt/flash/flash.go
----------------------------------------------------------------------
diff --git a/newt/flash/flash.go b/newt/flash/flash.go
index 4d7c3be..ea13e25 100644
--- a/newt/flash/flash.go
+++ b/newt/flash/flash.go
@@ -205,6 +205,22 @@ func (flashMap FlashMap) SortedAreas() []FlashArea {
return areas
}
+func (flashMap FlashMap) DeviceIds() []int {
+ deviceMap := map[int]struct{}{}
+
+ for _, area := range flashMap.Areas {
+ deviceMap[area.Device] = struct{}{}
+ }
+
+ devices := make([]int, 0, len(deviceMap))
+ for device, _ := range deviceMap {
+ devices = append(devices, device)
+ }
+ sort.Ints(devices)
+
+ return devices
+}
+
func areasDistinct(a FlashArea, b FlashArea) bool {
var lo FlashArea
var hi FlashArea
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/141160b2/newt/mfg/create.go
----------------------------------------------------------------------
diff --git a/newt/mfg/create.go b/newt/mfg/create.go
index 46058f3..2a7f36f 100644
--- a/newt/mfg/create.go
+++ b/newt/mfg/create.go
@@ -172,7 +172,7 @@ func (mi *MfgImage) rawEntryParts() []mfgPart {
return parts
}
-func bootLoaderBinPaths(t *target.Target) []string {
+func bootLoaderFromPaths(t *target.Target) []string {
return []string{
/* boot.elf */
builder.AppElfPath(t.Name(), builder.BUILD_NAME_APP, t.App().Name()),
@@ -185,7 +185,7 @@ func bootLoaderBinPaths(t *target.Target) []string {
}
}
-func loaderBinPaths(t *target.Target) []string {
+func loaderFromPaths(t *target.Target) []string {
if t.LoaderName == "" {
return nil
}
@@ -201,7 +201,7 @@ func loaderBinPaths(t *target.Target) []string {
}
}
-func appBinPaths(t *target.Target) []string {
+func appFromPaths(t *target.Target) []string {
return []string{
/* <app>.elf */
builder.AppElfPath(t.Name(), builder.BUILD_NAME_APP, t.App().Name()),
@@ -214,9 +214,9 @@ func appBinPaths(t *target.Target) []string {
}
}
-func imageBinPaths(t *target.Target) []string {
- paths := loaderBinPaths(t)
- paths = append(paths, appBinPaths(t)...)
+func imageFromPaths(t *target.Target) []string {
+ paths := loaderFromPaths(t)
+ paths = append(paths, appFromPaths(t)...)
return paths
}
@@ -234,22 +234,22 @@ func (mi *MfgImage) copyBinFile(srcPath string, dstDir string) error {
}
func (mi *MfgImage) copyBinFiles() error {
- dstPath := builder.MfgBinDir(mi.basePkg.Name())
+ dstPath := MfgBinDir(mi.basePkg.Name())
if err := os.MkdirAll(filepath.Dir(dstPath), 0755); err != nil {
return util.ChildNewtError(err)
}
- bootPaths := bootLoaderBinPaths(mi.boot)
+ bootPaths := bootLoaderFromPaths(mi.boot)
for _, path := range bootPaths {
- dstDir := builder.MfgBinBootDir(mi.basePkg.Name())
+ dstDir := MfgBootDir(mi.basePkg.Name())
if err := mi.copyBinFile(path, dstDir); err != nil {
return err
}
}
for i, imgTarget := range mi.images {
- imgPaths := imageBinPaths(imgTarget)
- dstDir := builder.MfgBinImageDir(mi.basePkg.Name(), i)
+ imgPaths := imageFromPaths(imgTarget)
+ dstDir := MfgImageBinDir(mi.basePkg.Name(), i)
for _, path := range imgPaths {
if err := mi.copyBinFile(path, dstDir); err != nil {
return err
@@ -266,7 +266,7 @@ func (mi *MfgImage) dstBootBinPath() string {
}
return fmt.Sprintf("%s/%s.elf.bin",
- builder.MfgBinBootDir(mi.basePkg.Name()),
+ MfgBootDir(mi.basePkg.Name()),
pkg.ShortName(mi.boot.App()))
}
@@ -305,7 +305,7 @@ func (mi *MfgImage) dstImgPath(slotIdx int) string {
}
return fmt.Sprintf("%s/%s.img",
- builder.MfgBinImageDir(mi.basePkg.Name(), imgIdx), pkg.ShortName(pack))
+ MfgImageBinDir(mi.basePkg.Name(), imgIdx), pkg.ShortName(pack))
}
func (mi *MfgImage) targetParts() ([]mfgPart, error) {
@@ -343,17 +343,17 @@ func (mi *MfgImage) targetParts() ([]mfgPart, error) {
// Returns a slice containing the path of each file required to build the
// manufacturing image.
-func (mi *MfgImage) SrcPaths() []string {
+func (mi *MfgImage) FromPaths() []string {
paths := []string{}
if mi.boot != nil {
- paths = append(paths, bootLoaderBinPaths(mi.boot)...)
+ paths = append(paths, bootLoaderFromPaths(mi.boot)...)
}
if len(mi.images) >= 1 {
- paths = append(paths, imageBinPaths(mi.images[0])...)
+ paths = append(paths, imageFromPaths(mi.images[0])...)
}
if len(mi.images) >= 2 {
- paths = append(paths, imageBinPaths(mi.images[1])...)
+ paths = append(paths, imageFromPaths(mi.images[1])...)
}
for _, raw := range mi.rawEntries {
@@ -401,25 +401,52 @@ func (mi *MfgImage) createManifest(hash []byte) ([]byte, error) {
return buffer, nil
}
-// @return [paths-of-sections], error
+func appendNonEmptyStr(dst []string, src string) []string {
+ if src != "" {
+ dst = append(dst, src)
+ }
+
+ return dst
+}
+
+func (mi *MfgImage) ToPaths() []string {
+ paths := []string{}
+
+ paths = appendNonEmptyStr(paths, mi.BootBinPath())
+ paths = appendNonEmptyStr(paths, mi.BootElfPath())
+ paths = appendNonEmptyStr(paths, mi.BootManifestPath())
+
+ for i := 0; i < len(mi.images); i++ {
+ paths = appendNonEmptyStr(paths, mi.LoaderImgPath(i))
+ paths = appendNonEmptyStr(paths, mi.LoaderElfPath(i))
+ paths = appendNonEmptyStr(paths, mi.AppImgPath(i))
+ paths = appendNonEmptyStr(paths, mi.AppElfPath(i))
+ paths = appendNonEmptyStr(paths, mi.ImageManifestPath(i))
+ }
+
+ paths = append(paths, mi.SectionBinPaths()...)
+ paths = append(paths, mi.ManifestPath())
+
+ return paths
+}
+
+// @return [paths-of-artifacts], error
func (mi *MfgImage) CreateMfgImage() ([]string, error) {
sections, hash, err := mi.build()
if err != nil {
return nil, err
}
- sectionDir := builder.MfgSectionDir(mi.basePkg.Name())
+ sectionDir := MfgSectionBinDir(mi.basePkg.Name())
if err := os.MkdirAll(sectionDir, 0755); err != nil {
return nil, util.ChildNewtError(err)
}
- sectionPaths := make([]string, len(sections))
for i, section := range sections {
- sectionPath := builder.MfgSectionPath(mi.basePkg.Name(), i)
+ sectionPath := MfgSectionBinPath(mi.basePkg.Name(), i)
if err := ioutil.WriteFile(sectionPath, section, 0644); err != nil {
return nil, util.ChildNewtError(err)
}
- sectionPaths[i] = sectionPath
}
manifest, err := mi.createManifest(hash)
@@ -427,11 +454,11 @@ func (mi *MfgImage) CreateMfgImage() ([]string, error) {
return nil, err
}
- manifestPath := builder.MfgManifestPath(mi.basePkg.Name())
+ manifestPath := mi.ManifestPath()
if err := ioutil.WriteFile(manifestPath, manifest, 0644); err != nil {
return nil, util.FmtNewtError("Failed to write mfg manifest file: %s",
err.Error())
}
- return sectionPaths, nil
+ return mi.ToPaths(), nil
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/141160b2/newt/mfg/load.go
----------------------------------------------------------------------
diff --git a/newt/mfg/load.go b/newt/mfg/load.go
index d8e660f..6e986ae 100644
--- a/newt/mfg/load.go
+++ b/newt/mfg/load.go
@@ -23,6 +23,7 @@ import (
"fmt"
"io/ioutil"
"sort"
+ "strconv"
"strings"
"github.com/spf13/cast"
@@ -82,23 +83,36 @@ func (mi *MfgImage) loadRawEntry(
raw := MfgRawEntry{}
+ var err error
+
+ deviceStr := rawEntry["device"]
+ if deviceStr == "" {
+ return raw, mi.loadError(
+ "raw entry %d missing required \"device\" field", entryIdx)
+ }
+
+ raw.device, err = util.AtoiNoOct(deviceStr)
+ if err != nil {
+ return raw, mi.loadError(
+ "raw entry %d contains invalid offset: %s", entryIdx, deviceStr)
+ }
+
offsetStr := rawEntry["offset"]
if offsetStr == "" {
return raw, mi.loadError(
- "raw rawEntry %d missing required \"offset\" field", entryIdx)
+ "raw entry %d missing required \"offset\" field", entryIdx)
}
- var err error
raw.offset, err = util.AtoiNoOct(offsetStr)
if err != nil {
return raw, mi.loadError(
- "raw rawEntry %d contains invalid offset: %s", entryIdx, offsetStr)
+ "raw entry %d contains invalid offset: %s", entryIdx, offsetStr)
}
raw.filename = rawEntry["file"]
if raw.filename == "" {
return raw, mi.loadError(
- "raw rawEntry %d missing required \"file\" field", entryIdx)
+ "raw entry %d missing required \"file\" field", entryIdx)
}
if !strings.HasPrefix(raw.filename, "/") {
@@ -108,7 +122,7 @@ func (mi *MfgImage) loadRawEntry(
raw.data, err = ioutil.ReadFile(raw.filename)
if err != nil {
return raw, mi.loadError(
- "error loading file for raw rawEntry %d; filename=%s: %s",
+ "error loading file for raw entry %d; filename=%s: %s",
entryIdx, raw.filename, err.Error())
}
@@ -130,6 +144,39 @@ func (mi *MfgImage) areaNameToPart(areaName string) (mfgPart, bool) {
return part, true
}
+func (mi *MfgImage) detectInvalidDevices() error {
+ sectionIds := mi.sectionIds()
+ deviceIds := mi.bsp.FlashMap.DeviceIds()
+
+ deviceMap := map[int]struct{}{}
+ for _, device := range deviceIds {
+ deviceMap[device] = struct{}{}
+ }
+
+ invalidIds := []int{}
+ for _, sectionId := range sectionIds {
+ if _, ok := deviceMap[sectionId]; !ok {
+ invalidIds = append(invalidIds, sectionId)
+ }
+ }
+
+ if len(invalidIds) == 0 {
+ return nil
+ }
+
+ listStr := ""
+ for i, id := range invalidIds {
+ if i != 0 {
+ listStr += ", "
+ }
+ listStr += strconv.Itoa(id)
+ }
+
+ return util.FmtNewtError(
+ "image specifies flash devices that are not present in the BSP's "+
+ "flash map: %s", listStr)
+}
+
func (mi *MfgImage) detectOverlaps() error {
type overlap struct {
part0 mfgPart
@@ -275,6 +322,10 @@ func Load(basePkg *pkg.LocalPackage) (*MfgImage, error) {
}
}
+ if err := mi.detectInvalidDevices(); err != nil {
+ return nil, err
+ }
+
if err := mi.detectOverlaps(); err != nil {
return nil, err
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/141160b2/newt/mfg/mfg.go
----------------------------------------------------------------------
diff --git a/newt/mfg/mfg.go b/newt/mfg/mfg.go
index 30e25b2..6805ab9 100644
--- a/newt/mfg/mfg.go
+++ b/newt/mfg/mfg.go
@@ -20,6 +20,8 @@
package mfg
import (
+ "sort"
+
"mynewt.apache.org/newt/newt/pkg"
"mynewt.apache.org/newt/newt/target"
)
@@ -27,6 +29,7 @@ import (
const MFG_YAML_FILENAME string = "mfg.yml"
type MfgRawEntry struct {
+ device int
offset int
filename string
data []byte
@@ -49,3 +52,35 @@ type MfgImage struct {
images []*target.Target
rawEntries []MfgRawEntry
}
+
+func (mi *MfgImage) imgApps(imageIdx int) (
+ app *pkg.LocalPackage, loader *pkg.LocalPackage) {
+
+ if imageIdx >= len(mi.images) {
+ return
+ }
+
+ t := mi.images[imageIdx]
+ app = t.App()
+ loader = t.Loader()
+ return
+}
+
+func (mi *MfgImage) sectionIds() []int {
+ idMap := map[int]struct{}{}
+
+ // The bootloader and images always go in section 0.
+ idMap[0] = struct{}{}
+
+ for _, entry := range mi.rawEntries {
+ idMap[entry.device] = struct{}{}
+ }
+
+ ids := make([]int, 0, len(idMap))
+ for id, _ := range idMap {
+ ids = append(ids, id)
+ }
+ sort.Ints(ids)
+
+ return ids
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/141160b2/newt/mfg/paths.go
----------------------------------------------------------------------
diff --git a/newt/mfg/paths.go b/newt/mfg/paths.go
new file mode 100644
index 0000000..cd9d38f
--- /dev/null
+++ b/newt/mfg/paths.go
@@ -0,0 +1,167 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package mfg
+
+import (
+ "fmt"
+ "path/filepath"
+ "strconv"
+
+ "mynewt.apache.org/newt/newt/builder"
+ "mynewt.apache.org/newt/newt/pkg"
+)
+
+func MfgBinDir(mfgPkgName string) string {
+ return builder.BinRoot() + "/" + mfgPkgName
+}
+
+func MfgBootDir(mfgPkgName string) string {
+ return MfgBinDir(mfgPkgName) + "/bootloader"
+}
+
+func MfgBootBinPath(mfgPkgName string, appName string) string {
+ return MfgBootDir(mfgPkgName) + "/" + appName + ".elf.bin"
+}
+
+func MfgBootElfPath(mfgPkgName string, appName string) string {
+ return MfgBootDir(mfgPkgName) + "/" + appName + ".elf"
+}
+
+func MfgBootManifestPath(mfgPkgName string, appName string) string {
+ return MfgBootDir(mfgPkgName) + "/manifest.json"
+}
+
+// Image indices start at 0.
+func MfgImageBinDir(mfgPkgName string, imageIdx int) string {
+ return MfgBinDir(mfgPkgName) + "/image" + strconv.Itoa(imageIdx)
+}
+
+func MfgImageImgPath(mfgPkgName string, imageIdx int,
+ appName string) string {
+
+ return MfgImageBinDir(mfgPkgName, imageIdx) + "/" + appName + ".img"
+}
+
+func MfgImageElfPath(mfgPkgName string, imageIdx int,
+ appName string) string {
+
+ return MfgImageBinDir(mfgPkgName, imageIdx) + "/" + appName + ".elf"
+}
+
+func MfgImageManifestPath(mfgPkgName string, imageIdx int) string {
+ return MfgImageBinDir(mfgPkgName, imageIdx) + "/manifest.json"
+}
+
+func MfgSectionBinDir(mfgPkgName string) string {
+ return MfgBinDir(mfgPkgName) + "/sections"
+}
+
+func MfgSectionBinPath(mfgPkgName string, sectionNum int) string {
+ return fmt.Sprintf("%s/%s-s%d.bin", MfgSectionBinDir(mfgPkgName),
+ filepath.Base(mfgPkgName), sectionNum)
+}
+
+func MfgManifestPath(mfgPkgName string) string {
+ return MfgBinDir(mfgPkgName) + "/manifest.json"
+}
+
+func (mi *MfgImage) ManifestPath() string {
+ return MfgManifestPath(mi.basePkg.Name())
+}
+
+func (mi *MfgImage) BootBinPath() string {
+ if mi.boot == nil {
+ return ""
+ }
+
+ return MfgBootBinPath(mi.basePkg.Name(),
+ pkg.ShortName(mi.boot.Package()))
+}
+
+func (mi *MfgImage) BootElfPath() string {
+ if mi.boot == nil {
+ return ""
+ }
+
+ return MfgBootElfPath(mi.basePkg.Name(), pkg.ShortName(mi.boot.Package()))
+}
+
+func (mi *MfgImage) BootManifestPath() string {
+ if mi.boot == nil {
+ return ""
+ }
+
+ return MfgBootManifestPath(mi.basePkg.Name(),
+ pkg.ShortName(mi.boot.Package()))
+}
+
+func (mi *MfgImage) AppImgPath(imageIdx int) string {
+ app, _ := mi.imgApps(imageIdx)
+ if app == nil {
+ return ""
+ }
+
+ return MfgImageImgPath(mi.basePkg.Name(), imageIdx, pkg.ShortName(app))
+}
+
+func (mi *MfgImage) AppElfPath(imageIdx int) string {
+ app, _ := mi.imgApps(imageIdx)
+ if app == nil {
+ return ""
+ }
+
+ return MfgImageElfPath(mi.basePkg.Name(), imageIdx, pkg.ShortName(app))
+}
+
+func (mi *MfgImage) LoaderImgPath(imageIdx int) string {
+ _, loader := mi.imgApps(imageIdx)
+ if loader == nil {
+ return ""
+ }
+
+ return MfgImageImgPath(mi.basePkg.Name(), imageIdx, pkg.ShortName(loader))
+}
+
+func (mi *MfgImage) LoaderElfPath(imageIdx int) string {
+ _, loader := mi.imgApps(imageIdx)
+ if loader == nil {
+ return ""
+ }
+
+ return MfgImageElfPath(mi.basePkg.Name(), imageIdx, pkg.ShortName(loader))
+}
+
+func (mi *MfgImage) ImageManifestPath(imageIdx int) string {
+ if imageIdx >= len(mi.images) {
+ return ""
+ }
+
+ return MfgImageManifestPath(mi.basePkg.Name(), imageIdx)
+}
+
+func (mi *MfgImage) SectionBinPaths() []string {
+ sectionIds := mi.sectionIds()
+
+ paths := make([]string, len(sectionIds))
+ for i, sectionId := range sectionIds {
+ paths[i] = MfgSectionBinPath(mi.basePkg.Name(), sectionId)
+ }
+ return paths
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/141160b2/newt/mfg/read.go
----------------------------------------------------------------------
diff --git a/newt/mfg/read.go b/newt/mfg/read.go
index a947494..04520db 100644
--- a/newt/mfg/read.go
+++ b/newt/mfg/read.go
@@ -28,7 +28,7 @@ import (
// @return mfg-image-path, error
func (mi *MfgImage) Upload() (string, error) {
// For now, we always upload section 0 only.
- section0Path := builder.MfgSectionPath(mi.basePkg.Name(), 0)
+ section0Path := MfgSectionBinPath(mi.basePkg.Name(), 0)
baseName := strings.TrimSuffix(section0Path, ".bin")
envSettings := map[string]string{"MFG_IMAGE": "1"}
[44/50] incubator-mynewt-newt git commit: newt;
pull 'develop' blinky with this version of newt.
Posted by cc...@apache.org.
newt; pull 'develop' blinky with this version of newt.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/6434dada
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/6434dada
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/6434dada
Branch: refs/heads/master
Commit: 6434dada6a47f885c0f6c76be13f3707cd74827a
Parents: a30bf2d
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Nov 9 10:44:05 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Nov 9 10:44:05 2016 -0800
----------------------------------------------------------------------
newt/newtutil/newtutil.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/6434dada/newt/newtutil/newtutil.go
----------------------------------------------------------------------
diff --git a/newt/newtutil/newtutil.go b/newt/newtutil/newtutil.go
index ddb2e94..d7369d9 100644
--- a/newt/newtutil/newtutil.go
+++ b/newt/newtutil/newtutil.go
@@ -34,7 +34,7 @@ import (
)
var NewtVersionStr string = "Apache Newt (incubating) version: 1.0.0-develop"
-var NewtBlinkyTag string = "mynewt_1_0_0_develop_tag"
+var NewtBlinkyTag string = "develop"
const NEWTRC_DIR string = ".newt"
const REPOS_FILENAME string = "repos.yml"
[02/50] incubator-mynewt-newt git commit: newt - Create manifests at
build-time
Posted by cc...@apache.org.
newt - Create manifests at build-time
Previously, newt only created a manifest when creating an image. This
had the potential to be misleading, as the list of git commits didn't
necessarily reflect what went into the build.
Now, manifest creation is done in two steps:
1. Create manifest at build time ("newt build").
This initial manifest contains the following fields:
* build_time
* pkgs
* loader_pkgs
* target
* repos
2. Augment manifest at image creation time.
The following fields are added to the existing manifest:
* build_version
* id
* image
* image_hash
* loader
* loader_hash
An "added bonus" is that boot loaders now have manifests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/5c047acd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/5c047acd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/5c047acd
Branch: refs/heads/master
Commit: 5c047acd8c314a406a5dd3e0630ce4df54b628fa
Parents: 3e7b198
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Oct 25 19:32:45 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Oct 25 20:33:51 2016 -0700
----------------------------------------------------------------------
newt/builder/targetbuild.go | 188 ++++++++++++++++++++++++++-------------
1 file changed, 124 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/5c047acd/newt/builder/targetbuild.go
----------------------------------------------------------------------
diff --git a/newt/builder/targetbuild.go b/newt/builder/targetbuild.go
index cbfb7f9..7d1dce3 100644
--- a/newt/builder/targetbuild.go
+++ b/newt/builder/targetbuild.go
@@ -22,6 +22,7 @@ package builder
import (
"encoding/json"
"fmt"
+ "io/ioutil"
"os"
"path/filepath"
"sort"
@@ -290,56 +291,25 @@ func (t *TargetBuilder) PrepBuild() error {
return nil
}
-func (t *TargetBuilder) Build() error {
- var err error
- var linkerScript string
-
- if err = t.PrepBuild(); err != nil {
- return err
- }
-
- /* Build the Apps */
- project.ResetDeps(t.AppList)
-
- if err := t.bspPkg.Reload(t.AppBuilder.cfg.Features()); err != nil {
- return err
- }
-
- err = t.AppBuilder.Build()
- if err != nil {
- return err
- }
-
- /* if we have no loader, we are done here. All of the rest of this
- * function is for split images */
- if t.LoaderBuilder == nil {
- err = t.AppBuilder.Link(t.bspPkg.LinkerScript)
- return err
- }
-
+func (t *TargetBuilder) buildLoader() error {
/* Link the app as a test (using the normal single image linker script) */
- err = t.AppBuilder.TestLink(t.bspPkg.LinkerScript)
- if err != nil {
+ if err := t.AppBuilder.TestLink(t.bspPkg.LinkerScript); err != nil {
return err
}
/* rebuild the loader */
project.ResetDeps(t.LoaderList)
- if err = t.bspPkg.Reload(t.LoaderBuilder.cfg.Features()); err != nil {
+ if err := t.bspPkg.Reload(t.LoaderBuilder.cfg.Features()); err != nil {
return err
}
- err = t.LoaderBuilder.Build()
-
- if err != nil {
+ if err := t.LoaderBuilder.Build(); err != nil {
return err
}
/* perform a test link of the loader */
- err = t.LoaderBuilder.TestLink(t.bspPkg.LinkerScript)
-
- if err != nil {
+ if err := t.LoaderBuilder.TestLink(t.bspPkg.LinkerScript); err != nil {
return err
}
@@ -362,15 +332,57 @@ func (t *TargetBuilder) Build() error {
/* set up the linker elf and linker script for the app */
t.AppBuilder.linkElf = t.LoaderBuilder.AppLinkerElfPath()
- linkerScript = t.bspPkg.Part2LinkerScript
+ linkerScript := t.bspPkg.Part2LinkerScript
if linkerScript == "" {
return util.NewNewtError("BSP must specify linker script ")
}
- /* link the app */
- err = t.AppBuilder.Link(linkerScript)
- if err != nil {
+ return nil
+
+}
+
+func (t *TargetBuilder) Build() error {
+ if err := t.PrepBuild(); err != nil {
+ return err
+ }
+
+ /* Build the Apps */
+ project.ResetDeps(t.AppList)
+
+ if err := t.bspPkg.Reload(t.AppBuilder.cfg.Features()); err != nil {
+ return err
+ }
+
+ if err := t.AppBuilder.Build(); err != nil {
+ return err
+ }
+
+ linkerScript := ""
+ if t.LoaderBuilder == nil {
+ linkerScript = t.bspPkg.LinkerScript
+ if linkerScript == "" {
+ return util.NewNewtError("BSP does not specify linker script")
+ }
+ } else {
+ if err := t.buildLoader(); err != nil {
+ return err
+ }
+
+ linkerScript = t.bspPkg.Part2LinkerScript
+ if linkerScript == "" {
+ return util.NewNewtError(
+ "BSP does not specify part 2 linker script for split image")
+ }
+ }
+
+ /* Link the app. */
+ if err := t.AppBuilder.Link(linkerScript); err != nil {
+ return err
+ }
+
+ /* Create manifest. */
+ if err := t.createManifest(); err != nil {
return err
}
@@ -554,42 +566,40 @@ func (t *TargetBuilder) GetTarget() *target.Target {
return t.target
}
-func (t *TargetBuilder) createManifest(
- appImg *image.Image,
- loaderImg *image.Image,
- buildId []byte) error {
+func readManifest(path string) (*image.ImageManifest, error) {
+ content, err := ioutil.ReadFile(path)
+ if err != nil {
+ return nil, util.ChildNewtError(err)
+ }
- versionStr := fmt.Sprintf("%d.%d.%d.%d",
- appImg.Version.Major, appImg.Version.Minor,
- appImg.Version.Rev, appImg.Version.BuildNum)
- hashStr := fmt.Sprintf("%x", appImg.Hash)
- timeStr := time.Now().Format(time.RFC3339)
+ manifest := &image.ImageManifest{}
+ if err := json.Unmarshal(content, &manifest); err != nil {
+ return nil, util.FmtNewtError(
+ "Failure decoding manifest with path \"%s\": %s", err.Error())
+ }
+ return manifest, nil
+}
+
+func (t *TargetBuilder) createManifest() error {
manifest := &image.ImageManifest{
- Version: versionStr,
- ImageHash: hashStr,
- Image: filepath.Base(appImg.TargetImg),
- Date: timeStr,
+ Date: time.Now().Format(time.RFC3339),
}
rm := image.NewRepoManager()
- for _, builtPkg := range t.AppBuilder.PkgMap {
+ for _, lpkg := range t.AppBuilder.sortedLocalPackages() {
manifest.Pkgs = append(manifest.Pkgs,
- rm.GetImageManifestPkg(builtPkg.LocalPackage))
+ rm.GetImageManifestPkg(lpkg))
}
- if loaderImg != nil {
- manifest.Loader = filepath.Base(loaderImg.TargetImg)
- manifest.LoaderHash = fmt.Sprintf("%x", loaderImg.Hash)
-
- for _, builtPkg := range t.LoaderBuilder.PkgMap {
+ if t.LoaderBuilder != nil {
+ for _, lpkg := range t.LoaderBuilder.sortedLocalPackages() {
manifest.LoaderPkgs = append(manifest.LoaderPkgs,
- rm.GetImageManifestPkg(builtPkg.LocalPackage))
+ rm.GetImageManifestPkg(lpkg))
}
}
- manifest.Repos = rm.AllRepos()
- manifest.BuildID = fmt.Sprintf("%x", buildId)
+ manifest.Repos = rm.AllRepos()
vars := t.GetTarget().Vars
keys := make([]string, 0, len(vars))
@@ -620,6 +630,56 @@ func (t *TargetBuilder) createManifest(
return nil
}
+// Reads an existing manifest file and augments it with image fields:
+// * Image version
+// * App image path
+// * App image hash
+// * Loader image path
+// * Loader image hash
+// * Build ID
+func (t *TargetBuilder) augmentManifest(
+ appImg *image.Image,
+ loaderImg *image.Image,
+ buildId []byte) error {
+
+ manifest, err := readManifest(t.AppBuilder.ManifestPath())
+ if err != nil {
+ return err
+ }
+
+ manifest.Version = fmt.Sprintf("%d.%d.%d.%d",
+ appImg.Version.Major, appImg.Version.Minor,
+ appImg.Version.Rev, appImg.Version.BuildNum)
+ manifest.ImageHash = fmt.Sprintf("%x", appImg.Hash)
+ manifest.Image = filepath.Base(appImg.TargetImg)
+
+ if loaderImg != nil {
+ manifest.Loader = filepath.Base(loaderImg.TargetImg)
+ manifest.LoaderHash = fmt.Sprintf("%x", loaderImg.Hash)
+ }
+
+ manifest.BuildID = fmt.Sprintf("%x", buildId)
+
+ file, err := os.Create(t.AppBuilder.ManifestPath())
+ if err != nil {
+ return util.FmtNewtError("Cannot create manifest file %s: %s",
+ t.AppBuilder.ManifestPath(), err.Error())
+ }
+ defer file.Close()
+
+ buffer, err := json.MarshalIndent(manifest, "", " ")
+ if err != nil {
+ return util.FmtNewtError("Cannot encode manifest: %s", err.Error())
+ }
+ _, err = file.Write(buffer)
+ if err != nil {
+ return util.FmtNewtError("Cannot write manifest file: %s",
+ err.Error())
+ }
+
+ return nil
+}
+
// @return app-image, loader-image, error
func (t *TargetBuilder) CreateImages(version string,
keystr string, keyId uint8) (*image.Image, *image.Image, error) {
@@ -646,7 +706,7 @@ func (t *TargetBuilder) CreateImages(version string,
}
buildId := image.CreateBuildId(appImg, loaderImg)
- if err := t.createManifest(appImg, loaderImg, buildId); err != nil {
+ if err := t.augmentManifest(appImg, loaderImg, buildId); err != nil {
return nil, nil, err
}
[40/50] incubator-mynewt-newt git commit: newt - Fix compile error
introduced in a7be46a
Posted by cc...@apache.org.
newt - Fix compile error introduced in a7be46a
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/56b708d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/56b708d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/56b708d4
Branch: refs/heads/master
Commit: 56b708d4ff23017251c0e920120c4a650bcc95bc
Parents: a7be46a
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Nov 8 13:27:51 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Nov 8 13:27:51 2016 -0800
----------------------------------------------------------------------
newt/mfg/meta.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/56b708d4/newt/mfg/meta.go
----------------------------------------------------------------------
diff --git a/newt/mfg/meta.go b/newt/mfg/meta.go
index 8dc4ed5..87aabe0 100644
--- a/newt/mfg/meta.go
+++ b/newt/mfg/meta.go
@@ -182,7 +182,7 @@ func insertMeta(section0Data []byte, flashMap flash.FlashMap) (
}
for _, area := range flashMap.SortedAreas() {
- if err := writeFlashArea(area, buf); err != nil {
+ if err := writeFlashMapEntry(area, buf); err != nil {
return 0, 0, err
}
}
[46/50] incubator-mynewt-newt git commit: newt - Fix crash for 'newt
target copy'
Posted by cc...@apache.org.
newt - Fix crash for 'newt target copy'
The base path was incorrect for the local repo.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/dd9b6440
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/dd9b6440
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/dd9b6440
Branch: refs/heads/master
Commit: dd9b6440dd50eeeffad1058bf5e65c2dc86d47d9
Parents: dd34193
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Nov 9 15:06:16 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Nov 9 15:06:16 2016 -0800
----------------------------------------------------------------------
newt/pkg/localpackage.go | 1 +
newt/project/project.go | 2 +-
newt/repo/repo.go | 18 ++++++++++++------
3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/dd9b6440/newt/pkg/localpackage.go
----------------------------------------------------------------------
diff --git a/newt/pkg/localpackage.go b/newt/pkg/localpackage.go
index d984a73..26c2252 100644
--- a/newt/pkg/localpackage.go
+++ b/newt/pkg/localpackage.go
@@ -383,6 +383,7 @@ func (pkg *LocalPackage) Clone(newRepo *repo.Repo,
// Insert the clone into the global package map.
proj := interfaces.GetProject()
pMap := proj.PackageList()
+
(*pMap[newRepo.Name()])[newPkg.name] = &newPkg
return &newPkg
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/dd9b6440/newt/project/project.go
----------------------------------------------------------------------
diff --git a/newt/project/project.go b/newt/project/project.go
index ae2c0e5..7fb070d 100644
--- a/newt/project/project.go
+++ b/newt/project/project.go
@@ -458,7 +458,7 @@ func (proj *Project) loadConfig() error {
proj.name = v.GetString("project.name")
// Local repository always included in initialization
- r, err := repo.NewLocalRepo()
+ r, err := repo.NewLocalRepo(proj.name)
if err != nil {
return err
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/dd9b6440/newt/repo/repo.go
----------------------------------------------------------------------
diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index 7a5c654..bf95dab 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -49,6 +49,7 @@ type Repo struct {
deps []*RepoDependency
ignDirs []string
updated bool
+ local bool
}
type RepoDesc struct {
@@ -90,7 +91,8 @@ func (r *Repo) ignoreDir(dir string) bool {
func (repo *Repo) FilteredSearchList(curPath string) ([]string, error) {
list := []string{}
- dirList, err := ioutil.ReadDir(filepath.Join(repo.Path(), curPath))
+ path := filepath.Join(repo.Path(), curPath)
+ dirList, err := ioutil.ReadDir(path)
if err != nil {
return list, util.FmtNewtError("failed to read repo \"%s\": %s",
repo.Name(), err.Error())
@@ -539,7 +541,7 @@ func (r *Repo) Init(repoName string, rversreq string, d downloader.Downloader) e
path := interfaces.GetProject().Path()
- if r.name == REPO_NAME_LOCAL {
+ if r.local {
r.localPath = filepath.Clean(path)
} else {
r.localPath = filepath.Clean(path + "/" + REPOS_DIR + "/" + r.name)
@@ -549,7 +551,9 @@ func (r *Repo) Init(repoName string, rversreq string, d downloader.Downloader) e
}
func NewRepo(repoName string, rversreq string, d downloader.Downloader) (*Repo, error) {
- r := &Repo{}
+ r := &Repo{
+ local: false,
+ }
if err := r.Init(repoName, rversreq, d); err != nil {
return nil, err
@@ -558,10 +562,12 @@ func NewRepo(repoName string, rversreq string, d downloader.Downloader) (*Repo,
return r, nil
}
-func NewLocalRepo() (*Repo, error) {
- r := &Repo{}
+func NewLocalRepo(repoName string) (*Repo, error) {
+ r := &Repo{
+ local: true,
+ }
- if err := r.Init(REPO_NAME_LOCAL, "", nil); err != nil {
+ if err := r.Init(repoName, "", nil); err != nil {
return nil, err
}
[39/50] incubator-mynewt-newt git commit: newt - Fix some typos.
Posted by cc...@apache.org.
newt - Fix some typos.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/eb6d0819
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/eb6d0819
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/eb6d0819
Branch: refs/heads/master
Commit: eb6d0819ea35f9e42bbd8f98b16a19203f74537b
Parents: c71f226
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Nov 8 13:25:25 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Nov 8 13:25:25 2016 -0800
----------------------------------------------------------------------
newt/builder/build.go | 2 +-
newt/builder/targetbuild.go | 2 +-
newt/toolchain/deps.go | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/eb6d0819/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index 276a742..d5bc998 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -589,7 +589,7 @@ func (b *Builder) buildRomElf(common *symbol.SymbolMap) error {
}
}
- bld, err := d.RomElfBuldRequired(b.AppLinkerElfPath(),
+ bld, err := d.RomElfBuildRequired(b.AppLinkerElfPath(),
b.AppElfPath(), archNames)
if err != nil {
return err
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/eb6d0819/newt/builder/targetbuild.go
----------------------------------------------------------------------
diff --git a/newt/builder/targetbuild.go b/newt/builder/targetbuild.go
index e044b43..b3a5570 100644
--- a/newt/builder/targetbuild.go
+++ b/newt/builder/targetbuild.go
@@ -477,7 +477,7 @@ func (t *TargetBuilder) RelinkLoader() (error, map[string]bool,
if len(badpkgs) > 0 {
errStr := fmt.Sprintf(
- "Common packages with different implementaiton\n %s \n",
+ "Common packages with different implementation\n %s\n",
strings.Join(badpkgs, "\n "))
errStr += symbolStr
return util.NewNewtError(errStr), nil, nil
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/eb6d0819/newt/toolchain/deps.go
----------------------------------------------------------------------
diff --git a/newt/toolchain/deps.go b/newt/toolchain/deps.go
index aad0dd6..a0ab37c 100644
--- a/newt/toolchain/deps.go
+++ b/newt/toolchain/deps.go
@@ -385,11 +385,11 @@ func (tracker *DepTracker) LinkRequired(dstFile string,
/* Building a ROM elf is used for shared application linking.
* A ROM elf requires a rebuild if any of archives (.a files) are newer
* than the rom elf, or if the elf file is newer than the rom_elf */
-func (tracker *DepTracker) RomElfBuldRequired(dstFile string, elfFile string,
+func (tracker *DepTracker) RomElfBuildRequired(dstFile string, elfFile string,
archFiles []string) (bool, error) {
- // If the rom_elf file doesn't exist or is older than any input file, a rebuild
- // is required.
+ // If the rom_elf file doesn't exist or is older than any input file, a
+ // rebuild is required.
dstModTime, err := util.FileModificationTime(dstFile)
if err != nil {
return false, err
[48/50] incubator-mynewt-newt git commit: MYNEWT-476;
if package source has .a's, include them when linking.
Posted by cc...@apache.org.
MYNEWT-476; if package source has .a's, include them when linking.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/93cf30fb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/93cf30fb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/93cf30fb
Branch: refs/heads/master
Commit: 93cf30fbe0b908de14f7bf630348da7efd0602d6
Parents: f9159f5
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Nov 9 17:10:18 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Nov 9 17:10:18 2016 -0800
----------------------------------------------------------------------
newt/builder/build.go | 23 ++++++++++++-----
newt/toolchain/compiler.go | 57 +++++++++++++++++++++++++++++++++++++----
newt/toolchain/deps.go | 27 +++++++++++++++++++
3 files changed, 95 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/93cf30fb/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index d5bc998..82798fb 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -176,6 +176,12 @@ func buildDir(srcDir string, c *toolchain.Compiler, arch string,
return err
}
+ // Copy in pre-compiled library files
+ if err := c.RecursiveCompile(toolchain.COMPILER_TYPE_ARCHIVE,
+ append(ignDirs, "arch")); err != nil {
+ return err
+ }
+
archDir := srcDir + "/arch/" + arch + "/"
if util.NodeExist(archDir) {
util.StatusMessage(util.VERBOSITY_VERBOSE,
@@ -204,6 +210,12 @@ func buildDir(srcDir string, c *toolchain.Compiler, arch string,
return err
}
+
+ // Copy in pre-compiled library files
+ if err := c.RecursiveCompile(toolchain.COMPILER_TYPE_ARCHIVE,
+ ignDirs); err != nil {
+ return err
+ }
}
return nil
@@ -322,9 +334,8 @@ func (b *Builder) link(elfName string, linkerScripts []string,
pkgNames := []string{}
for _, bpkg := range b.PkgMap {
- if util.NodeExist(b.ArchivePath(bpkg)) {
- pkgNames = append(pkgNames, b.ArchivePath(bpkg))
- }
+ archiveNames, _ := filepath.Glob(b.PkgBinDir(bpkg) + "/*.a")
+ pkgNames = append(pkgNames, archiveNames...)
}
c.LinkerScripts = linkerScripts
@@ -583,10 +594,8 @@ func (b *Builder) buildRomElf(common *symbol.SymbolMap) error {
/* build the set of archive file names */
for _, bpkg := range b.PkgMap {
- archivePath := b.ArchivePath(bpkg)
- if util.NodeExist(archivePath) {
- archNames = append(archNames, archivePath)
- }
+ archiveNames, _ := filepath.Glob(b.PkgBinDir(bpkg) + "/*.a")
+ archNames = append(archNames, archiveNames...)
}
bld, err := d.RomElfBuildRequired(b.AppLinkerElfPath(),
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/93cf30fb/newt/toolchain/compiler.go
----------------------------------------------------------------------
diff --git a/newt/toolchain/compiler.go b/newt/toolchain/compiler.go
index c139a28..42af123 100644
--- a/newt/toolchain/compiler.go
+++ b/newt/toolchain/compiler.go
@@ -42,9 +42,10 @@ import (
const COMPILER_FILENAME string = "compiler.yml"
const (
- COMPILER_TYPE_C = 0
- COMPILER_TYPE_ASM = 1
- COMPILER_TYPE_CPP = 2
+ COMPILER_TYPE_C = 0
+ COMPILER_TYPE_ASM = 1
+ COMPILER_TYPE_CPP = 2
+ COMPILER_TYPE_ARCHIVE = 3
)
type CompilerInfo struct {
@@ -595,6 +596,46 @@ func (c *Compiler) CompileAs() error {
return nil
}
+// Copies all archive files matching the specified file glob.
+//
+// @param match The file glob specifying which assembly files
+// to compile.
+func (c *Compiler) CopyArchive() error {
+ files, _ := filepath.Glob("*.a")
+
+ wd, err := os.Getwd()
+ if err != nil {
+ return err
+ }
+
+ log.Infof("Copying archive if outdated (%s/*.a) %s", wd,
+ strings.Join(files, " "))
+ for _, file := range files {
+ if shouldIgnore := c.shouldIgnoreFile(file); shouldIgnore {
+ log.Infof("Ignoring %s because package dictates it.", file)
+ continue
+ }
+
+ tgtFile := c.DstDir() + "/" +
+ strings.TrimSuffix(file, filepath.Ext(file)) + ".a"
+ copyRequired, err := c.depTracker.CopyRequired(file)
+ if err != nil {
+ return err
+ }
+ if copyRequired {
+ err = util.CopyFile(file, tgtFile)
+ util.StatusMessage(util.VERBOSITY_DEFAULT, "copying %s\n",
+ filepath.ToSlash(tgtFile))
+ }
+
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
func (c *Compiler) processEntry(wd string, node os.FileInfo, cType int,
ignDirs []string) error {
@@ -657,6 +698,8 @@ func (c *Compiler) RecursiveCompile(cType int, ignDirs []string) error {
return c.CompileAs()
case COMPILER_TYPE_CPP:
return c.CompileCpp()
+ case COMPILER_TYPE_ARCHIVE:
+ return c.CopyArchive()
default:
return util.NewNewtError("Wrong compiler type specified to " +
"RecursiveCompile")
@@ -978,14 +1021,18 @@ func (c *Compiler) CompileArchive(archiveFile string) error {
return util.NewNewtError(err.Error())
}
+ // Delete the old archive, if it exists.
+ err = os.Remove(archiveFile)
+
util.StatusMessage(util.VERBOSITY_DEFAULT, "Archiving %s\n",
path.Base(archiveFile))
objList := c.getObjFiles([]string{})
+ if objList == "" {
+ return nil
+ }
util.StatusMessage(util.VERBOSITY_VERBOSE, "Archiving %s with object "+
"files %s\n", archiveFile, objList)
- // Delete the old archive, if it exists.
- err = os.Remove(archiveFile)
if err != nil && !os.IsNotExist(err) {
return util.NewNewtError(err.Error())
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/93cf30fb/newt/toolchain/deps.go
----------------------------------------------------------------------
diff --git a/newt/toolchain/deps.go b/newt/toolchain/deps.go
index a0ab37c..86ec2cc 100644
--- a/newt/toolchain/deps.go
+++ b/newt/toolchain/deps.go
@@ -418,3 +418,30 @@ func (tracker *DepTracker) RomElfBuildRequired(dstFile string, elfFile string,
}
return false, nil
}
+
+// Determines if the specified static library needs to be copied. The
+// library needs to be archived if any of the following is true:
+// * The destination library file does not exist.
+// * Source object files has a newer modification time than the
+// target file.
+func (tracker *DepTracker) CopyRequired(srcFile string) (bool, error) {
+
+ tgtFile := tracker.compiler.DstDir() + "/" + filepath.Base(srcFile)
+
+ // If the target doesn't exist or is older than source file, a copy
+ // is required.
+ srcModTime, err := util.FileModificationTime(srcFile)
+ if err != nil {
+ return false, err
+ }
+ tgtModTime, err := util.FileModificationTime(tgtFile)
+ if err != nil {
+ return false, err
+ }
+ if srcModTime.After(tgtModTime) {
+ return true, nil
+ }
+
+ // The target is up to date.
+ return false, nil
+}
[30/50] incubator-mynewt-newt git commit: Correct MTU for CBOR BLE
transport
Posted by cc...@apache.org.
Correct MTU for CBOR BLE transport
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/67dc62ae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/67dc62ae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/67dc62ae
Branch: refs/heads/master
Commit: 67dc62ae98201c7ef12935480b464051d4359223
Parents: 9a4dd3e
Author: Vipul Rahane <vi...@apache.org>
Authored: Thu Nov 3 19:14:38 2016 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Thu Nov 3 19:15:28 2016 -0700
----------------------------------------------------------------------
newtmgr/cli/image.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/67dc62ae/newtmgr/cli/image.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index 7bcb879..f4a200e 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -251,7 +251,7 @@ func imageUploadCmd(cmd *cobra.Command, args []string) {
rexmits := 0
if profile.Type() == "ble" {
- mtu = uint32((transport.BleMTU - 33) * 3 / 4)
+ mtu = uint32((transport.BleMTU - 64) * 3 / 4)
} else {
/* since this possibly gets base 64 encoded, we want
* to ensure that the payload leaving this layer is 91
[33/50] incubator-mynewt-newt git commit: Allow BSP to specify
repository-relative paths
Posted by cc...@apache.org.
Allow BSP to specify repository-relative paths
This affects the following BSP settings:
* bsp.linkerscript
* bsp.part2linkerscript
* bsp.downloadscript
* bsp.debugscript
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/9dbb073c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/9dbb073c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/9dbb073c
Branch: refs/heads/master
Commit: 9dbb073c4ffda7946ac4ef7f59d12ecc7b55e044
Parents: 0fa7895
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Nov 4 17:56:44 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Nov 4 17:56:44 2016 -0700
----------------------------------------------------------------------
newt/builder/build.go | 2 +-
newt/builder/load.go | 12 +++++-----
newt/interfaces/interfaces.go | 1 +
newt/pkg/bsp_package.go | 45 ++++++++++++++++++++++++++++++++------
newt/project/project.go | 23 ++++++++++++++++++-
5 files changed, 67 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/9dbb073c/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index 6e2f9b5..abdba35 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -328,7 +328,7 @@ func (b *Builder) link(elfName string, linkerScript string,
}
if linkerScript != "" {
- c.LinkerScript = b.bspPkg.BasePath() + "/" + linkerScript
+ c.LinkerScript = linkerScript
}
err = c.CompileElf(elfName, pkgNames, keepSymbols, b.linkElf)
if err != nil {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/9dbb073c/newt/builder/load.go
----------------------------------------------------------------------
diff --git a/newt/builder/load.go b/newt/builder/load.go
index 46cb506..ec07f1f 100644
--- a/newt/builder/load.go
+++ b/newt/builder/load.go
@@ -22,7 +22,6 @@ package builder
import (
"fmt"
"os"
- "path/filepath"
"sort"
"strconv"
@@ -59,7 +58,6 @@ func Load(binBaseName string, bspPkg *pkg.BspPackage,
}
bspPath := bspPkg.BasePath()
- downloadScript := filepath.Join(bspPath, bspPkg.DownloadScript)
sortedKeys := make([]string, 0, len(extraEnvSettings))
for k, _ := range extraEnvSettings {
@@ -79,8 +77,8 @@ func Load(binBaseName string, bspPkg *pkg.BspPackage,
// bspPath, binBaseName are passed in command line for backwards
// compatibility
- downloadCmd := fmt.Sprintf("%s %s %s %s", envSettings, downloadScript,
- bspPath, binBaseName)
+ downloadCmd := fmt.Sprintf("%s %s %s %s", envSettings,
+ bspPkg.DownloadScript, bspPath, binBaseName)
util.StatusMessage(util.VERBOSITY_VERBOSE, "Load command: %s\n",
downloadCmd)
@@ -198,13 +196,13 @@ func (b *Builder) Debug(extraJtagCmd string, reset bool, noGDB bool) error {
envSettings = append(envSettings, fmt.Sprintf("NO_GDB=1"))
}
- debugScript := filepath.Join(bspPath, b.targetBuilder.bspPkg.DebugScript)
-
os.Chdir(project.GetProject().Path())
// bspPath, binBaseName are passed in command line for backwards
// compatibility
- cmdLine := []string{debugScript, bspPath, binBaseName}
+ cmdLine := []string{
+ b.targetBuilder.bspPkg.DebugScript, bspPath, binBaseName,
+ }
fmt.Printf("%s\n", cmdLine)
return util.ShellInteractiveCommand(cmdLine, envSettings)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/9dbb073c/newt/interfaces/interfaces.go
----------------------------------------------------------------------
diff --git a/newt/interfaces/interfaces.go b/newt/interfaces/interfaces.go
index 5bafdf7..602c8bb 100644
--- a/newt/interfaces/interfaces.go
+++ b/newt/interfaces/interfaces.go
@@ -60,6 +60,7 @@ type ProjectInterface interface {
Name() string
Path() string
ResolveDependency(dep DependencyInterface) PackageInterface
+ ResolvePath(basePath string, name string) (string, error)
PackageList() PackageList
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/9dbb073c/newt/pkg/bsp_package.go
----------------------------------------------------------------------
diff --git a/newt/pkg/bsp_package.go b/newt/pkg/bsp_package.go
index a57a31a..d89149b 100644
--- a/newt/pkg/bsp_package.go
+++ b/newt/pkg/bsp_package.go
@@ -23,6 +23,7 @@ import (
"strings"
"mynewt.apache.org/newt/newt/flash"
+ "mynewt.apache.org/newt/newt/interfaces"
"mynewt.apache.org/newt/newt/newtutil"
"mynewt.apache.org/newt/util"
"mynewt.apache.org/newt/viper"
@@ -38,13 +39,28 @@ type BspPackage struct {
Part2LinkerScript string /* script to link app to second partition */
DownloadScript string
DebugScript string
- WriteScript string
FlashMap flash.FlashMap
BspV *viper.Viper
}
+func (bsp *BspPackage) resolvePathSetting(
+ features map[string]bool, key string) (string, error) {
+
+ outVal := newtutil.GetStringFeatures(bsp.BspV, features, key)
+
+ proj := interfaces.GetProject()
+ path, err := proj.ResolvePath(bsp.BasePath(), outVal)
+ if err != nil {
+ return "", util.PreNewtError(err,
+ "BSP \"%s\" specifies invalid %s setting",
+ bsp.Name(), key)
+ }
+ return path, nil
+}
+
func (bsp *BspPackage) Reload(features map[string]bool) error {
var err error
+
bsp.BspV, err = util.ReadConfig(bsp.BasePath(),
strings.TrimSuffix(BSP_YAML_FILENAME, ".yml"))
if err != nil {
@@ -54,18 +70,33 @@ func (bsp *BspPackage) Reload(features map[string]bool) error {
bsp.CompilerName = newtutil.GetStringFeatures(bsp.BspV,
features, "bsp.compiler")
+
bsp.Arch = newtutil.GetStringFeatures(bsp.BspV,
features, "bsp.arch")
- bsp.LinkerScript = newtutil.GetStringFeatures(bsp.BspV,
+
+ bsp.LinkerScript, err = bsp.resolvePathSetting(
features, "bsp.linkerscript")
- bsp.Part2LinkerScript = newtutil.GetStringFeatures(bsp.BspV,
+ if err != nil {
+ return err
+ }
+
+ bsp.Part2LinkerScript, err = bsp.resolvePathSetting(
features, "bsp.part2linkerscript")
- bsp.DownloadScript = newtutil.GetStringFeatures(bsp.BspV,
+ if err != nil {
+ return err
+ }
+
+ bsp.DownloadScript, err = bsp.resolvePathSetting(
features, "bsp.downloadscript")
- bsp.DebugScript = newtutil.GetStringFeatures(bsp.BspV,
+ if err != nil {
+ return err
+ }
+
+ bsp.DebugScript, err = bsp.resolvePathSetting(
features, "bsp.debugscript")
- bsp.WriteScript = newtutil.GetStringFeatures(bsp.BspV,
- features, "bsp.writescript")
+ if err != nil {
+ return err
+ }
if bsp.CompilerName == "" {
return util.NewNewtError("BSP does not specify a compiler " +
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/9dbb073c/newt/project/project.go
----------------------------------------------------------------------
diff --git a/newt/project/project.go b/newt/project/project.go
index 95ee367..45f7405 100644
--- a/newt/project/project.go
+++ b/newt/project/project.go
@@ -523,7 +523,6 @@ func (proj *Project) ResolveDependency(dep interfaces.DependencyInterface) inter
func (proj *Project) ResolvePackage(
dfltRepo interfaces.RepoInterface, name string) (*pkg.LocalPackage, error) {
-
// Trim trailing slash from name. This is necessary when tab
// completion is used to specify the name.
name = strings.TrimSuffix(name, "/")
@@ -557,6 +556,28 @@ func (proj *Project) ResolvePackage(
return pack.(*pkg.LocalPackage), nil
}
+// Resolves a path with an optional repo prefix (e.g., "@apache-mynewt-core").
+func (proj *Project) ResolvePath(
+ basePath string, name string) (string, error) {
+
+ repoName, subPath, err := newtutil.ParsePackageString(name)
+ if err != nil {
+ return "", util.FmtNewtError("invalid path: %s (%s)", name,
+ err.Error())
+ }
+
+ if repoName == "" {
+ return basePath + "/" + subPath, nil
+ } else {
+ repo := proj.repos[repoName]
+ if repo == nil {
+ return "", util.FmtNewtError("Unknown repository: %s", repoName)
+ }
+
+ return repo.Path() + "/" + subPath, nil
+ }
+}
+
func findProjectDir(dir string) (string, error) {
for {
projFile := path.Clean(dir) + "/" + PROJECT_FILE_NAME