ziutek / emgo Goto Github PK
View Code? Open in Web Editor NEWEmgo: Bare metal Go (language for programming embedded systems)
License: BSD 3-Clause "New" or "Revised" License
Emgo: Bare metal Go (language for programming embedded systems)
License: BSD 3-Clause "New" or "Revised" License
Michal, I am trying to compile a code with go routine - a very similar to the one which you have presented on your blog.
package main
import (
"delay"
"fmt"
"stm32/hal/gpio"
"stm32/hal/system"
"stm32/hal/system/timer/systick"
)
var led, led2 gpio.Pin
func init() {
system.SetupPLL(-48, 6, 20, 0, 0, 2) // 80 MHz (max. for voltage Range 1).
//system.Setup80(0, 0) // Short form of above configuration.
//system.SetupPLL(-4, 1, 26, 0, 0, 4) // 26 MHz (max. for voltage Range 2).
system.SetupMSI(100) // Lowest possible frequency (100 kHz).
systick.Setup(2e7) // Typical 2e6 ns is to low for 100 kHz SysClk.
gpio.A.EnableClock(false)
led = gpio.A.Pin(5)
led2 = gpio.A.Pin(6)
cfg := gpio.Config{Mode: gpio.Out, Speed: gpio.Low}
led.Setup(&cfg)
// cfg2 := gpio.Config{Mode: gpio.Out, Driver: gpio.OpenDrain}
led2.Setup(&cfg)
}
func blinky(led gpio.Pin, period int) {
for {
led.Clear()
delay.Millisec(100)
led.Set()
delay.Millisec(period - 100)
}
}
func main() {
delay.Millisec(500)
buses := []system.Bus{
system.Core,
system.AHB,
system.APB1,
system.APB2,
}
fmt.Printf("\r\n")
for _, bus := range buses {
fmt.Printf("%4s: %9d Hz\r\n", bus, bus.Clock())
}
go blinky(led, 500)
blinky(led2, 1000)
}
script.ld:
ISRStack = 2048;
MainStack = 8192;
TaskStack = 1024;
MaxTasks = 4;
INCLUDE stm32/l476xg
INCLUDE stm32/loadflash
INCLUDE noos-cortexm
Unfortunately, I am getting compilation errors all the time (even for the example code from: "f030-demo-board/demo").
/tmp/eg-build977705888/main/__noos_cortexm4f_l476xx.o: In function `main$main':
emgo/egpath/src/stm32/examples/nucleo-l476rg/blinky/__noos_cortexm4f_l476xx.c:64: undefined reference to `internal$NewTask'
/tmp/eg-build490269123/main/__noos_cortexm0_f030x6.o: In function `main$main':
emgo/egpath/src/stm32/examples/f030-demo-board/demo/__noos_cortexm0_f030x6.c:88: undefined reference to `internal$NewTask'
emgo/egpath/src/stm32/examples/f030-demo-board/demo/__noos_cortexm0_f030x6.c:96: undefined reference to `internal$NewTask'
I am using the newest gcc-arm-none-eabi toolchain: gcc-arm-none-eabi-7-2017-q4-major and go version 1.9.5.
Am I doing something wrong or is there something missing in the repository?
I would like to use EMGO with one of the supported STM32 MTUs, alongside WiFi module (SPWF04 for example).
Does EMGO support WiFi?
What modules are supported if it does?
Hi, Just would like to let you know the thanks for the great work bringing the golang to the bare metal world! Really appreciated your work!
I'm building it on windows. Though, the note say it is run under cygwin, really it can just use the raw windows cmd window. Because both the cross-toolchain and the go-sdk installed are for raw windows. The notes is here: https://github.com/minghuadev/emgo/blob/minghuadev-notes/localnotes-win-cygwin.md
In either case, building the stm32/examples/f4-explorer/blinky sample will hit a linker line too long error. The reason is that all the lists of dependents for every package are concatenated together such that some packages appeared too many times on the command line. And the windows clearly cannot cope with it.
I'm using this patch to get it work around:
--- a/egc/buildtools.go
+++ b/egc/buildtools.go
@@ -240,6 +240,20 @@ func (bt *BuildTools) Link(e string, imports []string, o ...string) error {
if err != nil {
return err
}
+ // eliminate duplicate elements.
+ a = func(b []string) ([]string) {
+ rv := make([]string, 0)
+ regm := make(map[string]int)
+ for _,x := range b {
+ if _,ok := regm[x]; !ok {
+ rv = append(rv, x)
+ regm[x] = 1
+ }
+ }
+ return rv
+ }(a)
+ // then supply the list twice for linker to find earlier dependants
+ args = append(args, a...)
args = append(args, a...)
if bt.LDlibgcc != "" {
Since I'm not very good at golang, this may not be the best fix. Hope a better patch can be applied.
If you wonder, I'm thinking of porting it to picorv32 or myblaze. A long way ahead.
Thanks.
I've got an stm32f469 discovery board, I've added preliminary support for the chip and can successfully run blinky.
I'm trying to write a driver for the dsi display peripheral, and stm32xgen doesn't seem to handle its registers properly, along with perhaps a lot of other registers. The common factor seems to be registers which expose individual bits I think? like this:
7591 #define DSI_GPDR_DATA1_Pos (0U)
7592 #define DSI_GPDR_DATA1_Msk (0xFFU << DSI_GPDR_DATA1_Pos) /*!< 0x000000FF */
7593 #define DSI_GPDR_DATA1 DSI_GPDR_DATA1_Msk /*!< Payload Byte 1 */
7594 #define DSI_GPDR_DATA1_0 (0x01U << DSI_GPDR_DATA1_Pos) /*!< 0x00000001 */
7595 #define DSI_GPDR_DATA1_1 (0x02U << DSI_GPDR_DATA1_Pos) /*!< 0x00000002 */
7596 #define DSI_GPDR_DATA1_2 (0x04U << DSI_GPDR_DATA1_Pos) /*!< 0x00000004 */
7597 #define DSI_GPDR_DATA1_3 (0x08U << DSI_GPDR_DATA1_Pos) /*!< 0x00000008 */
7598 #define DSI_GPDR_DATA1_4 (0x10U << DSI_GPDR_DATA1_Pos) /*!< 0x00000010 */
7599 #define DSI_GPDR_DATA1_5 (0x20U << DSI_GPDR_DATA1_Pos) /*!< 0x00000020 */
7600 #define DSI_GPDR_DATA1_6 (0x40U << DSI_GPDR_DATA1_Pos) /*!< 0x00000040 */
7601 #define DSI_GPDR_DATA1_7 (0x80U << DSI_GPDR_DATA1_Pos) /*!< 0x00000080 */
Bad bitmask 0x01U << DSI_GPDR_DATA1_Pos : strconv.ParseUint: parsing "0x01U << DSI_GPDR_DATA1_Pos": invalid syntax
Bad bitmask 0x02U << DSI_GPDR_DATA1_Pos : strconv.ParseUint: parsing "0x02U << DSI_GPDR_DATA1_Pos": invalid syntax
Bad bitmask 0x04U << DSI_GPDR_DATA1_Pos : strconv.ParseUint: parsing "0x04U << DSI_GPDR_DATA1_Pos": invalid syntax
Bad bitmask 0x08U << DSI_GPDR_DATA1_Pos : strconv.ParseUint: parsing "0x08U << DSI_GPDR_DATA1_Pos": invalid syntax
Bad bitmask 0x10U << DSI_GPDR_DATA1_Pos : strconv.ParseUint: parsing "0x10U << DSI_GPDR_DATA1_Pos": invalid syntax
Bad bitmask 0x20U << DSI_GPDR_DATA1_Pos : strconv.ParseUint: parsing "0x20U << DSI_GPDR_DATA1_Pos": invalid syntax
Bad bitmask 0x40U << DSI_GPDR_DATA1_Pos : strconv.ParseUint: parsing "0x40U << DSI_GPDR_DATA1_Pos": invalid syntax
Bad bitmask 0x80U << DSI_GPDR_DATA1_Pos : strconv.ParseUint: parsing "0x80U << DSI_GPDR_DATA1_Pos": invalid syntax
The generated dsi.go has a bunch of constants with the same name, and I get a ton of errors:
src/stm32/hal/raw/dsi/f469xx--dsi.go:110:2: other declaration of VCID
src/github.com/ianmcmahon/emgo/egpath/src/stm32/hal/raw/dsi/f469xx--dsi.go:192:2: VCID0 redeclared in this block
src/github.com/ianmcmahon/emgo/egpath/src/stm32/hal/raw/dsi/f469xx--dsi.go:111:2: other declaration of VCID0
src/github.com/ianmcmahon/emgo/egpath/src/stm32/hal/raw/dsi/f469xx--dsi.go:193:2: VCID1 redeclared in this block
src/github.com/ianmcmahon/emgo/egpath/src/stm32/hal/raw/dsi/f469xx--dsi.go:112:2: other declaration of VCID1
src/github.com/ianmcmahon/emgo/egpath/src/stm32/hal/raw/dsi/f469xx--dsi.go:197:2: VCIDn redeclared in this block
src/github.com/ianmcmahon/emgo/egpath/src/stm32/hal/raw/dsi/f469xx--dsi.go:116:2: other declaration of VCIDn
src/github.com/ianmcmahon/emgo/egpath/src/stm32/hal/raw/dsi/f469xx--dsi.go:509:2: VCID redeclared in this block
src/github.com/ianmcmahon/emgo/egpath/src/stm32/hal/raw/dsi/f469xx--dsi.go:110:2: other declaration of VCID
src/github.com/ianmcmahon/emgo/egpath/src/stm32/hal/raw/dsi/f469xx--dsi.go:510:2: VCID0 redeclared in this block
etc
I'm looking at stm32xgen's parser and trying to understand how to correct this, but it's a bit hard to follow. Any suggestions?
Is there plans for adding support for the ESP8266 wifi chips?
It's very popular and I think it would be a great candidate for emgo!
hello,first it is a wonderful project,i has hate to use c to write Embedded program。
i find you use xgen to create sdk .go file by register config .go file。
now i want to add something in register config .go file
how can i use xgen to update sdk .go file like xgen_ficr.go
Hello,
first of, really great and interesting project. Thanks for the awesome work
I'm trying to add support for stm32f030x8 but I can't find any documentation on how to do it. I found a script in emgo/egpath/src/stm32/xgen/run.sh
and added
stm32xgen stm32/o/f030x8 <stm32f0xx/stm32f030x8.h
line to it.
I ran the script, it generated some errors but I didn't find for example the f030x8--mmap.go
file in:
emgo/egpath/src/stm32/hal/raw/mmap
I've successfully installed xgen
and stm32xgen
in my $GOPATH, so they are running fine and are found by the script.
The errors which generated can be found in this gist: https://gist.github.com/ironsteel/64bdaa091b2593e7ce6225e25faa4170
Help would be really appreciated. If you need more info I'll be happy to provide it to you.
Hey, is it possible to use emgo on a Nucleo l073rz ? Thanks
hi ,
i just came accross this and would like to know if i can use this for stm32h743bit6 cortexM7 processor ?
Thanks in advance
Celia
Are there any plans for generating board/arch definitions using SVD files? The Rust embedded effort uses a tool called svd2rust to generate type safe memory mappings (I’m not familiar with all the details in Rust as I’m a Go developer).
There is other project to bring GO to microcontrollers: https://github.com/aykevl/tinygo. Have you seen it? What is your opinion about it? I am just curious because you try to do the same thing but from different approach. Maybe you can work together for more productive results?
Hello, i have board STM32 Nucleo f767zi.
I want to make http-client on this board. In C/C++, i can use LWIP library, but i'm not found similar features in Emgo.
How can i make http-client by Emgo?
First of all, kudos for creating this great project. In the long term, this can be the beginning of something very big for the Go community, allowing the programming of limited resources microcontrollers.
In that sense, do you have any technical, rationale or "how does it work" (internals) documentation. I want to study the system and maybe start a port to another target MCU.
As I see it, you have here a mix of Go compiler and embedded framework. To allow the project to grow coherently, I mean with new targets/ports, without making the codebase too complicated, it'll be interesting to decouple as much as possible the "compiler" from the "embedded framework" part.
Also, if you are interested in creating a small community, I humbly suggest you start creating some wiki pages with basic information and, most important, a TODO list of easy things for others to contribute.
Again, thanks for your work!
Jose
Hello Michal,
In README.MD you wrote:
There is a set of scripts for any board in example directory that simplifies loding and debuging process. The load-oocd.sh and swo-oocd.sh scripts can handle SWO output from ITM (Instrumentation Trace Macrocell) but needs itmsplit to convert binary stream to readable messages. SWO is very useful for debuging and fmt.Print* functions by default use ITM trace port as standard output.
Could you write in steps how to get that output? I'm using usart example with Nucleo-L476RG but after some time my board stops working so I'm trying to debug it. Unfortunately, I haven't figured out how to get SWO working - I have tried your scripts but it seems that I am not able to get it working.
I would really appreciate if you could write steps starting from flashing a microcontroller (maybe I am just missing something).
I just noticed this project, it looks cool, but documentation is a little bit sparse.
Is there one page summary about differences between Emgo and Go?
I need the rcc_ex and dsi/lcd drivers that exist in the STM32F4xx_HAL_Driver package from ST. They're simple in that they only set configuration registers, but complicated as hell with regards to porting to go. I started porting it over, but I feel like this is the wrong way to go. Is it possible to include those C files in what egc builds?
Since the main Go doesn't compile to native wasm, only a variant that runs in a web browser. I was wondering if this project had any plans of supporting native wasm target
When LICENSE is properly applied to the repo, GitHub shows the name of the license of the top right of repo homepage. For this repo this is not the case. It is forcing me to google the sentences from license to see what it is and compare it word-by-word to see if anything else is modified from the original license.
in nrf5 example i find two example ble-advert and ble-connect,i cant understand how to work.
in my mind,i think it use bluetooth protocol stack in nrf5 flash. but it seem it use your own bluetooth protocol stack.
my problem is how can i use bluetooth protocol stack in nrf5 flash like nrf5 sdk.
if it is not a good way how can i use bluetooth. for example set Advertising interval ,Advertising_Type。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.