RZ/G u-boot Information


Starting Watchdog Timer

Preparation:
Remember to (" setenv wdt_timeout <seconds> ") before testing if you want board to reboot sooner. Otherwise, it will reboot after 1min due to the setting in the Device Tree.

Testing Phase:
Case 1: (which user replaces the wrong kernel Image or wrong dtb) In this case, we are going to use 1 random kernel Image, and 1 device tree ( .dtb ) for our board. For example: R-car M3 kernel Image + r8a774e1-hihope-rzg2h-ex.dtb.

Expected result: Board will stop at (" Starting kernel ..... ") due to the wrong kernel Image file. Board will reboot after the specified time which is set by user.

Case 2: (when loading a driver, kernel panic occurs because of loading driver fail and board stops booting) In this case, we will add a panic() function into one function of a driver such as probe() to create kernel panic, but make sure that you have included kernel.h to use this function.

For example: In the GPIO driver

#include <linux/kernel.h> 
static int gpio_rcar_probe(struct platform_device *pdev) 
{ 
    struct gpio_rcar_priv *p; 
    struct resource *io, *irq; 
    struct gpio_chip *gpio_chip; 
    ....... 
    panic("GPIO driver, Kernel panic\n"); 
    ....... 
}

Expected result: When loading GPIO driver, kernel panic occurs and board stops booting. Board will reboot after the specified time which is set by user.

Debugging U-boot in RAM for RZ/G2

In most of the cases, users modify the U-boot source code, compile the code, update the eMMC/QSPI flash, reboot the board, and then they can test or verify their modifications. It is OK but low efficiency.

There is a switch in U-boot defconfig, which is used to control the activation of PIC(position independent code). If it is enabled, the U-boot code can be executed from other RAM address instead of the linked address(0x50000000 for RZ/G2L). The PIC code will relocate the whole U-boot to the linking address and then execute as usual. That means when you are in U-boot command line(old U-boot), you can download(by NFS/TFTP/Serial/SD) the new U-boot binary to the available DDR address and then jump to it(using "go new-uboot-addr" command). Then you will enter new U-boot command line. You can always download and jump to U-boot until you think the new U-boot version has no bug. At last, you can burn the latest version to eMMC/QSPI flash.

Please note that the the U-boot binary for debugging must be raw binary format(without any header information). Usually, it is the file "u-boot.bin" in the output directory.


For RZ/G2L, you should add a configuration to the configs/smarc-rzg2l_defconfig:

CONFIG_POSITION_INDEPENDENT=y


Example:

1) tftp 0x48000000 u-boot.bin

2) dcache flush

3) go 0x48000000

Updating U-boot on Your Board

Enabling QSPI FLASH support for RZ/G2M-N-H

The QSPI flash support is enabled by default for the RZ/G2E board (EK874), instead it is not enabled for the Hihope boards. In the procedure below RZ/G2M is used as an example, but it applies to RZ/G2N and RZ/G2H as well.

1) Build U-boot as per Chris' script instructions

2) Once built with default configuration, open another terminal and change dir to ./out_hihope-rzg2m. This is necessary because to build U-boot you probably had to source the environment variable script of the SDK, that prevents you from running the following command (old toolchain):

make menuconfig 

3) Enable the following configurations (search by typing /):

SPI_FLASH 
SPI_FLASH_BAR 
SPI_FLASH_USE_4K_SECTORS 
SPI 
DM_SPI 
SPI_FLASH_WINBOND
RENESAS_RPC_SPI
CMD_SF 
CMD_SPI 
DM_SPI_FLASH 

4) Modify the device tree:

gedit ./arch/arm/dts/r8a774a1-hihope-rzg2m.dts 

and add the following lines:

    aliases { 
        spi0 = &rpc; 
    }; 

This one above should go just after the board model.

&rpc { 
   num-cs = <1>; 
   status = "okay"; 
   spi-max-frequency = <40000000>; 
   #address-cells = <1>; 
   #size-cells = <0>; 
 
   flash0: spi-flash@0 { 
       #address-cells = <1>; 
       #size-cells = <1>; 
       compatible = "spi-flash", "jedec,spi-nor"; 
       spi-max-frequency = <40000000>; 
       spi-tx-bus-width = <1>; 
       spi-rx-bus-width = <1>; 
       reg = <0>; 
       status = "okay"; 
   }; 
}; 

5) Rebuild using the first terminal you used to build the first time.

The u-boot.bin file can be now programmed using another Chris' script, just make sure it gets copied in the directory where the script searches for it. Once programmed, you can test it by stopping the normal kernel boot:

U-Boot 2018.09-g03c7e33415-dirty (Oct 07 2020 - 15:55:06 +0200) 
  
CPU: Renesas Electronics R8A774A1 rev 1.3 
Model: Hoperun Technology HiHope RZ/G2M platform (hihope-rzg2m) 
DRAM:  3.9 GiB 
Bank #0: 0x048000000 - 0x0bfffffff, 1.9 GiB 
Bank #1: 0x600000000 - 0x67fffffff, 2 GiB 
  
