7. The board

This chapter introduces the board, its hardware and how to boot it.

7.1. Hardware

The hardware documentation of Hachiko can be found here:

http://downloads.architechboards.com/doc/Hachiko/download.html

7.2. Power-On

Hachiko takes the power from the micro-USB connector CN11 and/or the mini-USB connector CN2.

On connector CN2 you can also have the serial console, so, during your daily development use, you would just connect your workstation to the board using a mini-USB to connector CN2. If you connect some power ungry device to the board, you can give more power to the board by connecting your workstation (or a smartphone-like battery charger for example) to the board by means of a micro-USB cable to board connector CN11.

7.3. Serial Console

On Hachiko there is the dedicated serial console connector CN2

_images/board-cn2.jpg

which you can connect, by means of a mini-USB cable, to your personal computer.

Note

Every operating system has its own killer application to give you a serial terminal interface. In this guide, we are assuming your host operating system is Ubuntu.

On a Linux (Ubuntu) host machine, the console is seen as a ttyUSBX device and you can access to it by means of an application like minicom.

Minicom needs to know the name of the serial device. The simplest way for you to discover the name of the device is by looking to the kernel messages, so:

  1. clean the kernel messages

Host

sudo dmesg -c

  1. connect the mini-USB cable to the board
  2. display the kernel messages

Host

dmesg

  1. read the output
  Host    select
[ 2912.634893] usb 3-4: >new full-speed USB device number 6 using xhci_hcd
[ 2912.658153] usb 3-4: >New USB device found, idVendor=0403, idProduct=6001
[ 2912.658160] usb 3-4: >New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2912.658164] usb 3-4: >Product: Hachiko Rev. B
[ 2912.658167] usb 3-4: >Manufacturer: AVNET EMG ITALY
[ 2912.658169] usb 3-4: >SerialNumber: A6XGP6WP
[ 2912.660753] ftdi_sio 3-4:1.0: >FTDI USB Serial Device converter detected
[ 2912.660801] usb 3-4: >Detected FT232RL
[ 2912.660805] usb 3-4: >Number of endpoints 2
[ 2912.660809] usb 3-4: >Endpoint 1 MaxPacketSize 64
[ 2912.660812] usb 3-4: >Endpoint 2 MaxPacketSize 64
[ 2912.660815] usb 3-4: >Setting MaxPacketSize 64
[ 2912.661102] usb 3-4: >FTDI USB Serial Device converter now attached to ttyUSB0

As you can see, here the device has been recognized as ttyUSB0.

Now that you know the device name, run minicom:

Host

sudo minicom -ws

If minicom is not installed, you can install it with:

Host

sudo apt-get install minicom

then you can setup your port with these parameters:

+-----------------------------------------------------------------------+
| A -    Serial Device      : /dev/ttyUSB0                              |
| B - Lockfile Location     : /var/lock                                 |
| C -   Callin Program      :                                           |
| D -  Callout Program      :                                           |
| E -    Bps/Par/Bits       : 115200 8N1                                |
| F - Hardware Flow Control : No                                        |
| G - Software Flow Control : No                                        |
|                                                                       |
|    Change which setting?                                              |
+-----------------------------------------------------------------------+
        | Screen and keyboard      |
        | Save setup as dfl        |
        | Save setup as..          |
        | Exit                     |
        | Exit from Minicom        |
        +--------------------------+

If on your system the device has not been recognized as ttyUSB0, just replace ttyUSB0 with the proper device.

Once you are done configuring the serial port, you are back to minicom main menu and you can select exit.

7.4. Bootstrap

In the latest release only bootmode 3 is supported by Hachiko board. That is the board boots from the serial flash memory connected to the SPI multi I/O bus. To enable bootmode 3 the jumpers J4, J5 and J6 must be respectively in position 0, 1 and 1. When set for bootmode 3, the bootloader (U-Boot) must be flashed on the serial NOR at address 0x18000000 (SPI multi I/O bus space). Hachiko boards already have the latest version of U-Boot flashed on SPI NOR at factory time.

