comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Arduino Due vs Mac
Date: Tue, 07 Jul 2015 12:08:50 +0100
Date: 2015-07-07T12:08:50+01:00	[thread overview]
Message-ID: <lyzj38w7gd.fsf@pushface.org> (raw)
In-Reply-To: ly8uatx9ea.fsf@pushface.org

Simon Wright <simon@pushface.org> writes:

> Maciej Sobczak <see.my.homepage@gmail.com> writes:
>
> What I did do is look again at https://github.com/shumatech/BOSSA.git
> and **check out the 'arduino' branch** (and compile with clang, not
> GCC!)
>
>> You should be able to upload any binary to the Arduino Due like this:
>>
>> $ bossac -e -w -v -U true -p tty.usbmodemfd131 -b program.bin
>>
>> Note: the USB device is a bit unpredictable, it might be
>> tty.usbmodemfd141 or something - I had to check the availability of
>> this special file name under /dev before every upload and use the
>> actual name that was there.
>
> If I leave out -U and -p this works (after a long pause while it scans
> through /dev/cu.Bluetooth- devices before finding /dev/cu.usbmodem1411
> (this seems stable for the Due programming port on the USB port nearer
> the front of the Macbook)).
>
> Now I have to find out why I'm getting 'Floating point exception: 8",
> but this is a huge improvement!

Turned out to be an integer division by zero if the number of Flash
pages to be written or verified was less than 10.

Now progressing to the point of having a blinking LED!!

As a matter of interest, I was able to write a simple program
initialization in Ada which, with minimal cooperation from the linker
script, lets me use gprbuild.

The linker script starts

   ENTRY(program_initialization)
   MEMORY
   {
       flash (RX)  : ORIGIN = 0x00080000, LENGTH = 512K
       sram (RWX)  : ORIGIN = 0x20070000, LENGTH = 96K
   }
   SECTIONS
   {
       .isr_vector :
       {
           . = ALIGN(4);
           LONG(_estack)
           LONG(program_initialization + 1)
           FILL(0)
           KEEP(*(.isr_vector))
       } > flash

       .text 0x00080100:

startup.ads:

   pragma Restrictions (No_Elaboration_Code);
   package Startup is
      procedure Program_Initialization
      with
        Export,
        Convention => C,
        External_Name => "program_initialization",
        No_Return;
   end Startup;

startup.adb:

   with System.Storage_Elements;
   package body Startup is

      --  Generated by gnatbind.
      procedure Main
      with
        Import,
        Convention => C,
        External_Name => "main",
        No_Return;

      procedure Program_Initialization is
         --  The following symbols are set up in the linker script:
         --
         --  _sidata: the start of read/write data in Flash, to be copied
         --           to SRAM
         --  _sdata:  where read/write data is to be copied to
         --  _edata: the first address after read/write data in SRAM
         --  _sbss:  the start of BSS (to be initialized to zero)
         --  _ebss:  the first address after BSS.

         use System.Storage_Elements;

         Sdata : Storage_Element
           with Import, Convention => C, External_Name => "_sdata";
         Edata : Storage_Element
           with Import, Convention => C, External_Name => "_edata";
         Sbss : Storage_Element
           with Import, Convention => C, External_Name => "_sbss";
         Ebss : Storage_Element
           with Import, Convention => C, External_Name => "_ebss";

         Data_Size : constant Storage_Offset := Edata'Address - Sdata'Address;

         --  Index from 1 so as to avoid subtracting 1 from the size
         Data_In_Flash : Storage_Array (1 .. Data_Size)
           with Import, Convention => C, External_Name => "_sidata";

         Data_In_Sram : Storage_Array (1 .. Data_Size)
           with Import, Convention => C, External_Name => "_sdata";

         Bss_Size : constant Storage_Offset := Ebss'Address - Sbss'Address;

         Bss : Storage_Array (1 .. Bss_Size)
           with Import, Convention => C, External_Name => "_sbss";
      begin
         Data_In_Sram := Data_In_Flash;
         Bss := (others => 0);
         Main;
      end Program_Initialization;

   end Startup;


  reply	other threads:[~2015-07-07 11:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 16:17 Arduino Due vs Mac Simon Wright
2015-07-06 16:24 ` Bob Duff
2015-07-06 20:59   ` Simon Wright
2015-07-06 18:03 ` Tero Koskinen
2015-07-06 21:08   ` Simon Wright
2015-07-08 17:22     ` darek
2015-07-09 20:27       ` Simon Wright
2015-07-11 13:35         ` Simon Wright
2015-07-11 17:55           ` darek
2015-07-06 20:34 ` Maciej Sobczak
2015-07-06 21:29   ` Simon Wright
2015-07-07 11:08     ` Simon Wright [this message]
2015-07-07 12:59 ` Jedi Tek'Unum
2015-07-07 15:32   ` Simon Wright
2015-07-07 21:12     ` Jedi Tek'Unum
2015-07-07 21:53       ` Simon Wright
2015-07-08 15:33         ` Jedi Tek'Unum
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox