RZ/G u-boot Information

From Renesas.info
Revision as of 13:45, 26 August 2022 by MicBis (talk | contribs) (→‎GPIO Control in u-boot: RZ/G2L example)

RZ-G


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.

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.

rzg2 gpio register.png



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