For more information:

7.5. Write to NOR

If for any reason U-Boot is corrupted or broken or simply the board refuses to boot again, the only way to recover the board is to try to flash a new U-Boot binary on the serial NOR. Flashing the NOR without U-Boot or Linux on the board being accessible is an easy task with the correct setup.
Renesas already has brief information about how to use a PARTNER-Jet or ULINK2 to write U-Boot in serial flash. Follows an extract from Renesas documentation.

7.5.1. Using PARTNER-Jet

  • Write to serial flash:
    1. Execute PARTNER-Jet_ARM_V5_71b.exe
    2. Create a new project
    3. Copy “JETARM.CFG” and “usrflash_arm.MON” from flash directory to created project.
    4. Push power on button of PARTNER-JET
    5. Write U-boot image data for serial flash boot to 0x18000000.

7.5.2. Using ULINK2

To use ULINK2, DS-5 from ARM Ltd. and binary writing tool provided from Renesas are needed. As for the way to obtain these tools, please ask Renesas electronics sales representative. After the installation of DS5 and binary writing tool, please go to the next step.

  • Writing to serial flash:
    1. Clear RZ_A1H_spibsc_boot_init\Debug\RZ_A1H_spibsc_boot_init.bin\ directory in DS-5 workspace.
    2. Rename U-boot image file for serial flash boot u-boot.bin as VECTOR_TABLE and put it on the above directory.
    3. Run DS-5.
    4. Connect ULINK2 to the board and poweron the board.
    5. Click script tag and double click RZ_A1H_sflash_boot_user.ds
The process using the ULINK2 is described here more in detail.

Software you need:
  • SPIBSCBoot.zip file containing the DS-5 workspace, the script file and a launcher configuration (download link)
  • DS-5 (preferred and tested version: DS500-BN-00003-r5p0-15rel1)
Setup of the environment and first run:
  1. Install the DS-5 and use the activation code found here http://ds.arm.com/renesas/rza-starter-kit/ to enable the Renesas compiler when a valid licence is asked the first time DS-5 is started
  2. Unzip the content of SPIBSCBoot.zip. Three more files should be available: Connection_Only.launch, Workspace.zip and script.zip. Unzip also Workspace.zip and script.zip
  3. Start DS-5 and import into workspace all the three projects ([File] >> [Import Existing Projects into Workspace]) taking care of select [Copy projects into workspace] when importing
  4. Import also the launch configuration (file Connection_Only.launch) ([File] >> [Import] >> [Launch configurations])
  5. Copy the script directory into workspace directory and copy only the script RZ_A1H_sflash_boot_user.ds in the workspace directory (outside the script dir)
  6. Open [Run] >> [Debug Configurations...] menu, then click on [DS-5 Debugger] >> [Connction_only]. In the [Connection] tab select [Renesas]/[RZ/A Series-R7S72100]/[Bare Metal Debug]/[Debug of Coretex-A9 via ULINK2] and press the [Browse] button to identify and select the attached debugger. Press Apply to save changes.
  7. Rename u-boot.bin file as VECTOR_TABLE and copy it in RZ_A1H_spibsc_boot_init\Debug\RZ_A1H_spibsc_boot_init.bin\ directory inside the workspace
  8. Connect the ULINK2 and power on the board. Select again [Run] >> [Debug Configurations...] menu, click on [DS-5 Debugger] >> [Connction_only] and on the Debug button.
  9. When the DS-5 Dubug perspective is open, in the [Script] tab of DS-5 import the script RZ_A1H_sflash_boot_user.ds
  10. Pause the microprocessor with the button in the toolbar and double-click on the script to run it
  11. When the download script runs, the flash downloader is launched and a message is shown in the [Application Console]. Answer Y to the first question and N to the second one
  12. When downloading finishes, it is possible to disconnect from target
