Skip to content

Commit 7657238

Browse files
authored
docs: refactor README content (#171)
* docs: refactor README to avoid duplication with information on the web site, and to reorder to make it easier for new users.
1 parent 3cba36f commit 7657238

File tree

2 files changed

+77
-135
lines changed

2 files changed

+77
-135
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ Please open a Github issue with your problem, and we will be happy to assist.
1616

1717
We probably have not implemented it yet. Please take a look at our [Roadmap](https://github.com/tinygo-org/tinygo/wiki/Roadmap). Your pull request adding the functionality to TinyGo would be greatly appreciated.
1818

19+
A long tail of small (and large) language features haven't been implemented yet. In almost all cases, the compiler will show a `todo:` error from `compiler/compiler.go` when you try to use it. You can try implementing it, or open a bug report with a small code sample that fails to compile.
20+
1921
### Some specific hardware you want to use does not appear to be in TinyGo
2022

2123
As above, we probably have not implemented it yet. Your contribution adding the hardware support to TinyGo would be greatly appreciated.
2224

25+
Lots of targets/boards are still unsupported. Adding an architecture often requires a few compiler changes, but if the architecture is supported you can try implementing support for a new chip or board in `src/runtime`. For details, see [this wiki entry on adding archs/chips/boards](https://github.com/tinygo-org/tinygo/wiki/Adding-a-new-board).
26+
27+
Microcontrollers have lots of peripherals (I2C, SPI, ADC, etc.) and many don't have an implementation yet in the `machine` package. Adding support for new peripherals is very useful.
28+
2329
## How to use our Github repository
2430

2531
The `master` branch of this repo will always have the latest released version of TinyGo. All of the active development work for the next release will take place in the `dev` branch. TinyGo will use semantic versioning and will create a tag/release for each release.

README.md

Lines changed: 71 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,70 @@
1-
# TinyGo - Go compiler for microcontrollers
1+
# TinyGo - Go compiler for small places
22

3-
[![Build Status](https://travis-ci.com/aykevl/tinygo.svg?branch=master)](https://travis-ci.com/tinygo-org/tinygo)
3+
[![Build Status](https://travis-ci.com/tinygo-org/tinygo.svg?branch=dev)](https://travis-ci.com/tinygo-org/tinygo)
44

5-
> We never expected Go to be an embedded language and so it's got serious
6-
> problems [...].
5+
TinyGo is a Go compiler intended for use in small places such as microcontrollers, WebAssembly (WASM), and command-line tools.
76

8-
-- Rob Pike, [GopherCon 2014 Opening Keynote](https://www.youtube.com/watch?v=VoS7DsT1rdM&feature=youtu.be&t=2799)
9-
10-
TinyGo is a project to bring Go to microcontrollers and small systems with a
11-
single processor core. It is similar to [emgo](https://github.com/ziutek/emgo)
12-
but a major difference is that I want to keep the Go memory model (which implies
13-
garbage collection of some sort). Another difference is that TinyGo uses LLVM
14-
internally instead of emitting C, which hopefully leads to smaller and more
15-
efficient code and certainly leads to more flexibility.
7+
It reuses libraries used by the [Go language tools](https://golang.org/pkg/go/) alongside [LLVM](http://llvm.org) to provide an alternative way to compile programs written in the Go programming language.
168

17-
My original reasoning was: if [Python](https://micropython.org/) can run on
18-
microcontrollers, then certainly [Go](https://golang.org/) should be able to and
19-
run on even lower level micros.
20-
21-
Example program (blinky):
9+
Here is an example program that blinks the built-in LED when run directly on any supported board with onboard LED:
2210

2311
```go
12+
package main
13+
2414
import (
25-
"machine"
26-
"time"
15+
"machine"
16+
"time"
2717
)
2818

2919
func main() {
30-
led := machine.GPIO{machine.LED}
31-
led.Configure(machine.GPIOConfig{Mode: machine.GPIO_OUTPUT})
32-
for {
33-
led.Low()
34-
time.Sleep(time.Millisecond * 1000)
35-
36-
led.High()
37-
time.Sleep(time.Millisecond * 1000)
38-
}
20+
led := machine.GPIO{machine.LED}
21+
led.Configure(machine.GPIOConfig{Mode: machine.GPIO_OUTPUT})
22+
for {
23+
led.Low()
24+
time.Sleep(time.Millisecond * 1000)
25+
26+
led.High()
27+
time.Sleep(time.Millisecond * 1000)
28+
}
3929
}
4030
```
4131

42-
Currently supported features:
43-
44-
* control flow
45-
* many (but not all) basic types: most ints, floats, strings, structs
46-
* function calling
47-
* interfaces for basic types (with type switches and asserts)
48-
* goroutines (very initial support)
49-
* function pointers (non-blocking)
50-
* interface methods
51-
* standard library (but most packages won't work due to missing language
52-
features)
53-
* slices (partially)
54-
* maps (very rough, unfinished)
55-
* defer
56-
* closures
57-
* bound methods
58-
* complex numbers (except for arithmetic)
59-
* channels (with some limitations)
60-
61-
Not yet supported:
62-
63-
* select
64-
* complex arithmetic
65-
* garbage collection
66-
* recover
67-
* introspection (if it ever gets implemented)
68-
* ...
69-
70-
## Installation
71-
72-
See the [getting started instructions](https://tinygo.org/getting-started/).
73-
74-
### Running with Docker
32+
The above program can be compiled and run without modification on an Arduino Uno, an Adafruit ItsyBitsy M0, or any of the supported boards that have a built-in LED, just by setting the correct TinyGo compiler target. For example, this compiles and flashes an Arduino Uno:
7533

76-
A docker container exists for easy access to the `tinygo` CLI:
77-
78-
```sh
79-
$ docker run --rm -v $(pwd):/src tinygo/tinygo tinygo build -o /src/wasm.wasm -target wasm examples/wasm
34+
```shell
35+
tinygo flash -target arduino examples/blinky1
8036
```
8137

82-
Note that you cannot run `tinygo flash` from inside the docker container,
83-
so it is less useful for microcontroller development.
84-
85-
## Supported targets
86-
87-
The following architectures/systems are currently supported:
88-
89-
* ARM (Cortex-M)
90-
* AVR (Arduino Uno)
91-
* Linux
92-
* WebAssembly
93-
94-
For more information, see [this list of targets and
95-
boards](https://tinygo.org/targets/). Pull requests for
96-
broader support are welcome!
38+
## Installation
9739

98-
## Analysis and optimizations
40+
See the [getting started instructions](https://tinygo.org/getting-started/) for information on how to install TinyGo, as well as how to run the TinyGo compiler using our Docker container.
9941

100-
The goal is to reduce code size (and increase performance) by performing all
101-
kinds of whole-program analysis passes. The official Go compiler doesn't do a
102-
whole lot of analysis (except for escape analysis) because it needs to be fast,
103-
but embedded programs are necessarily smaller so it becomes practical. And I
104-
think especially program size can be reduced by a large margin when actually
105-
trying to optimize for it.
42+
## Supported boards/targets
10643

107-
Implemented compiler passes:
44+
You can compile TinyGo programs for microcontrollers, WebAssembly and Linux.
10845

109-
* Analyse which functions are blocking. Blocking functions are functions that
110-
call sleep, chan send, etc. Its parents are also blocking.
111-
* Analyse whether the scheduler is needed. It is only needed when there are
112-
`go` statements for blocking functions.
113-
* Analyse whether a given type switch or type assert is possible with
114-
[type-based alias analysis](https://en.wikipedia.org/wiki/Alias_analysis#Type-based_alias_analysis).
115-
I would like to use flow-based alias analysis in the future, if feasible.
116-
* Do basic dead code elimination of functions. This pass makes later passes
117-
better and probably improves compile time as well.
46+
The following microcontroller boards are currently supported:
11847

119-
## Scope
48+
* [Adafruit ItsyBitsy M0](https://www.adafruit.com/product/3727)
49+
* [Arduino Uno](https://store.arduino.cc/arduino-uno-rev3)
50+
* [BBC:Microbit](https://microbit.org/)
51+
* [ST Micro STM32F103XX "Bluepill"](http://wiki.stm32duino.com/index.php?title=Blue_Pill)
52+
* [Digispark](http://digistump.com/products/1)
53+
* [Nordic Semiconductor PCA10031](https://www.nordicsemi.com/eng/Products/nRF51-Dongle)
54+
* [Nordic Semiconductor PCA10040](https://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF52-DK)
55+
* [Nordic Semiconductor PCA10056](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK)
56+
* [Makerdiary nRF52840-MDK](https://wiki.makerdiary.com/nrf52840-mdk/)
57+
* [Phytec reel board](https://www.phytec.eu/product-eu/internet-of-things/reelboard/)
12058

121-
Goals:
59+
For more information, see [this list of boards](https://tinygo.org/microcontrollers/). Pull requests for additional support are welcome!
12260

123-
* Have very small binary sizes. Don't pay for what you don't use.
124-
* Support for most common microcontroller boards.
125-
* Be usable on the web using WebAssembly.
126-
* Good CGo support, with no more overhead than a regular function call.
127-
* Support most standard library packages and compile most Go code without
128-
modification.
61+
## Currently supported features:
12962

130-
Non-goals:
131-
132-
* Using more than one core.
133-
* Be efficient while using zillions of goroutines. However, good goroutine
134-
support is certainly a goal.
135-
* Be as fast as `gc`. However, LLVM will probably be better at optimizing
136-
certain things so TinyGo might actually turn out to be faster for number
137-
crunching.
138-
* Be able to compile every Go program out there.
63+
For a description of currently supported Go language features, please see [https://tinygo.org/lang-support/](https://tinygo.org/lang-support/).
13964

14065
## Documentation
14166

142-
Documentation is currently maintained on a dedicated web site located at [https://tinygo.org/](https://tinygo.org/).
67+
Documentation is located on our web site at [https://tinygo.org/](https://tinygo.org/).
14368

14469
You can find the web site code at [https://github.com/tinygo-org/tinygo-site](https://github.com/tinygo-org/tinygo-site).
14570

@@ -154,26 +79,37 @@ should arrive fairly quickly (under 1 min): https://invite.slack.golangbridge.or
15479

15580
## Contributing
15681

157-
Patches are welcome!
158-
159-
If you want to contribute, here are some suggestions:
160-
161-
* A long tail of small (and large) language features haven't been implemented
162-
yet. In almost all cases, the compiler will show a `todo:` error from
163-
`compiler/compiler.go` when you try to use it. You can try implementing it,
164-
or open a bug report with a small code sample that fails to compile.
165-
* Lots of targets/boards are still unsupported. Adding an architecture often
166-
requires a few compiler changes, but if the architecture is supported you
167-
can try implementing support for a new chip or board in `src/runtime`. For
168-
details, see [this wiki entry on adding
169-
archs/chips/boards](https://github.com/tinygo-org/tinygo/wiki/Adding-a-new-board).
170-
* Microcontrollers have lots of peripherals and many don't have an
171-
implementation yet in the `machine` package. Adding support for new
172-
peripherals is very useful.
173-
* Just raising bugs for things you'd like to see implemented is also a form of
174-
contributing! It helps prioritization.
82+
Your contributions are welcome!
83+
84+
Please take a look at our [CONTRIBUTING.md](./CONTRIBUTING.md) document for details.
85+
86+
## Project Scope
87+
88+
Goals:
89+
90+
* Have very small binary sizes. Don't pay for what you don't use.
91+
* Support for most common microcontroller boards.
92+
* Be usable on the web using WebAssembly.
93+
* Good CGo support, with no more overhead than a regular function call.
94+
* Support most standard library packages and compile most Go code without modification.
95+
96+
Non-goals:
97+
98+
* Using more than one core.
99+
* Be efficient while using zillions of goroutines. However, good goroutine support is certainly a goal.
100+
* Be as fast as `gc`. However, LLVM will probably be better at optimizing certain things so TinyGo might actually turn out to be faster for number crunching.
101+
* Be able to compile every Go program out there.
102+
103+
## Why this project exists
104+
105+
> We never expected Go to be an embedded language and so its got serious problems...
106+
107+
-- Rob Pike, [GopherCon 2014 Opening Keynote](https://www.youtube.com/watch?v=VoS7DsT1rdM&feature=youtu.be&t=2799)
108+
109+
TinyGo is a project to bring Go to microcontrollers and small systems with a single processor core. It is similar to [emgo](https://github.com/ziutek/emgo) but a major difference is that we want to keep the Go memory model (which implies garbage collection of some sort). Another difference is that TinyGo uses LLVM internally instead of emitting C, which hopefully leads to smaller and more efficient code and certainly leads to more flexibility.
110+
111+
The original reasoning was: if [Python](https://micropython.org/) can run on microcontrollers, then certainly [Go](https://golang.org/) should be able to run on even lower level micros.
175112

176113
## License
177114

178-
This project is licensed under the BSD 3-clause license, just like the
179-
[Go project](https://golang.org/LICENSE) itself.
115+
This project is licensed under the BSD 3-clause license, just like the [Go project](https://golang.org/LICENSE) itself.

0 commit comments

Comments
 (0)