You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 2 Next »
On this page, please note the following:
Since arm-trusted-firmware is the first software to run after RESET, a minimal set of peripherals need to be configured and used.
Some required configurations are as follows:
The source code for TrustedFirmware-A is stored on github.
Refer to the table in the wiki section of the repository to determine which branch you should use based on your SoC.
After you clone the repository and check out the correct branch, you may want to do is to create a new branch for your edits. This will make it easier to pull in future updates.
Example:
$ git clone https://github.com/renesas-rz/rzg_trusted-firmware-a $ cd rzg_trusted-firmware-a $ git checkout v2.7/rz $ git checkout -b my_board # This will make a new branch named 'my_board'
#define BOARD_JUDGE_AUTO
//#define BOARD_JUDGE_AUTO <<<<<<<<<< comment out this line like this #ifdef BOARD_JUDGE_AUTO static uint32_t _board_judge(void); static uint32_t boardcnf_get_brd_type(void) { return _board_judge(); } #else static uint32_t boardcnf_get_brd_type(void) { return 1; <<<<<<<<<< will select boardcnfs[1] every time } #endif
This is the DDR driver for the RZ/G2E, but you should not have to edit it.
Memory Size
The size of the DDR is set by setting defining RCAR_DRAM_DDR3L_MEMCONF at compile time.
#if RCAR_DRAM_DDR3L_MEMCONF == 0 mmio_write_32(DBSC_DBMEMCONF_0_0, 0x0f030a02); /* 1GB */ /* (rows=15, banks=8, cols=10, Data Bus=32-bit) */ #else mmio_write_32(DBSC_DBMEMCONF_0_0, 0x10030a02); /* 2GB(default) */ /* (rows=16, banks=8, cols=10, Data Bus=32-bit) */ #endif
Chip Count
The number of the DDR memories connected on the board is set by setting defining RCAR_DRAM_DDR3L_MEMDUAL at compile time.
Example Settings
Memory | Settings |
---|---|
4pcs x 8bit 2GB | RCAR_DRAM_DDR3L_MEMCONF=1 RCAR_DRAM_DDR3L_MEMDUAL=1 |
2pcs x 16bit 2GB | RCAR_DRAM_DDR3L_MEMCONF=1 RCAR_DRAM_DDR3L_MEMDUAL=0 |
2pcs x 16bit 1GB | RCAR_DRAM_DDR3L_MEMCONF=0 RCAR_DRAM_DDR3L_MEMDUAL=0 |
Setting in Yocto
You can force your settings in Yocto by modifying file:
meta-renesas/meta-rzg2h/recipes-bsp/trusted-firmware-a/trusted-firmware-a.bbappend
And edit the line: ATFW_OPT_r8a774c0 = " "
For example:
ATFW_OPT_r8a774c0 = "LSI=G2E RCAR_SA0_SIZE=0 RCAR_DRAM_DDR3L_MEMCONF=1 RCAR_DRAM_DDR3L_MEMDUAL=1 SPD="none"".
⚠ Caution: The default BSP configuration assumes you have at least 512MB of DDR on your board. If you have less than that, you will need to adjust your Memory Map for all your software components. See RZ-G/RZ-G2_BSP_MemoryMap .
The DDR configuration files (param_mc.c and param_swizzle.c) to be used with ATF are the same as Flash Writer.
First of all create a new folder for your custom board in the platform folder:
mkdir -p plat/renesas/rz/board/custom
Copy one of the existing .mk files as template:
cp plat/renesas/rz/board/smarc_2/rz_board.mk plat/renesas/rz/board/custom/rz_board.mk
Edit the content of this newly created file:
# # SPDX-License-Identifier: BSD-3-Clause # DDR_SOURCES += plat/renesas/rz/soc/${PLAT}/drivers/ddr/param_mc.c \ plat/renesas/rz/common/drivers/ddr/param_swizzle.c DDR_PLL4 := 1600 $(eval $(call add_define,DDR_PLL4))
Note that DDR_PLL4 define have to match the DDR type (e.g. 1600 for DDR4 and 1333 for DDR3L).
Copy param_mc.c and param_swizzle.c in the folders pointed by the .mk just edited.
ifndef SPI_FLASH #SPI_FLASH = MT25QU512ABB ### <<< I commented out this line SPI_FLASH = S25L256XYZ ### <<< I added this new line endif
As mentioned in the previous paragraph, the SPI_MULTI_DQ_WIDES_1_1_1 is normally always supported. In some cases the Quad SPI flash device comes into a small package (e.g. 8-WSON). In this low pin count package SIO2 and SIO3 are multiplexed with other signals, WP# and RESET# respectively, and this is the factory default. In order to use Quad commands, the non-volatile QE bit in the Status Register need to be set. Being non-volatile this setting has to be done once and it will be kept until changed back to zero. As of today ATF code does not do that, so it has to be modified to do it or the QE bit has to be set by other means.
static const struct { uint32_t reg; uint32_t msk; uint32_t val; } sys_acctl[] = { /* Master Access Control Register */ {SYS_MSTACCCTL0, 0x00BB00BBU, 0x00AAAA88U}, {SYS_MSTACCCTL1, 0xBBBBBBBBU, 0xAAAAAAAAU}, {SYS_MSTACCCTL2, 0x00BBBBBBU, 0x00AAAAAAU}, {SYS_MSTACCCTL3, 0x00BBBBBBU, 0x00AAAAAAU}, {SYS_MSTACCCTL4, 0x0B0B00BBU, 0x0A0A00AAU}, {SYS_MSTACCCTL5, 0x00000000U, 0x00000000U}, /* Slave Access Control Register */ {SYS_SLVACCCTL0, 0x0000000FU, 0x00000008U}, {SYS_SLVACCCTL1, 0x3FFF3CFFU, 0x0800C0AAU}, {SYS_SLVACCCTL2, 0x00FFCFFFU, 0x00000002U}, {SYS_SLVACCCTL3, 0x3FFF3FFFU, 0x00000000U}, {SYS_SLVACCCTL4, 0xFFFF0FFFU, 0x00000000U}, {SYS_SLVACCCTL5, 0x00000033U, 0x00000000U}, {SYS_SLVACCCTL6, 0x0000000FU, 0x00000000U}, {SYS_SLVACCCTL7, 0x0000000CU, 0x00000008U}, {SYS_SLVACCCTL8, 0x0000000FU, 0x00000000U}, {SYS_SLVACCCTL9, 0x00000000U, 0x00000000U}, {SYS_SLVACCCTL10, 0x00000003U, 0x00000000U}, {SYS_SLVACCCTL11, 0x00000000U, 0x00000000U}, {SYS_SLVACCCTL12, 0x00000003U, 0x00000000U}, {SYS_SLVACCCTL13, 0x00000003U, 0x00000000U}, {SYS_SLVACCCTL14, 0x00000003U, 0x00000000U}, {SYS_SLVACCCTL15, 0x00000000U, 0x00000000U}, };
Boot from eMMC:
Boot from SPI Flash vs eMMC Flash:
Build Commands: ATF (release) can be built by giving the following command:
make -j$(nproc) PLAT=g2l BOARD=custom all
ATF (debug) instead:
make -j$(nproc) PLAT=g2l BOARD=custom DEBUG=1 all
Binaries (bl2.bin and bl31.bin) are located in the build/g2l/release|debug folder.
We have to combine bl2.bin with boot parameters, we can use this simple bash script to do that:
#!/bin/bash echo -e "\n[Creating bootparams.bin]" SIZE=$(stat -L --printf="%s" bl2.bin) SIZE_ALIGNED=$(expr $SIZE + 3) SIZE_ALIGNED2=$((SIZE_ALIGNED & 0xFFFFFFFC)) SIZE_HEX=$(printf '%08x\n' $SIZE_ALIGNED2) echo " bl2.bin size=$SIZE, Aligned size=$SIZE_ALIGNED2 (0x${SIZE_HEX})" STRING=$(echo \\x${SIZE_HEX:6:2}\\x${SIZE_HEX:4:2}\\x${SIZE_HEX:2:2}\\x${SIZE_HEX:0:2}) printf "$STRING" > bootparams.bin for i in `seq 1 506`e ; do printf '\xff' >> bootparams.bin ; done printf '\x55\xaa' >> bootparams.bin # Combine bootparams.bin and bl2.bin into single binary # Only if a new version of bl2.bin is created if [ "bl2.bin" -nt "bl2_bp.bin" ] || [p! -e "bl2_bp.bin" ] ; then echo -e "\n[Adding bootparams.bin to bl2.bin]" cat bootparams.bin bl2.bin > bl2_bp.bin fi
Make the fip creation tool:
cd tools/fiptool make -j$(nproc) plat=g2l
Now we can create the fip file by combining the bl31.bin and u-boot.bin (refer to this section and copy the .bin in the ATF root folder):
cd ../.. tools/fiptool/fiptool create --align 16 --soc-fw build/g2l/release|debug/bl31.bin --nt-fw u-boot.bin fip.bin
bl2_bp.bin and fip.bin are the files that have to be programmed using Flash Writer. Actually .srec may be more handy, they can be converted by using the following commands:
${CROSS_COMPILE}objcopy -I binary -O srec --adjust-vma=0x00011E00 --srec-forceS3 bl2_bp.bin bl2_bp.srec ${CROSS_COMPILE}objcopy -I binary -O srec --adjust-vma=0x00000000 --srec-forceS3 fip.bin fip.srec
ATF BL2 is what you more often might need to debug, since this is the part that includes most of the system specific options. Obviously it is possible to use the various log options (INFO, NOTICE, DEBUG, etc), however especially during the first stages or if something is difficult to catch, it might be just more convenient to use a JTAG debugger and OpenOCD. In this way you do not need to reflash the bootloaders every time since the new image is just loaded in the internal RAM directly. You can refer to this section, that shows how to setup the OpenOCD Eclipse plugin to debug BL2.