Initial check-in
[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 Flash Firmware
46
47 1. Connect reference hardware board to the development PC by using USB serial
48    cable.  
49 2. Open a serial console (like Teraterm in Windows, or gtkterm in Ubuntu that
50    can easily send files) with a baudrate of 115200n8.
51 3. Set bit2 of SW2221 (on the top of SoC board) to "off"which turns SW2221 to be
52         off,off,off,off.
53 4. Power on the reference board, you will find fillowing message outputed on the
54    serial console:
55
56 ```
57         SCIF Download mode (w/o verification)
58         (C) Renesas Electronics Corp.
59
60         -- Load Program to SystemRAM ---------------
61         please send !
62         
63 ```
64 5. Use console application menu to send the flash writer binary provided:
65
66 ```
67         AArch64_Flash_writer_SCIF_DUMMY_CERT_E6300400_salvator-x.mot
68 ```
69 6. After file is transferred correctly, following message will be outputed:
70
71 ```
72         Flash writer for R-Car H3/M3/M3N Series V1.11 Feb.12,2020
73         >
74 ```
75 7. Set reference board to boot from eMMC.
76
77     \> **EM_SECSD**  
78     Please Input EXT_CSD Index(H'00 - H'1FF) :**b1**  
79     EXT_CSD[B1] = 0x00  
80     Please Input Value(H'00 - H'FF) :**a**  
81     EXT_CSD[B1] = 0x0A  
82
83     \> **EM_SECSD**  
84     Please Input EXT_CSD Index(H'00 - H'1FF) :**b3**  
85     EXT_CSD[B3] = 0x00  
86     Please Input Value(H'00 - H'FF) :**8**  
87     EXT_CSD[B3] = 0x08  
88
89     \>**EM_DCSD**  
90     [CSD Field Data]  
91     [127:126]  CSD_STRUCTURE       0x03  
92     [125:122]  SPEC_VERS           0x04  
93     [119:112]  TAAC                0x27  
94     [111:104]  NSAC                0x01  
95     [103: 96]  TRAN_SPEED          0x32  
96     [ 95: 84]  CCC                 0x00F5  
97     [ 83: 80]  READ_BL_LEN         0x09  
98     [ 79: 79]  READ_BL_PARTIAL     0x00  
99     [ 78: 78]  WRITE_BLK_MISALIGN  0x00  
100     [ 77: 77]  READ_BLK_MISALIGN   0x00  
101     [ 76: 76]  DSR_IMP             0x00  
102     [ 73: 62]  C_SIZE              0x0FFF  
103     [ 61: 59]  VDD_R_CURR_MIN      0x06  
104     [ 58: 56]  VDD_R_CURR_MAX      0x06  
105     [ 55: 53]  VDD_W_CURR_MIN      0x06  
106     [ 52: 50]  VDD_W_CURR_MAX      0x06  
107     [ 49: 47]  C_SIZE_MULT         0x07  
108     [ 46: 42]  ERASE_GRP_SIZE      0x1F  
109     [ 41: 37]  ERASE_GRP_MULT      0x1F  
110     [ 36: 32]  WP_GRP_SIZE         0x0F  
111     [ 31: 31]  WP_GRP_ENABLE       0x01  
112     [ 30: 29]  DEFAULT_ECC         0x00  
113     [ 28: 26]  R2W_FACTOR          0x03  
114     [ 25: 22]  WRITE_BL_LEN        0x09  
115     [ 21: 21]  WRITE_BL_PARTIAL    0x00  
116     [ 16: 16]  CONTENT_PROT_APP    0x00  
117     [ 15: 15]  FILE_FORMAT_GRP     0x00  
118     [ 14: 14]  COPY                0x01  
119     [ 13: 13]  PERM_WRITE_PROTECT  0x00  
120     [ 12: 12]  TMP_WRITE_PROTECT   0x00  
121     [ 11: 10]  FILE_FORMAT         0x00  
122     [  9:  8]  ECC                 0x00  
123     [  7:  1]  CRC                 0x00  
124
125
126 8. Flash firmware  
127   The firmware are supposed to be stored on eMMC as following:
128
129   Name                                  | Load address          | eMMC partition        | Flash address         | Description
130   --------------------------------------|-----------------------|-----------------------|-----------------------|-----------------------------
131   bootparam_sa0-4x2g.srec               | H'E6320000            | 1                     | H'000000              | Boot parameter
132   bl2-salvator-x-4x2g.srec              | H'E6304000            | 1                     | H'00001E              | bl2 loader
133   cert_header_sa6-4x2g.srec             | H'E6320000            | 1                     | H'000180              | Certification
134   bl31-salvator-x-4x2g.srec             | H'44000000            | 1                     | H'000200              | bl3 loader
135   tee-salvator-x.srec                   | H'44100000            | 1                     | H'001000              | OP-Tee
136   u-boot-elf-salvator-xs-4x2g.srec      | H'50000000            | 2                     | H'000000              | U-boot
137
138   You can find these firmwares in the AGL build directory $AGL_TOP/build/tmp/deploy/images/salvator-x
139   and you can flash them by using **EM_W** command as following:  
140
141   \> **EM_W**  
142   \---------------------------------------------------------  
143   Please select,eMMC Partition Area.  
144    0:User Partition Area   : 62496768 KBytes  
145     eMMC Sector Cnt : H'0 - H'07733FFF  
146    1:Boot Partition 1      : 32640 KBytes  
147     eMMC Sector Cnt : H'0 - H'0000FEFF  
148    2:Boot Partition 2      : 32640 KBytes  
149     eMMC Sector Cnt : H'0 - H'0000FEFF  
150   \---------------------------------------------------------  
151   Select area(0-2)> **\<Enter the eMMC partition number above, Ex.'1' \>**   
152   -- Boot Partition X Program -----------------------------  
153   Please Input Start Address in sector : **\<Enter the Flash address above, Ex.'1e'\>**  
154   Please Input Program Start Address : **\<Enter the Load address above, Ex. 'e6304000'\>**  
155   Work RAM(H'50000000-H'50FFFFFF) Clear....  
156   please send ! ('.' & CR stop load)  
157   **\<Send the fimware file above by using console appliction, Ex. send 'bl2-salvator-x-4x2g.srec'\>**
158
159 9. Power off the board.
160 10. Reset bit2 of SW2221 (on the top of SoC board) to "on", which turns SW2221 to be  
161         off,on,off,off