OpenWrt Forum Archive

Topic: Tile/Tilera

The content of this topic has been archived between 15 Apr 2018 and 22 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Anyone have any experience with openwrt in architecture tile/tilera ?

Any target that i can use to test?

-
Edison

I'm also interested on install openwrt on tilera based hardware.
I try to install it on mikrotik ccr but with poor results since now.

Hi,

I'm currently trying to make Mikrotik CCR boards to work with openwrt. For now I managed to compile rootfs and kernel, and even to pass it to bootleader via network. But I don't see any output in serial console. I've been compiling vanilla 3.14.4 kernel (as vanilla 3.3.5 which is used by Mikrotik in ROS 6.12 gave constant compilation errors).

That's the only thing I get on serial console during network boot :
trying dhcp protocol... OK
resolved mac address 00:10:18:2D:CD:BB
Gateway: 192.168.88.254
transfer started .............................. transfer ok, time=0.32s
setting up elf image... OK
jumping to kernel code

Can anyone advise where the problem can be ? Any patches that are required there to work?

I suppose that the video device, specified during kernel compilation is wrong so the video output after the initial phase of boot will be redirected to something that we could not see.

Did you used "console=ttyS0" Arni ?

(Last edited by lain on 5 Jun 2014, 10:37)

I will be happy just to find a way to create the devel-login file on ccr to get root access.
Have you find a way to do that?

If I want to try, what target should I use?

I hexdump a working kernel extracted from mikrotik npk. It boots from bootp on a ccr-1036-12G-4S but obviusly it start a "normal" mikrotik services....
With hexdump i see they use console=ttyS0,115200 (if I do not wrong)

Hi lain,

I've done the same and i also can boot Mikrotik's kernel from their npk. I also included console=ttyS0,115200 as built-in command line (extracted same way as you did wink

anyways, it doesn't give any output on serial port.
Just a few minutes ago I managed to find a Mikrotik's patch for 3.3.5 kernel - so i'm trying to compile it in various configurations
providing a link here as well, may be it will help to find more than I did - http://www.mikrotik.com/download/share/ … 5_patch.gz

arni,

which toolchain you used to compile the kernel test? and the target?

efjgrub,

I've used official tilera toolchain - http://www.tilera.com/scm/
target - tilegx-unknown-linux-gnu

Thanks Arni,

I'm waiting for my CCR and soon also be able to help

Nobody will be alone anymore ;-)
We will win against ccr/mikrotik. :-)

Seriusly....

We try a lot of way to hack ccr hardware. Another way we used is to create a "forged" npk
that create /etc/devel-login file but we can't find the algorithm used for hash calculation at the end of the
package.
You can read what we done at the end of this page:
http://kingcope.wordpress.com/2013/09/0 … orruption/

(Last edited by lain on 5 Jun 2014, 17:17)

Any update from someone?

Got some updates. I can boot custom kernel on CCR, but there is no simple way to make it bootable.
The problem i have now is that there is no a single network interface found in the kernel (there is no tilegx.c driver in the patch they provide).

Mikrotik support refuses to provide the tilegx.c file (which I think violates GPL), and without this file there is no way to do any networking on the box. I tried to port this file from 3.5, but it can't find any interfaces too. Seems Mikrotik has changed behaviour of the driver, but doesn't want to show what they did there big_smile

It would be interesting to see a step-by-step guide how to make the kernel bootable.
I have tried to compile the 3.3.5 kernel (from Mikrotik) or newer 3.15 one's using the Tilera toolchain without any luck getting console feedback.
Modifying kernel options around console, uart, ... don't seem to have any effect either.

So after weeks I am still stuck at my first problem, is the kernel is even booting? I would be very happy to see some dmesg output.

ps. I can provide multiple dev-CCR's, I have no intrest at all in RouterOS hacking/modifying it (just need small bare-metal linux on these devices).

UPDATES:
I have my custom kernel running (based on 3.17.2), it has been a frustrating experience but I am very persistent if people think it cannot be done wink.

Some information:
- It looks like that Tilera run's some sort of hypervisor before you can run any kernel
- Tilera's hypervisor uses their own filesystem called hvfs, luckly it only has some very basic CRC check
- The size of our custom kernel is not a problem, it can be stripped and put in bzip2 format

The thing that still irritates me is that I needed to extract the hypervisor part out of the mikrotik software, it would be nice to get more native on the hardware (but that might depend on purchase of Tilera's MDE/ZOL).

Extracting the HV/ELF/HVFS parts:
1) Get the mikrotik kernel (I not going to help you with this part).
2) dd bs=1 count=723238 if=../kernel of=part1
3) dd bs=1 skip=3082922 if=../kernel of=part3

