How to flash SAMA5D4 Xplained usb bare metal examples?

For SAMA5D2 Xplained, SAMA5D3 Xplained and SAMA5D4 Xplained

Moderator: nferre

gopi_atmel
Posts: 10
Joined: Thu Apr 09, 2015 10:59 am

How to flash SAMA5D4 Xplained usb bare metal examples?

Thu Apr 09, 2015 12:37 pm

Hi,

 
I am trying out bare metal examples (IAR) of  usb mass storage to evaluate usb performance for new project using SAMA5D4 Xplained board from:

http://www.atmel.com/tools/SAMA5D4SOFTWAREPACKAGE.aspx

I am able to flash other examples having sram .bin files through SAM-BA from NAND flash.

But All usb example projects have ddram.bin as they are large code i guess.

I tried flashing this by
-SAM-BA using DDRAM tab
- searched forum for methods
-tried ba user manual  steps
-Tried flashing in place of uboot at 0x40000 after flashing at91 boot strap.
but can't  get it running. 


Please help me guide how to flash usb mass storage bare metal example on this board which are having ddram.bin.


Following my setup:

Board: SAMA5D4 Xplained Ultra 
SAM-BA: 2.15
IDE: IAR 7.3 (have .bin  compiled)

Thanks
Gopi
 
blue_z
Location: USA
Posts: 1550
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Thu Apr 09, 2015 9:22 pm

gopi_atmel wrote:-Tried flashing in place of uboot at 0x40000 after flashing at91 boot strap.
but can't  get it running. 
You are ignoring the salient attributes of these two memory regions and the requirements of binary images.
The SRAM, besides being internal to the SoC, is a small region of memory, only 128 Kbytes, residing at memory address 0x00300000 or 0x0.
The DDR2 DRAM, besides being external to the SoC and requires initialization, is a much larger region of memory residing at memory address 0x20000000.

Loading a binary image of a program is essentially a block copy operation. The salient parameters are the number of bytes to copy, the source location and the destination address.
You need to verify that AT91Bootstrap will copy the full length of your program. I.E. is it smaller than the presumed size of U-Boot?
Since you're storing your program at the same NAND offset, the source location does not change.
But you're messing up with the destination location.

These programs are compiled and then linked to start at a specific memory address.
The binary image of that program has to be loaded (i.e. written to memory) at that same memory address for proper execution.
AT91Bootstrap is linked for execution in internal memory, i.e. 0x0, because it will initialize the external DRAM.
U-Boot is typically linked for execution in upper external memory, e.g. 0x26F00000, because it doesn't fit in internal RAM.
You program is probably linked for execution at the start of external memory, e.g. 0x20000000, because it doesn't fit in internal RAM.

If you haven't modified AT91Bootstrap, then you are loading your program at the incorrect memory address.
These are not relocatable images that can loaded and executed at an arbitrary memory address.
Review the linker output (e.g. the .map file) for each program.

You need to rebuild AT91Bootstrap.
A `make menuconfig` will allow you to configure an appropriate "Image Loading Strategy".

Regards
gopi_atmel
Posts: 10
Joined: Thu Apr 09, 2015 10:59 am

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Fri Apr 10, 2015 7:22 am

blue_z wrote:
gopi_atmel wrote:-Tried flashing in place of uboot at 0x40000 after flashing at91 boot strap.
but can't  get it running. 
You are ignoring the salient attributes of these two memory regions and the requirements of binary images.
The SRAM, besides being internal to the SoC, is a small region of memory, only 128 Kbytes, residing at memory address 0x00300000 or 0x0.
The DDR2 DRAM, besides being external to the SoC and requires initialization, is a much larger region of memory residing at memory address 0x20000000.

Loading a binary image of a program is essentially a block copy operation. The salient parameters are the number of bytes to copy, the source location and the destination address.
You need to verify that AT91Bootstrap will copy the full length of your program. I.E. is it smaller than the presumed size of U-Boot?
Since you're storing your program at the same NAND offset, the source location does not change.
But you're messing up with the destination location.

These programs are compiled and then linked to start at a specific memory address.
The binary image of that program has to be loaded (i.e. written to memory) at that same memory address for proper execution.
AT91Bootstrap is linked for execution in internal memory, i.e. 0x0, because it will initialize the external DRAM.
U-Boot is typically linked for execution in upper external memory, e.g. 0x26F00000, because it doesn't fit in internal RAM.
You program is probably linked for execution at the start of external memory, e.g. 0x20000000, because it doesn't fit in internal RAM.

If you haven't modified AT91Bootstrap, then you are loading your program at the incorrect memory address.
These are not relocatable images that can loaded and executed at an arbitrary memory address.
Review the linker output (e.g. the .map file) for each program.

