diff mbox

N900 device tree conversion: how to do first step

Message ID 20130609015944.GA23559@amd.pavel.ucw.cz (mailing list archive)
State New, archived
Headers show

Commit Message

Pavel Machek June 9, 2013, 1:59 a.m. UTC
Hi!

I'd like to convert Nokia N900 to device tree.

Unfortunately, serial port is not easily available (very special cable
would be needed, does someone know where to get one?) and I don't have
BDI (and very special cable would be needed, too).

So I tried doing very small first step, hoping that I get booting
system... obviously I did not.

I tried formally switching to device tree while still booting using
hardcoded functions. No luck. Does anyone see what I did wrong?

Is it possible that n900 has its main memory somewhere else than
0x80000000?

Thanks,
									Pavel

\ No newline at end of file

Comments

Pali Rohár June 9, 2013, 9:24 a.m. UTC | #1
On Sunday 09 June 2013 03:59:44 Pavel Machek wrote:
> Hi!
> 
> I'd like to convert Nokia N900 to device tree.
> 
> Unfortunately, serial port is not easily available (very
> special cable would be needed, does someone know where to get
> one?) and I don't have BDI (and very special cable would be
> needed, too).
> 

Hello,

I used serial port only in qemu for debugging. Maybe you can try
to play with qemu first. Qemu has good n900 HW support.

But problematic is to create n900 mtd nand image bootable in
qemu, because it needs closed source nokia bootloader and this
needs to have CAL partition with some unknown data with is
proprietary format.

Nevertheless, there is prebuilded qemu image with maemo5 and with
special version of nokia patches qemu, which was (and still is)
very good for testing anything for n900. Special version of qemu
plus qemu image is part of MADDE development tool, look here:

Info: http://wiki.maemo.org/MADDE
Download link: http://tablets-dev.nokia.com/MADDE.php

Except skinning support and Opengl ES all other nokia patches were
included into Linaro version of qemu, so you can use it without
problems. But you still need proprietary bootloader and correct
CAL partition.

But, nokia released closed redistributable version of bootloader
for qemu and (proprietary) tool which generating mtd nand
partition. You can pass kernel, initfs, rootfs images and it
create correct mtd layout and automatically creating CAL.

Proprietary n900 bootloader (two parts!) for qemu is here:
http://download.meego.com/live/Trunk:/non-oss:/Testing/Trunk_Testing/i586/nolo-qemu-0.20100910-1.2.i586.rpm

Proprietary tool for creating mtd nand file is here:
http://download.meego.com/live/Trunk:/non-oss:/Testing/Trunk_Testing/i586/qflasher-21-1.2.i586.rpm

PS: Sorry for too many closed SW, but there is no FOSS equivalent
and this is the only one option how to use qemu n900 hw support.
U-Boot is ported to n900, but depends on Nokia bootloader...
Pavel Machek June 9, 2013, 5:30 p.m. UTC | #2
On Sun 2013-06-09 03:59:44, Pavel Machek wrote:
> Hi!
> 
> I'd like to convert Nokia N900 to device tree.
> 
> Unfortunately, serial port is not easily available (very special cable
> would be needed, does someone know where to get one?) and I don't have
> BDI (and very special cable would be needed, too).
> 
> So I tried doing very small first step, hoping that I get booting
> system... obviously I did not.
> 
> I tried formally switching to device tree while still booting using
> hardcoded functions. No luck. Does anyone see what I did wrong?
> 
> Is it possible that n900 has its main memory somewhere else than
> 0x80000000?

Interesting. It seems that memory setup from atags is indeed 
	     0x8000 0000 size 0x0800 0000
	     0x8800 0000 size 0x0800 0000

. But hopefully that's just complicated way of saying 
	     0x8000 0000 size 0x1000 0000
	     
.

Anyway, I now see problem with my reasoning: kernel is full of

if (of_have_populated_dt())

