Realtime Kernel for ODROID C1/C1+

This forum is for supported devices using an ARMv7 Amlogic SoC.

Realtime Kernel for ODROID C1/C1+

Postby blackout24 » Tue Jan 12, 2016 1:08 pm


I stumbled upon a version of the C1 kernel with the Linux Realtime patchset here: ... on-github/

I tried to make a PKGBUILD for it here:

I took the linux-odroid-c1 PKGBUILD as template, changed the source, removed the .config file and replace every occurance of ARCH with rt88.

However I encountered two problems.

First I try to create the config as explained in the blog post, before building with:
make arch=ARM odroidc_rt_defconfig

I removed the line where it copies the stock ARCH kernel .config from the srcdir, but when I ran makepkg on the PKGBUILD it complained that there is no .config. I went into the src dir and ran the command in the existing source dir and used makepkg -e afterwards and it worked.

Secondly the biggest problem is that when I try to boot the kernel it panics half way through the boot process.

The kernel image and dtb seems to be loaded without problme, though. It also identifies itself as:
Linux version 3.10.80-18-rt88 (alarm@alarm2) (gcc version 5.3.0 (GCC) ) #2 SMP PREEMPT RT Tue Jan 12 12:05:31 UTC 2016

Anyone has an idea what could be the problem? Also is there an easy way to install a custom kernel next to the ARCH kernel? From what it looks like uBoot doesn't seem flexible enough. To get back to a working system I put the SD Card into my laptop and extract the uImage and dtb from the linux-odroid-c1 package from Arch Linux ARM and manually replace it with the kernel image that was installed by the rt88 kernel.

EDIT: Looks like a null pointer dereference is the problem when loading the ethernet driver. No idea why, though.
Posts: 5
Joined: Mon Dec 14, 2015 10:17 pm

Re: Realtime Kernel for ODROID C1/C1+

Postby blackout24 » Thu Jan 14, 2016 11:43 pm

I did some printk debugging and the problem seems to be in drivers/amlogic/ethernet/am_net8218.c:

Code: Select all
1351 static void mac_from_efuse_to_DEFMAC(void)
1352 {
1353     printk("Now in mac_from_efuse_to_DEFMAC()\n");
1354     unsigned char mac[6];
1355     unsigned char *efuse_mac;
1356     int i;
1358     printk("Calling aml_efuse_get_item()\n");
1359     efuse_mac = aml_efuse_get_item("mac");
1360     printk("Called aml_efuse_get_item()\n");
1361     for (i = 0; i < 6 && efuse_mac[0] != '\0' && efuse_mac[1] != '\0'; i++) {
1362         printk("Calling chartonum(), loop index: %d\n", i);
1363         mac[i] = chartonum(efuse_mac[0]) << 4 | chartonum(efuse_mac[1]);
1364         efuse_mac += 3;
1365     }
1366     printk("Made it through the for-loop\n");
1367     memcpy(DEFMAC, mac, 6);
1368     printk("Called memcpy\n");
1369     g_mac_addr_setup++;
1370 }

Called aml_efuse_get_item() is the last message that is printed, before the kernel reports the null pointer dereference.
It doesn't even seem to enter the body of the for-loop once. How could a null pointer dereference happen in the condition of the for-loop and why does the same code work on the regular kernel?

Code: Select all
[    8.104075@1] pgd = c0004000
[    8.107417@1] [00000000] *pgd=00000000

Could this help me? I managed to google what pgd is, but don't quite understand it.

EDIT: So it looks like drivers/amlogic/efuse/efuse.c has the function that returns to NULL Pointer to efuse_mac, which
is dereferenced in the for-loop condition.

Code: Select all
282  unsigned char *aml_efuse_get_item(unsigned char* key_name)
283 {
284         unsigned char *ret = 0;
285     int id;
287         if(strcmp(key_name,"mac")==0)           id = EFUSE_MAC_ID;
288         else if(strcmp(key_name,"mac_bt")==0)   id = EFUSE_MAC_BT_ID;
289         else if(strcmp(key_name,"mac_wifi")==0) id = EFUSE_MAC_WIFI_ID;
290         else if(strcmp(key_name,"usid")==0)     id = EFUSE_USID_ID;
291         else {
292                 pr_info("%s: UNKNOWN key_name\n",   __func__);
293         return 0;
294         }
296     if (id == EFUSE_MAC_ID) {
297         return aml_efuse_mac();
298     }
300         return ret;
301 }
302 EXPORT_SYMBOL(aml_efuse_get_item);

