[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[openap-cvs] : openap-main/config/wl11000 build_flash.pl,NONE,1.1 rules.
From: |
David Kimdon <address@hidden> |
Subject: |
[openap-cvs] : openap-main/config/wl11000 build_flash.pl,NONE,1.1 rules.mk,1.3,1.4 |
Date: |
Fri, 09 Aug 2002 18:55:16 -0400 |
Update of /cvsroot/openap/openap-main/config/wl11000
In directory subversions:/tmp/cvs-serv9104/config/wl11000/
Modified Files:
rules.mk
Added Files:
build_flash.pl
Log Message:
board specific rules and scripts now in this directory.
--- NEW FILE ---
#!/usr/bin/perl -w
use strict;
use FileHandle;
my ($flash_size, $flash) = @ARGV;
# 2 * 1024 * 1024;
my $rootfs_dir = "./Image_final";
my $kernel = "linux";
my $kernel_img = "./$kernel/arch/i386/boot/bzImage";
my $loader_dir = "./apps/alios";
my $loader_bin = "$loader_dir/alios.bin";
my $port_speed = "4800";
# check if all the initial required files are there
my @initial_files = ($rootfs_dir,
$kernel_img,
$loader_dir,
$loader_bin
);
foreach my $file (@initial_files) {
check_file($file);
}
# create the Filesystem Image
{
exe_prn("./$kernel/scripts/cramfs/mkcramfs $rootfs_dir $flash");
}
# prepare the kernel
{
my $kernel_size = get_size_b($kernel_img);
# pad the kernel and initrd
# create the configuration blocks
# memory map of flash (1MBx8):
#
# 0xfffff +-------------+
# | bootloader | (16K)
# 0xfc000 +-------------+
# | unused | (8K) -+
# 0xfa000 +-------------+ |-- these regions will
# | unused | (8k) -+ contain persistent
# 0xf8000 +-------------+ configuration
# | | <512b pad, |
# | | kernel |
# V | justified | (~450K)
# | to top of |
# | region, |
# +-------------+
# | unused |
# / ... / (expansion space)
# | |
# +-------------+
# | ROM disk |
# ^ | justified | (~400K)
# | | from bottom |
# | | of flash |
# 0x00000 +-------------+
my $rootfs_size_b = get_size_b($flash);
my $rootfs_size_kb = int(($rootfs_size_b + 1023) / 1024);
my $kernel_pad_size = (512 - (get_size_b($kernel_img) % 512) % 512);
my $kernel_size_kb = int((get_size_b($kernel_img) + 1023) / 1024);
my $kernel_location = $flash_size - get_size_b($loader_bin) - 512 -
16*1024 - get_size_b($kernel_img) - $kernel_pad_size;
my $free = int((1023+$flash_size - 32 * 1024 - $rootfs_size_b -
get_size_b($kernel_img))/1024);
# create configuration file:
# concatenate the images
pad_file($flash, $kernel_location - get_size_b($flash));
exe_prn("cat $kernel_img >> $flash");
pad_file($flash, $kernel_pad_size);
pad_file($flash, 16*1024); # pad over the two config blocks
# example of bootargs that do ip autoconfig then mount rootfs over nfs
# "console=ttyS0,${port_speed}n8 root=/dev/nfs rw
nfsroot=192.168.0.104:/var/nfsroot/dwhedon
ip=192.168.0.58:192.168.0.104:192.168.0.1:255.255.255.0:i802ap:eth0:none" );
make_kconf_file( $flash,
$kernel_location,
"console=ttyS0,${port_speed}n8" );
pad_file($flash, 512 - (get_size_b($flash) % 512));
exe_prn("cat $loader_bin >> $flash");
print "filesystem image is $rootfs_size_kb Kb\n";
print "kernel image is $kernel_size_kb Kb\n";
print "free space in flash = $free Kb\n";
}
### (WMM) print the size of the kernel and ROM disk to the kernel:
#####################################################################
#####################################################################
#####################################################################
#####################################################################
#####################################################################
sub exe_prn {
my $command = shift(@_);
# print "$command\n";
`$command`;
}
# input file, output file, number of bytes to pad,
sub pad_file {
my ($output, $num_bytes) = @_;
my $char = pack "H2", "ff";
open(output_fh, ">>$output");
# add the byte padding
while ($num_bytes > 0) { print output_fh $char; $num_bytes--; }
close(output_fh);
return;
}
# input: file name, kernel size, kernel command line argument string:
sub make_kconf_file {
my ($output, $ksize, $kargs) = @_;
my $zero = pack "H2", "00";
# valid must be 1 byte, kaddr must be 4 bytes:
my $kaddr = pack "L", $ksize;
open output_fh, ">>$output";
print output_fh $kaddr;
# put the command line string in the file:
print output_fh $kargs;
print output_fh $zero;
close(output_fh);
return;
}
sub check_file {
my $file = shift(@_);
if (`file $file` =~ /can\'t stat/) {
print("file {$file} does not exist. exiting\n");
exit;
}
return;
}
sub get_field {
my $command = shift(@_);
my $field_num = shift(@_);
my $result = `$command | awk '{print \$$field_num}'`;
chomp $result;
if ($result eq "") { $result = 0; }
return $result;
}
# files or dir, provides overestimate
sub get_size_kb {
my $file_or_dir = shift(@_);
my $result = get_field("du -sk $file_or_dir", 1);
if ($result eq "") { $result = 0; }
return $result;
}
# files only
sub get_size_b {
my $file = shift(@_);
my $result = get_field("ls -la $file", 5);
if ($result eq "") { $result = 0; }
return $result;
}
Index: rules.mk
===================================================================
RCS file: /cvsroot/openap/openap-main/config/wl11000/rules.mk,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rules.mk 8 Aug 2002 20:47:58 -0000 1.3
+++ rules.mk 9 Aug 2002 22:55:13 -0000 1.4
@@ -1,4 +1,4 @@
-WL11000=config/wl11000
+WL11000=$(TOPDIR)/config/wl11000
rcS_FILES += $(WL11000)/S10configfs $(WL11000)/S20wireless
@@ -10,14 +10,15 @@
rcS_FILES += $(WL11000)/S40tcpip.bridge
rc1_FILES += $(WL11000)/K50tcpip.bridge
endif
+
ifeq ($(CONFIG_AP_ROUTER),y)
rcS_FILES += $(WL11000)/S40tcpip.router
rc1_FILES += $(WL11000)/K50tcpip.router
endif
-EXTRA_TARGETS += wl11000_devices
+EXTRA_IMAGE_TARGETS += wl11000_devices wl11000_image
+EXTRA_TOOLS_TARGETS += cramfsprogs
-MKNOD = /bin/mknod
sram: subdirs
$(MAKE) -C alios clean
@@ -33,6 +34,8 @@
cp flash $(IMAGE_DIR)/flash
./misc/build_flash.pl 2097152 sram # 2 * 1024 * 1024
+MKNOD = /bin/mknod
+
# FIXME : there should be a better way of creating these devices, possible
# using metafiles
wl11000_devices:
@@ -91,3 +94,14 @@
ln -s /var/etc/rw/resolv.conf $(DESTDIR)/etc/resolv.conf
ln -s /var/syslogd.socket $(DESTDIR)/dev/log
+
+
+cramfsprogs:
+ echo hi
+ $(MAKE) CC=gcc -C $(KERNEL_DIR)/scripts/cramfs/
+
+wl11000_image:
+ $(WL11000)/build_flash.pl 1048576 flash # 1024 * 1024
+ md5sum flash > flash.md5
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [openap-cvs] : openap-main/config/wl11000 build_flash.pl,NONE,1.1 rules.mk,1.3,1.4,
David Kimdon <address@hidden> <=