Jump to content
XPEnology Community

Kernel building


Andy928

Recommended Posts

 

Hi Andy928

 

Thanks for the sharing of this and the creation of the wiki.

 

Could really do with some help if you have a little spare time - I would like to try and combine the NIC drivers in the RS3413xs 3211 kernel with the DS3612xs 3202 kernel. Could you give me a couple of pointers - maybe step by step

 

Mucho thanko

 

Essper

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...
FYI,

 

The releases 3202 and 3211 are BINARY COMPATIBLE. Both uses the same Linux kernel for x64: 3.2.30. You can mix modules from both sources, mainly because no modifications from 3202 to 3211 in the kernel.

 

Good input! Thanks

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

Does anyone know where the sources for the different (compiled) cgi scripts are located?

 

I am trying to find out how the disks/volumes are managed and am not getting any further from the cli commands alone; so i was trying to do a top down aproach;

unfortunately i cant find the source for the cgi scripts...

 

Are those not included in the source code (and where do they come from then)?

 

Thx

Link to comment
Share on other sites

Does anyone know where the sources for the different (compiled) cgi scripts are located?

 

I am trying to find out how the disks/volumes are managed and am not getting any further from the cli commands alone; so i was trying to do a top down aproach;

unfortunately i cant find the source for the cgi scripts...

 

Are those not included in the source code (and where do they come from then)?

 

Thx

 

Synology apps managing disks are not open source :sad:

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...
  • 1 month later...

Modifying DSM 4.3 synobios.ko in Linux.

 

1. View the source code and look for the second 'ba ff ff ff ff' (25e1) in SetMicropId function using objdump.

 

# objdump -S synobios.ko | less

orig:
   25da:       e8 00 00 00 00          callq  25df 
   25df:       85 c0                   test   %eax,%eax
   25e1:       ba ff ff ff ff          mov    $0xffffffff,%edx
   25e6:       75 c4                   jne    25ac 
   25e8:       0f be 04 24             movsbl (%rsp),%eax
   25ec:       31 d2                   xor    %edx,%edx
   25ee:       89 05 00 00 00 00       mov    %eax,0x0(%rip)        # 25f4 

 

2. Replace the next entry (25e6), change it from '75 c4 0f be 04 24' to '48 31 c0 b0 42 90' using xxd.

 

# xxd -g 1 synobios.ko > synobios.hex
# sed -i 's/75 c4 0f be 04 24/48 31 c0 b0 42 90/' synobios.hex 
# xxd -r synobios.hex > synobios-edited.ko
# objdump -S synobios-edited.ko | less

edited:
   25da:       e8 00 00 00 00          callq  25df 
   25df:       85 c0                   test   %eax,%eax
   25e1:       ba ff ff ff ff          mov    $0xffffffff,%edx
   25e6:       48 31 c0                xor    %rax,%rax
   25e9:       b0 42                   mov    $0x42,%al
   25eb:       90                      nop
   25ec:       31 d2                   xor    %edx,%edx
   25ee:       89 05 00 00 00 00       mov    %eax,0x0(%rip)        # 25f4 

 

3. To disable the logging message, find '80 7c 24 17 00' (395) and replace the next entry (39a) with 'eb d4' in synobios_poll function.

 

# objdump -S synobios.ko | less

orig:
    394:       c3                      retq
    395:       80 7c 24 17 00          cmpb   $0x0,0x17(%rsp)
    39a:       74 d4                   je     370 
    39c:       be 24 02 00 00          mov    $0x224,%esi

 

# sed -i 's/80 7c 24 17 00 74 d4/80 7c 24 17 00 eb d4/' synobios.hex
# xxd -r synobios.hex > synobios-edited.ko
# objdump -S synobios-edited.ko | less

edited:
    394:       c3                      retq
    395:       80 7c 24 17 00          cmpb   $0x0,0x17(%rsp)
    39a:       eb d4                   jmp    370 
    39c:       be 24 02 00 00          mov    $0x224,%esi

Link to comment
Share on other sites

  • 1 month later...

I tried to compile 32 bit version myself by directions on this forum. I used 4.3 image bromolow (32bit) and Andys kernel from git. I just turned off x64, included VIA C7 platform, and VIA Rhine drivers in kernel, and while creating bzImage I got this error :

 

arch/x86/kernel/sys_i386_32.c: In function 'sys_SYNOmmap':
arch/x86/kernel/sys_i386_32.c:51: error: implicit declaration of function 'sys_mmap2'
make[2]: *** [arch/x86/kernel/sys_i386_32.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2

Edited by Guest
Link to comment
Share on other sites

Did you get synogpl-3776-x64.tbz? Have you also tried using /source/linux-3.x/synoconfigs/x86 or /source/linux-3.x/synoconfigs/x86_64 config?

 

I used

 

gcc420_glibc236_x64-GPL.tgz (extracted to /usr/local)

 

synogpl-3776-x64.tbz (extracted to /usr/local/x86_64-linux-gnu/)

 

andys kernel from github

 

Used menuconfig , turned off x64, used VIA C7 platform and Centaur support, and included VIA Rhine drivers.

Can you explain those synoconfigs with more details ?

 

After menuconfig, and modules building.

 

m4dm4n@m4dm4n-virtual-machine /usr/local/linux-3.x $ sudo make ARCH=x86 CROSS_COMPILE=/usr/local/x86_64-linux-gnu/bin/x86_64-linux-gnu- bzImage
 CHK     include/linux/version.h
 CHK     include/generated/utsrelease.h
 CALL    scripts/checksyscalls.sh
 CHK     include/generated/compile.h
 CC      arch/x86/kernel/sys_i386_32.o
arch/x86/kernel/sys_i386_32.c: In function 'sys_SYNOmmap':
arch/x86/kernel/sys_i386_32.c:51: error: implicit declaration of function 'sys_mmap2'
make[2]: *** [arch/x86/kernel/sys_i386_32.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2

Link to comment
Share on other sites

Well, it's not easy if you haven't tried to compile your own kernel from Linux distribution. Once you know how to do it, then you can try again. Aside from Andy's original patch, you still need to figure out how to detect/enable drives that are not fully supported by DSM. I spent a week or two before having a working kernel, and it was built from scratch including Andy's patch which I ported from 4.1 to 4.3 kernel. I've even have to learn how to use synology toolkit to make my life easier. :wink: Good luck on your endeavor.

Link to comment
Share on other sites

  • 3 weeks later...

This patch works well with dsgpl-4.3 source code. It also works with dsgpl-5.0 source code but you have to manually edit the relevant files. Go start build your own kernel and if ever you give back to this community. You can't please everyone, some of them are blood sucking leeches!

--- drivers/ata/libata-core.c.orig	2014-01-06 02:42:49.946152467 +0800
+++ drivers/ata/libata-core.c	2014-01-06 02:51:38.822224108 +0800
@@ -7359,7 +7359,7 @@
EXPORT_SYMBOL(funcSYNOSendDiskPortDisEvent);
#endif /* MY_ABC_HERE */

-#ifdef MY_DEF_HERE
+#if (defined(MY_DEF_HERE) || defined(XPENOLOGY))
int (*funcSYNOSendEboxRefreshEvent)(int portIndex) = NULL;
EXPORT_SYMBOL(funcSYNOSendEboxRefreshEvent);
#endif
--- include/linux/syno_user.h.orig	2014-01-06 02:42:49.948152589 +0800
+++ include/linux/syno_user.h	2014-01-06 03:01:35.815989363 +0800
@@ -4,6 +4,11 @@
#define __SYNO_USER_H_

/**
+ * XPEnology project
+ */
+#define XPENOLOGY
+
+/**
 * Dsc: Synology multimedia server feature. For indexing video, photo,
 *      music.
 * Ref: libsynosdk, lnxnetatalk, lnxsdk, rsync, samba, smbftpd
--- kernel/sysctl.c.orig	2014-01-06 02:42:49.955153014 +0800
+++ kernel/sysctl.c	2014-01-06 02:56:38.044634463 +0800
@@ -228,7 +228,7 @@
int (*funcSYNOGetHwCapability)(CAPABILITY *) = NULL;
EXPORT_SYMBOL(funcSYNOGetHwCapability);

-#ifdef MY_DEF_HERE
+#if (defined(MY_DEF_HERE) || defined(XPENOLOGY))
EUNIT_PWRON_TYPE (*funcSynoEunitPowerctlType)(void) = NULL;
EXPORT_SYMBOL(funcSynoEunitPowerctlType);
#endif
--- drivers/ata/sata_mv.c.orig	2013-08-24 17:37:08.000000000 +0800
+++ drivers/ata/sata_mv.c	2014-01-07 17:11:57.921748538 +0800
@@ -3692,6 +3692,7 @@
/*FIXME - Too brutal and directly, should separate into levels*/
void syno_sata_mv_gpio_write(u8 blFaulty, const unsigned short hostnum)
{
+#ifndef XPENOLOGY
	struct Scsi_Host *shost = scsi_host_lookup(hostnum);
	struct ata_port *ap = NULL;
	void __iomem *host_mmio = NULL;
@@ -3724,9 +3725,10 @@

	writel(gpio_value, host_mmio + GPIO_CTL_DATA);
	scsi_host_put(shost);
-
END:
+#endif /* XPENOLOGY */
	return;
+
}
EXPORT_SYMBOL(syno_sata_mv_gpio_write);
#endif
--- drivers/pci/quirks.c.orig	2014-02-16 07:28:49.702724291 -0800
+++ drivers/pci/quirks.c	2014-02-16 07:30:58.599035923 -0800
@@ -618,7 +618,9 @@
         ( pin < 0 || pin >= 96 ) ||
         NULL == pValue )
    {
+#ifndef XPENOLOGY
        printk("parameter error. gpiobase=%08X, pin=%d, pValue=%p\n", gpiobase, pin, pValue);
+#endif /* XPENOLOGY */
        goto END;
    }

--- fs/compat_ioctl.c.orig	2014-02-16 07:32:49.409608822 -0800
+++ fs/compat_ioctl.c	2014-02-16 07:34:43.256789001 -0800
@@ -1760,12 +1760,14 @@
	 sprintf(buf,"'%c'", (cmd>>_IOC_TYPESHIFT) & _IOC_TYPEMASK);
	if (!isprint(buf[1]))
		sprintf(buf, "%02x", buf[1]);
+#ifndef XPENOLOGY
	compat_printk("ioctl32(%s:%d): Unknown cmd fd(%d) "
			"cmd(%08x){t:%s;sz:%u} arg(%08x) on %s\n",
			current->comm, current->pid,
			(int)fd, (unsigned int)cmd, buf,
			(cmd >> _IOC_SIZESHIFT) & _IOC_SIZEMASK,
			(unsigned int)arg, fn);
+#endif

	if (path)
		free_page((unsigned long)path);
--- drivers/tty/vt/vt.c.orig
+++ drivers/tty/vt/vt.c
@@ -2474,7 +2474,7 @@ int vt_kmsg_redirect(int new)
		return kmsg_con;
}

