Thread overview | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
November 24, 2013 Need help making minimal bare metal ARM Cortex-M D program | ||||
---|---|---|---|---|
| ||||
I am very new to D, but I finally got my toolchain compiled and working. I'm using LDC. I failed with GDC and eventually gave up. I am trying to get an _extremely_ minimal bare metal ARM Cortex-M HelloWorld-type program compiled and executed on my STM32F4-based hardware. I know the toochain is buggy for arm right now, but I'm hoping I can do something about that if I can just get started. Here's the basic C code and linker script for my hardware. It doesn't actually print "hello world". I intend to add that after I get the following basic code compiled and downloaded to my hardware. /*************************** * start.c ****************************/ // defined in linker script extern unsigned long _stack_end; void handler_reset(void) { //Print hello world using SWI } __attribute__ ((section(".interrupt_vector"))) void (* const table_interrupt_vector[])(void) = { (void *) &_stack_end, handler_reset }; /*************************** * linkerscript.ld ****************************/ MEMORY { CCRAM (rxw) : ORIGIN = 0x10000000, LENGTH = 64k SRAM (rxw) : ORIGIN = 0x20000000, LENGTH = 128k FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024k } SECTIONS { .ccm (NOLOAD) : { . = ALIGN(4); *(.ccm) . = ALIGN(4); } >CCRAM stackTop = ORIGIN(CCRAM) + LENGTH(CCRAM); |
November 24, 2013 Re: Need help making minimal bare metal ARM Cortex-M D program | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | Please delete this thread. I hit a tab and a space while typing my code, resulting in a premature submit. I will make a separate complete post. Sorry, Mike |
November 24, 2013 Re: Need help making minimal bare metal ARM Cortex-M D program | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | On Sunday, 24 November 2013 at 12:45:19 UTC, Mike wrote:
> Please delete this thread. I hit a tab and a space while typing my code, resulting in a premature submit. I will make a separate complete post.
>
> Sorry,
> Mike
This is a mailing list, not a forum. We can't delete things here. :o)
|
November 24, 2013 Re: Need help making minimal bare metal ARM Cortex-M D program | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | On Sunday, 24 November 2013 at 12:43:01 UTC, Mike wrote:
> I am very new to D, but I finally got my toolchain compiled and working. I'm using LDC. I failed with GDC and eventually gave up.
>
I know Johannes has some patches yet to trickle down into gdc. And druntime is does not support ARM fully in 2.063, but it would be helpful if you could take some time to let people know what went wrong when you tried things, rather than just giving up. Otherwise, nothing will get fixed.
|
November 24, 2013 Re: Need help making minimal bare metal ARM Cortex-M D program | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On Sunday, 24 November 2013 at 12:53:42 UTC, Iain Buclaw wrote: > On Sunday, 24 November 2013 at 12:43:01 UTC, Mike wrote: >> I am very new to D, but I finally got my toolchain compiled and working. I'm using LDC. I failed with GDC and eventually gave up. >> > > I know Johannes has some patches yet to trickle down into gdc. And druntime is does not support ARM fully in 2.063, but it would be helpful if you could take some time to let people know what went wrong when you tried things, rather than just giving up. Otherwise, nothing will get fixed. I don't think the problems I encountered with GDC were the fault of GDC. They were my fault. I have more to learn about the Linux platform. It seems the GCC toolchain is highly dependent on the host platform and if things aren't set up just right, you get errors that have nothing to do with the actual problem. Also, when I tried to follow the crosstools instructions here (http://wiki.dlang.org/GDC/Cross_Compiler) I found that the latest crosstools was missing some of the options that are needed. I have been quite successful using the GNU Tools for ARM Embedded Processors here (https://launchpad.net/gcc-arm-embedded), and I hope to merge this with the GDC code and give it another try. I tried it this weekend, but I wasn't even able to get the shell scripts to run without errors. And, I didn't JUST give up. I worked on it all weekend, every weekend, for the past 3 weeks. I'm tired of the platform dependencies, and I'm anxious to just get started. Once I get more familiar with D and have some working code, I'll give GDC another try. |
November 24, 2013 Re: Need help making minimal bare metal ARM Cortex-M D program | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | Am Sun, 24 Nov 2013 14:19:43 +0100 schrieb "Mike" <none@none.com>: > On Sunday, 24 November 2013 at 12:53:42 UTC, Iain Buclaw wrote: > > On Sunday, 24 November 2013 at 12:43:01 UTC, Mike wrote: > >> I am very new to D, but I finally got my toolchain compiled and working. I'm using LDC. I failed with GDC and eventually gave up. > >> > > > > I know Johannes has some patches yet to trickle down into gdc. And druntime is does not support ARM fully in 2.063, but it would be helpful if you could take some time to let people know what went wrong when you tried things, rather than just giving up. Otherwise, nothing will get fixed. Cortex-M is the 'bare metal' branch of ARM where you usually don't run linux so druntime won't work anyway. There are some compiler fixes in my branch that could be interesting though: https://github.com/jpf91/GDC/commits/arm BTW: I'll start merging back the fixes to gdc master this week. Some fixes have to be merged into phobos upstream though so it might take some time. > > I don't think the problems I encountered with GDC were the fault of GDC. They were my fault. I have more to learn about the Linux platform. It seems the GCC toolchain is highly dependent on the host platform and if things aren't set up just right, you get errors that have nothing to do with the actual problem. > > Also, when I tried to follow the crosstools instructions here (http://wiki.dlang.org/GDC/Cross_Compiler) I found that the latest crosstools was missing some of the options that are needed. You mean options for bare metal builds or options described in the wiki? I'm not sure if crosstool-NG works well with bare metal builds. > > I have been quite successful using the GNU Tools for ARM Embedded Processors here (https://launchpad.net/gcc-arm-embedded), and I hope to merge this with the GDC code and give it another try. I tried it this weekend, but I wasn't even able to get the shell scripts to run without errors. > > And, I didn't JUST give up. I worked on it all weekend, every weekend, for the past 3 weeks. I'm tired of the platform dependencies, and I'm anxious to just get started. Once I get more familiar with D and have some working code, I'll give GDC another try. > GCC build scripts can be annoying, especially when cross-compiling. Your best bet is still crosstool-NG though, what exactly are the missing options? |
November 24, 2013 Re: Need help making minimal bare metal ARM Cortex-M D program | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau | On Sunday, 24 November 2013 at 14:21:57 UTC, Johannes Pfau wrote: > Cortex-M is the 'bare metal' branch of ARM where you usually don't run > linux so druntime won't work anyway. There are some compiler fixes in > my branch that could be interesting though: > https://github.com/jpf91/GDC/commits/arm > I'm aware of the druntime will not work, which is why I'm trying to find a way to write and compile code _without_ the druntime or phobos. See my re-post. >> Also, when I tried to follow the crosstools instructions here (http://wiki.dlang.org/GDC/Cross_Compiler) I found that the latest crosstools was missing some of the options that are needed. > > You mean options for bare metal builds or options described in the > wiki? I'm not sure if crosstool-NG works well with bare metal builds. > > GCC build scripts can be annoying, especially when cross-compiling. > Your best bet is still crosstool-NG though, what exactly are the > missing options? A couple of the options don't seem to exist in crosstools. Specifically "Go to C compiler, select Other languages and enter d". Pretty hard to tell the compiler to support D without this option. The GNU Tools for ARM scripts are specifically written for cross-compiling, and even Canadian cross compiling. When I run the build scripts, I get: cat ~/mylongdir/src/gcc/gcc/BASE-VER: No such file or directory. I looked through the shell script, but code like this GCC_VER=`cat $SRCDIR/$GCC/gcc/BASE-VER` GCC_VER_NAME=`echo $GCC_VER | cut -d'.' -f1,2 | sed -e 's/\./_/g'` is a little hard for me to figure out. Again, the problem here is not with GDC; it's that I don't know enough about the Linux tools to know what its trying to do here and what I can do about it. LLVM, clang, and LDC built on the first try after 3 weekends struggling with GCC. |
November 24, 2013 Re: Need help making minimal bare metal ARM Cortex-M D program | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | > A couple of the options don't seem to exist in crosstools. Specifically "Go to C compiler, select Other languages and enter d". Pretty hard to tell the compiler to support D without this option.
Have you set 'Try features marked as EXPERIMENTAL'?
Are you using a recent version of crosstool-NG? And in case
this isn't clear, there isn't a 'D' option to choose from,
you need to type 'D' into the field.
|
November 24, 2013 Re: Need help making minimal bare metal ARM Cortex-M D program | ||||
---|---|---|---|---|
| ||||
Posted in reply to jerro | On Sunday, 24 November 2013 at 15:32:04 UTC, jerro wrote:
>> A couple of the options don't seem to exist in crosstools. Specifically "Go to C compiler, select Other languages and enter d". Pretty hard to tell the compiler to support D without this option.
>
> Have you set 'Try features marked as EXPERIMENTAL'?
> Are you using a recent version of crosstool-NG? And in case
> this isn't clear, there isn't a 'D' option to choose from,
> you need to type 'D' into the field.
Yes, I tried experimental features, obsolete features, and number of other things. I know there isn't a D option to check. I was fully expecting a text field to type the letter 'D' into, but the "Other languages" option does not exist. It appears to have been replaced with a "C++" check option.
Give it a try yourself, and you'll see what I mean.
|
November 24, 2013 Re: Need help making minimal bare metal ARM Cortex-M D program | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike | It seems languages other than C are disabled for bare metal builds. You could try searching for cc.ini in your crosstool-ng installation and commenting out the line if ! BARE_METAL and endif # ! BARE_METAL |
Copyright © 1999-2021 by the D Language Foundation