Friday, October 16, 2015

Booting EBV Socrates from QSPI

One of my experiments with EBV Socrates is to boot Linux from QSPI flash. It was made on SoCrates v. 1.2. I was not familiar with Linux, so I was trying to find quick start guide for my board. I was wondered, when it's turned out, that EBV doesn't provide much docs for Socrates. However there is an other article, which seems to be suitable
This article is for another board: Altera Cyclone V SoC Development board. Altera's devboard looks similar to EBV's. Article was last modified on 28 Nov 2014, so I have decided that it's relatively fresh.
Next I have started to go through the article. During this I had many problems, which are described further in accordance with paragraphs. Looking ahead, it should be noted, that boot from QSPI still have many errors and warnings.

About the Yocto Source Package

There is specific Linux kernel for Socrates
It has many improvements from Altera and EBV. Among others, 4.0 kernel has MTD_SPI_NOR_USE_4K_SECTORS configuration option. This option has to be set to "n" in order to enable large erase sectors size of 0x00010000. The reason is that JFFS2 doesn't support erase sector size lower than 0x2000 = 8 KiB. More information is here

Yocto recipes have to be modified to use ebv-socrates-v4.0 kernel. It's more long story, though.
After communication with Altera support, I have learned a few things:
1) it's worth to use newer meta-altera and Yocto, than those from the package;
2) newer meta-altera has significant changes compared to the one from the package;
3) there is no documentation for meta-altera.
So if you want to quickly obtain fresh kernel image and rootfs by means of Yocto, you are out of luck.

D. Update QSPI Partitioning in Device Tree

soc_system_board_info.xml and hps_clock_info.xml generated in previous steps are not suitable for Socrates. These files are board specific and there are no ready ones for Socrates.

DTB file for Socrates can be generated from sources in Linux kernel:
$ make socfpga_socrates.dtb

Before using this command it is necessary to setup proper environment, same as for building kernel image.
To add new partitions, the device tree source in arch/arm/boot/dts/socfpga_socrates.dts needs to be edited.

E. Write Files to QSPI Flash

1. You need to create SD card that boots Linux. However, there is faster and easier way, than to use suggested step-by-step instruction. Socrates workshop includes mk-sd-card.sh aimed to create training SD card.


SD card will contain ebv-socrates-v3.12 kernel, not the fresher 4.0. But at least 3.12 kernel doesn't have problems with QSPI flash, as will be mentioned later.

2. SD card from Socrates workshop doesn't have DOS partition, so just copy files into appropriate folders in ext3 partition.

6. It's necessarily to erase memory region before using
# mtd_debug write
every time you want to rewrite some file in raw partition. However instead of erasing full partition with
# flash_erase
it's more suitable to erase just certain area using
# mtd_debug erase

flashcp can show progress if followed by -v flag.

F. Update U-boot Environment to Boot From QSPI

5. U-boot version from the package hangs up after saveenv command.

Reboot

Reset button doesn't reboot Socrates if QSPI is selected as boot source. It's related to QSPI addressing mode:
http://rocketboards.org/foswiki/view/Documentation/SocBoardQspiBoot

Result

ebv-socrates-v4.0 kernel boots on Socrates with different problems. So I have decided to boot 4.0 from SD card to investigate them. Strange messages appear, when Socrates boots 4.0 kernel from SD card:
[    1.049645] cadence-qspi ff705000.spi: cannot get qspi clk
[    1.055143] cadence-qspi: probe of ff705000.spi failed with error -2 
Therefore flash doesn't appear in /proc/mtd.
And there are some other issues. For example, starting part of the kernel output is garbled.

Tuesday, September 29, 2015

EBV Socrates serial output in VirtualBox

I have managed to connect Socrates board to virtual PC. I am using Ubuntu 12.04.5 amd64 running inside VirtualBox 5.0.4 under Windows 7 host. In previous version of VirtualBox - 4.3.16 - I couldn't do that. There was an issue related to TI USB 3410 driver for onboard UART to USB converter. This driver didn't work correctly inside VirtualBox 4.3.16.
However I couldn't use newer VirtualBox due to this error
After solving the error, I have upgraded Guest additions. USB of the board appears as /dev/ttyUSB0.

Here is screenshot of console output from Socrates















Next I'm going to find out why starting part of Linux kernel output is garbled, as can be seen from the picture.