iMX233-OLINUXINO-MICRO boot from spi flash

Started by bluesky_kun, May 10, 2013, 12:50:20 PM

Previous topic - Next topic

bluesky_kun

hello ,everyone.
    now, i get a micro board.no SD card,so i want to boot from spi flash.my spi flash is m25p80.
i just switch jumper to spi boot mode,but not work..who can tell me how to part it for my micro board.


jlumme

I'm booting my maxi from spi-flash, our flash chip is SST25VF064 (uses same driver on linux side as yours)

The imx bootlets were quite confusing, so much so that I changed to using u-boot as our loader.
It's quite simple from there - after compiling it, write it to the beginning of the flash and set the proper jumpers, and it boots as expected.  8)
I'm using imx-branch for uboot (http://git.denx.de/?p=u-boot/u-boot-imx.git)

bluesky_kun

#2
@jlumme,
thanks for your tips.
I just download imx-branch for uboot (http://git.denx.de/?p=u-boot/u-boot-imx.git).I choose mx23evk board for my target.use arm-none-linux-gnueabi-gcc as default cross compile toolchain.when I make CROSS_COMPILE=arm-none-linux-gnueabi- .some errors happen.

:),which toolchain fit this uboot imx-branch? please tell me



my toolchain is arm-none-linux-gnueabi-gcc
emsym@ubuntu:~$ arm-none-linux-gnueabi-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/src/gcc-4.3/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}' --enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2009q1-203' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/obj/host-libs-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/obj/host-libs-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203)




jlumme

Hi bluesky_kun,

I have compiled u-boot on the default cross compiling tools found in Ubuntu repository, as well as built new versions with buildroot - both work ok.

I did not use mx23evk, but imx23-olinuxino (board/olimex/mx23_olinuxino). Also I modified the configuration file somewhat (include/configs/mx23_olinuxino.h ), so that SPI drivers were compiled.
I think the flags were

#define CONFIG_CMD_SF
#define CONFIG_CMD_SPI

But I can't remember it right now from the top of my head, but I can check it once I get back home from work.

bluesky_kun

Hi,jlumme
   
    thank you.I just follow your step to make uboot.but some errors happen.trouble you tell when you check it .

error message:
/bin/bash: line 1: 19082 Segmentation fault      arm-linux-gnueabi-ld.bfd -pie -T u-boot.lds -Bstatic -Ttext 0x40000100 arch/arm/cpu/arm926ejs/start.o --start-group api/libapi.o arch/arm/cpu/arm926ejs/libarm926ejs.o arch/arm/cpu/arm926ejs/mxs/libmxs.o arch/arm/imx-common/libimx-common.o arch/arm/lib/libarm.o common/libcommon.o disk/libdisk.o drivers/bios_emulator/libatibiosemu.o drivers/block/libblock.o drivers/crypto/libcrypto.o drivers/dfu/libdfu.o drivers/dma/libdma.o drivers/fpga/libfpga.o drivers/gpio/libgpio.o drivers/hwmon/libhwmon.o drivers/i2c/libi2c.o drivers/input/libinput.o drivers/misc/libmisc.o drivers/mmc/libmmc.o drivers/mtd/libmtd.o drivers/mtd/nand/libnand.o drivers/mtd/onenand/libonenand.o drivers/mtd/spi/libspi_flash.o drivers/mtd/ubi/libubi.o drivers/net/libnet.o drivers/net/phy/libphy.o drivers/pci/libpci.o drivers/pcmcia/libpcmcia.o drivers/power/battery/libbattery.o drivers/power/fuel_gauge/libfuel_gauge.o drivers/power/libpower.o drivers/power/pmic/libpmic.o drivers/rtc/librtc.o drivers/serial/libserial.o drivers/sound/libsound.o drivers/spi/libspi.o drivers/tpm/libtpm.o drivers/twserial/libtws.o drivers/usb/eth/libusb_eth.o drivers/usb/gadget/libusb_gadget.o drivers/usb/host/libusb_host.o drivers/usb/musb-new/libusb_musb-new.o drivers/usb/musb/libusb_musb.o drivers/usb/phy/libusb_phy.o drivers/usb/ulpi/libusb_ulpi.o drivers/video/libvideo.o drivers/watchdog/libwatchdog.o fs/cbfs/libcbfs.o fs/cramfs/libcramfs.o fs/ext4/libext4fs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o fs/libfs.o fs/reiserfs/libreiserfs.o fs/sandbox/libsandboxfs.o fs/ubifs/libubifs.o fs/yaffs2/libyaffs2.o fs/zfs/libzfs.o lib/libfdt/libfdt.o lib/libgeneric.o lib/lzma/liblzma.o lib/lzo/liblzo.o lib/zlib/libz.o net/libnet.o post/libpost.o test/libtest.o board/olimex/mx23_olinuxino/libmx23_olinuxino.o --end-group /home/emsym/u-boot-imx/arch/arm/lib/eabi_compat.o -L /usr/lib/gcc/arm-linux-gnueabi/4.6.1 -lgcc -Map u-boot.map -o u-boot
make: *** [u-boot] Error 139

