Support arm-linux build(Raspberry Pi 2)
- [x] Change make system to support arm-linux
- https://github.com/Samsung/iotjs/pull/125 landed
- [x] Prepare a simple document to setup RPi2
- https://github.com/Samsung/iotjs/wiki/Setting-Raspberry-Pi-2-for-IoT.js
- [ ] Implement GPIO for RPi2
- Implement GPIO class #128
- Start of GPIO implementation based on GPIO API #131
@ruben-ayrapetyan , I get Segmentation fault with these steps. Standalone JerryScript works ok.
- get
https://github.com/seanshpark/iotjs/tree/rpi2_dev - update jerry to latest
cd deps/jerry
git checkout master
git pull
- patch jerry jmp_buf size 12 to 14
typedef uint64_t jmp_buf[14];
- build iotjs
./tools/build.py --target-arch=arm --target-os=linux \
--no-checktest --noinit-submodule
- copy
build/arm-linux/debug/iotjs/iotjsto RPi2 - in RPi2, run iotjs with simple js file
console.log("Hello World");
- in gdb
Program received signal SIGSEGV, Segmentation fault.
0x00069370 in mem_pools_alloc() ()
(gdb) bt
#0 0x00069370 in mem_pools_alloc() ()
#1 0x0004bf0e in ecma_alloc_number() ()
#2 0x00030e88 in vm_run_from_pos(opcode_t const*, unsigned short, unsigned int, ecma_object_t*, bool, bool) ()
#3 0x00030b62 in vm_run_global() ()
#4 0x0002d814 in jerry_run ()
#5 0x0002350a in iotjs::InitJerry() () at /.../harmony/iotjs/src/iotjs.cpp:50
- JerryScript hash : 0787d76b627cbb79646b01812e68ef79fd98d4c3
mem_pools is 0x01 right before segment fault.
(gdb) print mem_pools
$7 = (mem_pool_state_t *) 0x1
@seanshpark, seems that the issue is caused by incorrect include path of libc (https://github.com/Samsung/jerryscript/issues/304#issuecomment-118939054)
[ISSUE] Could I run IoT.js in Raspberry1? When I flash iotjs into the board, there is a problem leading the iotjs could not running:
./iotjs: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.17' not found (required by ./iotjs)
What should I do?
@GrowingM , thank you for the report.
GLIBC problem is related with the compiler you are using.
This problem itself can be solved by using gcc version 4.6.
But both IoT.js and JerryScript will not compile below 4.7 since it depends on compiler options.
You can try with new RASPBIAN JESSIE. I haven't tried this so not sure it will work.
(https://www.raspberrypi.org/downloads/raspbian/)
Or you can build with static option like the following:
./tools/build.py --buildtype=release --noinit-submodule --target-arch=arm --target-os=linux --cmake-option="-DCMAKE_EXE_LINKER_FLAGS=-static"
@seanshpark Thanks. I have tried this with new RASPBIAN JESSIE. GLIBC version problem is solved. But there are new problems: pi@raspberrypi:~$ ./iotjs Segmentation fault
This problem can be caused by reasons that I can't figure out.
@GrowingM For what it's worth, try with
./tools/build.py --target-arch=arm --cmake-option="-DCMAKE_EXE_LINK_FLAGS=-static"
I'm bot sure, but by this, the output binary will be statically linked with needed libraries, might solve the problem.
@ILyoan I'm sorry for that. The Segmentation fault is still exist. Is it because the cause of the Raspberry's memory allocation mechanism is different from ubuntu14.04?
@GrowingM you can try the prebuilt (static) iotjs from here: http://w.blankon.in/iPa
Please tell me if it works.
iotjs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=b4a938fc334cee01b92dd19eac40d116255815ec, not stripped
And here is the build config:
diorahman@kismis:~/src/iotjs$ sudo ./tools/build.py --buildtype=release --target-arch=arm --cmake-option="-DCMAKE_EXE_LINK_FLAGS=-static"
=======================================
- buildtype : release
- cmake-option : -DCMAKE_EXE_LINK_FLAGS=-static
- tidy : True
- make-flags : -j
- target-os : linux
- tuv : False
- target-arch : arm
- init-submodule : True
- target-board :
- jerry-memstats : False
- builddir : build
- checktest : True
- jerry-heaplimit : 81
- nuttx-home :
- buildlib : False
@diorahman It doesn't work. I have tried to run iotjs with the prebuilt iotjs, also with my own building with the build config you said.
pi@raspberrypi ~/Desktop $ file iotjs iotjs: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=8a64ced935a94d4b9c76b502febef564a5b39e8d, not stripped
The Segmentation Fault is still exist.
My host machine is ubuntu-14.04.2 64-bit. If it should build in 32-bit machine?
What does strace tell you?
''' execve("./iotjs", ["./iotjs"], [/* 18 vars _/]) = 0 brk(0) = 0x1811000 uname({sys="Linux", node="raspberrypi", ...}) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fc8000 access("/etc/ld.so.preload", R_OK) = 0 open("/etc/ld.so.preload", O_RDONLY|O_CLOEXEC) = 3 fstat64(3, {st_mode=S_IFREG|0644, st_size=42, ...}) = 0 mmap2(NULL, 42, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0xb6fc7000 close(3) = 0 open("/usr/lib/arm-linux-gnueabihf/libarmmem.so", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0h\5\0\0004\0\0\0"..., 512) = 512 lseek(3, 17960, SEEK_SET) = 17960 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 960) = 960 lseek(3, 17696, SEEK_SET) = 17696 read(3, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\3\f\1\22\4\24"..., 47) = 47 fstat64(3, {st_mode=S_IFREG|0644, st_size=18920, ...}) = 0 mmap2(NULL, 83236, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f86000 mprotect(0xb6f8b000, 61440, PROT_NONE) = 0 mmap2(0xb6f9a000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0xb6f9a000 mprotect(0xbec38000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC|PROT_GROWSDOWN) = 0 close(3) = 0 munmap(0xb6fc7000, 42) = 0 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 fstat64(3, {st_mode=S_IFREG|0644, st_size=72589, ...}) = 0 mmap2(NULL, 72589, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f74000 close(3) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/usr/lib/arm-linux-gnueabihf/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0xk\4\0004\0\0\0"..., 512) = 512 lseek(3, 808332, SEEK_SET) = 808332 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1280) = 1280 lseek(3, 807760, SEEK_SET) = 807760 read(3, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 47) = 47 fstat64(3, {st_mode=S_IFREG|0644, st_size=809612, ...}) = 0 mmap2(NULL, 900808, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e98000 mprotect(0xb6f59000, 61440, PROT_NONE) = 0 mmap2(0xb6f68000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xc0000) = 0xb6f68000 mmap2(0xb6f6e000, 24264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f6e000 close(3) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/arm-linux-gnueabihf/libm.so.6", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0p<\0\0004\0\0\0"..., 512) = 512 lseek(3, 434644, SEEK_SET) = 434644 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1160) = 1160 lseek(3, 434312, SEEK_SET) = 434312 read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\23\1\24"..., 49) = 49 fstat64(3, {st_mode=S_IFREG|0644, st_size=435804, ...}) = 0 mmap2(NULL, 499856, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e1d000 mprotect(0xb6e86000, 65536, PROT_NONE) = 0 mmap2(0xb6e96000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x69000) = 0xb6e96000 close(3) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/arm-linux-gnueabihf/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0`\321\0\0004\0\0\0"..., 512) = 512 lseek(3, 116400, SEEK_SET) = 116400 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1120) = 1120 lseek(3, 116072, SEEK_SET) = 116072 read(3, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 47) = 47 fstat64(3, {st_mode=S_IFREG|0644, st_size=117520, ...}) = 0 mmap2(NULL, 181664, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6df0000 mprotect(0xb6e0d000, 61440, PROT_NONE) = 0 mmap2(0xb6e1c000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c000) = 0xb6e1c000 close(3) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/arm-linux-gnueabihf/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0lY\0\0004\0\0\0"..., 512) = 512 lseek(3, 120788, SEEK_SET) = 120788 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1520) = 1520 lseek(3, 86420, SEEK_SET) = 86420 read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\23\1\24"..., 49) = 49 fstat64(3, {st_mode=S_IFREG|0755, st_size=122308, ...}) = 0 mmap2(NULL, 160316, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6dc8000 mprotect(0xb6ddc000, 65536, PROT_NONE) = 0 mmap2(0xb6dec000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0xb6dec000 mmap2(0xb6dee000, 4668, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6dee000 close(3) = 0 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) open("/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0L\204\1\0004\0\0\0"..., 512) = 512 lseek(3, 1223552, SEEK_SET) = 1223552 read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2840) = 2840 lseek(3, 1220116, SEEK_SET) = 1220116 read(3, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\23\1\24"..., 47) = 47 fstat64(3, {st_mode=S_IFREG|0755, st_size=1226392, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fc7000 mmap2(NULL, 1295768, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6c8b000 mprotect(0xb6db3000, 61440, PROT_NONE) = 0 mmap2(0xb6dc2000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x127000) = 0xb6dc2000 mmap2(0xb6dc5000, 9624, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6dc5000 close(3) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fc6000 set_tls(0xb6fc64c0, 0xb6fc6bb8, 0xb6fcb050, 0xb6fc64c0, 0xb6fcb050) = 0 mprotect(0xb6dc2000, 8192, PROT_READ) = 0 mprotect(0xb6dec000, 4096, PROT_READ) = 0 mprotect(0xb6e96000, 4096, PROT_READ) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fc5000 mprotect(0xb6f68000, 16384, PROT_READ) = 0 mprotect(0xb6f86000, 20480, PROT_READ|PROT_WRITE) = 0 mprotect(0xb6f86000, 20480, PROT_READ|PROT_EXEC) = 0 cacheflush(0xb6f86000, 0xb6f8b000, 0, 0x15, 0xbec38320) = 0 mprotect(0x8f000, 4096, PROT_READ) = 0 mprotect(0xb6fca000, 4096, PROT_READ) = 0 munmap(0xb6f74000, 72589) = 0 set_tid_address(0xb6fc6068) = 969 set_robust_list(0xb6fc6070, 12) = 0 rt_sigaction(SIGRTMIN, {0xb6dcd434, [], SA_RESTORER|SA_SIGINFO, 0xb6cba180}, NULL, 8) = 0 rt_sigaction(SIGRT_1, {0xb6dcd2d8, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0xb6cba180}, NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0 getrlimit(RLIMIT_STACK, {rlim_cur=8192_1024, rlim_max=RLIM_INFINITY}) = 0 --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x74} --- +++ killed by SIGSEGV +++
'''
@GrowingM ,
As Raspberry Pi core is ArmV6, it may not execute correctly when built with current configuration.
I've tried with giving with -march=armv6 but failed to compile JerryScript.
So for current state we cannot execute IoT.js in Raspberry Pi one.
@seanshpark Yes. I have try IoT.js with Raspberry Pi 2. It can execute IoT.js with ArmV7 architecture.
@seanshpark Could we close this issue?
right after #128 which depends on #276 is closed.
support rtLinux interface?
Closing. #276 is closed and GPIO for linux is supported at #128. (Only GPIO for nuttx is not supported)