FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
6307 Discussions

How to set the SPL and the sdimage correctly with baremetal applications

CAlex
New Contributor II
3,653 Views

Hi,

 

I'm working on cycloneV soc with the newest soceds 20.1 so the bsp-editor cant be used as a uboot setting.

I want to start the baremetal application from a sdcard.

SDimage:

    A2: u-boot-with-spl.sfp

    vfat: excution.bin

I set the uboot as cycloneVdefconfig and trying to use menuconfig to set the uboot settings.

I enable the FAT in SPL setting, set the File to load for U-boot from the filesystem to excution.bin.

In Boot options->Boot media, I enabled the support for booting from SD/EMMC option and let others go as default.

I make the uboot, which gave me two warning, the setting change the ECAM clk but the sfp was made successful.

Next I use the mkimage -A arm -T standalone -c 0x0100_0000 -e 0x0100_0040 to add the special head to the bin file.

The address 0x01000000 is the same as the Uboot setting called "Address in memory to use by default".

 

I made the image through make_sdimage_p3.py set the board correctly. 

Here is the return:


U-Boot SPL 2022.10-24688-g541b6afcb1-dirty (Jun 14 2023 - 14:32:10 +0800)
DDRCAL: Scrubbing ECC RAM (1024 MiB).
DDRCAL: SDRAM-ECC initialized success with 579 ms
Trying to boot from MMC1

U-Boot SPL 2022.10-24688-g541b6afcb1-dirty (Jun 14 2023 - 14:32:10 +0800)
DDRCAL: Scrubbing ECC RAM (1024 MiB).
DDRCAL: SDRAM-ECC initialized success with 579 ms
Trying to boot from MMC1

U-Boot SPL 2022.10-24688-g541b6afcb1-dirty (Jun 14 2023 - 14:32:10 +0800)
DDRCAL: Scrubbing ECC RAM (1024 MiB).
DDRCAL: SDRAM-ECC initialized success with 579 ms
Trying to boot from MMC1

U-Boot SPL 2022.10-24688-g541b6afcb1-dirty (Jun 14 2023 - 14:32:10 +0800)
DDRCAL: Scrubbing ECC RAM (1024 MiB).
DDRCAL: SDRAM-ECC initialized success with 578 ms
Trying to boot from MMC1

 

The spl didnt start the uboot or the bin file.

 

Now I dont know how to fix that problem,

whats the correct set for the Uboot?

what's the correct   -a and -e address?

 

Looking forward to your kindly help,please

 

Reguards.

 

 

 

Labels (1)
0 Kudos
25 Replies
JingyangTeh
Employee
3,047 Views

Hi Alex


The uboot location in the partition is correct.

Could you try out the u-boot-with-spl.sfp from the GSRD?

It should work booting from the sdcard.


After you successfully load the uboot it will not automatically load the binaries you would need to load mount the sdcard in uboot and load the binary.


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
3,038 Views

Hi,

 

Ive tried the older version of SOCEDS(which will auto-make the preloader-image.bin)

The result is as followed:


U-Boot SPL 2013.01.01 (Jun 15 2023 - 14:38:04)
BOARD : Altera SOCFPGA Cyclone V Board
CLOCK: EOSC1 clock 25000 KHz
CLOCK: EOSC2 clock 25000 KHz
CLOCK: F2S_SDR_REF clock 0 KHz
CLOCK: F2S_PER_REF clock 0 KHz
CLOCK: MPU clock 925 MHz
CLOCK: DDR clock 400 MHz
CLOCK: UART clock 100000 KHz
CLOCK: MMC clock 50000 KHz
CLOCK: QSPI clock 370000 KHz
RESET: WARM
INFO : Watchdog enabled
SDRAM: Initializing MMR registers
SDRAM: Calibrating PHY
SEQ.C: Preparing to start memory calibration
SEQ.C: CALIBRATION PASSED
SDRAM: 1024 MiB
SDRAM: Initializing SDRAM ECC
SDRAM: ECC initialized successfully with 1590 ms
SDRAM: ECC Enabled
ALTERA DWMMC: 0
reading P3_Ex.bin
reading P3_Ex.bin

 

I put the P3_Ex.bin in the vfat and set -a as 0x0010_0040 -e 0 as the example "unhosted" set, but the program didnt run.

 

Any ideas?

 

Reguards.

0 Kudos
JingyangTeh
Employee
3,020 Views

Hi Alex


Your SPL logs look a bit different from the standard SPL.

What changes did you made to the SPL? Did you follow the steps in RocketBoard to build the SPL?


Could you give me some time in trying to boot the baremetal application from SD Card?

I have tried the flow of booting from QSPI but not with SD Card.

Just to confirm you build your application using the flow describe in the HWLIBS RocketBoard article right?

For the logs in the previous comment, did the SPL automatically reads the P3_Ex.bin or did you made some changes to read the P3_Ex.bin?

Is it possible for you to share the env variable of your uboot environment?



Regards

Jingyang, Teh



0 Kudos
JingyangTeh
Employee
3,007 Views

Hi Alex


I managed to boot the baremetal application from the sdcard.

First you would need to build the application at address 0x1000040 and also build the uboot SPL.

Once you got both the application binary (application.bin) and the uboot SPL (u-boot-splx4.sfp).

You can combine both binary using the command:

cat u-boot-splx4.sfp application.bin > application_combine.bin


After having the application_combine.bin you could partition it into the sdcard using the sdcard creation script with the command:

sudo python3 ./make_sdimage_p3.py -f -P application_combine.bin,num=3,format=raw,size=10M,type=A2 -s 80M -n sdcard.img


Finally flash the sdcard.img on to the sdcard.


Regards

Jingyang, Teh




0 Kudos
CAlex
New Contributor II
2,982 Views

Hi,

Thank you for your responding.

I guess this is the way for "raw address" mentioned in the AN709,

if I want to start the application in vfat,what should I do?

 

Also, I tried the older version SOCEDS (before 19.0) so when you "make" the spl it will make a preloader-image.bin, this is the image I use.

 

Reguards.

 

 

0 Kudos
JingyangTeh
Employee
2,972 Views

Hi Alex


Could you give me some time to try out booting from sdcard in vfat file format?

I will get back to you once I got some results.


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
2,955 Views

Year sure please take your time, either before SOCEDS 19.1 or after is Okey.

 

Thank you for your help.

 

Reguards.

0 Kudos
JingyangTeh
Employee
2,904 Views

Hi CAlex


I could not boot from the sdcard using vfat format, only able to boot using the raw format.

You will need to use the raw format to boot from the sdcard.


I am using SOCED20.1


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
2,899 Views

Hi,

I managed to flash the image to the sdcard and start the board, the bin is a simple hello world printf.

I started the board and pushed the warm reset button, but nothing happened.

The booting mesege is the same as the SPL.

 

Any ideas?

 

Reguards.

0 Kudos
JingyangTeh
Employee
2,867 Views

Hi Alex


Are you using the raw format partition like I suggested?

I have tried out the vfat partition and found that it is not possible to load the SPL.

With the raw format, I am able to see the SPL logs and the logs of the baremetal.


When you compiled the baremetal application did you move the start address to be 0x1000040?


Regards

Jingyang, Teh


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
2,860 Views

Hi

 

Yes,I used the raw format.

 

I changed the default linker by changing all 0x0010_0040 to 0x0100_0040 to make the address fit the SPL setting address,

then I cahnged the 0x80_0000 to 0x0020_0000, to move the stack out of the way just in case.

Next,I made the hello.c to app.axf and use 

" arm-eabi-objcopy  -O binary app.axf app.bin" 

to build the bin file.

Then I use mkimage -A arm -T standalone -C none -a 0x01000040 -e 0x01000040 -n "bare-metal image" -d app.bin app.img 

to get the img file.

 

I made the SPL(which is working well) and combine the img and u-boot-splx4.sfp together with order:

cat app.img u-boot-splx4.sfp > final.bin.

 

I used the make_sdimage_p3.py to make the SD image.

 

After that,I used the rufus to copy the bin into the sdcard and started the board.

 

After several times of

"

U-Boot SPL 2022.10-24688-g541b6afcb1-dirty (Jun 14 2023 - 14:32:10 +0800)
DDRCAL: Scrubbing ECC RAM (1024 MiB).
DDRCAL: SDRAM-ECC initialized success with 579 ms
Trying to boot from MMC1

"

The hello world! string didnt appear.

 

I've tried to study the example of "unhosted" but the linker file is totally different from the default ones.

 

 

If convenient, could you please give me your hello world project with all bin,axf,linker file and img file.

 

Or if you need my project I 'll give mine to you.

 

Reguards.

0 Kudos
JingyangTeh
Employee
2,796 Views

Hi Alex

 

I am using the hwlibs examples located here:

https://www.rocketboards.org/foswiki/Documentation/HWLib#Running_Cyclone_V_HWLib_Example

 

Please find the binaries attached.

 

If you could also send me your copy that would be great.

 

I see that the steps that you are using is slightly different from mine.

The steps of creating the binary, i am using the command below:

"arm-eabi-objcopy -O binary application.elf application.bin"

 

The application should be in .elf instead of .axf.

You can change the Makefile line 54 to "ELF := application.elf".

 

Regards

Jingyang, Teh

 

0 Kudos
CAlex
New Contributor II
2,787 Views

Hi,

 

Sure, I'll attach my code to you, one is for arm ds, and another is for sdimage.

 

Meanwhile I'll try to use elf instead of axf, although I think there is no difference between two binaries.

 

Reguards.

0 Kudos
CAlex
New Contributor II
2,781 Views

Hi,

Update

Your temp is working pretty well, but my helloworld didnt work.

Ive tried the elf version,yet the result is the same.

 

Could you share your build sequence?

 

Reguards.

0 Kudos
CAlex
New Contributor II
2,768 Views

Hi,

Update 2

 I used the objdump to check the elf file,it shows the entry address is 0x0100_0060,

and your elf is 0x0010_0080(which make sence for it need 0x40 header from mkimage),

I didnt change the linker file or other settings except the "." from 0x0010_0040 to 0x0100_0040,

if MY ASSUMPTION is correct,the start address of my elf should be 0x0100_0080 INSTEAD OF 0x0100-0060.

 

 

Do you know why is that?

 

Reguards.

0 Kudos
CAlex
New Contributor II
2,738 Views

Hi,

Update 3

The start address problem is duel to the interrupt vector.

So the main problem is not the different start address of the elf file.

 

Reguards.

0 Kudos
CAlex
New Contributor II
2,733 Views

Hi,

 

Did you changed the spl payload setting to fit your bin file?

0 Kudos
CAlex
New Contributor II
2,703 Views

Hi,

Ive tried another project code, and it was successful.

 

I used the 0x01000040 as start address in the linker file, and conformed that you need to add the interrupt vector as the 0x01000060 so that the _socfpga_main at address 0x01000080 .

 

Now I have two questions:

 

1. I have a lot of printfs and added the "\n" at each printf,

but the result is a total mess:

 

U-Boot SPL 2020.07-08705-g35d7cfb999-dirty (Jul 10 2023 - 17:29:47 +0800)
DDRCAL: Scrubbing ECC RAM (1024 MiB).
DDRCAL: SDRAM-ECC initialized success with 578 ms
Trying to boot from MMC1
INFO: System init start. INFO: HPS Timer Initialization.INFO: Setting up Global Timer.INFO: Initializing General Purpose Timers.INFO: Initializing Watchdog 0 Timer.INFO: System Initialization.INFO: Init GPIO module.INFO: Setting up GPIO interrupt.INFO: Set up GPIO for LEDs.INFO: Set up GPIO for Push button.INFO: Register interrupt handler.INFO: HPS Timer Interrupt Setup.INFO: Setup DMA System ...INFO: Setup of DMA successful.
INFO: Setup FPGA System ...INFO: Setup of FPGA successful.
INFO: Sine Initial DoneINFO: Start L4SP1 Timer interrupts.Start the timer.INFO: Checking if SP Timer 1 is running.INFO: SP Timer 1 is running.INFO: System uninit.INFO: Cleaning up GPIO interrupt.INFO: Cleaning up Timer interrupts.INFO: Cleanup of FPGA ...INFO: Cleaning up DMA System ...

 

2. How should I do to start the code from the qspi?Could you please give me some guides or steps to do that?

 

Thank you very much.

 

 

Reguards.

 

0 Kudos
JingyangTeh
Employee
2,683 Views

Hi Alex


Could you share a snippet of your code of how you printf?

Here is a line from the example which


    printf("RESULT: Example completed successfully.\n");


For the QSPI you could reuse the binary file that you created that combine the SPL and your application binary.

You will need to flash the binary at the QSPI flash address 0, remember to swtich the BSEL to boot from QSPI.


Regards

Jingyang, Teh


0 Kudos
CAlex
New Contributor II
2,674 Views

Hi,

that's how I did for printf ,  and debug shows it worked well.

 

About QSPI, could you please tell me how to  "flash the binary at the QSPI flash address 0" ?

Does that mean I need to use mkimage to set the -a and -e to 0x0? and that's it?

 

Thanks.

Reguards.

0 Kudos
Reply