-
Notifications
You must be signed in to change notification settings - Fork 961
//go:section pragma #1759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
//go:section pragma #1759
Conversation
nice! |
I'll try it later. |
I've updated the 'persistent ram' prototype to use this mechanism: #1715 Seems to work fine. |
@aykevl one more merge conflict needs to be resolved, please. |
The following source code worked fine.
//go:section .canram
//go:align 4
var CANRxFifo [2][1024]byte
//go:section .canram
//go:align 4
var CANTxFifo [2][1024]byte
//go:section .canram
//go:align 4
var CANEvFifo [2][1024]byte |
@aykevl reminder this has merge conflict that needs resolution, please. |
With the following code, I was able to place the variable dummy in .text. package main
import (
"fmt"
"machine"
"time"
)
//go:section .constdata
var dummy = []byte("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")
func main() {
led := machine.LED
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
for {
led.Toggle()
println("hello world!")
fmt.Printf("%p %q\r\n", &dummy, string(dummy))
time.Sleep(time.Second)
}
}
|
@aykevl |
These pragmas weren't really tested anywhere, except that some code might break if they are not properly applied. These tests make it easy to see they work correctly and also provide a logical place to add new pragma tests. I've also made a slight change to how functions and globals are created: with the change they're also created in the IR even if they're not referenced. This makes testing easier.
I have rebased the PR to resolve the merge conflict.
Hmm, this can be a problem. Maybe |
Absolutely yes, this should also require |
This patch adds a new pragma for functions and globals to set the section name. This can be useful to place a function or global in a special device specific section, for example: * Functions may be placed in RAM to make them run faster, or in flash (if RAM is the default) to not let them take up RAM. * DMA memory may only be placed in a special memory area. * Some RAM may be faster than other RAM, and some globals may be performance critical thus placing them in this special RAM area can help. * Some (large) global variables may need to be placed in external RAM, which can be done by placing them in a special section. To use it, you have to place a function or global in a special section, for example: //go:section .externalram var externalRAMBuffer [1024]byte This can then be placed in a special section of the linker script, for example something like this: .bss.extram (NOLOAD) : { *(.externalram) } > ERAM
Okay, I've updated it to require an import of |
Thanks @aykevl for the revisions. Now merging. |
This PR adds a new pragma for functions and globals to set the
section name. This can be useful to place a function or global in a
special device specific section, for example:
(if RAM is the default) to not let them take up RAM.
performance critical thus placing them in this special RAM area can
help.
which can be done by placing them in a special section.
To use it, you have to place a function or global in a special section,
for example:
This can then be placed in a special section of the linker script, for
example something like this:
This PR also adds some testing for pragmas, for regression testing.