How to modify the bootloader?

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

How to modify the bootloader?

3,128 Views
PeterTeoh
Contributor I

As I navigate the filesystem inside my i.MX53 Quick Start board, there is no "grub" directory under /boot, and so now that have created the vmlinux/uImage and zImage/System.map, how do I update the bootloader to point to the new kernel image (compiled from linaro git tree, 2.6.38).

Thanks.

Tags (1)
0 Kudos
17 Replies

2,740 Views
daiane_angolini
NXP Employee
NXP Employee

There is only one image that should be placed at a right and pre-defined location (or address), it´s uboot image.

 

For uImage you may place it anywhere, if you tell both uboot and mkimage the right ldaddress.

 

For rootfs, it should be mounted by kernel through kernel command line. Your kernel command line will tell kernel which partition (or nfs folder) should be mounted as rootfs.

0 Kudos

2,740 Views
PeterTeoh
Contributor I

Thank you Krishna, 

I will come back I am over with some commitment, thanks for your help!!!   Good advice!!!


Krishna Pavan said:

Hi Peter,

 

1. Check whether DIP Switch Settings are O.K

 

2. Check that you have followed the steps properly as per the LInux_BSP_User_Guide, load bootloader & Kernel image sequentially.

 

3. Check that you have placed your SD Card in a proper slot 0/1

 

Even then if it does not work, then try to rebuild your kernel

 

Regards   ::    Krishna Pavan

0 Kudos

2,740 Views
KrishnaPavan
Contributor II

Hi Peter,

 

1. Check whether DIP Switch Settings are O.K

 

2. Check that you have followed the steps properly as per the LInux_BSP_User_Guide, load bootloader & Kernel image sequentially.

 

3. Check that you have placed your SD Card in a proper slot 0/1

 

Even then if it does not work, then try to rebuild your kernel

 

Regards   ::    Krishna Pavan

0 Kudos

2,740 Views
PeterTeoh
Contributor I

Sorry, I don't understand something.

 

I am modifying the sdcard which is shipped together with the development kit, so there already exists an existing rootfs - correct?

 

So I found that at offset sector 2048 - yes, the old uImage kernel is there.   So I overwrite it with the newly comiled uImage.

 

As for the existing rootfs, it is installed in the first partition on the sdcard - which starts from cylinder 16.   Mathematically, cylinder 16 means 15 cylinders (preceding it) x 19 * 48 (heads x sectors per track) = 13680 sector.   The uImage lies at 2048 sector, which is way before this.   So writing the uImage (which requires less than 6000 sectors) has no way of reaching this number 13680.   So something must be missing in the uImage which I had just compiled - how does it know WHERE to load the rootfs, which is in the first partition of the sdcard, and carries over as the same original rootfs image as the older uImage.   

 

sorry for all the confusion - it really puzzle me, as this default shipped rootfs from Freescale development starts from 13680th sector, but the BSP starter guide 7.1.4 specify making the partition at 8192 sector.   (which is a hassle for fdisk which worked at the cylinder level - 8192 sectors means approx 9th cylinder correct?)

 

Terribly confused.



Daiane Angolini said:

Did you fixed this error?

 

Or you have a wrong kernel command line (missing console) or you did configured your kernel using a wrong configure file.

 

Can you, please share your configure command line and your kernel command line?

 

Any init process will only be executed after all kernel being loadded. (so, you need to be sure it's loading)

 

Peter Teoh said:

Oh, I yes, I found the documentation inside the tgz file:

https://www.freescale.com/webapp/Download?colCode=IMX53_QSB_1101_LI...

 

And then I did a dd to backup the original image:

 

dd if=/dev/sdb of=uImage.orig bs=512 skip=2048 count=5000

and followed by the dd of the new compiled uImage:

dd if=uImage of=/dev/sdb bs=512 seek=2048 

 

It bootup alright with the new kernel, but just freeze immediately after the uncompressing.   what happened?

 

 

MMC read: dev # 0, block # 2048, count 6144 partition # 0 ...
6144 blocks read: OK
## Booting kernel from Legacy Image at 70800000 ...
Image Name: Linux-2.6.38.3+
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2381608 Bytes = 2.3 MB
Load Address: 70008000
Entry Point: 70008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

 

0 Kudos

2,740 Views
PeterTeoh
Contributor I

The dd command only write the sector starting from 2048 onwards, so there is no change to the partition table, which is sector 1 (sector 0 is the first sector).   Correct?   So which is why after dd, fdisk still can see my partition table having one partition starting from cylinder 16.

Krishna Pavan said:

Hi Peter,

My view is

After using the dd command, the partition table is altered, so there is no roots on your device.

 

 

Expecting Daiane to look at my view.

 

Regards  ::  Krishna Pavan

 

0 Kudos

2,740 Views
JohnReed
Contributor I

Peter,

 

I've had good luck with an SDcard burning script that was posted back in May on this group.   Follow this link:

 

http://imxcommunity.org/group/imx53quickstartboard/forum/topics/flashing-helper-script-for-the

 

It's sort of an all-in-one script.   You need to have both u-boot.bin and uImage under ltib/rootfs/boot

 

It writes all 3 to the SDcard.      So I'd start there, the script worked for me as-is.    But you could certainly modify it to fit your specific needs.

 

JR

0 Kudos

2,740 Views
daiane_angolini
NXP Employee
NXP Employee

If there is no rootfs kernel will hang when it tries to mount the rootfs (and I have face it a lot of times =P, missing NFS rootfs or forget to copy system to sdcard is commun on my desk =D)

 

I think you should focus on getting the uImage loading, at least something. And wait for the rootfs error. And it looks likes all uImage is read from memory, it only isn't executed.

 

I'm confused about which dd command was used. Sometimes you can skip the first part of SDCard preserving the MBR, uboot and uImage.

 

(in order words, there is 2 errors, rootfs and uImage)

0 Kudos

2,740 Views
KrishnaPavan
Contributor II

Hi Peter,

My view is

After using the dd command, the partition table is altered, so there is no roots on your device.

 

Expecting Daiane to look at my view.

 

Regards  ::  Krishna Pavan

0 Kudos

2,740 Views
daiane_angolini
NXP Employee
NXP Employee

Did you fixed this error?

 

Or you have a wrong kernel command line (missing console) or you did configured your kernel using a wrong configure file.

 

Can you, please share your configure command line and your kernel command line?

 

Any init process will only be executed after all kernel being loadded. (so, you need to be sure it's loading)

 

Peter Teoh said:

Oh, I yes, I found the documentation inside the tgz file:

https://www.freescale.com/webapp/Download?colCode=IMX53_QSB_1101_LI...

 

And then I did a dd to backup the original image:

 

dd if=/dev/sdb of=uImage.orig bs=512 skip=2048 count=5000

and followed by the dd of the new compiled uImage:

dd if=uImage of=/dev/sdb bs=512 seek=2048 

 

It bootup alright with the new kernel, but just freeze immediately after the uncompressing.   what happened?

 

 

MMC read: dev # 0, block # 2048, count 6144 partition # 0 ...
6144 blocks read: OK
## Booting kernel from Legacy Image at 70800000 ...
Image Name: Linux-2.6.38.3+
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2381608 Bytes = 2.3 MB
Load Address: 70008000
Entry Point: 70008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

 

0 Kudos

2,740 Views
KrishnaPavan
Contributor II

Hi Peter Teoh,

 

Initial RAM Disk initially copied & mounted in RAM, and used that serves as a temporary file system.

init RAM disk allows the Kernel to fully boot without having to mount any of the phyical disks.

 

Later when the kernel is completely booted, initrd is unmounted & rootfs is mounted on the physical disk.

 

Regards -- --- --- --- -- Krishna Pavan

0 Kudos

2,740 Views
PeterTeoh
Contributor I

Thanks Krishna, 

 

To confirm John Reed's question - yes I am booting from sdcard.

 

And I don't understand this.   First, section 7.1.2 is on bootloader image uboot, which I don't want to change, so I did not follow the instruction, correct?

 

Then 7.1.3 is the kernel image, yes, I did the dd.

 

But 7.1.4,  I still want to use the existing rootfs,  I download only the linaro kernel image and rebuild it for iMX53, but rootfs, to recreate it?  is totally even puzzling to me.

Looking at the partition in the sdcard (original from the Freescale i.MX53 package) :

 

fdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 3959 MB, 3959422976 bytes
19 heads, 48 sectors/track, 8479 cylinders
Units = cylinders of 912 * 512 = 466944 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a1287

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 16 6914 3145728 83 Linux
root@lucid-desktop:/proc#

 

So this means that the ext3 filesystem start from sector 16, and end in 6914 (sorry for the messed text).

 

But we earlier dd out the uImage starting from 2048th sector, which is inside the ext3 boundary.   How can that be?

 

But the documentation 7.1.4 also confused me:   it said first you do a fdisk starting offset 8192th sector,  and then mkfs on that partition.

 

This is again in contrary with the default setting as I had analyzed in the default Freescale provided sdcard.

 

Problem is even if i followed the mkfs and copied all the rootfs there, after the uImage execute, (which itself always startup from 2048th sector) how does it execute the init command in the rootfs?

 

Please help me in my confusion.

 

Thank you.

 

PS:

 

This is a link which I have not pursue much, so is it useful:

http://blog.angrygoats.net/2011/05/28/linaro-and-i-mx53/

0 Kudos

2,740 Views
KrishnaPavan
Contributor II

Hi Peter, Have you got the rootfs on to your device.

 

The Kernel Image did its job, it booted, thats all. So far good..

 

If you have got rootfs, then the next happens.

 

I did not quite understand the concept of Uimage.Original, If you want to update image then you can use u-boot-no-padding.

i did not understand, why you did not follow this procedure.

0 Kudos

2,740 Views
PeterTeoh
Contributor I

Oh, I yes, I found the documentation inside the tgz file:

https://www.freescale.com/webapp/Download?colCode=IMX53_QSB_1101_LINUXDOCS_BUNDLE&location=null&fpsp...

 

And then I did a dd to backup the original image:

 

dd if=/dev/sdb of=uImage.orig bs=512 skip=2048 count=5000

and followed by the dd of the new compiled uImage:

dd if=uImage of=/dev/sdb bs=512 seek=2048 

 

It bootup alright with the new kernel, but just freeze immediately after the uncompressing.   what happened?

 

MMC read: dev # 0, block # 2048, count 6144 partition # 0 ...
6144 blocks read: OK
## Booting kernel from Legacy Image at 70800000 ...
Image Name: Linux-2.6.38.3+
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2381608 Bytes = 2.3 MB
Load Address: 70008000
Entry Point: 70008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

0 Kudos

2,740 Views
KrishnaPavan
Contributor II

Hi Peter Teoh,

 

Is it that you want to load two kernel images and boot from them one after the another?

0 Kudos

2,740 Views
JohnReed
Contributor I

Peter,

 

Well, you're leaving out a lot of details:   like are you booting from NFS or from the microSD card??

 

I currently only have experience booting from the microSD card, in which case here's my answer:

 

If you build a new kernel, then it's not enough to just change the link in your boot directory, you have to actually use "dd" to write the new kernel to the disk.    Look at the document:

        i.MX53_START_Linux_BSP_UserGuide.pdf

        Look in section 7.1.3 of that document.

 

 

The command would be:

 

        dd if=uImage of=/dev/sdb bs=512 seek=2048 && sync && sync

 

The "of" parameter depends on where your USB device actually is.   On some machines it's /dev/sdb, but on my machine it's /dev/sdc.

 

The bootloader (it's named u-boot for i.MX53 QSB) expects to see the kernel at a particular offset on the microSD card.     That offset is 1MB (512 * 2048).   So you've got to "burn" it there.

 

Happy Hacking!!

JR

0 Kudos

2,740 Views
PeterTeoh
Contributor I

Nope, all the soft-link are changed, but the kernel still bootup back to the original version.

0 Kudos

2,740 Views
PeterTeoh
Contributor I

This is my directory:

 

lrwxrwxrwx 1 root root 27 2011-02-04 06:39 initrd.img -> initrd.img-2.6.1
-rw-r--r-- 1 root root 3914135 2010-06-13 13:54 initrd.img-2.6.31-607-imx51
lrwxrwxrwx 1 root root 19 2011-02-04 06:39 uImage -> uImage-744-g27fdf7b
-rw-r--r-- 1 root root 2967484 2011-01-28 05:29 uImage-744-g27fdf7b
lrwxrwxrwx 1 root root 20 2011-02-04 06:39 vmlinux -> vmlinux-744-g27fdfb
-rwxr-xr-x 1 root root 10951462 2011-01-28 05:29 vmlinux-744-g27fdf7b
lrwxrwxrwx 1 root root 24 2011-02-04 06:39 vmlinuz -> vmlinuz-2.6.31-6071
-rw-r--r-- 1 root root 3104896 2010-04-27 23:15 vmlinuz-2.6.31-607-imx51
lrwxrwxrwx 1 root root 19 2011-02-04 06:39 zImage -> zImage-744-g27fdf7b
-rwxr-xr-x 1 root root 2967420 2011-01-28 05:29 zImage-744-g27fdf7b 

 

Should i just change the soft-link to point my new images files, will it work?

0 Kudos