how to get the boot mode from the system registers? i can't find them ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to get the boot mode from the system registers? i can't find them ?

Jump to solution
2,484 Views
luoqiaofa
Contributor II

hello all:

how to get the boot mode from the system registers?

i want to use it to change the command line correctly  in boot_stream, thank you!

Labels (1)
Tags (2)
1 Solution
1,963 Views
PeterChan
NXP Employee
NXP Employee

I add your code to boot_prep and I can see the correct result as well.

diff --git a/init-mx28.c b/init-mx28.c

index 26744e0..146477b 100644

--- a/init-mx28.c

+++ b/init-mx28.c

@@ -1422,6 +1422,21 @@ int _start(int arg)

        }

        printf("finish simple test\r\n");

#endif

+

+#if 1

+  BW_PINCTRL_MUXSEL2_BANK1_PIN00(3);

+  BW_PINCTRL_MUXSEL2_BANK1_PIN01(3);

+  BW_PINCTRL_MUXSEL2_BANK1_PIN02(3);

+  BW_PINCTRL_MUXSEL2_BANK1_PIN03(3);

+  HW_PINCTRL_DOE1_CLR(0X0f);

+  value = HW_PINCTRL_MUXSEL2_RD();

+  printf("HW_PINCTRL_MUXSEL2  = 0x%x\r\n", value);

+  value = HW_PINCTRL_DOE1_RD();

+  printf("HW_PINCTRL_DOE1  = 0x%x\r\n", value);

+  value = HW_PINCTRL_DIN1_RD();

+  printf("HW_PINCTRL_DIN1_RD  = 0x%x\r\n", value);

+  printf("Boot Mode = 0x%x\r\n", (value & 0xff));

+#endif

        return 0;

}

============================================

HW_PINCTRL_MUXSEL2  = 0xFFFFFFFF

HW_PINCTRL_DOE1  = 0x00000000

HW_PINCTRL_DIN1_RD  = 0x04000009

Boot Mode = 0x00000009

View solution in original post

0 Kudos
9 Replies
1,963 Views
luoqiaofa
Contributor II

by the way:

   in boot stream source, i add the follow code:

  value = HW_OCOTP_ROMn_RD(0);

  printf("HW_OCOTP_ROM0 = 0x%x\r\n", value);

  when power on, it print all zeros.  what's wrong?

0 Kudos
1,963 Views
PeterChan
NXP Employee
NXP Employee

You have to follow the Software Read Sequence describe in i.MX28 reference manual, Chapter 20 to read HW_OCOTP registers. Sample code can be found at drivers/char/fsl_otp.c.

0 Kudos
1,963 Views
luoqiaofa
Contributor II

thank you PeterChan

we config the kernel FSL_OTP, and run it , but the value is not match as sd boot mode.

HW_OCOTP_ROM0 read test result as follows:

pwd

/sys/fsl_otp

# ls

HW_OCOTP_CRYPTO0  HW_OCOTP_HWCAP1   HW_OCOTP_ROM0     HW_OCOTP_SRK2

HW_OCOTP_CRYPTO1  HW_OCOTP_HWCAP2   HW_OCOTP_ROM1     HW_OCOTP_SRK3

HW_OCOTP_CRYPTO2  HW_OCOTP_HWCAP3   HW_OCOTP_ROM2     HW_OCOTP_SRK4

HW_OCOTP_CRYPTO3  HW_OCOTP_HWCAP4   HW_OCOTP_ROM3     HW_OCOTP_SRK5

HW_OCOTP_CUST0    HW_OCOTP_HWCAP5   HW_OCOTP_ROM4     HW_OCOTP_SRK6

HW_OCOTP_CUST1    HW_OCOTP_LOCK     HW_OCOTP_ROM5     HW_OCOTP_SRK7

HW_OCOTP_CUST2    HW_OCOTP_OPS0     HW_OCOTP_ROM6     HW_OCOTP_SWCAP

HW_OCOTP_CUST3    HW_OCOTP_OPS1     HW_OCOTP_ROM7     HW_OCOTP_UN0

HW_OCOTP_CUSTCAP  HW_OCOTP_OPS2     HW_OCOTP_SRK0     HW_OCOTP_UN1

HW_OCOTP_HWCAP0   HW_OCOTP_OPS3     HW_OCOTP_SRK1     HW_OCOTP_UN2

# cat HW_OCOTP_ROM0

0x0

0 Kudos
1,963 Views
PeterChan
NXP Employee
NXP Employee

Have you blown the OTP fuse for SD boot? By default, HW_OCOTP_ROM0 is 0. You can use BitBurner.exe to double check this.

If ENABLE_PIN_BOOT_CHECK OTP is not blown, the boot ROM will check LCD_D[4:0] regardless of the state of LCD_RS pin. If ENABLE_PIN_BOOT_CHECK OTP bit is blown, the boot ROM will check the state of LCD_RS pin to determine which option is used.

On i.MX28 EVK, ENABLE_PIN_BOOT_CHECK OTP is not blown and the boot ROM check the LCD_D[4:0] for boot mode.

If you need to read the boot mode from program, you need to configure these LCD pins as GPIO inputs and then read their GPIO input values. Please refer to i.MX28 Reference Manual Chapter 12 "Boot Modes" for more information.

1,963 Views
luoqiaofa
Contributor II

hello PeterChan:

on imx28,  we config the h LCD pins as GPIO inputs and then read their GPIO input values, it stiil didn't  match the boot mode

the code as follows:

BW_PINCTRL_MUXSEL2_BANK1_PIN00(3);

  BW_PINCTRL_MUXSEL2_BANK1_PIN01(3);

  BW_PINCTRL_MUXSEL2_BANK1_PIN02(3);

  BW_PINCTRL_MUXSEL2_BANK1_PIN03(3);

  HW_PINCTRL_DOE1_CLR(0X0f);

  value = HW_PINCTRL_DIN1_RD();

  printf("HW_PINCTRL_DIN1_RD  = 0x%x\r\n", value);

  printf("Boot Mode = 0x%x\r\n", (value & 0xff));

1. in sd boot mode, it printed :

HW_PINCTRL_DIN1_RD  = 0x0F000001

Boot Mode = 0x00000001

the correct boot mode should be 0X09 (0b1001), Is right ?

2. in nand boot mode , it printed :

HW_PINCTRL_DIN1_RD  = 0x0F000000

Boot Mode = 0x00000000

the correct boot mode should be 0X04 (0b0100)

what's wrong ?

0 Kudos
1,963 Views
PeterChan
NXP Employee
NXP Employee

I read the boot mode in kernel using the memtool and I can read it successfully.

root@freescale /unit_tests$ ./memtool 0x80018120 1

Reading 0x1 count starting at address 0x80018120

0x80018120:  00000000

root@freescale /unit_tests$ ./memtool 0x80018120=0xff

Writing 32-bit value 0xFF to address 0x80018120

root@freescale /unit_tests$ ./memtool 0x80018120 1

Reading 0x1 count starting at address 0x80018120

0x80018120:  000000FF

root@freescale /unit_tests$ ./memtool 0x80018b10 1

Reading 0x1 count starting at address 0x80018B10

0x80018B10:  00000000

boot mode = 0x9

root@freescale /unit_tests$ ./memtool 0x80018910 1

Reading 0x1 count starting at address 0x80018910

0x80018910:  0B000009

boot mode = 0x4

root@freescale /unit_tests$ ./memtool 0x80018910 1

Reading 0x1 count starting at address 0x80018910

0x80018910:  0F000004

Could you please double check the register values HW_PINCTRL_MUXSEL2 & HW_PINCTRL_DOE1?

0 Kudos
1,964 Views
PeterChan
NXP Employee
NXP Employee

I add your code to boot_prep and I can see the correct result as well.

diff --git a/init-mx28.c b/init-mx28.c

index 26744e0..146477b 100644

--- a/init-mx28.c

+++ b/init-mx28.c

@@ -1422,6 +1422,21 @@ int _start(int arg)

        }

        printf("finish simple test\r\n");

#endif

+

+#if 1

+  BW_PINCTRL_MUXSEL2_BANK1_PIN00(3);

+  BW_PINCTRL_MUXSEL2_BANK1_PIN01(3);

+  BW_PINCTRL_MUXSEL2_BANK1_PIN02(3);

+  BW_PINCTRL_MUXSEL2_BANK1_PIN03(3);

+  HW_PINCTRL_DOE1_CLR(0X0f);

+  value = HW_PINCTRL_MUXSEL2_RD();

+  printf("HW_PINCTRL_MUXSEL2  = 0x%x\r\n", value);

+  value = HW_PINCTRL_DOE1_RD();

+  printf("HW_PINCTRL_DOE1  = 0x%x\r\n", value);

+  value = HW_PINCTRL_DIN1_RD();

+  printf("HW_PINCTRL_DIN1_RD  = 0x%x\r\n", value);

+  printf("Boot Mode = 0x%x\r\n", (value & 0xff));

+#endif

        return 0;

}

============================================

HW_PINCTRL_MUXSEL2  = 0xFFFFFFFF

HW_PINCTRL_DOE1  = 0x00000000

HW_PINCTRL_DIN1_RD  = 0x04000009

Boot Mode = 0x00000009

0 Kudos
1,963 Views
luoqiaofa
Contributor II

thank you very much,

we add "deley (10000);"   before "value = HW_PINCTRL_DIN1_RD(); "  , then we can get the correct result too.

why can't the gpio configuration change immediatlly ?

0 Kudos
1,963 Views
PeterChan
NXP Employee
NXP Employee

Probably due to the weak external pull up resistors at the boot pin.