• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# JerryScript for OpenWrt build guide
2
3This document describes the steps required to compile the JerryScript
4for OpenWrt. For target device the TP-Link WR1043ND v1.x router is
5used. Please be advised, that if you have a different one minor
6modifications to this document could be required.
7
8IMPORTANT!
9
10As the TP-Link WR1043ND is a mips based device and mips is a big-endian
11architecture a JerryScipt snapshot which was built on an little-endian
12system will not work correctly. Thus it is advised that the
13snapshot functionally should be used with caution, that is
14DO NOT run snapshots generated on little-endian system(s) on
15a big-endian system.
16
17## OpenWrt notes
18
19In 2018 ~January the OpenWrt and LEDE project merged into one
20and thus the old OpenWrt parts are now usable only from
21an archived repository: https://github.com/openwrt/archive
22
23## OpenWrt toolchain setup
24
25To build the JerryScript for OpenWrt a toolchain is required for
26the target router/device. The toolchain setup in this document was
27tested on an Ubuntu 16.04.3 LTS Linux.
28
29Steps required for toolchain creation:
30
31### 0. Install OpenWrt build requirements
32```sh
33$ sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip gawk zlib1g-dev subversion mercurial
34```
35
36### 1. Clone OpenWrt (Chaos Calmer version)
37
38```sh
39$ git clone https://github.com/openwrt/archive openwrt -b chaos_calmer
40$ cd openwrt
41```
42
43### 2. Run Menuconfig and configure the OpenWrt
44
45```sh
46$ make menuconfig
47```
48
49Options which should be set:
50* Set "Target System" to "Atheros AR7xxx/AR9xxx".
51* Set "Target Profile" to "TP-LINK TL-WR1043N/ND".
52
53Save the configuration (as .config) and exit from the menuconfig.
54
55### 3. Configure the environment variables
56
57```sh
58$ export BUILDROOT=$(pwd) # where the openwrt root dir is
59$ export STAGING_DIR=${BUILDROOT}/staging_dir/ # required by the compiler
60$ export PATH=$PATH:${STAGING_DIR}/host/bin:${STAGING_DIR}/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/
61```
62
63The name `toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2` is created based on the menuconfig.
64This changes depending on the target device!
65
66### 4. Build the OpenWrt
67
68```sh
69$ make
70```
71
72### 5. Check if the compiler was built
73
74```sh
75$ mips-openwrt-linux-gcc --version # running this should print out the version information
76```
77
78At this point we have the required compiler for OpenWrt.
79
80## Build JerryScript for OpenWrt
81
82### 0. Check environment
83
84Please check if the `STAGING_DIR` is configured correctly and that the toolchain binary is on the `PATH`.
85
86### 1. Run the build with the OpenWrt toolchain file
87
88```
89$ ./tools/build.py --toolchain cmake/toolchain_openwrt_mips.cmake \
90                   --lto OFF
91```
92
93### 2. Copy the binary
94
95After a successful build the `build/bin/jerry` binary file can be copied to the target device.
96On how to copy a binary file to an OpenWrt target device please see the OpenWrt manual(s).
97