-#ifndef MY_ABC_HERE
+#ifdef MY_ABC_HERE
/*
 *	Console on virtual terminal
 *
@@ -2574,7 +2574,7 @@ quit:
}
#endif

-#ifndef MY_ABC_HERE
+#ifdef MY_ABC_HERE
static struct tty_driver *vt_console_device(struct console *c, int *index)
{
	*index = c->index ? c->index-1 : fg_console;
@@ -2942,7 +2942,7 @@ static int __init con_init(void)

	console_unlock();

-#ifndef MY_ABC_HERE
+#ifdef MY_ABC_HERE
#ifdef CONFIG_VT_CONSOLE
	register_console(&vt_console_driver);
#endif
--- drivers/scsi/sd.c.orig	2014-02-15 16:28:48.148339650 -0800
+++ drivers/scsi/sd.c	2014-02-15 16:30:15.022585662 -0800
@@ -3006,6 +3006,11 @@
{
	struct scsi_device *sdp = to_scsi_device(dev);

+#ifdef XPENOLOGY
+	printk(KERN_DEBUG "%s: disk driver '%s'", __FUNCTION__,
+			sdp->host->hostt->name);
+#endif
+
	// iscsi
#ifdef MY_ABC_HERE
	if(strcmp(sdp->host->hostt->name, "iSCSI Initiator over TCP/IP") == 0){
@@ -3036,12 +3041,19 @@

	if (SYNO_PORT_TYPE_SATA == sdp->host->hostt->syno_port_type) {
		// else treat as internal disks
+		printk(KERN_DEBUG "%s: SATA syno_port_type %x\n", __FUNCTION__, 
+				sdp->host->hostt->syno_port_type);
		return SYNO_DISK_SATA;
	}
	// sas disks
	if (SYNO_PORT_TYPE_SAS == sdp->host->hostt->syno_port_type) {
+		printk(KERN_DEBUG "%s: SAS syno_port_type %x", __FUNCTION__, 
+				sdp->host->hostt->syno_port_type);
		return SYNO_DISK_SAS;
	}
+#ifdef XPENOLOGY
+	printk(KERN_DEBUG "syno_disk_type_get: Got UNKNOWN port type %x\n", sdp->host->hostt->syno_port_type);
+#endif 
	return SYNO_DISK_UNKNOWN;
}
#endif
@@ -3210,7 +3222,7 @@
#endif
		// try at most 5 times
		while (want_idx != index &&
-			(SYNO_DISK_SATA == sdkp->synodisktype) && iRetry < 15) {
+			(SYNO_DISK_SATA == sdkp->synodisktype) && iRetry < 5) {
			/* Sometimes raid is not release all scsi disk yet. Try to delay and reget */
			printk("want_idx %d index %d. delay and reget\n", want_idx, index);

