aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
AgeCommit message (Collapse)Author
7 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]>
2024-11-22Fix invalid assembler syntax from gen-device-svdMatt Mets
This addresses #4608
2024-07-02wasi preview 2 support (#4027)Damian Gryski
* all: wasip2 support Co-authored-by: Randy Reddig <[email protected]>
2023-12-03tools/sizediff: cleanup and calculate ramYurii Soldak
2023-07-05tools/gen-device-svd: small changes needed for Renesas MCUsdeadprogram
Signed-off-by: deadprogram <[email protected]>
2023-06-06tools: use geomean for sizediffDamian Gryski
2023-05-20avr: add attiny1616 supportAyke van Laethem
This is just support for the chip, no boards are currently supported. However, you can use this target on a custom board. Notes: - This required a new runtime and machine implementation, because the hardware is actually very different (and much nicer than older AVRs!). - I had to update gen-device-avr to support this chip. This also affects the generated output of other AVRs, but I checked all chips we support and there shouldn't be any backwards incompatible changes. - I did not implement peripherals like UART, I2C, SPI, etc because I don't need them. That is left to do in the future. You can flash these chips with only a UART and a 1kOhm resistor, which is really nice (no special hardware needed). Here is the program I've used for this purpose: https://pypi.org/project/pymcuprog/
2023-05-20avr: update gen-device-avr tool to support newer AVRsAyke van Laethem
This refactors gen-device-avr to output two different formats: one for all the existing AVR chips (that don't really have the concept of a peripheral, just a bunch of registers), and one for all the new chips like the ATtiny1616 (tinyAVR 1-series and 2-series) that have peripherals like the Cortex-M chips with type structs and instances. I checked the generated code for all the AVR chips we have support for (atmega1280, atmega1284p, atmega2560, atmega328p, atmega32u4, attiny85) and while the generated Go code did change, it looks safe to me.
2023-05-20avr: fix interrupt names for newer attiny chipsAyke van Laethem
This only affects chips that aren't supported by TinyGo yet, so this should be a safe change. Importantly, it fixes interrupts on the ATtiny1616.
2023-05-04tools: add sizediff toolAyke van Laethem
This tool can be very useful to compare binary sizes as output by `-size=short`. This is a tool I wrote a while ago. It's not perfect (we should probably use a geomean) but it works well enough to get a good idea on the binary size impact of a change.
2023-03-08builder: sizes: list interrupt vector as a pseudo-package for -size=fullAyke van Laethem
This is another bit of memory that is now correctly accounted for in `-size=full`.
2023-02-18Better handling of sub-clusters in SVD (#3335)Anton D. Kachalov
gen: Better handling of sub-clusters in SVD
2022-12-19build: generate files with go:build tagsYurii Soldak
2022-11-06avr: drop GNU toolchain dependencyAyke van Laethem
- Use compiler-rt and picolibc instead of avr-libc. - Use ld.lld instead of avr-ld (or avr-gcc). This makes it much easier to get started with TinyGo on AVR because installing these extra tools (gcc-avr, avr-libc) can be a hassle. It also opens the door for future improvements such as ThinLTO. There is a code size increase but I think it's worth it in the long run. The code size increase can hopefully be reduced with improvements to the LLVM AVR backend and to compiler-rt.
2022-08-07all: move from os.IsFoo to errors.Is(err, ErrFoo)Damian Gryski
2022-01-21Provide Set/Get for each register field described in SVD filesDmitriy
- rename Bitfield to Constant - add methods to the exiting types to set/get bitfields - integrate clustered registers - add cluster size to properly add filler at the end of the structure - fix structures with leading filler (i.e. for FICR_Type.INFO in nfr9160) - shorten the function name when prefix and suffix are identical. i.e. GetSTATE_STATE vs GetSTATE
2021-12-28rumtime: implement __sync libcalls as critical sectionsNia Waldvogel
This change implements __sync atomic polyfill libcalls by disabling interrupts. This was previously done in a limited capacity on some targets, but this change uses a go:generate to emit all of the calls on all microcontroller targets.
2021-12-23Merge duplicate registers into a single record and merge they bitfields.Dmitriy
2021-12-23Add *_Msk for each bit field and avoid duplicate fields in the output fileDmitriy
2021-11-06transform: refactor interrupt loweringAyke van Laethem
Instead of doing everything in the interrupt lowering pass, generate some more code in gen-device to declare interrupt handler functions and do some work in the compiler so that interrupt lowering becomes a lot simpler. This has several benefits: - Overall code is smaller, in particular the interrupt lowering pass. - The code should be a bit less "magical" and instead a bit easier to read. In particular, instead of having a magic runtime.callInterruptHandler (that is fully written by the interrupt lowering pass), the runtime calls a generated function like device/sifive.InterruptHandler where this switch already exists in code. - Debug information is improved. This can be helpful during actual debugging but is also useful for other uses of DWARF debug information. For an example on debug information improvement, this is what a backtrace might look like before this commit: Breakpoint 1, 0x00000b46 in UART0_IRQHandler () (gdb) bt #0 0x00000b46 in UART0_IRQHandler () #1 <signal handler called> [..etc] Notice that the debugger doesn't see the source code location where it has stopped. After this commit, breaking at the same line might look like this: Breakpoint 1, (*machine.UART).handleInterrupt (arg1=..., uart=<optimized out>) at /home/ayke/src/github.com/tinygo-org/tinygo/src/machine/machine_nrf.go:200 200 uart.Receive(byte(nrf.UART0.RXD.Get())) (gdb) bt #0 (*machine.UART).handleInterrupt (arg1=..., uart=<optimized out>) at /home/ayke/src/github.com/tinygo-org/tinygo/src/machine/machine_nrf.go:200 #1 UART0_IRQHandler () at /home/ayke/src/github.com/tinygo-org/tinygo/src/device/nrf/nrf51.go:176 #2 <signal handler called> [..etc] By now, the debugger sees an actual source location for UART0_IRQHandler (in the generated file) and an inlined function.
2021-10-27Fix gen-device-svd to handle 64-bitDmitriy Zakharkin
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-04-24gen-device: add extra constants and rename them to be Go styleAyke van Laethem
- Add some extra fields: FPUPresent, CPU and NVICPrioBits which may come in handy at a later time (and are easy to add). - Rename DEVICE to Device, to match Go style. This is in preparation to the next commit, which requires the FPUPresent flag.
2021-04-15cortexm: add __isr_vector symbolAyke van Laethem
This doesn't change the firmware, but it does make the disassembly of the ELF files. Before: Disassembly of section .text: 00000000 <(machine.UART).Write-0x100>: 0: 20001000 .word 0x20001000 4: 000009db .word 0x000009db 8: 00000f05 .word 0x00000f05 c: 00000f0b .word 0x00000f0b 10: 00000f05 .word 0x00000f05 After: Disassembly of section .text: 00000000 <__isr_vector>: 0: 20001000 .word 0x20001000 4: 000009db .word 0x000009db 8: 00000f05 .word 0x00000f05 c: 00000f0b .word 0x00000f0b 10: 00000f05 .word 0x00000f05 The difference is that the disassembler will now use a proper symbol name instead of using the closest by symbol (in this case, (machine.UART).Write). This makes the disassembly easier to read.
2021-03-09all: replace strings.Replace with strings.ReplaceAllAyke van Laethem
This was an addition to Go 1.13 and results in slightly easier to read code.
2021-02-03Fix multiline descriptionsAndre Sencioles
Move element description formatting to a function Export struct fields for use in the template Add template helper functions Multiline comments for interrupts and peripherals Export more fields Move comments to the top of each element Do not remove line breaks from descriptions The template code should gracefully handle line breaks now go fmt gen-device-svd.go
2021-01-09stm32: use stm32-rs SVDs which are of much higher qualityAyke van Laethem
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-06tools/gen: ignore cluster registers with no actual clusters in them, and ↵deadprogram
handle parsing binary integer fields in versions of Go before 1.13 Signed-off-by: deadprogram <[email protected]>
2020-10-10gen-device-svd: ensure enum bitfields are uniqueardnew
2020-08-31esp: add support for the Espressif ESP32 chipAyke van Laethem
This is only very minimal support. More support (such as tinygo flash, or peripheral access) should be added in later commits, to keep this one focused. Importantly, this commit changes the LLVM repo from llvm/llvm-project to tinygo-org/llvm-project. This provides a little bit of versioning in case something changes in the Espressif fork. If we want to upgrade to LLVM 11 it's easy to switch back to llvm/llvm-project until Espressif has updated their fork.
2020-07-11builder: try to determine stack size information at compile timeAyke van Laethem
For now, this is just an extra flag that can be used to print stack frame information, but this is intended to provide a way to determine stack sizes for goroutines at compile time in many cases. Stack sizes are often somewhere around 350 bytes so are in fact not all that big usually. Once this can be determined at compile time in many cases, it is possible to use this information when available and as a result increase the fallback stack size if the size cannot be determined at compile time. This should reduce stack overflows while at the same time reducing RAM consumption in many cases. Interesting output for testdata/channel.go: function stack usage (in bytes) Reset_Handler 332 .Lcommand-line-arguments.fastreceiver 220 .Lcommand-line-arguments.fastsender 192 .Lcommand-line-arguments.iterator 192 .Lcommand-line-arguments.main$1 184 .Lcommand-line-arguments.main$2 200 .Lcommand-line-arguments.main$3 200 .Lcommand-line-arguments.main$4 328 .Lcommand-line-arguments.receive 176 .Lcommand-line-arguments.selectDeadlock 72 .Lcommand-line-arguments.selectNoOp 72 .Lcommand-line-arguments.send 184 .Lcommand-line-arguments.sendComplex 192 .Lcommand-line-arguments.sender 192 .Lruntime.run$1 548 This shows that the stack size (if these numbers are correct) can in fact be determined automatically in many cases, especially for small goroutines. One of the great things about Go is lightweight goroutines, and reducing stack sizes is very important to make goroutines lightweight on microcontrollers.
2020-07-08Minimal NXP/Teensy supportEthan Reesor
2020-06-26gen-device-svd: fix lowercase in register spaced arrayYannis Huber
2020-06-08gen-device-svd: fix lowercase cluster nameYannis Huber
2020-06-08risc-v: add support for 64-bit RISC-V CPUsYannis Huber
2020-03-17avr: use the correct RAM start addressAyke van Laethem
Previously, the RAM was set to start at address 0. This is incorrect: on AVR, the first few addresses are taken up by memory-mapped I/O. The reason this didn't lead to problems (yet) was because the stack was usually big enough to avoid real problems.
2020-01-27runtime/fe310: add support for PLIC interruptsAyke van Laethem
This commit adds support for software vectoring in the PLIC interrupt. The interrupt table is created by the compiler, which leads to very compact code while retaining the flexibility that the interrupt API provides.
2020-01-20all: add compiler support for interruptsAyke van Laethem
This commit lets the compiler know about interrupts and allows optimizations to be performed based on that: interrupts are eliminated when they appear to be unused in a program. This is done with a new pseudo-call (runtime/interrupt.New) that is treated specially by the compiler.
2019-12-21tools: use byte padding to skip unused register rangesAyke van Laethem
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-14tools: rewrite gen-device-svd in GoAyke van Laethem
This should make it more maintainable. Another big advantage that generation time (including gofmt) is now 3 times faster. No real attempt at refactoring has been made, that will need to be done at a later time.
2019-12-07tools/gen-device-avr: process files in parallelAyke van Laethem
This significantly speeds up processing of the files.
2019-12-07tools: rewrite gen-device-avr in GoAyke van Laethem
This brings a big speedup. Not counting gofmt time, `make gen-device-avr` became about 3x faster. In the future, it might be an idea to generate the AST in-memory and write it out already formatted.
2019-12-04tools: avoid _paddingX in generated struct fieldsAyke van Laethem
This makes the generation script slightly simpler.
2019-10-09generator: handle fields that use bitRange element and ensure all caps for ↵Ron Evans
attributes that are not already capitalized or start with number. Also handle subclusters. Signed-off-by: Ron Evans <[email protected]>
2019-09-13tools/generator: correctly handle padding when it is 3 bytes longRon Evans
Signed-off-by: Ron Evans <[email protected]>
2019-08-27Fix a Python SyntaxWarning.Elliott Sales de Andrade
Using 'is' for literals is incorrect, and only should be done for singletons.
2019-08-26tools: make tools python2 compatibleAyke van Laethem
This allows the tools to be used for Python 2 and Python 3.
2019-07-07all: add HiFive1 rev B board with RISC-V architectureAyke van Laethem
This page has been a big help in adding support for this new chip: https://wiki.osdev.org/HiFive-1_Bare_Bones
2019-07-06tools/gen-device-svd: be a bit more forgiving for stm32 svd filesAyke van Laethem
Some newer files have a few mistakes. Allow them to be processed.
2019-07-06tools/gen-device-svd: refactor to make the code more declarativeAyke van Laethem