Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 7eab5c4

Browse files
zolkisgrgustaf
authored andcommitted
[ashell] Add support for IDE protocol using webusb
Allows ashell to communicate over WebUSB. Signed-off-by: Zoltan Kis <[email protected]>
1 parent d5d5540 commit 7eab5c4

18 files changed

+1814
-63
lines changed

Makefile

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ OUT := $(abspath $(O))
2929
$(info Using outdir: $(OUT))
3030

3131
ifneq (,$(DEV))
32-
$(error DEV= is no longer supported, please use make ide or make ashell)
32+
$(error DEV= is no longer supported, please use make ide or make ashell or make ide_term or make ide_serial)
3333
endif
3434

3535
ifndef ZJS_BASE
@@ -85,12 +85,18 @@ ifeq ($(filter $(MAKECMDGOALS),linux), linux)
8585
$(error 'linux' make target is deprecated, use "make BOARD=linux")
8686
endif
8787

88-
ifneq (,$(filter $(MAKECMDGOALS),ide ashell))
88+
ifneq (,$(filter $(MAKECMDGOALS),ide ashell ide_term ide_serial))
8989
ifneq (,$(JS))
90-
$(error ide and ashell do not allow for setting JS)
90+
$(error ide ide_term ide_serial and ashell do not allow for setting JS)
9191
endif
9292
endif
9393

94+
ifeq ($(filter $(MAKECMDGOALS),ide_term), ide_term)
95+
ASHELL_TYPE=ide_term
96+
endif
97+
ifeq ($(filter $(MAKECMDGOALS),ide_serial), ide_serial)
98+
ASHELL_TYPE=ide_serial
99+
endif
94100
ifeq ($(filter $(MAKECMDGOALS),ide), ide)
95101
ASHELL_TYPE=ide
96102
endif
@@ -111,9 +117,9 @@ JERRY_OUTPUT = $(OUT)/$(BOARD)/jerry/build
111117
# Generate and run snapshot as byte code instead of running JS directly
112118
ifneq (,$(filter $(MAKECMDGOALS),ide ashell linux dynamic))
113119
SNAPSHOT=off
114-
# if the user passes in SNAPSHOT=on for ide, ashell, or linux give an error
120+
# if the user passes in SNAPSHOT=on for ide, ide_term, ide_serial, ashell, or linux give an error
115121
ifeq ($(SNAPSHOT), on)
116-
$(error ide, ashell, and linux do not support SNAPSHOT=$(SNAPSHOT))
122+
$(error ide, ide_term, ide_serial, ashell, and linux do not support SNAPSHOT=$(SNAPSHOT))
117123
endif
118124
else
119125
# snapshot is enabled by default
@@ -131,7 +137,7 @@ FORCED := $(FORCE),zjs_common.json
131137
endif
132138

133139
# Settings for ashell builds
134-
ifneq (,$(filter $(MAKECMDGOALS),ide ashell))
140+
ifneq (,$(filter $(MAKECMDGOALS),ide ide_term ide_serial ashell))
135141
ASHELL=zjs_ashell_$(ASHELL_TYPE).json
136142
FORCED := $(ASHELL),$(FORCED)
137143
ASHELL_ARC=zjs_ashell_arc.json
@@ -221,6 +227,12 @@ endif
221227
.PHONY: ide
222228
ide: zephyr
223229

230+
.PHONY: ide_term
231+
ide_term: zephyr
232+
233+
.PHONY: ide_serial
234+
ide_serial: zephyr
235+
224236
.PHONY: ashell
225237
ashell: zephyr
226238

@@ -331,10 +343,10 @@ ${JERRY_BASE}/CMakeLists.txt:
331343
-.PHONY: setup
332344
setup: ${JERRY_BASE}/CMakeLists.txt
333345
ifeq ($(ASHELL), ashell)
334-
ifeq ($(filter ide,$(MAKECMDGOALS)),ide)
335-
@echo CONFIG_USB_CDC_ACM=n >> prj.conf
336-
else
346+
ifeq ($(filter ide,$(MAKECMDGOALS)),cli)
337347
@echo CONFIG_USB_CDC_ACM=y >> prj.conf
348+
else
349+
@echo CONFIG_USB_CDC_ACM=n >> prj.conf
338350
endif
339351
endif
340352
ifeq ($(BOARD), arduino_101)
@@ -483,7 +495,9 @@ help:
483495
@echo "Build targets:"
484496
@echo " all: Build for either Zephyr or Linux depending on BOARD"
485497
@echo " zephyr: Build Zephyr for the given BOARD (A101 is default)"
486-
@echo " ide Build Zephyr in development mode for the IDE"
498+
@echo " ide Build Zephyr in development mode for the IDE using the IDE protocol"
499+
@echo " ide_serial Build Zephyr in development mode for the IDE using UART transport"
500+
@echo " ide_term Build Zephyr in development mode for the IDE using command line terminal"
487501
@echo " ashell Build Zephyr in development mode for command line"
488502
@echo " debug: Run Zephyr debug target"
489503
@echo " flash: Run Zephyr flash target"

src/ashell/ashell.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2017, Intel Corporation.
2+
3+
/**
4+
* @file
5+
* @brief Ashell main.
6+
*/
7+
8+
#include "ashell.h"
9+
10+
void zjs_ashell_init()
11+
{
12+
#ifdef ASHELL_IDE_UART
13+
extern void uart_init();
14+
uart_init();
15+
#else
16+
extern void ide_init();
17+
ide_init();
18+
#endif
19+
}
20+
21+
void zjs_ashell_process()
22+
{
23+
#ifdef ASHELL_IDE_UART
24+
extern void uart_process();
25+
uart_process();
26+
#else
27+
extern void ide_process();
28+
ide_process();
29+
#endif
30+
}

src/ashell/ashell.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
#ifndef __ashell_h__
44
#define __ashell_h__
55

6+
// Switches between console and IDE protocol mode.
7+
#define ASHELL_IDE_PROTOCOL 1
8+
9+
#define ASHELL_IDE_DBG 0
10+
611
// called from Zephyr.js main.c
712
void zjs_ashell_init();
813
void zjs_ashell_process();

0 commit comments

Comments
 (0)