@@ -3295,6 +3307,8 @@
			error = sd_format_disk_name(SYNO_SATA_DEVICE_PREFIX, index, gd->disk_name, DISK_NAME_LEN);
			break;
		case SYNO_DISK_USB:
+			error = sd_format_disk_name(SYNO_SATA_DEVICE_PREFIX, index, gd->disk_name, DISK_NAME_LEN);
+			break;
		default:
#ifdef SYNO_SAS_DISK_NAME
			if (1 == g_is_sas_model) {
@@ -3303,6 +3317,10 @@
			}
#endif
			error = sd_format_disk_name(SYNO_SATA_DEVICE_PREFIX, index, gd->disk_name, DISK_NAME_LEN);
+#ifdef XPENOLOGY
+			printk(KERN_DEBUG "sd_probe: Got UNKNOWN disk %s with index %x\n", gd->disk_name, index);
+			gd->systemDisk = 1;
+#endif
			break;
	}
#else

Link to comment
Share on other sites

  • 4 weeks later...

i have this error when i make the kernel after the "make ARCH=x86_64 CROSS_COMPILE=/usr/local/x86_64-linux-gnu/bin/x86_64-linux-gnu- menuconfig" command:

 

root@gilles-EP31-DS3L:/home/gilles/Téléchargements/linux-3.x# make
 CHK     include/linux/version.h
 CHK     include/generated/utsrelease.h
make[1]: « include/generated/mach-types.h » est à jour.
 CALL    scripts/checksyscalls.sh
 CHK     include/generated/compile.h
 CC      arch/arm/mach-armadaxp/core.o
arch/arm/mach-armadaxp/core.c: In function 'eth_init':
arch/arm/mach-armadaxp/core.c:785:9: error: 'mv88fx_neta' undeclared (first use in this function)
arch/arm/mach-armadaxp/core.c:785:9: note: each undeclared identifier is reported only once for each function it appears in
arch/arm/mach-armadaxp/core.c: At top level:
arch/arm/mach-armadaxp/core.c:1545:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
make[1]: *** [arch/arm/mach-armadaxp/core.o] Erreur 1
make: *** [arch/arm/mach-armadaxp] Erreur 2

Link to comment
Share on other sites

×
×
  • Create New...