Open bradleypeabody opened 2 years ago
The biggest immediate difference for custom boards is one cannot make assumptions about pin assignments or SERCOMs and the various things that use them (UART, SPI and I2C buses or anything else). This means that UARTs, SPIs, etc. need to be fully definable in user code. This is not terribly hard to do, but there are little things like the interrupt handler func for the UART on SAM microcontrollers is not exported (handleInterrupt).
I'm not quite understanding what you mean. Aren't peripherals consistent for a processor? TinyGo already separates what is machine
vs. what is board
. machine/machine_*
files contain hardware definitions which are constant for the processor, on the other hand machine/board_*
files have board specific definitions which may vary for a processor depending on the board it's on. To develop on a custom board one usually sets the environment with the processor as the target, for example, for the Raspberry Pi Pico's processor this would be the rp2040
target.
@soypat On a SAM microcontroller, for each device (UART, I2C, SPI, etc.) you want to use, you have to pick one of several "SERCOM"s, put it in the appropriate mode and settings and pick which pins it goes on (and internally there are few other things it does like selecting the "pad" for each pin).
As it stands right now (or at least the result of when I tested this earlier): If I specify "atsamd51j19a" as the target, I get compile errors because putchar
references a device that isn't present because no UART is defined (since this is done in the "board_" files but there is no board for these raw MCU targets). If this is supposed to work, I can try it again and dig up the exact error message and what I did to get it, I just got the idea from what I was seeing that this approach wasn't supported. (I also didn't see any documentation on this approach, which is part of what led me to that conclusion.)
I've been using TinyGo to develop firmware for a custom board based on the ATSAMD51. Overall it's been an awesome experience.
Some of the changes necessary have required forking TinyGo to get everything working right. I wanted to summarize those points here and see if there is interest in resolving them and get any guidance on the direction for each.
handleInterrupt
).print()
and friends would need to write to something which is user-definable (I'm thinking an instance of an interface with a Write and/or WriteByte method), so after the appropriate setup one could do something like "machine.DefaultPrinter = &myCustomUART". And by default it could just not send anywhere or maybe panic with a "must set DefaultPrinter before print()ing" message. Perhaps this behavior could correspond to a command line option like-serial=custom
runtime
internals, so it can't be (entirely) a third party package.objdump -S
on an ELF output from TinyGo to find which function it was in (and a rough guess from the asm what the corresponding code was). It would be great if this process were simpler. I realize debugging it's own thing, but I think this mapping of the PC back to a file:line could be really useful.So overall my question is: do these seem like things I should do changes and PRs for and try to get things to the point where custom boards (at least starting with those based on SAM chips) are supported out the box? And also some of the debug tooling mentioned above? If so, I'll see about setting aside some time to clean up the changes I made into merge-able PRs and originate any other discussion about the design of some of these things where needed.