We had designed a custom board based on imx6qsabre-AI , but the nor flash storage the data , the code is
#ifdef CONFIG_MXC_SPI
iomux_v3_cfg_t const ecspi1_pads[] = {
MX6_PAD_CSI0_DAT4__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
MX6_PAD_CSI0_DAT5__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
MX6_PAD_CSI0_DAT6__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
MX6_PAD_CSI0_DAT7__GPIO5_IO25 | MUX_PAD_CTRL(NO_PAD_CTRL),
};
void setup_spinor(void)
{
imx_iomux_v3_setup_multiple_pads(ecspi1_pads,
ARRAY_SIZE(ecspi1_pads));
gpio_direction_output(IMX_GPIO_NR(5, 25), 0);
}
int board_spi_cs_gpio(unsigned bus, unsigned cs)
{
return (bus == 0 && cs == 1) ? (IMX_GPIO_NR(5, 25)) : -1;
}
#endif
U-Boot 2015.04-14468-gd7d7c43-dirty (Jul 08 2016 - 14:38:47)
CPU: Freescale i.MX6Q rev1.5 at 792 MHz
CPU: Temperature 46 C
Reset cause: POR
Board: MX6Q-GWI-SCANNER revA
I2C: ready
DRAM: 1 GiB
PMIC: PFUZE100 ID=0x10
MMC: FSL_SDHC: 0
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
In: serial
Out: serial
Err: serial
Net: FEC [PRIME]
Boot from USB for mfgtools
Use default environment for mfgtools
Run bootcmd_mfg: run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
Hit any key to stop autoboot: 0
Bad Linux ARM zImage magic!
=> sf probe 1
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
=> setenv serverip 192.168.23.249
=> setenv ipaddr 192.168.23.111
=> setenv gatewayip 192.168.23.1
=> setenv netmask 255.255.255.0
=> saveenv
Saving Environment to SPI Flash...
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
Erasing SPI flash...Writing to SPI flash...done
baudrate=115200
boot_fdt=try
bootargs=console=ttymxc0,115200 rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass_storage.file=/fat g_mass_storage.ro=1 g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF g_mass_storage.iSerialNumber= enable_wait_mode=off
bootcmd=mmc dev ${mmcdev};if mmc rescan; then if run loadbootscript; then run bootscript;else else if run loadimage; then run mmcboot; else run netboot; fi; fi; else run netboot; fi
bootcmd_mfg=run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
bootdelay=1
bootscript=echo Running bootscript from mmc ...; source
console=ttymxc0
emmcdev=2
epdc_waveform=epdc_splash.bin
ethprime=FEC
fdt_addr=0x18000000
fdt_file=imx6q-gwi-scanner.dtb
fdt_high=0xffffffff
gatewayip=192.168.23.1
image=zImage
initrd_addr=0x12C00000
initrd_high=0xffffffff
ip_dyn=yes
ipaddr=192.168.23.111
loadaddr=0x12000000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
mfgtool_args=setenv bootargs console=ttymxc0,115200 rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass_storage.file=/fat g_mass_storage.ro=1 g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF g_mass_storage.iSerialNumber="" enable_wait_mode=off
mmcargs=setenv bootargs console=${console},${baudrate} ${smp} root=${mmcroot}
mmcautodetect=yes
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
mmcdev=0
mmcpart=1
mmcroot=/dev/mmcblk3p2 rootwait rw
netargs=setenv bootargs console=${console},${baudrate} ${smp} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${image}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
netmask=255.255.255.0
script=boot.scr
serverip=192.168.23.249
update_emmc_firmware=if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; if ${get_cmd} ${update_sd_firmware_filename}; then if mmc dev ${emmcdev} 1; then setexpr fw_sz ${filesize} / 0x200; setexpr fw_sz ${fw_sz} + 1; mmc write ${loadaddr} 0x2 ${fw_sz}; fi; fi
update_sd_firmware=if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; if mmc dev ${mmcdev}; then if ${get_cmd} ${update_sd_firmware_filename}; then setexpr fw_sz ${filesize} / 0x200; setexpr fw_sz ${fw_sz} + 1; mmc write ${loadaddr} 0x2 ${fw_sz}; fi; fi
Environment size: 3003/8188 bytes
=>
U-Boot 2015.04-14468-gd7d7c43-dirty (Jul 08 2016 - 14:38:47)
CPU: Freescale i.MX6Q rev1.5 at 792 MHz
CPU: Temperature 45 C
Reset cause: POR
Board: MX6Q-GWI-SCANNER revA
I2C: ready
DRAM: 1 GiB
PMIC: PFUZE100 ID=0x10
MMC: FSL_SDHC: 0
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
In: serial
Out: serial
Err: serial
Net: FEC [PRIME]
Boot from USB for mfgtools
Use default environment for mfgtools
Run bootcmd_mfg: run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
Hit any key to stop autoboot: 0
Bad Linux ARM zImage magic!
baudrate=115200
boot_fdt=try
bootargs=console=ttymxc0,115200 rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass_storage.file=/fat g_mass_storage.ro=1 g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF g_mass_storage.iSerialNumber= enable_wait_mode=off
bootcmd=mmc dev ${mmcdev};if mmc rescan; then if run loadbootscript; then run bootscript;else else if run loadimage; then run mmcboot; else run netboot; fi; fi; else run netboot; fi
bootcmd_mfg=run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
bootdelay=1
bootscript=echo Running bootscript from mmc ...; source
console=ttymxc0
emmcdev=2
epdc_waveform=epdc_splash.bin
ethprime=FEC
fdt_addr=0x18000000
fdt_file=imx6q-gwi-scanner.dtb
fdt_high=0xffffffff
image=zImage
initrd_addr=0x12C00000
initrd_high=0xffffffff
ip_dyn=yes
loadaddr=0x12000000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
mfgtool_args=setenv bootargs console=ttymxc0,115200 rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass_storage.file=/fat g_mass_storage.ro=1 g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF g_mass_storage.iSerialNumber="" enable_wait_mode=off
mmcargs=setenv bootargs console=${console},${baudrate} ${smp} root=${mmcroot}
mmcautodetect=yes
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
mmcdev=0
mmcpart=1
mmcroot=/dev/mmcblk3p2 rootwait rw
netargs=setenv bootargs console=${console},${baudrate} ${smp} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${image}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
script=boot.scr
update_emmc_firmware=if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; if ${get_cmd} ${update_sd_firmware_filename}; then if mmc dev ${emmcdev} 1; then setexpr fw_sz ${filesize} / 0x200; setexpr fw_sz ${fw_sz} + 1; mmc write ${loadaddr} 0x2 ${fw_sz}; fi; fi
update_sd_firmware=if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; if mmc dev ${mmcdev}; then if ${get_cmd} ${update_sd_firmware_filename}; then setexpr fw_sz ${filesize} / 0x200; setexpr fw_sz ${fw_sz} + 1; mmc write ${loadaddr} 0x2 ${fw_sz}; fi; fi
Environment size: 2904/8188 bytes
=>
Hi xuhui
for saving environment parameters in spi-nor please check
definition in uboot/include/configs/*board*.h file :
#define CONFIG_ENV_IS_IN_SPI_FLASH
Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
After testing found that flash memory can be an environment variable, but can not use,such as :
U-Boot 2015.04-14468-gd7d7c43-dirty (Jul 11 2016 - 10:44:31)
CPU: Freescale i.MX6Q rev1.5 at 792 MHz
CPU: Temperature 45 C
Reset cause: POR
Board: MX6Q-GWI-SCANNER revA
I2C: ready
DRAM: 1 GiB
PMIC: PFUZE100 ID=0x10
MMC: FSL_SDHC: 0
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
In: serial
Out: serial
Err: serial
Net: FEC [PRIME]
Boot from USB for mfgtools
Use default environment for mfgtools
Run bootcmd_mfg: run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
Hit any key to stop autoboot: 0
Bad Linux ARM zImage magic!
=> setenv serverip 192.168.23.249
=> setenv ipaddr 192.168.23.111
=> setenv gatewayip 192.168.23.1
=> setenv netmask 255.255.255.0
=> setenv ip_dyn no
=> setenv netargs setenv bootargs console=ttymxc0,115200 root=/dev/nfs ip=192.168.23.111 nfsroot=192.168.23.249:/home/lxh/nfsroot/nfs2,v3,tcp
=> setenv bootargs console=ttymxc0,115200 root=/dev/nfs ip=192.168.23.111 nfsroot=192.168.23.249:/home/lxh/nfsroot/nfs2,v3,tcp
=> saveenv
Saving Environment to SPI Flash...
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
Erasing SPI flash...Writing to SPI flash...done
=> sf probe
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
=> sf read ${loadaddr} 0xc0000 0x10000
SF: 65536 bytes @ 0xc0000 Read: OK
=> md.l ${loadaddr}
12000000: 52091475 64756162 65746172 3531313d u..Rbaudrate=115
12000010: 00303032 746f6f62 7464665f 7972743d 200.boot_fdt=try
12000020: 6f6f6200 67726174 6f633d73 6c6f736e .bootargs=consol
12000030: 74743d65 63786d79 31312c30 30303235 e=ttymxc0,115200
12000040: 6f6f7220 642f3d74 6e2f7665 69207366 root=/dev/nfs i
12000050: 39313d70 36312e32 33322e38 3131312e p=192.168.23.111
12000060: 73666e20 746f6f72 3239313d 3836312e nfsroot=192.168
12000070: 2e33322e 3a393432 6d6f682f 786c2f65 .23.249:/home/lx
12000080: 666e2f68 6f6f7273 666e2f74 762c3273 h/nfsroot/nfs2,v
12000090: 63742c33 6f620070 6d63746f 6d6d3d64 3,tcp.bootcmd=mm
120000a0: 65642063 7b242076 64636d6d 3b7d7665 c dev ${mmcdev};
120000b0: 6d206669 7220636d 61637365 74203b6e if mmc rescan; t
120000c0: 206e6568 72206669 6c206e75 6264616f hen if run loadb
120000d0: 73746f6f 70697263 74203b74 206e6568 ootscript; then
120000e0: 206e7572 746f6f62 69726373 653b7470 run bootscript;e
120000f0: 2065736c 65736c65 20666920 206e7572 lse else if run
=>
then I reboot the uboot :
U-Boot 2015.04-14468-gd7d7c43-dirty (Jul 11 2016 - 10:44:31)
CPU: Freescale i.MX6Q rev1.5 at 792 MHz
CPU: Temperature 45 C
Reset cause: POR
Board: MX6Q-GWI-SCANNER revA
I2C: ready
DRAM: 1 GiB
PMIC: PFUZE100 ID=0x10
MMC: FSL_SDHC: 0
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
In: serial
Out: serial
Err: serial
Net: FEC [PRIME]
Boot from USB for mfgtools
Use default environment for mfgtools
Run bootcmd_mfg: run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
Hit any key to stop autoboot: 0
Bad Linux ARM zImage magic!
=> sf probe
SF: Detected M25P32 with page size 256 Bytes, erase size 64 KiB, total 4 MiB
=> sf read ${loadaddr} 0xc0000 0x10000
SF: 65536 bytes @ 0xc0000 Read: OK
=> md.l ${loadaddr}
12000000: 52091475 64756162 65746172 3531313d u..Rbaudrate=115
12000010: 00303032 746f6f62 7464665f 7972743d 200.boot_fdt=try
12000020: 6f6f6200 67726174 6f633d73 6c6f736e .bootargs=consol
12000030: 74743d65 63786d79 31312c30 30303235 e=ttymxc0,115200
12000040: 6f6f7220 642f3d74 6e2f7665 69207366 root=/dev/nfs i
12000050: 39313d70 36312e32 33322e38 3131312e p=192.168.23.111
12000060: 73666e20 746f6f72 3239313d 3836312e nfsroot=192.168
12000070: 2e33322e 3a393432 6d6f682f 786c2f65 .23.249:/home/lx
12000080: 666e2f68 6f6f7273 666e2f74 762c3273 h/nfsroot/nfs2,v
12000090: 63742c33 6f620070 6d63746f 6d6d3d64 3,tcp.bootcmd=mm
120000a0: 65642063 7b242076 64636d6d 3b7d7665 c dev ${mmcdev};
120000b0: 6d206669 7220636d 61637365 74203b6e if mmc rescan; t
120000c0: 206e6568 72206669 6c206e75 6264616f hen if run loadb
120000d0: 73746f6f 70697263 74203b74 206e6568 ootscript; then
120000e0: 206e7572 746f6f62 69726373 653b7470 run bootscript;e
120000f0: 2065736c 65736c65 20666920 206e7572 lse else if run
=> run netboot
Booting from net ...
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
BOOTP broadcast 7
in my uboot/include/configs/borad.h file is such as :
#ifdef CONFIG_SYS_USE_SPINOR
#define CONFIG_CMD_SF
#define CONFIG_SPI_FLASH
#define CONFIG_SPI_FLASH_STMICRO
#define CONFIG_MXC_SPI
#define CONFIG_SF_DEFAULT_BUS 0
#define CONFIG_SF_DEFAULT_CS 1
#define CONFIG_SF_DEFAULT_SPEED 20000000
#define CONFIG_SF_DEFAULT_MODE (SPI_MODE_0)
#define CONFIG_ENV_IS_IN_SPI_FLASH
#endif
but it's the same than I Turn off the power and restored my save data is not in spi-nor flash