lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm trying to compile LuaJIT for an ARM-Cortex-M4F (168MHz, ARMv7
based, single precision FPU).

I was wondering if someone had tried this already (didn't find
anything, glanced over the eLua homepage- they don't seem to support
my target out of the box, so I decided to stick with LuaJIT).

I build with:
make CROSS=arm-none-eabi- TARGET_SYS=arm HOST_CC=gcc
TARGET_CFLAGS="-DLUAJIT_USE_SYSMALLOC -mthumb -mcpu=cortex-m4
-mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Wa,-mimplicit-it=thumb"

This is not sufficient; I have to prepend ".syntax unified" to the
(generated) lj_vm.s file, or the assembler will whine that "Thumb does
not support conditional execution". I am pretty clueless here, but I
guess that LuaJIT's DynASM is generating ARM-instructions and not
thumb-2 ones; I'm not sure that this fix together with
"-Wa,-mimplicit-it=thumb" is appropriate (I just hope it'll work-
would be nice to know for sure).

Now I have some questions:
- Will 100KiBytes of RAM get me anywhere, or will I (predictably) need
more (assuming I won't do anything too fancy)?
- I'm currently making LuaJIT use the system memory allocator
(newlib)- is there an easy way to tell the custom one "just take as
much memory as you want, starting somewhere (&_end) until you bump
into the stack"? Would this pay off in terms of performance? (doing
this currently via _sbrk for the system-malloc)
- Is the FFI module gonna work on this target (for accessing C-code
that is statically linked with the interpreter)?
- Would it be relatively simple to implement single precision
arithmetic (via ffi) myself (I'd publicdomain it, but I assume it
would take more skill and knowledge about LuaJIT intrinsics than I can
muster). Also I don't need it too badly.

Still adding libc-stubs and struggling with my toolchain atm...
If someone has an STM32F4-Discovery board lying around (<20$) or is
interested in this, tell me, and I'll try to get something into a
publishable shape ASAP. My main focus is easy initialization & control
of common peripherals from Lua (ADC, PWM, CAN, LED's, others will be
added as needed). Scripts and data I'm going to exchange via USB (with
libusb on the Host side).

PS: About -mfloat-abi=softfp: it's the same as -mfloat-abi=hard,
except that float-arguments are not passed via FP-registers? You also
can't use the hard fp-abi if the toolchains libc wasn't specifically
compiled for that? Information on the net is somewhat sketchy and
contradictory :(

Wolfgang Pupp