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 (no phobos, no runtime, nothing but what I type myself) compiled and executed on my STM32F4-based hardware. I know the toolchain 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 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
}

_stack_end = ORIGIN(CCRAM) + LENGTH(CCRAM);

SECTIONS
{
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector))
    . = ALIGN(4);
  } >FLASH

  .text :
  {
    . = ALIGN(4);
    KEEP(*(.interrupt_vector))
    *(.text)
    *(.text*)
    *(.rodata)
    *(.rodata*)
    . = ALIGN(4);
  } > flash  
}

Can anyone out them tell me if/how this can be accomplished in D?

Is there some syntax equivalent to __attribute__ ((section(".interrupt_vector")))?

Would the following give me a minimal reset_handler?

// compile with: ldc2 -c -nodefaultlib -noruntime
module reset_handler;

extern(C) __gshared void * _Dmodule_ref;
extern(C) void reset_handler()
{ }

I've seen some examples out on the web, but they all either use C, or are written specifically for an x86/x86_64 platform. So any help you could provide would be great to help me get started.

Reply via email to