LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 06-08-2011, 06:57 AM   #1
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 656

Rep: Reputation: 35
Question Why zero-pad uImage?


Hello

When compiling uClinux, I noticed that some distributions zero-pad the uImage, and I was wondering why this is needed?

FWIW, here's the output from Makefile...
Code:
./src/zeropad uClinux-dist/images/uImage uClinux-dist/images/uImage.padded 0x20000
blocksize = 131072 (0x20000)
... and the source code to zeropad.c:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[]) {
    FILE *fin, *fout;
    char *buf;
    int  n;
    int  blocksize;
   
    if (argc != 4) {
 printf("usage: %s InputFile PaddedFile BlockSize\n", argv[0]);
 exit(1);
    }

    fin = fopen(argv[1],"rb");
    if (fin == NULL) {
 printf("Error opening %s\n", argv[1]);
 exit(1);
    }
    
    fout = fopen(argv[2],"wb");
    if (fout == NULL) {
 printf("Error opening %s\n", argv[2]);
 exit(1);
    }

    blocksize = strtol(argv[3], NULL, 0);
    if (blocksize < 0) {
 printf("Error in blocksize\n");
 exit(1);
    }
    printf("blocksize = %d (0x%0x)\n", blocksize, blocksize);

    buf = (char *)malloc(blocksize);
    if (buf == NULL) {
 printf("Error in blocksize\n");
 exit(1);
    }
    memset(buf, 0, blocksize);

    while((n = fread(buf, sizeof(char), blocksize, fin))) {
 fwrite(buf, sizeof(char), blocksize, fout);
    }

    free(buf);
    fclose(fin);
    fclose(fout);
    
    return 0;
}
Thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
uImage Header Format Question gsinde Linux - Embedded & Single-board computer 3 01-12-2012 09:17 AM
Build Uimage utkarshrawat Linux - Newbie 6 03-13-2011 05:25 PM
[SOLVED] kernel panic when booting linux-2.6.30 uImage on at91rm9200ek board alexf007 Linux - Embedded & Single-board computer 4 07-21-2009 05:04 PM
Can't load UImage aemindia Linux - Kernel 1 06-16-2009 11:35 PM
u-boot and uImage.cc for LDK5910 Anitha Linux - Kernel 0 02-19-2007 10:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 06:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration