Commit Graph

648 Commits

Author SHA1 Message Date
Ayke van Laethem 4219652535 compiler: add basic heap-to-stack optimization 2018-10-09 14:14:52 +02:00
Ron Evans ca13bfd992 microbit: add SetEntireLEDMatrixOn() function
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-10-08 20:38:21 +02:00
Ayke van Laethem aee9eb413e main, travis: add qemu to run tests in
This makes sure we'll catch bugs that occur only on ARM hardware.
2018-10-08 20:36:25 +02:00
Ayke van Laethem 3289dd7134 compiler: use a fresh context for every compilation 2018-10-08 20:18:12 +02:00
Ayke van Laethem a63af97e86 all: add emulation support for Cortex-M3 with QEMU 2018-10-08 17:07:19 +02:00
Ayke van Laethem 8982b8df83 runtime: refactor initialization code
Let each target handle its own initialization/finalization sequence
instead of providing one in the runtime with hooks for memory
initialization etc. This is much more flexible although it causes a
little bit of code duplication.
2018-10-08 14:49:33 +02:00
Ayke van Laethem 96f07243a4 main: add aeabi builtins to arm targets
Some builtins require these __aeabi_* functions.
2018-10-07 23:20:46 +02:00
Ayke van Laethem e50c6f1af1 main: generate binary files when compiling to .bin 2018-10-07 22:48:33 +02:00
Ayke van Laethem f0f6a12d19 docs: add avr-libc as a dependency 2018-10-07 22:14:44 +02:00
Ayke van Laethem 1bbdab41d2 all: improve compiler-rt compilation
A few changes to make sure compiler-rt is correctly compiled (and
doesn't include host headers, for example).

This improves support for AVR, but it still doesn't work. Compiler-rt
itself doesn't really work for AVR either.
2018-10-07 21:29:45 +02:00
Ayke van Laethem 73709922b2 main: extra interface test for simple named types 2018-10-07 19:40:21 +02:00
Ron Evans c516a11004 microbit: add functions for LED matrix and correct button pin mapping
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-10-07 19:40:16 +02:00
Ron Evans 269bef5494 microbit: add Makefile entries for target=microbit
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-10-07 19:06:00 +02:00
Ayke van Laethem 22da104530 all: use compiler-rt for builtins 2018-10-07 19:04:29 +02:00
Ayke van Laethem e8f211935e compiler: fix expanded structs in invoke calls 2018-10-07 13:19:38 +02:00
Ayke van Laethem 4957db89f4 compiler: fix interface calls for big underlying values
When the underlying value of an interface does not fit in a pointer, a
pointer to the value was correctly inserted in the heap. However, the
receiving method still assumed it got the underlying value instead of a
pointer to it leading to a crash.

This commit inserts wrapper functions for method calls on interfaces.

The bug wasn't obvious as on a 64-bit system, the underlying value was
almost always put directly in the interface. However, it led to a crash
on the AVR platform where pointer are (usually) just 16 bits making it
far more likely that underlying values cannot be directly stored in an
interface.
2018-10-07 02:06:48 +02:00
Ayke van Laethem 482c5633dd compiler: put debug information on package initializer functions
Make sure package initializers show up in backtraces, as they should. In
practice, it doesn't actually break backtraces as these functions are
usually inlined anyway, but it may help to debug an error in
initialization code.
2018-10-06 23:50:35 +02:00
Ayke van Laethem 5db43e8d04 compiler: move Optimize() function to a separate file
In the future, there will be more optimizations. Let's keep them in a
separate file for separation of concerns.
2018-10-06 19:57:41 +02:00
Ayke van Laethem c9c9935b9c travis: add micro:bit 2018-10-06 13:51:40 +02:00
Ayke van Laethem bc9210b674 nrf: add micro:bit board 2018-10-06 13:04:14 +02:00
Ron Evans e4fa1a8288 nrf: I2C interface
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-10-05 12:50:43 +02:00
Ron Evans 8f7b7e6ee3 nrf52: implement ADC and PWM interfaces
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-10-04 13:56:44 +02:00
Ayke van Laethem 3e98fbcdc8 avr: use machine.UART0 as stdout 2018-10-04 13:38:12 +02:00
Ayke van Laethem f37d409855 nrf: use machine.UART0 as stdout 2018-10-04 13:36:15 +02:00
Ayke van Laethem b36b9c24a2 tools/gen-device-svd: fix interrupts for derived peripherals 2018-10-03 20:06:13 +02:00
Ayke van Laethem 9d408b7cbc main: hide OCD output by default in gdb subcommand
In most cases, it's useless. But in some cases it may be critical if the
OCD server (like openocd) has a problem.

It would be nice if openocd would differentiate between stdout and
stderr, and only write errors to stderr. But sadly it doesn't.
2018-10-03 19:33:36 +02:00
Ayke van Laethem 5d2ffa79e5 compiler: improve debug info to cover initialization 2018-10-03 19:24:29 +02:00
Ayke van Laethem f2768bee17 nrf: better formatting of pca10040.json 2018-10-03 19:03:27 +02:00
Ayke van Laethem b08c8a0cf0 all: implement gdb sub-command for easy debugging 2018-10-03 19:03:22 +02:00
Ron Evans ef2ac09561 nrf: implement UART interface
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-10-02 17:08:31 +02:00
Ayke van Laethem 3540fd9638 travis: try to build blinky2 for the host 2018-10-02 16:00:52 +02:00
Ayke van Laethem afecd28859 travis: test running a few builds for MCUs
Just a sanity check nothing gets horribly broken in the "runtime" or
"machine" packages.
2018-10-02 15:42:13 +02:00
Ayke van Laethem 2ca4540f2a tools/gen-device-svd: support old Python version
Travis-CI runs Ubuntu Trusty with Python 3.4, so we have to support
that.
2018-10-02 14:22:28 +02:00
Ayke van Laethem bdcac9ae42 Makefile: add gen-device-stm32 to gen-device target 2018-10-02 13:30:49 +02:00
Ayke van Laethem ffa6d562a9 tools/gen-device-svd: fix bug in previous commit
There was a bug in the generated Go code: padding member numbers would
not increase their count leading to multiple struct members with the
same name.
2018-10-01 21:21:09 +02:00
Ayke van Laethem a72d0b7959 tools/gen-device-svd: make sure all clusters are included
This is important for nrf52840, which has UART pin selection in a
cluster that wasn't exposed.
2018-10-01 17:14:33 +02:00
Ron Evans 4c8a725d78 avr: implement UART interface
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-10-01 12:02:59 +02:00
Ayke van Laethem bcf441ccba docs: add another way in which a llvm-7-dev installation can fail 2018-09-30 18:02:15 +02:00
Ayke van Laethem eac81e5232 Makefile: run verbose 'make test' 2018-09-30 18:01:14 +02:00
Ayke van Laethem 02936042b8 travis: add Travis CI build script 2018-09-30 17:32:40 +02:00
Ayke van Laethem a2e57b40f9 docs: update installation instructions
* Update to system-installed LLVM.
  * Avoid the use of make.
2018-09-30 15:40:58 +02:00
Ayke van Laethem f107a24b72 all: use LLVM library provided by the system 2018-09-30 15:10:04 +02:00
Ayke van Laethem 5c79a93c85 tools/gen-device-svd: generate code for cluster arrays
This should make it possible to add support for PWM on nrf devices.
2018-09-30 14:57:06 +02:00
Ayke van Laethem 9b4a6dcc14 tools/gen-device-svd: move peripheral list to beginning
It's much easier to scan the source when the peripheral list is at the
front. Go doesn't care about the order of declaration anyway.
2018-09-30 14:56:19 +02:00
Ayke van Laethem e77a5af5d2 tools/gen-device-svd: rewrite with ElementTree
xml.etree.ElementTree is much easier to work with. This also fixes a few
small bugs in the parser. And as an added bonus, device generation got a
lot faster: apprently etree is a lot faster than minidom.
2018-09-30 14:55:38 +02:00
Ron Evans ee5d562050 examples: add color mood lamp that shows using GPIO, PWM, ADC, and I2C all at the same time on an Arduino
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-09-29 23:18:31 +02:00
Ayke van Laethem 802350f8da main: helpful error message for flash cmd without -target 2018-09-29 22:39:44 +02:00
Ayke van Laethem b6db84e916 main: use GOPATH from the environment
Be more compatible with the Go toolchain by setting GOPATH in the same
way. This makes it possible to flash and run examples from the standard
GOPATH instead of only from the source tree.
2018-09-29 22:30:45 +02:00
Ayke van Laethem 5bf058a0a6 nrf: fix off-by-one in modulo of runtime.ticks
This code:
    foo & 0xffffff
Is equivalent to this code:
    foo % 0x1000000
However, to drop the high 8 bits, this calculation was used:
    foo % 0xffffff
This is far more expensive (and incorrect), as it needs an actual modulo
operation which increases code size and probably reduces speed on a
Cortex-M4 and needs library functions for a Cortex-M0 increasing code
size by a much bigger amount.
2018-09-29 16:21:17 +02:00
Ayke van Laethem c1a833c7cc main: add basic float tests 2018-09-29 00:12:23 +02:00