Porting Cora Z7 Board to barebox
I have a Cora Z7 board which I want to port to barebox. The Cora Z7 embeds an Zynq 7000 SoC with a single core Cortex-A9 and 512 MB DDR3 memory. Barebox already supports the Zynq 7000 and the Avnet Zedboard.
I have some questions and maybe you can point me in the right direction:
When I am compiling barebox with the zynq_defconfig, as an output I get the file barebox-avnet-zedboard.img. This file contains the PBL, barebox proper and the device tree, right?
The Cora Z7 uses a different memory configuration compared to the Zedboard. My first idea was to use Xilinx FSBL and let the FSBL start barebox. The FSBL can start an ELF file. But if I use just the compiled barebox file, the device tree is missing, right? Is there a way to hard code the UART to use for the barebox console for barebox proper?
The Zynq on the Cora Z7 only embeds a single core Cortex A9 while the SoC on the Zedboard embeds a dual core Cortex A9. Does this affect the cores initialization in arch/arm/mach_zynq?
I am looking forward to your replies.
Thank you and best regards,
Johannes Roith
Hi Johannes,
Quoted 9 lines · On Mon, Apr 28, 2025 at 07:20:01PM +0200, [email protected] wrote:
I have a Cora Z7 board which I want to port to barebox. The Cora Z7 embeds an Zynq 7000 SoC with a single core Cortex-A9 and 512 MB DDR3 memory. Barebox already supports the Zynq 7000 and the Avnet Zedboard.
I have some questions and maybe you can point me in the right direction:
When I am compiling barebox with the
zynq_defconfig, as an output I get the file barebox-avnet-zedboard.img. This file contains the PBL, barebox proper and the device tree, right?
Right.
Quoted 5 lines
The Cora Z7 uses a different memory configuration compared to the Zedboard. My first idea was to use Xilinx FSBL and let the FSBL start barebox. The FSBL can start an ELF file. But if I use just the compiled barebox file, the device tree is missing, right?
In case of the Zedboard you could take start_avnet_zedboard.pbl. This contains all necessary components including device tree and barebox proper.
However, this binary is linked to 0x0 and the FSBL will likely load it there. I don't know where the FSBL itself is located.
Quoted 2 lines
Is there a way to hard code the UART to use for the barebox console for barebox proper?
Why do you want to hardcode it? Setting the console via device tree is just fine.
For debugging your early code I recommend CONFIG_DEBUG_LL. For zynq the UART is hardcoded to ZYNQ_UART1_BASE_ADDR in include/mach/zynq/debug_ll.h. You can change it in this file.
With CONFIG_DEBUG_LL enabled you can put putc_ll() in your code.
Quoted 4 lines
The Zynq on the Cora Z7 only embeds a single core Cortex A9 while the SoC on the Zedboard embeds a dual core Cortex A9. Does this affect the cores initialization in
arch/arm/mach_zynq?
I don't think so. I haven't used Zynq myself though.
Regards,
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi,
Quoted 6 lines · Sascha Hauer
In case of the Zedboard you could take start_avnet_zedboard.pbl. This contains all necessary components including device tree and barebox proper.
However, this binary is linked to
0x0and the FSBL will likely load it there. I don't know where the FSBL itself is located.
The pbl files tend to be a bit bigger, because they are meant only as input to objcopy. You can add to images/Makefile.zynq, e.g.
image-$(CONFIG_MACH_ZEDBOARD) += start_avnet_zedboard.elf
And it will generate a much more compact ELF file that should be interchangeable (I had tested this on ZynqMP).
Quoted 11 lines
Quoted 2 lines
Is there a way to hard code the UART to use for the barebox console for barebox proper?
Why do you want to hardcode it? Setting the console via device tree is just fine.
For debugging your early code I recommend
CONFIG_DEBUG_LL. For zynq the UART is hardcoded toZYNQ_UART1_BASE_ADDRininclude/mach/zynq/debug_ll.h. You can change it in this file.With
CONFIG_DEBUG_LLenabled you can putputc_ll()in your code.
CONFIG_DEBUG_PBL is also often useful.
Quoted 5 lines
Quoted 3 lines
The Zynq on the Cora Z7 only embeds a single core Cortex A9 while the SoC on the Zedboard embeds a dual core Cortex A9. Does this affect the cores initialization in
arch/arm/mach_zynq?I don't think so. I haven't used Zynq myself though.
Cheers,
Ahmad
Quoted 4 lines
Regards,
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi,
thanks for the fast replies.
Am Tue, Apr 29, 2025 at 11:49:40AM +0200 schrieb Ahmad Fatoum:
Quoted 9 lines
Hi,
Quoted 6 lines · Sascha Hauer
In case of the Zedboard you could take start_avnet_zedboard.pbl. This contains all necessary components including device tree and barebox proper.
However, this binary is linked to
0x0and the FSBL will likely load it there. I don't know where the FSBL itself is located.
Can I change the address to which barebox is linked to? E.g. in Vitis the application is linked to 0x10000 and the FSBL starting this application to 0x0.
Quoted 29 lines
The pbl files tend to be a bit bigger, because they are meant only as input to objcopy. You can add to images/Makefile.zynq, e.g.
image-$(CONFIG_MACH_ZEDBOARD) += start_avnet_zedboard.elfAnd it will generate a much more compact ELF file that should be interchangeable (I had tested this on ZynqMP).
Quoted 11 lines
Quoted 2 lines
Is there a way to hard code the UART to use for the barebox console for barebox proper?
Why do you want to hardcode it? Setting the console via device tree is just fine.
For debugging your early code I recommend
CONFIG_DEBUG_LL. For zynq the UART is hardcoded toZYNQ_UART1_BASE_ADDRininclude/mach/zynq/debug_ll.h. You can change it in this file.With
CONFIG_DEBUG_LLenabled you can putputc_ll()in your code.
CONFIG_DEBUG_PBLis also often useful.Quoted 5 lines
Quoted 3 lines
The Zynq on the Cora Z7 only embeds a single core Cortex A9 while the SoC on the Zedboard embeds a dual core Cortex A9. Does this affect the cores initialization in
arch/arm/mach_zynq?I don't think so. I haven't used Zynq myself though.
Quoted 14 lines
Cheers,
AhmadQuoted 4 lines
Regards,
SaschaSignature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
The good news is, I can boot barebox (PBL and proper) now and sometimes also can Linux. Here is the output of my barebox:
Digilent Cora Z7 PBLuncompress.c: memory at 0x00000000, size 0x20000000
mmu: enabling MMU, ttb @ 0x1ffd0000
endmem = 0x20000000 arm_mem_scratch = 0x1fff8000+0x00008000 arm_mem_stack = 0x1ffe9000+0x0000f000 arm_mem_ttb = 0x1ffd0000+0x00010000
arm_mem_barebox_image = 0x1fe00000+0x00200000arm_mem_early_malloc = 0x1fde0000+0x00020000
membase = 0x00000000+0x20000000uncompress.c: uncompressing barebox binary at 0x00006270 (size 0x00029c0c) to 0x1fe00000 (uncompressed size: 0x0006c0e8) uncompress.c: jumping to uncompressed image at 0x1fe00000
barebox 2025.04.0-00215-gdacb19ae3252-dirty #11 Wed Apr 30 22:22:15 CEST 2025
Board: Digilent Cora Z7
ERROR: could not get clock /axi/dma-controller@f8003000:apb_pclk(0)
ERROR: could not get clock /axi/etb@f8801000:apb_pclk(0)
ERROR: could not get clock /axi/tpiu@f8803000:apb_pclk(0)
ERROR: could not get clock /axi/funnel@f8804000:apb_pclk(0)
ERROR: could not get clock /axi/ptm@f889c000:apb_pclk(0)
ERROR: could not get clock /axi/ptm@f889d000:apb_pclk(0)mdio_bus: miibus0: probed
macb [email protected]: Cadence GEM at 0xe000b000 arasan-sdhci [email protected]: registered as mmc0
malloc space: 0x17e00000 -> 0x1fdfffff (size 128 MiB)
arasan-sdhci [email protected]: error while transferring data for command 6 arasan-sdhci [email protected]: state = 0x01f70202 , interrupt = 0x00208000
mmc0: Card's startup fails with -74
barebox-environment chosen:environment-sd.of: probe failed: No such file or directory environment load /dev/env0: No such file or directory
Maybe you have to create the partition.
Do you know what to do about the "could not get clock errors"? Do I have to take care about them or just ignore them?
The more critical error comes from the SD card. Every second boot I am getting the errors shown above, sometimes the card is started correctly.
Also when barebox can startup the mmc0, when starting the Linux Kernel sometimes the rootfs on /dev/mmcblk0p2 is not found and the SD Card is not detected. So, there seems to be something wrong with the SD Card interface...
In lowlevel.c I am setting the clock divider for the sdio0 interface to 10 and the Source for generated clock is IO PLL. Therefore, the sdio IP should get a 100 MHz input clock. IS this correct? Do you know which clockrate the driver expects?
Or do you have any other idea what could case the error?
In case I can fix the remaining errors I would like to bring the changes upstream and send a patch. Here I also have some questions:
I added the following files and folder:
arch/arm/boards/digilent-cora/
arch/arm/dts/zynq-cora.dts
dts/src/arm/xilinx/zynq-cora.dts
arch/arm/boards/digilent-cora/ is a copy of arch/arm/boards/avnet-zed/ with my changes applied. In the Copyright, should I keep the existing name and just add mine as a second author?
If I understand it correctly, the files in dts/src are imported from the Linux kernel git repo, right? In this case I should try to bring my modified device tree mainline to Linux first and then commit my changes to barebox? Or is there another file location I can drop my device tree temporarily until it is available in Linux?
And a last question: How can I change the default boot method in barebox from net to mmc0?
Thanks and best regards,
Johannes
Am Thu, May 01, 2025 at 02:16:44PM +0200 schrieb Johannes Roith:
Quoted 105 lines
Hi,
thanks for the fast replies.
Am Tue, Apr 29, 2025 at 11:49:40AM +0200 schrieb Ahmad Fatoum:
Quoted 9 lines
Hi,
Quoted 6 lines · Sascha Hauer
In case of the Zedboard you could take start_avnet_zedboard.pbl. This contains all necessary components including device tree and barebox proper.
However, this binary is linked to
0x0and the FSBL will likely load it there. I don't know where the FSBL itself is located.Can I change the address to which barebox is linked to? E.g. in Vitis the application is linked to
0x10000and the FSBL starting this application to0x0.Quoted 29 lines
The pbl files tend to be a bit bigger, because they are meant only as input to objcopy. You can add to images/Makefile.zynq, e.g.
image-$(CONFIG_MACH_ZEDBOARD) += start_avnet_zedboard.elfAnd it will generate a much more compact ELF file that should be interchangeable (I had tested this on ZynqMP).
Quoted 11 lines
Quoted 2 lines
Is there a way to hard code the UART to use for the barebox console for barebox proper?
Why do you want to hardcode it? Setting the console via device tree is just fine.
For debugging your early code I recommend
CONFIG_DEBUG_LL. For zynq the UART is hardcoded toZYNQ_UART1_BASE_ADDRininclude/mach/zynq/debug_ll.h. You can change it in this file.With
CONFIG_DEBUG_LLenabled you can putputc_ll()in your code.
CONFIG_DEBUG_PBLis also often useful.Quoted 5 lines
Quoted 3 lines
The Zynq on the Cora Z7 only embeds a single core Cortex A9 while the SoC on the Zedboard embeds a dual core Cortex A9. Does this affect the cores initialization in
arch/arm/mach_zynq?I don't think so. I haven't used Zynq myself though.
Quoted 14 lines
Cheers,
AhmadQuoted 4 lines
Regards,
SaschaSignature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |The good news is, I can boot barebox (PBL and proper) now and sometimes also can Linux. Here is the output of my barebox:
Digilent Cora Z7 PBL
uncompress.c: memory at0x00000000, size0x20000000
mmu: enabling MMU, ttb @0x1ffd0000endmem = 0x20000000 arm_mem_scratch = 0x1fff8000+0x00008000 arm_mem_stack = 0x1ffe9000+0x0000f000 arm_mem_ttb = 0x1ffd0000+0x00010000
arm_mem_barebox_image= 0x1fe00000+0x00200000arm_mem_early_malloc= 0x1fde0000+0x00020000
membase = 0x00000000+0x20000000uncompress.c: uncompressing barebox binary at0x00006270(size0x00029c0c) to0x1fe00000(uncompressed size:0x0006c0e8)uncompress.c: jumping to uncompressed image at0x1fe00000barebox 2025.04.0-00215-gdacb19ae3252-dirty #11 Wed Apr 30 22:22:15 CEST 2025
Board: Digilent Cora Z7
ERROR: could not get clock /axi/dma-controller@f8003000:apb_pclk(0)
ERROR: could not get clock /axi/etb@f8801000:apb_pclk(0)
ERROR: could not get clock /axi/tpiu@f8803000:apb_pclk(0)
ERROR: could not get clock /axi/funnel@f8804000:apb_pclk(0)
ERROR: could not get clock /axi/ptm@f889c000:apb_pclk(0)
ERROR: could not get clock /axi/ptm@f889d000:apb_pclk(0)mdio_bus: miibus0: probed
macb [email protected]: Cadence GEM at0xe000b000arasan-sdhci [email protected]: registered as mmc0
malloc space:0x17e00000->0x1fdfffff(size 128 MiB)
arasan-sdhci [email protected]: error while transferring data for command 6 arasan-sdhci [email protected]: state =0x01f70202, interrupt =0x00208000
mmc0: Card's startup fails with -74
barebox-environment chosen:environment-sd.of: probe failed: No such file or directory environment load/dev/env0: No such file or directory
Maybe you have to create the partition.Do you know what to do about the "could not get clock errors"? Do I have to take care about them or just ignore them?
Quoted 7 lines
The more critical error comes from the SD card. Every second boot I am getting the errors shown above, sometimes the card is started correctly.
Also when barebox can startup the mmc0, when starting the Linux Kernel sometimes the rootfs on
/dev/mmcblk0p2is not found and the SD Card is not detected. So, there seems to be something wrong with the SD Card interface...
Maybe because I missed the rootwait argument for the Linux Kernel Commandline...
Quoted 7 lines
In
lowlevel.cI am setting the clock divider for the sdio0 interface to 10 and the Source for generated clock is IO PLL. Therefore, the sdio IP should get a 100 MHz input clock. IS this correct? Do you know which clockrate the driver expects?Or do you have any other idea what could case the error?
Ok, I found out that maybe 100 MHz is a little bit to slow for this SD Card IP. When setting the clock to 200 MHz or 250 MHz, the mmc0 gets detected all the time by barebox.
Quoted 26 lines
In case I can fix the remaining errors I would like to bring the changes upstream and send a patch. Here I also have some questions:
I added the following files and folder:
arch/arm/boards/digilent-cora/
arch/arm/dts/zynq-cora.dts
dts/src/arm/xilinx/zynq-cora.dts
arch/arm/boards/digilent-cora/is a copy ofarch/arm/boards/avnet-zed/with my changes applied. In the Copyright, should I keep the existing name and just add mine as a second author?If I understand it correctly, the files in dts/src are imported from the Linux kernel git repo, right? In this case I should try to bring my modified device tree mainline to Linux first and then commit my changes to barebox? Or is there another file location I can drop my device tree temporarily until it is available in Linux?
And a last question: How can I change the default boot method in barebox from net to mmc0?
Thanks and best regards,
Johannes
Quoted 12 lines · Johannes Roith
Hi,
thanks for the fast replies.
Am Tue, Apr 29, 2025 at 11:49:40AM +0200 schrieb Ahmad Fatoum:
Quoted 7 lines
Hi,
Quoted 4 lines · Sascha Hauer
In case of the Zedboard you could take start_avnet_zedboard.pbl. This contains all necessary components including device tree and barebox proper.
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
However, this binary is linked to
0x0and the FSBL will likely load it there. I don't know where the FSBL itself is located.Can I change the address to which barebox is linked to? E.g. in Vitis the application is linked to
0x10000and the FSBL starting this application to0x0.
First of all the barebox binary is relocatable, you can start it at any address.
You could change the address by adjusting ARCH_TEXT_BASE, but why would you? From the output below it seems your binary just starts fine from address 0x0.
Quoted 41 lines
The good news is, I can boot barebox (PBL and proper) now and sometimes also can Linux. Here is the output of my barebox:
Digilent Cora Z7 PBL
uncompress.c: memory at0x00000000, size0x20000000
mmu: enabling MMU, ttb @0x1ffd0000endmem = 0x20000000 arm_mem_scratch = 0x1fff8000+0x00008000 arm_mem_stack = 0x1ffe9000+0x0000f000 arm_mem_ttb = 0x1ffd0000+0x00010000
arm_mem_barebox_image= 0x1fe00000+0x00200000arm_mem_early_malloc= 0x1fde0000+0x00020000
membase = 0x00000000+0x20000000uncompress.c: uncompressing barebox binary at0x00006270(size0x00029c0c) to0x1fe00000(uncompressed size:0x0006c0e8)uncompress.c: jumping to uncompressed image at0x1fe00000barebox 2025.04.0-00215-gdacb19ae3252-dirty #11 Wed Apr 30 22:22:15 CEST 2025
Board: Digilent Cora Z7
ERROR: could not get clock /axi/dma-controller@f8003000:apb_pclk(0)
ERROR: could not get clock /axi/etb@f8801000:apb_pclk(0)
ERROR: could not get clock /axi/tpiu@f8803000:apb_pclk(0)
ERROR: could not get clock /axi/funnel@f8804000:apb_pclk(0)
ERROR: could not get clock /axi/ptm@f889c000:apb_pclk(0)
ERROR: could not get clock /axi/ptm@f889d000:apb_pclk(0)mdio_bus: miibus0: probed
macb [email protected]: Cadence GEM at0xe000b000arasan-sdhci [email protected]: registered as mmc0
malloc space:0x17e00000->0x1fdfffff(size 128 MiB)
arasan-sdhci [email protected]: error while transferring data for command 6 arasan-sdhci [email protected]: state =0x01f70202, interrupt =0x00208000
mmc0: Card's startup fails with -74
barebox-environment chosen:environment-sd.of: probe failed: No such file or directory environment load/dev/env0: No such file or directory
Maybe you have to create the partition.
Quoted 2 lines
Do you know what to do about the "could not get clock errors"? Do I have to take care about them or just ignore them?
We don't have drivers for any of the devices that you fail to get a clock for, so that is not a problem.
Anyway, the clocks are registered by the clock driver, so normally they should be found.
Do you have BAREBOX_DEEP_PROBE_ENABLE() in your board file? If not, please add it. It makes sure the clock driver is probed once we need a clock.
Quoted 8 lines
The more critical error comes from the SD card. Every second boot I am getting the errors shown above, sometimes the card is started correctly.
Also when barebox can startup the mmc0, when starting the Linux Kernel sometimes the rootfs on
/dev/mmcblk0p2is not found and the SD Card is not detected. So, there seems to be something wrong with the SD Card interface...
You found out yourself, but yes, rootwait is needed to boot from SD/eMMC cards.
Quoted 13 lines
In
lowlevel.cI am setting the clock divider for the sdio0 interface to 10 and the Source for generated clock is IO PLL. Therefore, the sdio IP should get a 100 MHz input clock. IS this correct? Do you know which clockrate the driver expects?Or do you have any other idea what could case the error?
In case I can fix the remaining errors I would like to bring the changes upstream and send a patch. Here I also have some questions:
I added the following files and folder:
Quoted 7 lines
arch/arm/boards/digilent-cora/
arch/arm/dts/zynq-cora.dts
dts/src/arm/xilinx/zynq-cora.dts
arch/arm/boards/digilent-cora/is a copy ofarch/arm/boards/avnet-zed/with my changes applied. In the Copyright, should I keep the existing name and just add mine as a second author?
I'd say in this case just replace the original author with your name. You would likely have come up with the same file if you had written it yourself.
Quoted 3 lines
If I understand it correctly, the files in dts/src are imported from the Linux kernel git repo, right?
Yes, right.
Quoted 4 lines
In this case I should try to bring my
modified device tree mainline to Linux first and then commit my changes to barebox? Or is there another file location I can drop my device tree temporarily until it is available in Linux?
We thought about creating a an extra directory for dts files which are pending upstream, but we are not there yet.
Best practice is to separate the barebox specific dts stuff from the about-to-be-upstreamed stuff and put both files into arch/arm/dts. With this we can just drop the non-barebox specific file once it's in Linux upstream without losing the barebox specific changes.
Quoted 3 lines
And a last question: How can I change the default boot method in barebox from net to mmc0?
nv boot.default="mmc0". See https://www.barebox.org/doc/latest/user/variables.html
and the output of the "magicvar" command
Regards,
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Sascha,
thanks for the fast reply.
Am Mon, May 05, 2025 at 09:39:41AM +0200 schrieb Sascha Hauer:
Quoted 20 lines · Johannes Roith
Quoted 12 lines
Hi,
thanks for the fast replies.
Am Tue, Apr 29, 2025 at 11:49:40AM +0200 schrieb Ahmad Fatoum:
Quoted 7 lines
Hi,
Quoted 4 lines · Sascha Hauer
In case of the Zedboard you could take start_avnet_zedboard.pbl. This contains all necessary components including device tree and barebox proper.
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
However, this binary is linked to
0x0and the FSBL will likely load it there. I don't know where the FSBL itself is located.Can I change the address to which barebox is linked to? E.g. in Vitis the application is linked to
0x10000and the FSBL starting this application to0x0.
Quoted 6 lines
First of all the barebox binary is relocatable, you can start it at any address.
You could change the address by adjusting
ARCH_TEXT_BASE, but why would you? From the output below it seems your binary just starts fine from address0x0.
The Zynq-7000 has a processor system (PS) with a Cortex-A9 and a programmable logic (PL) which is basically a FPGA. With barebox I can't load a bitstream to the FPGA. Or does barebox provides an interface for loading FPGAs?
My idea was to use Xilinx FSBL which loads the bitstream to the FPGA and then loads an ELF file. The problem is, if the ELF file is linked to address 0x0 like the FSBL, the FSBL overwrites its code when loading the ELF file and crashes.
But if I write a small application which is loaded by the FSBL I can read start_dt_2nd.pblb from the mmc, put it somewhere in DRAM memory and jump to it. This should start the barebox proper, right?
I set ARCH_TEXT_BASE to 0x1000_0000 as you suggested and create a Xilinx Boot Image with start_dt_2nd.pbl inside, but the ELF file seems still be linked for 0x0. The FSBL loaded the FPGA but barebox never booted, so I guess the FSBL overwrote itself.
Quoted 48 lines
Quoted 42 lines
The good news is, I can boot barebox (PBL and proper) now and sometimes also can Linux. Here is the output of my barebox:
Digilent Cora Z7 PBL
uncompress.c: memory at0x00000000, size0x20000000
mmu: enabling MMU, ttb @0x1ffd0000endmem = 0x20000000 arm_mem_scratch = 0x1fff8000+0x00008000 arm_mem_stack = 0x1ffe9000+0x0000f000 arm_mem_ttb = 0x1ffd0000+0x00010000
arm_mem_barebox_image= 0x1fe00000+0x00200000arm_mem_early_malloc= 0x1fde0000+0x00020000
membase = 0x00000000+0x20000000uncompress.c: uncompressing barebox binary at0x00006270(size0x00029c0c) to0x1fe00000(uncompressed size:0x0006c0e8)uncompress.c: jumping to uncompressed image at0x1fe00000barebox 2025.04.0-00215-gdacb19ae3252-dirty #11 Wed Apr 30 22:22:15 CEST 2025
Board: Digilent Cora Z7
ERROR: could not get clock /axi/dma-controller@f8003000:apb_pclk(0)
ERROR: could not get clock /axi/etb@f8801000:apb_pclk(0)
ERROR: could not get clock /axi/tpiu@f8803000:apb_pclk(0)
ERROR: could not get clock /axi/funnel@f8804000:apb_pclk(0)
ERROR: could not get clock /axi/ptm@f889c000:apb_pclk(0)
ERROR: could not get clock /axi/ptm@f889d000:apb_pclk(0)mdio_bus: miibus0: probed
macb [email protected]: Cadence GEM at0xe000b000arasan-sdhci [email protected]: registered as mmc0
malloc space:0x17e00000->0x1fdfffff(size 128 MiB)
arasan-sdhci [email protected]: error while transferring data for command 6 arasan-sdhci [email protected]: state =0x01f70202, interrupt =0x00208000
mmc0: Card's startup fails with -74
barebox-environment chosen:environment-sd.of: probe failed: No such file or directory environment load/dev/env0: No such file or directory
Maybe you have to create the partition.Quoted 2 lines
Do you know what to do about the "could not get clock errors"? Do I have to take care about them or just ignore them?
We don't have drivers for any of the devices that you fail to get a clock for, so that is not a problem.
Quoted 6 lines
Anyway, the clocks are registered by the clock driver, so normally they should be found.
Do you have
BAREBOX_DEEP_PROBE_ENABLE()in your board file? If not, please add it. It makes sure the clock driver is probed once we need a clock.
Thanks, adding BAREBOX_DEEP_PROBE_ENABLE() fixed it. Now the errors do no longer appear.
Quoted 30 lines
Quoted 9 lines
The more critical error comes from the SD card. Every second boot I am getting the errors shown above, sometimes the card is started correctly.
Also when barebox can startup the mmc0, when starting the Linux Kernel sometimes the rootfs on
/dev/mmcblk0p2is not found and the SD Card is not detected. So, there seems to be something wrong with the SD Card interface...You found out yourself, but yes, rootwait is needed to boot from SD/eMMC cards.
Quoted 17 lines
In
lowlevel.cI am setting the clock divider for the sdio0 interface to 10 and the Source for generated clock is IO PLL. Therefore, the sdio IP should get a 100 MHz input clock. IS this correct? Do you know which clockrate the driver expects?Or do you have any other idea what could case the error?
In case I can fix the remaining errors I would like to bring the changes upstream and send a patch. Here I also have some questions:
I added the following files and folder:
arch/arm/boards/digilent-cora/
arch/arm/dts/zynq-cora.dts
dts/src/arm/xilinx/zynq-cora.dts
Quoted 7 lines
Quoted 3 lines
arch/arm/boards/digilent-cora/is a copy ofarch/arm/boards/avnet-zed/with my changes applied. In the Copyright, should I keep the existing name and just add mine as a second author?I'd say in this case just replace the original author with your name. You would likely have come up with the same file if you had written it yourself.
OK, thanks.
Quoted 12 lines
Quoted 4 lines
If I understand it correctly, the files in dts/src are imported from the Linux kernel git repo, right?
Yes, right.
Quoted 4 lines
In this case I should try to bring my
modified device tree mainline to Linux first and then commit my changes to barebox? Or is there another file location I can drop my device tree temporarily until it is available in Linux?
Quoted 8 lines
We thought about creating a an extra directory for dts files which are pending upstream, but we are not there yet.
Best practice is to separate the barebox specific dts stuff from the about-to-be-upstreamed stuff and put both files into
arch/arm/dts. With this we can just drop the non-barebox specific file once it's in Linux upstream without losing the barebox specific changes.
Currently both files are named zynq-cora.dts. What would be a good name for the DT which will be replaced when upstreamed to Linux? zynq-cora-linux.dts?
Quoted 6 lines
Quoted 3 lines
And a last question: How can I change the default boot method in barebox from net to mmc0?
nv boot.default="mmc0". See https://www.barebox.org/doc/latest/user/variables.html
and the output of the "magicvar" command
Ok, it now tries to boot from mmc0, but I am getting an error:
Board: Digilent Cora Z7
deep-probe: supported due to xlnx,zynq-coramdio_bus: miibus0: probed
macb [email protected]: Cadence GEM at 0xe000b000 arasan-sdhci [email protected]: registered as mmc0 malloc space: 0x17e00000 -> 0x1fdfffff (size 128 MiB)
mmc0: detected SD card version 2.0
mmc0: registered mmc0
Hit any to stop autoboot: 3
barebox@Digilent Cora Z7:/ boot
Nothing bootable found on 'mmc0'
Nothing bootable found
barebox@Digilent Cora Z7:/ nv
allow_color: true
autoboot_timeout: 3
boot.default: mmc0
linux.bootargs.console: console=ttyPS1,115200 root=/dev/mmcblk0p2 rootwait
user: none
I have an SD card with a FAT32 and an EXT4 partition. On the FAT32 I have the zImage of the Linux kernel. Am I missing something here?
Quoted 9 lines
Regards,
SaschaSignature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Best regard,
Johannes
Hi Johannes,
Quoted 4 lines · Johannes Roith
The Zynq-7000 has a processor system (PS) with a Cortex-A9 and a programmable logic (PL) which is basically a FPGA. With barebox I can't load a bitstream to the FPGA. Or does barebox provides an interface for loading FPGAs?
As mentioned in the other thread, there is a framework for firmware loading, which is already used for ZynqMP for example.
Quoted 8 lines
My idea was to use Xilinx FSBL which loads the bitstream to the FPGA and then loads an ELF file. The problem is, if the ELF file is linked to address
0x0like the FSBL, the FSBL overwrites its code when loading the ELF file and crashes.But if I write a small application which is loaded by the FSBL I can read start_dt_2nd.pblb from the mmc, put it somewhere in DRAM memory and jump to it. This should start the barebox proper, right?
A barebox build can generate multiple image, so if you need a separate first stage bootloader, just create a new PBL entry point, but don't call barebox_arm_entry. See for example arch/arm/boards/sama5d27-som1/lowlevel.c; On the AT91, the BootROM looks for a BOOT.BIN file on the FAT and then that BOOT.BIN file looks for a barebox.bin and loads it into DRAM after setting it up.
You'll probably notice that the PBL MMC drivers in barebox are a bit peculiar; normally the BootROM doesn't reset the SD-Card and often even keeps the SD-Card controller running, so barebox PBL makes use of that by just sending a read multiple block command to the SD-Card to chainload the big barebox after SDRAM has been set up. This saves a lot of time, complexity and image size.
The alternative would be having a MMC stack in the PBL and doing that initialization dance for the card after resetting it. There are out-of-tree patches for that, but I'd suggest you try doing it like other in-tree boards do if you are interested in FSBL support inside barebox.
Quoted 4 lines
I set
ARCH_TEXT_BASEto 0x1000_0000 as you suggested and create a Xilinx Boot Image with start_dt_2nd.pbl inside, but the ELF file seems still be linked for0x0. The FSBL loaded the FPGA but barebox never booted, so I guess the FSBL overwrote itself.
Did you see any early DEBUG_LL output at least? Or did you resolve this by now?
Quoted 9 lines
Quoted 5 lines
Best practice is to separate the barebox specific dts stuff from the about-to-be-upstreamed stuff and put both files into
arch/arm/dts. With this we can just drop the non-barebox specific file once it's in Linux upstream without losing the barebox specific changes.Currently both files are named
zynq-cora.dts. What would be a good name for the DT which will be replaced when upstreamed to Linux?zynq-cora-linux.dts?
That works I guess.
Quoted 28 lines
Quoted 5 lines
Quoted 2 lines
And a last question: How can I change the default boot method in barebox from net to mmc0?
nv boot.default="mmc0". See https://www.barebox.org/doc/latest/user/variables.html
and the output of the "magicvar" commandOk, it now tries to boot from mmc0, but I am getting an error:
Board: Digilent Cora Z7
deep-probe: supported due to xlnx,zynq-coramdio_bus: miibus0: probed
macb [email protected]: Cadence GEM at0xe000b000arasan-sdhci [email protected]: registered as mmc0 malloc space:0x17e00000->0x1fdfffff(size 128 MiB)
mmc0: detected SD card version 2.0
mmc0: registered mmc0Hit any to stop autoboot: 3
barebox@Digilent Cora Z7:/ boot
Nothing bootable found on 'mmc0'
Nothing bootable found
barebox@Digilent Cora Z7:/ nv
allow_color: true
autoboot_timeout: 3
boot.default: mmc0
linux.bootargs.console: console=ttyPS1,115200 root=/dev/mmcblk0p2 rootwait
user: none
Quoted 2 lines
I have an SD card with a FAT32 and an EXT4 partition. On the FAT32 I have the zImage of the Linux kernel. Am I missing something here?
With bootm, you can explicitly name which images you want to boot. The boot command on the other hand will try to figure out what images should be used without hardcoding as is described in its help text.
For MMC, I'd suggest you use bootloader spec entries. Here's an example:
https://gist.github.com/a3f/f2e2b7414128cad6d1bceca0b6013cf8
Just place that at /loader/entries/cora.conf or something.
Cheers,
Ahmad
Quoted 14 lines
Quoted 10 lines
Regards,
SaschaSignature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |Best regard,
Johannes
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 6 lines
Quoted 6 lines
In
lowlevel.cI am setting the clock divider for the sdio0 interface to 10 and the Source for generated clock is IO PLL. Therefore, the sdio IP should get a 100 MHz input clock. IS this correct? Do you know which clockrate the driver expects?
Quoted 6 lines
Quoted 1 line
Or do you have any other idea what could case the error?
Ok, I found out that maybe 100 MHz is a little bit to slow for this SD Card IP. When setting the clock to 200 MHz or 250 MHz, the mmc0 gets detected all the time by barebox.
This only works for me on my soldert eMMC card (MTFC8GAKAJCN).
Quoted 1 line
From my measurements back in 2020 i remember that the amplitude of the clock signal will shrink with higher frequencies on Zynq-7000.
Therefore I reduced the Clock to 25MHz on purpose, or some micro SD cards connected to the other sdhci interface do not work.
I do not have a solution for this, but an eval hack ;-)
@@ -985,10 +985,13 @@ static int sd_change_freq(struct mci *mci)
if (mci->scr[0] & SD_DATA_STAT_AFTER_ERASE)
mci->erased_byte = 0xFF;
else
mci->erased_byte = 0x0;
+ /* Bug do not change freqency for SD cords */
+ return 0;
+
/* Version 1.0 doesn't support switching */ if (mci->version == SD_VERSION_1_0)
return 0;
timeout = 4;
@@ -1499,14 +1502,22 @@ static int mci_mmc_try_bus_width(struct mci *mci, enum mci_bus_width bus_width,
static int mci_mmc_select_bus_width(struct mci *mci)
{
struct mci_host *host = mci->host;
int ret;
int idx = 0;
+
+#ifdef CONFIG_ARCH_ZYNQ
+ /* On zynq-7000 mmc and sdcard are connected via 4-line bus anyway */
+ static enum mci_bus_width bus_widths[] = {
+ MMC_BUS_WIDTH_4,
+ };
+#else
static enum mci_bus_width bus_widths[] = {
MMC_BUS_WIDTH_4,
MMC_BUS_WIDTH_8,
};
+#endif
if (!(host->host_caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)))
return MMC_BUS_WIDTH_1;
/*