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

452 коммитов

Автор SHA1 Сообщение Дата
Kenneth Bell
fcdaa83368 stm32-l5: corrected alt function and other review comments 2021-02-16 12:48:52 +01:00
Kenneth Bell
af02c09b56 nucleol552ze: implementation with CLOCK, LED, and UART 2021-02-16 12:48:52 +01:00
Ayke van Laethem
801bd2a7ff avr: use Clang for compiling C and assembly files
This is one step towards an avr-gcc free TinyGo toolchain, something
that will make it easier to use AVR targets in TinyGo.
2021-02-12 01:10:06 +01:00
Ayke van Laethem
9c8ef5c48f digispark: split off attiny85 target
This split is similar to the atmega328p/arduino split and may be helpful
for adding other attiny85 boards or using the attiny85 without a board.
2021-02-12 01:10:06 +01:00
Ayke van Laethem
d3d4acaadf esp: add picolibc
With this change, it is possible to fully use CGo on ESP32/ESP8266
chips. The following will work:

    tinygo flash -target=d1mini       -port=/dev/ttyUSB0 ./testdata/cgo/
    tinygo flash -target=esp32-mini32 -port=/dev/ttyUSB0 ./testdata/cgo/

Previously it would produce output like the following:

    /tmp/tinygo905539688/main.o:(.literal.runtime.run$1$gowrapper+0x150): undefined reference to `strcpy'
    /tmp/tinygo905539688/main.o:(.literal.runtime.run$1$gowrapper+0x154): undefined reference to `strlen'
