Skip to content

Commit bc843db

Browse files
committed
bricks/ev3: Add instructions to build for bare metal.
1 parent 8378675 commit bc843db

1 file changed

Lines changed: 145 additions & 0 deletions

File tree

bricks/ev3/README.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Pybricks on EV3 without Linux (Work in progress)
2+
3+
This Pybricks port is intended to run on EV3 as a "bare metal" port, _without_
4+
an underlying operating system such as `ev3dev` or `TOPPERS/EV3RT`.
5+
6+
The goal is to make it very similar to the other "bare metal" ports such as the
7+
ones we have for the SPIKE Prime Hub, Technic Hub, City Hub, and the BOOST Move
8+
Hub. By making it work the same, it will become part of the same family of
9+
hubs. It will be able to use the same online code editor, so that EV3 can be
10+
used well into the future, even when the official apps are all discontinued.
11+
12+
This should resolve many open requests to continue support for EV3 in Pybricks
13+
3.X. It should also resolve technical issues related to device detection and
14+
[loop time issues](https://github.com/pybricks/support/issues/1035).
15+
16+
Since it won't have Linux, it won't have certain features like Wi-Fi or support
17+
for advanced accessories. For those uses cases, Pybricks 2.0 on ev3dev will
18+
remain available.
19+
20+
## Requirements
21+
22+
Since USB communication is not yet implemented, you need the following hardware
23+
to use this:
24+
25+
- A USB serial adapter to connect to sensor port 1 on the EV3 brick. You could
26+
use [this one](http://www.mindsensors.com/ev3-and-nxt/40-console-adapter-for-ev3).
27+
Or make your own using a standard USB to serial adapter and connecting it to the
28+
data wires of an EV3 cable.
29+
- A microSD card (32 GB or less) to store the firmware image.
30+
31+
## Prerequisites
32+
33+
Before attempting to build this, please follow the instructions to build the
34+
firmware for one of the other targets, such as the SPIKE Prime Hub, as
35+
explained [here](../../CONTRIBUTING.md).
36+
37+
Then, install the following additional tools:
38+
39+
```
40+
sudo apt install u-boot-tools
41+
```
42+
43+
Prepare a microSD card (32 GB or less) and format it as a single FAT32
44+
partition. It is not necessary needed to set any boot flags.
45+
46+
In the following examples, we assume that the formatted volume is called
47+
`ev3`.
48+
49+
## Building the firmware
50+
51+
52+
```bash
53+
# Navigate to the repository.
54+
cd pybricks-micropython
55+
56+
# Build the uImage.
57+
make -C bricks/ev3 clean
58+
make -C bricks/ev3 uImage -j
59+
60+
# Copy the result and resources to the root of microSD card, e.g:
61+
cp bricks/ev3/build/uImage /media/user_name/ev3/uImage
62+
63+
```
64+
65+
Note: This should not be confused with other existing or outdated EV3 builds in the `bricks` folder such as the `ev3dev` or `ev3rt` builds. They can serve as inspiration, but are completely separate from this build. From a code point of view, this new `bricks/ev3` build will be a lot more like `bricks/primehub`.
66+
67+
## Operating the brick
68+
69+
- Connect your serial adapter to sensor port 1 on the EV3 brick.
70+
- Start a terminal emulator such as `screen` or `picocom`.
71+
- Insert the microSD card into the EV3 brick.
72+
- Press the center button to boot.
73+
74+
You should see something like the following output:
75+
76+
```
77+
EV3 initialization passed!
78+
Booting EV3 EEprom Boot Loader
79+
80+
EEprom Version: 0.60
81+
EV3 Flashtype: N25Q128A13B
82+
83+
EV3 Booting system
84+
85+
Jumping to entry point at: 0xC1080000
86+
87+
88+
U-Boot 2009.11 (Oct 26 2012 - 10:30:38)
89+
90+
I2C: ready
91+
DRAM: 64 MB
92+
MMC: davinci: 0
93+
In: serial
94+
Out: serial
95+
Err: serial
96+
ARM Clock : 300000000 Hz
97+
DDR Clock : 132000000 Hz
98+
Invalid MAC address read.
99+
Hit 'l' to stop autoboot: 0
100+
reading boot.scr
101+
102+
** Unable to read "boot.scr" from mmc 0:1 **
103+
reading uImage
104+
105+
209016 bytes read
106+
## Booting kernel from Legacy Image at c0007fc0 ...
107+
Image Name:
108+
Image Type: ARM Linux Kernel Image (uncompressed)
109+
Data Size: 208952 Bytes = 204.1 kB
110+
Load Address: c0008000
111+
Entry Point: c0008000
112+
Loading Kernel Image ... OK
113+
OK
114+
115+
Starting kernel ...
116+
117+
Hello!
118+
World!
119+
Traceback (most recent call last):
120+
121+
File "%q", line %dhello.py", line %d8D��D�, in %q
122+
<module>
123+
KeyboardInterrupt:
124+
Pybricks MicroPython v1.20.0-23-g6c633a8dd on 2024-06-08; MINDSTORMS EV3 Brick with TI Sitara AM1808
125+
Type "help()" for more information.
126+
>>>
127+
```
128+
129+
You can remove the microSD card after booting. After updating the uImage, you
130+
can try out your new build by rebooting: Press and hold the center and back
131+
buttons for 4 seconds.
132+
133+
For now, there is just the REPL and several builtin MicroPython modules.
134+
Sensors and motors are not yet enabled.
135+
136+
## Development status
137+
138+
This is a highly experimental development. Pretty much nothing is enabled yet.
139+
The intention is to prepare a minimal build where we can add drivers one by
140+
one, with help from experts in the community.
141+
142+
Inspiration for future hardware implementation:
143+
- [ev3dev](https://www.ev3dev.org/docs/kernel-hackers-notebook/ev3dev-linux-kernel/): Well documented resources for EV3 on debian Linux.
144+
- [EV3RT](https://github.com/pybricks/ev3rt-lib): RTOS (not Linux). Closer to the metal, but drivers mixed in with RTOS.
145+
- [am18xlib](https://github.com/pybricks/am18x-lib-ev3): Good inspiration for minimal peripheral drivers, including PRU and so on.

0 commit comments

Comments
 (0)