2009-02-24 10:55:51 How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Dominic On (CANADA)
Message: 69824
Hi,
I'm newbie to use the blackfin BF527. Right now the system boot OK, but I would like to have the system to boot either Kernel "A" or Kernel "B", how can I do this? please help.
The purpose of duo-boot is for customer to do upgrading, if something wrong to the newly upgrading kernel "A", we still have a backup kernel "B" and vise versa.
I use STMicro M25P64 (8 Megabytes) SPI Flash, and would like to setup the partitions: U-Boot (196KB), Kernel "A" (2.5MB), Kernel "B" (2.5MB), User Space FS (2MB), Program Configure Data (Remaining 828KB).
Many thanks with your help.
Regards,
Dominic On
QuoteReplyEditDelete
2009-02-24 11:05:50 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Mike Frysinger (UNITED STATES)
Message: 69825
when you read spi flashes in u-boot, you give it an offset/length. if you want to boot somewhere else, give it a different offset/length.
QuoteReplyEditDelete
2009-02-24 13:15:12 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Dominic On (CANADA)
Message: 69833
Thank you Mike for the fast reply. How do I setup the partition? How do I mount the User Space, and User Program Data?
QuoteReplyEditDelete
2009-02-24 13:20:00 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Dominic On (CANADA)
Message: 69834
How do I know the kernel is successfully loaded, so that the U-Boot has to change the offset/length if the current loaded kernel is failed?
QuoteReplyEditDelete
2009-02-24 13:42:31 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Mike Frysinger (UNITED STATES)
Message: 69836
u-boot doesnt deal in partitions
if you want to know about Linux, read the docs:
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:mtd
QuoteReplyEditDelete
2009-02-24 13:43:26 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Mike Frysinger (UNITED STATES)
Message: 69837
u-boot has scripting support when you enable the hush shell ... the u-boot source code has more information
QuoteReplyEditDelete
2009-02-24 13:49:22 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Robin Getz (UNITED STATES)
Message: 69838
Dominic:
I thought there was a U-Boot feature where U-Boot would decide to boot one image vs a different one -- based on if the first one failed to boot -- but I can't seem to find which CONFIG_ it is now...
-Robin
QuoteReplyEditDelete
2009-02-25 13:58:20 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Phil Wilshire (UNITED STATES)
Message: 69904
Hi,
Take a look at
CONFIG_BOOTCOUNT_LIMIT
in common/main.c
It is NOT yet setup for the blackfin as standard but I have done some work with it on a coldfire system.
This option will try a few boots and increment a boot count (kept in scratchpad)
(Watch out because the scratch pad may be used as an early stack by Linux)
When the count exceeds a limit the env var "altbootcmd" will be used instead of "bootcmd".
When the kernel boots it should reset the boot count. The count has a "magic" number associated with it
to indicate that it was indeed set up by u-boot.
The system assumes that no correct magic number will be seen after a power cycle.
The "Hush" shell can be used to run "iminfo" on a possible image ( after reading into ram )
An "if-then-else" condition can then be used to select a good image.
But be warned that when you use the Hush shell all references like "$(serverip)" have to be replaced with
"${serverip}"
regards
Phil Wilshire
QuoteReplyEditDelete
2009-02-28 20:50:40 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Robin Getz (UNITED STATES)
Message: 70169
Phil:
That is the one I was looking for - but I couldn't find it - thanks for the pointer - although it looks like we need to add some things in the kernel, and in the blackfin specific portions of U-Boot to make it work.
-Robin
QuoteReplyEditDelete
2009-03-04 18:19:18 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Dominic On (CANADA)
Message: 70387
Could anybody provide or give me a document STEP by STEP HOW TO CREATE MTD PARTITIONS? Thanks. I follow the instruction from this link http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:mtd, but does'n work.
QuoteReplyEditDelete
2009-03-04 19:45:19 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Mike Frysinger (UNITED STATES)
Message: 70390
we dont copy & paste documentation when people can go to a link and read it themselves
if the document isnt helping, then describe *exactly* what you're doing (i.e. config settings / source changes) as well as *exactly* what you're seeing (i.e. kernel boot log and relevant /proc/ files)
then we'll look at what you missed or what the documentation is missing
QuoteReplyEditDelete
2009-03-06 18:08:42 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Dominic On (CANADA)
Message: 70549
I changed the partition design, and only have 1 kernel, instead of 2 kernels as previously design (too much work). I just wanted to make the MTD works first.
Right now, I have the partitions, and I can dump from/to flash/ram and vise versa, I can erase and have no problem, But I can NOT mount.
cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00010000 "Bootloader"
mtd1: 00300000 00010000 "Kernel"
mtd2: 00300000 00010000 "RootFS"
mtd3: 001c0000 00010000 "Data"
=======================================================
eraseall /dev/mtd3
MTD_open
MTD_ioctl
ErasingM64 KTbyte D 0 --_ 0 % iompleoc.tl
spi0.1: m25p80_erase at 0x00640000, len 65536
spi0.1: erase_sector at 0x00640000
....
spi0.1: m25p80_erase at 0x007f0000, len 65536
spi0.1: erase_sector at 0x007f0000
Erased 1M92 KTDyte @_0 -- 100% complete
=============================================================
dump:
dd if=/dev/mtdblock3 of=/var/fdump count=120
mtdblock_open
ok
mtdblock: read on "Data" at 0x0, size 0x200
spi0.1: m25p80_read from 0x00640000, len 512
.......
spi0.1: m25p80_read from 0x0067be00, len 512
mtdblock_release
ok
120+0 records in
120+0 records out
==============================================================
root:/> mount -t yaffs2 /dev/mtdblock3 /mnt
mount: mounting /dev/mtdblock3 on /mnt failed
root:/> mount -t jffs2 /dev/mtdblock3 /mnt
mount: mounting /dev/mtdblock3 on /mnt failed
I've notice that the Len is 512 when read/write from/to the spi flash, but when erase, the erase size is 1 sector of 64K
Here is what I'm doing:
Config:
Device Drivers --->
<*> Memory Technology Device (MTD) support --->
[*] MTD partitioning support
[*] Command line partition table parsing
[*] Direct char device access to MTD devices
[*] Caching block device access to MTD devices
Mapping drivers for chip access --->
[*] Support non-linear mappings of flash chips
< > Generic uClinux RAM/ROM filesystem support (disable this option)
Self-contained MTD device drivers --->
<*> Support for M25 SPI Flash
[*] Use FAST_READ OPCode allowing SPI CLK <= 50MHz
Board Resource change:
file: uclinux-dist/linux-2.6.x/arch/blackfin/mach-bf527/board/ezkit.c
#if defined(CONFIG_MTD_M25P80) \ || defined(CONFIG_MTD_M25P80_MODULE) static struct mtd_partition bfin_spi_flash_partitions[] = { {
.name = "Bootloader",
.size = 0x40000, //Use 4 sectors (256 KB 0r 0.25 MB)
.offset = 0,
.mask_flags = MTD_CAP_ROM
}, {
.name = "Kernel",
.size = 0x3C0000, //Use 30 sectors (3 MB)
.offset = MTDPART_OFS_APPEND,
}, {
.name = "RootFS",
.size = 0x3C0000, //Use 30 sectors (3 MB)
.offset = MTDPART_OFS_APPEND,
}, {
.name = "Data",
.size = MTDPART_SIZ_FULL, //The remainning 8 MB - 256 KB - 3MB - 3 MB = 0x1C0000 (1.75 MB)
.offset = MTDPART_OFS_APPEND,
}
};
static struct flash_platform_data bfin_spi_flash_data = {
.name = "m25p80",
.parts = bfin_spi_flash_partitions,
.nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
.type = "m25p64",
};
/* SPI flash chip (m25p64) */
static struct bfin5xx_spi_chip spi_flash_chip_info = {
.enable_dma = 0, /* use dma transfer with this chip*/
.bits_per_word = 8,
};
#endif static struct spi_board_info bfin_spi_board_info[] __initdata = {
#if defined(CONFIG_MTD_M25P80) \
|| defined(CONFIG_MTD_M25P80_MODULE)
{
/* the modalias must be the same as spi device driver name */
.modalias = "m25p80", /* Name of spi_driver for this device */
.max_speed_hz = 32000000, /* max spi clock (SCK) speed in HZ */
.bus_num = 0, /* Framework bus number */
.chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
.platform_data = &bfin_spi_flash_data,
.controller_data = &spi_flash_chip_info,
.mode = SPI_MODE_3,
},
#endif
Please help!
Thanks,
Dominic On
QuoteReplyEditDelete
2009-03-06 18:18:35 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Mike Frysinger (UNITED STATES)
Message: 70550
did you actually enable and/or load the filesystems as documented ?
if you did, then read the kernel log with `dmesg`. if there isnt anything interesting in there, then run the mount command through strace to see what the error is coming from.
QuoteReplyEditDelete
2009-03-09 13:11:36 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Dominic On (CANADA)
Message: 70619
Thank you very much for your help. I didn't know about enable FS, I thought it'll be automatically enabled when MTD is enabled
The following link does NOT show us how to enable the filesystems.
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:mtd.
Anyway, here is how to enable the file systems:
File systems ----->
<*> Filesystem in Userspace support
Miscellaneous filesystems ---->
<*> Journalling Flash File System v2 (JFFS2) support
(0) JFFS2 debugging verbosity (0 = quiet, 2 = noisy)
[*] JFFS2 write-buffering support
Regards,
Dominic On
QuoteReplyEditDelete
2009-03-09 16:49:16 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Mike Frysinger (UNITED STATES)
Message: 70626
that's because that document doesnt cover filesystems. if you read the intro, you would have known this and seen the links to the filesystem specific pages.
it makes no sense for for the MTD options to force random file systems to be enabled.
QuoteReplyEditDelete
2009-03-10 13:19:36 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Dominic On (CANADA)
Message: 70711
I would suggest to move the File System Enable option to the MTD option section, so we (the newbies) won't miss this.
Anyway, now I try to use netflash to upgrade the image to the flash, is the netflash require TFTP only? Can I use FTP instead?
netflash aways crashes my system when invalid option or server is not ready.
I have TFTP server running at IP 192.168.200.33, and I use netflash to download uImage to /dev/mtd2 for a test, but no success. Here is the output:
root:/> netflash -k -b -n -r /dev/mtd2 192.168.100.33/uImage
MTD_open
neMflashT offsDt is _reatec thanldevico sizese
0)
The warning or error message telling me something about offset greater than device size ?
Please help.
Thanks,
Dominic On
QuoteReplyEditDelete
2009-03-10 15:18:43 Re: How do I setup the Duo-Boot system management using the SPI Flash STMicro M25P64
Mike Frysinger (UNITED STATES)
Message: 70718
the MTD page is already big enough. adding tons of filesystem-specific information is not a good idea (jffs/yaffs/ubifs/...).
just use a simple script:
cd /tmp
ftpget ...
erase_all /dev/mtd2
cat foo > /dev/mtd2