summaryrefslogtreecommitdiff
path: root/BUILD.md
blob: f8f0b0e3f9974468430218c0d7b9c8466539e091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Yocto build instructions for Pelion Edge firmware on Raspberry Pi

The following are instructions for building Pelion Edge firmware for the Raspberry Pi. Pelion Edge firmware is a Yocto Linux Raspberry Pi build which includes the meta (meta-pelion-edge) included in this repository.

For convenience, the manual instructions below have been automated in repositories for [Environment](https://github.com/armpelionedge/manifest-pelion-os-edge) and [Build](https://github.com/armpelionedge/build-pelion-os-edge).
See also [instructions for flashing the image](https://github.com/armpelionedge/meta-pelion-edge-ww/blob/master/FLASH.md) onto an SD card.

## Manual instructions

Note:
All of the instructions in this document were built and tested with Docker CE on [Ubuntu 18.10](https://docs.docker.com/install/linux/docker-ce/ubuntu/).

### Requirements

[Install Yocto system requirements](https://www.yoctoproject.org/docs/2.6.1/ref-manual/ref-manual.html#ref-manual-system-requirements)

Install additional requirements
```
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y --no-install-recommends g++-multilib libssl-dev:i386 libcrypto++-dev:i386 zlib1g-dev:i386
sudo dpkg-reconfigure dash
```
This last command reconfigures Ubuntu/Debian to use bash as the non-interactive shell.  At the prompt, select No.

For older Ubuntu's you also need to install the python 2.7 package
```
sudo apt-get install python2.7
```

And then create some links for it in /usr/bin
```
sudo ln -sf /usr/bin/python2.7 /usr/bin/python
sudo ln -sf /usr/bin/python2.7 /usr/bin/python2
```

### Clone Repositories

For all upstream repositories, use the [thud] branch.

First the main Yocto project poky layer
```
~# git clone -b thud git://git.yoctoproject.org/poky.git poky
```
Then the dependency layers under that
```
~$ cd poky
~/poky$ git clone -b thud git://git.openembedded.org/meta-openembedded
~/poky$ git clone -b thud git://git.yoctoproject.org/meta-virtualization
~/poky$ git clone -b thud git://git.yoctoproject.org/meta-security
~/poky$ git clone -b thud git://git.yoctoproject.org/meta-raspberrypi
~/poky$ git clone -b pyro git@github.com:aaronovz1/meta-nodejs
~/poky$ git clone -b dev git@github.com:armpelionedge/meta-pelion-edge
```

### Credentials, Keys, and Certificates

#### Pelion Cloud credentials

Pelion Cloud development credentials are needed for Pelion Edge.  Provision your build with a Pelion Cloud developer certificate if you are building for [Pelion Cloud developer mode](https://cloud.mbed.com/docs/current/connecting/provisioning-development-devices.html).  Copy your mbed_cloud_dev_credentials.c file to `recipes-wigwag/mbed-edge-core/files/mbed_cloud_dev_credentials.c`.


#### Firmware Update Manifest Credentials

If you enabled support for Pelion firmware updates in mbed-edge-core, copy your manifest certificate to `recipes-wigwag/mbed-edge-core/files/update_default_resources.c`.

To generate update_default_resources.c, run [manifest-tool](https://github.com/ARMmbed/manifest-tool).  See the documentation on [getting the update resources](https://github.com/ARMmbed/mbed-edge/blob/master/README.md#getting-the-update-resources).

Note: To unlock the rich node features, such as gateway logs and gateway terminal in the Pelion web Portal, pass the command-line parameter `-V 42fa7b48-1a65-43aa-890f-8c704daade54` to the manifest-tool while generating `update_default_resources.c`.

### Initialize the build directory

Use Yocto's oe-init-build-env script to create the build directory layout and provide the meta-pelion-edge/conf example configuration scripts to initialize the build environment.

```
~/poky$ TEMPLATECONF=meta-pelion-edge/conf source oe-init-build-env
```

### WARNING: 
Do not include `meta-yocto-bsp` in your `bblayers.conf`. The Yocto BSP requirements for the Raspberry Pi are in `meta-raspberrypi`.

For example, if your directory structure does not look exactly like this, you will need to modify bblayers.conf
```
~/poky/
     meta-openembedded/
     meta-raspberrypi
     meta-pelion-edge/
     build/
        conf/
     ...
```

### Edit local.conf
Customize your local.conf to suit your build.

#### ROOT PASSWORD
There is only one login user by default, root.

The default password is set to 'redmbed' by these two lines in the local.conf file
```
INHERIT += "extrausers"
EXTRA_USERS_PARAMS = "usermod -P redmbed root; "
```
These two lines force a password change on first login
```
INHERIT += "chageusers"
CHAGE_USERS_PARAMS = "chage -d0 root; "
```
You can comment them out if you do not want that behavior.

If you want no password at all (development only hopefully), comment those four lines and uncomment this line
```
EXTRA_IMAGE_FEATURES = "debug-tweaks"

#INHERIT += "extrausers"
#EXTRA_USERS_PARAMS = "usermod -P redmbed root; "

#INHERIT += "chageusers"
#CHAGE_USERS_PARAMS = "chage -d0 root; "
```
You can always add or change the password once logged in.

### Run the build
You need to `source` the Yocto environment into your shell before you can use `bitbake`. The `oe-init-build-env` will not overwrite your customized conf files.
```
~/poky$ source oe-init-build-env
```

###  Shell environment set up for builds. ### 

You can now run 'bitbake '

Common targets are:
    console-image

### Build
To build the console-image run the following command
```
~/poky/build$ bitbake console-image
```
You may occasionally run into build errors related to packages that either failed to download or sometimes out of order builds. The easy solution is to clean the failed package and rerun the build again.

For instance if the build for zip failed for some reason, I would run this
```
~/poky/build$ bitbake -c cleansstate zip
~/poky/build$ bitbake zip 
```
And then continue with the full build.
```
~/poky/build$ bitbake console-image
```
The cleansstate command (with two s’s) works for image recipes as well.

#### NOTE: trouble running bitbake

If you recieve an error running bitbake like:

```
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Summary: There was 1 ERROR message shown, returning a non-zero exit code.
```

You need to fix your ssh access to github.

This can usually be fixed by the following ssh command and then rerunning bitbake:

```
$ ssh -T git@github.com
```