2009-01-27 03:04:46 firmware upgrade
Daniele Pagani (ITALY)
Message: 68373
Dear sirs,
in my project, I need to upgrade the "firmware" by network.
For me "firmware" means kernel+file system, that is what now I do with u-boot and with uImage.initramfs.
I've yet read something about mtd and so on.
So, my idea it to:
1) download the uImage.initramfs to ram
2) eraseall /dev/mtdx where "x" is the question of this thread
3) dd -if=uImage.initramfs of=/dev/mtdblocky where "y" is the question of this thread.
I'm using the Ezkit bf537; dmesg tells me:
Creating 4 MTD partitions on "physmap-flash.0":
0x00000000 - 0x00040000 : "Bootloader"
0x00040000 - 0x00120000 : "Kernel"
0x00120000 - 0x003f0000 : "RootFS"
0x003f0000 - 0x00400000 : "MAC Address"
/proc/mtd tells me:
mtd0: 00040000 00010000 "Bootloader"
mtd1: 000e00000 00010000 "Kernel"
mtd2: 002d0000 00010000 "RootFS"
mtd3: 00010000 00010000 "MAC Address"
So, if I want to upgrade all the uClinux image, that is uImage.initramfs in /images directory, what can I do?
I've tried
eraseall /dev/mtd2
dd -if=uImage.initramfs -of=/dev/mtdblock2
but then the kernel doesn't start.
Best regards,
Daniele.
TranslateQuoteReplyEditDelete
2009-01-27 10:06:07 Re: firmware upgrade
Mike Frysinger (UNITED STATES)
Message: 68404
where ever you store the uImage in flash, you have to have u-boot boot the same location. are you doing that ? what exactly do you mean by "the kernel doesn't start" ?
QuoteReplyEditDelete
2009-01-27 10:19:41 Re: firmware upgrade
Daniele Pagani (ITALY)
Message: 68405
Dear Mike,
when I use u-boot I do as follows:
tftp 0x1000000 uImage.initramfs // to copy from tftp server the image
flinfo // to see my flash situation
erase 0x20040000 0x203effff
cp.b 0x1000000 0x20040000
printenv bootcmd gives me bootcmd=bootm 0x20040000
and all works fine.
Now, I want to write in flash the same (or new, of course) image but by linux console (on the embedded system).
So, wget or similar to copy image from server to embedded system:
tftp -g -r uImage.initramfs 192.168.1.68 // my tftp server
mtd partition as in previous message
eraseall /dev/mtd2
dd if=uImage.initramfs of=/dev/mtdblock2
reboot
## Booting image at 20040000
Image Name: Linux-2.6.22.19-ADI-2008R1.5-svn
Created: 2009-01-26 16:49:43 UTC
Image Type: Blackfin Linux Kernel Image (gzip compressed)
Data Size: 2724465 Bytes = 2.6MB
Load Address: 00001000
Entry Point: 0014c000
Verifying Checksum ... Bad Data CRC
bfin>
Best regards,
Daniele.
TranslateQuoteReplyEditDelete
2009-01-27 10:46:20 Re: firmware upgrade
Mike Frysinger (UNITED STATES)
Message: 68410
well you arent writing the same location. in u-boot you're using offset of 0x40000. in userspace, you're using offset of 0x120000.
QuoteReplyEditDelete
2009-01-27 11:23:50 Re: firmware upgrade
Daniele Pagani (ITALY)
Message: 68412
Dear Mike,
ok, but what command can I use in Linux to erase all block and then to write the whole uImage.initramfs in different partitions?
That is, I can use:
eraseall /dev/mdt0
eraseall /dev/mtd1
eraseall /dev/mtd2
but, now, how can I write uImate.initramfs in these three different partitions?
It is possible with dd or something similar?
Best regards,
Daniele.
TranslateQuoteReplyEditDelete
2009-01-27 11:29:48 Re: firmware upgrade
Michael Hennerich (GERMANY)
Message: 68413
<*> Direct char device access to MTD devices
CONFIG_MTD_CHAR allows you to use cp
cp /var/rootfs.jffs2 /dev/mtd1
-Michael
QuoteReplyEditDelete
2009-01-27 12:20:19 Re: firmware upgrade
Mike Frysinger (UNITED STATES)
Message: 68417
why would you want to do that ? you'd erase the entire flash in the process. just do the right thing and match your flash usage in u-boot with the partition map you've declared in linux.
QuoteReplyEditDelete
2009-01-27 14:57:54 Re: firmware upgrade
Daniele Pagani (ITALY)
Message: 68431
Dear Mike,
yes, I have done a mistake, if I execute
eraseall /dev/mtd0
then I delete also the bootloader, so it is not a good idea of course...
What I need to do is doing an upgrade of all operative system, kernel + rootfs
So, if I understand, I need to delete mtd1 and mtd2
but then, when I want to write into flash, I don't understand how can I split the file uImage.initramfs in two files, in order to put one in mtd1 (kernel) and on in mtd2 (rootfs).
In u-boot I run:
cp.b 0x1000000 0x20040000 $(filesize)
and so I copy the whole uImage.initramfs file into flash.
But, if I need to write in two partitions in linux I don't understand how.
That is, can I execute from linux shell:
cp.b uImage.initramfs 0x20040000
I think that this is not possible.
In my project I can not use u-boot, because I've only a ethernet connection, no other interface (no button, no uart, no display, and so on..).
Best regards,
Daniele.
Dear Michael, I'll test your solution, but I've some doubt about it.
TranslateQuoteReplyEditDelete
2009-01-27 15:15:55 Re: firmware upgrade
Mike Frysinger (UNITED STATES)
Message: 68432
if you cant use u-boot, then you cant use linux. there is no support for booting linux directly from the bootrom ... all of the logic is in u-boot.
you cant just throw any old image into random places in the flash from u-boot or linux and expect things to simply line up. you need to layout exactly what it is you want to accomplish (kernel / rootfs / etc...), and then you need to layout exactly how you will partition the flash.
you might want to start with these documents:
http://docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:images
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:mtd
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:jffs
QuoteReplyEditDelete
2009-01-28 02:35:18 Re: firmware upgrade
Daniele Pagani (ITALY)
Message: 68448
Dear Mike,
I've already read these articles several times, but there is something that cause me confusion.
Now, the layout partitions is in according to the first message; I'm using the Ezkit bf537, and it is the "standard" partitions.
So, I want to upgrade both the kernel and the rootfs.
So, I execute:
eraseall /dev/mtd1 --> to erase the partition Kernel from 0x40000 to 0x120000
eraseall /dev/mtd2 --> to erase the partition RootFS from 0x120000 to 0x3f0000
Now I need to write into this partitions, of course, so I take these files from my images directory:
rootfs.initramfs.gz --> A root filesystem formatted in the cpio archive format and compressed with gzip (from http://docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:images)
vmImage --> The Linux kernel in the bootable U-Boot format -- no root filesystem(from the same document)
I execute:
dd if=vmImage of=/dev/mtdblock1
dd if=rootfs.initramfs.gz of=/dev/mtdblock2
in order to put these files into flash.
Then I reboot:
## Booting image at 20040000...
Bad Magic Number
So, sorry, there is something that I don't know/understand
Best regards,
Daniele.
TranslateQuoteReplyEditDelete
2009-01-28 07:37:57 Re: firmware upgrade
Ian Jeffray (UNITED KINGDOM)
Message: 68471
vmImage --> The Linux kernel in the bootable U-Boot format -- no root filesystem(from the same document)
Are you sure about that? You'd want to put a uImage there...
QuoteReplyEditDelete
2009-01-28 08:22:42 Re: firmware upgrade
Daniele Pagani (ITALY)
Message: 68477
Dear Ian,
when I use u-boot I select uImage.initramfs and all works fine.
In Linux shell I can not use uImage.initramfs (this is my mistake, but I don't understand), because the size:
uImage.initramfs: 2,724,529 byte
and I have mtd1 with 0xe0000 size (896kb)
So, when I execute:
dd if=uImage.initramfs of=/dev/mtdblock1
how can I write a file bigger than the space on mtd block?
So, I think I need to "split" uImage.initramfs into two partitions.
This is what I don't understand and I don't how can I do.
Best regards,
Daniele.
TranslateQuoteReplyEditDelete
2009-01-28 14:43:31 Re: firmware upgrade
Mike Frysinger (UNITED STATES)
Message: 68493
rootfs.initramfs.gz is never used directly. it's provided as a debugging tool.
if you want to use a rootfs out of flash, then you need to pick a real flash based rootfs. initramfs is only ever used embedded in a kernel.
so like Ian said, if you want to boot a uImage.initramfs out of flash, you need to write that to flash, not a vmImage.
QuoteReplyEditDelete
2009-01-29 03:29:43 Re: firmware upgrade
Daniele Pagani (ITALY)
Message: 68501
Dears Mike and Ian,
I've solved my problem and I'd like to show how if somebody will have the same problem.
I want to use uImage.initramfs, but, in according to "default" partitions is not possible (I don't know how) to write uImage.initramfs into two partitions, because it is a whole file.
I've read something about mtd concatenating and so on, but I don't find nothing about shell command.
So, the solution is to write the partitions.
In order to do this, I've done:
in file
uClinux-dist-2008R1.5-RC3/linux-2.6.x/arch/blackfin/mach-bf537/boards/stamp.c
I've changed:
static struct mtd_partition stamp_partitions[]={
{
.name = "Bootloader",
.size = 0x40000,
.offset = 0,
},{
.name = "Linux",
.size = 0x3B0000,
.offset = MTDPART_OFS_APPEND,
},{
.name = "MAC Address",
.size = MTDPART_SIZ_FULL,
.offset = 0x3f0000,
.mask_flags = MTD_WRITEABLE,
}
};
That is, the idea is to create a whole partition in which I'll put the uImage.initramfs.
This is what I need, so thank you very much for your support.
Best regards,
Daniele.