Getting Linux on Mediatek?

Hello all,

I would be interested in getting Linux onto the board, to be able to use it as a lightweight desktop machine. I wonder what would be the best way to go about doing this. I have tried to load an aarch64 linux kernel and initrd into the board, via fastboot, but that did not boot. (It was a generic ArchLinux ARM image). I wonder if anyone has any tips.

I am also interested in getting the board to boot off SD, have not found a way to do that either.


I was able to run Debian with a slightly hacked vendor kernel (daniel.thompson/linux.git - Personal repo for development and upstreaming. Contains significant work on NMI/FIQ. ) but I lost interest in taking things further and never got the WiFi (probably just a firmware) or graphics (potentially very difficult) working.

Thanks, so I just compile this and I should be able to load the kernel and the debian initrd using “fastboot boot”? I presume you were unable to use the graphics drivers from Android’s linux kernel? It does not sound that promising, but it is only for a hobby project so it would be my knowledge not the time that would be an issue (I’m fresh out of undergrad so only have some theoretical knowledge, nothing too practical)

I don’t really remember. I didn’t keep great notes. I suspect I used debootstrap to generate a full Debian root filesystem and then overwrote one of the Android partitons (the 2560M by the look of it) with it.

To be honest, if you want full hardware enablement then libhybris is probably the way to go… unfortunately I don’t think there’s any documentation (I’ve heard rumours that libhybris has a useful and active IRC channel but I’ve never tried anything myself in this area).

Thanks! One more question, because I am afraid of rendering my device completely useless: do you know if I could do this using an SD card, or will this render the device in a recoverable state? I presume it would, if the other partitions are left as they are, just want to double check

I don’t know how to boot this board from SD card but I can recommend you try running though the “Board Recovery” process. If memory serves this allows you to download a special bootloader via USB that allows you to reprogram the eMMC from scratch.

Hopefully that would give you the confidence to hack on the board!

Dear kovirobi and danielt,

I’m also interested in getting Linux on the X20. Shall we team up to document the process so that the whole community can benefit from our effort?


Okay, that sounds good to me, hopefully I can be of some help :slight_smile: At the moment I have not done much at all, just trying to fight the tools provided by android, because they don’t seem to be able to work much at all (I’m using adb shell to connect to my device)

Great, I don’t have experience with Android either. At least we can share the pain :wink:
Tomorrow I will be able to spend some time trying to port Linux to the X20 board. I’ll post my progress here.

I’ll be happy to help if I can but TBH I drifted away from this work
because my (rather unusual) needs were met by the mainline kernel
efforts for this board:

Dear danielt,

