How to migrate Lua to the Linux kernel on the arm platform

Source: Internet
Author: User

Porting the script to the kernel is a cool thing, Lua has been ported to the kernel of NetBSD, there is a project called Lunatik to the Linux kernel, but only to support x86, not support arm, search on the internet, did not find ready, so I researched the next, Now share it.

Ported to arm platform, mainly to re-implement SETJMP and longjmp two functions, the online related information is very few, finally found a KLIBC project, there is setmp and longjmp arm platform implementation, so directly to use, needless to say, It is exciting to see the script execute in the kernel and print out "Hello,world". Here is the method used, the specific code can go to the following location to download:

Https://github.com/negtise/luak-arm


1, download the code first, download it and put the Lunatik directory inside the Lib directory.


2. Configure the kernel:

2.1 Modify Lib/kconfig, add the following configuration

Config Lunatik
TriState "Enable Lunatik Lua Engine"
Default Y
Help
Enables the Lunatik LUA engine which allows execution of LUA code


2.2 Configuring LUA to generate KO files

Perform:

Make Arch=arm Menuconfig

And then:

Config Lunatik to compile as Module
Library Routines--->
<M> Enable Lunatik Lua Engine


3. Compiling:

Make Arch=arm cross_compile=arm-linux-gnueabi-modules Subdirs=lib/lunatik

Will generate a Luak.ko


4. Commissioning:

Execute the following command:

Cat/proc/kmsg &

echo 9 >/PROC/SYS/KERNEL/PRINTK

Insmod Luak.ko

echo "Print (' Hello,world ')" >/sys/class/lunak/eval


If one is OK, it will output:

Hello,world

This is done from the kernel.


5. How do I extend the functionality?

You can view the code in the Bindings directory.




How to migrate Lua to the Linux kernel on the arm platform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.