Ariaboard G2E OpenWRT guide
Here we will use a official AARCH64 openwrt image + custom kernel and uboot to create a fully working openwrt on G2E.
Compilation
Ubuntu 20.04 pre-install apts
apt install git build-essential flex bison
Fetch RZ/G2E Linux SDK
###git clone ### or wget ### cd rzg2-linux-sdk git submodule update --init
Build RZG2 Flash Burner
cd rzg2-flash-writer ./build-g2e-emmc.sh
Build ARM Trusted Firmware
cd arm-trusted-firmware ./build-ek874-emmc.sh
Build U-Boot
cd renesas-u-boot-cip ./build-g2e-emmc.sh
Installation Process
We need to follow these steps:
- Install kernel & rootfs to a SD CARD (on PC)
- connect UART console to Linux PC, set jumper to download mode, power on the dev board.
- use minicom (115,200bps send file [Flash Burner .mot] with ASCII mode)
- Use flash burner bootloader to eMMC (ARM Trusted Firmware and U-boot) see the table below.
- Power off and insert the SD CARD, and power on. booting from eMMC, interrupt the countdown prompt, boot kernel and rootfs from the SD CARD.
- Now copy kernel and rootfs from the SD CARD to eMMC.
- Reboot and DONE!
Boot Flash Burner from serial port
Set serial port of PC to 115200bps, 8N1. Set boot mode of board to download mode. Connect Debug port of board to the serial port of PC. Power on the board, then something like "please send !" will be printed on terminal.
Upload file rzg2-flash-writer/AArch64_output/AArch64_Flash_writer_SCIF_DUMMY_CERT_E6300400_ek874.mot with ASCII mode. After uploading, prompt ">" will appear in terminal.
Install ARM Trusted Firmware & U-Boot
Filename | Program Top Address | eMMC Save Partition | eMMC Save Sectors | Description |
---|---|---|---|---|
arm-trusted-firmware/deploy/bootparam_sa0.srec | E6320000 | boot partition1 | 000000 | Loader(Boot parameter) |
arm-trusted-firmware/deploy/bl2.srec | E6304000 | boot partition1 | 00001E | Loader |
arm-trusted-firmware/deploy/cert_header_sa6.srec | E6320000 | boot partition1 | 000180 | Loader(Certification) |
arm-trusted-firmware/deploy/bl31.srec | 44000000 | boot partition1 | 000200 | ARM Trusted Firmware |
renesas-u-boot-cip/deploy/u-boot-elf.srec | 50000000 | boot partition2 | 000000 | U-boot |
Use EM_W command to write S-record file into eMMC. e.g:
>EM_W EM_W Start -------------- --------------------------------------------------------- Please select,eMMC Partition Area. 0:User Partition Area : 30535680 KBytes eMMC Sector Cnt : H'0 - H'03A3DFFF 1:Boot Partition 1 : 16384 KBytes eMMC Sector Cnt : H'0 - H'00007FFF 2:Boot Partition 2 : 16384 KBytes eMMC Sector Cnt : H'0 - H'00007FFF --------------------------------------------------------- Select area(0-2)>1 <<<< Enter "1" here -- Boot Partition 1 Program ----------------------------- Please Input Start Address in sector :0000 <<<< Enter "0000" here Please Input Program Start Address : E6320000 <<<< Enter "E6320000" here Work RAM(H'50000000-H'50FFFFFF) Clear.... please send ! ('.' & CR stop load) SAVE -FLASH....... EM_W Complete!
eMMC Boot Settings
Please note that for eMMC booting, the following EXT_CSD registers need to be modified:
EXT_CSD[B1] = 0x0A EXT_CSD[B3] = 0x08
Use EM_SECSD command to modify EXT CSD registers:
>EM_SECSD Please Input EXT_CSD Index(H'00 - H'1FF) :b1 EXT_CSD[B1] = 0x00 Please Input Value(H'00 - H'FF) :a EXT_CSD[B1] = 0x0A >EM_SECSD Please Input EXT_CSD Index(H'00 - H'1FF) :b3 EXT_CSD[B1] = 0x00 Please Input Value(H'00 - H'FF) :8 EXT_CSD[B1] = 0x08
Check Bootloader
Power off the board. Set boot mode to eMMC boot. Then power on. It should be able to boot into u-boot:
[ 0.000096] NOTICE: BL2: RZ G2E Initial Program Loader(CA53) [ 0.004372] NOTICE: BL2: Initial Program Loader(Rev.2.0.7) [ 0.009905] NOTICE: BL2: PRR is RZG G2E Ver.1.1 [ 0.014478] NOTICE: BL2: PLL1 nonSSCG Clock select [ 0.019327] NOTICE: BL2: Board is EK874 RZ/G2E Rev.1.0 [ 0.024502] NOTICE: BL2: Boot device is eMMC(50MHz x8) [ 0.029682] NOTICE: BL2: LCM state is CM [ 0.033647] NOTICE: BL2: 0x400000000 - 0x47fffffff, 2 GiB [ 0.039080] NOTICE: BL2: DDR1856(rev.0.12) [ 0.043231] NOTICE: BL2: [COLD_BOOT] [ 0.048483] NOTICE: BL2: DRAM Split is OFF [ 0.051179] NOTICE: BL2: QoS is default setting(rev.0.05) [ 0.056622] NOTICE: BL2: DRAM refresh interval 3.9 usec [ 0.068842] NOTICE: BL2: v1.5(release):61eac60f5-dirty [ 0.072573] NOTICE: BL2: Built : 19:44:42, Dec 16 2020 [ 0.077761] NOTICE: BL2: Normal boot [ 0.081399] NOTICE: BL2: eMMC boot from partition 1 [ 0.086539] NOTICE: BL2: Load dst=0xe6312100 src=(p:1)0x30000(384) len=0x200(1) [ 0.093922] NOTICE: BL2: Load dst=0x43f00000 src=(p:1)0x30400(386) len=0x1800(12) [ 0.101589] NOTICE: BL2: Load dst=0x44000000 src=(p:1)0x40000(512) len=0x10000(128) [ 0.110783] NOTICE: BL2: Load dst=0x50000000 src=(p:2)0x0(0) len=0x100000(2048) [ 0.139578] NOTICE: BL2: Booting BL31 U-Boot 2018.09-g3bc3f7369f-dirty (Dec 17 2020 - 16:51:50 +0900) CPU: Renesas Electronics R8A774C0 rev 1.1 Model: Silicon Linux EK874 RZ/G2E board DRAM: 1.9 GiB Bank #0: 0x048000000 - 0x0bfffffff, 1.9 GiB Watchdog: Not found by seq! WDT: watchdog@00000000e6020000 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: 2
Build Linux Kernel
cd linux-cip ./build-g2e-openwrt.sh
Create root filesystem
Prepare a SD card with capacity of 1GB or more. Use partition tool like fdisk, create 2 partitions on SD card: first partition should be FAT16/32, with size at least 64MiB, secord partition should be ext4, size should be at least 256MiB. Copy files below into first partition:
linux-cip/deploy/g2e-openwrt/Image linux-cip/deploy/g2e-openwrt/r8a774c0-rzg2e-novotech.dtb linux-cip/deploy/g2e-openwrt/openwrt-modules.tar.gz
Download OpenWRT 19.04 official image for AArch64: https://downloads.openwrt.org/releases/19.07.4/targets/armvirt/64/openwrt-19.07.4-armvirt-64-root.ext4.gz
Restore rootfs to SD card by command below (replace /dev/sdb2 with the real device path of the second patition on your SD card):
gunzip -c openwrt-19.07.4-armvirt-64-root.ext4.gz | sudo dd of=/dev/sdb2 bs=1M status=progress
Mount new rootfs to your system:
sudo mount /dev/sdb2 /mnt
Change serial port device path:
sudo sed -i 's/ttyAMA0/ttySC0/g' /mnt/etc/inittab
Extract kernel modules:
sudo tar -xzf linux-cip/deploy/g2e-openwrt/openwrt-modules.tar.gz -C /mnt
If you want to run OpenWRT on eMMC, you can copy openwrt-19.07.4-armvirt-64-root.ext4.gz to SD card.
Unmount rootfs:
sudo umount /dev/sdb2
Boot kernel & rootfs from SD card
At u-boot auto booting count down, press enter to break into u-boot command-line. Use commands below to boot from SD card:
setenv bootargs 'root=/dev/mmcblk0p2 rootwait rw' fatload mmc 0:1 0x48080000 Image; fatload mmc 0:1 0x48000000 r8a774c0-rzg2e-novotech.dtb; booti 0x48080000 - 0x48000000
The device path of SD card is /dev/mmcblk0, and the path of eMMC is /dev/mmcblk2. Kernel and rootfs can be written into eMMC with the same partition structure as SD card.
Create root filesystem on eMMC
ifconfig br-lan 0.0.0.0 brctl delif br-lan eth0 udhcpc -i eth0 opkg update opkg install fdisk dosfstools e2fsprogs fdisk /dev/mmcblk2
Use fdisk to create partitions just like the partitions on SD card. Then copy necessary files to eMMC:
mkfs.fat /dev/mmcblk2p1 mkdir -p /boot mount /dev/mmcblk0p1 /boot #SDCARD mount /dev/mmcblk2p1 /mnt #eMMC cp -v /boot/* /mnt/ umount /mnt gunzip -c /openwrt-19.07.4-armvirt-64-root.ext4.gz | dd of=/dev/mmcblk2p2 bs=1M sync mount /dev/mmcblk2p2 /mnt sed -i 's/ttyAMA0/ttySC0/g' /mnt/etc/inittab tar -xzf /boot/openwrt-modules.tar.gz -C /mnt umount /mnt
Then reboot system, it will boot from eMMC normally.
System Configuration
Set root password:
passwd
Install luci:
ifconfig br-lan 0.0.0.0 brctl delif br-lan eth0 udhcpc -i eth0 opkg update opkg install luci luci-base /etc/init.d/uhttpd enable reboot
Known problems
Set MAC address of ethernet card
You can set MAC address in u-boot, press Enter key when u-boot is waiting for interrupting, then set MAC address with commands below:
setenv ethaddr "AC:F3:5F:1E:87:53" saveenv
You can replace the address with the one you want.