Not able to build an image for ZCU104 with Yocto - embedded-linux

I am trying to build my first image with Yocto for a Xilinx Eval Board ZCU104. As I am just a beginner I installed the required packages to work with Poky and stuck to the following simple steps:
I cloned Poky: git clone git://git.yoctoproject.org/poky
source oe-init-build-env: a build directory was created.
In the build directory I cloned the meta-xilinx layers: git clone git#github.com:Xilinx/meta-xilinx.git
I read the README.md and README.building.md files from meta-xilinx/meta-xilinx-bsp to find what to do next.
I used the command bitbake-layers add-layer to add the following layers: meta-xilinx-bsp, meta-xilinx-standalone and meta-xilinx-contrib. I can see those layers in bblayers.conf.
I edited MACHINE in local.conf: MACHINE ?= zcu104-zynqmp
I think I am good to go so I call bitbake -k core-image-minimal and expect a succesful build.
Bitbake started to parse until it throwed the following error:
ERROR: ParseError at
//poky/build/meta-xilinx/meta-xilinx-bsp/recipes-bsp/uboot-device-tree/uboot-device-tree.bb:11:
Could not inherit file classes/xsctdt.bbclass
I looked for that class under /meta-xilinx-bsp/classes and it is not there, but I found it in the meta-xilinx repository so I started wondering why I didn't get that class (among others).
Note that I did not switch to any branch yet (either yocto or meta-xilinx) and I stayed on the master branches. I gave it a second try after switching to the latest tags from both projects but I got the following error:
ERROR: Layer xilinx is not compatible with the core layer which only
supports these series: gatesgarth (layer is compatible with zeus)
What should I try next? Should I checkout other branches? If so, is there any index to link the right yocto and meta-xilinx branches?
Anyways, how come I am missing necessary classes from the repository when I clone it?
Thanks a lot!

Checkout the branches named the same way in each layer you're using (poky included). The branches are usually named after Yocto releases. It's usually wise to avoid the master branch.
If there is no branch of a given Yocto release for a layer, look into what seems to be a recent branch and check in conf/layer.conf for the LAYERSERIES_COMPAT variable. Find a branch which has a LAYERSERIES_COMPAT with the Yocto release you want to use. If there are none, you'll need to add the Yocto release to said variable and fix things along the way until it compiles and everything is working fine.
c.f.: https://docs.yoctoproject.org/ref-manual/variables.html#term-LAYERSERIES_COMPAT

Related

go get fails for hashicorp/levant

I inherited a build script that builds a docker image and uses hashicorp/levant library to deploy. For a year or so we have been running go get github.com/jrasell/levant to grab the levant library. In past few days, the repo URL was merged under Hashicorp's organization and we've changed our script to pull with go get github.com/hashicorp/levant. But either way, we get this multi assign error. What does this mean, doesn't 'go' just basically pull the git repo?
../go/src/github.com/hashicorp/levant/template/render.go:28:11: cannot assign
*"github.com/hashicorp/nomad/vendor/github.com/hashicorp/nomad/api".Job to job
(type *"github.com/hashicorp/nomad/api".Job) in multiple assignment
Firstly, go get works with packages, not repositories.
In addition to pulling them go get also compiles and installs them, and here's when your error pops up.
More info here:
https://nanxiao.gitbooks.io/golang-101-hacks/content/posts/go-get-command.html
I recommend you to use Go modules.
hashicorp/levant does have go.{mod,sum} files and hence you should forget using the go get way.
It's better to do a clone and follow the go module way i.e.,
git clone git#github.com:hashicorp/levant.git
go test ./...
go build ./...
The steps with not only just clone your repo but would also bring your dependent packages required for building/ testing the package.
Note: You should have Go v1.11+

Processing: apply core patch and compile

I want to apply this patch
https://github.com/processing/processing/pull/5881
into my own processing core for use in my PDE. How do I go about ?
i can take the source here
https://github.com/processing/processing
apply the patch
compile that (eg using javac) to get a core.jar
But in the App, there are two core.jars :
Processing.app/Contents/Java/core/library/core.jar
and
Processing.app/Contents/Java/core.jar
which one is what ?
Did this:
read this howto
https://github.com/processing/processing/blob/master/build/howto.txt
clone this repo
https://github.com/processing/processing
downloaded the correct version java
get an account at oracle.com
and download java (in my case 8u202) here
https://www.oracle.com/java/technologies/javase-java-archive-javase8-downloads.html
and install that.
build the app with ant
Go into your cloned repo and
cd build
ant run
This builds a processing PDE in the build/ directory of your repo
and opens it. It works.
apply the patch and build it again
git checkout -b pull/5881
git pull origin pull/5881/head
ant run
That creates a new branch, pulls the patch I wanted to apply, applies that, builds the PDE again and runs it.
And the patch fixed my problem :-)

Building dependent packages with BitBake separately

