Skip to content

Instantly share code, notes, and snippets.

@chunseoklee
Last active February 20, 2017 17:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chunseoklee/c1ad97ad80d2dd6c8038 to your computer and use it in GitHub Desktop.
Save chunseoklee/c1ad97ad80d2dd6c8038 to your computer and use it in GitHub Desktop.
build iotjs for nuttx on stm32f4
#!/bin/bash
# This script assumes that you have all dependencies on Ubuntu 14.04
# It will takes about 10 or more minites due to repo cloning.
#
# ./harmony ----- iotjs
# |
# ---- nuttx
mkdir harmony
cd harmony
echo '1. install dependencies';
sudo apt-get install autoconf libtool gperf flex bison autoconf2.13
sudo apt-get install libncurses-dev
sudo apt-get install libusb-1.0-0-dev
sudo apt-get install libsgutils2-dev
echo '2. kconfig frontend';
if [[ ! -d "kconfig-frontends" ]]; then
git clone https://github.com/jameswalmsley/kconfig-frontends.git
cd kconfig-frontends
./bootstrap
./configure --enable-mconf
make
sudo make install
sudo ldconfig
cd ..
fi
echo '3. Nuttx Setting(wait for a while)';
if [[ ! -d "nuttx" ]]; then
mkdir nuttx
cd nuttx
git init
git submodule add https://bitbucket.org/seanshpark/nuttx.git nuttx
git submodule add https://bitbucket.org/seanshpark/nuttx_apps.git apps
cd apps
git checkout iotjs
cd ../nuttx
git checkout iotjs
git submodule update --init --recursive
cd tools
./configure.sh stm32f4discovery/iotjs
cd ..
#make menuconfig
touch .config
cd tools
./mkromfsimg.sh ..
sed -i 's/unsigned char/const unsigned char/' nsh_romfsimg.h
sed -i 's/unsigned char/const unsigned char/' nsh_romfsimg.h
cp nsh_romfsimg.h ../../apps/nshlib/nsh_romfsimg_iotjs.h
cd ..
# silly
make
cd ../..
fi
echo '3. Nuttx Setting(wait for a while)';
if [[ ! -d "stlink" ]]; then
git clone https://github.com/texane/stlink.git
cd stlink
./autogen.sh
./configure
make
cd ..
fi
echo '4. IoT.js cloning....'
if [[ ! -d "iotjs" ]]; then
git clone https://github.com/Samsung/iotjs.git
fi
echo '5. Now, Build IoT.js for nuttx on stm32f4discovery'
cd iotjs
rm -rf build
tools/build.py --buildtype=release --target-arch=arm --target-os=nuttx --nuttx-home=../nuttx/nuttx --buildlib --jerry-heaplimit=78 --target-board=stm32f4dis
cp ./build/arm-nuttx/release/lib/libiotjs.a ../nuttx/nuttx/lib/liblibiotjs.a
cp ./build/arm-nuttx/release/lib/libjerrycore.a ../nuttx/nuttx/lib/libjerrycore.a
cp ./build/arm-nuttx/release/lib/libtuv.a ../nuttx/nuttx/lib/libtuv.a
cp ./build/arm-nuttx/release/lib/libhttpparser.a ../nuttx/nuttx/lib/libhttpparser.a
cp ./build/arm-nuttx/release/lib/libfdlibm.a ../nuttx/nuttx/lib/libfdlibm.a
cd ..
echo '6. Build nuttx...'
cd nuttx/nuttx
make
echo 'Build Process Done.'
echo "Now, try to flash bin into stm32f4[Enter]"
read flash
echo "Flashing...."
sudo ../../stlink/st-flash write nuttx.bin 0x8000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment