Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have an Aruba AP61 Wireless node that loads its firmware files in an "APBoot" format. This file is a normal boot image, but with an extra header.
This header is built using an image.h file included at the bottom of the post.
It looks fairly simple, I'm assuming I just need to generate the output from this file, append the DD-WRT image that I am trying to use, and start my debugging away.
My knowledge in Linux is an average level, and I have some programming experience, but not in C. So what I need help with are these points:
A script to "compile" this source?
Additional source to combine the header and a selected file.
A script to run the program with my selected options (maybe even filling out some of the data automaticly, such as the data size [ih_size] and image CRC [ih_hcrc]).
Help with a few of the values. Such as: ih_load and ih_ep
Any help would be GREATLY apperciated. My self and a few other folks are all in the same boat, and I will be sharing the completed work back with a few other places:
/*
* (C) Copyright 2000
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef __IMAGE_H__
#define __IMAGE_H__
/*
* Operating System Codes
*/
#define IH_OS_INVALID 0 /* Invalid OS */
#define IH_OS_OPENBSD 1 /* OpenBSD */
#define IH_OS_NETBSD 2 /* NetBSD */
#define IH_OS_FREEBSD 3 /* FreeBSD */
#define IH_OS_4_4BSD 4 /* 4.4BSD */
#define IH_OS_LINUX 5 /* Linux */
#define IH_OS_SVR4 6 /* SVR4 */
#define IH_OS_ESIX 7 /* Esix */
#define IH_OS_SOLARIS 8 /* Solaris */
#define IH_OS_IRIX 9 /* Irix */
#define IH_OS_SCO 10 /* SCO */
#define IH_OS_DELL 11 /* Dell */
#define IH_OS_NCR 12 /* NCR */
#define IH_OS_LYNXOS 13 /* LynxOS */
#define IH_OS_VXWORKS 14 /* VxWorks */
#define IH_OS_PSOS 15 /* pSOS */
#define IH_OS_QNX 16 /* QNX */
#define IH_OS_PPCBOOT 17 /* Firmware */
/*
* CPU Architecture Codes (supported by Linux)
*/
#define IH_CPU_INVALID 0 /* Invalid CPU */
#define IH_CPU_ALPHA 1 /* Alpha */
#define IH_CPU_ARM 2 /* ARM */
#define IH_CPU_I386 3 /* Intel x86 */
#define IH_CPU_IA64 4 /* IA64 */
#define IH_CPU_MIPS 5 /* MIPS */
#define IH_CPU_MIPS64 6 /* MIPS 64 Bit */
#define IH_CPU_PPC 7 /* PowerPC */
#define IH_CPU_S390 8 /* IBM S390 */
#define IH_CPU_SH 9 /* SuperH */
#define IH_CPU_SPARC 10 /* Sparc */
#define IH_CPU_SPARC64 11 /* Sparc 64 Bit */
/*
* Image Types
*
* "Standalone Programs" are directly runnable in the environment
* provided by PPCBoot; it is expected that (if they behave
* well) you can continue to work in PPCBoot after return from
* the Standalone Program.
* "OS Kernel Images" are usually images of some Embedded OS which
* will take over control completely. Usually these programs
* will install their own set of exception handlers, device
* drivers, set up the MMU, etc. - this means, that you cannot
* expect to re-enter PPCBoot except by resetting the CPU.
* "RAMDisk Images" are more or less just data blocks, and their
* parameters (address, size) are passed to an OS kernel that is
* being started.
* "Multi-File Images" contain several images, typically an OS
* (Linux) kernel image and one or more data images like
* RAMDisks. This construct is useful for instance when you want
* to boot over the network using BOOTP etc., where the boot
* server provides just a single image file, but you want to get
* for instance an OS kernel and a RAMDisk image.
*
* "Multi-File Images" start with a list of image sizes, each
* image size (in bytes) specified by an "uint32_t" in network
* byte order. This list is terminated by an "(uint32_t)0".
* Immediately after the terminating 0 follow the images, one by
* one, all aligned on "uint32_t" boundaries (size rounded up to
* a multiple of 4 bytes).
*
* "Firmware Images" are binary images containing firmware (like
* PPCBoot or FPGA images) which usually will be programmed to
* flash memory.
*
* "Script files" are command sequences that will be executed by
* PPCBoot's command interpreter; this feature is especially
* useful when you configure PPCBoot to use a real shell (hush)
* as command interpreter.
*/
#define IH_TYPE_INVALID 0 /* Invalid Image */
#define IH_TYPE_STANDALONE 1 /* Standalone Program */
#define IH_TYPE_KERNEL 2 /* OS Kernel Image */
#define IH_TYPE_RAMDISK 3 /* RAMDisk Image */
#define IH_TYPE_MULTI 4 /* Multi-File Image */
#define IH_TYPE_FIRMWARE 5 /* Firmware Image */
#define IH_TYPE_SCRIPT 6 /* Script file */
/*
* Compression Types
*/
#define IH_COMP_NONE 0 /* No Compression Used */
#define IH_COMP_GZIP 1 /* gzip Compression Used */
#define IH_COMP_BZIP2 2 /* bzip2 Compression Used */
#define IH_MAGIC 0x27051956 /* Image Magic Number */
#define IH_NMLEN 32 /* Image Name Length */
#ifdef __CYGWIN__
typedef unsigned long uint32_t;
typedef unsigned char uint8_t;
#endif /* __CYGWIN__ */
/*
* all data in network byte order (aka natural aka bigendian)
*/
typedef struct image_header {
uint32_t ih_magic; /* Image Header Magic Number */
uint32_t ih_hcrc; /* Image Header CRC Checksum */
uint32_t ih_time; /* Image Creation Timestamp */
uint32_t ih_size; /* Image Data Size */
uint32_t ih_load; /* Data Load Address */
uint32_t ih_ep; /* Entry Point Address */
uint32_t ih_dcrc; /* Image Data CRC Checksum */
uint8_t ih_os; /* Operating System */
uint8_t ih_arch; /* CPU architecture */
uint8_t ih_type; /* Image Type */
uint8_t ih_comp; /* Compression Type */
uint8_t ih_name[IH_NMLEN]; /* Image Name */
} image_header_t;
#endif /* __IMAGE_H__ */
This header is built using an image.h file included at the bottom of the post.
The file you included there is just a C header file. It is *part* of a program, or of some source code, but it is not actually "source code" itself; you cannot build (compile) anything from/with that file alone. Do you have the source-code of whatever it is that you're trying to compile? Or a link to it?
I followed the first link you provided above, to the ddwrt forum, but after having read the whole thread, I get the impression that you are talking about compiling a new firmware image for this device. If so, you need source code. The downloadable images mentioned on that other forum appear to be pre-built binary images (rom files, or firmware files) that are already built, i.e. by the manufacturer.
Writing a script, like maybe a bash script, to execute some compile commands, is not difficult, but still, we would need something to compile
Sorry if my understanding of the issue here is out of whack.. But could you give some more info about what's going on here, what the plan is?
There is a lot of code in this project that I'm not going to use. The only thing I need to do is to splice in a few bytes of data at the beginning of a file so it passes a check this application runs. I am going to look at the project again today, I was getting tiered yesterday.
I may be able to find the code that does this, maybe not. But if I can't find it, it shouldn't be much to recreate.
Read settings (via command line or settings file or even static in the script).
CRC source image.
Find source image size.
Build header.
Write header to target image.
Concatenate source image to target image.
I will do some more homework on this in a few hours.
Back to the orig. topic ... (I hope the hijack will be moved)
Quote:
Originally Posted by BloodBlight
The only thing I need to do is to splice in a few bytes of data at the beginning of a file so it passes a check this application runs.
Did it turn out that "splice" was more complicated than using cat?
Quote:
Originally Posted by BloodBlight
Read settings (via command line or settings file or even static in the script).
CRC source image.
Find source image size.
Build header.
Write header to target image.
Concatenate source image to target image.
Looks straight fwd. -- did you get it implemented? ... How?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.