|
1 | 1 | ### About
|
2 | 2 |
|
3 |
| -This folder contains files to run JerryScript on RIOT-OS with STM32F4-Discovery board. |
| 3 | +This folder contains files to run JerryScript on |
| 4 | +[STM32F4-Discovery board](https://www.st.com/en/evaluation-tools/stm32f4discovery.html) with |
| 5 | +[RIOT](https://www.riot-os.org/). |
| 6 | +The document had been validated on Ubuntu 20.04 operating system. |
4 | 7 |
|
5 | 8 | ### How to build
|
6 | 9 |
|
7 |
| -#### 1. Preface |
| 10 | +#### 1. Setup the build environment for STM32F4-Discovery board |
8 | 11 |
|
9 |
| -1, Directory structure |
| 12 | +Clone the necessary projects into a `jerry-riot` directory. |
| 13 | +The latest tested working version of RIOT is `2021.10`. |
10 | 14 |
|
11 |
| -Assume `harmony` as the path to the projects to build. |
12 |
| -The folder tree related would look like this. |
| 15 | +```sh |
| 16 | +# Create a base folder for all the projects. |
| 17 | +mkdir jerry-riot && cd jerry-riot |
13 | 18 |
|
| 19 | +git clone https://github.com/jerryscript-project/jerryscript.git |
| 20 | +git clone https://github.com/RIOT-OS/RIOT.git -b 2021.10 |
14 | 21 | ```
|
15 |
| -harmony |
16 |
| - + jerryscript |
17 |
| - | + targets |
18 |
| - | + riot-stm32f4 |
19 |
| - + RIOT |
20 |
| -``` |
21 |
| - |
22 |
| -2, Target board |
23 |
| - |
24 |
| -Assume [STM32F4-Discovery with BB](http://www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1199/PF255417) |
25 |
| -as the target board. |
26 |
| - |
27 |
| -#### 2. Prepare RIOT-OS |
28 | 22 |
|
29 |
| -Follow [this](https://www.riot-os.org/#download) page to get the RIOT-OS source. |
| 23 | +#### 2. Install dependencies of the projects |
30 | 24 |
|
31 |
| -Follow the [Inroduction](https://github.com/RIOT-OS/RIOT/wiki/Introduction) wiki site and also check that you can flash the stm32f4-board. |
| 25 | +``` |
| 26 | +# Assuming you are in jerry-riot folder. |
| 27 | +jerryscript/tools/apt-get-install-deps.sh |
32 | 28 |
|
| 29 | +sudo apt install gcc-arm-none-eabi openocd minicom |
| 30 | +``` |
33 | 31 |
|
34 |
| -#### 3. Build JerryScript for RIOT-OS |
| 32 | +The following directory structure has been created: |
35 | 33 |
|
36 | 34 | ```
|
37 |
| -# assume you are in harmony folder |
38 |
| -cd jerryscript |
39 |
| -make -f ./targets/riot-stm32f4/Makefile.riot |
| 35 | +jerry-riot |
| 36 | + + jerryscript |
| 37 | + | + targets |
| 38 | + | + riot-stm32f4 |
| 39 | + + RIOT |
40 | 40 | ```
|
41 | 41 |
|
42 |
| -This will generate the following libraries: |
43 |
| -``` |
44 |
| -/build/bin/release.riotstm32f4/librelease.jerry-core.a |
45 |
| -/build/bin/release.riotstm32f4/librelease.jerry-math.lib.a |
46 |
| -``` |
| 42 | +#### 3. Build RIOT (with JerryScript) |
47 | 43 |
|
48 |
| -This will copy one library files to `targets/riot-stm32f4/bin` folder: |
49 | 44 | ```
|
50 |
| -libjerrycore.a |
| 45 | +# Assuming you are in jerry-riot folder. |
| 46 | +make BOARD=stm32f4discovery -f jerryscript/targets/riot-stm32f4/Makefile |
51 | 47 | ```
|
52 | 48 |
|
53 |
| -This will create a hex file in the `targets/riot-stm32f4/bin` folder: |
54 |
| -``` |
55 |
| -riot_jerry.elf |
56 |
| -``` |
| 49 | +The created binary is a `riot_jerryscript.elf` named file located in `jerryscript/build/riot-stm32f4/bin/` folder. |
57 | 50 |
|
58 |
| -#### 4. Flashing |
| 51 | +#### 4. Flash the device |
| 52 | + |
| 53 | +Connect Mini-USB for charging and flashing the device. |
59 | 54 |
|
60 | 55 | ```
|
61 |
| -make -f ./targets/riot-stm32f4/Makefile.riot flash |
| 56 | +# Assuming you are in jerry-riot folder. |
| 57 | +make BOARD=stm32f4discovery -f jerryscript/targets/riot-stm32f4/Makefile flash |
62 | 58 | ```
|
63 | 59 |
|
64 |
| -For how to flash the image with other alternative way can be found here: |
65 |
| -[Alternative way to flash](https://github.com/RIOT-OS/RIOT/wiki/Board:-STM32F4discovery#alternative-way-to-flash) |
| 60 | +Note: `ST-LINK` also can be used that is described at [this page](https://github.com/RIOT-OS/RIOT/wiki/ST-LINK-tool). |
| 61 | + |
| 62 | +#### 5. Connect to the device |
66 | 63 |
|
67 |
| -#### 5. Cleaning |
| 64 | +Use `USB To TTL Serial Converter` for serial communication. STM32F4-Discovery pins are mapped by RIOT as follows: |
68 | 65 |
|
69 |
| -To clean the build result: |
70 | 66 | ```
|
71 |
| -make -f ./targets/riot-stm32f4/Makefile.riot clean |
| 67 | + STM32f4-Discovery PA2 pin is configured for TX. |
| 68 | + STM32f4-Discovery PA3 pin is configured for RX. |
72 | 69 | ```
|
73 | 70 |
|
| 71 | +* Connect `STM32f4-Discovery` **PA2** pin to **RX** pin of `USB To TTL Serial Converter` |
| 72 | +* Connect `STM32f4-Discovery` **PA3** pin to **TX** pin of `USB To TTL Serial Converter` |
| 73 | +* Connect `STM32f4-Discovery` **GND** pin to **GND** pin of `USB To TTL Serial Converter` |
| 74 | + |
| 75 | +The device should be visible as `/dev/ttyUSB0`. Use `minicom` communication program with `115200`. |
74 | 76 |
|
75 |
| -### 5. Running JerryScript Hello World! example |
| 77 | +* In `minicom`, set `Add Carriage Ret` to `off` in by `CTRL-A -> Z -> U` key combinations. |
| 78 | +* In `minicom`, set `Hardware Flow Control` to `no` by `CTRL-A -> Z -> O -> Serial port setup -> F` key combinations. |
76 | 79 |
|
77 |
| -You may have to press `RESET` on the board after the flash. |
| 80 | +```sh |
| 81 | +sudo minicom --device=/dev/ttyUSB0 --baud=115200 |
| 82 | +``` |
| 83 | + |
| 84 | +RIOT prompt looks like as follows: |
78 | 85 |
|
79 |
| -You can use `minicom` for terminal program, and if the prompt shows like this: |
80 | 86 | ```
|
81 |
| -main(): This is RIOT! (Version: ****) |
82 |
| - You are running RIOT on a(n) stm32f4discovery board. |
83 |
| - This board features a(n) stm32f4 MCU. |
| 87 | +main(): This is RIOT! (Version: 2021.10) |
| 88 | +You are running RIOT on a(n) stm32f4discovery board. |
| 89 | +This board features a(n) stm32 MCU. |
| 90 | +> |
84 | 91 | ```
|
85 |
| -please set `Add Carriage Ret` option by `CTRL-A` > `Z` > `U` at the console, if you're using `minicom`. |
86 | 92 |
|
| 93 | +You may have to press `RESET` on the board and press `Enter` key on the console several times to make RIOT prompt visible. |
| 94 | + |
| 95 | +#### 6. Run JerrySript |
| 96 | + |
| 97 | +Type `help` to list shell commands: |
87 | 98 |
|
88 |
| -Help will provide a list of commands: |
89 | 99 | ```
|
90 | 100 | > help
|
| 101 | +Command Description |
| 102 | +--------------------------------------- |
| 103 | +test Jerryscript Hello World test |
| 104 | +reboot Reboot the node |
| 105 | +version Prints current RIOT_VERSION |
| 106 | +pm interact with layered PM subsystem |
91 | 107 | ```
|
92 | 108 |
|
93 |
| -The `test` command will run the test example, which contains the following script code: |
| 109 | +Type `test` to execute JerryScript: |
| 110 | + |
94 | 111 | ```
|
95 |
| -print ('Hello, World!'); |
| 112 | +> test |
| 113 | +This test run the following script code: [print ('Hello, World!');] |
| 114 | +
|
| 115 | +Hello, World! |
96 | 116 | ```
|
0 commit comments