Category: Embedded

Yocto/OpenEmbedded: fix “max_leb_cnt too low” error

I am developing with the board Atmel SAMA5D3-Xplained, if you are compiling with Yocto/OpenEmbedded you might experience a similar error:

ERROR: Error: The image creation script '/home/cesare/development/projects/atmel_studio/yocto/poky_atmel2/poky/build-atmel/tmp/work/sama5d3_xplained-poky-linux-gnueabi/atmel-qt5-demo-image/1.0-r0/temp/create_image.ubifs' returned 255:
Error: max_leb_cnt too low (2101 needed)
WARNING: exit code 255 from a shell command.

ERROR: Function failed: do_rootfs
ERROR: Logfile of failure stored in: /home/cesare/development/projects/atmel_studio/yocto/poky_atmel2/poky/build-atmel/tmp/work/sama5d3_xplained-poky-linux-gnueabi/atmel-qt5-demo-image/1.0-r0/temp/log.do_rootfs.17769
ERROR: Task 7 (/home/cesare/development/projects/atmel_studio/yocto/poky_atmel2/meta-atmel/qt5-layer/recipes-qt/images/atmel-qt5-demo-image.bb, do_rootfs) failed with exit code '1'
NOTE: Tasks Summary: Attempted 4519 tasks of which 4274 didn't need to be rerun and 1 failed.

To solve edit /poky/meta-atmel/conf/machine/sama5d3-xplained.conf and change the argument -c <newvalue> at line

MKUBIFS_ARGS ?= " -e 0x1f000 -c 2048 -m 0x800  -x lzo"

with a new increased value.

How to install OpenOCD v0.8.x, a useful hardware debugger for Eclipse and Netbeans

OpenOCD (Open On-Chip Debugger) is an open-source software that provides debugging and in-system programming for embedded target devices using JTAG interface.

OpenOCD provides also the ability to flash NAND and NOR FLASH memory devices that are attached to the processor on the target system. Flash programming is supported for external CFI compatible flashes (Intel and AMD/Spansion command set) and several internal flashes (LPC2000, AT91SAM7, STR7x, STR9x, LM3 and STM32x). Official website: http://openocd.sourceforge.net

 

How to install OpenOCD v0.8.0

This procedure has been verified on Xubuntu 14.04.

We create a working directory and clone its repository:

mkdir openocd
git clone git://git.code.sf.net/p/openocd/code repository
cd repository

To see all the available stable versions:

git tag

Switch from master to the latest stable release, at this time v.0.8.0.

git checkout v0.8.0

Install packages:

sudo apt-get install libtool automake libusb-1.0.0-dev texinfo libusb-dev

libusb-dev will enable automatically the support for
Olimex ARM-JTAG-EW Programmer           yes (auto)

libusb-1.0.0-dev will enable automatically the support for
MPSSE mode of FTDI based devices        yes (auto)
ST-Link JTAG Programmer                 yes (auto)
TI ICDI JTAG Programmer                 yes (auto)

texinfo is also needed to avoid the error

line 81: makeinfo: command not found
WARNING: 'makeinfo' is missing on your system.
You should only need it if you modified a '.texi' file, or
any other file indirectly affecting the aspect of the manual.

 

Before compiling

Because we are building from repository

./bootstrap

To see the list of all the supported options: ./configure –help

This time any interface based on the parallel port are not enabled

./configure

At the end we will get the summary reporting the supported devices

OpenOCD configuration summary
--------------------------------------------------
MPSSE mode of FTDI based devices        yes (auto)
ST-Link JTAG Programmer                 yes (auto)
TI ICDI JTAG Programmer                 yes (auto)
Keil ULINK JTAG Programmer              yes (auto)
Altera USB-Blaster II Compatible        yes (auto)
Segger J-Link JTAG Programmer           yes (auto)
OSBDM (JTAG only) Programmer            yes (auto)
eStick/opendous JTAG Programmer         yes (auto)
Andes JTAG Programmer                   yes (auto)
Versaloon-Link JTAG Programmer          yes (auto)
USBProg JTAG Programmer                 yes (auto)
Raisonance RLink JTAG Programmer        yes (auto)
Olimex ARM-JTAG-EW Programmer           yes (auto)
CMSIS-DAP Compliant Debugger            no

 

Time to compile and install

make
sudo make install

The executable will be installed in: /usr/local/bin/openocd while

scripts will be in: /usr/local/share/openocd/scripts

 

