Add OpenWrt build guide (#2199)

There was an OpenWrt toolchain file however it's a bit outdated and
we did not have any guide on how to build for this target at all.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
Péter Gál 2018-02-12 09:21:57 +01:00 committed by yichoi
parent e8608707b6
commit 4652c3caaf
3 changed files with 119 additions and 1 deletions

View File

@ -15,4 +15,4 @@
set(CMAKE_SYSTEM_NAME Openwrt)
set(CMAKE_SYSTEM_PROCESSOR mips)
set(CMAKE_C_COMPILER mipsel-openwrt-linux-gcc)
set(CMAKE_C_COMPILER mips-openwrt-linux-gcc)

View File

@ -0,0 +1,18 @@
# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(CMAKE_SYSTEM_NAME Openwrt)
set(CMAKE_SYSTEM_PROCESSOR mips)
set(CMAKE_C_COMPILER mipsel-openwrt-linux-gcc)

100
targets/openwrt/readme.md Normal file
View File

@ -0,0 +1,100 @@
# JerryScript for OpenWrt build guide
This document describes the steps required to compile the JerryScript
for OpenWrt. For target device the TP-Link WR1043ND v1.x router is
used. Please be advised, that if you have a different one minor
modifications to this document could be required.
IMPORTANT!
As the TP-Link WR1043ND is a mips based device and mips is a big-endian
architecture a JerryScipt snapshot which was built on an little-endian
system will not work correctly. Thus it is advised that the
snapshot functionally should be used with caution, that is
DO NOT run snapshots generated on little-endian system(s) on
a big-endian system.
## OpenWrt notes
In 2018 ~January the OpenWrt and LEDE project merged into one
and thus the old OpenWrt parts are now usable only from
an archived repository: https://github.com/openwrt/archive
## OpenWrt toolchain setup
To build the JerryScript for OpenWrt a toolchain is required for
the target router/device. The toolchain setup in this document was
tested on an Ubuntu 16.04.3 LTS Linux.
Steps required for toolchain creation:
### 0. Install OpenWrt build requirements
```sh
$ sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip gawk zlib1g-dev subversion mercurial
```
### 1. Clone OpenWrt (Chaos Calmer version)
```sh
$ git clone https://github.com/openwrt/archive openwrt -b chaos_calmer
$ cd openwrt
```
### 2. Run Menuconfig and configure the OpenWrt
```sh
$ make menuconfig
```
Options which should be set:
* Set "Target System" to "Atheros AR7xxx/AR9xxx".
* Set "Target Profile" to "TP-LINK TL-WR1043N/ND".
Save the configuration (as .config) and exit from the menuconfig.
### 3. Configure the environment variables
```sh
$ export BUILDROOT=$(pwd) # where the openwrt root dir is
$ export STAGING_DIR=${BUILDROOT}/staging_dir/ # required by the compiler
$ export PATH=$PATH:${STAGING_DIR}/host/bin:${STAGING_DIR}/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/
```
The name `toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2` is created based on the menuconfig.
This changes depending on the target device!
### 4. Build the OpenWrt
```sh
$ make
```
### 5. Check if the compiler was built
```sh
$ mips-openwrt-linux-gcc --version # running this should print out the version information
```
At this point we have the required compiler for OpenWrt.
## Build JerryScript for OpenWrt
### 0. Check environment
Please check if the `STAGING_DIR` is configured correctly and that the toolchain binary is on the `PATH`.
### 1. Run the build with the OpenWrt toolchain file
```
$ ./tools/build.py --toolchain cmake/toolchain_openwrt_mips.cmake \
--jerry-libc OFF \
--lto OFF
```
Currenlty the JerryScript libc does not supports the mips platform, that's why the `--jerry-libc OFF` argument
is passed during build.
### 2. Copy the binary
After a successful build the `build/bin/jerry` binary file can be copied to the target device.
On how to copy a binary file to an OpenWrt target device please see the OpenWrt manual(s).