Re: Creating a microcontroller startup file

2015-04-10 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 23:18:41 UTC, Mike wrote: You may also wnat to compile with -nodefaultlibs -nostdlib -nostartfiles. That removes the cruntime and libgcc. I forgot about those. Yes, when excluded those and added a /DISCARD/ for the exidx and armexidx, I finally got rid of the

Re: Creating a microcontroller startup file

2015-04-10 Thread Jens Bauer via Digitalmars-d-learn
On Thursday, 9 April 2015 at 10:47:42 UTC, Artur Skawina wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: -It would be neat, if @attribute(weak) and @attribute(alias,function) could be combined into one, but I haven't found a way to do that

Re: Creating a microcontroller startup file

2015-04-10 Thread Jens Bauer via Digitalmars-d-learn
On Friday, 10 April 2015 at 00:05:29 UTC, Mike wrote: On Wednesday, 8 April 2015 at 15:25:20 UTC, Jens Bauer wrote: Question number 2: Is it possible to change the VectorFunc to be a real function pointer, rather than a void* ? Can you successfully cast(ISR)_stack ? I don't know if that's

Re: Creating a microcontroller startup file

2015-04-09 Thread Artur Skawina via Digitalmars-d-learn
On 04/08/15 18:10, Jens Bauer via Digitalmars-d-learn wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: enum weak = gcc.attribute.attribute(weak); enum isrDefault = gcc.attribute.attribute(alias, defaultHandler);

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 2: Is it possible to change the VectorFunc to be a real function pointer, rather than a void* ? I did something along these lines (modified to match your example) and it worked fine for me: alias VectorFunc =

Re: Creating a microcontroller startup file

2015-04-08 Thread Johannes Pfau via Digitalmars-d-learn
Am Tue, 07 Apr 2015 20:38:52 + schrieb Jens Bauer doc...@who.no: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 1: How can a C subroutine be made optional, so it's called only if it linked ? Question 1 might be answered by the following thread:

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 08:02:35 UTC, Johannes Pfau wrote: I actually saw these errors when I first tested your examples, but I thought that was a mistake in the example code. I didn't even know that extern weak symbols get default values in C ;-) Don't feel bad about that. I think I

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
Something tells me that now is when I have to start doing some hard work. ;) -Sorry, I need to split this up into short replies/questions. On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 2: Is it possible to

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 2: Is it possible to change the VectorFunc to be a real function pointer, rather than a void* ? I did something along these lines (modified to match your

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: I did something along these lines (modified to match your example) and it worked fine for me: alias VectorFunc = void function(); @attribute(weak) @attribute(alias, defaultHandler) extern void Reset_Handler(); Strange; I can't get it

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 3: How can I call an external function and keep the binary file size down ? Are you compiling with -ffunction-sections -fdata-sections and linking with

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: enum weak = gcc.attribute.attribute(weak); enum isrDefault = gcc.attribute.attribute(alias, defaultHandler); extern @weak @isrDefault void NMI_Handler(); extern @weak

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 15:53:37 UTC, Jens Bauer wrote: [snip] I find it strange that calling an empty function outside the source file will cause that huge difference. -But of course, there's a logic explanation somewhere. ;) It might be caused by the linker script; I'll try and see if I

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 16:10:53 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: -I actually added @attribute(naked) to my defaultResetHandler yesterday, as I wanted to get rid of the prologue;

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 23:23:53 UTC, Mike wrote: I actually added that out of necessity, not optimization. Id I use the STM32, and reset the MCU, the CCRAM is disabled by default. Since my stack is in CCRAM, I need to first enable it before any functions can be called. According to

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 15:44:00 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: I did something along these lines (modified to match your example) and it worked fine for me: alias VectorFunc = void function(); @attribute(weak) @attribute(alias,

Re: Creating a microcontroller startup file

2015-04-08 Thread Jens Bauer via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 23:28:45 UTC, Mike wrote: If I use the STM32 system bootloader, and reset the MCU, the CCRAM is disabled by default. I see. That is absolutely incorrect behaviour of the bootloader. A bootloader should only change the things that are absolutely necessary to

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 17:45:01 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 15:53:37 UTC, Jens Bauer wrote: [snip] I find it strange that calling an empty function outside the source file will cause that huge difference. -But of course, there's a logic explanation somewhere. ;)

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Thursday, 9 April 2015 at 00:37:32 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 23:23:53 UTC, Mike wrote: I actually added that out of necessity, not optimization. Id I use the STM32, and reset the MCU, the CCRAM is disabled by default. Since my stack is in CCRAM, I need to first

Re: Creating a microcontroller startup file

2015-04-08 Thread Mike via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 23:23:53 UTC, Mike wrote: On Wednesday, 8 April 2015 at 16:10:53 UTC, Jens Bauer wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: -I actually added @attribute(naked) to my

Re: Creating a microcontroller startup file

2015-04-07 Thread Jens Bauer via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 1: How can a C subroutine be made optional, so it's called only if it linked ? Question 1 might be answered by the following thread: http://forum.dlang.org/thread/mg1bad$30uk$1...@digitalmars.com -So no need to answer

Creating a microcontroller startup file

2015-04-07 Thread Jens Bauer via Digitalmars-d-learn
I'm currently working on a startup file for Cortex-M. Thanks to Johannes, I'm now able to implement almost everything I need. While the most important part of the code code works, there are still a few things, that I would like added/changed. Here's a cut-down version of a start.d:

Re: Creating a microcontroller startup file

2015-04-07 Thread Rikki Cattermole via Digitalmars-d-learn
On 8/04/2015 8:38 a.m., Jens Bauer wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 1: How can a C subroutine be made optional, so it's called only if it linked ? Question 1 might be answered by the following thread: