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