Create your arch/tile environment:
1) http://www.tilera.com/scm/tilegx-x86_64.tar.bz2
2) Create a file export.source (something like this):

PATH=$PATH:/:/home/thomas/TILE/tilegx-x86_64/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/thomas/TILE/tilegx-x86_64/lib:/home/thomas/TILE/tilegx-x86_64/tilegx-unknown-linux-gnu/lib/
TILERA_ROOT="/home/thomas/TILE/tilegx-x86_64"

3) Activate it:
$ source export.source

Compile the new kernel:
1) .config : http://pastebin.com/A5nz07Ne
2) make -j2 ARCH=tilegx CROSS_COMPILE=tilegx-unknown-linux-gnu- menuconfig
3) make -j2 ARCH=tilegx CROSS_COMPILE=tilegx-unknown-linux-gnu- vmlinux
4) strip it: ../../tilegx-x86_64/bin/tilegx-unknown-linux-gnu-strip vmlinux
5) compress it: bzip2 vmlinux (arch/tile has no (b)zImage concept as far I could see)

Bring everything together:
1) cat part1 > vmlinux
2) cat vmlinux.bz2 >> vmlinux
3) Include zero's, part3 needs to start at 3082922 (0x2F0AAA)
dd if=/dev/zero of=part2 bs=1 count=811217
cat part2 >> vmlinux
4) cat part3 >> vmlinux
5) check our size & if readelf gives output without any error:
$ du -b vmlinux
3084096     vmlinux
$ readelf -a ./vmlinux

First boot:
The first boot should fail with a CRC error of HVFS, looking like this:
(0,0) hv_panic: corrupt hvfs: computed CRC 0xd1d8dbae, trailer CRC 0x4b1d9ff0   

Open your hexeditor and search for the trailer CRC: F0 9F 1D 4B (reverse of 0x 4B 1D 9F F0 within the panic) and replace with the computed CRC (same method: 0xd1d8dbae becomes AE DB D8 D1)

Second boot:

Linux version 3.17.2 (thomas@desktop) (gcc version 4.4.6 (GCC) ) #1 SMP Tue Nov 11 21:07:52 CET 2014
16336MB memory available.
PERCPU: 1 64K pages/cpu @fffffff600000000 s9472 r8192 d47872
Built 2 zonelists in Zone order, mobility grouping on.  Total pages: 261152

http://pastebin.com/Zyuz7CjA


The next step is to include a cpio/xz based filesystem in the custom kernel, this way we can boot towards something like busybox and do more debugging.

Bit more automated logic:

part1: first ELF part of Mikrotik
part2.bz2: your new/custom kernel
part3: trailer hfvs/closing stuff

cat part1 > vmlinux
sizepart1=`du -b part1 | awk {'print $1'}`

cat part2.bz2 >> vmlinux
sizepart2=`du -b part2-new.bz2 | awk {'print $1'}`

part1and2size=$((sizepart1 + sizepart2))
locationpart3=$((3082922))
tofill=$((locationpart3 - part1and2size))
echo "Zero's to create: $tofill"

rm part2.bz2-to-part3-zero >/dev/null 2>&1
dd if=/dev/zero of=part2.bz2-to-part3-zero bs=1 count=$tofill >/dev/null 2>&1
cat part2.bz2-to-part3-zero >> vmlinux

cat part3 >> vmlinux
readelf -a ./vmlinux

We still need to find a way to automate the HVFS's CRC.

Seems that the network driver has some custom modifications done by Mikrotik:

$ strings tilegx.ko | grep CCR
CCR1036-12G-4S
CCR1016-12G
CCR1036-8G-2S+
CCR1009-10G
CCR1009-8G-1S-1S+
CCR1016-8G
CCR1016-8G-1S-1S+
CCR1016-12S-1S+
CCR1036-12S-1S+
CCR1009-8G-1S
CCR1072-1G-8S+
$ strings tilegx.ko | grep license
license=GPL
$ strings tilegx.ko | grep author
author=Tilera
$


This is the included kernel one:
linux-3.17.2$ grep -r Tilera ./drivers/net/ethernet/tile/tilegx.c
* Copyright 2012 Tilera Corporation. All Rights Reserved.
MODULE_AUTHOR("Tilera Corporation");
    pr_info("Tilera Network Driver\n");
linux-3.17.2$ grep -r CCR ./drivers/net/ethernet/tile/tilegx*
linux-3.17.2$

