Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arm-linux build for RPi2 and fix for nuttx build #125

Merged
merged 1 commit into from
Jul 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@

cmake_minimum_required(VERSION 2.8)

string(TOLOWER ${CMAKE_SYSTEM_NAME} CFG_SYS_NAME)
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CFG_SYS_PROCESSOR)

if(${CFG_SYS_NAME} STREQUAL "linux")
if(${CFG_SYS_PROCESSOR} STREQUAL "x86" OR
${CFG_SYS_PROCESSOR} STREQUAL "x86_64")
set(DEVICE_DEPENDS "x86-linux")
elseif(${CFG_SYS_PROCESSOR} STREQUAL "armv7l-hf")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"armv7l-hf" just tells us the cpu architecture, we could not determine that this is Raspberry PI2 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we need board dependent implementation. at this time there is only one arm-linux and it's RPi2, but later there might be others. I'm not sure about how to extend this right now. I hope you can give a way to do this.

set(DEVICE_DEPENDS "arm-linux")
endif()
elseif(${CFG_SYS_NAME} STREQUAL "darwin")
message(fatal "Darwin not ready")
elseif(${CFG_SYS_NAME} STREQUAL "external")
if(${CFG_SYS_PROCESSOR} STREQUAL "arm")
set(DEVICE_DEPENDS "arm-nuttx")
endif()
endif()

set(CC ${CMAKE_C_COMPILER})
set(CXX ${CMAKE_CXX_COMPILER})

Expand Down
39 changes: 39 additions & 0 deletions cmake/config/arm-linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2015 Samsung Electronics Co., Ltd.
#
# 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.

include(CMakeForceCompiler)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7l-hf)

set(EXTERNAL_CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(EXTERNAL_CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)

CMAKE_FORCE_C_COMPILER(${EXTERNAL_CMAKE_C_COMPILER} GNU)
CMAKE_FORCE_CXX_COMPILER(${EXTERNAL_CMAKE_CXX_COMPILER} GNU)

set(FLAGS_COMMON -mlittle-endian
-mthumb
-mfpu=vfpv3-d16
-D__LINUX__
-D__ARM__)

foreach(FLAG ${FLAGS_COMMON})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
endforeach()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
2 changes: 0 additions & 2 deletions cmake/config/arm-nuttx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ include(CMakeForceCompiler)

set(CMAKE_SYSTEM_NAME EXTERNAL)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSTEM_VERSION NUTTX)

set(EXTERNAL_CMAKE_C_COMPILER arm-none-eabi-gcc)
set(EXTERNAL_CMAKE_CXX_COMPILER arm-none-eabi-g++)
Expand All @@ -26,7 +25,6 @@ CMAKE_FORCE_CXX_COMPILER(${EXTERNAL_CMAKE_CXX_COMPILER} GNU)

set(NO_PTHREAD YES)
set(BUILD_TO_LIB YES)
set(DEVICE_DEPENDS "nuttx-stm32f4disco")

set(FLAGS_COMMON -mcpu=cortex-m4
-mthumb
Expand Down
2 changes: 0 additions & 2 deletions cmake/config/i686-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ include(CMakeForceCompiler)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86)

set(DEVICE_DEPENDS "linux-x86")

set(FLAGS_COMMON -D__LINUX__
-D__i686__
-fno-builtin)
Expand Down
2 changes: 0 additions & 2 deletions cmake/config/x86_64-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ include(CMakeForceCompiler)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

set(DEVICE_DEPENDS "linux-x86")

set(FLAGS_COMMON -D__LINUX__
-D__x86_64__
-fno-builtin)
Expand Down
82 changes: 82 additions & 0 deletions src/device/arm-linux/giopctl-arm-linux.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* Copyright 2015 Samsung Electronics Co., Ltd.
*
* 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.
*/

#include "iotjs_def.h"
#include "iotjs_module_gpioctl.h"


