rewrote quickstart, build-process
[AGL/documentation.git] / docs / 0_Getting_Started / 2_Building_AGL_Image / 5_2_Raspberry_Pi_4.md
1 ---
2 title: Building for Raspberry Pi 4
3 ---
4
5 The
6 [Raspberry Pi](https://www.raspberrypi.org/help/what-%20is-a-raspberry-pi/) is a small computer that is ideal for learning computing and computer languages.
7 The AGL Project supports building images for the
8 [Raspberry Pi 4](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/) board.
9 These board comes in a variety of models.
10 See the
11 [Raspberry Pi Product Page](https://www.raspberrypi.org/products/) for more information.
12
13 This section describes the steps you need to take to build the
14 AGL demo image for the Raspberry Pi 4 board.
15
16 ## 1. Making Sure Your Build Environment is Correct
17
18 The
19 "[Initializing Your Build Environment](./3_Initializing_Your_Build_Environment.md)"
20 section presented generic information for setting up your build environment
21 using the `aglsetup.sh` script.
22 If you are building the AGL demo image for a Raspberry Pi 4 board, you need to specify some
23 specific options when you run the script :
24
25 **Qt based IVI demo :**
26
27   ```sh
28   $ source meta-agl/scripts/aglsetup.sh -f -m raspberrypi4 -b raspberrypi4 agl-demo agl-devel
29   $ echo '# reuse download directories' >> $AGL_TOP/site.conf
30   $ echo 'DL_DIR = "$HOME/downloads/"' >> $AGL_TOP/site.conf
31   $ echo 'SSTATE_DIR = "$AGL_TOP/sstate-cache/"' >> $AGL_TOP/site.conf
32   $ ln -sf $AGL_TOP/site.conf conf/
33   ```
34
35 **HTML5 based IVI demo :**
36
37   ```sh
38   $ source meta-agl/scripts/aglsetup.sh -f -m raspberrypi4 -b raspberrypi4 agl-demo agl-devel agl-profile-graphical-html5
39   $ echo '# reuse download directories' >> $AGL_TOP/site.conf
40   $ echo 'DL_DIR = "$HOME/downloads/"' >> $AGL_TOP/site.conf
41   $ echo 'SSTATE_DIR = "$AGL_TOP/sstate-cache/"' >> $AGL_TOP/site.conf
42   $ ln -sf $AGL_TOP/site.conf conf/
43   ```
44
45 In each case, the "-m" option specifies the machine and the list of AGL features used with script are appropriate for development of
46 the AGL demo image suited for Raspberry Pi 4.
47
48 ## 2. Configuring the Build to Include Packages Under a Commercial License
49
50 Before launching the build, it is good to be sure your build
51 configuration is set up correctly (`/build/conf/local.conf` file).
52 The "[Customizing Your Build](./4_Customizing_Your_Build.md)"
53 section highlights some common configurations that are useful when
54 building any AGL image.
55
56 For the Raspberry Pi platforms, you need to take an additional
57 configuration step if you want to include any packages under a
58 commercial license.
59
60 For example, suppose you want to include an implementation of the
61 [OpenMAX](https://www.khronos.org/openmax/) Intagration Library
62 (`libomxil`) under a commercial license as part of your AGL image.
63 If so, you must include the following two lines in your
64 `/build/conf/local.conf` file:
65
66 ```sh
67 # For libomxil
68 LICENSE_FLAGS_WHITELIST = "commercial"
69 IMAGE_INSTALL_append = "libomxil"
70 ```
71
72 ## 3. Using BitBake
73
74 This section shows the `bitbake` command used to build the AGL image.
75
76 Start the build using the `bitbake` command.
77
78 **NOTE:** An initial build can take many hours depending on your
79 CPU and and Internet connection speeds.
80 The build also takes approximately 100G-bytes of free disk space.
81
82 **Qt Based IVI demo :**
83 The target is `agl-demo-platform`.
84
85 ```sh
86 $ time bitbake agl-demo-platform
87 ```
88
89 By default, the build process puts the resulting image in the Build Directory and further exporting that as `$IMAGE_NAME`.
90 Here is example for the Raspberry Pi 4 board for Qt Based demo:
91
92 ```sh
93 <build_dir>/tmp/deploy/images/raspberrypi4/agl-demo-platform-raspberrypi4.wic.xz
94
95 $ export IMAGE_NAME=agl-demo-platform-raspberrypi4.wic.xz
96 ```
97
98 **HTML5 Based IVI demo :**
99 The target is `agl-demo-platform-html5`.
100
101 ```sh
102 $ time bitbake agl-demo-platform-html5
103 ```
104
105 By default, the build process puts the resulting image in the Build Directory and further exporting that as `$IMAGE_NAME`.
106 Here is example for the Raspberry Pi 4 board for HTML5 Based demo:
107
108 ```sh
109 <build_dir>/tmp/deploy/images/raspberrypi4/agl-demo-platform-html5-raspberrypi4-64.wic.xz
110
111 $ export IMAGE_NAME=agl-demo-platform-html5-raspberrypi4-64.wic.xz
112 ```
113
114 ## 4. Deploying the AGL Demo Image
115
116 Deploying the AGL demo image consists of copying the image on a MicroSD card,
117 plugging the card into the Raspberry Pi board, and then booting the board.
118
119 Follow these steps to copy the image to a MicroSD card and boot
120 the image on the Raspberry Pi 4 board:
121
122   1. Plug your MicroSD card into your Build Host (i.e. the system that has your build output).
123
124   2. Extract the image into the SD card of Raspberry Pi 4 :
125
126     **NOTE:** For Raspberry Pi 4, the image is at `<build-dir>/tmp/deploy/images/raspberrypi4/${IMAGE_NAME}`.
127
128       Be sure you are root, provide the actual device name for *sdcard_device_name*, and the actual image name for *image_name*.
129
130       ```sh
131       $ lsblk
132       $ sudo umount <sdcard_device_name>
133       $ xzcat ${IMAGE_NAME} | sudo dd of=<sdcard_device_name> bs=4M
134       $ sync
135       ```
136
137     **IMPORTANT NOTE:** Before re-writing any device on your Build Host, you need to
138         be sure you are actually writing to the removable MicroSD card and not some other
139         device.
140         Each computer is different and removable devices can change from time to time.
141         Consequently, you should repeat the previous operation with the MicroSD card to
142         confirm the device name every time you write to the card.
143
144     To summarize this example so far, we have the following:
145         The first SATA drive is `/dev/sda` and `/dev/sdc` corresponds to the MicroSD card, and is also marked as a removable device.You can see this in the output of the `lsblk` command where "1" appears in the "RM" column for that device.
146
147   3. SSH into Raspberry Pi :
148     - Connect Raspberry Pi to network : `Homescreen > Settings`, IP address mentioned here.
149     - SSH :
150
151       ```sh
152       $ ssh root@<Raspberry-Pi-ip-address>
153       ```
154
155   4. Serial Debugging :
156
157     When things go wrong, you can take steps to debug your Raspberry Pi.
158     For debugging, you need a 3.3 Volt USB Serial cable to fascilitate
159     communication between your Raspberry Pi board and your build host.
160
161     You can reference the following diagram for information on the following steps:
162
163     ![](images/RaspberryPi2-ModelB-debug-serial-cable.png)
164
165     1. Connect the TTL cable to the Universal Asynchronous Receiver-Transmitter
166       (UART) connection on your Raspberry Pi board.
167       Do not connect the USB side of the cable to your build host at this time.
168
169           **CAUTION:** No warranty is provided using the following procedure.
170           Pay particular attention to the collors of your cable as they could
171           vary depending on the vendor.
172
173     2. Connect the cable's BLUE wire to pin 6 (i.e. Ground) of the UART.
174
175     3. Connect the able's GREEN RX line to pin 8 (i.e. the TXD line) of
176       the UART.
177
178     4. Connect the cable's RED TX line to pin 10 (i.e. the RXD line) of
179       the UART.
180
181     5. Plug the USB connector of the cable into your build host's USB port.
182
183     6. Use your favorite tool for serial communication between your build host
184       and your Raspberry Pi.
185       For example, if your build host is a native Linux machine (e.g. Ubuntu)
186       you could use `screen` as follows from a terminal on the build host:
187
188       ```sh
189       $ sudo screen /dev/ttyUSB0 115200
190       ```
191
192 5. SOTA
193
194     Follow the step below to build AGL for Raspberry Pi with enabled software over
195     the air (SOTA) updates:
196
197     1. Include **agl-sota** feature.
198
199     2. In **bblayers.conf** replace meta-updater-qemux86-64 with
200     **meta-updater-raspberrypi**.
201
202     3. In **local.conf** set `SOTA_PACKED_CREDENTIALS` and `OSTREE_BRANCHNAME`.
203
204     More details are available [here](https://docs.ota.here.com/getstarted/dev/raspberry-pi.html).