bootstrap support for AT91SAM9263-EK
Subsystems (4)
cover bootstrap support for AT91SAM9263-EK
This small patchset enables bootstrap support for the Atmel AT91SAM9263-EK evaluation board.
To achive this there is one questionaable fix in lib/bootstrap/disk.c - where a detect_all() is
used to allow us to mount the SD card.
I dunno if this is the right approach, but it was required to mount the SD card.
The patchset is based upon the next branch and is made on top of the previous patchset I sent with "random collection".
The only dependency is in:arch/arm/boards/at91sam9263ek/Makefile
I am happy to finally get this working. Considering that all the heavy lifting was done already by Jean-Christophe this took me much more effort than one could expect.
Sam
Sam Ravnborg (3):
arm: at91: fix clock to mci1 for at91sam9263
lib: bootstrap: detect SD card before mounting
at91sam9263ek: add bootstrap support
arch/arm/boards/Makefile | 1 + arch/arm/boards/at91sam9263ek/Makefile | 4 +--- arch/arm/boards/at91sam9263ek/lowlevel_init.c | 9 +++++++++ arch/arm/configs/at91sam9263ek_bootstrap_defconfig | 19 +++++++++++++++++++ arch/arm/mach-at91/Kconfig | 14 ++++++++++++++ arch/arm/mach-at91/at91sam9263_devices.c | 3 +++ lib/bootstrap/disk.c | 2 ++ 7 files changed, 49 insertions(+), 3 deletions(-)
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/3 arm: at91: fix clock to mci1 for at91sam9263
at91_add_device_mci() was missing configuration of PIOA6 when configuring mci1.
With this fix we can read data from SD card with at91sam9263ek, when built without DT.
Building without a DT is required when we do a bootstrap build.
The other at91samxxx_devices was checked - only the 9263 was missing the CLK configuration for mci1.
--- arch/arm/mach-at91/at91sam9263_devices.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mach-at91/at91sam9263_devices.c +3 -0
@@ -396,6 +396,9 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) }else {/* MCI1 */ start =AT91SAM9263_BASE_MCI1 ; +/* CLK */ +at91_set_A_periph (AT91_PIN_PA6 ,0 ); +if (data->slot_b) {/* CMD */ at91_set_A_periph (AT91_PIN_PA21 ,1 );
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263
Hi Sasha.
This patch is OK - but the other two are bogus.
Please apply.
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263
In reply to Sam RavnborgQuoted 11 lines · Sam Ravnborg
at91_add_device_mci()was missing configuration of PIOA6 when configuring mci1.
With this fix we can read data from SD card with at91sam9263ek, when built without DT.
Building without a DT is required when we do a bootstrap build.The other
at91samxxx_deviceswas checked - only the 9263 was missing the CLK configuration for mci1.Signed-off-by Sam Ravnborg <[email protected]>---
Applied (this one), thanks
Sascha
Quoted 26 lines
arch/arm/mach-at91/at91sam9263_devices.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/mach-at91/at91sam9263_devices.c +3
-0@@ -396,6 +396,9 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) }else {/* MCI1 */ start =AT91SAM9263_BASE_MCI1 ; +/* CLK */ +at91_set_A_periph (AT91_PIN_PA6 ,0 ); +if (data->slot_b) {/* CMD */ at91_set_A_periph (AT91_PIN_PA21 ,1 );Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/3 lib: bootstrap: detect SD card before mounting
In reply to Sam RavnborgTo support bootstrap from SD card run a detect all before mounting the SD card.
--- lib/bootstrap/disk.c | 2 ++ 1 file changed, 2 insertions(+)
lib/bootstrap/disk.c +2 -0
@@ -21,6 +21,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)size_t len;const char *path ="/" ; +device_detect_all (); + ret =mount (dev, fstype, path,NULL );if (ret) {bootstrap_err ("mounting %s failed with %d\n" , dev, ret);
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
Quoted 14 lines · Sam Ravnborg
To support bootstrap from SD card run a detect all before mounting the SD card.
Signed-off-by Sam Ravnborg <[email protected]>--- lib/bootstrap/disk.c | 2 ++ 1 file changed, 2 insertions(+)lib/bootstrap/disk.c +0
-0
lib/bootstrap/disk.c void* bootstrap_read_disk(const char *dev, const char *fstype) · line 25
Quoted 5 lines
lib/bootstrap/disk.c +2
-0@@ -21,6 +21,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)size_t len;const char *path ="/" ; +device_detect_all (); +
Can device_detect_by_name(dev) be used here instead?
Thanks,
Andrey Smirnov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
Hi Andrey.
Quoted 16 lines
Quoted 16 lines
To support bootstrap from SD card run a detect all before mounting the SD card.
Signed-off-by Sam Ravnborg <[email protected]>--- lib/bootstrap/disk.c | 2 ++ 1 file changed, 2 insertions(+)lib/bootstrap/disk.c +0
-0@@ -21,6 +21,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)size_t len;const char *path ="/" ;
Quoted 4 lines
lib/bootstrap/disk.c void* bootstrap_read_disk(const char *dev, const char *fstype) · line 25
Quoted 2 lines
lib/bootstrap/disk.c +2
-0+device_detect_all (); +Can
device_detect_by_name(dev)be used here instead?
dev equals "disk0.0" when we call bootstrap_read_disk(). Calling device_detect_by_name("disk0.0") did not work, and then the easy solution with device_detect_all() worked.
I could pass the dev name to bootstrap_read_disk() but this would make the caller less general which is why I ended up with the more brutal solution.
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
Hi Andreay.
Quoted 21 lines
Quoted 16 lines
Quoted 16 lines
To support bootstrap from SD card run a detect all before mounting the SD card.
Signed-off-by Sam Ravnborg <[email protected]>--- lib/bootstrap/disk.c | 2 ++ 1 file changed, 2 insertions(+)lib/bootstrap/disk.c +0
-0@@ -21,6 +21,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)size_t len;const char *path ="/" ;Quoted 4 lines
lib/bootstrap/disk.c void* bootstrap_read_disk(const char *dev, const char *fstype) · line 25
Quoted 2 lines
lib/bootstrap/disk.c +2
-0+device_detect_all (); +Can
device_detect_by_name(dev)be used here instead?
Quoted 7 lines
dev equals "disk0.0" when we call
bootstrap_read_disk(). Callingdevice_detect_by_name("disk0.0")did not work, and then the easy solution withdevice_detect_all()worked.I could pass the dev name to
bootstrap_read_disk()but this would make the caller less general which is why I ended up with the more brutal solution.
I ended up with following code in arch/arm/boards/at91sam9263ek/init.c:
#if defined(CONFIG_MCI_ATMEL)
static struct atmel_mci_platform_data __initdata ek_mci_data = {
.devname = "disk0",
.bus_width = 4,
.detect_pin = AT91_PIN_PE18,
.wp_pin = AT91_PIN_PE19,};
When I specify "devname=disk0", then I could usedetect_by_name(dev) in bootstrap_read_disk().
No too pretty, but preferable compared to
running a loop detecting all devices.
I will include this change in v2.
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
Quoted 38 lines · Sam Ravnborg
Hi Andreay.
Quoted 21 lines
Quoted 16 lines
Quoted 16 lines
To support bootstrap from SD card run a detect all before mounting the SD card.
Signed-off-by Sam Ravnborg <[email protected]>--- lib/bootstrap/disk.c | 2 ++ 1 file changed, 2 insertions(+)lib/bootstrap/disk.c +0
-0@@ -21,6 +21,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)size_t len;const char *path ="/" ;Quoted 4 lines
lib/bootstrap/disk.c void* bootstrap_read_disk(const char *dev, const char *fstype) · line 25
Quoted 2 lines
lib/bootstrap/disk.c +2
-0+device_detect_all (); +Can
device_detect_by_name(dev)be used here instead?Quoted 7 lines
dev equals "disk0.0" when we call
bootstrap_read_disk(). Callingdevice_detect_by_name("disk0.0")did not work, and then the easy solution withdevice_detect_all()worked.I could pass the dev name to
bootstrap_read_disk()but this would make the caller less general which is why I ended up with the more brutal solution.I ended up with following code in
arch/arm/boards/at91sam9263ek/init.c:
#ifdefined(CONFIG_MCI_ATMEL)
static structatmel_mci_platform_data__initdataek_mci_data= {.devname = "disk0", .bus_width = 4, .detect_pin = AT91_PIN_PE18, .wp_pin = AT91_PIN_PE19,
Quoted 6 lines
};
When I specify "devname=disk0", then I could use
detect_by_name(dev)inbootstrap_read_disk().
No too pretty, but preferable compared to
running a loop detecting all devices.
There are two other possibilities. First there is CONFIG_MCI_STARTUP which causes the SD cards to be detected during host registration. Another possibility would be to call device_detect_by_name() from board code (where you implicitly know which hardware device to probe)
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
Hi Sasha.
Quoted 2 lines
There are two other possibilities. First there is
CONFIG_MCI_STARTUPwhich causes the SD cards to be detected during host registration.
This one worked like a charm and I could drop my hacks - thanks!
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/3 at91sam9263ek: add bootstrap support
In reply to Sam RavnborgFix lowlevel init to get reset vector.
Add new MACH_AT91SAM9263EK_BOOTSTRAP config entry
used when building the bootstrap variant.
The new config entry is required as we cannot combine MULTI_IMAGE with a bootstrap variant.
With this we have two config symbols that points to the same board directory. This was the simple way to share the same low_level.c implmentation.
Add at91sam9263ek_bootstrap_defconfig that can boot barebox.bin from SD card (must be named BOOT.BIN)
Boot log:
barebox 2018.12.0-00266-g1e927dc53-dirty #41 Wed Jan 2 20:51:43 CET 2019
Board: Atmel at91sam9263-ek
Clocks: CPU 199 MHz, master 99 MHz, main 16.367 MHz atmel_mci atmel_mci1: version: 0x210 atmel_mci atmel_mci1: registered as mci0 malloc space: 0x23be4000 -> 0x23fe3fff (size 4 MiB) Boot from mmc
mci0: detected SD card version 2.0
mci0: registered disk0
--- arch/arm/boards/Makefile | 1 + arch/arm/boards/at91sam9263ek/Makefile | 4 +--- arch/arm/boards/at91sam9263ek/lowlevel_init.c | 9 +++++++++ arch/arm/configs/at91sam9263ek_bootstrap_defconfig | 19 +++++++++++++++++++ arch/arm/mach-at91/Kconfig | 14 ++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 arch/arm/configs/at91sam9263ek_bootstrap_defconfig
arch/arm/boards/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_MACH_ARCHOSG9) += archosg9/ obj-$(CONFIG_MACH_AT91SAM9260EK) += at91sam9260ek/ obj-$(CONFIG_MACH_AT91SAM9261EK) += at91sam9261ek/ obj-$(CONFIG_MACH_AT91SAM9263EK) += at91sam9263ek/ +obj-$(CONFIG_MACH_AT91SAM9263EK_BOOTSTRAP) += at91sam9263ek/ obj-$(CONFIG_MACH_AT91SAM9G10EK) += at91sam9261ek/ obj-$(CONFIG_MACH_AT91SAM9G20EK) += at91sam9260ek/ obj-$(CONFIG_MACH_AT91SAM9M10G45EK) += at91sam9m10g45ek/
arch/arm/boards/at91sam9263ek/Makefile +1 -3
@@ -1,6 +1,4 @@ -ifeq ($(CONFIG_OFDEVICE),) -obj-y += init.o -endif +obj-$(CONFIG_MACH_AT91SAM9263EK_BOOTSTRAP) += init.o obj-$(CONFIG_OFDEVICE) += of_init.o lwl-y += lowlevel_init.o
arch/arm/boards/at91sam9263ek/lowlevel_init.c +9 -0
@@ -115,6 +115,7 @@ static void __bare_init at91sam9263ek_init(void *fdt) fdt); } +#ifdef CONFIG_OFDEVICE extern char __dtb_at91sam9263ek_start[];ENTRY_FUNCTION (start_at91sam9263ek, r0, r1, r2)
@@ -132,3 +133,11 @@ ENTRY_FUNCTION(start_at91sam9263ek, r0, r1, r2)at91sam9263ek_init (fdt); } +#else +void __naked __bare_init barebox_arm_reset_vector(void) +{ +arm_cpu_lowlevel_init (); +arm_setup_stack (AT91SAM9263_SRAM0_BASE +AT91SAM9263_SRAM0_SIZE -16 ); +at91sam9263ek_init (NULL ); +} +#endif
arch/arm/configs/at91sam9263ek_bootstrap_defconfig new file +19 -0
@@ -0,0 +1,19 @@ +CONFIG_ARCH_AT91SAM9263=y +CONFIG_AT91_BOOTSTRAP=y +CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x40000 +CONFIG_AEABI=y +CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y +CONFIG_MALLOC_DUMMY=y +CONFIG_PROMPT="9263-EK:" +CONFIG_SHELL_NONE=y +# CONFIG_TIMESTAMP is not set +CONFIG_CONSOLE_SIMPLE=y +# CONFIG_SPI is not set +CONFIG_MCI=y +# CONFIG_MCI_WRITE is not set +CONFIG_MCI_ATMEL=y +# CONFIG_FS_RAMFS is not set +# CONFIG_FS_DEVFS is not set +CONFIG_FS_FAT=y +CONFIG_BOOTSTRAP_DEVFS=y +CONFIG_BOOTSTRAP_DISK=y
arch/arm/mach-at91/Kconfig +14 -0
@@ -394,6 +394,20 @@ if ARCH_AT91SAM9263 choice prompt "AT91SAM9263 Board Type" +config MACH_AT91SAM9263EK_BOOTSTRAP + bool "Atmel AT91SAM9263-EK bootstrap" + depends on ARCH_AT91SAM9263 + select HAVE_AT91_USB_CLK + select HAVE_NAND_ATMEL_BUSWIDTH_16 + select HAVE_AT91_BOOTSTRAP + select AT91SAM926X_BOARD_INIT + help + Say y here to build the bootstrap variant of barebox + for the Atmel AT91SAM9263-EK Evaluation board. + barebox.bin can be copied to a SD card, named BOOT.BIN, + then ROMBOOT in the at91sam9263 will load the bootstrap + and then bootstrap can load the real barebox + config MACH_PM9263 bool "Ronetix PM9263" select HAVE_AT91_BOOTSTRAP
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 3/3] at91sam9263ek: add bootstrap support
Hi Sam,
Quoted 6 lines · Sam Ravnborg
Fix lowlevel init to get reset vector.
Add new
MACH_AT91SAM9263EK_BOOTSTRAPconfig entry
used when building the bootstrap variant.
The new config entry is required as we cannot combineMULTI_IMAGEwith a bootstrap variant.
Why can't that be combined?
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 3/3] at91sam9263ek: add bootstrap support
Hi Sascha.
Quoted 8 lines
Quoted 6 lines
Fix lowlevel init to get reset vector.
Add new
MACH_AT91SAM9263EK_BOOTSTRAPconfig entry
used when building the bootstrap variant.
The new config entry is required as we cannot combineMULTI_IMAGEwith a bootstrap variant.Why can't that be combined?
The bootstrap support did not play well with the PBL support. And MULTI_IMAGE somehow forced this on me.
I did not dive deep into why bootstrap and MULTI_IMAGE did not work. I looked at the binraty using objdump, and could see that without
Unless there are something I missed so PBL support should work I will update the commit message for a v2 of the pathset.
Note: I also had to disable MMU support to get bootstrap working. With MMU enable it halted when __mmu_cache_on() was called in mmu-early.c
I will also try to look a little deeper into this, but here I have only limited hope as my debugging is so far limited to using pr_info(...).
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 3/3] at91sam9263ek: add bootstrap support
Hi Sascha.
Previous mail was written while being disturbed by others - sorry.
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
Fix lowlevel init to get reset vector.
Add new
MACH_AT91SAM9263EK_BOOTSTRAPconfig entry
used when building the bootstrap variant.
The new config entry is required as we cannot combineMULTI_IMAGEwith a bootstrap variant.Why can't that be combined?
The bootstrap support did not play well with the PBL support. And
MULTI_IMAGEsomehow forced this on me.
So far I have not managed to build a barebox image that would allow ROMBOOT to load it.
As ROMBOOT is silent about why it fails I have not too much clue why it fails.
When I compare the disassembled image with and without PBL support enabled they looks not exactly
the same.
One example is that barebox_image_size is wrong when I build with PBL / MULTI_IMAGE support enabled.
I need to dig deeper to find out why.
The image size is stored at address 0x14 - but is supposed to be used only by DataFlast, NOR-flash, so this is likely not the root-cause. But it looks wrong so one thing to fix.
I will try to chase it a bit more to see if I can get it to work.
Quoted 3 lines
Note: I also had to disable MMU support to get bootstrap working. With MMU enable it halted when
__mmu_cache_on()was called inmmu-early.c
The above was only partially correct.
If MMU is enabled then I need to comment out the call to __mmu_cache_on() in mmu_init().
Otherwise barebox just hang right after (or in) the call to __mmu_cache_on()
(which is a call to v7_mmu_cache_on() )
ROMBOOT will copy barebox to 0x40000 and then remap:0x40000 => 0x00x0 => 0x40000
I guess there is some kind of conflict between the remapping done by ROMBOOT and the MMU setup / cache setup done by barebox. So far I am fully satisfied to continue with MMU disabled.
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v1 3/3] at91sam9263ek: add bootstrap support
Quoted 21 lines · Sam Ravnborg
Hi Sascha.
Previous mail was written while being disturbed by others - sorry.
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
Fix lowlevel init to get reset vector.
Add new
MACH_AT91SAM9263EK_BOOTSTRAPconfig entry
used when building the bootstrap variant.
The new config entry is required as we cannot combineMULTI_IMAGEwith a bootstrap variant.Why can't that be combined?
The bootstrap support did not play well with the PBL support. And
MULTI_IMAGEsomehow forced this on me.So far I have not managed to build a barebox image that would allow ROMBOOT to load it.
As ROMBOOT is silent about why it fails I have not too much clue why it fails.
Quoted 6 lines
When I compare the disassembled image with and without PBL support enabled they looks not exactly the same.
One example is thatbarebox_image_sizeis wrong when I build with PBL /MULTI_IMAGEsupport enabled. I need to dig deeper to find out why.
Is it a wrong nonzero value or 0x0?
Quoted 3 lines
The image size is stored at address
0x14- but is supposed to be used only by DataFlast, NOR-flash, so this is likely not the root-cause. But it looks wrong so one thing to fix.
It's probably time to revise this part. We used to cat the compressed barebox binary behind the PBL, so we had no chance to determine the reulting image size with linker variables in the PBL. Now that we link the compressed binary into the PBL linker variables could generally work, so at least we have the chance to use them.
Quoted 16 lines
I will try to chase it a bit more to see if I can get it to work.
Quoted 3 lines
Note: I also had to disable MMU support to get bootstrap working. With MMU enable it halted when
__mmu_cache_on()was called inmmu-early.cThe above was only partially correct.
If MMU is enabled then I need to comment out the call to
__mmu_cache_on()inmmu_init().
Otherwise barebox just hang right after (or in) the call to__mmu_cache_on()
(which is a call tov7_mmu_cache_on())
Quoted 7 lines
ROMBOOT will copy barebox to
0x40000and then remap:0x40000=>0x00x0=>0x40000I guess there is some kind of conflict between the remapping done by ROMBOOT and the MMU setup / cache setup done by barebox. So far I am fully satisfied to continue with MMU disabled.
So ROMBOOT sets up the MMU? Or is there some kind of remap register?
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox