Add Yocto Project scarthgap release compatibility
[AGL/meta-agl-refhw.git] / meta-agl-refhw-gen3 / docs / ReferenceHW_Rcar_gen3.md
1 # Reference Hardware Board
2
3 - [About](#about)
4 - [Difference to Salvator-XS When Flashing Firmware](#difference-to-salvator-xs-when-flashing-firmware)
5 - [How to Build the Flash Writer](#how-to-build-the-flash-writer)
6 - [How to Flash Firmware](#how-to-flash-firmware)
7 - [How to Build the Firmware](#how-to-build-the-firmware)
8
9
10 ## About
11 The AGL Reference hardware board with R-Car H3 SoC is made by Panasonic for the
12 AGL community.
13
14 ## Difference to Salvator-XS When Flashing Firmware
15
16 The HyperFlash/QSPI flash switch function is not implemented on the reference
17 hardware board at present, HyperFlash and QSPI flash are not used.  Firmware
18 (arm-trusted-firmware, U-Boot...) is stored in eMMC and updated by using serial
19 download.
20
21 ## How to build the Flash Writer
22
23 1. Get the prebuilt cross compiler:
24     ```
25     $ cd ~/
26     $ wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-elf/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-elf.tar.xz
27     $ tar xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-elf.tar.xz
28     ```
29 2. Prepare the source code:
30     ```
31     $ cd ~/
32     $ git clone https://github.com/renesas-rcar/flash_writer.git
33     $ cd flash_writer
34     $ git checkout rcar_gen3
35     ```
36 3. Build the Flash Writer
37     ```
38     $ make AArch=64 clean
39     $ CROSS_COMPILE=~/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-elf/bin/aarch64-elf- make AArch=64
40     ```
41     The output image is at:
42     ```
43     ./AArch64_output/AArch64_Flash_writer_SCIF_DUMMY_CERT_E6300400_salvator-x.mot
44     ```
45
46
47 ## How to Flash Firmware
48
49 1. Connect reference hardware board to the development PC by using USB serial cable.
50
51 2. Open a serial console (like Teraterm in Windows, or gtkterm in Ubuntu that
52    can easily send files) with a baudrate of 115200n8.
53
54 4. Set bit2 of SW2221 (on the top of SoC board) to "off"which turns SW2221 to be
55         off,off,off,off.
56
57 5. Power on the reference board, you will find following message on the serial
58    console:
59     ```
60     SCIF Download mode (w/o verification)
61     (C) Renesas Electronics Corp.
62
63     -- Load Program to SystemRAM ---------------
64     please send !
65     ```
66
67 6. Use console application menu to send the flash writer binary:
68     ```
69     AArch64_Flash_writer_SCIF_DUMMY_CERT_E6300400_salvator-x.mot
70     ```
71
72 7. After the writer is transferred correctly, the following message will be displayed:
73     ```
74     Flash writer for R-Car H3/M3/M3N Series V1.11 Feb.12,2020
75     >
76     ```
77 8. Set reference board to boot from eMMC:
78
79     \> **EM_SECSD**  
80     Please Input EXT_CSD Index(H'00 - H'1FF) :**b1**  
81     EXT_CSD[B1] = 0x00  
82     Please Input Value(H'00 - H'FF) :**a**  
83     EXT_CSD[B1] = 0x0A  
84
85     \> **EM_SECSD**  
86     Please Input EXT_CSD Index(H'00 - H'1FF) :**b3**  
87     EXT_CSD[B3] = 0x00  
88     Please Input Value(H'00 - H'FF) :**8**  
89     EXT_CSD[B3] = 0x08  
90
91     \>**EM_DCSD**  
92     [CSD Field Data]  
93     [127:126]  CSD_STRUCTURE       0x03  
94     [125:122]  SPEC_VERS           0x04  
95     [119:112]  TAAC                0x27  
96     [111:104]  NSAC                0x01  
97     [103: 96]  TRAN_SPEED          0x32  
98     [ 95: 84]  CCC                 0x00F5  
99     [ 83: 80]  READ_BL_LEN         0x09  
100     [ 79: 79]  READ_BL_PARTIAL     0x00  
101     [ 78: 78]  WRITE_BLK_MISALIGN  0x00  
102     [ 77: 77]  READ_BLK_MISALIGN   0x00  
103     [ 76: 76]  DSR_IMP             0x00  
104     [ 73: 62]  C_SIZE              0x0FFF  
105     [ 61: 59]  VDD_R_CURR_MIN      0x06  
106     [ 58: 56]  VDD_R_CURR_MAX      0x06  
107     [ 55: 53]  VDD_W_CURR_MIN      0x06  
108     [ 52: 50]  VDD_W_CURR_MAX      0x06  
109     [ 49: 47]  C_SIZE_MULT         0x07  
110     [ 46: 42]  ERASE_GRP_SIZE      0x1F  
111     [ 41: 37]  ERASE_GRP_MULT      0x1F  
112     [ 36: 32]  WP_GRP_SIZE         0x0F  
113     [ 31: 31]  WP_GRP_ENABLE       0x01  
114     [ 30: 29]  DEFAULT_ECC         0x00  
115     [ 28: 26]  R2W_FACTOR          0x03  
116     [ 25: 22]  WRITE_BL_LEN        0x09  
117     [ 21: 21]  WRITE_BL_PARTIAL    0x00  
118     [ 16: 16]  CONTENT_PROT_APP    0x00  
119     [ 15: 15]  FILE_FORMAT_GRP     0x00  
120     [ 14: 14]  COPY                0x01  
121     [ 13: 13]  PERM_WRITE_PROTECT  0x00  
122     [ 12: 12]  TMP_WRITE_PROTECT   0x00  
123     [ 11: 10]  FILE_FORMAT         0x00  
124     [  9:  8]  ECC                 0x00  
125     [  7:  1]  CRC                 0x00  
126
127 9. Flash the firmware.
128
129     If using an AGL build with the agl-refhw-h3 feature, you can find the firmware
130     files under the build directory in `tmp/deploy/images/h3ulcb`.
131
132     If you use the reference hardware numbered 100 or above,
133     please flash the firmware with the suffix "-4x2g-1rank".
134
135     The firmware should be stored on the eMMC as follows:
136
137     | Name                                | eMMC partition | Flash address | Load address | Description
138     |-------------------------------------|:--------------:|:-------------:|:------------:|------------------|
139     | bootparam_sa0-agl-refhw-4x2g.srec   | 1              | H'000000      | H'E6320000   | Boot parameter
140     | bl2-agl-refhw-4x2g.srec             | 1              | H'00001E      | H'E6304000   | bl2 loader
141     | cert_header_sa6-agl-refhw-4x2g.srec | 1              | H'000180      | H'E6320000   | Certification
142     | bl31-agl-refhw-4x2g.srec            | 1              | H'000200      | H'44000000   | bl3 loader
143     | tee-h3ulcb.srec                     | 1              | H'001000      | H'44100000   | OP-Tee
144     | u-boot-elf-agl-refhw.srec           | 2              | H'000000      | H'50000000   | U-boot
145
146     If the firmware has been built using a standalone build outside of AGL
147     (see [below](#standalone-build)), then the firmware files can be be found in
148     `tmp/deploy/images/agl-refhw-h3`, and should be stored on the eMMC as follows:
149
150     | Name                                | eMMC partition | Flash address | Load address | Description
151     |-------------------------------------|:--------------:|:-------------:|:------------:|------------------|
152     | bootparam_sa0-4x2g.srec             | 1              | H'000000      | H'E6320000   | Boot parameter
153     | bl2-agl-refhw-h3-4x2g.srec          | 1              | H'00001E      | H'E6304000   | bl2 loader
154     | cert_header_sa6-4x2g.srec           | 1              | H'000180      | H'E6320000   | Certification
155     | bl31-agl-refhw-h3-4x2g.srec         | 1              | H'000200      | H'44000000   | bl3 loader
156     | tee-agl-refhw-h3.srec               | 1              | H'001000      | H'44100000   | OP-Tee
157     | u-boot-elf-salvator-x.srec          | 2              | H'000000      | H'50000000   | U-boot
158
159     The firmware files can be flashed by using **EM_W** command for each of them:
160
161     \> **EM_W**  
162     \---------------------------------------------------------  
163     Please select,eMMC Partition Area.  
164      0:User Partition Area   : 62496768 KBytes  
165       eMMC Sector Cnt : H'0 - H'07733FFF  
166      1:Boot Partition 1      : 32640 KBytes  
167       eMMC Sector Cnt : H'0 - H'0000FEFF  
168      2:Boot Partition 2      : 32640 KBytes  
169       eMMC Sector Cnt : H'0 - H'0000FEFF  
170     \---------------------------------------------------------  
171     Select area(0-2)> **\<Enter the eMMC partition number above, Ex.'1' \>**   
172     -- Boot Partition X Program -----------------------------  
173     Please Input Start Address in sector : **\<Enter the Flash address above, Ex.'1e'\>**  
174     Please Input Program Start Address : **\<Enter the Load address above, Ex. 'e6304000'\>**  
175     Work RAM(H'50000000-H'50FFFFFF) Clear....  
176     please send ! ('.' & CR stop load)  
177     **\<Send the fimware file above by using console appliction, Ex. send 'bl2-agl-refhw-x-4x2g.srec'\>**
178
179 9. Power off the board.
180 10. Reset bit2 of SW2221 (on the top of SoC board) to "on", which turns SW2221 to be  
181     off,on,off,off.
182
183
184 ## How to build the Firmware
185
186 ### In AGL Build
187
188 1. Initialize build environment:
189     ```
190     source meta-agl/scripts/aglsetup.sh -m h3ulcb agl-refhw-h3
191     ```
192     or:
193     ```
194     source meta-agl/scripts/aglsetup.sh -m h3ulcb-nogfx agl-refhw-h3
195     ```
196 2. Build the firmware:
197     ```
198     bitbake arm-trusted-firmware optee-os u-boot
199     ```
200 3. Afterwards, the firmware files will be in the directory `tmp/deploy/images/agl-refhw-h3`.
201
202
203 ### Standalone Build
204
205 It is also possible to build the firmware outside of the AGL build by using this
206 BSP layer on top of the meta-rcar-gen3 layer in meta-renesas.
207
208 1. In a temporary working directory, clone poky the poky repository and check out the kirkstone branch:
209     ```
210     git clone git://git.yoctoproject.org/poky
211     cd poky
212     git checkout kirkstone
213     ..
214     ```
215 2.  Clone the Renesas BSP and it's dependent layers:
216     ```
217     git clone https://github.com/renesas-rcar/meta-renesas
218     cd meta-renesas
219     git checkout Renesas-Yocto-v5.5.0
220     cd ..
221     git clone git://git.openembedded.org/meta-openembedded
222     cd meta-openembedded
223     git checkout kirkstone
224     cd ..
225     ```
226 3. Clone the reference hardware BSP layer:
227     ```
228     git clone https://gerrit.automotivelinux.org/gerrit/AGL/meta-agl-refhw
229     ```
230 4. Create a build environment:
231     ```
232     . ./poky/oe-init-build-env build
233     ```
234 5. Add the layers to `conf/bblayers.conf`, the `BBLAYERS` variable definition should look like:
235     ```
236     BBLAYERS ?= " \
237         /home/user/workdir/poky/meta \
238         /home/user/workdir/poky/meta-poky \
239         /home/user/poky/meta-yocto-bsp \
240         /home/user/workdir/meta-openembedded/meta-oe \
241         /home/user/workdir/meta-openembedded/meta-python \
242         /home/user/workdir/meta-renesas/meta-rcar-gen3 \
243         /home/user/workdir/meta-agl-refhw/meta-agl-refhw-gen3 \
244     "
245     ```
246 6. Add the machine setting to `conf/local.conf`, for example:
247     ```
248     echo MACHINE=agl-refhw-h3 >> conf/local.conf
249     ```
250 7. Build the firmware:
251     ```
252     bitbake arm-trusted-firmware optee-os u-boot
253     ```
254 8. Afterwards, the firmware files will be in the directory `tmp/deploy/images/agl-refhw-h3`.