You need to rebuild AT91Bootstrap.
A `make menuconfig` will allow you to configure an appropriate "Image Loading Strategy".

Regards
Thanks blue for wonderful explantion.    :o

This was what even i was thinking might be missing.  :)

I will try your steps.


Update
1.Now using JTAG, IAR ide i am able to debug(Debug and download option) and execute the program  if the board has at91sam boot strip(provided with lin4sam/uboot example) at 0x0.
2.But it does not debug if NAND Flash is erased(i.e No boot strap). A message saying Failed to get CPU status pops up from Jlink JTAG in IAR ide.
3. IAR says it still may not have  support for this SAMA5D44 cpu on board as per their website.I am using  Cortex-A5 profile for JTAG then it works but breaks sometimes if no bootloader present.I wonder how atmel website  gave this examples (with readme saying IAR version upto 7.3)and in IAR site they say its not supported.

Since i want to test usb thoughput using code from DDRAM , i may go with bootloader to avoid overhead.

Do you think there will be any overhead running (usb msc) code using IAR-JTAG Debug instead of executing using a boot strap?

Thanks
blue_z
Location: USA
Posts: 1550
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Fri Apr 10, 2015 9:19 pm

gopi_atmel wrote:Do you think there will be any overhead running (usb msc) code using IAR-JTAG Debug instead of executing using a boot strap?
Someone else has to answer to that, since I use neither IAR or JTAG.

Regards
gopi_atmel
Posts: 10
Joined: Thu Apr 09, 2015 10:59 am

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Wed Apr 29, 2015 9:28 am

Update:
To load ddram program:
1.One has to get sources of atmel bootstrap in linux 

2.Make menuconfig
(do as per instructions here linux4sam/bin/view/Linux4SAM/AT91Bootstrap )

In menu:
Select Image loading strategy--> Load 1MB to SDRAM
DemoApplication Image storage setup -->Change offset 0x40000 (if needed)

3. Recompile bootstrap will produce bin
(sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin in my case)

4.Flash step 3) .bin at 0x00 as boot file(follow website instructions) in NAND.

5.Flash your softpack (example bin ddram.bin) at 0x40000 by sendfile to NAND

6.Now you can run everytime from DDRAM.


Hope it helps others  :mrgreen:

Atmel should update this in website or its difficult for newbies using this SAMA5D44
Thanks
jancumps
Posts: 15
Joined: Tue Mar 31, 2015 8:47 pm

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Wed May 06, 2015 9:21 am

(related to a design contest that I'm doing on element14 for the sama5d4 xplained ultra, and partly cross-post of Who has a working SAM-BA script for one of the ATMEL Software Package examples)


Do you have to happen a SAM-BA example that uploads one of the Atmel sama5d4x_xplained_softpack examples? It would be great if you could zip up such an example so that I can try it out.

I'd like to be able to load one of those examples in persistent storage of the board, and have it executed when the board starts. 

I have the lib and example binaries from Software Package compiled from source, linked and ready.
I was not able to build correct SAM-BA scripts and boot binaries for bare metal binaries to work by myself.

I have been successful doing the following things:

- Load precompiled Linux distros to the board using SAM-BA
- Cross compile and link a simple program (Hello, world!) with GNU on Windows, load it to the board (running linux) with SCP and execute my  binary successful.
- Cross-compile Atmel's libraries and examples from sama5d4x_xplained_softpack
gopi_atmel
Posts: 10
Joined: Thu Apr 09, 2015 10:59 am

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Fri May 08, 2015 12:18 pm

jancumps wrote:(related to a design contest that I'm doing on element14 for the sama5d4 xplained ultra, and partly cross-post of Who has a working SAM-BA script for one of the ATMEL Software Package examples)


Do you have to happen a SAM-BA example that uploads one of the Atmel sama5d4x_xplained_softpack examples? It would be great if you could zip up such an example so that I can try it out.

I'd like to be able to load one of those examples in persistent storage of the board, and have it executed when the board starts. 

I have the lib and example binaries from Software Package compiled from source, linked and ready.
I was not able to build correct SAM-BA scripts and boot binaries for bare metal binaries to work by myself.

I have been successful doing the following things:

- Load precompiled Linux distros to the board using SAM-BA
- Cross compile and link a simple program (Hello, world!) with GNU on Windows, load it to the board (running linux) with SCP and execute my  binary successful.
- Cross-compile Atmel's libraries and examples from sama5d4x_xplained_softpack
1.Download the soft pack from here
http://www.atmel.com/images/sama5d4x_xu ... m_6.50.exe

2.It will install if you have IAR or you can extract to a directory.

3.Say you want to try usb example , you can find  pre-compiled binary  in :
sama5d4x-xplained\examples_usb\usb_hid_msd\build\ewarm\ddram\bin\ddram.bin

4.Download  bootstrap:
http://s000.tinyupload.com/index.php?fi ... 6174246080
 and flash as per step 4) above(previous post)

5.Follow instruction from 5) to 6)
---------