jlumme

"Segmentation fault" - doesn't sound like something that would be committed to the repository.
I guess something is not correct the way you are launching your compilation or cross compiler settings..
Can you compile something on that compiler, and it executes on the board ?

bluesky_kun

#6
I miss some #define so that "Segmentation fault" happen.
I add some #define to mx23_olinuxino.h

even though I add some #define and no error find but can't boot from spi flash.

I think some #define I added is wrong.so please send me a copy of your mx23_olinuxino.h.


add #defines:

#define CONFIG_FLASH_CFI_DRIVER
#define CONFIG_SYS_FLASH_BASE 0x20000000
#define CONFIG_SYS_FLASH_CFI
#define CONFIG_SYS_FLASH_CFI_AMD_RESET
#define CONFIG_SYS_MAX_FLASH_BANKS 1
#define CONFIG_SYS_MAX_FLASH_SECT 67

#define CONFIG_SPI_FLASH_EON

#define CONFIG_MXS_SPI
#define CONFIG_ENV_SPI_MAX_HZ 30000000
#define CONFIG_SF_DEFAULT_SPEED 30000000
#define CONFIG_SPI_FLASH
#define CONFIG_SPI_FLASH_ALL




my skype :a77024128        we can on line chat

jlumme

You can find my config here ( http://paste.ubuntu.com/5664205/ ), I did add quite a few stuff there.
Don't forget that u-boot has to be flashed to the beginning of the memory

bluesky_kun

#8
     only modify mx23_olinuxino.h file? other file need to be added or modified? ;)
sorry to trouble you,I just try to add a few stuff there.and boot from spi flash

I have already modified CONFIG_SPI_FLASH_SST to CONFIG_SPI_FLASH_EON.I just use EON chip

serial port print error

error here:

0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003
0x80502008
          H0x80501003

jlumme

Quote from: bluesky_kun on May 15, 2013, 04:28:09 AM
     only modify mx23_olinuxino.h file? other file need to be added or modified? ;)

Hi bluesky_kun, sorry, I don't think I changed any other files, only added those configurations as far as I remember.
But I do not use the latest snapshot - I cloned mine from the repository on April 9th..

What is your boot trace when you try to boot ?

jlumme

OK, I guess you checked already, but

From http://sasamy.narod.ru/IMX23_ROM_Error_Codes.pdf
Quote
#define ERROR_ROM_LDR_SIGNATURE (ERROR_ROM_GROUP | ERROR_ROM_LOADER_GROUP | 0x3)
0x80501003 The file signature or file version is incorrect

You're sure you have set the jumpers correct ? Can you check the SPI bus with oscilloscope/logic analyzer, do you see any activity there ?

bluesky_kun

#11
jumpers is correct, and I use logic analyzer to find spi_cs not activity.

I choose SPI1 master for booting.

here my mx23_olinuxino.h  mark with /************************************************************/ are different from yours


