Skip to contentSkip to conversation

loading environment from SATA

U-Boot Ben Hewson 3 participants 5 messages Apr 30, 2015 – May 6, 2015

lore
Share & tools
lore

Ben Hewson

author
#0 lore raw

booting from SATA works very well on my iMX6 based board, however if I do

#define CONFIG_ENV_IS_IN_FAT

#if defined(CONFIG_ENV_IS_IN_FAT)
    #define CONFIG_FAT_WRITE
    #define FAT_ENV_INTERFACE           "sata"
    #define FAT_ENV_DEVICE_AND_PART     "0:1"
    #define FAT_ENV_FILE                "u-boot.env"

#endif

nothing is loaded as the SATA has not been initialised.

Looking at board_r.c I can see lots of inits, for mmc, nand and other stuff, but not sata.

Following the format I have added a function

#ifdef CONFIG_CMD_SATA
static int initr_sata(void)

{
	puts("SATA:   ");
        sata_initialize();
	return 0;
}

#endif

and inside init_fnc_t init_sequence_r[] = { after

#ifdef CONFIG_GENERIC_MMC
initr_mmc,
#endif

I have added

#ifdef CONFIG_CMD_SATA
initr_sata,
#endif

So this compiled and booted and to my surprise worked.
Is this the best way to achieve this. I can see potential problems if sata_inialize() depends on other sub-systems being initialized first. I am perhaps lucky that it works for me.

regards
Ben

#1 lore raw
Quoted 42 lines · Ben Hewson

booting from SATA works very well on my iMX6 based board, however if I do

#define CONFIG_ENV_IS_IN_FAT

#if defined(CONFIG_ENV_IS_IN_FAT)
    #define CONFIG_FAT_WRITE
    #define FAT_ENV_INTERFACE           "sata"
    #define FAT_ENV_DEVICE_AND_PART     "0:1"
    #define FAT_ENV_FILE                "u-boot.env"

#endif

nothing is loaded as the SATA has not been initialised.

Looking at board_r.c I can see lots of inits, for mmc, nand and other stuff, but not sata.

Following the format I have added a function

#ifdef CONFIG_CMD_SATA
static int initr_sata(void)

{
	puts("SATA:   ");
        sata_initialize();
	return 0;
}

#endif

and inside init_fnc_t init_sequence_r[] = { after

#ifdef CONFIG_GENERIC_MMC
initr_mmc,
#endif

I have added

#ifdef CONFIG_CMD_SATA
initr_sata,
#endif

Quoted 4 lines

So this compiled and booted and to my surprise worked.
Is this the best way to achieve this. I can see potential problems if sata_inialize() depends on other sub-systems being initialized first. I am perhaps lucky that it works for me.

For today at least yes, this sounds about right. I'm sure there's going to be a case or two where it isn't enough (SATA off of PCI rather than SoC bus?). If you'd like to make and submit a patch that'd be great!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150430/9ec72ca4/attachment.sig>
#2 lore raw
In reply to Ben Hewson

Hi Ben,

Quoted 35 lines · Ben Hewson

booting from SATA works very well on my iMX6 based board, however if I do

#define CONFIG_ENV_IS_IN_FAT

#if defined(CONFIG_ENV_IS_IN_FAT)
    #define CONFIG_FAT_WRITE
    #define FAT_ENV_INTERFACE           "sata"
    #define FAT_ENV_DEVICE_AND_PART     "0:1"
    #define FAT_ENV_FILE                "u-boot.env"

#endif

nothing is loaded as the SATA has not been initialised.

Looking at board_r.c I can see lots of inits, for mmc, nand and other stuff, but not sata.

Following the format I have added a function

#ifdef CONFIG_CMD_SATA
static int initr_sata(void)

{
        puts("SATA:   ");
        sata_initialize();
        return 0;
}

#endif

and inside init_fnc_t init_sequence_r[] = { after

#ifdef CONFIG_GENERIC_MMC
initr_mmc,
#endif

Quoted 8 lines

I have added

#ifdef CONFIG_CMD_SATA
initr_sata,
#endif

So this compiled and booted and to my surprise worked.

Could you please send a formal patch to the list?

Process is described here: http://www.denx.de/wiki/U-Boot/Patches

Thanks,

Fabio Estevam

author
#3 lore raw

Hi Fabio,

Sorry, kind of got side tracked a bit.

Tom, in response to SATA off a PCI bus, that was my main concern with just adding a SATA init. However after looking through the code I have noticed that there is a CONFIG_SYS_EARLY_PCI_INIT which if declared will call initr_pci before my initr_sata. Ho ever this got me to thinking, would it be better to have someting like CONFIG_SYS_EARLY_SATA_INIT and do

#if defined(CONFIG_CMD_SATA) && defined(CONFIG_SYS_EARLY_SATA_INIT)
initr_sata,
#endif

Or is this just being too complicated. Is there a file some place listing all of the various CONFIG_XXX and CONFIG_SYS_XXX ? I know the README file has many, but not all it seems.

regards
Ben

Quoted 54 lines · On Tuesday 05 May 2015 11:17:55 Fabio Estevam wrote:

Hi Ben,

Quoted 35 lines · Ben Hewson

booting from SATA works very well on my iMX6 based board, however if I do

#define CONFIG_ENV_IS_IN_FAT

#if defined(CONFIG_ENV_IS_IN_FAT)
    #define CONFIG_FAT_WRITE
    #define FAT_ENV_INTERFACE           "sata"
    #define FAT_ENV_DEVICE_AND_PART     "0:1"
    #define FAT_ENV_FILE                "u-boot.env"

#endif

nothing is loaded as the SATA has not been initialised.

Looking at board_r.c I can see lots of inits, for mmc, nand and other stuff, but not sata.

Following the format I have added a function

#ifdef CONFIG_CMD_SATA
static int initr_sata(void)

{
        puts("SATA:   ");
        sata_initialize();
        return 0;
}

#endif

and inside init_fnc_t init_sequence_r[] = { after

#ifdef CONFIG_GENERIC_MMC
initr_mmc,
#endif

Quoted 8 lines

I have added

#ifdef CONFIG_CMD_SATA
initr_sata,
#endif

So this compiled and booted and to my surprise worked.

Could you please send a formal patch to the list?

Process is described here: http://www.denx.de/wiki/U-Boot/Patches

Thanks,

Fabio Estevam

#4 lore raw
Quoted 12 lines · Ben Hewson

Hi Fabio,

Sorry, kind of got side tracked a bit.

Tom, in response to SATA off a PCI bus, that was my main concern with just adding a SATA init. However after looking through the code I have noticed that there is a CONFIG_SYS_EARLY_PCI_INIT which if declared will call initr_pci before my initr_sata. Ho ever this got me to thinking, would it be better to have someting like CONFIG_SYS_EARLY_SATA_INIT and do

Quoted 3 lines

#if defined(CONFIG_CMD_SATA) && defined(CONFIG_SYS_EARLY_SATA_INIT)
initr_sata,
#endif

Hmmm. I would condition it on CONFIG_CMD_SATA && CONFIG_ENV_IS_IN_SATA to start with and if we somehow have another early use for SATA we can always revisit.

Quoted 2 lines

Or is this just being too complicated. Is there a file some place listing all of the various CONFIG_XXX and CONFIG_SYS_XXX ?

There is not.

Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150506/5caadfda/attachment.sig>