Regarding SAM-BA flashing, sharing my note about programming this board(sam5d4xplained):

For DDRAM mode bin
-------------
Power off board
Short JP7
Power on/Reset
Open JP7
Start SAM-BA
Select NAND,
Scripts-->Enable NAND flash-->Execute,
Scripts-->Enable OS PMECC parameters-->Execute,
Scripts-->Erase All-->Execute,
Scripts-->Send boot file--> select sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin-->Execute,

Enter address 0x40000 -->Send file --> Program.bin(ddram.bin)


Reset to run program(JP7 should be open)


Hope that helps
cheers
Last edited by gopi_atmel on Wed May 13, 2015 9:34 am, edited 2 times in total.
gopi_atmel
Posts: 10
Joined: Thu Apr 09, 2015 10:59 am

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Mon May 11, 2015 11:33 am

awneil wrote:
gopi_atmel wrote:Do you think there will be any overhead running (usb msc) code using IAR-JTAG Debug instead of executing using a boot strap?
I don't get the question - please clarify
Hi awneil , my doubt was is there any  difference in performance of usb msc  while running in below two modes-
1.Running in DDRAM by debug-run in IAR (connected by JTAG)
2.Running  in DDRAM by flashing bootloader and bin to NAND flash and reset-run.

Can you also help me with this another question of mine
discussions/viewtopic.php/f,30/t,24014.html

Thanks
jancumps
Posts: 15
Joined: Tue Mar 31, 2015 8:47 pm

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Tue May 12, 2015 5:49 pm

gopi_atmel wrote:
jancumps wrote:(related to a design contest that I'm doing on element14 for the sama5d4 xplained ultra, and partly cross-post of Who has a working SAM-BA script for one of the ATMEL Software Package examples)


Do you have to happen a SAM-BA example that uploads one of the Atmel sama5d4x_xplained_softpack examples? It would be great if you could zip up such an example so that I can try it out.

I'd like to be able to load one of those examples in persistent storage of the board, and have it executed when the board starts. 

I have the lib and example binaries from Software Package compiled from source, linked and ready.
I was not able to build correct SAM-BA scripts and boot binaries for bare metal binaries to work by myself.

I have been successful doing the following things:

- Load precompiled Linux distros to the board using SAM-BA
- Cross compile and link a simple program (Hello, world!) with GNU on Windows, load it to the board (running linux) with SCP and execute my  binary successful.
- Cross-compile Atmel's libraries and examples from sama5d4x_xplained_softpack
1.Download the soft pack from here
http://www.atmel.com/images/sama5d4x_xu ... m_6.50.exe

2.It will install if you have IAR or you can extract to a directory.

3.Say you want to try usb example , you can find  pre-compiled binary  in :
sama5d4x-xplained\examples_usb\usb_hid_msd\build\ewarm\ddram\bin\ddram.bin

4.Download  bootstrap:
http://s000.tinyupload.com/index.php?fi ... 6174246080
 and flash as per step 4) above(previous post)

5.Follow instruction from 5) to 6)
---------

Regarding SAM-BA flashing, sharing my note about programming this board(sam5d4xplained):

For DDRAM mode bin
-------------
Power off board
Short JP7
Power on/Reset
Open JP7
Start SAM-BA
Select NAND,
Enable PMMC param..,
Erase All,
Send boot file-->sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin at 0x00.
Enter adress 0x40000
Send file --> Program.bin(ddram.bin)
Reset to run program(JP7 should be open)


Hope that helps
cheers
Thank you. I'm trying this.
jancumps
Posts: 15
Joined: Tue Mar 31, 2015 8:47 pm

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Tue May 12, 2015 6:38 pm

gopi_atmel wrote:
jancumps wrote:(related to a design contest that I'm doing on element14 for the sama5d4 xplained ultra, and partly cross-post of Who has a working SAM-BA script for one of the ATMEL Software Package examples)


Do you have to happen a SAM-BA example that uploads one of the Atmel sama5d4x_xplained_softpack examples? It would be great if you could zip up such an example so that I can try it out.

I'd like to be able to load one of those examples in persistent storage of the board, and have it executed when the board starts. 

I have the lib and example binaries from Software Package compiled from source, linked and ready.
I was not able to build correct SAM-BA scripts and boot binaries for bare metal binaries to work by myself.

I have been successful doing the following things:

- Load precompiled Linux distros to the board using SAM-BA
- Cross compile and link a simple program (Hello, world!) with GNU on Windows, load it to the board (running linux) with SCP and execute my  binary successful.
- Cross-compile Atmel's libraries and examples from sama5d4x_xplained_softpack
1.Download the soft pack from here
http://www.atmel.com/images/sama5d4x_xu ... m_6.50.exe

2.It will install if you have IAR or you can extract to a directory.

3.Say you want to try usb example , you can find  pre-compiled binary  in :
sama5d4x-xplained\examples_usb\usb_hid_msd\build\ewarm\ddram\bin\ddram.bin

4.Download  bootstrap:
http://s000.tinyupload.com/index.php?fi ... 6174246080
 and flash as per step 4) above(previous post)

