Build mender from the source code?

389 views
Skip to first unread message

LoveMeow

unread,
Dec 18, 2017, 9:08:44 AM12/18/17
to Mender List mender.io
Hi,

I was wondering if it is possible to build mender directly on the board from the source code for Apalis Imx6 (using make)?
Which source code should I use for this purpose?

Thanks
Meow

Kristian Amlie

unread,
Dec 18, 2017, 9:23:04 AM12/18/17
to men...@lists.mender.io, LoveMeow
Yes, it's possible. You need the ARM package from here:
https://golang.org/dl/. And the usual tools like make and git installed
on the board.

Then you can do:

git clone https://github.com/mendersoftware/mender
cd mender
git checkout 1.2.1
make

The resulting binary you can put in /usr/bin.

*But*, it's important to remember that the binary alone doesn't give you
everything you need to use Mender, since the bootloader and partition
layout is important as well, and these you get using Yocto.

--
Kristian

LoveMeow

unread,
Dec 18, 2017, 12:17:42 PM12/18/17
to Mender List mender.io, ramapriya...@rapyuta-robotics.com
hi,

I followed your instructions, when I make mender I run into the following errors related to go?:

root@apalis-imx6:~/mender# make
go build -ldflags "-X main.Version=1.2.1" 
deployment_log_hook.go:20:2: cannot find package "github.com/Sirupsen/logrus" in any of:
        /home/root/go/src/github.com/Sirupsen/logrus (from $GOROOT)
        /home/root/go_workspace/src/github.com/Sirupsen/logrus (from $GOPATH)
auth.go:20:2: cannot find package "github.com/mendersoftware/log" in any of:
        /home/root/go/src/github.com/mendersoftware/log (from $GOROOT)
        /home/root/go_workspace/src/github.com/mendersoftware/log (from $GOPATH)
auth.go:21:2: cannot find package "github.com/mendersoftware/mender/client" in any of:
        /home/root/go/src/github.com/mendersoftware/mender/client (from $GOROOT)
        /home/root/go_workspace/src/github.com/mendersoftware/mender/client (from $GOPATH)
mender.go:29:2: cannot find package "github.com/mendersoftware/mender/installer" in any of:
        /home/root/go/src/github.com/mendersoftware/mender/installer (from $GOROOT)
        /home/root/go_workspace/src/github.com/mendersoftware/mender/installer (from $GOPATH)
mender.go:30:2: cannot find package "github.com/mendersoftware/mender/statescript" in any of:
        /home/root/go/src/github.com/mendersoftware/mender/statescript (from $GOROOT)
        /home/root/go_workspace/src/github.com/mendersoftware/mender/statescript (from $GOPATH)
auth.go:22:2: cannot find package "github.com/mendersoftware/mender/store" in any of:
        /home/root/go/src/github.com/mendersoftware/mender/store (from $GOROOT)
        /home/root/go_workspace/src/github.com/mendersoftware/mender/store (from $GOPATH)
block_device.go:20:2: cannot find package "github.com/mendersoftware/mender/utils" in any of:
        /home/root/go/src/github.com/mendersoftware/mender/utils (from $GOROOT)
        /home/root/go_workspace/src/github.com/mendersoftware/mender/utils (from $GOPATH)
auth.go:23:2: cannot find package "github.com/pkg/errors" in any of:
        /home/root/go/src/github.com/pkg/errors (from $GOROOT)
        /home/root/go_workspace/src/github.com/pkg/errors (from $GOPATH)
ioctl.go:23:2: cannot find package "github.com/ungerik/go-sysfs" in any of:
        /home/root/go/src/github.com/ungerik/go-sysfs (from $GOROOT)
        /home/root/go_workspace/src/github.com/ungerik/go-sysfs (from $GOPATH)
Makefile:37: recipe for target 'build' failed
make: *** [build] Error 1

What should I set GOPATH to?

Thanks
Meow

Kristian Amlie

unread,
Dec 19, 2017, 2:40:18 AM12/19/17
to men...@lists.mender.io, LoveMeow
Sorry, I forgot that you also need to clone mender inside the directory
structure that Go expects. So you should clone it like this:

mkdir -p $HOME/go/src/github.com/mendersoftware
cd $HOME/go/src/github.com/mendersoftware
git clone https://github.com/mendersoftware/mender
cd mender
git checkout 1.2.1
make

I think that should get rid of the errors.

--
Kristian

Kristian Amlie

unread,
Dec 21, 2017, 4:06:19 AM12/21/17
to Ramapriya Sridharan, mender
On 20/12/17 12:37, Ramapriya Sridharan wrote:
> Additionally, is there anyway to create a mender artifact appart from
> bitbaking?
> Bitbaking somehow does not work on my computer (problems with loading
> toradex)

There is some information about that here:
https://mender.io/blog/porting-mender-to-a-non-yocto-build-system

Keep in the mind that the blog post is a year old now, and it's not an
easy path to go down compared to Yocto. But we know people have had
success with this approach.

--
Kristian

