I have install modify kernel in my dns-320 and it working well.
Tell me step for step u need help with.
I can also give u access to my DNS-320
I do not have anything value on it yet.
if u mail me private at magnus at greatlord dot com I can give u
access to it.
Dlink have release the source code for DNS-320 as well
the kernel config is call DNS323D1
2011/4/25 Joao Cardoso <whoami...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "Alt-F" group.
> To post to this group, send email to al...@googlegroups.com.
> To unsubscribe from this group, send email to alt-f+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/alt-f?hl=en.
>
>
> The modified kernel was a recompilation of the dlink published kernel
> source code?
Yes
>With what modifications?
I need it usb support for some usb hardware (3G USB modem, few other thing)
>Are they publicly available?
The kernel I did build with my changes no. But how I did it, yes I did
add my build script at http://wiki.dns323.info/dns-320
> Most likely (99.9% sure) a serial port will be needed, do you have
> one?
No
I have flash in no modify kernel now in dns320 version 1.0
Dlink orignal firmware.
Yes I want try out alt-f on my dnlink dns-320, and I do not care about
the fan and tempatrure now
under devloping of alt-f to dns-320
This is what I getting from standard dlink dns-320 firmware without
custom settings.
/ # dmesg
Linux version 2.6.22.18 (wyc@SWTEST3) (gcc version 4.2.1) #22 Mon Aug
30 19:09:34 CST 2010
CPU: ARM926EJ-S [56251311] revision 1 (ARMv5TE), cr=00053977
Machine: Feroceon-KW
Using UBoot passing parameters structure
Memory policy: ECC disabled, Data cache writeback
On node 0 totalpages: 32768
DMA zone: 256 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 32512 pages, LIFO batch:7
Normal zone: 0 pages used for memmap
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 4, 32 byte lines, 128 sets
CPU0: D cache: 16384 bytes, associativity 4, 32 byte lines, 128 sets
Built 1 zonelists. Total pages: 32512
Kernel command line: root=/dev/ram console=ttyS0,115200 :::DB88FXX81:egiga0:none
PID hash table entries: 512 (order: 9, 2048 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB 0MB 0MB 0MB = 128MB total
Memory: 123776KB available (4028K code, 246K data, 124K init)
Calibrating delay loop... 796.26 BogoMIPS (lpj=3981312)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
CPU Interface
-------------
SDRAM_CS0 ....base 00000000, size 128MB
SDRAM_CS1 ....disable
SDRAM_CS2 ....disable
SDRAM_CS3 ....disable
PEX0_MEM ....base e8000000, size 128MB
PEX0_IO ....base f2000000, size 1MB
INTER_REGS ....base f1000000, size 1MB
NFLASH_CS ....base fa000000, size 2MB
SPI_CS ....base f4000000, size 16MB
BOOT_ROM_CS ....no such
DEV_BOOTCS ....no such
CRYPT_ENG ....base f0000000, size 2MB
Marvell Development Board (LSP Version KW_LSP_4.3.4_patch30)--
DB-88F6281A-BP Soc: 88F6281 A1 LE
Detected Tclk 166666667 and SysClk 200000000
MV Buttons Device Load
Marvell USB EHCI Host controller #0: c0fb3600
PEX0 interface detected no Link.
PCI: bus0: Fast back to back transfers enabled
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
Time: kw_clocksource clocksource has been installed.
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd
Freeing initrd memory: 1594K
cpufreq: Init kirkwood cpufreq driver
cpufreq: High frequency: 800000KHz - Low frequency: 200000KHz
cpufreq: Setting CPU Frequency to 800000 KHz
cpufreq: Setting PowerSaveState to off
XOR registered 1 NET_DMA over 4 channels
XOR 2nd invalidate WA enabled
cesadev_init(c00119d8)
mvCesaInit: sessions=640, queue=64, pSram=f0000000
Warning: TS unit is powered off.
MV Buttons Driver Load
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
squashfs: version 3.3 (2007/10/31) Phillip Lougher
squashfs: LZMA suppport for slax.org by jro
Installing knfsd (copyright (C) 1996 ok...@monad.swb.de).
JFFS2 version 2.2. (NAND) é 2001-2006 Red Hat, Inc.
SGI XFS with large block numbers, no debug enabled
io scheduler noop registered
io scheduler anticipatory registered (default)
Serial: 8250/16550 driver $Revision: 1.7 $ 4 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0xf1012000 (irq = 33) is a 16550A
serial8250.0: ttyS1 at MMIO 0xf1012100 (irq = 34) is a 16550A
RAMDISK driver initialized: 16 RAM disks of 10240K size 1024 blocksize
loop: module loaded
Loading Marvell Ethernet Driver:
o Cached descriptors in DRAM
o DRAM SW cache-coherency
o Single RX Queue support - ETH_DEF_RXQ=0
o Single TX Queue support - ETH_DEF_TXQ=0
o TCP segmentation offload enabled
o LRO support supported
o Receive checksum offload enabled
o Transmit checksum offload enabled
o Network Fast Processing (Routing) supported
o Driver ERROR statistics enabled
o Driver INFO statistics enabled
o Proc tool API enabled
o SKB Reuse supported
o SKB Recycle supported
o Rx descripors: q0=128
o Tx descripors: q0=532
o Loading network interface(s):
o register under egiga0 platform
o egiga0, ifindex = 1, GbE port = 0
Warning: Giga 1 is Powered Off
mvFpRuleDb (c7d5d000): 1024 entries, 4096 bytes
Integrated Sata device found
scsi0 : Marvell SCSI to SATA adapter
scsi1 : Marvell SCSI to SATA adapter
scsi 1:0:0:0: Direct-Access WDC WD15EADS-00P8B0 01.0 PQ: 0 ANSI: 5
scsi 1:0:0:0: Attached scsi generic sg0 type 0
NFTL driver: nftlcore.c $Revision: 1.1.1.1 $, nftlmount.c $Revision: 1.1.1.1 $
NAND device: Manufacturer ID: 0xec, Chip ID: 0xf1 (Samsung NAND 128MiB
3,3V 8-bit)
Scanning device for bad blocks
Using static partition definition
Creating 6 MTD partitions on "nand_mtd":
0x00000000-0x00100000 : "u-boot"
0x00100000-0x00600000 : "uImage"
0x00600000-0x00b00000 : "ramdisk"
0x00b00000-0x07100000 : "image"
0x07100000-0x07b00000 : "mini firmware"
0x07b00000-0x08000000 : "config"
ehci_marvell ehci_marvell.70059: Marvell Orion EHCI
ehci_marvell ehci_marvell.70059: new USB bus registered, assigned bus number 1
ehci_marvell ehci_marvell.70059: irq 19, io base 0xf1050100
ehci_marvell ehci_marvell.70059: USB 2.0 started, EHCI 1.00, driver 10 Dec 2004
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
ohci_hcd: 2006 August 04 USB 1.1 'Open' Host Controller (OHCI) Driver
USB Universal Host Controller Interface driver v3.0
mice: PS/2 mouse device common for all mice
i2c /dev entries driver
md: linear personality registered for level -1
md: raid0 personality registered for level 0
md: raid1 personality registered for level 1
device-mapper: ioctl: 4.11.0-ioctl (2006-10-12) initialised: dm-d...@redhat.com
dm_crypt using the OCF package.
cpufreq: Setting CPU Frequency to 800000 KHz
cpufreq: Setting PowerSaveState to off
usb 1-1: new full speed USB device using ehci_marvell and address 2
usb 1-1: configuration #1 chosen from 1 choice
usbcore: registered new interface driver usbhid
drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
RAMDISK: Compressed image found at block 0
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem).
Freeing init memory: 124K
sd 1:0:0:0: [sda] 2930277168 512-byte hardware sectors (1500302 MB)
sd 1:0:0:0: [sda] Write Protect is off
sd 1:0:0:0: [sda] Mode Sense: 23 00 10 00
sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports
DPO and FUA
sd 1:0:0:0: [sda] 2930277168 512-byte hardware sectors (1500302 MB)
sd 1:0:0:0: [sda] Write Protect is off
sd 1:0:0:0: [sda] Mode Sense: 23 00 10 00
sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports
DPO and FUA
sda: sda1 sda2 sda4
sd 1:0:0:0: [sda] Attached SCSI disk
usbcore: registered new interface driver usblp
drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver
egiga0: mac address changed
egiga0: link up, full duplex, speed 100 Mbps
egiga0: started
kjournald starting. Commit interval 5 seconds
EXT3 FS on sda4, internal journal
EXT3-fs: mounted filesystem with ordered data mode.
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
kjournald starting. Commit interval 5 seconds
EXT3 FS on sda2, internal journal
EXT3-fs: recovery complete.
EXT3-fs: mounted filesystem with ordered data mode.
md: md0 stopped.
md: bind<sda1>
raid1: raid set md0 active with 1 out of 2 mirrors
Adding 530040k swap on /dev/md0. Priority:-1 extents:1 across:530040k
NTFS driver 2.1.28 [Flags: R/O MODULE].
usbcore: deregistering interface driver usb-storage
/ # uname -a
Linux dlink-FFAFAB 2.6.22.18 #22 Mon Aug 30 19:09:34 CST 2010 armv5tejl unknown
/ # cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 "u-boot"
mtd1: 00500000 00020000 "uImage"
mtd2: 00500000 00020000 "ramdisk"
mtd3: 06600000 00020000 "image"
mtd4: 00a00000 00020000 "mini firmware"
mtd5: 00500000 00020000 "config"
/ # cat /proc/cpuinfo
Processor : ARM926EJ-S rev 1 (v5l)
BogoMIPS : 796.26
Features : swp half thumb fastmult edsp
CPU implementer : 0x56
CPU architecture: 5TE
CPU variant : 0x2
CPU part : 0x131
CPU revision : 1
Cache type : write-back
Cache clean : cp15 c7 ops
Cache lockdown : format C
Cache format : Harvard
I size : 16384
I assoc : 4
I line length : 32
I sets : 128
D size : 16384
D assoc : 4
D line length : 32
D sets : 128
Hardware : Feroceon-KW
Revision : 0000
Serial : 0000000000000000
/ # gunzip -c /proc/config.gz
gunzip: /proc/config.gz: No such file or directory
2011/4/26 Joao Cardoso <whoami...@gmail.com>:
root@dlink-FFAFAB:/# modinfo /mnt/HD/HD_a2/usblp.ko
filename: /mnt/HD/HD_a2/usblp.ko
license: GPL
description: USB Printer Device Class driver
author: Michael Gee, Pavel Machek, Vojtech Pavlik, Randy
Dunlap, Pete Zaitcev, David Paschal
alias: usb:v04B8p0202d*dc*dsc*dp*ic*isc*ip*
alias: usb:v*p*d*dc*dsc*dp*ic07isc01ip03*
alias: usb:v*p*d*dc*dsc*dp*ic07isc01ip02*
alias: usb:v*p*d*dc*dsc*dp*ic07isc01ip01*
alias: usb:v*p*d*dc07dsc01dp03ic*isc*ip*
alias: usb:v*p*d*dc07dsc01dp02ic*isc*ip*
alias: usb:v*p*d*dc07dsc01dp01ic*isc*ip*
depends:
vermagic: 2.6.22.18 mod_unload ARMv5
parm: proto_bias:Favourite protocol number (int)
root@dlink-FFAFAB:/#
I will build serial port cable for DNS-320, But I do not known when I
get time buying the part I need.
Next Issue is the build of alt-f did not run out of the box,
the mklibs 0.1.31 does not longer exists at debian ftp I did change
mkprepare.sh so it
did download it from
https://launchpad.net/ubuntu/+archive/primary/+files/mklibs_0.1.31.tar.gz
I am building the firmware on my dns-320 now inside chrooted debian.
I will let u known how it goes. can u tell me how to reload the alt-f
without flashing it ?
test se if it works without flashing it ?
2011/4/27 Joao Cardoso <whoami...@gmail.com>:
2011/4/28 Magnus Olsen <olsen....@gmail.com>:
Attached is a reloaded-2.6.22.18.ko kernel module that should enable reloading
any kernels/initrd (not only Alt-F kernel/initramfs) for the dns-320/325.
To use it, it must be loaded using 'insmod', using the arguments given by
'modinfo'
# /sbin/modinfo reloaded/alt-f/reloaded-2.6.22.18.ko filename:
reloaded/alt-f/reloaded-2.6.22.18.ko
license: GPL
depends:
vermagic: 2.6.22.18 mod_unload ARMv5
parm: kernel:Kernel image file (string)
parm: initrd:initrd file (string)
parm: cmdline:Kernel command line (string)
parm: machtype:Machine type (see linux/arch/arm/tools/mach-types)
(int)
Alt-F fun_plug uses it at its end like this:
insmod reloaded-$KV.ko machtype=$machtype kernel=$kernel initrd=$initrd
cmdline=\"$cmdline\"
You have to research to find the correct machtype id.
The execution of the module loads the new kernel without any cleanup of the
currently running kernel, so most of the work done by fun_plug is to stop
running processes in order to free memory, unmount (or mount read-only) all
mounted filesystems.
So, if not using a serial-rs232 connection, you will be disconnected from the
box and will not see the kernel booting errors.
Don't use this with disks with valuable data on them!
> I will build serial port cable for DNS-320, But I do not known when I
> get time buying the part I need.
>
> Next Issue is the build of alt-f did not run out of the box,
> the mklibs 0.1.31 does not longer exists at debian ftp I did change
> mkprepare.sh so it
> did download it from
> https://launchpad.net/ubuntu/+archive/primary/+files/mklibs_0.1.31.tar.gz
Currently mklibs is not used at all, you can replace 0.1.31 by 0.1.32 or just
comment/remove the relevant building code.
> I am building the firmware on my dns-320 now inside chrooted debian.
You mean you don't have a linux box? It will be veeery slooow... better for
you to install a virtual machine on your OS and install a linux distro on it.
> I will let u known how it goes. can u tell me how to reload the alt-f
> without flashing it ?
See above, just 'insmod' the kernel module, no flashing is involved.
BTW, 2.6.22 has kexec support, which is much more reliable than "reloading".
To use kexec you need to compile kexec-tools for the target (dns-320) and
enable kexec support from the running kernel. Alt-F have kexec enabled and
kexec-tools built-in.
> test se if it works without flashing it ?
if you just execute 'insmod reloaded-2.6.22.18.lo' either you get an error,
and that is probably my fault building the module, or your box will freeze,
meaning that the modules was correctly loaded and executed (but without the
correct arguments it will fail)
> Hi I found this
> http://packages.debian.org/en/squeeze/linux-image-2.6.32-5-kirkwood
> it seam debian have a linux kernel for kirkwood
Debian has it all :)
But the kernel is highly modularized and does not runs from flash.
I believe that Dwight Hubbard had success reloading Debian directly (from
disk), take a look at posts from "dhub" at
http://forum.dsmg600.info/viewforum.php?id=3
2011/4/28 Joao Cardoso <whoami...@gmail.com>:
On Sunday, June 19, 2011 00:23:04 Antonıo wrote:
> Unfortunately the kernel does not have kexec support built in.
> One possibility would be flashing a modified kernel with kexec
> support; I built one with the DLink devel environment, but As the risk
> of bricking the device is high, I would like to test the new kernel
> before flashing it; however, for some reason I haven't been able to
> interrupt the U-Boot boot sequence from the console.
Have you tried the dns323 procedure?
http://wiki.dns323.info/howto:uboot
Type the two keys SPACE and 1 before the monitor 3 second timeout.
Can you open a login sh using the serial console? In the dns323, it works by typing at the serial connection to get shell acess:
5784468
All this was discovered reading the DLink delivered/modified GPL sources (uboot and busybox)
I remember to read somewhere that not all DNS models enable uboot access, e.g., the dns323-revC1 hardware seems to not support it.
> BTW, I paste below the initial boot messages for reference (this is
> from a DNS320 with firmware 2.0.).
Can you put it in the 320 wiki? perhaps togetther with dmesg output? http://wiki.dns323.info/dns-320
Good it is working now. Can we expect a kexec enabled kernel?
Just to rule things out, do you mind to try the attached
reloaded-2.6.22.18.ko?
It is the result of compiling fonz's original dns323-reloaded-0.7.167, in
contrary to the previously posted one, which has some patches applied.
If it still does not works, then you could add in the wiki that fonz's
"reloaded" modules does not work in the box, saving other people time and
distress. (and if it works, saying people how to use it, mainly the mach id to
use)
Linux version 2.6.39.3 (antonio@othello64) (gcc version 4.5.2
(Ubuntu/Linaro 4.5.2-8ubuntu3) ) #4 Wed Jul 20 00:20:46 CEST 2011
> The kernel configuration was based on the kirkwood_defconfig one?
> Significative changes made? Can you post it?
I started from it, and configured extra options with a 'make
oldconfig'. Today I changed a few more options to include things that
were left out (like the rtc clock and the xor engine). I attach the
.config to this message.
>
> You can only boot it from u-boot? Not from the command line?
I haven't tried to 'reload' it. So far, I boot it from HD with uBoot,
by setting mainlineLinux=yes and arcNumber=1680.
> Now that you have a working kernel you could try to compile
> "reloaded" as an external module? So that other people without a
> serial connection could use it.
Will try. However, I am facing a rather annoying problem: the vanilla
kernel behaves like uBoot: it only recognises one of the disks. Both
sata interfaces are detected, but then it gives the following message:
ata2: SATA link down (SStatus 0 SControl F300)
> And about leds and buttons? Do you have any info about them?
Not (yet).
> I have a 100� donation, I'm considering if I would buy a dns-321 or
> raise more funds and buy a 320/325 instead. What people think that
> would be more useful?
I vote for a 320/325 (surprise!) :-)
a friend of mine just got a DNS-320, so i wanted to ask if you made
any progress with an alternative firmware for it :)
Thanks, and have a nice day,
Michael
2011/7/20 Antonio Schifano <antonio....@gmail.com>:
> On 19/07/11 15:56, Joao Cardoso wrote:
>>
>> Good news!
>>
>> What cross-toolchain have you used?
>
> I have used the ubuntu/linaro toolchain; from dmesg:
>
> Linux version 2.6.39.3 (antonio@othello64) (gcc version 4.5.2 (Ubuntu/Linaro
> 4.5.2-8ubuntu3) ) #4 Wed Jul 20 00:20:46 CEST 2011
>
>
>> The kernel configuration was based on the kirkwood_defconfig one?
>> Significative changes made? Can you post it?
>
> I started from it, and configured extra options with a 'make oldconfig'.
> Today I changed a few more options to include things that were left out
> (like the rtc clock and the xor engine). I attach the .config to this
> message.
>>
>> You can only boot it from u-boot? Not from the command line?
>
> I haven't tried to 'reload' it. So far, I boot it from HD with uBoot, by
> setting mainlineLinux=yes and arcNumber=1680.
>>
>> Now that you have a working kernel you could try to compile "reloaded" as
>> an external module? So that other people without a serial connection could
>> use it.
>
> Will try. However, I am facing a rather annoying problem: the vanilla kernel
> behaves like uBoot: it only recognises one of the disks. Both sata
> interfaces are detected, but then it gives the following message:
>
> ata2: SATA link down (SStatus 0 SControl F300)
>
>> And about leds and buttons? Do you have any info about them?
>
> Not (yet).
>>
>> I have a 100€ donation, I'm considering if I would buy a dns-321 or raise
>> more funds and buy a 320/325 instead. What people think that would be more
>> useful?
>
> I vote for a 320/325 (surprise!) :-)
>
Here is my plan
1. Figout the firmware header and how it is made by merge (DONE)
2. Compare Linux kernel source code againts DNS320 kernel code (in progress)
3. Create patch for offical linux kernel againts dlink 320 kernel code (todo)
4. Try load new kernel in dlink320 (todo)
5. Release the patch if anyone have been created.
Here is my program for extract, show contain, merge firmware,
we do not need to use dlink own merge program for dns320 any longer,
I have not tested -m option yet it should work.
all other option haven been tested by me.
-x
-cmp
-mf
-s
#include <stdio.h>
#include <stdlib.h>
#define UINT32 unsigned int
#define BYTE unsigned char
#define ALGIN4(_x) (_x + (4 - (_x % 4)))
typedef struct {
/* 0x00 - 0x03 */ UINT32 uImageOffset;
/* 0x04 - 0x07 */ UINT32 uImageLenght;
/* 0x08 - 0x0B */ UINT32 uRamDiskOffset;
/* 0x0C - 0x0F */ UINT32 uRamDiskLenght;
/* 0x10 - 0x13 */ UINT32 ImageOffset;
/* 0x14 - 0x17 */ UINT32 ImageLenght;
/* 0x18 - 0x1B */ UINT32 DefaultOffset;
/* 0x1C - 0x1F */ UINT32 DefaultLenght;
/* 0x20 - 0x23 */ UINT32 uImageChecksum;
/* 0x24 - 0x27 */ UINT32 uRamDiskChecksum;
/* 0x28 - 0x2B */ UINT32 ImageChecksum;
/* 0x2C - 0x2F */ UINT32 DefaultChecksum;
/* 0x30 - 0x30 */ BYTE magic_0; // always set 0x55 same as DNS-323
/* 0x31 - 0x31 */ BYTE magic_1; // always set 0xAA same as DNS-323
/* 0x32 - 0x3A */ BYTE strModelName[9]; // always contain string
DNS323D1U with no terminateor \0 same as DNS-323
/* 0x3B - 0x3B */ BYTE magic_2; // always set 0xAA same as DNS-323
/* 0x3C - 0x3C */ BYTE productId; // always set 0x00 same as DNS-323
/* 0x3D - 0x3D */ BYTE customId; // always set 0x08
/* 0x3E - 0x3E */ BYTE modelId; // always set 0x07
/* 0x3F - 0x3F */ BYTE hardwareId; // always set 0x01
/* 0x40 - 0x40 */ BYTE subId; // always set 0x00
/* 0x41 - 0x7B */ BYTE Reseverd[59]; // not in use
/* 0x7C - 0x7F */ UINT32 NextOffset; // next offset;
} DLINK_DNS320_FIRMWARE_HEAD_128BYTE;
void showFirmware(char *flashfilename, int extract_frimware, char
*kernelfilename, char *ramdiskfilename, char *imagefilename, char *
configfilename );
int pack_firmware(char *flashfilename, char *kernelfilename, char
*ramdiskfilename, char *imagefilename, char * configfilename );
void firmware_unpack_extract(char *inFileName, char *outFileName,
UINT32 inFileOffset, UINT32 dataLenght);
UINT32 firmware_calc_checksum(char *inFileName);
int calc_checksum(char *filename);
int check_size(char *filename, UINT32 *file_size, UINT32 max_size);
char * strtolower(const char *ret);
int compare(char *filename1, char *filename2);
char *strtolower(const char *ret)
{
char *s = ret;
for ( s = ret;*s != 0; s++)
{
if (*s != 0)
{ *s = tolower(*s); }
}
return ret;
}
int main(int argc, char **argv)
{
int showHelp = 1;
if (argc == 3)
{
strtolower(argv[1]);
if ( strcmp("-s",argv[1]) == 0)
{ showFirmware(argv[2], 0, "", "", "", "" ); showHelp--; }
if ( strcmp("-x",argv[1]) == 0)
{ showFirmware(argv[2], 1, "uImage", "uRamDisk", "image.cfs",
"default.tar.gz" ); showHelp--; }
if ( strcmp("-mf",argv[1]) == 0)
{ pack_firmware(argv[2],"uImage", "uRamDisk", "image.cfs",
"default.tar.gz"); showHelp--; }
}
if (argc == 4)
{
strtolower(argv[1]);
if ( strcmp("-cmp",argv[1]) == 0)
{ compare(argv[2], argv[3]); showHelp--; }
}
if (argc == 8)
{
strtolower(argv[1]);
if ( strcmp("-m",argv[1]) == 0)
{
strtolower(argv[6]);
if ( strcmp("-f",argv[6]) == 0)
{ pack_firmware(argv[7],argv[2], argv[3], argv[4],
argv[5]); showHelp--; }
}
if ( strcmp("-x",argv[1]) == 0)
{
strtolower(argv[3]);
if ( strcmp("-o",argv[3]) == 0)
{ showFirmware(argv[2], 1, argv[4], argv[5], argv[6],
argv[7] ); showHelp--; }
}
}
if (showHelp)
{
printf("Copyright 2011 by Magnus Olsen (mag...@greatlord.com)\n");
printf("This program are under licen GPL 2.0\n\n");
printf("Merge kernel (uImage) + ramdisk (uRamDisk) + image
(image.cfs) and\nconfig (default.tar.gz) to a flash image for dlink
DNS320\n\n");
printf("dns320flash -m kernel ramdisk image config -f
dlink320firmware\n\n\n");
printf("dns320flash -mf dlink320firmware dlink320firmware\n\n\n");
printf("Extract flash image to kernel (uImage) + ramdisk
(uRamDisk) + \nimage (image.cfs) and config (default.tar.gz) for dlink
DNS320\n\n");
printf("dns320flash -x dlink320firmware -o kernel ramdisk
image config\n");
printf("dns320flash -x dlink320firmware \n\n\n");
printf("Show flash image contains for dlink DNS320\n\n");
printf("dns320flash -s dlink320firmware\n\n\n");
}
return 0;
}
void showFirmware(char *flashfilename, int extract_frimware, char
*kernelfilename, char *ramdiskfilename, char *imagefilename, char *
configfilename )
{
int read_byte;
FILE *fp;
char str[10];
DLINK_DNS320_FIRMWARE_HEAD_128BYTE dnsHeader;
fp = fopen(flashfilename,"rb");
if (fp)
{
memset( &dnsHeader,0,sizeof(DLINK_DNS320_FIRMWARE_HEAD_128BYTE));
read_byte = fread(&dnsHeader, 1,
sizeof(DLINK_DNS320_FIRMWARE_HEAD_128BYTE),fp);
fclose(fp);
if (read_byte != sizeof(DLINK_DNS320_FIRMWARE_HEAD_128BYTE))
{
printf("not vaild firmware for DNS320");
exit(0);
}
memcpy(&str,dnsHeader.strModelName,9);
str[9] = 0;
if ( (dnsHeader.magic_0 != 0x55) ||
(dnsHeader.magic_1 != 0xAA) ||
(dnsHeader.magic_2 != 0xAA) ||
(dnsHeader.productId != 0x00) ||
(dnsHeader.customId != 0x08) ||
(dnsHeader.modelId != 0x07) ||
(dnsHeader.hardwareId != 0x01) ||
(dnsHeader.subId != 0x00) ||
(strcmp(str,"DNS323D1U") != 0) )
{
printf("not vaild firmware for DNS320");
exit(0);
}
printf("magic_0 : %02x\n",dnsHeader.magic_0);
printf("magic_1 : %02x\n",dnsHeader.magic_1);
printf("string : %s\n",str);
printf("magic_2 : %02x\n",dnsHeader.magic_2);
printf("productId : %02x\n",dnsHeader.productId);
printf("customId : %02x\n",dnsHeader.customId);
printf("modelId : %02x\n",dnsHeader.modelId);
printf("hardwareId : %02x\n",dnsHeader.hardwareId);
printf("subId : %02x\n",dnsHeader.subId);
printf("Next_offset : %08x\n\n",dnsHeader.NextOffset);
printf("Kernel (uImage) Offset head : %08x\n",dnsHeader.uImageOffset);
printf("Kernel (uImage) Lenght head : %08x\n",dnsHeader.uImageLenght);
printf("Kernel (uImage) Checksum head :
%08x\n",dnsHeader.uImageChecksum);
if (extract_frimware)
{
firmware_unpack_extract(flashfilename, kernelfilename,
dnsHeader.uImageOffset, dnsHeader.uImageLenght);
printf("Kernel (uImage) Checksum file :
%08x\n\n",calc_checksum(kernelfilename));
}
else
{ printf("\n"); }
printf("uRamDisk Offset head :
%08x\n",dnsHeader.uRamDiskOffset);
printf("uRamDisk Lenght head :
%08x\n",dnsHeader.uRamDiskLenght);
printf("uRamDisk Checksum head :
%08x\n",dnsHeader.uRamDiskChecksum);
if (extract_frimware)
{
firmware_unpack_extract(flashfilename, ramdiskfilename,
dnsHeader.uRamDiskOffset, dnsHeader.uRamDiskLenght);
printf("uRamDisk Checksum file :
%08x\n\n",calc_checksum(ramdiskfilename));
}
else
{ printf("\n"); }
printf("image Offset head : %08x\n",dnsHeader.ImageOffset);
printf("image Lenght head : %08x\n",dnsHeader.ImageLenght);
printf("image Checksum head :
%08x\n",dnsHeader.ImageChecksum);
if (extract_frimware)
{
firmware_unpack_extract(flashfilename, imagefilename,
dnsHeader.ImageOffset, dnsHeader.ImageLenght);
printf("image Checksum file :
%08x\n\n",calc_checksum(imagefilename));
}
else
{ printf("\n"); }
printf("Default Offset head :
%08x\n",dnsHeader.DefaultOffset);
printf("Default Lenght head :
%08x\n",dnsHeader.DefaultLenght);
printf("Default Checksum head :
%08x\n",dnsHeader.DefaultChecksum);
if (extract_frimware)
{
firmware_unpack_extract(flashfilename, configfilename,
dnsHeader.DefaultOffset, dnsHeader.DefaultLenght);
printf("Default Checksum file :
%08x\n\n",calc_checksum(configfilename));
}
else
{ printf("\n"); }
}
}
void firmware_unpack_extract(char *inFileName, char *outFileName,
UINT32 inFileOffset, UINT32 dataLenght)
{
FILE *read_fp;
FILE *save_fp;
BYTE *ch;
UINT32 lenght = 0;
printf("Extracting %s from %s\n",outFileName, inFileName);
read_fp = fopen(inFileName,"rb");
if (read_fp)
{
fseek(read_fp,inFileOffset, SEEK_SET);
save_fp = fopen(outFileName,"wb+");
if (save_fp)
{
while(lenght<dataLenght)
{
fread(&ch,1,1,read_fp);
fwrite(&ch,1,1,save_fp);
lenght++;
}
printf("writing done\n");
fclose(save_fp);
}
fclose(read_fp);
}
}
int pack_firmware(char *flashfilename, char *kernelfilename, char
*ramdiskfilename, char *imagefilename, char * configfilename )
{
FILE *fp_read;
FILE *fp_save;
int i, kernelSize,ramdiskSize, imageSize, configSize;
UINT32 byte;
DLINK_DNS320_FIRMWARE_HEAD_128BYTE dnsHeader;
memset(&dnsHeader,0,sizeof(DLINK_DNS320_FIRMWARE_HEAD_128BYTE));
if ( check_size(kernelfilename, &dnsHeader.uImageLenght,
0x00300000) == -1)
{ return -1; }
if ( check_size(ramdiskfilename, &dnsHeader.uRamDiskLenght,
0x00300000) == -1)
{ return -1; }
if ( check_size(configfilename, &dnsHeader.DefaultLenght,
0x00300000) == -1)
{ return -1; }
if ( check_size(imagefilename, &dnsHeader.ImageLenght,
0x04000000) == -1)
{ return -1; }
// Setup header id
dnsHeader.magic_0 = 0x55;
dnsHeader.magic_1 = 0xAA;
dnsHeader.magic_2 = 0xAA;
dnsHeader.productId = 0x00;
dnsHeader.customId = 0x08;
dnsHeader.modelId = 0x07;
dnsHeader.hardwareId = 0x01;
dnsHeader.subId = 0x00;
memcpy(dnsHeader.strModelName,"DNS323D1U",9);
// Setup header checksum
dnsHeader.uImageChecksum = calc_checksum(kernelfilename);
dnsHeader.uRamDiskChecksum = calc_checksum(ramdiskfilename);
dnsHeader.DefaultChecksum = calc_checksum(configfilename);
dnsHeader.ImageChecksum = calc_checksum(imagefilename);
// Fix Algin issue for header
kernelSize = dnsHeader.uImageLenght;
ramdiskSize = dnsHeader.uRamDiskLenght;
imageSize = dnsHeader.ImageLenght;
configSize = dnsHeader.DefaultLenght;
if ((dnsHeader.uImageLenght % 4) != 0)
{ dnsHeader.uImageLenght = ALGIN4(dnsHeader.uImageLenght); }
if ((dnsHeader.uRamDiskLenght % 4) != 0)
{ dnsHeader.uRamDiskLenght = ALGIN4(dnsHeader.uRamDiskLenght); }
if ((dnsHeader.ImageLenght % 4) != 0)
{ dnsHeader.ImageLenght = ALGIN4(dnsHeader.ImageLenght); }
if ((dnsHeader.DefaultLenght % 4) != 0)
{ dnsHeader.DefaultLenght = ALGIN4(dnsHeader.DefaultLenght); }
// Setup header Offset
dnsHeader.uImageOffset = sizeof(DLINK_DNS320_FIRMWARE_HEAD_128BYTE);
dnsHeader.uRamDiskOffset =
sizeof(DLINK_DNS320_FIRMWARE_HEAD_128BYTE) + dnsHeader.uImageLenght;
dnsHeader.ImageOffset = sizeof(DLINK_DNS320_FIRMWARE_HEAD_128BYTE)
+ dnsHeader.uImageLenght + dnsHeader.uRamDiskLenght ;
dnsHeader.DefaultOffset =
sizeof(DLINK_DNS320_FIRMWARE_HEAD_128BYTE) + dnsHeader.uImageLenght +
dnsHeader.uRamDiskLenght + dnsHeader.ImageLenght ;
// print out info
printf("Kernel (uImage) Offset : %08x\n",dnsHeader.uImageOffset);
printf("Kernel (uImage) Lenght : %08x\n",dnsHeader.uImageLenght);
printf("Kernel (uImage) Checksum : %08x\n\n",dnsHeader.uImageChecksum);
printf("uRamDisk Offset : %08x\n",dnsHeader.uRamDiskOffset);
printf("uRamDisk Lenght : %08x\n",dnsHeader.uRamDiskLenght);
printf("uRamDisk Checksum : %08x\n\n",dnsHeader.uRamDiskChecksum);
printf("image Offset : %08x\n",dnsHeader.ImageOffset);
printf("image Lenght : %08x\n",dnsHeader.ImageLenght);
printf("image Checksum : %08x\n\n",dnsHeader.ImageChecksum);
printf("Default Offset : %08x\n",dnsHeader.DefaultOffset);
printf("Default Lenght : %08x\n",dnsHeader.DefaultLenght);
printf("Default Checksum : %08x\n\n",dnsHeader.DefaultChecksum);
if ( (fp_save = fopen(flashfilename,"wb+")) == 0)
{
printf("Error : Can not merge firmware\n");
return -1;
}
fwrite(&dnsHeader,1,sizeof(DLINK_DNS320_FIRMWARE_HEAD_128BYTE),fp_save);
if ( (fp_read = fopen(kernelfilename,"rb")) == 0)
{
printf("Error : Can not merge firmware\n");
return -1;
}
for(i=0;i<dnsHeader.uImageLenght/4;i++)
{
fread(&byte,1,4,fp_read);
fwrite(&byte,1,4,fp_save);
}
fclose(fp_read);
if ( (fp_read = fopen(ramdiskfilename,"rb")) == 0)
{
printf("Error : Can not merge firmware\n");
return -1;
}
for(i=0;i<dnsHeader.uRamDiskLenght/4;i++)
{
fread(&byte,1,4,fp_read);
fwrite(&byte,1,4,fp_save);
}
fclose(fp_read);
if ( (fp_read = fopen(imagefilename,"rb")) == 0)
{
printf("Error : Can not merge firmware\n");
return -1;
}
for(i=0;i<dnsHeader.ImageLenght/4;i++)
{
fread(&byte,1,4,fp_read);
fwrite(&byte,1,4,fp_save);
}
fclose(fp_read);
if ( (fp_read = fopen(configfilename,"rb")) == 0)
{
printf("Error : Can not merge firmware\n");
return -1;
}
for(i=0;i<dnsHeader.DefaultLenght/4;i++)
{
fread(&byte,1,4,fp_read);
fwrite(&byte,1,4,fp_save);
}
fclose(fp_read);
fclose(fp_save);
return 0;
}
int check_size(char *filename, UINT32 *file_size, UINT32 max_size)
{
FILE *fp_read;
if ((fp_read = fopen(filename,"rb")) )
{
fseek(fp_read,0,SEEK_END);
*file_size = ftell(fp_read);
if ( *file_size >= max_size )
{
printf("\nMake firmware error\n");
printf("Ramdisk sizes can not more than %d byte",max_size);
return -1;
}
fclose(fp_read);
}
else
{
printf("Can not open file uImage\n");
}
return 0;
}
int calc_checksum(char *filename)
{
FILE *fp_read;
UINT32 chk_sum = 0;
int byte,size,filesize;
if (!(fp_read = fopen(filename,"rb")))
{
printf("Error: Can't open %s file !\n", filename);
return 0;
}
fseek(fp_read, 0, SEEK_END);
filesize = ftell(fp_read);
fseek(fp_read, 0, SEEK_SET);
for(size=0;size<filesize;size+=4)
{
byte = 0;
fread(&byte, 1, 4, fp_read);
chk_sum ^= byte;
}
fclose(fp_read);
return chk_sum;
}
int compare(char *filename1, char *filename2)
{
FILE *fp_read1;
FILE *fp_read2;
int file1_size;
int file2_size;
int i;
if ((fp_read1 = fopen(filename1,"rb")) == 0)
{ printf("Error : Can not open file %s\n",filename1); return -1; }
if ((fp_read2 = fopen(filename2,"rb")) == 0)
{ printf("Error : Can not open file %s\n",filename2);
fclose(fp_read1); return -1; }
fseek(fp_read1,0,SEEK_END);
fseek(fp_read2,0,SEEK_END);
file1_size = ftell(fp_read1);
file2_size = ftell(fp_read2);
fseek(fp_read1,0,SEEK_SET);
fseek(fp_read2,0,SEEK_SET);
if (file1_size != file2_size)
{
printf("Error : File %s and file %s does not have same
filesize\n",filename1,filename2);
fclose(fp_read1);
fclose(fp_read2);
return -1;
}
for (i=0;i<file1_size;i++)
{
if ( fgetc(fp_read1) != fgetc(fp_read2) )
{
printf("Error : Byte are not same\n");
printf("FileOffset : %08lx\n",ftell(fp_read1));
fclose(fp_read1);
fclose(fp_read2);
return -1;
}
}
fclose(fp_read1);
fclose(fp_read2);
return 0;
}
2011/10/19 Michael Groh <schnitz...@gmail.com>:
I got lite time over and working on DNS320 again.Here is my plan
1. Figout the firmware header and how it is made by merge (DONE)
2. Compare Linux kernel source code againts DNS320 kernel code (in progress)
3. Create patch for offical linux kernel againts dlink 320 kernel code (todo)
No big progress till a couple of days ago, when Joao sent the link to
the new kernel patch for the DNS-325 that works also on the 320.
There is still an issue with the temperature sensor to be solved
though.
Sorry for the late reply, I realized only now about your message.
Best regards,
Antonio
On 19 Ott, 18:05, Michael Groh <schnitzelkuc...@gmail.com> wrote:
> Hello Antonio Schifano,
>
> a friend of mine just got a DNS-320, so i wanted to ask if you made
> any progress with an alternative firmware for it :)
>
> Thanks, and have a nice day,
>
> Michael
>
> 2011/7/20 Antonio Schifano <antonio.schif...@gmail.com>:
Can u write instal guide how u did instal arch for 320
--
You received this message because you are subscribed to the Google Groups "Alt-F" group.
To post to this group, send email to al...@googlegroups.com.
To unsubscribe from this group, send email to alt-f+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/alt-f/-/JY8oNv7i3CkJ.
For more options, visit https://groups.google.com/groups/opt_out.
Can u write instal guide how u did instal arch for 320
--
You received this message because you are subscribed to the Google Groups "Alt-F" group.
To post to this group, send email to al...@googlegroups.com.
To unsubscribe from this group, send email to alt-f+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/alt-f/-/APQhN37jGzoJ.