SAMA5D2 xplained start application bare metal (without os)

For SAMA5D2 Xplained, SAMA5D3 Xplained and SAMA5D4 Xplained

Moderator: nferre

JR9020
Posts: 2
Joined: Tue Oct 17, 2017 11:06 am

SAMA5D2 xplained start application bare metal (without os)

Tue Oct 17, 2017 4:38 pm

Hello,

I have the ATMEL sama5d27 xplained ultra board and i want to develop applications which should run "directly" on the board without an operating system (no linux4sam). Therefore I have downloaded the atmel software package https://github.com/atmelcorp/atmel-software-package. As first example I want to run the "getting-started". I think that I also need the AT91Bootstrap second level bootloader to load the main application from boot media to main memory? (But I am not sure) Link: https://github.com/linux4sam/at91bootstrap. In order to flash the AT91Bootstrap bootloader to the board I have downloaded the sam-ba tool. Link: https://github.com/atmelcorp/sam-ba/releases

So i have done the following (maybe it is wrong but that is why I am asking):

1. Build AT91Bootstrap
I have build the AT91Bootstrap as explained here: linux4sam/bin/view/Linux4SAM/Sama5d2Xpl ... om_sources

Code: Select all

git clone git://github.com/linux4sam/at91bootstrap.git

Code: Select all

cd at91bootstrap/

Code: Select all

make mrproper

Code: Select all

make sama5d2_xplaineddf_uboot_defconfig

Code: Select all

make menuconfig

Code: Select all

make
2. Flash AT91Bootstrap
I have flashed the AT91Bootstrap as explained here: linux4sam/bin/view/Linux4SAM/Sama5d2Xpl ... rap_binary
I got the binary (.bin file) from the previous step and flashed it in serialflash.

Code: Select all

sam-ba -p serial -b sama5d2-xplained -a serialflash -c erase::0x3000 -c writeboot:at91bootstrap-sama5d2_xplained.bin
3. Build application
First I installed the GCC ARM Embedded:

Code: Select all

sudo apt-get install gcc-arm-embedded
Then I have build the getting started example as follows:

Code: Select all

git clone git://github.com/atmelcorp/atmel-software-package.git

Code: Select all

cd atmel-software-package/examples/getting_started/

Code: Select all

make TARGET=sama5d2-xplained
4. Flash application
I have flashed the (in the previous step generated) binary at the address where the u-boot should be. I am not sure if this is the correct way to get the application running. Link: linux4sam/bin/view/Linux4SAM/Sama5d2Xpl ... oot_binary

Code: Select all

sam-ba -p serial -b sama5d2-xplained -a serialflash -c erase:0x8000:0x70000 -c write:getting-started.bin:0x8000
Problem:
After rebooting the board i get the following output:

Code: Select all

AT91Bootstrap 3.8.9-rc6-00013-gf25feef (Mon Okt 16 15:48:34 CEST 2017)

EEPROM: Loading AT24xx information ...
EEPROM: BoardName | [Revid] | VendorName
  #0  SAMA5D2-XULT [AA1]      ATMEL-RF0

EEPROM: Board sn: 0xd300000 revision: 0x200000

SF: Got Manufacturer and Device ID: 0x1f 0x47 0x1 0x0 0x0
SF: Copy 0xa0000 bytes from 0x8000 to 0x26f00000
SF: Done to load image
The AT91Bootstrap bootloader is started and it copies bytes from 0x8000 (thats where the application is stored). I have chacked that the application is not bigger than 0xa0000, so the whole programm must be copied. BUT nothing happens after the last output of the AT91Bootstrap. If i flash the (expected) u-boot.bin to 0x8000 the u-boot binary is executed and i get the u-boot output.

What am I doing wrong?

I have also tried the IAR Embedded Workbench with the segger j-link plus and with these tools I am able to flash and run the app. BUT i am not able to automatically run the app after powering the board (without using the IAR Embedded Workbench). And I also do not want to buy the IAR Embedded Workbench.

So my question is:
How to build and flash the getting-started example that the board executes the application after powering.

I hope anybody can help me.
BR JR
blue_z
Location: USA
Posts: 1547
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D2 xplained start application bare metal (without os)

Tue Oct 17, 2017 10:19 pm

JR9020 wrote:What am I doing wrong?
The clue that you incompletely scrutinized is
JR9020 wrote:

Code: Select all

SF: Copy 0xa0000 bytes from 0x8000 to 0x26f00000
You were concerned about (but verified) the length of the transfer and the source address, but failed to question the target address.
The 0x26f00000 target address in use is the default load address for U-Boot, which is why u-boot.bin successfully executes.
The DRAM Softpack example that you built and want to execute has a load address of 0x20000000.
These binary images are non-relocateable code. They must be loaded to memory at the address specified when they were built (i.e. linked).
Study the output of the linker (e.g. the symbol map file) to confirm.

The proper correction is in your step 1 when you build AT91Bootstrap.
The default configurations provided are only for booting U-Boot. You need to reconfigure the build to boot an alternate program. Use the `make menuconfig` command to perform the needed changes.
Under `Image Loading Strategy` select one of the `Load x MB into start of SDRAM` choices that you deem adequate.
Under `Demo Application Image Storage Setup` configure the entries appropriate to your application, especially the `External Ram Address`, which represents the load address.
For the `Image Name` use an appropriate name such as "softpack.bin".