But as all devices are included in the CPU (mPIPE/SGMII/XAUI/SerDes...):
http://www.tilera.com/sites/default/fil … ILE-Gx.pdf

We should at least see some traces of it, except if it's 'blocked' in this special HV?

Looking at the network driver issue:
./arch/tile/gxio/mpipe.c
        rv = gxio_mpipe_info_enumerate_aux(context, idx, &name, &mac);

Gives back a value of -1116, it should be a positive integer when any device is found.

./arch/tile/gxio/iorpc_mpipe_info.c

int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t *context,
                                  unsigned int idx,
                                  _gxio_mpipe_link_name_t *name,
                                  _gxio_mpipe_link_mac_t *mac)
{
        int __result;
        struct enumerate_aux_param temp;
        struct enumerate_aux_param *params = &temp;

        __result =
            hv_dev_pread(context->fd, 0, (HV_VirtAddr) params, sizeof(*params),
                         (((uint64_t)idx << 32) |
                          GXIO_MPIPE_INFO_OP_ENUMERATE_AUX));

        *name = params->name;
        *mac = params->mac;

        return __result;

Does calls to the hypervisor (hv_dev_pread())

/** Read data from a hypervisor device synchronously.
*
*  This service transfers data from a hypervisor device to a memory buffer.
*  When the service returns, the data has been written from the memory buffer,
*  and the buffer will not be further modified by the driver.
*
*  No ordering is guaranteed between requests issued from different tiles.

(Last edited by thomasthomas on 12 Nov 2014, 22:19)

Hi,

I've just started working on a new project and for that it would be really nice to have a standard linux (maybe optimised and with some tools) on a CCR.

as far as I understand what you've done so far it looks really promising. But I'm not that experienced in this sort of stuff but if there's anything I could help you with let me know.

For now I'll read more into it.

This looks promising. I will have to take home a CCR from my work and try it out. bare-metal linux box on one of these would be cool. Are you getting the kernel out of the npk?

yes, following is now based on routeros 6.22 (vs 6.20 in my previous post).

$ dd bs=1 count=723238 if=kernel of=part1
$ dd bs=1 skip=3082891 if=kernel of=part3-bis

lazy-kernel-compile-script (dont forget the export.source):

linux-3.17.2$ cat ../run-compile.sh
#!/bin/sh
rm vmlinux.bz2
make -j2 ARCH=tilegx CROSS_COMPILE=tilegx-unknown-linux-gnu- vmlinux
../../tilegx-x86_64/bin/tilegx-unknown-linux-gnu-strip vmlinux
bzip2 vmlinux
du vmlinux.bz2
cp vmlinux.bz2 ../part2-new.bz2

linux-3.17.2$

lazy-generate-image-script:

$ cat generate-image.sh
#!/bin/sh
cat part1 > vmlinux
sizepart1=`du -b part1 | awk {'print $1'}`
cat part2-new.bz2 >> vmlinux
sizepart2=`du -b part2-new.bz2 | awk {'print $1'}`
part1and2size=$((sizepart1 + sizepart2))

#locationpart3=$((3082922))
locationpart3=$((3082891))
tofill=$((locationpart3 - part1and2size))
echo $tofill

rm part2.bz2-to-part3-zero
dd if=/dev/zero of=part2.bz2-to-part3-zero bs=1 count=$tofill
cat part2.bz2-to-part3-zero >> vmlinux

cat part3-bis >> vmlinux
$

Check the vmlinux with 'readelf -a' if all is successful, boot your CCR, modify the CRC and reboot into your custom kernel.

Hi thomasthomas and thanks for your posts!

However, I didn't get it: did you manage to get the MPIPE ethernet interfaces working on the CCR?
If not, I may be able to help in private, if you want to get in touch drop me a line at piguasco@gmail.com thanks smile

Hi thomasthomas,
We are excited about the prospect of installing openwrt on CCR routers. Were you able to resolve the network driver issue?

Thanks!

Hey all,

I did'nt have time to work on this due to lots of travel and other stuff in the past month, I will restart my efforts in the coming days.
First goal would be to get some (very basic) linux, this gives a starting point for more research (instead of recompiling and modifying the kernel each time).
USB seems to be similar to networking (hv), trying to find other ways of bringing IP for NFS/diskless boot (like serial? internal second port is present).

I am not a programmer, my level of C is limited to breaking/echoing things. My hope is that as soon as I have a running shell other people can help fixing/making the required kernel code.

My overall goal would be to have a custom openvswitch-style poc device that has almost no limit in flow table entries compared to existing SDN switch hardware vendors. mPIPE potentially looks good in resolving performance issues you would have on x86 style of lab equipment.