2021-02-11 10:50:29 +01:00
Ayke van Laethem
676a78776a esp8266: add compiler-rt library
With this change, it is possible to compile ./testdata/float.go for the
ESP8266 and run it successfully. Previously it would result in many
linker error like this:

    /tmp/tinygo494494333/main.o:(.literal.runtime.printfloat64+0x0): undefined reference to `__unorddf2'
    /tmp/tinygo494494333/main.o:(.literal.runtime.printfloat64+0x4): undefined reference to `__gtdf2'
    /tmp/tinygo494494333/main.o:(.literal.runtime.printfloat64+0xc): undefined reference to `__nedf2'
    /tmp/tinygo494494333/main.o:(.literal.runtime.printfloat64+0x10): undefined reference to `__ltdf2'
    /tmp/tinygo494494333/main.o:(.literal.runtime.printfloat64+0x1c): undefined reference to `__gedf2'

I have verified that the output on the serial console matches
./testdata/float.txt when run on the ESP8266.
2021-02-11 10:50:29 +01:00
Přemek Vyhnal
32a5d46c57
nice!nano board support (#1499)
machine/nice\!nano: add board support
2021-01-24 16:46:21 +01:00
Ayke van Laethem
154c7c691b stm32: use stm32-rs SVDs which are of much higher quality
This commit changes the number of wait states for the stm32f103 chip to
2 instead of 4. This gets it back in line with the datasheet, but it
also has the side effect of breaking I2C. Therefore, another (seemingly
unrelated) change is needed: the i2cTimeout constant must be increased
to a higher value to adjust to the lower flash wait states - presumably
because the lower number of wait states allows the chip to run code
faster.
2021-01-09 21:45:07 +01:00
Fauchon
65caf777dd
Support for STM32L0 MCUs and Dragino LGT92 device (#1561)
machine/stm32l0: add support for stm32l0 family and Dragino LGT92 Board
2021-01-08 22:27:25 +01:00
deadprogram
6ec868710b machine/microbit-v2: add initial support based on work done by @alankrantas thank you!
Signed-off-by: deadprogram <ron@hybridgroup.com>
2021-01-06 18:50:46 +01:00
Quentin Smith
75f13491b6 Add support for the P1AM-100 (similar to Arduino MKR) 2021-01-06 00:36:57 +01:00
Jacques Supcik
2f4200a01b
Add support for additional openocd commands (#1492)
main: add ability to define specific OpenOCD commands to be executed for a target.
2020-12-30 09:19:41 +01:00
deadprogram
939b393325 machine/clue: correct volume name and add alias for release version of Adafruit Clue board
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-12-29 15:17:38 +01:00
kenbell
43a31467d3
Nucleo f722ze (#1526)
machine/nucleo-f722ze: Add support for ST Micro NUCLEO-F722ZE
2020-12-15 06:51:35 +01:00
Ayke van Laethem
4568de556e esp32: use the compiler-rt library for extra routines
These routines are necessary to compile testdata/float.go.
2020-12-11 12:11:46 +01:00
ardnew
7a4ccd916f
matrixportal-m4: Add support for board Adafruit Matrix Portal M4 (#1529)
machine/matrixportal-m4: add Adafruit Matrix Portal M4 board definition
2020-12-11 10:00:41 +01:00
Ayke van Laethem
4cc1cdf672 main: support gdb debugging with AVR
Be able to run `tinygo gdb -target=arduino examples/serial` and debug a
program with the power of a real debugger.

Note that this only works on LLVM 11 because older versions have a bug
in the AVR backend that cause it to produce invalid debug information:
https://reviews.llvm.org/D74213.
2020-12-10 16:44:27 +01:00
Ayke van Laethem
098f900363 esp8266: implement task based scheduler
I have chosed to call this implementation `esp8266` instead of `xtensa`
as it has been written specifically for the ESP8266 and there are no
other Xtensa chips with the CALL0 ABI (no windowing) that I know of. The
only other related chip is the ESP32, which does implement register
windowing and thus needs a very different implementation.
2020-12-05 11:09:46 +01:00
Ayke van Laethem
caf35cfc41 esp32: implement task based scheduler
This has been a *lot* of work, trying to understand the Xtensa windowed
registers ABI. But in the end I managed to come up with a very simple
implementation that so far seems to work very well.

I tested this with both blinky examples (with blinky2 slightly edited)
and ./testdata/coroutines.go to verify that it actually works.
Most development happened on the ESP32 QEMU fork from Espressif
(https://github.com/espressif/qemu/wiki) but I also verified that it
works on a real ESP32.
2020-12-05 09:02:11 +01:00
Ayke van Laethem
abb09e869e runtime, internal/task: refactor to simplify stack switching
The Cortex-M target isn't much changed, but much of the logic for the
AVR stack switcher that was previously in assembly has now been moved to
Go to make it more maintainable and in fact smaller in code size. Three
functions (tinygo_getCurrentStackPointer, tinygo_switchToTask,
tinygo_switchToScheduler) have been changed to one: tinygo_swapTask.

This reduction in assembly code should make the code more maintainable
and should make it easier to port stack switching to other
architectures.

I've also moved the assembly files to src/internal/task, which seems
like a more appropriate location to me.
2020-12-05 09:02:11 +01:00
fleshin
7abc67107d
sam: add support for the MKR1000 board 2020-12-03 00:33:23 +01:00
Ayke van Laethem
3f680b75f3 sam: remove redundant build tags
Some build tags were duplicated. This commit removes them.
2020-11-15 16:19:51 +01:00
ardnew
b1d24a72c1 teensy40: fix typo in target JSON 2020-11-11 18:34:47 +01:00
ardnew
6e24c86320 teensy40: remove FPU spec in target JSON list of cflags 2020-11-11 18:34:47 +01:00
ardnew
19a0270303 teensy40: refactor to remove unnecessary code and constants 2020-11-11 18:34:47 +01:00
ardnew
691185f5f4 teensy40: initial implementation 2020-11-11 18:34:47 +01:00
deadprogram
77c70d2758 machine/qtpy: add board definition for Adafruit QTPy
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-11-08 22:56:01 +01:00
Lucas Teske
387bca8e32 nintendoswitch: Add env parser and removed unused stuff
*	Heap allocation based on available ram
*	Added homebrew launcher parser (for overriden heap)
*	Removed unused stuff (moved to gonx)
*	Kept require code at minimum to work in a real device
*	Moved everything to a single file
2020-11-03 23:28:55 +01:00
Ayke van Laethem
171f793c1e avr: properly support the .rodata section
Unfortunately, the .rodata section can't be stored in flash. Instead, an
explicit .progmem section should be used, which is supported in LLVM as
address space 1 but not exposed to normal programs.

Eventually a pass should be written that converts trivial const globals
of which all loads are visible to be in addrspace 1, to get the benefits
of storing those globals directly in ROM.
2020-10-31 21:06:26 +01:00
Ayke van Laethem
7a78b2dc0e all: replace underscores with dashes in target names
This is the convention, so use it everywhere.
2020-10-28 12:40:54 +01:00
Ayke van Laethem
6ab0106af3 nrf: fix nrf52832 flash size
I've accidentally specified just half of the available flash in the
linker script. This change fixes that.

There is in fact a 256kB version of the nrf52832, but it also has 32kB
of RAM so if you had used that it wouldn't actually work right now.
Also, extending the available flash should not affect existing programs
(as I haven't seen any run into size limitations yet).
2020-10-20 19:13:43 +02:00
蒼時弦也
e690ff0d8c Add instanceof support for WebAssembly 2020-10-18 22:15:47 +02:00
deadprogram
d382f3a259 esp8266: add target for d1mini board and add pin mappings for SPI/I2C to help out implementers
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-10-17 19:57:53 +02:00
deadprogram
c7d8223ab7 machine/esp32, targets/esp32: correct board definitions for actual boards not processor variants, also define all labeled pins
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-10-14 21:48:48 +02:00
deadprogram
bb146edb47 wasi: remove --no-threads flag as no longer in LLVM 11 linker
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-10-14 13:58:01 +02:00
Ayke van Laethem
b40f250530 main: add initial support for (in-development) LLVM 11
This can be useful to test improvements in LLVM master and to make it
possible to support LLVM 11 for the most part already before the next
release. That also allows catching LLVM bugs early to fix them upstream.

Note that tests do not yet pass for this LLVM version, but the TinyGo
compiler can be built with the binaries from apt.llvm.org (at the time
of making this commit).
2020-10-13 20:23:50 +02:00
Takeshi Yoneda
9a015f4f64
add wasm-abi field in TargetSpec && set generic for WASI by default (#1421)
Signed-off-by: mathetake <takeshi@tetrate.io>
2020-10-03 19:52:01 +02:00
Ayke van Laethem
67de8b490d gc: use raw stack access whenever possible
The only architecture that actually needs special support for scanning
the stack is WebAssembly. All others allow raw access to the stack with
a small bit of assembly. Therefore, don't manually keep track of all
these objects on the stack manually and instead just use conservative
stack scanning.

This results in a massive code size decrease in the affected targets
(only tested linux/amd64 for code size) - sometimes around 33%. It also
allows for future improvements such as using proper stackful goroutines.
2020-10-02 08:54:43 +02:00
Ayke van Laethem
bfa29f17da runtime: move/refactor some GC-related code
Instead of putting tinygo_scanCurrentStack in scheduler_*.S files, put
them in dedicated files. The function tinygo_scanCurrentStack has
nothing to do with scheduling and so doesn't belong there. Additionally,
while scheduling code is made specific for the Cortex-M, the
tinygo_scanCurrentStack is generic to all ARM targets so this move
removes some duplication there.

Specifically:

  * tinygo_scanCurrentStack is moved out of scheduler_cortexm.S as it
    isn't really part of the scheduler. It is now gc_arm.S.
  * Same for the AVR target.
  * Same for the RISCV target.
  * scheduler_gba.S is removed, using gc_arm.S instead as it only
    contains tinygo_scanCurrentStack.
2020-10-02 08:54:43 +02:00
Takeshi Yoneda
f50ad3585d
support WASI target (#1373)
* initial commit for WASI support

* merge "time" package with wasi build tag
* override syscall package with wasi build tag
* create runtime_wasm_{js,wasi}.go files
* create syscall_wasi.go file
* create time/zoneinfo_wasi.go file as the replacement of zoneinfo_js.go
* add targets/wasi.json target

* set visbility hidden for runtime extern variables

Accodring to the WASI docs (https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md#current-unstable-abi),
none of exports of WASI executable(Command) should no be accessed.

v0.19.0 of bytecodealliance/wasmetime, which is often refered to as the reference implementation of WASI,
does not accept any exports except functions and the only limited variables like "table", "memory".

* merge syscall_{baremetal,wasi}.go

* fix js target build

* mv wasi functions to syscall/wasi && implement sleepTicks

* WASI: set visibility hidden for globals variables

* mv back syscall/wasi/* to runtime package

* WASI: add test

* unexport wasi types

* WASI test: fix wasmtime path

* stop changing visibility of runtime.alloc

* use GOOS=linux, GOARCH=arm for wasi target

Signed-off-by: mathetake <takeshi@tetrate.io>

* WASI: fix build tags for os/runtime packages

Signed-off-by: mathetake <takeshi@tetrate.io>

* run WASI test only on Linux

Signed-off-by: mathetake <takeshi@tetrate.io>

* set InternalLinkage instead of changing visibility

Signed-off-by: mathetake <takeshi@tetrate.io>
2020-09-29 21:58:03 +02:00
Ayke van Laethem
b713001313 test: support non-host tests
For example, for running tests with -target=wasm or
-target=cortex-m-qemu. It looks at the output to determine whether tests
were successful in the absence of a status code.
2020-09-24 21:17:26 +02:00
Lucas Teske
622de53854 nintendoswitch: simplified assembly code 2020-09-17 07:46:29 +02:00
Lucas Teske
fb1fc267ab nintendoswitch: Add dynamic loader for runtime loading PIE sections 2020-09-17 07:46:29 +02:00
Ayke van Laethem
4dadb31e18 microbit: reelboard: flash using OpenOCD when needed
When using a SoftDevice, the MSD flash method is not appropriate as it
will erase the entire flash area before writing the new firmware. This
also wipes the SoftDevice. Instead, use OpenOCD to only rewrite the
parts of flash that need to be rewritten and leave the SoftDevice alone.
2020-09-15 17:07:40 +02:00
Ayke van Laethem
9e599bac49 nintendoswitch: support outputting .nro files directly
By modifying the linker script a bit and adding the NRO0 header directly
in the assembly, it's possible to craft an ELF file that can be
converted straight to a binary (using objcopy or similar) that is a NRO
file. This avoids custom code for NRO files or an extra build step.

With another change, .nro files are recognized by TinyGo so that this
will create a ready-to-run NRO file:

    tinygo build -o test.nro -target=nintendoswitch examples/serial
2020-09-12 18:37:58 +02:00
ardnew
efc824a103 change default flash method to DFU (using dfu-util over USB) 2020-09-11 09:09:02 +02:00
ardnew
cb4f3f12e6 replace flash method with openocd, disable automatic stack sizing 2020-09-11 09:09:02 +02:00
ardnew
20a1c730a1 add STM32F405 machine/runtime, and new board/target feather-stm32f405 2020-09-11 09:09:02 +02:00
jreamy
04f65f1189
Adding support for the Arduino Zero (#1365)
* machine/arduino-zero: adding support for Arduino Zero

Co-authored-by: Ayke
Co-authored-by: Jack Reamy
2020-09-10 10:32:12 +02:00
Ayke van Laethem
2ce17a1892 esp8266: add support for this chip
Many thanks to cnlohr for the nosdk8266 project:
    https://github.com/cnlohr/nosdk8266
2020-09-09 19:17:11 +02:00