четвер, 28 вересня 2017 р.

warning: script 'startupssrv' missing LSB tags and overrides

Development for Embedded systems running Linux requires that your PC has one of Linux based distros installed. And if you are Linux user you might get in question while buying UPS compatible with Linux. There are some solutions from APC, but searching further you can find French company Legrand which has nice devices supplied with Linux utilities suitable for advanced usage scenarios. Legrand devices is cheaper, but looks well made.
UPS Communicator is one of the tools from Legrand. It is free, but has only command line interface. After installing UPS Communicator you will notice lot of errors coming from insserv Linux tool that calculate the dependencies between all init scripts.
$ sudo /usr/lib/insserv/insserv -n
insserv: warning: script 'K20startupssrv' missing LSB tags and overrides
insserv: warning: script 'startupssrv' missing LSB tags and overrides
insserv: There is a loop between service plymouth and urandom if started
insserv:  loop involving service urandom at depth 4
insserv:  loop involving service hwclock at depth 3
insserv: There is a loop between service startupssrv and udev if started
insserv:  loop involving service udev at depth 1
insserv: There is a loop at service startupssrv if started
insserv: There is a loop at service plymouth if started
insserv: Starting startupssrv depends on plymouth and therefore on system facility `$all' which can not be true!
insserv: Starting startupssrv depends on plymouth and therefore on system facility `$all' which can not be true!
insserv: Starting startupssrv depends on plymouth and therefore on system facility `$all' which can not be true! 
I spent some time trying to figure out the reason of these notifications. The problem was missing hash symbol in UPS Communicator script header LSB fields

Add 3rd hash symbol before BEGIN INIT INFO and run
$ sudo /usr/lib/insserv/insserv -n
again to check the notifications gone.

понеділок, 6 лютого 2017 р.

Nested bash scripts call graph

One time I had to investigate complex build system from proprietary Linux BSP. It consists of many nested bash scripts. Googling through the Internet I found, that there are no ready tools to create bash call tree. But someone suggested to wrap the shell itself by a custom application, which logs who called it and exec the original shell.
Here you can see my implementation of the wrapper
bash_wrapper produces a colored log of executed scripts. The log also includes call stack for every script.
The code can be easily modified to help investigate complex nested scripts often used by third-parties to build Linux kernel, rootfs and applications, and to pack it into resulted firmware image.

пʼятниця, 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.


Reset button doesn't reboot Socrates if QSPI is selected as boot source. It's related to QSPI addressing mode:


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.

вівторок, 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.