Support for Olimex AM3352-SOM in beaglebone kernel

Started by vinifr, December 09, 2015, 01:48:38 PM

Previous topic - Next topic

vinifr

Hi Olimex,

I have submitted a patch to oficial Beaglebone kernel to support AM3352-SOM: https://github.com/beagleboard/linux/pull/53 ... I took the kernel code am335x-olimex-som.dts from Dimitar' kernel and created a am335x-som-common.dtsi based on am335x-bone-common.dtsi, to make it more acceptable patch. As I picked up the Dimitar kernel code, I added:
Signed-off-by: Dimitar Gamishev hehopmajieh@debian.bg ... I hope you do not mind  ;D

vinifr

#1
Hi,

If anyone is interested, the patch has already been accepted: https://github.com/beagleboard/linux/commit/30796bae3b6c17830e0a162c538f803530bf8fda. Now I'm trying a defconfig: https://github.com/beagleboard/linux/pull/54.

filipeisaac

Hello,

This patch will enable the bonecapes on AM3352? I'm having many problems with this olimex image for AM3352 and the BB capes would help a lot!

Obrigado

vinifr

#3
Hi,

You can use AM3352 at same way like you use Beaglebone, since we are running the same kernel. But note that the patch was submitted to kernel 4.1, so we can not use overlay. The way to instantiate devices has changed!

damancuso

Hi vinifr,

I'm trying to use the Beageblone kernel on the AM3352-SOM but I'm not sure exactly how to do it, I'm sorry for this newbie question but I would really appreciate some guidance here :) .
First I've tried the latest Beageblone Debian image but of course the AM3352-SOM didn't boot up for differences on the U-Boot on both boards. So then I tried flashing my SD card with the Olimex "u-boot-2013.10-ti2013.12.01-am3352_som" on the first 2048 sectors and the rootfs partition on the area above --> U-Boot starts, finds the Olimex dts file (/boot/dtbs/4.4.9-ti-r25/am335x-olimex-som.dtb) but then it fails (here is the U-Boot output: http://pastebin.com/6XvPNkhu) which I guess that makes sense because the kernel images are completely different.
Which MLO and u-boot.img binaries should I use? I don't see anything related to am335x-olimex on the latest U-Boot sources so I'm a bit lost here  :-\

Thanks in advance!!

vinifr

#5
Hi, here go a simple guide...

You have to use olimex bootloader, since u-boot mainline does not have support for am3352-som yet. To build olimex bootloader follow the instructions here: https://www.olimex.com/wiki/Building_Debian_AM3352_SOM (2. Building Uboot).
Another detail, you need to change u-boot init script in order to boot beaglebone kernel. uEnv.txt code

bootcmd_mmc0=setenv devnum 0; setenv rootpart 1; run mmc_boot;
mmc_boot=setenv devtype mmc; if mmc dev ${devnum}; then run mmcargs;run scan_boot; run mmcboot;setenv mmcdev 0; setenv bootpart 0:1; run mmcboot;fi
bootpart=0:1
mmcroot=/dev/mmcblk0p1 ro
fdtfile=am335x-olimex-som.dtb
loadximage=load mmc 0:1 ${loadaddr} /boot/zImage
loadxfdt=load mmc 0:1 ${fdtaddr} /boot/${fdtfile}
##loadxrd=load mmc 0:1 ${rdaddr} /boot/initrd.img-${uname_r}; setenv rdsize ${filesize}
loadall=run loadximage;  run loadxfdt;

kgdb=kgdboc=ttyS0,115200n8 kgdbwait

mmcargs=setenv bootargs console=ttyS0,115200n8 ${optargs} root=${mmcroot} rootfstype=${mmcrootfstype} ${cmdline} cmdline=quiet init=/lib/systemd/systemd

uenvcmd=run loadall; run mmcargs; bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr};


This script expects to find zImage and am335x-olimex-som.dtb inside /boot folder. So, you must copy these files for boot folder. To compile beaglegone kernel:

git clone https://github.com/beagleboard/linux.git
cd linux
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bb.org_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 zImage dtbs LOADADDR=0x82000000
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 modules
make ARCH=arm INSTALL_MOD_PATH=output modules_install

