aboutsummaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)Author
2021-10-23add support for CPU interrupts for ESP32-C3espnetDmitriy
2021-09-29cgo: add more FreeRTOS compatibilityAyke van Laethem
This commit implements: * xTaskCreate * vTaskDelay * xSemaphoreCreateCounting (partially) * xSemaphoreTake * xSemaphoreGive * xQueueCreate * vQueueDelete * xQueueReceive * xQueueSend * uxQueueMessagesWaiting
2021-09-28cgo: add FreeRTOS compatibility headersAyke van Laethem
This is especially useful if we ever want to support the ESP-IDF. Currently implemented: - xTaskGetCurrentTaskHandle - xSemaphoreCreateRecursiveMutex - xSemaphoreDelete - xSemaphoreTakeRecursive - xSemaphoreGiveRecursive
2021-09-28esp32c3: use tasks scheduler by defaultAyke van Laethem
2021-09-28riscv: switch to tasks-based schedulerAyke van Laethem
This is only supported for RV32 at the moment. RV64 can be added at a later time.
2021-09-28riscv: implement 32-bit atomic operationsAyke van Laethem
This is necessary to support the ESP32-C3, which lacks the A (atomic) extension and thus requires these 32-bit atomic operations. With this commit, flashing ./testdata/atomic.go to the ESP32-C3 works correctly and produces the expected output on the serial console.
2021-09-28riscv: use MSTATUS.MIE bit instead of MIE to disable interruptsAyke van Laethem
This should behave the same but is compatible with the ESP32-C3 which lacks the MIE CSR (but does have the MSTATUS CSR).
2021-09-27baremetal: implement calloc libc functionAyke van Laethem
This simply calls runtime.alloc, because the memory will be zero-initialized anyway.
2021-09-27esp32c3: add support for GDB debuggingAyke van Laethem
You can now debug the ESP32-C3 from the TinyGo command line, like this: tinygo flash -target=esp32c3 examples/serial tinygo gdb -target=esp32c3 examples/serial It's important to flash before running `tinygo gdb`, because loading a new firmware from GDB has not yet been implemented. Probably the easiest way to connect to the ESP32-C3 is by using the built-in JTAG connection. See: https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-guides/jtag-debugging/configure-builtin-jtag.html You will need to make sure that the `openocd` command in your $PATH is the one from Espressif. Otherwise GDB will hang. You can debug this by supplying the -ocd-output flag: $ tinygo gdb -target=esp32c3 -ocd-output examples/serial Open On-Chip Debugger 0.10.0 openocd: Licensed under GNU GPL v2 openocd: For bug reports, read openocd: http://openocd.org/doc/doxygen/bugs.html openocd: embedded:startup.tcl:60: Error: Can't find interface/esp_usb_jtag.cfg openocd: in procedure 'script' openocd: at file "embedded:startup.tcl", line 60 Make sure to configure OpenOCD correctly, until you get the correct version (that includes the string "esp32"): $ openocd --version Open On-Chip Debugger v0.10.0-esp32-20210721 (2021-07-21-13:33) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html If you are on Linux, you may also get the following error: $ tinygo gdb -target=esp32c3 -ocd-output examples/serial Open On-Chip Debugger v0.10.0-esp32-20210721 (2021-07-21-13:33) openocd: Licensed under GNU GPL v2 openocd: For bug reports, read openocd: http://openocd.org/doc/doxygen/bugs.html openocd: Info : only one transport option; autoselect 'jtag' openocd: adapter speed: 40000 kHz openocd: openocd: Warn : Transport "jtag" was already selected openocd: Info : Listening on port 6666 for tcl connections openocd: Info : Listening on port 4444 for telnet connections openocd: Error: libusb_open() failed with LIBUSB_ERROR_ACCESS openocd: Error: esp_usb_jtag: could not find or open device! The error LIBUSB_ERROR_ACCESS means that there is a permission error. You can fix this by creating the following file: $ cat /etc/udev/rules.d/50-esp.rules # ESP32-C3 SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1001", MODE="0666" For more details, see: https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-guides/jtag-debugging/index.html
2021-09-27cgo: add stdio support to picolibcAyke van Laethem
2021-09-27baremetal: define the abort functionAyke van Laethem
This is normally provided by the libc, but in our case it makes more sense to define it in the runtime (just like malloc).
2021-09-27esp32c3: add some sections to the linker scriptAyke van Laethem
This is necessary to support the WiFi binary blobs from Espressif.
2021-09-27cgo: add support for the -T flagAyke van Laethem
This adds support for specifying linker scripts in LDFLAGS. I looked a bit into whether it allows arbitrary code execution but I couldn't find any sign of that.
2021-09-27cgo: implement rudimentary C array decayingAyke van Laethem
This is just a first step. It's not complete, but it gets some real world C code to parse. This signature, from the ESP-IDF: esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6]); Was previously converted to something like this (pseudocode): C.esp_err_t esp_wifi_get_mac(ifx C.wifi_interface_t, mac [6]uint8) But this is not correct. C array parameters will decay. The array is passed by reference instead of by value. Instead, this would be the correct signature: C.esp_err_t esp_wifi_get_mac(ifx C.wifi_interface_t, mac *uint8) So that it can be called like this (using CGo): var mac [6]byte errCode := C.esp_wifi_get_mac(C.ESP_IF_WIFI_AP, &mac[0]) This stores the result in the 6-element array mac.
2021-09-24cgo: add support for stdio in picolibcAyke van Laethem
This is simple: just add the required header file. But this commit also adds a simple test to make sure it remains supported.
2021-09-21transform (coroutines): move any misplaced entry-block allocas to the start ↵v0.20.0Nia Waldvogel
of the entry block before lowering
2021-09-21transform (coroutines): fix memory corruption for tail calls that reference ↵Nia Waldvogel
stack allocations This change fixes a bug in which `alloca` memory lifetimes would not extend past the suspend of an asynchronous tail call. This would typically manifest as memory corruption, and could happen with or without normal suspending calls within the function.
2021-09-21main: release version 0.20.0Ayke van Laethem
2021-09-17builder: simplify running of jobsAyke van Laethem
Instead of keeping a slice of jobs to run, let the runJobs function determine which jobs should be run by investigating all dependencies. This has two benefits: - The code is somewhat cleaner, as no 'jobs' slice needs to be maintained while constructing the dependency graph. - Eventually, some jobs might not be required by any dependency. While it's possible to avoid adding them to the slice, the simpler solution is to build a new slice from the dependencies which will only include required dependencies by design.
2021-09-16esp32c3: add support for this chipAyke van Laethem
This change adds support for the ESP32-C3, a new chip from Espressif. It is a RISC-V core so porting was comparatively easy. Most peripherals are shared with the (original) ESP32 chip, but with subtle differences. Also, the SVD file I've used gives some peripherals/registers a different name which makes sharing code harder. Eventually, when an official SVD file for the ESP32 is released, I expect that a lot of code can be shared between the two chips. More information: https://www.espressif.com/en/products/socs/esp32-c3 TODO: - stack scheduler - interrupts - most peripherals (SPI, I2C, PWM, etc)
2021-09-16stm32: add support for PortMask* functions for WS2812 supportAyke van Laethem
This also requires support in the tinygo.org/x/drivers/ws2812 package, which I've already partially written.
2021-09-15loader: fix panic in CGo files with syntax errorsAyke van Laethem
If all of the Go files presented to the compiler have syntax errors, cgo.Process gets an empty files slice and will panic: panic: runtime error: index out of range [0] with length 0 goroutine 1 [running]: github.com/tinygo-org/tinygo/cgo.Process({0x0, 0x4e8e36, 0x0}, {0xc000024104, 0x18}, 0xc000090fc0, {0xc000899780, 0x7, 0xc00018ce68}) /home/ayke/src/github.com/tinygo-org/tinygo/cgo/cgo.go:186 +0x22ee github.com/tinygo-org/tinygo/loader.(*Package).parseFiles(0xc0001ccf00) /home/ayke/src/github.com/tinygo-org/tinygo/loader/loader.go:400 +0x51e This is simple to work around: just don't try to run CGo when there are no files to process. It just means there are bugs to fix before CGo can properly run. (This is perhaps not the nicest solution but certainly the simplest).
2021-09-15os: add SEEK_SET, SEEK_CUR, and SEEK_ENDAyke van Laethem
These are deprecated but still used by some code.
2021-09-15unix: check for mmap error and act accordinglyAyke van Laethem
At startup, a large chunk of virtual memory is used up by the heap. This works fine in emulation (qemu-arm), but doesn't work so well on an actual Raspberry Pi. Therefore, this commit reduces the requested amount until a heap size is found that works on the system. This can certainly be improved, but for now it's an important fix because it allows TinyGo built binaries to actually run on a Raspberry Pi with just 1GB RAM.
2021-09-15arm: switch to Thumb instruction set on ARMAyke van Laethem
This reduces binary size substantially, for two reasons: - It switches to a much more architecture ARMv4 vs ARMv7. - It switches to Thumb2, which is a lot denser than regular ARM. Practically all modern and not-so-modern ARM chips support Thumb2, so this seems like a safe change to me. The size in numbers: - Code size for testdata/stdlib.go is reduced by about 35%. - Binary size for testdata/stdlib.go (when compiling with -no-debug to strip debug information) is reduced by about 16%.
2021-09-13relax restriction on configuration with duplicate settingsardnew
2021-09-13teensy40: enable hardware UART reconfiguration, fix receive watermark interruptardnew
2021-09-10machine: fix copy-paste error for atsamd21/51 calibTrim blockDamian Gryski
Fixes #2097
2021-09-09target: fix pid for mdbt50qrx-uf2sago35
2021-09-09runtime: fix a suspicious bitwise operationDamian Gryski
The `0 << nxp.SIM_CLKDIV1_OUTDIV1_Pos` term was duplicated. No effect other than triggering a static analysis check.
2021-09-09targets: add DefaultUART to adafruit boardssago35
2021-09-09cgo: don't normalize CGo tests anymoreAyke van Laethem
Normalization was required because previously we supported Go 1.13 and Go 1.14 at the same time. Now we've dropped support for both so this normalization is not necessary anymore. CGo support remains the same. It's just the test outputs that aren't normalized anymore.
2021-09-09compiler: avoid zero-sized alloca in channel operationsAyke van Laethem
This works around a bug in LLVM (https://bugs.llvm.org/show_bug.cgi?id=49916) but seems like a good change in general.
2021-09-08builder: add missing error check for ioutil.TempFile()Damian Gryski
2021-09-08board: add Raytac MDBT50Q-RX Dongle with TinyUF2BCG
2021-09-08compiler: fix equally named structs in different scopesAyke van Laethem
For example, in this code: type kv struct { v float32 } func foo(a *kv) { type kv struct { v byte } } Both 'kv' types would be given the same LLVM type, even though they are different types! This is fixed by only creating a LLVM type once per Go type (types.Type). As an added bonus, this change gives a performance improvement of about 0.4%. Not that much, but certainly not nothing for such a small change.
2021-09-08tinygo: add a flag for creating cpu profilesDamian Gryski
2021-09-07Makefile: add smoke test with gc=leaking to test dead asm codeDamian Gryski
2021-09-07internal/task, runtime: add subsections_via_symbols to assembly files on darwinDamian Gryski
This allows the assembly routines in these files to be stripped as dead code if they're not referenced. This solves the link issues on MacOS when the `leaking` garbage collector or the `coroutines` scheduler are selected. Fixes #2081
2021-09-06Revert "Minor changes to support go 1.17"Ron Evans
This reverts commit 2d224ae049286acf77298ee7060aa2dea2fdec19.
2021-09-05nrf52840: fix ram sizesago35
2021-09-05fix GBA ROM headerMike Mogenson
Populate the GBA ROM header so that emulators and physical Game Boy Advance consoles recognize the ROM as a valid game. Note: The reserve space at the end of the header was hand-tuned. Why this magic value?
2021-09-05machine/arduino_mkrwifi1010: fix pin definition of NINA_RESETNsago35
2021-09-05interp: remove unused gepOperands sliceDamian Gryski
2021-09-04src/runtime: reset heapptr to heapStart after preinit()Damian Gryski
heapptr is assinged to heapStart (which is 0) when it's declared, but preinit() may have moved the heap somewhere else. Set heapptr to the proper value of heapStart when we initialize the heap properly. This allows the leaking allocator to work on unix.
2021-09-02docker: use go 1.17 for docker dev builddeadprogram
Signed-off-by: deadprogram <[email protected]>
2021-09-01machine/feather-rp2040: add pin name definition for feathersago35
2021-09-01targets: add openocd configuration for rp2040sago35
2021-09-01Implement os.ExecutableFederico G. Schwindt
For now this is a stub for everything but linux, which is a slightly modified copy of the official implementation. Should address #1778.
2021-09-01board/nano-rp2040: define NINA_SPI and fix wifinina pinsYurii Soldak