For all the subsequent times it will be enough:
  1. Open the DS-5
  2. Switch to DS-5 Debug perspective
  3. Select the launcher from the [Debug control] tab
  4. Press the [Connect to Target] button in the toolbar
  5. Double click on the script in the [Script] tab
  6. Answer Y and N to the two questions in the [Application Console]
  7. Disconnect from the target using the [Disconnect from the Target] button in the toolbar

For a more detailed description of the entire process, see:

Note

* To change file to program in serial NOR it is enough to overwrite again the file named VECTOR_TABLE as seen at step (8)
* It is not possible to reprogram the NOR flash if the board successfully boots Linux. To be able to write the NOR using the DS-5 it is required that the board stops in U-Boot or at first stage bootloader (before U-Boot is loaded)

7.6. U-Boot

To check if the board is correctly programmed, connect the board to a terminal emulator on your computer. To see how this can be achieved please refer to section serial_console_label.

If everything is setup correctly you should be able to see the bootstrap process and the U-Boot output. In particular, as soon as the board is powered a countdown is started and displayed on the serial output. If a key is pressed before the countdown expires the autoboot stops, otherwise Linux is loaded from USB or SPI NOR.

On Hachiko board you can boot using the USB or the serial NOR. During the boot process, if U-Boot detects a correct kernel and rootfs on the USB drive it will boot from this USB device, otherwise it will switch to SPI NOR. In case no correct linux kernel is detected, the boot stops in the U-Boot console.

For a brief documentation about U-Boot:

7.7. Boot from USB

Booting from USB requires that an USB pen drive is prepared with all the files needed for booting Linux and that it is correctly partitioned.

Important

The only USB port that it is possible to use for booting is the USB port at the bottom of the USB connector.

7.7.1. USB partitioning

The USB pen driver is required to have one single EXT2 partition with a start sector of the partition below the 63rd sector. It is possible to use tools as fdisk or cfdisk to partition the USB drive.

Before use these commands you need unmount the device:

  Host    select
sudo umount /path/to/your/USB/device/partition

After that you can use the following commands:

  Host    select
sudo cfdisk /path/to/your/USB/device

As alternative it is possible to use the sfdisk tools to have the partition correctly aligned to the first sector:

  Host    select
sudo sfdisk /path/to/your/USB/device << EOF
0,
EOF
To format the partition it is enough:
  Host    select
sudo mkfs.ext2 /path/to/your/USB/device/partition

7.7.2. USB content

When booting from USB, U-Boot expects to find a valid single EXT2 partition in the USB pen drive containing the rootfs. Moreover U-Boot needs to find in /boot directory a valid kernel image and a valid DTB file respectively named uImage and rza1-hachiko.dtb.

When using Yocto to generate the rootfs we need to extract the compressed rootfs found in

  Host    select
/home/architech/architech_sdk/architech/hachiko-tiny/yocto/build/tmp/deploy/images/hachiko

in the partition on the USB and copy the kernel in /boot/uImage and DTB file in /boot/rza1-hachiko.dtb.

Briefly, to have a bootable USB stick after having compiled an image with Yocto:

  1. Create one EXT2 partition in the USB stick
  2. Extract the content of your .tar.bz2 rootfs tarball file in the EXT2 partition
  3. Copy uImage to /boot
  4. Copy uImage-rza1-hachiko.dtb to /boot and rename it as rza1-hachiko.dtb

At this point it is possible to boot Linux by inserting the USB pen drive in the correct USB port and power on the board.

7.8. Boot from NOR

When no USB device is attached or the kernel image is not valid, U-Boot tries to boot from SPI NOR. In Hachiko board the NOR is required to contain all the needed files in the first serial flash memory on channel 0.

Note

A valid NOR Linux image is programmed at factory time in Hachiko NOR, so it is possible to start using Hachiko board right away.

7.8.1. NOR Partitioning

The serial flash memory is divided into 5 partitions according to the following scheme (the base address is 0x18000000):

