Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => AM3352 => Topic started by: vinifr on December 09, 2015, 01:48:38 pm

Title: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on December 09, 2015, 01:48:38 pm
Hi Olimex,

I have submitted a patch to oficial Beaglebone kernel to support AM3352-SOM: https://github.com/beagleboard/linux/pull/53 (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
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on December 17, 2015, 10:19:23 pm
Hi,

If anyone is interested, the patch has already been accepted: https://github.com/beagleboard/linux/commit/30796bae3b6c17830e0a162c538f803530bf8fda (https://github.com/beagleboard/linux/commit/30796bae3b6c17830e0a162c538f803530bf8fda). Now I'm trying a defconfig: https://github.com/beagleboard/linux/pull/54 (https://github.com/beagleboard/linux/pull/54).
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: filipeisaac on April 14, 2016, 06:00:19 pm
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
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on April 14, 2016, 06:53:20 pm
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!
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: damancuso on October 20, 2016, 10:00:06 pm
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!!
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on October 20, 2016, 10:15:09 pm
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 (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.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: damancuso on October 20, 2016, 11:15:54 pm
Thanks a lot! I really appreciate the support. I'll give it a try :)
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: thom_nic on January 25, 2017, 04:43:11 pm
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? 
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on January 25, 2017, 05:05:21 pm
Yes, it is. But you can also use any version starting at 4.1.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: thom_nic on January 25, 2017, 10:59:22 pm
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.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on January 26, 2017, 08:16:41 pm
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
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: thom_nic on January 31, 2017, 04:54:46 am
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 ..?
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on January 31, 2017, 05:11:20 am
You might use am335x-olimex-som.dts and add any peripherals. You don't need create a new one.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: thom_nic on January 31, 2017, 11:38:39 pm
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!
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on February 02, 2017, 05:51:57 pm
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 (https://github.com/vinifr/linux/blob/am3352_som/arch/arm/boot/dts/am335x-boneblack-spi0.dts#L92)
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: thom_nic on February 02, 2017, 11:10:49 pm
That's great, thanks!
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: thom_nic on February 07, 2017, 07:27:55 pm
I have one more question re: DTS...  I noticed with the beaglebone am335x-som DTS, LEDs on GPIO3 pins 19, 20 and 21 are used as the heartbeat.  On the Olimex SOM (and their DTS,) the green LED on the SOM is conected to gpio2 pin 18.  I know I can add that pin definition in my own DTS but what should I do to disable pins 19, 20 and 21?  I don't need 4 blinking heartbeat LEDs :D

I would prefer actually to remap gpio3 20 and 21 back to mmc0 and cpu0 trigger respectively as they were in the original Olimex EVB DTS.  Can I do that while still including the am335x-som-common.dtsi and override them?

Thanks.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on February 07, 2017, 07:43:53 pm
Hi,

You can remove them and define in another point with different functions, no problem.

Btw, if I remember well, those pin numbers in &am33xx_pinmux{ are the same in both, am3352 and beaglebone. So, we can use:

bb_spi0_pins: pinmux_bb_spi0_pins {
pinctrl-single,pins = <
0x150 0x30 /* spi0_sclk.spi0_sclk, INPUT_PULLUP | MODE0 */
0x154 0x30 /* spi0_d0.spi0_d0, INPUT_PULLUP | MODE0 */
0x158 0x10 /* spi0_d1.spi0_d1, OUTPUT_PULLUP | MODE0 */
0x15c 0x10 /* spi0_cs0.spi0_cs0, OUTPUT_PULLUP | MODE0 */
>;
};
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: thom_nic on February 07, 2017, 10:57:36 pm
Thanks.  from looking at these files:
https://www.olimex.com/Products/SOM/AM3352/AM3352-SOM/resources/AM3352_SOM_GPIOs.pdf
and https://github.com/OLIMEX/SOM/raw/master/AM3352/AM3352-SOM/AM3352-SOM_Rev_C.pdf

P3_18 is the onboard green LED,
P3_20 and P3_21 are the red and yellow LEDs on the EVB.
P0_19 (defined as led@1) is EMU2 for JTAG

So what is defined in am335x-som-common.dtsi as:


led@1 {
label = "led1:green:heartbeat";
gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "heartbeat";
};

led@2 {
label = "led2:red:heartbeat";
gpios = <&gpio3 20 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "heartbeat";
};

led@3 {
label = "led3:yello:heartbeat";
gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "heartbeat";
};


I re-defined to:


led@1 {
label = "olimex-som:green:heartbeat";
gpios = <&gpio3 18 GPIO_ACTIVE_HIGH>;
};

led@2 {
label = "olimex-evb:red:led2";
gpios = <&gpio3 20 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "mmc0";
default-state = "off";
};

led@3 {
label = "olimex-evb:yellow:led3";
gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "cpu0";
default-state = "off";
};

/* later on... */

&user_leds_s0 {
pinctrl-single,pins = <
0x1a0 ( PIN_OUTPUT | MUX_MODE7 ) /* (B12) mcasp0_aclkr.gpio3[18] */
0x1a8 ( PIN_OUTPUT | MUX_MODE7 ) /* (D13) mcasp0_axr1.gpio3[20] */
0x1ac ( PIN_OUTPUT | MUX_MODE7 ) /* (A14) mcasp0_ahclkx.gpio3[21] */
>;
};


This correctly maps the green LED1 (on the SOM) to heartbeat and red EVB LED2 to disk activity but EVB LED3 (yellow) does not trigger on CPU activity.  I think that may be due to something I disabled in kernel config however since `cat /sys/devices/platform/leds/leds/olimex-evb:yellow:led3` does not list `cpu0` as an option.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on February 09, 2017, 03:23:06 am
Hi thom,

That is great, you should try submit these changes to bb kernel.

About leds triggers, I found useful informations here: http://www.crashcourse.ca/wiki/index.php/LEDs_on_the_BBB (http://www.crashcourse.ca/wiki/index.php/LEDs_on_the_BBB)... Maybe you disabled CONFIG_LEDS_TRIGGER_CPU.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on February 10, 2017, 01:26:18 pm
Hi thom,

Could you pass me your config? I'll make it default configuration for AM3352-som on my repository.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: thom_nic on February 13, 2017, 04:26:01 pm
Quote from: vinifr on February 09, 2017, 03:23:06 am
Maybe you disabled CONFIG_LEDS_TRIGGER_CPU.


Yup, it seems CONFIG_LEDS_TRIGGER_CPU is present in omap2plus_defconfig but not in bb.org_defconfig.

Here's my dts.  I started with a copy of am335x-olimex-som.dts, then added the pin re-mappings from Olimex's EVB pins from their patch.  Also noticed &aes and &sham were not enabled so did that as well.  Note I omitted the LCD pin definitions because I don't need it for my application but a default configuration might want to keep it.


/dts-v1/;

#include "am33xx.dtsi"
#include "am335x-som-common.dtsi"

/ {
model = "Olimex AM335x SOM";
compatible = "olimex,am335x-olimex-som", "ti,am33xx";

/* Override LED defs from am335x-som-common so it's correct for Olimex SOM:
* gpio3[18] is the on-SOM green LED1
* gpio3[20] is the EVB red LED2
* gpio3[21] is the EVB yellow LED3 */
leds {
led@1 {
label = "olimex-som:green:heartbeat";
gpios = <&gpio3 18 GPIO_ACTIVE_HIGH>;
};

led@2 {
label = "olimex-evb:red:led2";
gpios = <&gpio3 20 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "mmc0";
default-state = "off";
};

led@3 {
label = "olimex-evb:yellow:led3";
gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "cpu0";
default-state = "off";
};
};
};

&ldo3_reg {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-always-on;
};

&mmc1 {
vmmc-supply = <&vmmcsd_fixed>;
};

&am33xx_pinmux {
/* LCD pin definitions would go here - see am335x-olimex-som.dts */
};

/* Override pin defs in am335x-som-common.dtsi */
&user_leds_s0 {
pinctrl-single,pins = <
AM33XX_IOPAD(0x9a0, PIN_OUTPUT | MUX_MODE7 ) /* (B12) mcasp0_aclkr.gpio3[18] */
AM33XX_IOPAD(0x9a8, PIN_OUTPUT | MUX_MODE7 ) /* (D13) mcasp0_axr1.gpio3[20] */
AM33XX_IOPAD(0x9ac, PIN_OUTPUT | MUX_MODE7 ) /* (A14) mcasp0_ahclkx.gpio3[21] */
>;
};

&aes {
status = "okay";
};

&sham {
status = "okay";
}
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on February 13, 2017, 05:48:34 pm
Hi,

I meant, could you provide me your custom bb.org_defconfig? I'll make it the default defconfig for AM3352-som on my repository, since Robert Nelson does not accept a defconfig specific for a target.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: thom_nic on March 14, 2017, 04:59:40 pm
Hey I noticed some issues in dmesg, probably related to the DTS in the bb.org kernel:


[    0.647864] cpsw 4a100000.ethernet: Using 1 as Reserved VLAN for 0 slave
[    0.647948] cpsw 4a100000.ethernet: Missing dual_emac_res_vlan in DT.
[    0.647960] cpsw 4a100000.ethernet: Using 2 as Reserved VLAN for 1 slave
...
[    0.697664] pinctrl-single 44e10800.pinmux: pin 44e109a0.0 already requested by 48060000.mmc; cannot claim for leds
[    0.697689] pinctrl-single 44e10800.pinmux: pin-104 (leds) status -22
[    0.697704] pinctrl-single 44e10800.pinmux: could not request pin 104 (44e109a0.0) from group user_leds_s0  on device pinctrl-single
[    0.697717] leds-gpio leds: Error applying setting, reverse things back
...
[    0.723512] PM: Cannot get wkup_m3_ipc handle
...
[    0.762891] tps65217 0-0024: Failed to read revision register: -121
...
[    7.703680] musb-hdrc musb-hdrc.1.auto: musb_init_controller failed with status -517


The "Missing dual_emac_res_vlan in DT" is probably because Olimex' DTS defines &cpsw_emac[0,1] like so:


&cpsw_emac0 {
status = "okay";
phy_id = <&davinci_mdio>, <0>;
phy-mode = "mii";
dual_emac_res_vlan = <1>;
};

&cpsw_emac1 {
status = "okay";
phy_id = <&davinci_mdio>, <1>;
phy-mode = "mii";
dual_emac_res_vlan = <2>;
};


The issue about LED pinmux is probably because I'm trying to use gpio3[18,20,21] which are labelled LED1,2,3 on AM3352-SOM_RevC.pdf. 

In Olimex' am335x-olimex.dtsi:

mmc1_pins_default: mmc1_pins_default {
pinctrl-single,pins = <
0x100 ( PIN_INPUT | MUX_MODE0 ) /* (G17) mmc0_clk.mmc0_clk */
0x104 ( PIN_INPUT | MUX_MODE0 ) /* (G18) mmc0_cmd.mmc0_cmd */
0xfc ( PIN_INPUT | MUX_MODE0 ) /* (G16) mmc0_dat0.mmc0_dat0 */
0xf8 ( PIN_INPUT | MUX_MODE0 ) /* (G15) mmc0_dat1.mmc0_dat1 */
0xf4 ( PIN_INPUT | MUX_MODE0 ) /* (F18) mmc0_dat2.mmc0_dat2 */
0xf0 ( PIN_INPUT_PULLUP | MUX_MODE0 ) /* (F17) mmc0_dat3.mmc0_dat3 */
0x160 ( PIN_INPUT | MUX_MODE7 ) /* (C15) spi0_cs1.mmc0_sdcd */
>;
};


Versus am335x-som-common.dtsi in the beaglebone kernel sources:

mmc1_pins_default: pinmux_mmc1_pins {
pinctrl-single,pins = <
0x0F0 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat3.mmc0_dat3 */
0x0F4 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat2.mmc0_dat2 */
0x0F8 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat1.mmc0_dat1 */
0x0FC (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat0.mmc0_dat0 */
0x100 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_clk.mmc0_clk */
0x104 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_cmd.mmc0_cmd */
0x1A0 (PIN_INPUT_PULLUP | MUX_MODE7) /* mcasp0_aclkr.gpio3_18 <--- THIS ONE */
0x160 (PIN_INPUT | MUX_MODE7) /* spi0_cs1.gpio0_6 */
>;
};


The tps65217 error I'm guessing is because I'm not using that component for power management.  I will see if I can simply delete that node from my device tree.

Finally, I'm not sure what to do about the "musb-hdrc musb-hdrc.1.auto: musb_init_controller failed with status -517" error - that may have to do with some extra USB drivers which should not be enabled, I am not sure.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: vinifr on April 13, 2017, 01:50:09 pm
Hi,

Sorry, I don't have investigated these problems carefully yet.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: laser_dude on October 21, 2017, 08:49:48 pm
Hello. Has anyone had this working with the display? I was able to successfully get the beaglebone 4.4 kernel running, and I'm able to SSH into my Olimex board. However, there is no display (neither VGA nor LCD). Is there something I missed? Thanks.
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: sunnywilson09 on May 27, 2020, 08:35:43 pm
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 :) .
Title: Re: Support for Olimex AM3352-SOM in beaglebone kernel
Post by: JohnS on May 28, 2020, 07:39:40 pm
Does it even support the Olimex board?

John