mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix ESP8266 build
This change is to fix build for ESP8266 board with jerry_api_value_t changes. JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
This commit is contained in:
parent
36c7440c40
commit
ed2a3602f4
@ -48,10 +48,10 @@ JERRY_BUILD_FILES := $(SRCPATH)/jerry_extapi.c
|
||||
JERRY_BUILD_FILES := $(JERRY_BUILD_FILES);$(SRCPATH)/jerry_run.c
|
||||
|
||||
|
||||
.PHONY: jerry js2c mbed check-env flash clean
|
||||
.PHONY: jerry js2c mkbin check-env flash clean
|
||||
|
||||
|
||||
all: check-env jerry js2c mbed
|
||||
all: check-env jerry js2c mkbin
|
||||
|
||||
|
||||
jerry:
|
||||
@ -83,7 +83,7 @@ js2c:
|
||||
cd targets/esp8266; ../tools/js2c.py
|
||||
|
||||
|
||||
mbed:
|
||||
mkbin:
|
||||
cd targets/esp8266; \
|
||||
make clean; \
|
||||
BOOT=new APP=1 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE_MAP=3 make; \
|
||||
|
||||
@ -24,14 +24,14 @@
|
||||
|
||||
#define API_DATA_IS_FUNCTION(val_p) \
|
||||
(API_DATA_IS_OBJECT(val_p) && \
|
||||
jerry_api_is_function((val_p)->v_object))
|
||||
jerry_api_is_function((val_p)->u.v_object))
|
||||
|
||||
#define JS_VALUE_TO_NUMBER(val_p) \
|
||||
((val_p)->type == JERRY_API_DATA_TYPE_FLOAT32 ? \
|
||||
(double) ((val_p)->v_float32) : \
|
||||
(double) ((val_p)->u.v_float32) : \
|
||||
(val_p)->type == JERRY_API_DATA_TYPE_FLOAT64 ? \
|
||||
(double) ((val_p)->v_float64) : \
|
||||
(double) ((val_p)->v_uint32))
|
||||
(double) ((val_p)->u.v_float64) : \
|
||||
(double) ((val_p)->u.v_uint32))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
### About
|
||||
|
||||
Files in this folder (embedding/esp8266) are copied from
|
||||
examples/project_template of esp_iot_rtos_sdk and modified for JerryScript.
|
||||
You can view online from [this](https://github.com/espressif/esp_iot_rtos_sdk/tree/master/examples/project_template) page.
|
||||
`examples/project_template` of `esp_iot_rtos_sdk` and modified for JerryScript.
|
||||
You can view online from
|
||||
[this](https://github.com/espressif/esp_iot_rtos_sdk/tree/master/examples/project_template) page.
|
||||
|
||||
|
||||
### How to build JerryScript for ESP8266
|
||||
@ -21,7 +22,9 @@ Below is a summary after SDK patch is applied.
|
||||
|
||||
```
|
||||
cd ~/harmony/jerryscript
|
||||
# clean build
|
||||
make -f ./targets/esp8266/Makefile.esp8266 clean
|
||||
# or just normal build
|
||||
make -f ./targets/esp8266/Makefile.esp8266
|
||||
```
|
||||
|
||||
@ -29,7 +32,7 @@ Output files should be placed at $BIN_PATH
|
||||
|
||||
#### 4. Flashing for ESP8266 ESP-01 board (WiFi Module)
|
||||
|
||||
Steps are for ESP8266 ESP-01(WiFi) board. Others may vary.
|
||||
Steps are for `ESP8266 ESP-01(WiFi)` board. Others may vary.
|
||||
Refer http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family page.
|
||||
|
||||
##### 4.1 GPIO0 and GPIO2
|
||||
|
||||
@ -41,12 +41,12 @@ NAME ## _handler (const jerry_api_object_t * function_obj_p __UNSED__, \
|
||||
#define REGISTER_HANDLER(NAME) \
|
||||
register_native_function ( # NAME, NAME ## _handler)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
DELCARE_HANDLER(assert) {
|
||||
if (args_cnt == 1
|
||||
&& args_p[0].type == JERRY_API_DATA_TYPE_BOOLEAN
|
||||
&& args_p[0].v_bool == true)
|
||||
&& args_p[0].u.v_bool == true)
|
||||
{
|
||||
printf (">> Jerry assert true\r\n");
|
||||
return true;
|
||||
@ -65,13 +65,13 @@ DELCARE_HANDLER(print) {
|
||||
printf(">> print(%d) :", (int)args_cnt);
|
||||
for (cc=0; cc<args_cnt; cc++)
|
||||
{
|
||||
if (args_p[cc].type == JERRY_API_DATA_TYPE_STRING && args_p[cc].v_string)
|
||||
if (args_p[cc].type == JERRY_API_DATA_TYPE_STRING && args_p[cc].u.v_string)
|
||||
{
|
||||
static char buffer[128];
|
||||
int length, maxlength;
|
||||
length = -jerry_api_string_to_char_buffer (args_p[0].v_string, NULL, 0);
|
||||
jerry_api_size_t length, maxlength;
|
||||
length = -jerry_api_string_to_char_buffer (args_p[0].u.v_string, NULL, 0);
|
||||
maxlength = MIN(length, 126);
|
||||
jerry_api_string_to_char_buffer (args_p[cc].v_string,
|
||||
jerry_api_string_to_char_buffer (args_p[cc].u.v_string,
|
||||
(jerry_api_char_t *) buffer,
|
||||
maxlength);
|
||||
*(buffer + length) = 0;
|
||||
@ -88,15 +88,15 @@ DELCARE_HANDLER(print) {
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
DELCARE_HANDLER(gpio_dir) {
|
||||
int port, value;
|
||||
if (args_cnt < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int port, value;
|
||||
port = (int)JS_VALUE_TO_NUMBER (&args_p[0]);
|
||||
value = (int)JS_VALUE_TO_NUMBER (&args_p[1]);
|
||||
|
||||
@ -106,12 +106,12 @@ DELCARE_HANDLER(gpio_dir) {
|
||||
} /* gpio_dir_handler */
|
||||
|
||||
DELCARE_HANDLER(gpio_set) {
|
||||
int port, value;
|
||||
if (args_cnt < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int port, value;
|
||||
port = (int)JS_VALUE_TO_NUMBER (&args_p[0]);
|
||||
value = (int)JS_VALUE_TO_NUMBER (&args_p[1]);
|
||||
|
||||
@ -122,24 +122,25 @@ DELCARE_HANDLER(gpio_set) {
|
||||
|
||||
|
||||
DELCARE_HANDLER(gpio_get) {
|
||||
int port, value;
|
||||
if (args_cnt < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int port, value;
|
||||
port = (int)JS_VALUE_TO_NUMBER (&args_p[0]);
|
||||
|
||||
value = native_gpio_get (port) ? 1 : 0;
|
||||
|
||||
ret_val_p->type = JERRY_API_DATA_TYPE_FLOAT64;
|
||||
ret_val_p->v_float64 = (double)value;
|
||||
ret_val_p->u.v_float64 = (double)value;
|
||||
|
||||
return true;
|
||||
} /* gpio_dir_handler */
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static bool
|
||||
register_native_function (const char* name,
|
||||
jerry_external_handler_t handler)
|
||||
@ -163,7 +164,7 @@ register_native_function (const char* name,
|
||||
|
||||
jerry_api_acquire_object (reg_func_p);
|
||||
reg_value.type = JERRY_API_DATA_TYPE_OBJECT;
|
||||
reg_value.v_object = reg_func_p;
|
||||
reg_value.u.v_object = reg_func_p;
|
||||
|
||||
bok = jerry_api_set_object_field_value (global_obj_p,
|
||||
(jerry_api_char_t *)name,
|
||||
@ -182,7 +183,7 @@ register_native_function (const char* name,
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void js_register_functions (void)
|
||||
{
|
||||
|
||||
@ -24,19 +24,20 @@
|
||||
static const char* fn_sys_loop_name = "sysloop";
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int js_entry (const char *source_p, const size_t source_size)
|
||||
{
|
||||
const jerry_api_char_t *jerry_src = (const jerry_api_char_t *) source_p;
|
||||
jerry_completion_code_t ret_code = JERRY_COMPLETION_CODE_OK;
|
||||
jerry_flag_t flags = JERRY_FLAG_EMPTY;
|
||||
jerry_api_object_t *err_obj_p = NULL;
|
||||
|
||||
jerry_init (flags);
|
||||
|
||||
js_register_functions ();
|
||||
|
||||
if (!jerry_parse (jerry_src, source_size))
|
||||
if (!jerry_parse ((jerry_api_char_t *)jerry_src, source_size, &err_obj_p))
|
||||
{
|
||||
printf ("Error: jerry_parse failed\r\n");
|
||||
ret_code = JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION;
|
||||
@ -45,7 +46,8 @@ int js_entry (const char *source_p, const size_t source_size)
|
||||
{
|
||||
if ((flags & JERRY_FLAG_PARSE_ONLY) == 0)
|
||||
{
|
||||
ret_code = jerry_run ();
|
||||
jerry_api_value_t err_value = jerry_api_create_void_value ();
|
||||
ret_code = jerry_run (&err_value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,6 +74,9 @@ int js_loop (uint32_t ticknow)
|
||||
{
|
||||
jerry_api_object_t *global_obj_p;
|
||||
jerry_api_value_t sysloop_func;
|
||||
jerry_api_value_t* val_args;
|
||||
uint16_t val_argv;
|
||||
jerry_api_value_t res;
|
||||
bool is_ok;
|
||||
|
||||
global_obj_p = jerry_api_get_global ();
|
||||
@ -93,16 +98,12 @@ int js_loop (uint32_t ticknow)
|
||||
return -2;
|
||||
}
|
||||
|
||||
jerry_api_value_t* val_args;
|
||||
uint16_t val_argv;
|
||||
|
||||
val_argv = 1;
|
||||
val_args = (jerry_api_value_t*)malloc (sizeof (jerry_api_value_t) * val_argv);
|
||||
val_args[0].type = JERRY_API_DATA_TYPE_UINT32;
|
||||
val_args[0].v_uint32 = ticknow;
|
||||
val_args[0].u.v_uint32 = ticknow;
|
||||
|
||||
jerry_api_value_t res;
|
||||
is_ok = jerry_api_call_function (sysloop_func.v_object,
|
||||
is_ok = jerry_api_call_function (sysloop_func.u.v_object,
|
||||
global_obj_p,
|
||||
&res,
|
||||
val_args,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
/* Copyright 2014-2016 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.
|
||||
@ -46,11 +46,45 @@ int jerry_port_errormsg (const char* format, ...)
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/** exit - cause normal process termination */
|
||||
void exit (int status)
|
||||
{
|
||||
printf ("!!!! EXIT: %d\n", status);
|
||||
while (true)
|
||||
{
|
||||
;
|
||||
}
|
||||
} /* exit */
|
||||
|
||||
/** abort - cause abnormal process termination */
|
||||
void abort (void)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
} /* abort */
|
||||
|
||||
/**
|
||||
* fwrite
|
||||
*
|
||||
* @return number of bytes written
|
||||
*/
|
||||
size_t
|
||||
fwrite (const void *ptr, /**< data to write */
|
||||
size_t size, /**< size of elements to write */
|
||||
size_t nmemb, /**< number of elements */
|
||||
FILE *stream) /**< stream pointer */
|
||||
{
|
||||
return size * nmemb;
|
||||
} /* fwrite */
|
||||
|
||||
/**
|
||||
* This function can get the time as well as a timezone.
|
||||
*
|
||||
* @return 0 if success, -1 otherwise
|
||||
*/
|
||||
int
|
||||
gettimeofday (void *tp, /**< struct timeval */
|
||||
void *tzp) /**< struct timezone */
|
||||
{
|
||||
return -1;
|
||||
} /* gettimeofday */
|
||||
|
||||
@ -98,7 +98,6 @@ void jerry_task(void *pvParameters) {
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR user_init(void)
|
||||
{
|
||||
const portTickType onesec = 1000 / portTICK_RATE_MS;
|
||||
uart_div_modify(UART0, UART_CLK_FREQ / (BIT_RATE_115200));
|
||||
|
||||
show_free_mem(0);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user