The patch was submitted for beaglebone kernel 4.1. So, use 4.1 version or higher.

damancuso

Thanks a lot! I really appreciate the support. I'll give it a try :)

thom_nic

Hey there - just to confirm, I should be able to build a 4.4 kernel from the beaglebone sources with the following extra steps vs the official Olimex instructions:

- use the bb.org_defconfig
- set LOADADDR= during make zImage
- use the updated uEnv.txt

and that's it? 

vinifr

Yes, it is. But you can also use any version starting at 4.1.

thom_nic

Confirmed, the Beagleboard kernel v4.4 appears to run happily on the AM3352-som.

Wow the bbb.org_defconfig (on v4.4) creates a much bigger binary!  8.3MB kernel and what looks to be a lot more modules. 

Is it possible to use the omap2plus_defconfig instead if I'm only interested in supporting the basics like Eth, CAN, standard UARTs and GPIOs?

Only caveat to note, I got the following during boot:


[FAILED] Failed to start Load Kernel Modules.
See 'systemctl status systemd-modules-load.service' for details.


I had to delete the ledtrig-heartbeat module from /etc/modules-load.d/.  Oddly that doesn't seem to affect the green heartbeat LED on the Olimex SOM since it's still blinking after rebooting with this disabled.

vinifr

#10
Well, i'm not sure if you can use omap2plus_defconfig. They are really similar, but there are small differences.

About "[FAILED] Failed to start Load Kernel Modules.", you have to copy for uSD: kernel(zImage), dtb file(am335x-olimex-som.dtb) and the modules from output/lib/modules/4.4.xxxx folder. Copy the modules to file system partition into /lib/modules

thom_nic

Thanks!  The "module load" failure was because the bb.org defconfig has ledtrig-heartbeat set as a compiled-in option rather than a module.  Which is why the heartbeat LED still works - it just means I could remove that line from /etc/modules-load.d/modules.conf.

I started going through the menuconfig from a bb.org defconfig as a starting point and disabled everything that looks like a driver that I'm not using... There's a lot but I'm slowly whittling it down.

I've got a hangup with the DTBs, I added the am335x-olimex-som-evb.dts (tweaked to use the dtsi) to the kernel sources and built it but when I try to use it the kernel does not boot.  So clearly I'm not doing it right, I guess I need to figure out how to add the hardware peripherals I'm using to the to a new DTS based on the am335x-olimex-som.dts ..?

vinifr

#12
You might use am335x-olimex-som.dts and add any peripherals. You don't need create a new one.

thom_nic

Ah, I see now, most of the EVB pin definitions (USB, ETH, etc) are in the am335x-som-common.dtsi whereas they were in the -evb.dts definition file from Olimex.  I was expecting the base configuration to not have those definitions.  I first tried to copy the -evb.dts file to the bb.org kernel tree, and I tweaked something wrong because when I tried to use it the kernel would not boot at all. 

So you're right, when I use the am335x-olimex-som.dts it looks like most of the peripherals are present (maybe dcan is missing?)

Thanks!

vinifr

#14
Hi thom,

We can use the same code from beaglebone. For example, adding SPI and I2C:

&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&olimex_spi0_pins>;
status = "okay";

channel@0 {
compatible = "spidev";
spi-max-frequency = <16000000>;
reg = <0>;
spi-cpha;
};

channel@1 {
compatible = "spidev";
spi-max-frequency = <16000000>;
reg = <1>;
};
};


&i2c0 {
tda19988 {
compatible = "nxp,tda998x";
reg = <0x70>;
pinctrl-names = "default", "off";
pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;
port {
hdmi_0: endpoint@0 {
remote-endpoint = <&lcdc_0>;
};
};
};
};

Note that you have to define olimex_spi0_pins inside am33xx_pinmux section! The same for I2C. And this code should be put inside am335x-olimex-som.dts. Look here: https://github.com/vinifr/linux/blob/am3352_som/arch/arm/boot/dts/am335x-boneblack-spi0.dts#L92