0x18000000-0x18080000 spibsc0_loader  (offset: 0x00000000)
0x18080000-0x180c0000 spibsc0_bootenv (offset: 0x00080000)
0x180c0000-0x184c0000 spibsc0_kernel  (offset: 0x000c0000)
0x184c0000-0x18500000 spibsc0_dtb     (offset: 0x004c0000)
0x18500000-0x1c000000 spibsc0_rootfs  (offset: 0x00500000)
spibsc0_loader: contains u-boot (u-boot.bin)
spibsc0_bootenv: contains u-boot environment
spibsc0_kernel: contains the Linux kernel (uImage)
spibsc0_dtb: contains the DTB file (rza1-hachiko.dtb)
spibsc0_rootfs: contains the rootfs

7.8.2. NOR content

To write in NOR and replace or update the content of the NOR partitions you can go through U-Boot or Linux. It is strongly recommended to use Linux for writing new data in NOR partitions, especially when no external SDRAM is available.

7.8.2.2. Using Linux

To use linux for writing or updating data on the serial NOR you are going to need MTD utils. It is possible to compile a small image containing the MTD utils with Yocto by means, for example, of image core-image-minimal-mtdutils that can be generated by Bitbake with this command line:

  Host    select
bitbake core-image-minimal-mtdutils

Warning

If you are using the Hachiko-tiny which is the board without external RAM, in order to compile successfully this image you have to abilitate the IPv6 in the uClibc. To do so open the file:
/home/architech/architech_sdk/architech/hachiko-tiny/yocto/meta-hachiko/conf/distro/tiny-linux-uclibc.conf
and at the line DISTRO_FEATURES_NET = “ipv4” change it with DISTRO_FEATURES_NET = “ipv4 ipv6”

In Linux, the process is made easier by the MTD framework that remap each NOR partition to a different device file. In particular:

  Board    select
/dev/mtd0: spibsc0_loader
/dev/mtd1: spibsc0_bootenv
/dev/mtd2: spibsc0_kernel
/dev/mtd3: spibsc0_dtb
/dev/mtd4: spibsc0_rootfs

Again the process goes through 2 steps: (1) erasing the content of the serial NOR partition and (2) write the new data.

  1. To erase the content of the partition the tool flash_erase can be used. For raw files as u-boot.bin, uImage or rza1-hachiko.dtb, the tool can be used as follow:
  Board    select
flash_erase /path/to/your/mtd/device 0 0

This command completely erases the content of the partition. For the root file system the command is slightly different, since being spibsc0_rootfs a JFFS2 partition, it requires proper formatting, so for mtd4 device you need to run this command:

  Board    select
flash_erase -j /dev/mtd4 0 0
  1. To write the new data on the serial NOR the tool flashcp is used. Again for raw file the simple syntax is:
  Board    select
flashcp -v /path/to/your/file /path/to/your/mtd/device

For rootfs we have two different ways to write data in spibsc0_rootfs partition:

  1. Using the image file .jffs2 generated by Yocto
  Board    select
flashcp -v /path/to/your/image/file.jffs2 /dev/mtd4
  1. If you wish to use the image file .tar.bz2 instead, you need to mount the partition and decompress the file content in place.
  Board    select
mount -t jffs2 mtd4 /mnt/
tar xv -C /mnt/ -f /path/to/your/image/file.tar.bz2
umount /mnt/

For more information on how to manage flash storage with Linux:

7.9. Network

The network PHY is provided by Renesas’s chip 60610 (U6). Within Linux, you can see the network interface as eth0.

If you want that configuration to be brought up at boot you can add a few line in file /etc/network/interfaces, for example, if you want eth0 to have a fixed ip address (say 192.168.0.10) and MAC address of value 1e:ed:19:27:1a:b6 you could add the following lines:

  Board    select
auto eth0
iface eth0 inet static
    address 192.168.0.10
    netmask 255.255.255.0
    hwaddress ether 1e:ed:19:27:1a:b6