diff mbox

[U-Boot,1/2] mxs: mxsboot: Move sdcard BCB header to 4 sectors offset

Message ID 1366838608-7126-1-git-send-email-otavio@ossystems.com.br
State Awaiting Upstream
Delegated to: Stefano Babic
Headers show

Commit Message

Otavio Salvador April 24, 2013, 9:23 p.m. UTC
The MX23 Boot ROM does blindly load from 2048 offset while the MX28
does parse the BCB header to known where to load the image from. We
move the BCB header to 4 sectors offset so same code can be used by
both SoCs avoiding code duplication.

This idea was given by Marek Vasut <marex@denx.de>

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 tools/mxsboot.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Marek Vasut April 24, 2013, 9:29 p.m. UTC | #1
Dear Otavio Salvador,

> The MX23 Boot ROM does blindly load from 2048 offset while the MX28
> does parse the BCB header to known where to load the image from. We
> move the BCB header to 4 sectors offset so same code can be used by
> both SoCs avoiding code duplication.
> 
> This idea was given by Marek Vasut <marex@denx.de>
> 
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>

What devices did you test this code on?

Best regards,
Marek Vasut
Otavio Salvador April 24, 2013, 9:33 p.m. UTC | #2
On Wed, Apr 24, 2013 at 6:29 PM, Marek Vasut <marex@denx.de> wrote:
> Dear Otavio Salvador,
>
>> The MX23 Boot ROM does blindly load from 2048 offset while the MX28
>> does parse the BCB header to known where to load the image from. We
>> move the BCB header to 4 sectors offset so same code can be used by
>> both SoCs avoiding code duplication.
>>
>> This idea was given by Marek Vasut <marex@denx.de>
>>
>> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
>
> What devices did you test this code on?

MX23EVK and MX28EVK

--
Otavio Salvador                             O.S. Systems
E-mail: otavio@ossystems.com.br  http://www.ossystems.com.br
Mobile: +55 53 9981-7854              http://projetos.ossystems.com.br
Fabio Estevam April 24, 2013, 9:57 p.m. UTC | #3
On Wed, Apr 24, 2013 at 6:23 PM, Otavio Salvador
<otavio@ossystems.com.br> wrote:
> The MX23 Boot ROM does blindly load from 2048 offset while the MX28
> does parse the BCB header to known where to load the image from. We
> move the BCB header to 4 sectors offset so same code can be used by
> both SoCs avoiding code duplication.
>
> This idea was given by Marek Vasut <marex@denx.de>
>
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>

On mx23evk/mx28evk:

Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Marek Vasut April 25, 2013, 8:45 p.m. UTC | #4
Dear Otavio Salvador,

> The MX23 Boot ROM does blindly load from 2048 offset while the MX28
> does parse the BCB header to known where to load the image from. We
> move the BCB header to 4 sectors offset so same code can be used by
> both SoCs avoiding code duplication.
> 
> This idea was given by Marek Vasut <marex@denx.de>
> 
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>

On M28EVK
Tested-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut
Stefano Babic April 26, 2013, 7:15 a.m. UTC | #5
On 25/04/2013 22:45, Marek Vasut wrote:
> Dear Otavio Salvador,
> 
>> The MX23 Boot ROM does blindly load from 2048 offset while the MX28
>> does parse the BCB header to known where to load the image from. We
>> move the BCB header to 4 sectors offset so same code can be used by
>> both SoCs avoiding code duplication.
>>
>> This idea was given by Marek Vasut <marex@denx.de>
>>
>> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> 
> On M28EVK
> Tested-by: Marek Vasut <marex@denx.de>
> 

Ok, thanks, I push it to -master

Best regards,
Stefano Babic
Stefano Babic April 26, 2013, 7:18 a.m. UTC | #6
On 24/04/2013 23:23, Otavio Salvador wrote:
> The MX23 Boot ROM does blindly load from 2048 offset while the MX28
> does parse the BCB header to known where to load the image from. We
> move the BCB header to 4 sectors offset so same code can be used by
> both SoCs avoiding code duplication.
> 
> This idea was given by Marek Vasut <marex@denx.de>
> 
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> ---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic
diff mbox

Patch

diff --git a/tools/mxsboot.c b/tools/mxsboot.c
index 6c05aa4..d92c39f 100644
--- a/tools/mxsboot.c
+++ b/tools/mxsboot.c
@@ -551,7 +551,7 @@  static int mx28_create_sd_image(int infd, int outfd)
 
 	fsize = lseek(infd, 0, SEEK_END);
 	lseek(infd, 0, SEEK_SET);
-	size = fsize + 512;
+	size = fsize + 4 * 512;
 
 	buf = malloc(size);
 	if (!buf) {
@@ -559,7 +559,7 @@  static int mx28_create_sd_image(int infd, int outfd)
 		goto err0;
 	}
 
-	ret = read(infd, (uint8_t *)buf + 512, fsize);
+	ret = read(infd, (uint8_t *)buf + 4 * 512, fsize);
 	if (ret != fsize) {
 		ret = -1;
 		goto err1;
@@ -574,8 +574,8 @@  static int mx28_create_sd_image(int infd, int outfd)
 	cb->drv_info[0].chip_num = 0x0;
 	cb->drv_info[0].drive_type = 0x0;
 	cb->drv_info[0].tag = 0x1;
-	cb->drv_info[0].first_sector_number = sd_sector + 1;
-	cb->drv_info[0].sector_count = (size - 1) / 512;
+	cb->drv_info[0].first_sector_number = sd_sector + 4;
+	cb->drv_info[0].sector_count = (size - 4) / 512;
 
 	wr_size = write(outfd, buf, size);
 	if (wr_size != size) {