I gave it a try but I am now stuck, hopefully you can help me to find a way out. Let me explain what I did so far:

  1. Use multistrap to create a debian root file system (arch=arm64, suite=jessie). I am able to chroot into it and succesfully run ‘dpkg --configure -a’

  2. Create an empty image file:

    dd if=/dev/zero of=arm64_linux_root_file_system.img bs=1M count=2560

  3. Format the newly created file:

    mkfs ext3 -F arm64_linux_root_file_system.img

  4. Mount the image file and copy the root file system into it:

    sudo mount -o loop,rw,sync arm64_linux_root_file_system.img /tmp/mount_tmp
    sudo cp -rf dev-arm64/* /tmp/mount_tmp/

  5. Download your version of the Linux kernel (commit: ece0e740c5492b51790c86dd2e9dabf04e829110)

  6. Crosscompile the kernel:

    make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- amt6797_64_open_defconfig
    make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j8 Imag

So far, so good, but now is when it gets fuzzy. I am able to read the following partition table of my mediatek X20 through the UART0:

[1940] Part Info.(1blk=512B):

[1940] [0x0000000000008000-0x0000000001007fff] ( 32768 blocks): “recovery”

[1940] [0x0000000001008000-0x0000000001087fff] ( 1024 blocks): “para”

[1940] [0x0000000001088000-0x0000000001a87fff] ( 20480 blocks): “expdb”

[1940] [0x0000000001a88000-0x0000000001b87fff] ( 2048 blocks): “frp”

[1940] [0x0000000001b88000-0x0000000002387fff] ( 16384 blocks): “nvcfg”

[1940] [0x0000000002388000-0x0000000004387fff] ( 65536 blocks): “nvdata”

[1940] [0x0000000004388000-0x0000000006387fff] ( 65536 blocks): “metadata”

[1940] [0x0000000006388000-0x0000000006b87fff] ( 16384 blocks): “protect1”

[1940] [0x0000000006b88000-0x00000000077fffff] ( 25536 blocks): “protect2”

[1940] [0x0000000007800000-0x0000000007ffffff] ( 16384 blocks): “seccfg”

[1940] [0x0000000008000000-0x00000000081fffff] ( 4096 blocks): “oemkeystore”

[1940] [0x0000000008200000-0x00000000084fffff] ( 6144 blocks): “proinfo”

[1960] [0x0000000008500000-0x0000000009cfffff] ( 49152 blocks): “md1img”

[1960] [0x0000000009d00000-0x000000000a0fffff] ( 8192 blocks): “md1dsp”

[1960] [0x000000000a100000-0x000000000a3fffff] ( 6144 blocks): “md1arm7”

[1960] [0x000000000a400000-0x000000000a8fffff] ( 10240 blocks): “md3img”

[1960] [0x000000000a900000-0x000000000a9fffff] ( 2048 blocks): “scp1”

[1960] [0x000000000aa00000-0x000000000aafffff] ( 2048 blocks): “scp2”

[1960] [0x000000000ab00000-0x000000000affffff] ( 10240 blocks): “nvram”

[1960] [0x000000000b000000-0x000000000b07ffff] ( 1024 blocks): “lk”

[1960] [0x000000000b080000-0x000000000b0fffff] ( 1024 blocks): “lk2”

[1960] [0x000000000b100000-0x000000000c0fffff] ( 32768 blocks): “boot”

[1960] [0x000000000c100000-0x000000000c8fffff] ( 16384 blocks): “logo”

[1960] [0x000000000c900000-0x000000000cdfffff] ( 10240 blocks): “tee1”

[1960] [0x000000000ce00000-0x000000000d2fffff] ( 10240 blocks): “tee2”

[1980] [0x000000000d300000-0x000000000dffffff] ( 26624 blocks): “keystore”

[1980] [0x000000000e000000-0x00000000adffffff] ( 5242880 blocks): “system”

[1980] [0x00000000ae000000-0x00000000c8ffffff] ( 884736 blocks): “cache”

[1980] [0x00000000c9000000-0x00000001d0ffbdff] ( 8650719 blocks): “userdata”

[1980] [0x00000001d0ffbe00-0x00000001d1ffbdff] ( 32768 blocks): “flashinfo”

Based on one of your previous posts, I replaced the “system” (2560M) partition with my root file system image (arm64_linux_root_file_system.img). However, I don’t know how to go about the patched Linux kernel. I assume that I should replace the partition “boot” with a new “boot.img” including the new kernel? If so, shall I use a tool such as “mkbooting” to build it? Shall I first unpack the original “boot.img” to get some parts/info? As you can see, I can use some help here and thus, I would very much appreciate if you could walk me through this part of the porting procedure :slight_smile:


According to my logbook t looks like I configured, built and installed the kernel using the following commands:

make amt6797_64_open_defconfig
# mmcblk0p27 is the system partition (fastboot flash system rootfs.img)
scripts/config \
	--enable CMDLINE_FORCE --set-str CMDLINE \
	'console=ttyMT0,921600n1 root=/dev/mmcblk0p27 rw vmalloc=496M maxcpus=5 mrdump_rsvmem=0x46000000,0x400000,0x44800000,0x9c280 lcm=1-nt35695_fhd_dsi_cmd_truly_nt50358_drv fps=6000 vram=29229056 boot_reason=0 gpt=1 loglevel=1'
scripts/config \
	--disable TOUCHSCREEN_MTK \
	--disable TOUCHSCREEN_MTK_GT1151 \
	--enable TMPFS \
	--enable DEVTMPFS \
	--enable CGROUPS \
	--enable FHANDLE \
	--enable AUTOFS4_FS \
	--enable IPV6
make olddefconfig

make -j `nproc`

touch arch/arm64/boot/empty
gzip -f arch/arm64/boot/empty
abootimg \
	--create arch/arm64/boot/aboot.img \
	-k arch/arm64/boot/Image.gz-dtb \
	-r arch/arm64/boot/empty.gz \
	-c "pagesize = 0x800" \
	-c "kerneladdr = 0x40080000" \
	-c "ramdiskaddr = 0x45000000" \
	-c "secondaddr = 0x40f00000" \
	-c "tagsaddr = 0x44000000" \
	-c "name = " \
	-c "cmdline = bootopt=64S3,32N2,64N2"
fastboot boot arch/arm64/boot/aboot.img

You’ll notice above that I don’t actually flash the kernel, instead I try to boot the kernel directly. I was running with a LittleKernel that I hacked myself for easier kernel development that would automatically enter fastboot mode if the boot partition was empty (like LK for DB410C)… unfortunately I can’t find the code for that so I don’t know quite what I did.

If “fastboot boot” doesn’t work try “fastboot flash boot” instead…

Thanks a lot danielt! Now I’m able to boot debian succesfully:

Found device /dev/ttyMT0.
[\0x1b[32m OK \0x1b[0m] Reached target Sound Card. Starting Serial Getty on ttyMT0…
[\0x1b[32m OK \0x1b[0m] Started Serial Getty on ttyMT0.
[\0x1b[32m OK \0x1b[0m] Reached target Login Prompts.
[\0x1b[32m OK \0x1b[0m] Reached target Multi-User System.
[\0x1b[32m OK \0x1b[0m] Reached target Graphical terface.
Starting Update UTMP about System Runlevel Changes…
\0x1b[0m] Started Update UTMP about System Runlevel Changes.
debian_arm ttyMT0

debian_arm login:

However, I’m not able to type and get passed the initial login… Do you know what may be the issue? I’m connected to the UART0, which prompts all the booting sequence but remains impassive to my key strokes.


That’s pretty weird and I really don’t have much clue. Once that getty starts we usually have everything we need to communicate with the UART.

If this were happening to me my first call would be to double check all the physical connections, especially after messing with the jumpers if you are using a 96boards-uart! Have the connections been proved to work using the Android build?

Hi danielt,

It was just a stupid mistake on my hand made UART connector extension.
Now it all works fine. Thanks a lot for your support!


Dear danielt,

one last thing: were you able to set up the wireless interface? I’m not able to see it:

debian_arm:~$ sudo ifconfig -a

ifb0 Link encap:Ethernet HWaddr 9a:9e:d0:fb:45:11

ifb1 Link encap:Ethernet HWaddr ba:04:22:7c:66:23

ip6tnl0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00

lo Link encap:Local Loopback

sit0 Link encap:IPv6-in-IPv4

tunl0 Link encap:IPIP Tunnel HWaddr

In a word… no.

However neither did I try very hard. I suspect the WiFi driver is trying (and failing) to load a firmware from the root filesystem; that firmware will need to be copied from the Android images.

Thanks a lot danielt, you have helped me a lot!

No worries. It would be great to see folks interested in taking the boards to new places!

Sorry… no idea why I used past tense there. It is great to see folks interested in this.