Page 22

EETE MAR 2015

DEBUGGING &PROGRAMING TOLS shell initialisation file’s /etc/profile. Boot time may be decreased markedly, and overall performance may be improved, by enabling Execute In Place (XIP). This is a method for executing code from Flash. Normally, Linux code is loaded from Flash into external memory, and then executed from external memory. By executing from Flash, less memory space is used as a copy step is eliminated, and no memory is occupied by read-only sections. The example project featured in this article is based on an STM32F429 MCU. In fact, users might find peripheral initialisation on the STM32F4 series difficult at first. Fortunately, STMicroelectronics has developed several tools to help. One of the latest is the STM32CubeMX initialisation code generator (part number UM1718). This tool covers every detail of peripheral initialisation, shows warnings and errors, and warns of hardware conflicts while configuring peripherals. The STM32F429 MCU has enough internal Flash memory for small embedded Linux projects. It is important to remember that embedded Linux projects use several binary images (boot loader, Linux kernel and the root filesystem): these need to be aligned on Flash sector boundaries. This avoids the risk that, by loading one image, a part of another will be erased or corrupted. Step 3: installing Linux on a host computer To build an embedded Linux project, a Linux host is required. For a Windows PC, it is advisable to install the Oracle® VirtualBox, creating a new virtual machine with 512Mbytes of RAM and a 16Gbyte disk. Many Linux distributions are available; Debian is, in the author’s experience, compatible with the VirtualBox environment. This Linux host must have access to the internet, so that the GNU cross-build tools for the ARM Cortex-M target may be downloaded. The designer will then create a tree structure similar to that shown in figure 1, and extract cross-build tools into the /tools folder. At this point, it is necessary to create an ACTIVATE.sh script. Simply use this code to do so. (<.......> is the path to the extracted GNU tools folder): export INSTALL_ROOT=<.......> export PATH=$INSTALL_ROOT/bin:$PATH export CROSS_COMPILE=arm-uclinuxeabiexport CROSS_COMPILE_APPS=arm-uclinuxeabiexport MCU=STMDISCO export ARCH=arm Installing GNU tools into a clean Linux system, however, is not on its own sufficient to allow their use. Their operation is in fact dependent on some other system components (such as the host C/C++ compiler, standard C library headers, and some system utilities). One way to provide these necessary components is to install the Eclipse Integrated Development Environment (IDE) for C. As well as fixing this immediate problem, the Eclipse IDE can help in many other aspects of the development process, although it is outside the scope of this article to describe its features. Now, it is time to launch the Linux terminal utility: click ‘Applications’, then ‘Accessories’ and ‘Terminal’ (see figure 2). Terminal is the main tool used to configure the Linux host and to build embedded Linux applications. Type these commands to install Eclipse and other required tools: su enter root user password apt-get install eclipse-cdt apt-get install genromfs apt-get install libncurses5-dev apt-get install git apt-get install mc Fig. 2: Linux includes the ‘Terminal’ utility and ‘Files’, a graphical utility similar to Windows Explorer The last step in preparing Linux is to download the STM32F429 Discovery Buildroot and extract it to the /uclinux folder. Step 4: building μClinux with Buildroot Now it is necessary to close the previous terminal, which was using the root user profile, and launch a new terminal. In the command line, type ‘mc’ and use the navigator to go to ‘Documents’, then ‘uclinux’. Press Ctrl+O and activate a Linux ARM Cortex-M development session, and run ‘.ACTIVATE.sh’. Again press Ctrl+O and enter the ‘stm32f429-linux-builder-master’ folder. The user now has two options. If using the example project in VirtualBox, follow the ‘make clean’ and ‘make all’ command sequence. If preparing a brand new environment, use the ‘make’ command. Around 30 minutes later, the new μClinux images will be available, as follows: out\uboot\u-boot.bin out\kernel\arch\arm\boot\ xipuImage.bin out\romfs.bin Write these new images to Flash memory. If using Windows and the ST-LINK utility, the following code will work: ST-LINK_CLI.exe -ME ST-LINK_CLI.exe -P “u-boot.bin” 0x08000000 ST-LINK_CLI.exe -P “xipuImage.bin” 0x08020000 ST-LINK_CLI.exe -P “romfs.bin” 0x08120000 Connect the serial console to the board (external RX => 22 Electronic Engineering Times Europe March 2015 www.electronics-eetimes.com


EETE MAR 2015
To see the actual publication please follow the link above