/*
* Copyright (C) 2013 Marek Vasut <marex@denx.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef __MX23_OLINUXINO_CONFIG_H__
#define __MX23_OLINUXINO_CONFIG_H__

#include <asm/arch/iomux-mx23.h>

/*
* SoC configurations
*/
#define CONFIG_MX23 /* i.MX23 SoC */
#define CONFIG_MXS_GPIO /* GPIO control */
#define CONFIG_SYS_HZ 1000 /* Ticks per second */

#define CONFIG_MACH_TYPE 4105

#include <asm/arch/regs-base.h>

#define CONFIG_SYS_NO_FLASH
#define CONFIG_BOARD_EARLY_INIT_F
#define CONFIG_ARCH_MISC_INIT

/*
* SPL
*/
#define CONFIG_SPL
#define CONFIG_SPL_NO_CPU_SUPPORT_CODE
#define CONFIG_SPL_START_S_PATH "arch/arm/cpu/arm926ejs/mxs"
#define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds"
#define CONFIG_SPL_LIBCOMMON_SUPPORT
#define CONFIG_SPL_LIBGENERIC_SUPPORT
#define CONFIG_SPL_GPIO_SUPPORT

/*
* U-Boot Commands
*/
#include <config_cmd_default.h>
#define CONFIG_DISPLAY_CPUINFO
#define CONFIG_DOS_PARTITION

#define CONFIG_CMD_CACHE
#define CONFIG_CMD_DHCP
#define CONFIG_CMD_EXT2
#define CONFIG_CMD_FAT
#define CONFIG_CMD_GPIO
#define CONFIG_CMD_LED
#define CONFIG_CMD_MMC
#define CONFIG_CMD_NET
#define CONFIG_CMD_USB

#define CONFIG_ENV_IS_IN_SPI_FLASH  /************************************************************/
/* jlumme */
#define CONFIG_CMD_SF
#define CONFIG_CMD_SPI

/* jlumme, for ethernet */
#define CONFIG_CMD_PING
#define CONFIG_BOOTP_SUBNETMASK
#define CONFIG_BOOTP_GATEWAY
#define CONFIG_BOOTP_HOSTNAME
#define CONFIG_BOOTP_BOOTPATH

#define CONFIG_IPADDR        192.168.2.123    /************************************************************/
#define CONFIG_SERVERIP      192.168.2.246    /************************************************************/

#ifdef CONFIG_CMD_SPI
#define CONFIG_HARD_SPI
#define CONFIG_MXS_SPI
#define CONFIG_MXS_SPI_DMA_ENABLE
#define CONFIG_SPI_HALF_DUPLEX
#define CONFIG_DEFAULT_SPI_BUS 1    /************************************************************/
#define CONFIG_DEFAULT_SPI_MODE SPI_MODE_0

/* SPI Flash */
#ifdef CONFIG_CMD_SF
#define CONFIG_SPI_FLASH
#define CONFIG_SF_DEFAULT_BUS 1            /************************************************************/
#define CONFIG_SF_DEFAULT_CS 0
/* this may vary and depends on the installed chip */
#define CONFIG_SPI_FLASH_EON                /************************************************************/
#define CONFIG_SF_DEFAULT_MODE SPI_MODE_0
/* #define CONFIG_SF_DEFAULT_SPEED 24000000 */
#define CONFIG_SF_DEFAULT_SPEED 12000000

/* (redundant) environemnt in SPI flash */
#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
#define CONFIG_ENV_SIZE 0x1000 /* 4KB */
#define CONFIG_ENV_OFFSET 0x40000 /* 256K */
#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
#define CONFIG_ENV_SECT_SIZE 0x1000
#define CONFIG_ENV_SPI_CS 0
#define CONFIG_ENV_SPI_BUS 1    /************************************************************/
#define CONFIG_ENV_SPI_MAX_HZ 24000000
#define CONFIG_ENV_SPI_MODE SPI_MODE_0
#endif
#endif
#endif


/* < jlumme */