LoveMeow

unread,
Dec 21, 2017, 9:14:09 AM12/21/17
to Mender List mender.io, ramapriya...@rapyuta-robotics.com

Hi,

Thanks, I followed the instructions and I am having a problem with running mender. When I run mender I get the following:

root@apalis-imx6:/usr/local/go/src/github.com/mendersoftware/mender# mender -daemon
ERRO[0000] failed to open DB environment: mdb_env_open: no such file or directory  module=dbstore
ERRO[0000] failed to initialize DB store                 module=main


Are any dependencies missing on Apalis?

Additionally, I cannot see my device on the server? These are my mender.conf contents:

{
  "ClientProtocol": "http",
  "HttpsClient": {
    "Certificate": "",
    "Key": ""
  },
  "RootfsPartA": "/dev/mmcblk0p2",
  "RootfsPartB": "/dev/mmcblk0p2",
  "UpdatePollIntervalSeconds": 30,
  "InventoryPollIntervalSeconds": 30,
  "RetryPollIntervalSeconds": 30,
  "ServerURL": "https://blah/",
  "ServerCertificate": "/etc/mender/server.crt"
}

I copied server.crt from your github page, and setup the identity and inventory of my machine like in the documentation.

I also generated ssh key pair using keygen, but I am not sure where to place the keys obtained on client and server? I just need it working in demo mode. I followed instructions here : https://docs.mender.io/1.2/Administration/Certificates-and-keys

and generated it like this:
CERT_API_CN=https://blah:443 CERT_STORAGE_CN=s3.docker.mender.io ./keygen

I modified CERT_API_CN to my ip since apalis needs to access server on my computer right? I did not change CERT_STORAGE_CN.
I was able to generate the keygen. The server is in the docker container like in the demo.

I was wondering what changes I should make to get rid of the error and get my device to appear on the server?

Thanks
Meow

LoveMeow

unread,
Dec 21, 2017, 11:40:49 AM12/21/17
to Mender List mender.io, ramapriya...@rapyuta-robotics.com
Hi,

I was finally able to start mender, this is what I get:

root@apalis-imx6:/usr/share/mender# mender --debug --daemon
DEBU[0000] Reading Mender configuration from file /etc/mender/mender.conf  module=config
DEBU[0000] block type: RSA PRIVATE KEY                   module=keystore
INFO[0000] State transition: init [none] -> init [none]  module=mender
DEBU[0000] no state data stored                          module=state
INFO[0000] State transition: init [none] -> idle [Idle]  module=mender
DEBU[0000] statescript: timeout for executing scripts is not defined; using default of 60 seconds  module=executor
INFO[0000] State transition: idle [Idle] -> authorize [Sync]  module=mender
DEBU[0000] statescript: timeout for executing scripts is not defined; using default of 60 seconds  module=executor
DEBU[0000] statescript: timeout for executing scripts is not defined; using default of 60 seconds  module=executor
DEBU[0000] handle authorize state                        module=state
ERRO[0000] authorize failed: transient error: authorization request failed: failed to build authorization request: failed to obtain authorization message data: failed to obtain identity data: failed to call /usr/share/mender/identity/mender-device-identity: fork/exec /usr/share/mender/identity/mender-device-identity: exec format error  module=state
INFO[0000] State transition: authorize [Sync] -> authorize-wait [Idle]  module=mender
DEBU[0000] statescript: timeout for executing scripts is not defined; using default of 60 seconds  module=executor
DEBU[0000] statescript: timeout for executing scripts is not defined; using default of 60 seconds  module=executor
DEBU[0000] handle authorize wait state                   module=state
DEBU[0000] wait 30s before next authorization attempt    module=state
DEBU[0030] wait complete                                 module=state
INFO[0030] State transition: authorize-wait [Idle] -> authorize [Sync]  module=mender
DEBU[0030] statescript: timeout for executing scripts is not defined; using default of 60 seconds  module=executor
DEBU[0030] statescript: timeout for executing scripts is not defined; using default of 60 seconds  module=executor
DEBU[0030] handle authorize state                        module=state
ERRO[0030] authorize failed: transient error: authorization request failed: failed to build authorization request: failed to obtain authorization message data: failed to obtain identity data: failed to call /usr/share/mender/identity/mender-device-identity: fork/exec /usr/share/mender/identity/mender-device-identity: exec format error  module=state
INFO[0030] State transition: authorize [Sync] -> authorize-wait [Idle]  module=mender
DEBU[0030] statescript: timeout for executing scripts is not defined; using default of 60 seconds  module=executor
DEBU[0030] statescript: timeout for executing scripts is not defined; using default of 60 seconds  module=executor
DEBU[0030] handle authorize wait state                   module=state
DEBU[0030] wait 30s before next authorization attempt    module=state


This is my identity script output:
DeviceID=abcd1234
ip=10.41.1.41
using interface eth0
mac=00:14:2d:4b:aa:20

my device does not appear on the server either.

Meow
Reply all
Reply to author
Forward
0 new messages