Skip to content

Instantly share code, notes, and snippets.

@janjongboom
Created January 12, 2018 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save janjongboom/4a0508155c6825863c8ee8340d56da86 to your computer and use it in GitHub Desktop.
Save janjongboom/4a0508155c6825863c8ee8340d56da86 to your computer and use it in GitHub Desktop.
RTL8195AM w/ Mbed.js
diff --git a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/DigitalOut-js.cpp b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/DigitalOut-js.cpp
index 7edae943..bb361542 100644
--- a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/DigitalOut-js.cpp
+++ b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/DigitalOut-js.cpp
@@ -92,31 +92,6 @@ DECLARE_CLASS_FUNCTION(DigitalOut, read) {
return jerry_create_number(result);
}
-/**
- * DigitalOut#is_connected (native JavaScript method)
- *
- * @returns 0 if the DigitalOut is set to NC, or 1 if it is connected to an
- * actual pin
- */
-DECLARE_CLASS_FUNCTION(DigitalOut, is_connected) {
- CHECK_ARGUMENT_COUNT(DigitalOut, is_connected, (args_count == 0));
-
- // Extract native DigitalOut pointer
- void* void_ptr;
- const jerry_object_native_info_t* type_ptr;
- bool has_ptr = jerry_get_object_native_pointer(this_obj, &void_ptr, &type_ptr);
-
- if (!has_ptr || type_ptr != &native_obj_type_info) {
- return jerry_create_error(JERRY_ERROR_TYPE,
- (const jerry_char_t *) "Failed to get native DigitalOut pointer");
- }
-
- DigitalOut* native_ptr = static_cast<DigitalOut*>(void_ptr);
-
- int result = native_ptr->is_connected();
- return jerry_create_number(result);
-}
-
/**
* DigitalOut (native JavaScript constructor)
*
@@ -152,7 +127,6 @@ DECLARE_CLASS_CONSTRUCTOR(DigitalOut) {
// attach methods
ATTACH_CLASS_FUNCTION(js_object, DigitalOut, write);
ATTACH_CLASS_FUNCTION(js_object, DigitalOut, read);
- ATTACH_CLASS_FUNCTION(js_object, DigitalOut, is_connected);
return js_object;
}
diff --git a/targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/PinNames.h b/targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/PinNames.h
index 525b7cd0e..6558f01a0 100644
--- a/targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/PinNames.h
+++ b/targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/PinNames.h
@@ -52,124 +52,124 @@ typedef enum {
typedef enum {
- PA_0 = (PORT_A<<4|0),
- PA_1 = (PORT_A<<4|1),
- PA_2 = (PORT_A<<4|2),
- PA_3 = (PORT_A<<4|3),
- PA_4 = (PORT_A<<4|4),
- PA_5 = (PORT_A<<4|5),
- PA_6 = (PORT_A<<4|6),
- PA_7 = (PORT_A<<4|7),
-
- PB_0 = (PORT_B<<4|0),
- PB_1 = (PORT_B<<4|1),
- PB_2 = (PORT_B<<4|2),
- PB_3 = (PORT_B<<4|3),
- PB_4 = (PORT_B<<4|4),
- PB_5 = (PORT_B<<4|5),
- PB_6 = (PORT_B<<4|6),
- PB_7 = (PORT_B<<4|7),
-
- PC_0 = (PORT_C<<4|0),
- PC_1 = (PORT_C<<4|1),
- PC_2 = (PORT_C<<4|2),
- PC_3 = (PORT_C<<4|3),
- PC_4 = (PORT_C<<4|4),
- PC_5 = (PORT_C<<4|5),
- PC_6 = (PORT_C<<4|6),
- PC_7 = (PORT_C<<4|7),
- PC_8 = (PORT_C<<4|8),
- PC_9 = (PORT_C<<4|9),
-
- PD_0 = (PORT_D<<4|0),
- PD_1 = (PORT_D<<4|1),
- PD_2 = (PORT_D<<4|2),
- PD_3 = (PORT_D<<4|3),
- PD_4 = (PORT_D<<4|4),
- PD_5 = (PORT_D<<4|5),
- PD_6 = (PORT_D<<4|6),
- PD_7 = (PORT_D<<4|7),
- PD_8 = (PORT_D<<4|8),
- PD_9 = (PORT_D<<4|9),
-
- PE_0 = (PORT_E<<4|0),
- PE_1 = (PORT_E<<4|1),
- PE_2 = (PORT_E<<4|2),
- PE_3 = (PORT_E<<4|3),
- PE_4 = (PORT_E<<4|4),
- PE_5 = (PORT_E<<4|5),
- PE_6 = (PORT_E<<4|6),
- PE_7 = (PORT_E<<4|7),
- PE_8 = (PORT_E<<4|8),
- PE_9 = (PORT_E<<4|9),
- PE_A = (PORT_E<<4|10),
-
- PF_0 = (PORT_F<<4|0),
- PF_1 = (PORT_F<<4|1),
- PF_2 = (PORT_F<<4|2),
- PF_3 = (PORT_F<<4|3),
- PF_4 = (PORT_F<<4|4),
- PF_5 = (PORT_F<<4|5),
+ PA_0 = (0<<4|0),
+ PA_1 = (0<<4|1),
+ PA_2 = (0<<4|2),
+ PA_3 = (0<<4|3),
+ PA_4 = (0<<4|4),
+ PA_5 = (0<<4|5),
+ PA_6 = (0<<4|6),
+ PA_7 = (0<<4|7),
+
+ PB_0 = (1<<4|0),
+ PB_1 = (1<<4|1),
+ PB_2 = (1<<4|2),
+ PB_3 = (1<<4|3),
+ PB_4 = (1<<4|4),
+ PB_5 = (1<<4|5),
+ PB_6 = (1<<4|6),
+ PB_7 = (1<<4|7),
+
+ PC_0 = (2<<4|0),
+ PC_1 = (2<<4|1),
+ PC_2 = (2<<4|2),
+ PC_3 = (2<<4|3),
+ PC_4 = (2<<4|4),
+ PC_5 = (2<<4|5),
+ PC_6 = (2<<4|6),
+ PC_7 = (2<<4|7),
+ PC_8 = (2<<4|8),
+ PC_9 = (2<<4|9),
+
+ PD_0 = (3<<4|0),
+ PD_1 = (3<<4|1),
+ PD_2 = (3<<4|2),
+ PD_3 = (3<<4|3),
+ PD_4 = (3<<4|4),
+ PD_5 = (3<<4|5),
+ PD_6 = (3<<4|6),
+ PD_7 = (3<<4|7),
+ PD_8 = (3<<4|8),
+ PD_9 = (3<<4|9),
+
+ PE_0 = (4<<4|0),
+ PE_1 = (4<<4|1),
+ PE_2 = (4<<4|2),
+ PE_3 = (4<<4|3),
+ PE_4 = (4<<4|4),
+ PE_5 = (4<<4|5),
+ PE_6 = (4<<4|6),
+ PE_7 = (4<<4|7),
+ PE_8 = (4<<4|8),
+ PE_9 = (4<<4|9),
+ PE_A = (4<<4|10),
+
+ PF_0 = (5<<4|0),
+ PF_1 = (5<<4|1),
+ PF_2 = (5<<4|2),
+ PF_3 = (5<<4|3),
+ PF_4 = (5<<4|4),
+ PF_5 = (5<<4|5),
/* unavailable pins */
-// PF_6 = (PORT_F<<4|6),
-// PF_7 = (PORT_F<<4|7),
-
- PG_0 = (PORT_G<<4|0),
- PG_1 = (PORT_G<<4|1),
- PG_2 = (PORT_G<<4|2),
- PG_3 = (PORT_G<<4|3),
- PG_4 = (PORT_G<<4|4),
- PG_5 = (PORT_G<<4|5),
- PG_6 = (PORT_G<<4|6),
- PG_7 = (PORT_G<<4|7),
-
- PH_0 = (PORT_H<<4|0),
- PH_1 = (PORT_H<<4|1),
- PH_2 = (PORT_H<<4|2),
- PH_3 = (PORT_H<<4|3),
- PH_4 = (PORT_H<<4|4),
- PH_5 = (PORT_H<<4|5),
- PH_6 = (PORT_H<<4|6),
- PH_7 = (PORT_H<<4|7),
-
- PI_0 = (PORT_I<<4|0),
- PI_1 = (PORT_I<<4|1),
- PI_2 = (PORT_I<<4|2),
- PI_3 = (PORT_I<<4|3),
- PI_4 = (PORT_I<<4|4),
- PI_5 = (PORT_I<<4|5),
- PI_6 = (PORT_I<<4|6),
- PI_7 = (PORT_I<<4|7),
-
- PJ_0 = (PORT_J<<4|0),
- PJ_1 = (PORT_J<<4|1),
- PJ_2 = (PORT_J<<4|2),
- PJ_3 = (PORT_J<<4|3),
- PJ_4 = (PORT_J<<4|4),
- PJ_5 = (PORT_J<<4|5),
- PJ_6 = (PORT_J<<4|6),
+// PF_6 = (5<<4|6),
+// PF_7 = (5<<4|7),
+
+ PG_0 = (6<<4|0),
+ PG_1 = (6<<4|1),
+ PG_2 = (6<<4|2),
+ PG_3 = (6<<4|3),
+ PG_4 = (6<<4|4),
+ PG_5 = (6<<4|5),
+ PG_6 = (6<<4|6),
+ PG_7 = (6<<4|7),
+
+ PH_0 = (7<<4|0),
+ PH_1 = (7<<4|1),
+ PH_2 = (7<<4|2),
+ PH_3 = (7<<4|3),
+ PH_4 = (7<<4|4),
+ PH_5 = (7<<4|5),
+ PH_6 = (7<<4|6),
+ PH_7 = (7<<4|7),
+
+ PI_0 = (8<<4|0),
+ PI_1 = (8<<4|1),
+ PI_2 = (8<<4|2),
+ PI_3 = (8<<4|3),
+ PI_4 = (8<<4|4),
+ PI_5 = (8<<4|5),
+ PI_6 = (8<<4|6),
+ PI_7 = (8<<4|7),
+
+ PJ_0 = (9<<4|0),
+ PJ_1 = (9<<4|1),
+ PJ_2 = (9<<4|2),
+ PJ_3 = (9<<4|3),
+ PJ_4 = (9<<4|4),
+ PJ_5 = (9<<4|5),
+ PJ_6 = (9<<4|6),
/* unavailable pins */
-// PJ_7 = (PORT_J<<4|7),
-
- PK_0 = (PORT_K<<4|0),
- PK_1 = (PORT_K<<4|1),
- PK_2 = (PORT_K<<4|2),
- PK_3 = (PORT_K<<4|3),
- PK_4 = (PORT_K<<4|4),
- PK_5 = (PORT_K<<4|5),
- PK_6 = (PORT_K<<4|6),
+// PJ_7 = (9<<4|7),
+
+ PK_0 = (10<<4|0),
+ PK_1 = (10<<4|1),
+ PK_2 = (10<<4|2),
+ PK_3 = (10<<4|3),
+ PK_4 = (10<<4|4),
+ PK_5 = (10<<4|5),
+ PK_6 = (10<<4|6),
/* unavailable pins */
- // PK_7 = (PORT_K<<4|7),
+ // PK_7 = (10<<4|7),
- AD_1 = (PORT_V<<4|1),
- AD_2 = (PORT_V<<4|2),
- AD_3 = (PORT_V<<4|3),
+ AD_1 = (11<<4|1),
+ AD_2 = (11<<4|2),
+ AD_3 = (11<<4|3),
- DA_0 = (PORT_U<<4|0),
- DA_1 = (PORT_U<<4|1),
+ DA_0 = (12<<4|0),
+ DA_1 = (12<<4|1),
// Not connected
- NC = (uint32_t)0xFFFFFFFF,
+ NC = 0xFFFFFFFF,
// Generic signals namings
/* LED1~4 are defined as alias of GPIO pins, they are not the LEDs on board*/
@@ -236,3 +236,4 @@ typedef enum {
#endif
#endif
+
@narioinc
Copy link

Thanks Jan,

For spending time with the RTL8195 code changes. I'll set the patch up and build the source again now. I have a couple of board here that i can run on. Will report back soon with the build and test.

@narioinc
Copy link

Jan,

The same should work with the 8711AM as well as the two boards are mostly pin-to-pin compatible right ???.
Will try with both the chipsets

@narioinc
Copy link

Hi Jan

I followed the steps as below:

  1. entered the build/jerryscript folder and applied the jerryscript.patch with "git apply jerryscript.patch"
  2. entered jerryscript/target/mbedos5 and applied the mbed-os.patch with "git apply mbed-os.patch"

cleared the node_modules folder and reran

  1. npm install
  2. sudo -H gulp --target=realtek_rtl8195am

I get the error as below:

[20:34:40] Using gulpfile /home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/Gulpfile.js
[20:34:40] Starting 'make-build-dir'...
[20:34:40] Finished 'make-build-dir' after 99 μs
[20:34:40] Starting 'makefile'...
[20:34:40] Starting 'bundle'...
[20:34:40] Starting 'ignorefile'...
[20:34:40] Finished 'makefile' after 38 ms
[20:34:40] Starting 'get-jerryscript'...
[20:34:40] Finished 'get-jerryscript' after 69 μs
[20:34:40] Starting 'getlibs'...
[20:34:40] Finished 'ignorefile' after 28 ms
[20:34:40] Finished 'getlibs' after 9.28 ms
$ make getlibs
make: Nothing to be done for 'getlibs'.
[20:34:40] Finished 'bundle' after 81 ms
[20:34:40] Starting 'cppify'...
[20:34:40] Finished 'cppify' after 17 ms
[20:34:40] Starting 'build'...
[20:34:41] Found native packages: mbed-js-repl
$ make BOARD=realtek_rtl8195am EXTRAS=/home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/node_modules/mbed-js-repl/.
[20:34:41] build/make
[20:34:41] Finished 'build' after 1.25 s
[20:34:41] Starting 'default'...
[20:34:41] Finished 'default' after 22 μs
cd jerryscript/targets/mbedos5 && pip install -r tools/requirements.txt && rm -f source/js_encoded.cpp && rm -f source/pins.cpp && rm -f source/main.cpp && make BOARD=realtek_rtl8195am EXTRA_SRC="/home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/node_modules/mbed-js-repl/.:../../../source" EXTERN_BUILD_DIR=../../../out/realtek_rtl8195am NO_JS=1
Requirement already satisfied: pycparser<=2.17 in /usr/local/lib/python2.7/dist-packages (from -r tools/requirements.txt (line 1))
Requirement already satisfied: simpleeval in /usr/local/lib/python2.7/dist-packages (from -r tools/requirements.txt (line 2))
Requirement already satisfied: pycparserext in /usr/local/lib/python2.7/dist-packages (from -r tools/requirements.txt (line 3))
Requirement already satisfied: ply>=3.4 in /usr/local/lib/python2.7/dist-packages (from pycparserext->-r tools/requirements.txt (line 3))
make[1]: Entering directory '/home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/build/jerryscript/targets/mbedos5'
python tools/generate_pins.py realtek_rtl8195am
Traceback (most recent call last):
File "tools/generate_pins.py", line 247, in
main()
File "tools/generate_pins.py", line 237, in main
pins = enumerate_pins(pins_file, ['./tools'] + list(includes), defines)
File "tools/generate_pins.py", line 154, in enumerate_pins
parser=GnuCParser())
File "/usr/local/lib/python2.7/dist-packages/pycparser/init.py", line 86, in parse_file
text = preprocess_file(filename, cpp_path, cpp_args)
File "/usr/local/lib/python2.7/dist-packages/pycparser/init.py", line 49, in preprocess_file
('Original error: %s' % e))
RuntimeError: Unable to invoke 'cpp'. Make sure its path was passed correctly
Original error: [Errno 2] No such file or directory
Makefile:72: recipe for target 'source/pins.cpp' failed
make[1]: Leaving directory '/home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/build/jerryscript/targets/mbedos5'
make[1]: *** [source/pins.cpp] Error 1
Makefile:14: recipe for target 'all' failed
make: *** [all] Error 2
events.js:182
throw er; // Unhandled 'error' event
^