Watchdog: Not found by seq! 
WDT:   watchdog@e6020000 
Watchdog: Started! 
MMC:   sd@ee100000: 0, sd@ee160000: 1 
Loading Environment from MMC... OK 
In:    serial@e6e88000 
Out:   serial@e6e88000 
Err:   serial@e6e88000 
Net: 
Error: ethernet@e6800000 address not set. 
eth-1: ethernet@e6800000 
Hit any key to stop autoboot:  0 
=> sf probe 
SF: Detected w25m512jw with page size 256 Bytes, erase size 4 KiB, total 32 MiB 
=>

GPIO Control in u-boot

Here is an example of how to control a GPIO in u-boot.
For example, in the RZ/G2H HiHope board, the MD1 pin is also a GPIO 0-2 and is connected to a switch.
When the switch is OFF, it means the pin is pulled high and I get:

=> gpio status -a gpio@e60500002
Bank gpio@e6050000:
gpio@e60500002: input: 1 [ ]


When the switch is ON, it means the pins is grounded and I get:

=> gpio status -a gpio@e60500002
Bank gpio@e6050000:
gpio@e60500002: input: 0 [ ]

The GPIO registers for bank 6 starts at address 0xE605_5400.



That would mean you would use bank "gpio@e6055400" in u-boot.
For example, to read bank 6 pin 12 specifically would be :
=> gpio status -a gpio@e605540012

First you might need to make it a gpio input.
=> gpio input gpio@e605540012
gpio: pin gpio@e605540012 (gpio 132) value is 1 

RZ/G2L-LC-UL, RZ/V2L

In these devices the gpio banks are named differently:

=> gpio status -a
Bank gpio-00:
gpio-000: unused: 0 [ ]
gpio-001: unused: 0 [ ]
Bank gpio-01:
gpio-010: unused: 0 [ ]
gpio-011: output: 1 [ ]
Bank gpio-02:
gpio-020: unused: 0 [ ]
gpio-021: unused: 0 [ ]

[...]

Bank gpio-47:
gpio-470: unused: 0 [ ]
gpio-471: unused: 0 [ ]
gpio-472: unused: 0 [ ]
gpio-473: unused: 0 [ ]
Bank gpio-48:
gpio-480: unused: 0 [ ]
gpio-481: unused: 0 [ ]
gpio-482: unused: 0 [ ]
gpio-483: unused: 0 [ ]
gpio-484: unused: 0 [ ]

These names directly correspond to the nomenclature specified in the User's Manual, e.g.:

gpio-020 = P2_0, gpio-472 = P47_2 and so on.

Therefore, for example to set P41_0 as an output and to set it to zero:

=> gpio clear gpio-410
gpio: pin gpio-410 (gpio 91) value is 0

Use SPI Flash for Env Variables

  • By default, the RZ BSP uses eMMC Flash to store u-boot environment variables. However, you can choose to use SPI Flash to store environment variables.
  • SPI Flash support was not available in early BSP releases, so make sure you are using the latest release.

Method 1: Use menuconifg

  • Use menuconfig and make the changes in the "Environment" section.

Disable (uncheck) eMMC

Enviroment --> [ ] Environment in an MMC device

Enable (check) SPI Flash settings

Environment --> [*] Environment is in SPI flash
Environment --> (0xF0000) Environment offset
Environment --> (0x10000) Environment Size
Environment --> (0x10000) Environment Sector-Size
  • If use the build scripts, you can do:
$ ./build.sh u menuconfig
$ ./build.sh u

Method 2: Edit defconfig file

  • You can manually edit the config file (For example: configs/smarc-rzg2l_defconfig) and make the change below.
diff --git a/configs/smarc-rzg2l_defconfig b/configs/smarc-rzg2l_defconfig
index be27446fab..b24c705b09 100644
--- a/configs/smarc-rzg2l_defconfig
+++ b/configs/smarc-rzg2l_defconfig
@ -71,10 +71,11 @ CONFIG_USB_EHCI_GENERIC=y
CONFIG_USB_STORAGE=y
CONFIG_OF_LIBFDT_OVERLAY=y
CONFIG_SMBIOS_MANUFACTURER=""
-CONFIG_ENV_IS_IN_MMC=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y

+CONFIG_ENV_SIZE=0x10000
+CONFIG_ENV_OFFSET=0xF0000
+CONFIG_ENV_SECT_SIZE=0x10000
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-CONFIG_SYS_MMC_ENV_DEV=0
-CONFIG_SYS_MMC_ENV_PART=2
CONFIG_SYS_I2C_RZG2L_RIIC=y
CONFIG_SPI_FLASH=y
CONFIG_SPI_FLASH_BAR=y
  • Then, you have to do a full rebuilt. For example, if you are using the build scripts, you can do
$ ./build.sh u smarc-rzg2l_defconfig
$ ./build.sh u


How to select active Ethernet port

u-boot only supports using 1 Ethernet port at a time.

If you want to use eth1 when both eth0 & eth1 are enabled in Device Tree of u-boot, you should use the env "ethact" to select which ethernet port is the active port. By default, "ethact" is "ethernet@11c20000" (that is eth0 on RZ/G2L). Also the eth1 mac address(eth1addr) must be set.
Switch to eth1:

=> setenv ethact ethernet@11c30000
=> setenv eth1addr 00:12:23:32:A0:C0






  • No labels