5.Follow instruction from 5) to 6)
---------

Regarding SAM-BA flashing, sharing my note about programming this board(sam5d4xplained):

For DDRAM mode bin
-------------
Power off board
Short JP7
Power on/Reset
Open JP7
Start SAM-BA
Select NAND,
Enable PMMC param..,
Erase All,
Send boot file-->sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin at 0x00.
Enter adress 0x40000
Send file --> Program.bin(ddram.bin)
Reset to run program(JP7 should be open)


Hope that helps
cheers
I tested getting-started example and could replicate the steps without getting errors..
The code isn't after a reset with the P7 open though.
The board isn't flashing LEDs and the serial console output isn't showing anything.

Code: Select all

loading history file ... 0 events added
SAM-BA console display active (Tcl8.5.9 / Tk8.5.9)
(sam-ba_2.15) 1 % 
(sam-ba_2.15) 1 % NANDFLASH::Init
-I- NANDFLASH::Init (trace level : 4)
-I- Loading applet applet-nandflash-sama5d4x.bin at address 0x20000000
-I- Memory Size : 0x20000000 bytes
-I- Buffer address : 0x20024DF4
-I- Buffer size: 0x40000 bytes
-I- Applet initialization done
(sam-ba_2.15) 1 % NANDFLASH::NandHeaderValue HEADER 0xc1e04e07
   - HEADER value  is 0xC1E04E07
-I- Pmecc header configration successful
-I- PMECC configure c1e04e07
(sam-ba_2.15) 1 % NANDFLASH::EraseAll
-I- Erasing  blocks  batch 0
-I- Erasing  blocks  batch 1
-I- Erasing  blocks  batch 2
-I- Erasing  blocks  batch 3
-I- Erasing  blocks  batch 4
-I- Erasing  blocks  batch 5
-I- Erasing  blocks  batch 6
-I- Erasing  blocks  batch 7
(sam-ba_2.15) 1 % send_file {NandFlash} "C:/Users/Jan/Documents/elektronica/atmel/barematal bootstrap/sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin" 0x0 0
-I- Send File C:/Users/Jan/Documents/elektronica/atmel/barematal bootstrap/sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin at address 0x0
GENERIC::SendFile C:/Users/Jan/Documents/elektronica/atmel/barematal bootstrap/sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin at address 0x0
-I- File size : 0x4EA4 byte(s)
-I- 	Writing: 0x4EA4 bytes at 0x0 (buffer addr : 0x20024DF4)
-I- 	0x4EA4 bytes written by applet
(sam-ba_2.15) 1 % send_file {NandFlash} "C:/Atmel/sama5d4x_xult_softpack_1.3_for_ewarm_6.50/arm/examples/Atmel/sama5d4x-xult/examples/getting-started/build/ewarm/ddram/bin/ddram.bin" 0x40000 0
-I- Send File C:/Atmel/sama5d4x_xult_softpack_1.3_for_ewarm_6.50/arm/examples/Atmel/sama5d4x-xult/examples/getting-started/build/ewarm/ddram/bin/ddram.bin at address 0x40000
GENERIC::SendFile C:/Atmel/sama5d4x_xult_softpack_1.3_for_ewarm_6.50/arm/examples/Atmel/sama5d4x-xult/examples/getting-started/build/ewarm/ddram/bin/ddram.bin at address 0x40000
-I- File size : 0x8038 byte(s)
-I- 	Writing: 0x8038 bytes at 0x40000 (buffer addr : 0x20024DF4)
-I- 	0x8038 bytes written by applet
(sam-ba_2.15) 1 % 
I'm checking what's wrong.
gopi_atmel
Posts: 10
Joined: Thu Apr 09, 2015 10:59 am

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Wed May 13, 2015 9:29 am

1.I think you are not sending the bootstrap using Sendboot file option in the SAMBAdropdown(Scripts).

I have edited the steps in post-
discussions/viewtopic.php/p,45357.html#p45357

Do it again.

2.You can use EDBG as serial port and also power board.
After above steps complete, open both  JP7 and EDBG_DIS jumpers.
Connect the board using J11 usb port.(EDBG).
Now open the corresponding Comport installed in PC using 115200 baud.

Enjoy.  :mrgreen:


Here is my log

Code: Select all