Configure UDEV for the new devices

Copy the rules file into udev default directory and reload the rules. After that assure your username is in the plugdev group.

sudo cp  /usr/local/share/openocd/contrib/99-openocd.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules

 

Create the pdf documentation

texlive is needed to create the documentation

sudo apt-get install texlive
make pdf

A pdf containing the documentation will be created in /doc.

Fix “registers may not be the same” ARM GCC error

I was developing a project using STM32F2 microcontroller when I decided to update the ARM toolchain. After have updated Code Sourcery CodeBench Lite Edition to version 2013.11-24 I encountered the following error:

 

core_cm3.s:826: Error: registers may not be the same — `strexb r3,r2,[r3]’

 

After some investigation I found this thread and according to it we need to edit some functions.

Open core_cm3.c (typically in Libraries/CMSIS/CM3/CoreSupport/core_cm3.c if using the STM32F2xx Standard Peripherals Library) and look for the functions __STREXB and __STREXH.

You have to change “=r” to “=&r” in order to have:

from

__ASM volatile ("strexb %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );

to:

__ASM volatile ("strexb %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );

I solved in this way and I hope ST will upgrade their libraries soon.

Install SEGGER J-Link tools on GNU/Linux x64 machine

OpenOCD is a great useful utility which supports the SEGGER J-Link but sometimes I prefer its native tools, for instance I can enable the SWD JTAG mode and take advantage of other useful low level commands.

Here is the procedure how to install the proprietary J-Link tools from SEGGER on GNU/Linux. This has been tested on Xubuntu 13.04.

First of all download the J-Link software: http://www.segger.com/jlink-software.html

At the moment of this writing the latest version is the v4.62a

tar xf JLink_Linux_V462a.tgz
cd JLink_Linux_V462a

make sure you are a member of the group plugdev, to check which users are in the group

cat /etc/group | grep plugdev

if eventually you have to add your name to the group

sudo useradd -G plugdev <username>

then copy the UDEV rules file which will allow every J-Link device to be open without root permission

sudo cp 45-jlink.rules /etc/udev/rules.d

now, if we try to launch the J-Link Commander we will probably get a weird error

./StartJLinkExe.sh
./StartJLinkExe.sh: 7: ./StartJLinkExe.sh: ./JLinkExe: not found

this is due because we are trying to launch a 32bit binary on 64bit machine, in fact we need the ia32-libs package.

sudo apt-get install ia32-libs

if we launch again the start script we might get

./StartJLinkExe.sh
./JLinkExe: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory

then we have to install the readline library 32bit version

sudo apt-get install lib32readline5

we can now launch the J-Link Commander without restarting

./StartJLinkExe.sh
SEGGER J-Link Commander V4.62a ('?' for help)
 Compiled Feb  6 2013 11:42:45
 DLL version V4.62a, compiled Feb  6 2013 11:42:42
 Firmware: J-Link ARM V8 compiled Nov 14 2012 22:34:52
 Hardware: V8.00
 S/N: 58000000
 Feature(s): RDI,FlashDL,FlashBP,JFlash,GDBFULL
 VTarget = 3.222V
 Info: TotalIRLen = 9, IRPrint = 0x0011
 Info: Found Cortex-M3 r2p0, Little endian.
 Info: TPIU fitted.
 Info: ETM fitted.
 Info: FPUnit: 6 code (BP) slots and 2 literal slots
 Found 2 JTAG devices, Total IRLen = 9:
 #0 Id: 0x4BA00477, IRLen: 04, IRPrint: 0x1, CoreSight JTAG-DP (ARM)
 #1 Id: 0x06411041, IRLen: 05, IRPrint: 0x1, STM32 Boundary Scan
 Cortex-M3 identified.
 JTAG speed: 100 kHz
 J-Link>

To check which libraries are loaded:

export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
ldd JLinkExe
linux-gate.so.1 =>  (0xf772d000)
libjlinkarm.so.4 => not found
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf76f2000)
libusb-0.1.so.4 => /lib/i386-linux-gnu/libusb-0.1.so.4 (0xf76e7000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xf76de000)
libreadline.so.5 => /lib32/libreadline.so.5 (0xf76a5000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf74f2000)
/lib/ld-linux.so.2 (0xf772e000)
libtinfo.so.5 => /lib/i386-linux-gnu/libtinfo.so.5 (0xf74d3000)

 

WordPress Themes