booting from USB
Hello List,
I'm interested in booting a linux image from a USB memory stick. I configured u-boot (version 1.1.2) to provide me with the usb commands. I try to load the image with the following commands.
usb rest
usb scan
usbboot 10000 0:1
The usbboot command ends up with
Loading from USB device 0, partition 1: Name: usbda1
Type: U-Boot
First Block: 32, # of blocks: 255456, Block Size: 512
** Bad Magic Number **
The image is the same I download with the tftp command. Should I create the image in a different way?
Thanks for your hints.
Jonas
Hallo Jonas,
Quoted 5 lines · in message <[email protected]> you wrote:
I'm interested in booting a linux image from a USB memory stick. I configured u-boot (version 1.1.2) to provide me with the usb commands. I try to load the image with the following commands.
usb rest
rest or reset?
Quoted 9 lines
usb scan
usbboot 10000 0:1The usbboot command ends up with
Loading from USB device 0, partition 1: Name: usbda1
Type: U-Boot
First Block: 32, # of blocks: 255456, Block Size: 512** Bad Magic Number **
Ummm... the number of blocks is obviously bogus - 255456 blocks is 124 MB; I don't think that's the real size of your kernel image. Probably you made some error when storing the image to the USB stick.
Quoted 2 lines
The image is the same I download with the tftp command. Should I create the image in a different way?
How did you write the image to the USB stick?
You can also try looking at the image data, something like this:
=> tft 100000 uImage
=> md 100000
=> usb read 200000 20 10
=> md 200000
Do you see any difference?
Viele Gr??e,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de It may be bad manners to talk with your mouth full, but it isn't too good either if you speak when your head is empty.
Hallo Wolfgang,
Quoted 7 lines
Quoted 4 lines
I'm interested in booting a linux image from a USB memory stick. I configured u-boot (version 1.1.2) to provide me with the usb commands. I try to load the image with the following commands.
usb restrest or reset?
reset, of course. Just a typo ;-)
Quoted 10 lines
Quoted 5 lines
Loading from USB device 0, partition 1: Name: usbda1
Type: U-Boot
First Block: 32, # of blocks: 255456, Block Size: 512** Bad Magic Number **
Ummm... the number of blocks is obviously bogus - 255456 blocks is 124 MB; I don't think that's the real size of your kernel image. Probably you made some error when storing the image to the USB stick.
Just played around with my usb stick and reduced the size of the first partition. When I now try the usbboot command the number of blocks is exact the size of the partition.
Is there a special way of creating the image or can I use the same I use with the tftp command?
Quoted 1 line
How did you write the image to the USB stick?
I tried to follow DULG -booting from IDE, Compact Flash. Maybe it was not a good idea...
Copied it from my host to the stick. This is not the proper way?
Can you tell me which fs to use? I tried it with dos.
Mit freundlichem Gru?,
Jonas
Hallo Jonas,
Quoted 4 lines · in message <[email protected]> you wrote:
Just played around with my usb stick and reduced the size of the first partition. When I now try the usbboot command the number of blocks is exact the size of the partition.
This doesn't make sense.
Quoted 2 lines
Is there a special way of creating the image or can I use the same I use with the tftp command?
You use the very same image.
Does the "usbboot" command print the image header? Does the data look correct, especially the image size?
Quoted 3 lines
Quoted 1 line
How did you write the image to the USB stick?
I tried to follow DULG -booting from IDE, Compact Flash. Maybe it was not a good idea...
Actually this should work.
Quoted 1 line
Copied it from my host to the stick. This is not the proper way?
It is.
Quoted 1 line
Can you tell me which fs to use? I tried it with dos.
DOS, VFAT and ext2 have been tested by myself; never tried reiser yet.
Try adding some debug prints to "common/cmd_usb.c"; like here:
396 hdr = (image_header_t *)addr;
397
398 if (hdr->ih_magic == IH_MAGIC) {
399 print_image_hdr (hdr);
400 cnt = (hdr->ih_size + sizeof(image_header_t));
401 cnt += info.blksz - 1;
402 cnt /= info.blksz;
403 cnt -= 1;
404 } else {
405 printf("\n** Bad Magic Number **\n");
406 return 1;
407 }Check if the value of "cnt" looks sane to you. Verify that hdr->ih_size and info.blksz hold correct values.
Best regards,
Wolfgang Denk
Signature · 3 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "I've seen it. It's rubbish." - Marvin the Paranoid Android
Hallo Wolfgang,
Quoted 8 lines
Quoted 3 lines
Just played around with my usb stick and reduced the size of the first partition. When I now try the usbboot command the number of blocks is exact the size of the partition.
This doesn't make sense.
I did the following steps:
A9M9750 # usb partprint_part of 0
Partition Map for USB device 0 -- Partition Type: DOS
Partition Start Sector Num Sectors Type
1 1 10239 83
2 10240 10240 83
3 20480 235520 83A9M9750 # usbboot 10000 0:1
Loading from USB device 0, partition 1: Name: usbda1
Type: U-Boot
First Block: 1, # of blocks: 10239, Block Size: 512
** Bad Magic Number **
Ok, let me see if the image on the stick is corrupt. I loaded it with the fatload command.
A9M9750 # fatload usb 0:1 10000 uImage
reading uImage
...............................................................................................................
1144120 bytes read
A9M9750 # bootm
## Booting image at 00010000 ...
Image Name: Linux-2.6.10-fs1
Created: 2005-02-02 13:23:01 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1144056 Bytes = 1.1 MB
Load Address: 00008000
Entry Point: 00008000
Verifying Checksum ... OKOK
And it works. Nice. But whats going/I'm doing wrong with the usbboot command?
Quoted 2 lines
Does the "usbboot" command print the image header? Does the data look correct, especially the image size?
Not at all. So
Quoted 14 lines
Try adding some debug prints to "
common/cmd_usb.c"; like here:396 hdr = (image_header_t *)addr; 397 398 if (hdr->ih_magic == IH_MAGIC) { 399 print_image_hdr (hdr); 400 cnt = (hdr->ih_size + sizeof(image_header_t)); 401 cnt += info.blksz - 1; 402 cnt /= info.blksz; 403 cnt -= 1; 404 } else { 405 printf("\n** Bad Magic Number **\n"); 406 return 1; 407 }
I put the print_image_hdr() before the if clause, but as expected I only get garbage.
Image Name:
Created: 2024-06-19 15:57:52 UTC
Image Type: Invalid CPU Invalid OS Invalid Image (uncompressed)
Data Size: 33816832 Bytes = 32.3 MB
Load Address: 020002fe
Entry Point: 27f80800Gru?,
Jonas
Hallo Jonas,
Quoted 11 lines · in message <[email protected]> you wrote:
A9M9750 # usbboot 10000 0:1
Loading from USB device 0, partition 1: Name: usbda1
Type: U-Boot
First Block: 1, # of blocks: 10239, Block Size: 512** Bad Magic Number **
Ok, let me see if the image on the stick is corrupt. I loaded it with the fatload command.
fatload? FATLOAD??? You mean you have a FAT filesystem on that partition???
Than why do you try using usbboot? usbboot like diskboot try to load an U-Boot image from a RAW partition, i. e. without any filesystem on it.
Quoted 1 line
A9M9750 # fatload usb 0:1 10000 uImage
If you have a FAT filesystem you should use fatload to load your image. If you have an ext2 filesystem you should use ext2load to load your image. If you have a foo filesystem you should use fooload to load your image.
Quoted 2 lines
And it works. Nice. But whats going/I'm doing wrong with the usbboot command?
You used the command without having a valid image IN THE RAW PARTITION.
The "First Block: 1, # of blocks: 10239, Block Size: 512" message should not be printed at all; it is actually debug code only. I'll change this in the code. I'll also make the code verify the header checksum - just relying on the magic number is probably a bit too weak.
Best regards,
Wolfgang Denk
Signature · 3 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The high cost of living hasn't affected its popularity.
Hallo Wolfgang,
Quoted 6 lines
Quoted 6 lines
A9M9750 # usbboot 10000 0:1
Loading from USB device 0, partition 1: Name: usbda1
Type: U-Boot
First Block: 1, # of blocks: 10239, Block Size: 512
Quoted 7 lines
Quoted 4 lines
** Bad Magic Number **
Ok, let me see if the image on the stick is corrupt. I loaded it with the fatload command.
fatload? FATLOAD??? You mean you have a FAT filesystem on that partition???
:-O hope you havn't got a heart attack...
Quoted 3 lines
Than why do you try using usbboot? usbboot like diskboot try to load an U-Boot image from a RAW partition, i. e. without any filesystem on it.
I thought you told me that you tested it with a FS.... Maybe I misunderstood something.
Ok, put my image to the RAW partiton and executed usbboot again. Still the same problem like above...
Copied the image into RAM with usb read (hope it is correct) and then bootm. That works.
Then I removed the "if (hdr->ih_magic == IH_MAGIC)" in common/cmd_usb.c, set cnt to a suitable value and tested usbboot again. This works, too.
Perhaps I find out how to solve that.
Thanks for your help!
Regards,
Jonas
Quoted 3 lines · In message <[email protected]> you wrote:
I thought you told me that you tested it with a FS.... Maybe I misunderstood something.
Probably.
Quoted 2 lines
Ok, put my image to the RAW partiton and executed usbboot again. Still the same problem like above...
I think you must be doing something wrong.
Which exact commands did you use to put the image into the boot partition?
Quoted 2 lines
Copied the image into RAM with usb read (hope it is correct) and then bootm. That works.
usbboot is nothing else but a clever version of usb read (which auto-determines the number of blocks to read).
Quoted 1 line
Perhaps I find out how to solve that.
If you just posted the exact commands you use, and the output you get, I had a much better chance to help you.
Best regards,
Wolfgang Denk
Signature · 4 lines
Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "The number of Unix installations has grown to 10, with more expected." - The Unix Programmer's Manual, 2nd Edition, June, 1972