because the key_name is "mac" aml_efuse_mac is called to return the pointer, which turns out to be NULL.

Code: Select all
  245 static char *aml_efuse_mac(void)
  246 {
  247     char hwmac[20];
  248     char buf[80];
  249         char mac_mask;
  250     efuseinfo_item_t info;
  252     if (efuse_getinfo_byID(EFUSE_MAC_ID, &info) < 0)
  253         return 0;
  255     if (efuse_read_item(buf, info.data_len,
  256                 (loff_t*)&info.offset) < 0)
  257         return 0;
  259     sprintf(hwmac, "%02x:%02x:%02x:%02x:%02x:%02x",
  260             buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
  262         mac_mask = buf[3] & 0xf0;
  263         if ((0x30 == mac_mask)
  264                 || ((0xa0 <= mac_mask) && (mac_mask <= 0xc0))) {
  265                 info.data_len = 16;
  266                 info.offset = 4;
  267                 efuse_read_item(buf, info.data_len,
  268                                 (loff_t*)&info.offset);
  270                 if (0x30 == mac_mask) {
  271                         hwmac[9] = MACCHAR(buf[5]);
  272                 }
  274                 sprintf(hwmac + 10, "%c:%c%c:%c%c",
  275                         MACCHAR(buf[11]), MACCHAR(buf[12]), MACCHAR(buf[13]),
  276                         MACCHAR(buf[14]), MACCHAR(buf[15]));
  277         }
  279     return hwmac;
  280 }

Any hints?
Posts: 5
Joined: Mon Dec 14, 2015 10:17 pm

Re: Realtime Kernel for ODROID C1/C1+

Postby blackout24 » Fri Jan 15, 2016 11:25 pm

I fixed the kernel by wrapping the offending portion of the amlogic ethernet driver code in a NULL pointer guard. ... 652fe03ba8

I tried to debug why efuse_mac is set to a NULL pointer, but I it's a bit of a mystery. I updated my PKGBUILD, which now
will pull this comit and build a working realtime kernel package with "makepkg -s".

Caveat: The ethernet device seems to behave strangely with this kernel. If you ping the latency will by exactly 1000ms 99% of the time with occasional pings that only take 14ms. So you need to use USB/UART for working with the device.
Posts: 5
Joined: Mon Dec 14, 2015 10:17 pm

Re: Realtime Kernel for ODROID C1/C1+

Postby chlorisdroid » Sun Jan 24, 2016 8:22 am

Posts: 1
Joined: Sun Jan 24, 2016 8:19 am

Re: Realtime Kernel for ODROID C1/C1+

Postby madady » Wed Feb 10, 2016 1:38 pm

@blackout24. I've run into the same problem while compiling the official Odroid C1+ Kernel (followed the instructions here: ... ARM-device). No special RT patches, just a wireless module activated.

Either the problem is somewhere in the sources - although they haven't been changed in a year, or maybe gcc-5.3 causes the problem? I will see if I can compile it with GCC-4.9

For now I'm building with your patch to see if it boots.
Posts: 3
Joined: Wed Feb 10, 2016 1:31 pm

Re: Realtime Kernel for ODROID C1/C1+

Postby madady » Thu Feb 11, 2016 12:26 pm


I've recompiled the kernel with GCC-4.8 (instead of GCC-5.3) and now the newly compiled kernel has functional ethernet.
Posts: 3
Joined: Wed Feb 10, 2016 1:31 pm

Re: Realtime Kernel for ODROID C1/C1+

Postby moonman » Thu Feb 11, 2016 8:29 pm

FYI: kmihelich has a patch for this in oir official kernel: ... -odroid-c1
Pogoplug V4 | GoFlex Home | Raspberry Pi B 512 | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
[armv5] Updated U-Boot | |[armv5] How to install service | [armv5] NAND Rescue System
Posts: 3089
Joined: Sat Jan 15, 2011 3:36 am
Location: Calgary, Canada

Re: Realtime Kernel for ODROID C1/C1+

Postby madady » Fri Feb 12, 2016 7:06 am

Thanks for the patch!
Posts: 3
Joined: Wed Feb 10, 2016 1:31 pm

Return to Amlogic

Who is online

Users browsing this forum: No registered users and 1 guest