namespace iotjs {


class GpioControlInst : public GpioControl {
public:
explicit GpioControlInst(JObject& jgpioctl);
virtual int Initialize(void);
virtual void Release(void);
virtual int PinMode(uint32_t portpin);
virtual int WritePin(uint32_t portpin, uint8_t data);
virtual int ReadPin(uint32_t portpin, uint8_t* pdata);
};


//-----------------------------------------------------------------------------

GpioControl* GpioControl::Create(JObject& jgpioctl)
{
return new GpioControlInst(jgpioctl);
}


GpioControlInst::GpioControlInst(JObject& jgpioctl)
: GpioControl(jgpioctl) {
}


int GpioControlInst::Initialize(void) {
if (_fd > 0 )
return IOTJS_GPIO_INUSE;

_fd = 1;
return _fd;
}


void GpioControlInst::Release(void) {
_fd = 0;
}


int GpioControlInst::PinMode(uint32_t portpin) {
if (_fd <= 0)
return IOTJS_GPIO_NOTINITED;
return 0;
}


int GpioControlInst::WritePin(uint32_t portpin, uint8_t data) {
if (_fd <= 0)
return IOTJS_GPIO_NOTINITED;
return 0;
}


int GpioControlInst::ReadPin(uint32_t portpin, uint8_t* pdata) {
if (_fd <= 0)
return IOTJS_GPIO_NOTINITED;
return 0;
}


} // namespace iotjs
1 change: 1 addition & 0 deletions src/iotjs_module_gpioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define IOTJS_MODULE_GPIOCTL_H

#include "iotjs_binding.h"
#include "iotjs_objectwrap.h"


namespace iotjs {
Expand Down
15 changes: 14 additions & 1 deletion tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def sys_machine():
'tidy': True,
'jerry-memstats': False,
'checktest': True,
'jerry-heaplimit': 81,
}

boolean_opts = ['buildlib',
Expand Down Expand Up @@ -189,6 +190,9 @@ def opt_jerry_memstats():
def opt_checktest():
return options['checktest']

def opt_jerry_heaplimit() :
return options['jerry-heaplimit']

def parse_boolean_opt(name, arg):
if arg.endswith(name):
options[name] = False if arg.startswith('no') else True
Expand Down Expand Up @@ -217,6 +221,8 @@ def parse_args():
options[opt] = val
elif opt == 'nuttx-home':
options[opt] = val
elif opt == 'jerry-heaplimit':
options[opt] = val
else:
for opt_name in boolean_opts:
if parse_boolean_opt(opt_name, opt):
Expand Down Expand Up @@ -275,6 +281,8 @@ def build_libuv():
# libuv is using gyp. run the system according to build target.
if opt_target_arch() == 'arm' and opt_target_os() =='nuttx':
check_run_cmd('./nuttx-configure', [opt_nuttx_home()])
elif opt_target_arch() == 'arm' and opt_target_os() =='linux':
check_run_cmd('./armlinux-configure')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is configure file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok I see this is for uv configuration. so the file should have been in the uv source tree. That good.

else:
check_run_cmd('./gyp_uv.py', ['-f', 'make'])

Expand Down Expand Up @@ -378,12 +386,17 @@ def build_libjerry():
jerry_cmake_opt.append('-DCMAKE_TOOLCHAIN_FILE=' +
opt_cmake_toolchain_file())


# for nuttx build.
if opt_target_arch() == 'arm' and opt_target_os() =='nuttx':
# nuttx include path.
jerry_cmake_opt.append('-DEXTERNAL_LIBC_INTERFACE=' +
join_path([opt_nuttx_home(), 'include']))
jerry_cmake_opt.append('-DPLATFORM_EXT=NUTTX')
jerry_cmake_opt.append('-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=arm')
jerry_cmake_opt.append('-DEXTERNAL_MEM_HEAP_SIZE_KB=' +
str(opt_jerry_heaplimit()))
elif opt_target_arch() == 'arm' and opt_target_os() =='linux':
jerry_cmake_opt.append('-DUSE_COMPILER_DEFAULT_LIBC=YES')

# run cmake.
# FIXME: Running cmake once cause a problem because cmake does not know
Expand Down