JR9020 wrote:As first example I want to run the "getting-started". I think that I also need the AT91Bootstrap second level bootloader to load the main application from boot media to main memory?
There's more than one memory on the board. See this post.
There are two versions of the "getting-started" example program, one for each type of memory.
To execute the DRAM version, yes, you would need an intermediate program to initialize dynamic RAM prior to loading.

JR9020 wrote:How to build and flash the getting-started example that the board executes the application after powering.
Seems like you're almost there, except for the missing re-configuration of AT91Bootstrap.
Note that there are alternate boot schemes, such as using U-Boot as a third-level boot program. U-Boot can (when properly configured) load binary images from different media (e.g. SDcard) and over a network (e.g. using TFTP), and then execute them (using a `go` command) or store them. These commands can be entered interactively or stored for automatic execution on boot. In the long run IMO, experience with U-Boot will be more valuable than proficiency with the Atmel SAM-BA utility.

Regards
JR9020
Posts: 2
Joined: Tue Oct 17, 2017 11:06 am

Re: SAMA5D2 xplained start application bare metal (without os)

Wed Oct 18, 2017 2:56 pm

Hello,

thank you for your answer. I configured the at91bootstrap as you suggested and now it works.
Thanks a lot.

BR JR
Oleksandr
Posts: 4
Joined: Thu Nov 02, 2017 10:30 pm

Re: SAMA5D2 xplained start application bare metal (without os)

Fri Nov 03, 2017 12:03 am

Hi guys.

I did everything according to the above instructions and have the following situation: "getting-started.bin" with SPIFlash is copied into DDRAM (at 0x20000000) but does not want to be executed.

So, if I load "getting-started.bin" from the IAR into DDRAM then it works, but if the same "getting-started.bin" is loaded into DDRAM using bootstrap then it does not works.

"Get-started.bin" is actually loaded into DDRAM, because I can see its code after Power-On using the "Debud without downloading" mode in IAR over j-link adapter.

Where can I do wrong?

Help me please!
blue_z
Location: USA
Posts: 1547
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D2 xplained start application bare metal (without os)

Fri Nov 03, 2017 10:31 pm

Oleksandr wrote:I did everything according to the above instructions ...
But apparently you have a different built environment, i.e. you mention IAR whereas the OP used a GNU toolchain.

Oleksandr wrote:... but does not want to be executed.
That's not an observable fact, but rather your conjecture about a personified object. This first sentence makes all your claims suspect.

Since you have a "j-link adapter", debug the code when AT91Bootstrap jumps to 0x20000000.

Regards
Oleksandr
Posts: 4
Joined: Thu Nov 02, 2017 10:30 pm

Re: SAMA5D2 xplained start application bare metal (without os)

Sun Nov 05, 2017 12:54 pm

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

Re: SAMA5D2 xplained start application bare metal (without os)

Mon Nov 06, 2017 11:53 pm

Oleksandr wrote:Look, please, where I'm wrong
If all you provide are vague descriptions and a list of instructions, then do not expect a positive resolution to your problem.
If you study the OP's post, you should notice that there's a detailed description of steps performed and then the results of executing the program. There is information sufficient to pinpoint the problem and offer the solution.
You on the other hand, have only provided vague summations.
Nobody has the time and imagination to think of all the ways that you could make mistakes.

Regards
Oleksandr
Posts: 4
Joined: Thu Nov 02, 2017 10:30 pm

Re: SAMA5D2 xplained start application bare metal (without os)

Tue Nov 07, 2017 7:54 am

What kind of vague description are you talking about? This is a clear list of steps that I personally carried out and documented.
blue_z
Location: USA
Posts: 1547
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D2 xplained start application bare metal (without os)

Thu Nov 09, 2017 1:35 am

Why not focus on providing detailed descriptions of the results of what you did instead of complaining?
Oleksandr
Posts: 4
Joined: Thu Nov 02, 2017 10:30 pm

Re: SAMA5D2 xplained start application bare metal (without os)

Thu Nov 09, 2017 10:25 am

Hi, blue_z.

Firstly, you named the work that I performed as "an vague description"

Secondly, carefully read this: blue_z is a valuable contributor to at91 forum and has quite a track record of good answers. (c) nferre
You are a "valuable contributor", not me, not others, but you. Therefore, I appeal to you for help. If I were such a cool guy, I would not ask for help here.

Thirdly, I'm new to Linux and Atmel. All time I worked with 8051 and stm32. In quality IDE used Keil uVision 5 under Windows. And here everything is new - the compiler, the processor, the operating system.
I came to the forum for help but something went wrong. :-)
I also do not speak English well.

Okay, forget it all.

Now let's go back to the question: what's wrong with the description? Why do not you want to read it? I tried, made out, took screenshots.
blue_z
Location: USA
Posts: 1547
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D2 xplained start application bare metal (without os)

Thu Nov 09, 2017 10:44 pm

For whatever reason, there was only one page viewable the first time I looked at your document.
I still cannot determine what toolchain version you used to build AT91Bootstrap.
Try the advice from this post on using a proven toolchain. Note that the download command is for a 32-bit toolchain, whereas the Linux4SAM webpage is for a 64-bit toolchain.

Regards

Return to “SAMA5 Xplained”

Who is online

Users browsing this forum: No registered users and 1 guest