Граф коммитов

1287 коммитов

Автор SHA1 Сообщение Дата
Ayke van Laethem
4d5dafd360 main: fix race condition in tests
This caused most tests to run the zeroalloc.go test instead of what they
should have been tested, and in turn explains most of the performance
gains of parallel testing.

This commit fixes it by avoiding race conditions. Luckily, no tests
started failing since then due to this.
2020-01-14 16:40:13 +01:00
Ayke van Laethem
1a32a68674 compiler: add support for CGO_ENABLED environment variable 2020-01-14 07:13:12 +01:00
Ayke van Laethem
9a69c6bcca hifive1b: add support for gdb subcommand
This makes debugging on the HiFive1 rev B much easier:

    tinygo gdb -target=hifive1b examples/echo

Using JLinkGDBServer as I couldn't figure out how to do it with OpenOCD.
2020-01-12 17:02:53 +01:00
Ayke van Laethem
6841f9e245 compiler: add support for debugging through JLinkGDBServer
Some J-Link targets aren't supported in OpenOCD (or would need some
special configuration), so also give the option to use JLinkGDBServer
instead.
2020-01-12 17:02:53 +01:00
Ron Evans
ef4ede43d1 machine/pyportal: remove manual SPI pin mapping as now handled by default
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-01-11 21:31:33 +01:00
Ayke van Laethem
31d3ac725f machine/atsamd51: refactor SPI pin configuration to only look at pin numbers
This commit does the same thing as
https://github.com/tinygo-org/tinygo/pull/597 but for samd51 series
chips. Pin mode and pad numbers are automatically calculated from pin
numbers, returning an error if no valid pinout is possible.
2020-01-11 20:57:10 +01:00
Ron Evans
7ace991a2b machine/digispark: add clock speed and pin mappings 2020-01-11 12:58:37 +01:00
Ayke van Laethem
b258f3424b riscv: print exception PC and code
This can be useful for debugging critical bugs in code. I haven't added
human-readable exceptions (such as "illegal instruction" or "stack
overflow") yet, they can be added when they happen in practice (to avoid
increasing code size too much).
2020-01-11 12:27:58 +01:00
Ayke van Laethem
b9cdfd9e9a riscv: add bare-bones interrupt support
This commit adds support for timer interrupts, replacing the busy loop
that was used before. It is perhaps the most simple interrupt to
implement and should serve as the basis for further interrupt support in
RISC-V.
2020-01-10 08:04:13 +01:00
Ayke van Laethem
360923abbf compiler,riscv: implement CSR operations as intrinsics
CSR operations must be implemented in assembly. The easiest way to
implement them is with some custom intrinsics in the compiler.
2020-01-10 08:04:13 +01:00
Ayke van Laethem
ed9b2dbc03 runtime/hifive1: use CLINT peripheral for timekeeping
The CLINT is implemented both on the fe310-g002 chip and in the sifive_e
QEMU machine type. Therefore, use that peripheral for consistency.