loading history file ... 7 events added
SAM-BA console display active (Tcl8.5.9 / Tk8.5.9)
(sam-ba_2.15) 8 % 
(sam-ba_2.15) 8 % NANDFLASH::Init
-I- NANDFLASH::Init (trace level : 4)
-I- Loading applet applet-nandflash-sama5d4x.bin at address 0x20000000
-I- Memory Size : 0x20000000 bytes
-I- Buffer address : 0x20024DF4
-I- Buffer size: 0x40000 bytes
-I- Applet initialization done
(sam-ba_2.15) 8 % NANDFLASH::NandHeaderValue HEADER 0xc1e04e07
   - HEADER value  is 0xC1E04E07
-I- Pmecc header configration successful
-I- PMECC configure c1e04e07
(sam-ba_2.15) 8 % NANDFLASH::EraseAll
-I- Erasing  blocks  batch 0
-I- Erasing  blocks  batch 1
-I- Erasing  blocks  batch 2
-I- Erasing  blocks  batch 3
-I- Erasing  blocks  batch 4
-I- Erasing  blocks  batch 5
-I- Erasing  blocks  batch 6
-I- Erasing  blocks  batch 7
(sam-ba_2.15) 8 % NANDFLASH::SendBootFilePmecc
Sending boot file done.
(sam-ba_2.15) 8 % send_file {NandFlash} "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm/examples/Atmel/sama5d4x-xplained/examples/pwm/build/ewarm/ddram/bin/ddram.bin" 0x40000 0
-I- Send File C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm/examples/Atmel/sama5d4x-xplained/examples/pwm/build/ewarm/ddram/bin/ddram.bin at address 0x40000
GENERIC::SendFile C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm/examples/Atmel/sama5d4x-xplained/examples/pwm/build/ewarm/ddram/bin/ddram.bin at address 0x40000
-I- File size : 0x77A0 byte(s)
-I- 	Writing: 0x77A0 bytes at 0x40000 (buffer addr : 0x20024DF4)
-I- 	0x77A0 bytes written by applet
(sam-ba_2.15) 8 % 
jancumps wrote:
gopi_atmel wrote:
jancumps wrote:(related to a design contest that I'm doing on element14 for the sama5d4 xplained ultra, and partly cross-post of Who has a working SAM-BA script for one of the ATMEL Software Package examples)


Do you have to happen a SAM-BA example that uploads one of the Atmel sama5d4x_xplained_softpack examples? It would be great if you could zip up such an example so that I can try it out.

I'd like to be able to load one of those examples in persistent storage of the board, and have it executed when the board starts. 

I have the lib and example binaries from Software Package compiled from source, linked and ready.
I was not able to build correct SAM-BA scripts and boot binaries for bare metal binaries to work by myself.

I have been successful doing the following things:

- Load precompiled Linux distros to the board using SAM-BA
- Cross compile and link a simple program (Hello, world!) with GNU on Windows, load it to the board (running linux) with SCP and execute my  binary successful.
- Cross-compile Atmel's libraries and examples from sama5d4x_xplained_softpack
1.Download the soft pack from here
http://www.atmel.com/images/sama5d4x_xu ... m_6.50.exe

2.It will install if you have IAR or you can extract to a directory.

3.Say you want to try usb example , you can find  pre-compiled binary  in :
sama5d4x-xplained\examples_usb\usb_hid_msd\build\ewarm\ddram\bin\ddram.bin

4.Download  bootstrap:
http://s000.tinyupload.com/index.php?fi ... 6174246080
 and flash as per step 4) above(previous post)

5.Follow instruction from 5) to 6)
---------

Regarding SAM-BA flashing, sharing my note about programming this board(sam5d4xplained):

For DDRAM mode bin
-------------
Power off board
Short JP7
Power on/Reset
Open JP7
Start SAM-BA
Select NAND,
Enable PMMC param..,
Erase All,
Send boot file-->sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin at 0x00.
Enter adress 0x40000
Send file --> Program.bin(ddram.bin)
Reset to run program(JP7 should be open)


Hope that helps
cheers
I tested getting-started example and could replicate the steps without getting errors..
The code isn't after a reset with the P7 open though.
The board isn't flashing LEDs and the serial console output isn't showing anything.

Code: Select all

loading history file ... 0 events added
SAM-BA console display active (Tcl8.5.9 / Tk8.5.9)
(sam-ba_2.15) 1 % 
(sam-ba_2.15) 1 % NANDFLASH::Init
-I- NANDFLASH::Init (trace level : 4)
-I- Loading applet applet-nandflash-sama5d4x.bin at address 0x20000000
-I- Memory Size : 0x20000000 bytes
-I- Buffer address : 0x20024DF4
-I- Buffer size: 0x40000 bytes
-I- Applet initialization done
(sam-ba_2.15) 1 % NANDFLASH::NandHeaderValue HEADER 0xc1e04e07
   - HEADER value  is 0xC1E04E07
-I- Pmecc header configration successful
-I- PMECC configure c1e04e07
(sam-ba_2.15) 1 % NANDFLASH::EraseAll
-I- Erasing  blocks  batch 0
-I- Erasing  blocks  batch 1
-I- Erasing  blocks  batch 2
-I- Erasing  blocks  batch 3
-I- Erasing  blocks  batch 4
-I- Erasing  blocks  batch 5
-I- Erasing  blocks  batch 6
-I- Erasing  blocks  batch 7
(sam-ba_2.15) 1 % send_file {NandFlash} "C:/Users/Jan/Documents/elektronica/atmel/barematal bootstrap/sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin" 0x0 0
-I- Send File C:/Users/Jan/Documents/elektronica/atmel/barematal bootstrap/sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin at address 0x0
GENERIC::SendFile C:/Users/Jan/Documents/elektronica/atmel/barematal bootstrap/sama5d4_xplained-nandflashboot-softpack-3.7.2-rc2.bin at address 0x0
-I- File size : 0x4EA4 byte(s)
-I- 	Writing: 0x4EA4 bytes at 0x0 (buffer addr : 0x20024DF4)
-I- 	0x4EA4 bytes written by applet
(sam-ba_2.15) 1 % send_file {NandFlash} "C:/Atmel/sama5d4x_xult_softpack_1.3_for_ewarm_6.50/arm/examples/Atmel/sama5d4x-xult/examples/getting-started/build/ewarm/ddram/bin/ddram.bin" 0x40000 0
-I- Send File C:/Atmel/sama5d4x_xult_softpack_1.3_for_ewarm_6.50/arm/examples/Atmel/sama5d4x-xult/examples/getting-started/build/ewarm/ddram/bin/ddram.bin at address 0x40000
GENERIC::SendFile C:/Atmel/sama5d4x_xult_softpack_1.3_for_ewarm_6.50/arm/examples/Atmel/sama5d4x-xult/examples/getting-started/build/ewarm/ddram/bin/ddram.bin at address 0x40000
-I- File size : 0x8038 byte(s)
-I- 	Writing: 0x8038 bytes at 0x40000 (buffer addr : 0x20024DF4)
-I- 	0x8038 bytes written by applet
(sam-ba_2.15) 1 % 
I'm checking what's wrong.
jancumps
Posts: 15
Joined: Tue Mar 31, 2015 8:47 pm

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Sun May 17, 2015 1:06 pm

Indeed, I used the Send file button in stead of the Send Boot File script.
I'll retry...
jancumps
Posts: 15
Joined: Tue Mar 31, 2015 8:47 pm

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Sun May 17, 2015 2:46 pm

It worked!
Once I flashed the bootloader with the script, all was ok.
Thank you, gopi_atmel
monish
Posts: 1
Joined: Tue Sep 08, 2015 5:39 pm

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Tue Sep 08, 2015 5:49 pm

Hello gopi_atmel,
I have a question regarding the procedure you are following for flashing sram.bin files.
Are you following the same procedure for flashing sram.bin files as you have mentioned in your post(of flashing dram.bin files into SAMA5D board)?


Regards,
Monish
User avatar
BlackMesa
Location: Vilnius
Posts: 9
Joined: Thu Oct 05, 2017 2:02 pm

Re: How to flash SAMA5D4 Xplained usb bare metal examples?

Mon Oct 16, 2017 12:49 pm

I have Atmel sama5d4 xplained board and trying to get basic (getting-started and pwm) bare metal examples working.

I tried these steps: (Using windows 10 machine for compiling GNU examples with Eclipse IDE.)
1. Downloaded bare metal examples from http://www.atmel.com/tools/SAMA5D4SOFTWAREPACKAGE.aspx . Tried both: IAR precompiled ddram.bin and sources for GNU (I compiled with eclipse and get getting-started-ddram.bin). Both variants leads to same result.

Next steps I did with linux Debian 9 (not VirtualBox) machine, because it was hard to me to Cross_Compile bootstrap in windows:
2. Downloaded bootstrap from Git https://github.com/linux4sam/at91bootst ... 4_xplained .

3. Installed GNU Cross Compiler with command: apt-get install gcc-arm-linux-gnueabi as described here: linux4sam/bin/view/Linux4SAM/AT91Bootstrap

4. Made these commands as root:
make mrproper - to clean previously built binaries (if they are built);
make sama5d4_xplainednf_uboot_secure_defconfig - to configure default configurations for sama5d4 xplained board;
make menuconfig - for advanced configurations. In configuration window changed:
  • Image Loading Strategy to "Load 1 MB into start of SDRAM"
  • Demo Application Image Storage Setup --> The External Ram Address to Load Demo-App Image, tried both 0x26F00000 (default) and 0x20000000 (as readed in this forum);
export CROSS_COMPILE=arm-linux-gnueabi- - to define cross compiler;
make - to make binaries;

Binaries made well and the output is here:

Code: Select all

root@BlackMesa:/home/lukas/Documents/GitHub/Bootstraps/at91bootstrap# make
CC
========
arm-linux-gnueabi-gcc 6.3.0

as FLAGS
========
-g -Os -Wall -I/home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/board/sama5d4_xplained -Iinclude -Icontrib/include -DJUMP_ADDR=0x20000000 -DTOP_OF_MEMORY=0x210000 -DMACH_TYPE=9999 -Dsama5d4_xplained -DMACH_TYPE=9999 -DTOP_OF_MEMORY=0x210000 -DCRYSTAL_12_000MHZ -DSAMA5D4 -mcpu=cortex-a5 -mtune=cortex-a5 -DCONFIG_CPU_V7 -DCONFIG_SAMA5D4_XPLAINED

gcc FLAGS
=========
-nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabi/6/include -ffunction-sections -g -Os -Wall -mno-unaligned-access -fno-stack-protector -fno-common -I/home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/board/sama5d4_xplained -Icontrib/include -Iinclude -Ifs/include -I/home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/config/at91bootstrap-config -DAT91BOOTSTRAP_VERSION="3.8.9" -DCOMPILE_TIME="Mon Oct 16 12:23:32 EEST 2017" -DIMG_ADDRESS=0x00040000 -DIMG_SIZE=0x000a0000 -DJUMP_ADDR=0x20000000 -DOF_OFFSET= -DOF_ADDRESS= -DMEM_BANK= -DMEM_SIZE= -DIMAGE_NAME="u-boot.bin" -DCMDLINE="" -DCMDLINE_FILE="" -DTOP_OF_MEMORY=0x210000 -DMACH_TYPE=9999 -DCONFIG_DEBUG -DBANNER="

AT91Bootstrap " AT91BOOTSTRAP_VERSION " (" COMPILE_TIME ")

" -DCONFIG_HW_DISPLAY_BANNER -DCONFIG_HW_INIT -Dsama5d4_xplained -DMACH_TYPE=9999 -DTOP_OF_MEMORY=0x210000 -DCRYSTAL_12_000MHZ -DSAMA5D4 -mcpu=cortex-a5 -mtune=cortex-a5 -DCONFIG_SCLK -DCONFIG_CRYSTAL_12_000MHZ -DCONFIG_CPU_CLK_600MHZ -DCONFIG_BUS_SPEED_200MHZ -DCPU_HAS_PIO3 -DCONFIG_LOAD_EEPROM -DCONFIG_CPU_V7 -DCONFIG_MATRIX -DCONFIG_REDIRECT_ALL_INTS_AIC -DCPU_HAS_H32MXDIV -DCONFIG_SAMA5D4_XPLAINED -DCONFIG_DDRC -DCONFIG_DDR2 -DCONFIG_RAM_512MB -DCONFIG_NANDFLASH -DCONFIG_USE_PMECC -DCONFIG_ONFI_DETECT_SUPPORT -DCONFIG_USE_ON_DIE_ECC_SUPPORT -DBOOTSTRAP_DEBUG_LEVEL=DEBUG_INFO -DCONFIG_DISABLE_WATCHDOG -DCONFIG_TWI -DCONFIG_TWI0 -DCONFIG_TWI1 -DCONFIG_TWI2 -DCONFIG_TWI3 -DCONFIG_ACT8865 -DCONFIG_ACT8865_SET_VOLTAGE -DCONFIG_DISABLE_ACT8865_I2C -DCONFIG_PM -DCONFIG_MACB -DCONFIG_MAC0_PHY -DCONFIG_HDMI -DCONFIG_LOAD_HW_INFO -DCONFIG_PM_PMIC -DCONFIG_AUTOCONFIG_TWI_BUS -DCPU_HAS_HSMCI0

ld FLAGS
========
-nostartfiles -Map=/home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/binaries/sama5d4_xplained-nandflashboot-u-boot-3.8.9.map --cref -static -T elf32-littlearm.lds --gc-sections -Ttext 0x200000

  AS        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/crt0_gnu.S
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/main.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/board/sama5d4_xplained/sama5d4_xplained.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/lib/string.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/lib/eabi_utils.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/lib/div.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/debug.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/at91_slowclk.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/common.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/at91_pio.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/pmc.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/at91_pit.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/at91_wdt.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/at91_usart.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/at91_rstc.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/lp310_l2cc.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/ddramc.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/nandflash.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/pmecc.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/at24xx.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/board_hw_info.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/matrix.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/pm.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/at91_twi.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/act8865.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/macb.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/hdmi_SiI9022.c
  CC        /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/driver/at91_aicredir.c
mkdir -p /home/lukas/Documents/GitHub/Bootstraps/at91bootstrap/binaries
  LD        sama5d4_xplained-nandflashboot-u-boot-3.8.9.elf
Size of sama5d4_xplained-nandflashboot-u-boot-3.8.9.bin is 25960 bytes
[Succeeded] It's OK to fit into SRAM area
[Attention] The space left for stack is 39576 bytes
root@BlackMesa:/home/lukas/Documents/GitHub/Bootstraps/at91bootstrap#
5. Shorted JP7 (BOOT_DIS) jumper (EDBG_DIS jumper left opened, I'm not touching it);
Powered board up by connecting USB cable to J11 (A5-USB-A);
Opened JP7 jumper;
Opened SAM-BA (as administrator), switched to NandFlash tab and did following:
Enable NandFlash --> Execute;
Enable OS PMECC parameters --> Execute;
Erase All --> Execute;
Send Boot File --> Execute --> Selecting generated bootstrap file (in my case sama5d4_xplained-nandflashboot-u-boot-3.8.9.bin);
Upload File --> Send File Name: --> browse for IAR precompiled ddram.bin or Eclipse compiled getting-started-ddram.bin --> Chande Address to 0x40000 --> Send File;
Quit SAM-BA and reset the board. Disconnected USB cable from J11 (board discharges) and connected USB to J20 (EDBG-USB) connector.

SAM-BA output is here:

Code: Select all

loading history file ... 0 events added
SAM-BA CDC console display active (Tcl8.5.9 / Tk8.5.9)
(sam-ba_cdc_linux) 1 % 
(sam-ba_cdc_linux) 1 % NANDFLASH::Init
-I- NANDFLASH::Init (trace level : 4)
-I- Loading applet applet-nandflash-sama5d4x.bin at address 0x20000000
-I- Memory Size : 0x20000000 bytes
-I- Buffer address : 0x20024DEC
-I- Buffer size: 0x40000 bytes
-I- Applet initialization done
(sam-ba_cdc_linux) 1 % NANDFLASH::NandHeaderValue HEADER 0xc1e04e07
   - HEADER value  is 0xC1E04E07
-I- Pmecc header configration successful
-I- PMECC configure c1e04e07
(sam-ba_cdc_linux) 1 % NANDFLASH::EraseAll
-I- Erasing  blocks  batch 0
-I- Erasing  blocks  batch 1
-I- Erasing  blocks  batch 2
-I- Erasing  blocks  batch 3
-I- Erasing  blocks  batch 4
-I- Erasing  blocks  batch 5
-I- Erasing  blocks  batch 6
-I- Erasing  blocks  batch 7
(sam-ba_cdc_linux) 1 % NANDFLASH::SendBootFilePmecc
Sending boot file done.
(sam-ba_cdc_linux) 1 % send_file {NandFlash} "/home/lukas/Documents/Embedded_Projects/GetStart/ddram.bin" 0x40000 0
-I- Send File /home/lukas/Documents/Embedded_Projects/GetStart/ddram.bin at address 0x40000
GENERIC::SendFile /home/lukas/Documents/Embedded_Projects/GetStart/ddram.bin at address 0x40000
-I- File size : 0x8038 byte(s)
-I- 	Writing: 0x8038 bytes at 0x40000 (buffer addr : 0x20024DEC)
-I- 	0x8038 bytes written by applet
(sam-ba_cdc_linux) 1 % 
I used Putty to see board output in terminal when board starts (With all IAR and GNU examples I got the same output):

Code: Select all

RomBOOT


AT91Bootstrap 3.8.9 (Mon Oct 16 12:23:32 EEST 2017)

EEPROM: Loading AT24xx information ...
EEPROM: BoardName | [Revid] | VendorName
HW Info: The total size: 0xff isn't correct

EEPROM: Using default information

EEPROM: Board sn: 0x1012420 revision: 0x680820

HDMI SiI9022: Enter D3 Cold mode
NAND: ONFI not supported
NAND: Manufacturer ID: 0x0 Chip ID: 0x0
NAND: Disable On-Die ECC
Nand flash is not ONFI compliant, use 2-bit/512-byte ecc.
PMECC: Not supported page size: 0
NAND: Failed to load image
Could somebody help me to understand why board failed to load the image? Is this fail caused by bootstrap or by example binary?

The .map file generated by Eclipse: https://drive.google.com/file/d/0B8i7OG ... sp=sharing
Could somebody read which address is Start of program? Does the stack address have to be written in bootstrap somewhere?

Return to “SAMA5 Xplained”

Who is online

Users browsing this forum: No registered users and 1 guest