Error: Command make BOARD=realtek_rtl8195am EXTRAS=/home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/node_modules/mbed-js-repl/. exited with code 2
at ChildProcess.handleSubShellExit (/home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/node_modules/gulp-run/command.js:166:13)
at Object.onceWrapper (events.js:318:30)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
nareshkrish@cerebrum:~/Downloads/mbedjs/mbed-js-repl-example$=../../../out/realtek_rtl8195am NO_JS=1
The directory '/home/nareshkrish/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/nareshkrish/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: pycparser<=2.17 in /usr/local/lib/python2.7/dist-packages (from -r tools/requirements.txt (line 1))
Requirement already satisfied: simpleeval in /usr/local/lib/python2.7/dist-packages (from -r tools/requirements.txt (line 2))
Requirement already satisfied: pycparserext in /usr/local/lib/python2.7/dist-packages (from -r tools/requirements.txt (line 3))
Requirement already satisfied: ply>=3.4 in /usr/local/lib/python2.7/dist-packages (from pycparserext->-r tools/requirements.txt (line 3))
make[1]: Entering directory '/home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/build/jerryscript/targets/mbedos5'
python tools/generate_pins.py realtek_rtl8195am
Traceback (most recent call last):
File "tools/generate_pins.py", line 247, in
main()
File "tools/generate_pins.py", line 237, in main
pins = enumerate_pins(pins_file, ['./tools'] + list(includes), defines)
File "tools/generate_pins.py", line 154, in enumerate_pins
parser=GnuCParser())
File "/usr/local/lib/python2.7/dist-packages/pycparser/init.py", line 86, in parse_file
text = preprocess_file(filename, cpp_path, cpp_args)
File "/usr/local/lib/python2.7/dist-packages/pycparser/init.py", line 49, in preprocess_file
('Original error: %s' % e))
RuntimeError: Unable to invoke 'cpp'. Make sure its path was passed correctly
Original error: [Errno 2] No such file or directory
Makefile:72: recipe for target 'source/pins.cpp' failed
make[1]: Leaving directory '/home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/build/jerryscript/targets/mbedos5'
make[1]: *** [source/pins.cpp] Error 1
Makefile:14: recipe for target 'all' failed
make: *** [all] Error 2
events.js:182
throw er; // Unhandled 'error' event
^

Error: Command make BOARD=realtek_rtl8195am EXTRAS=/home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/node_modules/mbed-js-repl/. exited with code 2
at ChildProcess.handleSubShellExit (/home/nareshkrish/Downloads/mbedjs/mbed-js-repl-example/node_modules/gulp-run/command.js:166:13)
at Object.onceWrapper (events.js:318:30)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)

I still have a doubt with the cpp module being shown as not found. I am not sure if the build process is expecting some kind of environment variable to be set when trying to execute cpp. However i have cpp in my environment and am able to execute it without issues

nareshkrish@cerebrum:~/Downloads/mbedjs/mbed-js-repl-example$ cpp --help
Usage: cpp [options] file...
Options:
-pass-exit-codes Exit with highest error code from a phase.
--help Display this information.
--target-help Display target specific command line options.
--help={common|optimizers|params|target|warnings|[^]{joined|separate|undocumented}}[,...].
Display specific types of command line options.
(Use '-v --help' to display command line options of sub-processes).
--version Display compiler version information.
-dumpspecs Display all of the built in spec strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment