debian image with mainline kernel

Started by lambda, March 11, 2018, 04:07:02 PM

Previous topic - Next topic


Hi all,

as promised in the other thread recently I have uploaded a disk image with recent debian testing and a pre-release 4.16 kernel:

This image has a patched u-boot (by deesix) to get the display up early and a brand new DT for the board. Other than that it is a very minimal debian with only packages of priority standard plus a few extras like non-free firmware for the wireless chip. There are users root and olimex, with password olimex each.

WARNING: ssh password login for root is enabled, to allow entering the system via network if you mess up the display somehow. If you intend to use this system for more then testing, please be sure to at least change the root password and possibly also disable password login for ssh!

Usb network adapters should work after proper configuration in /etc/network/interfaces - and wifi can be set up with the "iw"  tool. For ppp or mobile modems you will need to install some packages first.

I resized the image to less then 1GB before uploading to make writing it to a sd-card quicker. After writing it to your storage with

gzip -d <teres-debian.gz | dd of=/dev/xxx

you will have a 1GB partition that is mostly full and and otherwise empty medium. Of course you can partition the rest of the medium any way you want, but I recommend to just increase the size of the partition with fdisk and then grow the filesystem with resize2fs.

WARNING: The boot scripts in the image expect to load a system from the external mmc slot. If you write the image to the internal eMMC, it probably won't work (out of the box).

I have also put the .config used to compile the kernel (only a few modules enabled on top of standard debian kernels) online:

and the DT file:

These will be submitted to linux and debian in the next days. Feedback and bug reports being much appreciated till then.

I don't intend to do more work on this image or make a version with more software installed, because
  • I'm sure everybody has a debian mirror that is faster for them than my server
  • I'm optimistic that, with our work sent upstream, there will be official support for the TERES I in debian installer soon. Such a image should not be necessary to bootstrap a TERES I in the near future, anymore.



First of all, thank you.

Can you also post some instruction for building u-boot (ie: patch, config)?

BTW: I've quickly tried the image, and it works fine so far. I'll let you now if I found problems.



Quote from: diegor on March 11, 2018, 08:02:46 PM
Can you also post some instruction for building u-boot (ie: patch, config)?

This work was done by deesix (user dddddd in #olimex irc channel). You will have to ask her, as I don't know the details.

However I expect that all patches will be upstream and in debian quite soon. Also I can point you to the debian package atf-allwinner, that already has most of the code.


The patch itself is for the ATF. See u-boot's board/sunxi/README.sunxi64 for details.

Icenowy's patch for anarsoul's u-boot adds the defconfig and a minimal dts.

diff --git a/plat/sun50iw1p1/sunxi_power.c b/plat/sun50iw1p1/sunxi_power.c
index 2d2924fd..57b0f97d 100644
--- a/plat/sun50iw1p1/sunxi_power.c
+++ b/plat/sun50iw1p1/sunxi_power.c
@@ -66,6 +66,29 @@
#define RUNTIME_ADDR 0x2d
#define AXP803_HW_ADDR 0x3a3

+ * Olimex TERES-I LCD power-up hack, to be patched on top of
+ *
+ *
+ * For u-boot proper, cherry-pick
+ *
+ * on top of
+ *
+ *
+ * See:
+ *  - Olimex TERES-PCB1-A64-MAIN_Rev.C.pdf
+ *  - AXP803 datasheet
+ *  - A64 user manual
+ *  - u-boot board/sunxi/README.sunxi64
+ *
+ * Consider this patch public domain. Use at your own risk.
+ * Feb-Mar 2018
+ */
+#define PD_CFG3         SUNXI_PIO_BASE + (3 * 0x24) + 0x0c
+#define PD_CFG3_REG     PD_CFG3 + 0x78
+#define PD_DATA_REG     PD_CFG3 + 0x7c
/* Initialize the RSB controller and its pins. */
static int init_rsb(void)
@@ -266,7 +289,35 @@ static int pmic_setup(const char *dt_name)
sunxi_pmic_write(0x24, 0x2c);
+ /* Enable the LCD power planes to get the display up early. */
+ if (!strcmp(dt_name, "sun50i-a64-teres-i")) {
+ // Enable GPIO PD24 used as eDP_RESET, for output
+ mmio_write_32(PD_CFG3_REG, 0x01 /* output */);
+ // Set eDP_RESET to LOW
+ ret = mmio_read_32(PD_DATA_REG);
+ mmio_write_32(PD_DATA_REG, ret & (~(1<<24)));
+ // Set DLDO3 to 1.2V
+ sunxi_pmic_write(0x17, 0x05); /* 0.7 + (n/10); n=5(0x05) ==> 0.7+0.5 = 1.2 */
+ // Set DLDO2 to 2.5V
+ sunxi_pmic_write(0x16, 0x12); /* 0.7 + (n/10); n=18(0x12) ==> 0.7+1.8 = 2.5 */
+ // Up DLDO2
+ ret = sunxi_pmic_read(0x12); /* 0x12 ==> Output power on/off control 2 */
+ sunxi_pmic_write(0x12, ret | 0x10); /* 0x12 idem; DLDO2 at bit 4(0x10) */
+ // 2 ms delay
+ udelay(2000);
+ // Up DLDO3
+ ret = sunxi_pmic_read(0x12); /* 0x12 idem */
+ sunxi_pmic_write(0x12, ret | 0x20); /* 0x12 idem; DLDO3 at bit 5(0x20) */
+ // 10ms delay
+ udelay(10000);
+ // eDP_RESET to HIGH
+ ret = mmio_read_32(PD_DATA_REG);
+ mmio_write_32(PD_DATA_REG, ret | (1<<24));
+ NOTICE("PMIC: enabled TERES-I display\n");
+ }
sunxi_pmic_write(0x15, 0x1a); /* DLDO1 = VCC3V3_HDMI voltage = 3.3V */

return 0;

The atf-allwinner package sources should be mostly compatible with the patch (based on a near commit, I think). It should work but I didn't tested it. I'm also not sure where to put those #define. The comments may need another format.

For the image at hand, u-boot is compiled with environment disabled, to avoid accidental writes to internal flash (from SD card u-boot!).


JFTR here is a link to the bug report describing the changes to the default debian kernel config, for the teres:

With this (and the information in the "going mainline" thread) all the changes necessary to build the debian image have been made public. Let's hope everything get's merged soon ...


Debian have added the necessary modules for teres and have uploaded a new kernel package to experimental: linux-image-4.16.0-rc6-arm64

However on a quick test my system didn't boot after upgrading the kernel. Maybe mkinitramfs isn't including all the modules neccessary to get the rootfs up - I haven't had time to check yet. - Just a warning and maybe somebody has time to look into this before me... ;)


Indeed, adding


to /etc/initramfs-tools/modules and running update-initramfs makes the system boot again.