aboutsummaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)Author
7 daysfeature: make SPI implementation shared for rp2040/rp2350deadprogram
Signed-off-by: deadprogram <[email protected]>
8 daysfeature: make i2c implementation shared for rp2040/rp2350deadprogram
Signed-off-by: deadprogram <[email protected]>
8 daysAdd RP2350 support (#4459)Patricio Whittingslow
machine/rp2350: add support * add linker scripts for rp2350 * add bootloader * begin melding rp2040 and rp2350 APIs * add UART * add rp2350 boot patching * Fix RP2350 memory layout (#4626) * Remove rp2040-style second stage bootloader. * Add 'minimum viable' IMAGE_DEF embedded block * Create a pico2 specific target * Implement rp2350 init, clock, and uart support * Merge rp2 reset code back together * Separate chip-specific clock definitions * Clear pad isolation bit on rp2350 * Init UART in rp2350 runtime * Correct usb/serial initialization order * Implement jump-to-bootloader * test: add pico2 to smoketests --------- Signed-off-by: deadprogram <[email protected]> Co-authored-by: Matthew Mets <[email protected]> Co-authored-by: Matt Mets <[email protected]> Co-authored-by: deadprogram <[email protected]>
8 daysfix: add build tags to ensure that tkey target has stubs for ↵deadprogram
runtime/interrupt package Signed-off-by: deadprogram <[email protected]>
8 daysfeature: modify i2s interface/implementation to better match specificationdeadprogram
Signed-off-by: deadprogram <[email protected]>
10 daysruntime: make channels parallelism-safeAyke van Laethem
12 daystargets: add implementation for Tillitis TKey device (#4631)Ron Evans
* initial implementation for Tillitis TKey device * add UART implementation for TKey * add Pin interface implementation for TKey touch sensor * add RNG interface implementation for TKey * add helpful machine package functions to return identifiers such as name and version for TKey * use built-in timer for sleep timing on TKey * modify UART implementation for TKey to implement Serialer interface * implement BLAKE2s ROM function call for TKey device * handle abort by triggering TKey device fault using illegal instruction to halt CPU * simplify TKey implementation by inheriting from existing riscv32 target * return error for trying to configure invalid baudrates on UART * add tkey to builder test * be very specific for features passed to LLVM for specific config in use for TKey * handle feedback items from TKey device code review Signed-off-by: deadprogram <[email protected]>
12 dayscompiler: report error instead of crashing on missing function bodyAyke van Laethem
This can happen with generic functions, see: https://github.com/tinygo-org/tinygo/issues/4486
2024-12-09fix: specify ubuntu-22.04 during GH actions transition period to ubuntu-24.04deadprogram
See https://github.com/actions/runner-images/issues/10636 Signed-off-by: deadprogram <[email protected]>
2024-12-06test: make tests deterministic with -scheduler=threadsAyke van Laethem
2024-12-06sync: make Cond MT-safeAyke van Laethem
This actually simplifies the code and avoids a heap allocation in the call to Wait. Instead, it uses the Data field of the task to store information on whether a task was signalled early.
2024-12-04make: modify smoketest for nintendoswitch target to build something that ↵deadprogram
includes the 'os' package Signed-off-by: deadprogram <[email protected]>
2024-12-04fix: allow nintendoswitch target to compiledeadprogram
Signed-off-by: deadprogram <[email protected]>
2024-12-04sync: implement WaitGroup using a futexAyke van Laethem
This prepares sync.WaitGroup for multithreading. Code size for the cooperative scheduler is nearly unchanged.
2024-12-04internal/task: add cooperative implementation of FutexAyke van Laethem
See the code comments for details. But in short, this implements a futex for the cooperative scheduler (that is single threaded and non-reentrant). Similar implementations can be made for basically every other operating system, and even WebAssembly with the threading (actually: atomics) proposal. Using this basic futex implementation means we can use the same implementation for synchronisation primitives on cooperative and multicore systems. For more information on futex across operating systems: https://outerproduct.net/futex-dictionary.html
2024-12-04internal/task: add non-atomic atomic operationsAyke van Laethem
This adds some non-atomic types that have the same interface as the ones in sync/atomic. We currently don't need these to be atomic (because the scheduler is entirely cooperative), but once we add support for a scheduler with multiple threads and/or preemptive scheduling we can trivially add some type aliases under a different build tag in the future when real atomicity is needed for threading.
2024-12-04runtime: remove CondAyke van Laethem
I don't think this is used anywhere right now, and it would need to be updated to work with multithreading. So instead of fixing it, I think we can remove it. My original intention was to have something like this that could be used in the machine package, but since this is in the runtime package (and the runtime package imports the machine package on baremetal) it can't actually be used that way. I checked the TinyGo repo and the drivers repo, and `runtime.Cond` isn't used anywhere except in that one test.
2024-12-04ci: cache the Go cache across buildsAyke van Laethem
This should hopefully make the build slightly faster.
2024-12-01mips: fix a bug when scanning the stackAyke van Laethem
Previously the assembler was reordering this code: jal tinygo_scanstack move $a0, $sp Into this: jal tinygo_scanstack nop move $a0, $sp So it was "helpfully" inserting a branch delay slot, even though this was already being taken care of. Somehow this didn't break, but it does break in the WIP threading branch (https://github.com/tinygo-org/tinygo/pull/4559) where this bug leads to a crash.
2024-12-01runtime: lock output in print/printlnAyke van Laethem
This ensures that calls to print/println happening in different threads are not interleaved. It's a task.PMutex, so this should only change things when threading is used. This matches the Go compiler, which does the same thing: https://godbolt.org/z/na5KzE7en The locks are not recursive, which means that we need to be careful to not call `print` or `println` inside a runtime.print* implementation, inside putchar (recursively), and inside signal handlers. Making them recursive might be useful to do in the future, but it's not really necessary.
2024-12-01runtime: make signals parallelism-safeAyke van Laethem
2024-11-30runtime: implement GoexitAyke van Laethem
This is needed for full support for the testing package
2024-11-29examples: use default UART settings in echo exampledeadprogram
Signed-off-by: deadprogram <[email protected]>
2024-11-27runtime: use uint32 for the channel state and select indexAyke van Laethem
This uses uint32 instead of uint64. The reason for this is that uint64 atomic operations aren't universally available (especially on 32-bit architectures). We could also use uintptr, but that seems needlessly complicated: it's unlikely real-world programs will use more than a billion select states (2^30).
2024-11-26builder: add testing for -size=fullAyke van Laethem
This helps to make sure this feature continues to work and we won't accidentally introduce regressions.
2024-11-26builder: fix wasi-libc path names on Windows with -size=fullAyke van Laethem
Without this fix, wasi-libc is listed as follows: 65 0 0 0 | 65 0 | C:\Users\Ayke\src\tinygo\tinygo\lib\wasi-libc\libc-bottom-half\sources 14 0 0 0 | 14 0 | C:\Users\Ayke\src\tinygo\tinygo\lib\wasi-libc\libc-top-half\musl\src\exit 1398 0 0 0 | 1398 0 | C:\Users\Ayke\src\tinygo\tinygo\lib\wasi-libc\libc-top-half\musl\src\string 1525 0 0 0 | 1525 0 | C:\Users\Ayke\src\tinygo\tinygo\lib\wasi-libc\libc-top-half\sources With this fix, it's identified as the wasi-libc C library: 3002 0 0 0 | 3002 0 | C wasi-libc
2024-11-26builder: work around bug in DWARF paths in ClangAyke van Laethem
See bug: https://github.com/llvm/llvm-project/issues/117317
2024-11-26builder: fix cache paths in -size=full outputAyke van Laethem
This fixes long paths from the TinyGo cached GOROOT, as can be seen here: code rodata data bss | flash ram | package ------------------------------- | --------------- | ------- 0 5 0 5 | 5 5 | (padding) 148 0 0 5 | 148 5 | (unknown) 76 0 0 0 | 76 0 | /home/ayke/.cache/tinygo/goroot-ce8827882be9dc201bed279a631881177ae124ea064510684a3cf4bb66436e1a/src/device/arm 4 0 0 0 | 4 0 | /home/ayke/.cache/tinygo/goroot-ce8827882be9dc201bed279a631881177ae124ea064510684a3cf4bb66436e1a/src/internal/task They're now attributed to the correct package instead (device/arm and internal/task).
2024-11-26cgo: fix build warnings on Windows ARMAyke van Laethem
Fix the warning, and also remove tinygo_clang_enum_visitor which was unused. See: https://github.com/golang/go/issues/49721
2024-11-22Fix invalid assembler syntax from gen-device-svdMatt Mets
This addresses #4608
2024-11-22Update cmsis-svd libraryMatt Mets
This updates the version of the cmsis-svd library, to include a version that supports rp2350. This is in support of #4452
2024-11-22sync: make Pool thread-safeAyke van Laethem
Make sure the object is locked when trying to modify it. Binary size seems unaffected when not using threading.
2024-11-22sync: only use a lock in the Map implementation when neededAyke van Laethem
2024-11-22runtime: prepare the leaking GC for concurrent operationsAyke van Laethem
This uses the task.PMutex parallel-only-mutex type to make the leaking GC parallelism safe. The task.PMutex type is currently a no-op but will become a real mutex once we add true parallelism.
2024-11-22internal/task: implement PMutexAyke van Laethem
PMutex is a mutex when threading is possible, and a dummy mutex-like object (that doesn't do anything) otherwise.
2024-11-21interp: align created globalsAyke van Laethem
Use the alignment from the align attribute of the runtime.alloc call. This is going to be a more accurate alignment, and is typically smaller than the default.
2024-11-21runtime: fix regression introduced by merging conflicting PRsAyke van Laethem
2024-11-20runtime: implement race-free signals using futexesAyke van Laethem
This requires an API introduced in MacOS 11. I think that's fine, since the version before that (MacOS 10.15) is EOL since 2022. Though if needed, we could certainly work around it by using an older and slightly less nice API.
2024-11-20runtime: use SA_RESTART when registering a signalAyke van Laethem
This really is the only sane way to register a signal. If this flag is not set, many syscalls will return EINTR (and not complete their operation) which will be a massive source of hard-to-debug bugs.
2024-11-20fix: add updated test output to match recent changesdeadprogram
Signed-off-by: deadprogram <[email protected]>
2024-11-20runtime: rewrite channel implementationAyke van Laethem
This rewrite simplifies the channel implementation considerably, with 34% less LOC. Perhaps the most important change is the removal of the channel state, which made sense when we had only send and receive operations but only makes things more compliated when multiple select operations can be pending on a single channel. I did this rewrite originally to make it possible to make channels parallelism-safe. The current implementation is not parallelism-safe, but it will be easy to make it so (the main additions will be a channel lock, a global select lock, and an atomic compare-and-swap in chanQueue.pop).
2024-11-20cgo: add support for `#cgo noescape` linesAyke van Laethem
Here is the proposal: https://github.com/golang/go/issues/56378 They are documented here: https://pkg.go.dev/cmd/cgo@master#hdr-Optimizing_calls_of_C_code This would have been very useful to fix https://github.com/tinygo-org/bluetooth/issues/176 in a nice way. That bug is now fixed in a different way using a wrapper function, but once this new noescape pragma gets included in TinyGo we could remove the workaround and use `#cgo noescape` instead.
2024-11-20compiler: add //go:noescape pragmaAyke van Laethem
This only works on declarations, not definitions. This is intentional: it follows the upstream Go implemetation. However, we might want to loosen this requirement at some point: TinyGo sometimes stores pointers in memory mapped I/O knowing they won't actually escape, but the compiler doesn't know about this.
2024-11-20runtime: move scheduler code aroundAyke van Laethem
This moves all scheduler code into a separate file that is only compiled when there's a scheduler in use (the tasks or asyncify scheduler, which are both cooperative). The main goal of this change is to make it easier to add a new "scheduler" based on OS threads. It also fixes a few subtle issues with `-gc=none`: - Gosched() panicked. This is now fixed to just return immediately (the only logical thing to do when there's only one goroutine). - Timers aren't supported without a scheduler, but the relevant code was still present and would happily add a timer to the queue. It just never ran. So now it exits with a runtime error, similar to any blocking operation.
2024-11-20cgo: support errno value as second return parameterAyke van Laethem
Making this work on all targets was interesting but there's now a test in place to make sure this works on all targets that have the CGo test enabled (which is almost all targets).
2024-11-20compiler: Fix wasmimport -> wasmexport in error messageDamian Gryski
Fixes #4615
2024-11-19windows: don't return, exit via exit(0) insteadAyke van Laethem
This fixes a bug where output would not actually be written to stdout before exiting the process, leading to a flaky Windows CI. Exiting using `exit(0)` appears to fix this. For some background, see: https://github.com/tinygo-org/tinygo/pull/4589
2024-11-19syscall: use wasi-libc tables for wasm/js targetAyke van Laethem
Instead of using fake tables for errno and others, use the ones that correspond to wasi-libc.
2024-11-19syscall: refactor environment handlingAyke van Laethem
* Move environment functions to their own files. * Rewrite the WASIp2 version of environment variables to be much simpler (don't go through C functions).
2024-11-18cgo: support function-like macrosAyke van Laethem
This is needed for code like this: #define __WASI_ERRNO_INVAL (UINT16_C(28)) #define EINVAL __WASI_ERRNO_INVAL