Forum > Embedded - ARM

Arduino DUE

(1/5) > >>

Mathias:
I'm trying to build a flasher with the Arduino DUE, but unfortunately I don't see any reaction on the LED13.
Does anyone have a tip on what I'm doing wrong?

I tried to convert the following code from GITHUB to Lazarus.
https://github.com/marangisto/blink-sam3x8e

My cross compiler compiles everything smoothly.



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program Project1; {$H-,J-,O-} uses  cortexm3;   procedure Delay;  var    i: uint32;  begin    for i := 0 to 1000000 do begin      asm               Nop end; // Leerbefehl    end;  end; begin  PIOB.PER := $FFFFFFFF;  PIOB.OER := $FFFFFFFF;   PIOB.SODR := 0;  repeat    PIOB.SODR := $FFFFFFFF;    Delay;    PIOB.CODR := $FFFFFFFF;    Delay;  until False;end.
Maybe I'm doing something wrong with loading too?

--- Code: ---$ /home/tux/.arduino15/packages/arduino/tools/bossac/1.6.1-arduino/bossac --port=ttyACM0 --info -e -w -v -b Project1.bin -R
Atmel SMART device 0x285e0a60 found
Device       : ATSAM3X8
Chip ID      : 285e0a60
Version      : v1.1 Dec 15 2010 19:25:04
Address      : 524288
Pages        : 2048
Page Size    : 256 bytes
Total Size   : 512KB
Planes       : 2
Lock Regions : 32
Locked       : none
Security     : false
Boot Flash   : false
Erase flash
done in 0.033 seconds

Write 980 bytes to flash (4 pages)
Gleitkomma-Ausnahme (Speicherabzug geschrieben)

--- End code ---

In the appendix the complete source.

MiR:
I have very limited knowledge of the sam3x8e, so I cannot tell if your code is correct but one thing is that you flash using a bootloader and the bootloader will likely conflict with your image as both expect to run at the start of flash.
Have a look at this Forum post:

https://forum.lazarus.freepascal.org/index.php/topic,49243.0.html

on how to tweak the start address that fpc assumes.

In this example another bootloader for an STM32 was used so you will likely have to exchange the address used there with some offset to the start of flash on sam3x8e

Found this link:

http://www.inspirel.com/articles/Ada_On_Cortex_Linking_And_Booting.html

try 0x00080000, looks like a promising start for experiments....

MiR:
Found this link to enable a half-decent, real debugger:

https://github.com/lanserge/at16u2_cmsis_dap

Also found an Arduino Due board in my 'Grabbelkiste', trying to connect it via JLink Debugger, will keep you posted.

Michael

Mathias:

--- Quote ---try 0x00080000, looks like a promising start for experiments....
--- End quote ---


I have now entered the following in Lazarus under "Settings for Project / Compiler Settings / Custom Settings".

--- Code: ----WpATSAM3X8E
-k-Ttext=0x00080000
--- End code ---
Unfortunately, nothing has changed.

I don't see any change in the output of bossac either.



I tried it with "-k-Ttext = 0x00000000", then an interesting error message comes from the compiler.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---...Error: /home/tux/fpcupdeluxe_stm32/cross/bin/arm-embedded/arm-none-eabi-ld: address 0x368 of /n4800/DATEN/Programmierung/Lazarus/Tutorials/Embedded/ARM/Arduino_DUE/Blink_Pin13/Project1.elf section `.text' is not within region `flash'Error: /home/tux/fpcupdeluxe_stm32/cross/bin/arm-embedded/arm-none-eabi-ld: /n4800/DATEN/Programmierung/Lazarus/Tutorials/Embedded/ARM/Arduino_DUE/Blink_Pin13/Project1.elf section `.data' will not fit in region `flash'Error: /home/tux/fpcupdeluxe_stm32/cross/bin/arm-embedded/arm-none-eabi-ld: address 0x368 of /n4800/DATEN/Programmierung/Lazarus/Tutorials/Embedded/ARM/Arduino_DUE/Blink_Pin13/Project1.elf section `.text' is not within region `flash'Error: /home/tux/fpcupdeluxe_stm32/cross/bin/arm-embedded/arm-none-eabi-ld: region `flash' overflowed by -785452 bytesProject1.pas(49,0) Error: Error while linking


MiR:
This code works for me, in the Debugger I saw that enabling all port bits crashed the debugger.
Explicitly enabling only the led port did the job.
Enabling the clock for the pio is not needed (I guess, this is what it says in the reference Manual), I did it anyway as not everything works when pio clock is disabled.

The setting of the text segment is correct as is, you do not need to change that, for me the default worked out of the box.

I jaw in your project file that you also own an stlink. If you are serious about playing with this cpu i'd convert it to a black magic probe so that you can do real debugging.

In the debugger i saw the issue immediately.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program Project1; {$H-,J-,O-} uses  cortexm3;   procedure Delay;  var    i: uint32;  begin    for i := 0 to 1000000 do begin      asm               Nop end; // Leerbefehl    end;  end;   procedure Delay_ms(x: Int32);  var    y: Int32;  begin    y := RTT.VR + x;    while y >= RTT.VR do begin    end;  end; const  led = 1 shl 27; begin  PMC.PCER0 := 1 shl 12;  PIOB.PER := 1 shl 27;  PIOB.OER := 1 shl 27;   repeat    // Pin13 -- High    PIOB.SODR := 1 shl 27;    Delay;     // Pin13 -- Low    PIOB.CODR := 1 shl 27;    Delay;  until False;end. 

Navigation

[0] Message Index

[#] Next page

Go to full version