The only difference is the clock speed, which runs at 10MHz in QEMU for
some reason instead of 32.768kHz as on the physical HiFive1 boards.
2020-01-10 08:04:13 +01:00
Ayke van Laethem
3e521f710a compiler: add support for debugging globals
This makes most globals visible from GDB, using `info variables`.
2020-01-07 20:20:19 +01:00
BCG
ecff6f8e0c Adafruit PyPortal Support (#800)
* machine/PyPortal: implementation, also includes refinements for other members of samd51x familty.
2020-01-06 11:53:43 +01:00
Jaden Weiss
7363bdc298 Add Jaden Weiss to CONTRIBUTORS 2020-01-06 09:24:20 +01:00
Michael Matloob
1cb9b948bc targets: add target circuitplay-bluefruit
Add a target for the Adafruit Circuit Playground Bluefruit, which is
based on the nRF52840. Adds the necessary code for the machine
package and the json and linker script files in the targets directory.
The machine package code is based on board_circuitplay_express.go,
with modifications made by consulting the wiring diagram on the
adafruit website here:
https://learn.adafruit.com/adafruit-circuit-playground-bluefruit/downloads

Also adds support to the uf2 conversion packacge to set the familyID
field. The Circuit Playground Bluefruit firmware rejects uf2 files
without the family id set to 0xADA52840 (and without the flag specifying
that the family id is present).
2020-01-06 09:23:39 +01:00
Ayke van Laethem
25cff20117 interp: error location for "unknown GEP" error
This commit removes a panic and replaces it with a proper source
location. The message still isn't very helpful, but at least it points
to a location in the source code.

I'm not very happy with all the `err.Error()` calls, but that's the way
to fit this in a `scanner.Error`. Eventually we should make a
replacement for `scanner.Error` that does proper wrapping of the
original error message.
2020-01-05 13:45:23 +01:00
Ayke van Laethem
ec467da83c ci: produce zip as artifact in Azure Pipelines
Zip files are far more often used on Windows systems, so we provide zip
files in releases. Unfortunately, previously the provided artifact in CI
was really just a compressed .tar.gz file, which defeats the purpose.

This commit zips the release tarball itself so it can be downloaded as
an artifact.
2020-01-05 12:43:21 +01:00
BCG
5f77447e1a Adding code use 12-bit resolution for ADC and to clear previous ADC INPUTCTRL before subsequent read 2020-01-05 12:34:47 +01:00
Ayke van Laethem
27fafb7ab5 runtime: fix atsamd51 volatile usage
It was still using the (long removed) //go:volatile pragma for volatile
variables, thus it was only accidentally working.
2020-01-05 12:08:33 +01:00
Ayke van Laethem
d1cc3c109d compiler: add globaldce pass to start of optimization pipeline
This reduces code size in a few cases when tested against the drivers
smoketests (although there was one minor increase) without significantly
increasing compile time. In fact, in my testing compile time appears to
be going down a little bit (around 1%, within the noise).
2020-01-05 11:37:26 +01:00
Ayke van Laethem
0933577e60 compiler: improve "function redeclared" error
This error can normally only happen with //go:linkname and such, but
it's nice to get an informative error message in that case.
2020-01-04 10:24:14 +01:00
Ayke van Laethem
69c1d802e1 loader: improve error messages for failed imports
Add location information (whenever possible) to failed imports. This
helps in debugging where an incorrect import came from.

For example, show the following error message:

    /home/ayke/src/github.com/tinygo-org/tinygo/src/machine/machine.go:5:8: cannot find package "foobar" in any of:
        /usr/local/go/src/foobar (from $GOROOT)
        /home/ayke/src/foobar (from $GOPATH)

Instead of the following:

    error: cannot find package "foobar" in any of:
        /usr/local/go/src/foobar (from $GOROOT)
        /home/ayke/src/foobar (from $GOPATH)
2020-01-04 00:01:07 +01:00
Ayke van Laethem
b424056721 cgo: fix a bug in number tokenization 2020-01-03 23:44:58 +01:00
Ayke van Laethem
d735df6e16 cgo: add support for symbols 2020-01-03 23:44:58 +01:00
Ayke van Laethem
d37bbadb54 machine/arduino-nano33: fix UART1 and UART2
UART2 was configured with the wrong SERCOM for the used pins (PB22 and
PB23). However, after changing the SERCOM from 3 to 5 that led to a
conflict with UART1 (used for the on-board WiFi). But the used pins are
also usable from SERCOM 3, so in the end I switched SERCOM5 and SERCOM3
around.

With this change, I was able to get examples/echo working.
2020-01-03 23:25:37 +01:00
Ayke van Laethem
ab7dc45288 wasm: implement memcpy and memset
This was reported in issue #805.
2019-12-30 20:51:46 +01:00
Jaden Weiss
eee1b995f6 revise defer to use heap allocations when running a variable number of times 2019-12-30 18:12:40 +01:00
Ayke van Laethem
a4fa41b49d compiler: don't crash when encountering types.Invalid
This commit fixes a crash when trying to compile the following (invalid)
code:

    package main

    import "unsafe"

    func main() {
    }

    type Foo struct {
       x DoesNotExist
    }

    const foo = unsafe.Sizeof(Foo{})

This commit fixes this situation. The result is a regular error message,
indicating that DoesNotExist is not defined.
2019-12-30 13:40:37 +01:00
Ayke van Laethem
a5a90a57b9 main: remove getting a serial port in gdb subcommand
Remove this code for two reasons:

 1. It is not needed.
 2. It breaks `tinygo gdb` for debugging QEMU targets (such as
    cortex-m-qemu).
2019-12-29 19:41:24 +01:00
Dmitri Goutnik
71a380ce8c Add initial FreeBSD support 2019-12-29 10:48:28 +01:00
Ayke van Laethem
3b2a4b64c5 main: kill tests if they run too long
Sometimes, tests suddenly hang somewhere (in particular in emulators
where crashes often lead to hangs). Setting a limit has two advantages:

  1. Quickly killing test processes that are frozen (as opposed to
     waiting for the default 10min go test timeout).
  2. The output becomes visible, hopefully giving a clue what went
     wrong.
2019-12-28 21:10:13 +01:00
Ayke van Laethem
184827e4d8 riscv: support sleeping in QEMU
QEMU doesn't support the RTC peripheral yet so work around it for now.

This makes the following command work:

    tinygo run -target=hifive1-qemu ./testdata/coroutines.go
2019-12-26 09:57:58 +01:00
Ayke van Laethem
14474e7099 compiler: fix assertion on empty interface
This fixes issue #453.
2019-12-26 09:20:22 +01:00
Ron Evans
3656ac2fc9 main: increment version to 0.12-dev
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-12-24 19:48:38 +01:00
Ayke van Laethem
08f01ba3ff riscv: improve startup assembly
Now that we've switched to LLVM 9, we don't need a workaround anymore
for the 'la' pseudo-instruction.
2019-12-24 19:00:22 +01:00
Ayke van Laethem
699312f477 ci: remove symlink creation
These symlinks are now unnecessary because Clang (and previously lld)
have been integrated into TinyGo.
2019-12-24 08:59:33 +01:00
Ayke van Laethem
9644edcd5a builder: update Clang header location
We have long since moved towards a different location for these headers
in the git checkout, so update where getClangHeaderPath looks for these
headers.

Also add an extra check to make sure a path has been detected.
2019-12-24 08:59:33 +01:00
Ayke van Laethem
46325910c5 ci: increase Azure Pipelines timeout to 4 hours
3 hours is too close to the edge. Extend to 4 hours to make sure a build
including LLVM build will finish before the deadline.
2019-12-24 08:49:04 +01:00
Ayke van Laethem
923c2e7ada main: version 0.11.0 2019-12-23 16:37:59 +01:00
Ron Evans
18e446561d flash: use more precise searches for correct volume/port with default Windows matching
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-12-23 16:09:58 +01:00
Ron Evans
447537aebe flash: use win32 wmi to try to find UF2 and COM ports
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-12-23 16:09:58 +01:00
Ayke van Laethem
74e32acf33 compiler: improve error locations in goroutine lowering 2019-12-23 08:33:04 +01:00
Ayke van Laethem
072f8c354e interp: add runtime fallback for mapassign operations
Some mapassign operations cannot (yet) be done by the interp package.
Implement a fallback mechanism so that these operations can still be
performed at runtime.
2019-12-23 08:15:09 +01:00
Daniel Esteban
0587934a44 added missing pinetime devkit to list of suppoerted boards/targets 2019-12-22 21:23:07 +01:00
Daniel Esteban
c2481b10f4 Added Adafruit's pybadge target (#795)
* machine/pybadge: add support for Adafruit PyBadge board
2019-12-22 19:37:16 +01:00
Ayke van Laethem
d41f01f003 main: avoid leaving files open
Eventually, open files should be closed when the GC runs and the
finalizer is called. However we shouldn't rely on that.

Using `ioutil.ReadFile` as it's a simpler pattern anyway.
2019-12-21 23:12:13 +01:00
Ayke van Laethem
5a70c88483 transform: make reflection sidetables constant globals
These globals are (and must be!) never modified by the reflect package.
By marking them as constant, they will be put in read-only memory. This
reduces RAM consumption on microcontrollers.
2019-12-21 22:59:23 +01:00
Ayke van Laethem
5510dec846 compiler: add location information to the IR checker 2019-12-21 20:49:51 +01:00
Ayke van Laethem
dffb9fbfa7 tools: use byte padding to skip unused register ranges
This simplifies the code. The fields are blank anyway so there is no way
to access them anyway (volatile or not).
Also do some other related simplifications of the code that result from
this change.
2019-12-21 19:59:41 +01:00
Jaden Weiss
525ded3d90 run tests partially in parallel 2019-12-21 12:22:59 +01:00