This article describes what elua is. This article will conduct hands-on experiments, compile elua, and compile it on the stm32f4discovery platform.
Prerequisites:
Software:
The Ubuntu operating system is used as a cross-compiling environment (I use 14.04, but other versions should be fine)
Git (if not, Apt-Get installgit)
Hardware
Stm32f4discovery Development Board
Mini USB cable
Micro USB cable
Install dependency:
Apt-Get install 5.1 (preferably 5.1, 5.2 never tried)
Apt-Get install luarocks
Luarocks install luafilesystem
Luarocks install lpack
Luarocks install MD5
Installation tool chain:
The tool chain here is different from that officially recommended by elua (codesoourcery). Instead, it uses GNU tools forarm embedded processors toolchain.
For the reason, see the last section.
First, download gcc-arm-none-eabi-4_8-44q2-20140609-linux.tar.bz2 based on the link GNU tools forarm embedded processors toolchain. assume that the download file is saved in the user's root directory ~
Decompress: Tar -xvjfgcc-arm-none-eabi-4_8-2014q2-20131204-linux.tar.bz2
Add path
Add
Exportpath = $ path :~ /Gcc-arm-none-eabi-4_8-2014q2/bin
After setting, you can perform a test:
$ Arm-None-Eabi-gcc-print-Multi-lib
Download elua source code
Git clonehttps: // github.com/elua/elua.git
Compile elua source code
Go to the elua directory
Luabuild_elua.lua board = stm32f4discovery
*********************************
Compilingelua...
CPU: stm32f407vg
Board: stm32f4discovery
Platform: paif4
Allocator: Multiple
Bootmode: Standard
Target: Lua
Toolchain: codesourcery
Romfsmode: verbatim
Version: v0.9-215-gc216dd2
Luabuild_elua.lua board = stm32f4discovery-c equivalent to clean
Prog is used to generate Hex and binfiles for writing. If there is no prog option, only elf and map files are generated.
Burn an elua Image
Install dependency first
Whichautoconf
No sudo apt-Get install Autoconf
LikewiseSudo apt-getinstall libusb-1.0
Sudo apt-Get install PKG-config
Download stlink code
Git clone https://github.com/texane/stlink stlink. Git
Compile stlink code
CD stlink. Git
./Autogen. Sh
./Configure
Make
Install
CD flash
Sudo CP St-flash/usr/bin
Install udev to identify stlink Devices
CD ..
Sudo Cp *. Rules/etc/udev/rules. d
Sudo restart udev
Connect the PC and stm32f4discovery with miniusb
Command Line input (in the elua directory ):
St-flash write elua_lua_stm32f4discovery.bin 0x8000000
Connect to stm32f4discovery
Use micro USB to connect the PC and stm32f4discovery. Linux does not require a driver. The/dev directory contains ttyacm0.
Use cutecom as the serial port terminal (SUDO apt-Get install cutecom)
Open cutecom sudo cutecom
Ttyacm0 115200 N 8 1
Note: Carriage Return and line feed
Enter help
The help of elua shell will be returned. Information about elua shell will be covered in the fourth article
About the officially recommended tool chain codesourcery
At first, I referred to the official documents:
Http://www.eluaproject.net/doc/master/en_building.html
Http://www.eluaproject.net/doc/master/en_toolchains.html
Install the lite version of sourcery (free of charge) according to official recommendations. Note that for ARM Eabi
Obtainingand installing the toolchain is very easy:
1. Go to the codesourcery download location for the toolchain.
2. select from the table the current version in the "Eabi" Line (the link to the current version is just above the "allversions..." link ).
3. download and run the installer.
DownloadArm-2014.05-28-arm-none-eabi.bin
Install/bin/sh arm-2014.05-28-arm-none-eabi.bin
Configure path
Export Path =/Home/xxx/Mentorgraphics/sourcery_codebench_lite_for_arm_eabi/bin // bin: $ path
Verify it.
$ Arm-None-Eabi-gcc-print-Multi-lib
Compared with the GNU version, we can find that a lot of libraries are missing, and there is no support for hard floating point. (in this case, after a link error occurs, we can find a lot of files)
Compile luabuild_elua.lua board = stm32f4discovery
Link error:
A long error occurs. It is literally a LD error. libm. A does not support VFP.
Search for stm32f4discovery onlineUses vfpregister arguments and other keywords, found:
Http://hertaville.com/2012/05/28/gcc-arm-toolchain-stm32f0discovery/
There are a variety of arm-toolchains outthere. these include arm devkit pro, yagarto, mentorgraphics codesourcery lite, and the GCC-arm toolchain. of these toolchains, the two most popular ones are the codesourcery lite (ownedby mentor graphics) and the GCC-arm toolchain. traditionally I wocould use the codesourcery litw.lchain. however that toolchain does not provide "hardfp" (hardware floatingpoint) support. so if I choose to use it with say the stm32f4discovery board in the future, Iwill not be able to take full advantage of the Floating Point Unit (FPU) on thestm32f4 microcontroller on board. the GCC-arm toolchain on the other hand hashardfp support and can be used with all Cortex-M0, M3 and M4 parts. thisuniversality is why I will choose it even though I will most likely onlyfocus on Cortex-M0 cores. and so for the purpose of this tutorial, I Will beusing the GCC-arm toolchain.
Http://stackoverflow.com/questions/10585208/gnu-arm-toolchain-with-hardware-floating-point-support
I have startedworking on each F4 discovery Board and have compiled and run a few basicprograms using the latest yagarto toolchain containing the GCC 4.6.2. latelythough on several forums I have read that implements toolchains including the latestyagarto have problems when it comes to using the on-board hardware FPU. ihave also read that the latest codesourcery toolchain does support hardwarefloating point , But not in the Lite Edition !!
While digging deepinto the topic I found this toolchain which is specifically for ARM cortex M/rcontrollers, and claims to have no problems when it comes to hardware FPU.
Two solutions:
First, change the tool chain.
Second, change hard floating point to key floating point:
Fp32with FPU Enabled
Http://elua-development.2368040.n2.nabble.com/FP32-with-fpu-enabled-td7013335.html
Where:
- Software floating point emulation, which is the default. In this case, the compiler implements floating-point Arithmetic by means of library CILS.
- VFP hardware floating-point support using the soft-float Abi. this is selected by the-mfloat-Abi = softfp option. when you select this variant, the compiler generates VFP floating-point instructions, but the resulting code uses the same call and return conventions as Code Compiled with software floating point.
- VFP hardware floating-point support using the VFP Abi, which is the VFP variant of the procedure call standard for the arm? Architecture (aapcs). This Abi uses VFP registers to pass function arguments and return values, resulting in faster floating-point code. To use this variant, compile with-mfloat-Abi = hard.
It is determined that it is a floating-point compilation option problem, library files and compilation options are not compatible
Find the elua source code, search for "mfloat-Abi", and find in/src/platform/javasf4/CONF. Lua
Localtarget_flags = {'-mcpu = cortex-m4', '-mthumb','-mfloat-Abi = hard ','-mfpu = fpv4-sp-d16 '}
This is
Local target_flags = {'-mcpu = cortex-m4', '-mthumb','-mfloat-Abi = softfp}
But you need to clean it.
Luabuild_elua.lua board = stm32f4discovery-C
Recompile
Luabuild_elua.lua board = stm32f4discovery target = lualong
-- It is related to-mfloat-Abi = softfp. If the default target = Lua is of the float type and has a console, It is not reflected after the Lua command is entered.
*********************************
Compilingelua...
CPU: stm32f407vg
Board: stm32f4discovery
Platform: paif4
Allocator: Multiple
Bootmode: Standard
Target: lualong
Toolchain: codesourcery
Romfsmode: verbatim
Version: v0.9-215-gc216dd2
OK is compiled, but Lua does not support floating-point operations.
References:
Http://www.eluaproject.net/doc/master/en_building.html
Http://www.fussylogic.co.uk/blog? P = 1222
Http://wiki.eluaproject.net/STM32F4DISCOVERY
Http://www.eluaproject.net/doc/master/en_arch_ltr.html
Http://www.eluaproject.net/doc/master/en_toolchains.html
Http://www.wolinlabs.com/blog/linux.stm32.discovery.gcc.html
Http://startingelectronics.com/tutorials/STM32-microcontrollers/programming-STM32-flash-in-Linux/
In the next article, elua compilation options will be set to add and delete some functional modules (such as WOFS file systems)
Learning elua (II) -- compiling and writing