tests, so it is impossible to switch to device tree, and still expect
old-style init to work :-(.

									Pavel
Aaro Koskinen June 9, 2013, 8:11 p.m. UTC | #3
Hi,

On Sun, Jun 09, 2013 at 03:59:44AM +0200, Pavel Machek wrote:
> I'd like to convert Nokia N900 to device tree.
> 
> Unfortunately, serial port is not easily available (very special cable
> would be needed, does someone know where to get one?) and I don't have
> BDI (and very special cable would be needed, too).
> 
> So I tried doing very small first step, hoping that I get booting
> system... obviously I did not.

The following works for me, it's enough to boot and get the USB networking
working. After that I can connect to the device with ssh. I don't use
serial either, I just have initramfs with busybox+dropbear with hardcoded
interface setup.

---8<---

/dts-v1/;

/include/ "omap34xx.dtsi"

/ {
	model = "Nokia N900";
	compatible = "nokia,omap3-n900", "ti,omap3";

	cpus {
		cpu@0 {
			cpu0-supply = <&vcc>;
		};
	};

	memory {
		device_type = "memory";
		reg = <0x80000000 0x10000000>; /* 256 MB */
	};

};

&i2c1 {
	clock-frequency = <2200000>;

	twl: twl@48 {
		reg = <0x48>;
		interrupts = <7>; /* SYS_NIRQ cascaded to intc */
		interrupt-parent = <&intc>;
	};
};

/include/ "twl4030.dtsi"

&twl_gpio {
	ti,pullups	= <0x0>;
	ti,pulldowns	= <0x03ff3f>; /* BIT(0..5) | BIT(8..17) */
};

&i2c2 {
	clock-frequency = <400000>;
};

&i2c3 {
	clock-frequency = <100000>;
};

&mmc1 {
	status = "disabled";
};

&mmc2 {
	status = "disabled";
};

&mmc3 {
	status = "disabled";
};

&usb_otg_hs {
	interface-type = <0>;
	usb-phy = <&usb2_phy>;
	mode = <2>;
	power = <50>;
};
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pavel Machek June 13, 2013, 1:26 p.m. UTC | #4
Hi!

> > I'd like to convert Nokia N900 to device tree.
> > 
> > Unfortunately, serial port is not easily available (very special cable
> > would be needed, does someone know where to get one?) and I don't have
> > BDI (and very special cable would be needed, too).
> > 
> > So I tried doing very small first step, hoping that I get booting
> > system... obviously I did not.
> 
> The following works for me, it's enough to boot and get the USB networking
> working. After that I can connect to the device with ssh. I don't use
> serial either, I just have initramfs with busybox+dropbear with hardcoded
> interface setup.

Nice.... thanks a lot.

Did you get video to work with the device tree? That's what I'd like
to accomplish now.

If I init spi manually (and some more hacks), it works in the
qemu. But I have not tested on real hw for a while.

									Pavel
Tony Lindgren June 13, 2013, 2:10 p.m. UTC | #5
* Pavel Machek <pavel@ucw.cz> [130613 06:32]:
> Hi!
> 
> > > I'd like to convert Nokia N900 to device tree.
> > > 
> > > Unfortunately, serial port is not easily available (very special cable
> > > would be needed, does someone know where to get one?) and I don't have
> > > BDI (and very special cable would be needed, too).
> > > 
> > > So I tried doing very small first step, hoping that I get booting
> > > system... obviously I did not.
> > 
> > The following works for me, it's enough to boot and get the USB networking
> > working. After that I can connect to the device with ssh. I don't use
> > serial either, I just have initramfs with busybox+dropbear with hardcoded
> > interface setup.
> 
> Nice.... thanks a lot.
> 
> Did you get video to work with the device tree? That's what I'd like
> to accomplish now.

The DSS code is still using pdata, see mach-omap2/dss-common.[ch].
 
> If I init spi manually (and some more hacks), it works in the
> qemu. But I have not tested on real hw for a while.

You should be able to initialize spi by adding the .dts entry,
or is there something missing in drivers/spi/spi-omap2-mcspi.c?

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sebastian Reichel July 19, 2013, 6:14 p.m. UTC | #6
Hi,

On Sun, Jun 09, 2013 at 03:59:44AM +0200, Pavel Machek wrote:
> I'd like to convert Nokia N900 to device tree.
> 
> Unfortunately, serial port is not easily available (very special cable
> would be needed, does someone know where to get one?)

One way to get one is building it yourself. I finished mine yesterday:

http://elektranox.org/n900/adapter/index.html

-- Sebastian
Pavel Machek July 28, 2013, 1:37 p.m. UTC | #7
Hi!

> > I'd like to convert Nokia N900 to device tree.
> > 
> > Unfortunately, serial port is not easily available (very special cable
> > would be needed, does someone know where to get one?)
> 
> One way to get one is building it yourself. I finished mine yesterday:
> 
> http://elektranox.org/n900/adapter/index.html

Nice but a bit above my hardware hacking skills. For now, I'm using
automated scripts to run qemu... (They are available at 

http://tui.cvs.sourceforge.net/viewvc/tui/tui/auto/

). They should allow automated testing for regressions and automatic
bisect.

									Pavel
diff mbox

Patch

diff --git a/.config b/.config
index a36bbe2..130a7a8 100644
--- a/.config
+++ b/.config
@@ -498,11 +498,11 @@  CONFIG_ATAGS=y
 # CONFIG_DEPRECATED_PARAM_STRUCT is not set
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
-# CONFIG_ARM_APPENDED_DTB is not set
-CONFIG_CMDLINE="init=/sbin/preinit ubi.mtd=rootfs root=ubi0:rootfs rootfstype=ubifs rootflags=bulk_read,no_chk_data_crc rw mtdoops.mtddev=log console=tty0 console=ttyO2"
-CONFIG_CMDLINE_FROM_BOOTLOADER=y
-# CONFIG_CMDLINE_EXTEND is not set
-# CONFIG_CMDLINE_FORCE is not set
+CONFIG_ARM_APPENDED_DTB=y
+CONFIG_ARM_ATAG_DTB_COMPAT=y
+# CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER is not set
+CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND=y
+CONFIG_CMDLINE=""
 CONFIG_KEXEC=y
 CONFIG_ATAGS_PROC=y
 # CONFIG_CRASH_DUMP is not set
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 9c62558..7b1a075 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -119,6 +119,7 @@  dtb-$(CONFIG_ARCH_OMAP2PLUS) += omap2420-h4.dtb \
 	omap3-beagle-xm.dtb \
 	omap3-evm.dtb \
 	omap3-tobi.dtb \
+	omap3-n900.dtb \
 	omap4-panda.dtb \
 	omap4-panda-a4.dtb \
 	omap4-panda-es.dtb \
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
new file mode 100644
index 0000000..e093543
--- /dev/null
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -0,0 +1,35 @@ 
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+/dts-v1/;
+
+/include/ "skeleton.dtsi"
+/* FIXME: "omap3.dtsi" */
+
+/ {
+	model = "Nokia N900";
+	compatible = "nokia,omap3-n900", "ti,omap3";
+
+	memory {
+		device_type = "memory";
+		reg = <0x80000000 0x10000000>; /* 256 MB */
+	};
+};
+
+/*
+&mmc1 {
+	status = "disabled";
+};
+
+&mmc2 {
+	status = "disabled";
+};
+
+&mmc3 {
+	status = "disabled";
+};
+*/
diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c
index 74f83a5..f857b5b 100644
--- a/arch/arm/mach-omap2/board-rx51.c
+++ b/arch/arm/mach-omap2/board-rx51.c
@@ -36,6 +36,8 @@ 
 
 #define RX51_GPIO_SLEEP_IND 162
 
+/* This lights up left part of keyboard */
+
 static struct gpio_led gpio_leds[] = {
 	{
 		.name	= "sleep_ind",
@@ -119,21 +121,21 @@  static void __init rx51_init(void)
 	platform_device_register(&leds_gpio);
 }
 
-static void __init rx51_reserve(void)
-{
-	omap_reserve();
-}
+static const char *omap3_boards_compat[] __initdata = {
+	"nokia,omap3-n900",
+        NULL,
+};
 
-MACHINE_START(NOKIA_RX51, "Nokia RX-51 board")
-	/* Maintainer: Lauri Leukkunen <lauri.leukkunen@nokia.com> */
-	.atag_offset	= 0x100,
-	.reserve	= rx51_reserve,
+DT_MACHINE_START(N900_DT, "Nokia N900 (Flattened Device Tree)")
+	.atag_offset    = 0x100,
+	.reserve	= omap_reserve,
 	.map_io		= omap3_map_io,
-	.init_early	= omap3430_init_early,
-	.init_irq	= omap3_init_irq,
-	.handle_irq	= omap3_intc_handle_irq,
-	.init_machine	= rx51_init,
-	.init_late	= omap3430_init_late,
-	.init_time	= omap3_sync32k_timer_init,
-	.restart	= omap3xxx_restart,
+	.init_early     = omap3430_init_early,
+	.init_irq       = omap3_init_irq, /* FIXME: omap_intc_of_init, */
+	.handle_irq     = omap3_intc_handle_irq,
+	.init_machine   = rx51_init, /* FIXME: omap_generic_init, */
+	.init_late      = omap3430_init_late, /* FIXME: omap3_init_late, */
+	.init_time      = omap3_sync32k_timer_init,
+	.dt_compat      = omap3_boards_compat,
+	.restart        = omap3xxx_restart,
 MACHINE_END
diff --git a/mkit b/mkit
index 354610c..e9ffc02 100755
--- a/mkit
+++ b/mkit
@@ -1,3 +1,4 @@ 
 #!/bin/bash
 ARCH=arm time make -j 3 && \
-    sudo ../maemo/0xffff/src/0xFFFF -m arch/arm/boot/zImage -l -b 'root=/dev/mmcblk0p6 rootwait'
\ No newline at end of file
+    cat arch/arm/boot/zImage arch/arm/boot/dts/omap3-n900.dtb > zImage_dtb && \
+    sudo ../maemo/0xffff/src/0xFFFF -m zImage_dtb -l -b 'root=/dev/mmcblk0p6 rootwait'