We have a collection of related, and partly interdependent, packages. They live in separate Git repositories. Like:
git#bitbucket.company:common
git#bitbucket.company:libfoo
depends on common
git#bitbucket.company:libbar
depends on common
git#bitbucket.compnay:libbarex
depends on libbar
git#bitbucket.company:daemon
depends on common
final-image (just an image recipe)
depends on libfoo, libbar, libbarex, daemon
The packages are currently built by setting up the Yocto environment, checking out all of them and running bitbake with the image target that depends on all of them. The checkout is done with logic containing special logic. That is
git clone https://git.yoctoproject.org/git/poky
git clone -b $BRANCH git#bitbucket.company:common
git clone -b $BRANCH git#bitbucket.company:libfoo
git clone -b $BRANCH git#bitbucket.company:libbar
git clone -b $BRANCH git#bitbucket.company:libbarex
git clone -b $BRANCH git#bitbucket.company:daemon
. poky/oe-init-build-env
../common/add-layers.sh
bitbake final-image
The disadvantage is that the CI server does not understand the configuration management side of things, so it can't do things like building each pull-request, not to mention reporting it back to the Git repository manager to gate the pull-requests on it.
So I would like to start splitting the build to build each package separately, pulling the dependencies according to some specification that shall be updated as needed.
But how do I do that?
I can add
bitbake -c populate_sdk final-image
to the main build, and then use the SDK to build individual components. However that means that any changes in common have to be merged, and the SDK rebuilt, before I can build libfoo, libbar or daemon and additionally changes to libbar have to be merged before I can build libbarex.
Can I push the results of these incremental builds to some kind of repository and pull them back to build the dependent component without having to rebuild the SDK?

How does testing work when working in a forked repo in golang?

Consider a situation where a test is failing in a golang project, say "github.com/originaluser/reponame".
A person who wants to fix the bug forks the repo into github.com/forkeduser/reponame" and then go gets it into his local machine.
The test will fail on his machine even after he fixes the bug if the test file is importing from "github.com/originaluser/reponame" because his changes have not been merged with the original project.
How does testing work in such a scenario?
The only resource I found was a splice.com blog
Just a short and simple solution it to clone the forked repository into the original repository path.
Step 1: create the path github.com/originaluser/reponame inside your gopath.
Step 2: change the working directory to your new folder
Step 3: git clone github.com/forkeduser/reponame.git
Step 4: fix the bug
Because now your fix is inside the original path, everything works.

Modifying an imported library in Go

My Problem
Elastic Beats is an open source project for log shippers written in Go. It features several log outputs, including console, Elasticsearch and Redis. I would like to add an output of my own - to AWS Kinesis.
I have cloned the repo to ~/github/beats, and tried building it:
$ cd filebeat; go build main.go
However, it failed due to a missing library which is a part of the project:
main.go:6:2: cannot find package "github.com/elastic/beats/filebeat/cmd" in any of:
/usr/local/go/src/github.com/elastic/beats/filebeat/cmd (from $GOROOT)
/Users/adam/go/src/github.com/elastic/beats/filebeat/cmd (from $GOPATH)
A directory of the project is dependent on a package from the same repo, but instead of looking one directory up the hierarchy it looks in the GOPATH.
So, go get github.com/elastic/beats/filebeat/cmd fetched the code, and now go build main.go works. Changing the code in my GOPATH is reflected in these builds.
This leaves me with an structural inconvenience. Some of my code is at a working directory, and some of it is at my GOPATH and included by the code in my working directory.
I would like to have all my code in a single directory for various reasons, not the least being keeping everything under version control.
What Have I Tried
Mostly searching for the problem. I am quite new to Go, so I might have missed the correct terminology.
My Question
What is the right way to edit the code of an imported library in Go?
One of the recommended ways to work with other's packages is:
Get the sources of the original package:
go get github.com/elastic/beats
As a result you will clone project's git repository to the folder
$GOPATH/src/github.com/elastic/beats
Make some fixes, compile code, fix, compile... When you make go install package will be compiled and installed to your system. When you need merge updates from original repository you can git pull them.
Everything is OK. What's next? How to share your work with others?
Fork project on github, suppose it will be github.com/username/beats
Add this fork as another remote mycopy (or any other name you like) to your local repository
git remote add mycopy git://github.com/username/beats.git
When all is done you can push updated sources to your repo on github
git push mycopy
and then open a pull-request to original sources. This way you can share your work with others. And keep your changes in sync with mainstream.
Previous answers to this question are obsolete when developing projects that using Go Modules.
For projects that using Go Modules, one may use the following command to replace an imported library(eg. example.com/imported/module) with a local module(eg. ./local/module):
go mod edit -replace=example.com/imported/module=./local/module
Or by adding the following line into the go.mod file:
replace example.com/imported/module => ./local/module
Reference Docs: https://golang.org/doc/modules/managing-dependencies#unpublished
A project working copy should be checked out into $GOPATH/src/package/import/path - for example, this project should be checked out into /Users/adam/go/src/github.com/elastic/beats. With the project in the correct location, the go tooling will be able to operate on it normally; otherwise, it will not be able to resolve imports correctly. See go help gopath for more info.

Resources