/*
* Memory configurations
*/
#define CONFIG_NR_DRAM_BANKS 1 /* 1 bank of DRAM */
#define PHYS_SDRAM_1 0x40000000 /* Base address */
#define PHYS_SDRAM_1_SIZE 0x08000000 /* Max 128 MB RAM */
#define CONFIG_SYS_MALLOC_LEN 0x00400000 /* 4 MB for malloc */
#define CONFIG_SYS_GBL_DATA_SIZE 128 /* Initial data */
#define CONFIG_SYS_MEMTEST_START 0x40000000 /* Memtest start adr */
#define CONFIG_SYS_MEMTEST_END 0x40400000 /* 4 MB RAM test */
#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
/* Point initial SP in SRAM so SPL can use it too. */

#define CONFIG_SYS_INIT_RAM_ADDR 0x00000000
#define CONFIG_SYS_INIT_RAM_SIZE (128 * 1024)

#define CONFIG_SYS_INIT_SP_OFFSET \
(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
#define CONFIG_SYS_INIT_SP_ADDR \
(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
/*
* We need to sacrifice first 4 bytes of RAM here to avoid triggering some
* strange BUG in ROM corrupting first 4 bytes of RAM when loading U-Boot
* binary. In case there was more of this mess, 0x100 bytes are skipped.
*/
#define CONFIG_SYS_TEXT_BASE 0x40000100

/*
* U-Boot general configurations
*/
#define CONFIG_SYS_LONGHELP
#define CONFIG_SYS_PROMPT "=> "
#define CONFIG_SYS_CBSIZE 1024 /* Console I/O buffer size */
#define CONFIG_SYS_PBSIZE \
(CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
/* Print buffer size */
#define CONFIG_SYS_MAXARGS 32 /* Max number of command args */
#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
/* Boot argument buffer size */
#define CONFIG_VERSION_VARIABLE /* U-BOOT version */
#define CONFIG_AUTO_COMPLETE /* Command auto complete */
#define CONFIG_CMDLINE_EDITING /* Command history etc */
#define CONFIG_SYS_HUSH_PARSER

/*
* Serial Driver
*/
#define CONFIG_PL011_SERIAL
#define CONFIG_PL011_CLOCK 24000000
#define CONFIG_PL01x_PORTS { (void *)MXS_UARTDBG_BASE }
#define CONFIG_CONS_INDEX 0
#define CONFIG_BAUDRATE 115200 /* Default baud rate */

/*
* Status LED
*/
#define CONFIG_STATUS_LED
#define CONFIG_GPIO_LED
#define CONFIG_BOARD_SPECIFIC_LED
#define STATUS_LED_BOOT 0
#define STATUS_LED_BIT MX23_PAD_SSP1_DETECT__GPIO_2_1
#define STATUS_LED_STATE STATUS_LED_ON
#define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)

/*
* MMC Driver
*/
#ifdef CONFIG_CMD_MMC
#define CONFIG_MMC
#define CONFIG_BOUNCE_BUFFER
#define CONFIG_GENERIC_MMC
#define CONFIG_MXS_MMC
#endif

/*
* APBH DMA
*/
#define CONFIG_APBH_DMA

/* USB */
#ifdef CONFIG_CMD_USB
#define CONFIG_USB_EHCI
#define CONFIG_USB_EHCI_MXS
#define CONFIG_EHCI_MXS_PORT0
#define CONFIG_USB_MAX_CONTROLLER_COUNT 1
#define CONFIG_EHCI_IS_TDI
#define CONFIG_USB_STORAGE
#endif

/* Ethernet */
#ifdef CONFIG_CMD_NET
#define CONFIG_USB_HOST_ETHER
#define CONFIG_USB_ETHER_SMSC95XX
#endif

/*
* Boot Linux
*/
#define CONFIG_CMDLINE_TAG
#define CONFIG_SETUP_MEMORY_TAGS
#define CONFIG_BOOTDELAY 3
#define CONFIG_BOOTFILE "uImage"
#define CONFIG_LOADADDR 0x42000000
#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR
#define CONFIG_OF_LIBFDT

/*
* Environment
*/
/*
#define CONFIG_ENV_IS_IN_MMC    /********************************************************/
#define CONFIG_ENV_OVERWRITE
#ifdef CONFIG_ENV_IS_IN_MMC
#define CONFIG_ENV_OFFSET (256 * 1024)
#define CONFIG_ENV_SIZE (16 * 1024)
#define CONFIG_SYS_MMC_ENV_DEV 0
#endif
*/
/*
* Extra Environments
*/
#define CONFIG_EXTRA_ENV_SETTINGS \
"update_sd_firmware_filename=u-boot.sd\0" \
"update_sd_firmware=" /* Update the SD firmware partition */ \
"if mmc rescan ; then " \
"if tftp ${update_sd_firmware_filename} ; then " \
"setexpr fw_sz ${filesize} / 0x200 ; " /* SD block size */ \
"setexpr fw_sz ${fw_sz} + 1 ; " \
"mmc write ${loadaddr} 0x800 ${fw_sz} ; " \
"fi ; " \
"fi\0" \
"script=boot.scr\0" \
"uimage=uImage\0" \
"console=ttyAMA0\0" \
"fdt_file=imx23-olinuxino.dtb\0" \
"fdt_addr=0x41000000\0" \
"boot_fdt=try\0" \
"ip_dyn=yes\0" \
"mmcdev=0\0" \
"mmcpart=2\0" \
"mmcroot=/dev/mmcblk0p3 rw rootwait\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
"root=${mmcroot}\0" \
"loadbootscript="  \
"fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
"bootscript=echo Running bootscript from mmc ...; " \
"source\0" \
"loaduimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}\0" \
"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
"mmcboot=echo Booting from mmc ...; " \
"run mmcargs; " \
"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
"if run loadfdt; then " \
"bootm ${loadaddr} - ${fdt_addr}; " \
"else " \
"if test ${boot_fdt} = try; then " \
"bootm; " \
"else " \
"echo WARN: Cannot load the DT; " \
"fi; " \
"fi; " \
"else " \
"bootm; " \
"fi;\0" \
"netargs=setenv bootargs console=${console_mainline},${baudrate} " \
"root=/dev/nfs " \
"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
"netboot=echo Booting from net ...; " \
"usb start; " \
"run netargs; " \
"if test ${ip_dyn} = yes; then " \
"setenv get_cmd dhcp; " \
"else " \
"setenv get_cmd tftp; " \
"fi; " \
"${get_cmd} ${uimage}; " \
"if test ${boot_fdt} = yes; then " \
"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
"bootm ${loadaddr} - ${fdt_addr}; " \
"else " \
"if test ${boot_fdt} = try; then " \
"bootm; " \
"else " \
"echo WARN: Cannot load the DT; " \
"fi;" \
"fi; " \
"else " \
"bootm; " \
"fi;\0"

#define CONFIG_BOOTCOMMAND \
"mmc dev ${mmcdev}; if mmc rescan; then " \
"if run loadbootscript; then " \
"run bootscript; " \
"else " \
"if run loaduimage; then " \
"run mmcboot; " \
"else run netboot; " \
"fi; " \
"fi; " \
"else run netboot; fi"

#endif /* __MX23_OLINUXINO_CONFIG_H__ */



bluesky_kun

If that' all right,please sent me a copy of your u-boot source.(Email:bluesky_kun@sina.com)
I find which different are they with Beyond Compare software.

thank you

bluesky_kun

I want to put u-boot kernel rootfs all into spi flash.  no SD card,no NAND flash.

so,I choose SPI1 master for booting .Things always not smooth. I have spent 3 weeks to port it . :'(



jlumme

I am also booting from SSP1 by the way, I have other stuff in SPI2.
Now that you made a comparison, it's interesting to find that in my config I set default bus to 2.. Maybe that is why automatic kernel loading is failing on my board.. ? (I have to manually load kernel every time currently. I had bigger issues so I have been postponing the fix for that)

Anyway, yes it's no problem to zip my u-boot, but I have some doubts using older version solves your problem. I will also re-grep my environment to make sure I didn't change something else in the code.

SPI1_CS not happening sounds indeed like a problem..