diff mbox series

[PATCH/next,4/5] solidrun/macchiatobin: add new board

Message ID 20171112201646.15558-5-geomatsi@gmail.com
State Changes Requested
Headers show
Series Add support for MacchiatoBin board | expand

Commit Message

Sergey Matyukevich Nov. 12, 2017, 8:16 p.m. UTC
Add MacchiatoBin board by SolidRun. This board is based on Marvell
Armada 8040 SoC. Board support package includes the following
two options: mainline and vendor BSPs.

Mainline BSP:
- Marvell ATF v1.3-armada-17.10 and its dependencies
- mainline U-Boot v2017.09
- mainline Linux kernel v4.13.11

Marvell BSP with more hardware support enabled:
- Marvell ATF v1.3-armada-17.10 and its dependencies
- vendor U-Boot based on v2017.03
- Marvell Linux kernel based v4.4.52

More details about this board are available on wiki:
- http://wiki.macchiatobin.net

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
---
 board/solidrun/macchiatobin/genimage.cfg         | 16 ++++++
 board/solidrun/macchiatobin/readme.txt           | 70 ++++++++++++++++++++++++
 configs/solidrun_macchiatobin_mainline_defconfig | 46 ++++++++++++++++
 configs/solidrun_macchiatobin_marvell_defconfig  | 48 ++++++++++++++++
 4 files changed, 180 insertions(+)
 create mode 100644 board/solidrun/macchiatobin/genimage.cfg
 create mode 100644 board/solidrun/macchiatobin/readme.txt
 create mode 100644 configs/solidrun_macchiatobin_mainline_defconfig
 create mode 100644 configs/solidrun_macchiatobin_marvell_defconfig

Comments

Baruch Siach Nov. 13, 2017, 12:27 p.m. UTC | #1
Hi Sergey,

On Sun, Nov 12, 2017 at 11:16:45PM +0300, Sergey Matyukevich wrote:
> Add MacchiatoBin board by SolidRun. This board is based on Marvell
> Armada 8040 SoC. Board support package includes the following
> two options: mainline and vendor BSPs.
> 
> Mainline BSP:
> - Marvell ATF v1.3-armada-17.10 and its dependencies
> - mainline U-Boot v2017.09
> - mainline Linux kernel v4.13.11

Thanks. For the mainline kernel BSP:

Tested-by: Baruch Siach <baruch@tkos.co.il>

I'll note though that 'df' crashes here consistently:

[  962.179129] df[1346]: unhandled level 2 translation fault (11) at 0x00000a74, esr 0x92000046, in busybox[400000+a4000]
[  962.190801] CPU: 0 PID: 1346 Comm: df Not tainted 4.13.11 #1
[  962.197869] Hardware name: Marvell 8040 MACHIATOBin (DT)
...

I have not investigated it any further.

A few more comments below.

> Marvell BSP with more hardware support enabled:
> - Marvell ATF v1.3-armada-17.10 and its dependencies
> - vendor U-Boot based on v2017.03
> - Marvell Linux kernel based v4.4.52
> 
> More details about this board are available on wiki:
> - http://wiki.macchiatobin.net
> 
> Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
> ---
>  board/solidrun/macchiatobin/genimage.cfg         | 16 ++++++
>  board/solidrun/macchiatobin/readme.txt           | 70 ++++++++++++++++++++++++
>  configs/solidrun_macchiatobin_mainline_defconfig | 46 ++++++++++++++++
>  configs/solidrun_macchiatobin_marvell_defconfig  | 48 ++++++++++++++++
>  4 files changed, 180 insertions(+)
>  create mode 100644 board/solidrun/macchiatobin/genimage.cfg
>  create mode 100644 board/solidrun/macchiatobin/readme.txt
>  create mode 100644 configs/solidrun_macchiatobin_mainline_defconfig
>  create mode 100644 configs/solidrun_macchiatobin_marvell_defconfig
> 
> diff --git a/board/solidrun/macchiatobin/genimage.cfg b/board/solidrun/macchiatobin/genimage.cfg
> new file mode 100644
> index 0000000000..fdcda368a2
> --- /dev/null
> +++ b/board/solidrun/macchiatobin/genimage.cfg
> @@ -0,0 +1,16 @@
> +image sdcard.img {
> +	hdimage {
> +	}
> +
> +	partition uboot {
> +		in-partition-table = "no"
> +		image = "flash-image.bin"
> +		offset = 0x200000
> +	}
> +
> +	partition rootfs {
> +		partition-type = 0x83
> +		offset = 0x2200000
> +		image = "rootfs.ext4"
> +	}
> +}
> diff --git a/board/solidrun/macchiatobin/readme.txt b/board/solidrun/macchiatobin/readme.txt
> new file mode 100644
> index 0000000000..7bab5aca3c
> --- /dev/null
> +++ b/board/solidrun/macchiatobin/readme.txt
> @@ -0,0 +1,70 @@
> +Intro
> +=====
> +
> +This default configuration will allow you to start experimenting with the
> +buildroot environment for the MacchiatoBin board based on Marvell Armada
> +8040 SoC. Documentation for the board hardware and software
> +is available on wiki: http://wiki.macchiatobin.net
> +
> +This default configuration will bring-up the board and allow
> +access through the serial console.

Would be nice to note that the serial console is accessible at the micro-USB 
connector marked CON9.

> +
> +How to build
> +============
> +
> +There are two build options. The first option is mainline BSP:
> + - Linux v4.13.11
> + - U-Boot v2017.09
> +
> +The second option is vendor BSP which enables more hardware.
> +Marvell BSP is based on the following Linux and U-Boot versions:
> + - Linux v4.4.52
> + - U-Boot v2017.03
> +Sources are available on Marvell GitHub page:
> +   https://github.com/MarvellEmbeddedProcessors
> +
> +To use mainline BSP run the following commands:
> +    $ make solidrun_macchiatobin_mainline_defconfig
> +    $ make
> +
> +To use vendor BSP run the following commands:
> +    $ make solidrun_macchiatobin_marvell_defconfig
> +    $ make
> +
> +Note: you will need access to the internet to download
> +all the required sources.
> +
> +How to write the SD card
> +========================
> +
> +Once the build process is finished you will have an image
> +called "sdcard.img" in the output/images/ directory.
> +
> +Copy the bootable "sdcard.img" onto an SD card with "dd":
> +
> +  $ sudo dd if=output/images/sdcard.img of=/dev/sdX
> +  $ sudo sync

A somewhat faster one liner:

  sudo dd if=output/images/sdcard.img of=/dev/sdX bs=1M conv=fsync

> +Insert the micro SDcard in MacchiatoBin board and power it up.
> +The console is on the serial line, 115200 8N1.
> +
> +Note that MacchiatoBin board can be setup to load bootloader
> +from different sources including eMMC, SPI flash, and SD card.
> +Make sure to properly configure DIP switches SW1 and SW2
> +according to information available on wiki.

Would be nice to write here the DIP switches configuration for SD card boot:

SW2: 01110
SW1: 1xxxx

> +By default U-Boot will use environment from SPI flash. If SPI flash
> +is empty or it keeps legacy environment which is incompatible with
> +up-to-date mainline U-Boot and kernel, then the following
> +commands can be used to boot the board:
> +
> +=> env default -f -a
> +=> setenv bootargs console=ttyS0,115200 root=/dev/mmcblk1p1 rw rootwait
> +=> setenv bootdelay 2

This doesn't make much sense, since the user is now at the serial console 
already.

> +=> setenv fdt_addr 0x1000000
> +=> setenv fdt_high 0xffffffffffffffff
> +=> setenv fdt_name boot/armada-8040-mcbin.dtb
> +=> setenv kernel_addr 0x2000000
> +=> setenv image_name boot/Image
> +=> setenv bootcmd 'mmc dev 1; ext4load mmc 1:1 $kernel_addr $image_name; ext4load mmc 1:1 $fdt_addr $fdt_name; booti $kernel_addr - $fdt_addr'
> +=> boot

Having to type all that on the console is not nice. Unfortunately, current 
mainline U-Boot does not make it easy to override the SPI flash stored 
environment. But we can ease the pain somewhat. Create a uEnv.txt file, and 
store it in /boot. The sequence above can now be shortened to:

=> ext4load mmc 1:1 0x01700000 /boot/uEnv.txt
=> env import -t 0x01700000 $filesize
=> boot

The uEnv.txt file that I tested is attached.

baruch
Jan Kundrát Nov. 13, 2017, 12:51 p.m. UTC | #2
On pondělí 13. listopadu 2017 13:27:02 CET, Baruch Siach wrote:
> Create a uEnv.txt file, and store it in /boot.

Hi Baruch, does U-Boot auto-load this file on each and every boot? If not, 
than I suggest to name it differently -- perhaps uEnv-recovery.txt. I would 
expect that any change in a /boot/uEnv.txt somehow propagates to U-Boot 
environment during the next boot.

Cheers,
Jan
Baruch Siach Nov. 13, 2017, 1:13 p.m. UTC | #3
Hi Jan,

On Mon, Nov 13, 2017 at 01:51:01PM +0100, Jan Kundrát wrote:
> On pondělí 13. listopadu 2017 13:27:02 CET, Baruch Siach wrote:
> > Create a uEnv.txt file, and store it in /boot.
> 
> Hi Baruch, does U-Boot auto-load this file on each and every boot?

That depends on the default U-Boot environment. In the case of the 
Macchiatobin the built-in default is empty, and the SPI flash stored 
environment is not in a known state. So you must load uEnv.txt manually on 
every boot to make sure your environment is in a known state.

> If not, than I suggest to name it differently -- perhaps uEnv-recovery.txt. 
> I would expect that any change in a /boot/uEnv.txt somehow propagates to 
> U-Boot environment during the next boot.

That's a good idea.

baruch
Baruch Siach Nov. 13, 2017, 2:52 p.m. UTC | #4
Hi Sergey,

On Sun, Nov 12, 2017 at 11:16:45PM +0300, Sergey Matyukevich wrote: 
> diff --git a/configs/solidrun_macchiatobin_mainline_defconfig b/configs/solidrun_macchiatobin_mainline_defconfig
> new file mode 100644
> index 0000000000..ab82865a0d
> --- /dev/null
> +++ b/configs/solidrun_macchiatobin_mainline_defconfig
> @@ -0,0 +1,46 @@
> +BR2_aarch64=y
> +
> +#
> +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_13=y
> +BR2_TARGET_GENERIC_HOSTNAME="mcbin"
> +BR2_TARGET_GENERIC_ISSUE="Welcome to Buildroot for Marvell MacchiatoBin"
> +
> +# Firmware
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_GIT=y
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_URL="https://github.com/MarvellEmbeddedProcessors/atf-marvell.git"
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_VERSION="atf-v1.3-armada-17.10"
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="a80x0_mcbin"
> +BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="USE_COHERENT_MEM=0"
> +
> +BR2_TARGET_ARMADA_FIRMWARE=y
> +BR2_TARGET_ARMADA_FIRMWARE_IMAGE="mrvl_scp_bl2_8040.img"
> +BR2_TARGET_ARMADA_FIRMWARE_VERSION="binaries-marvell-armada-17.10"

It turns out that this firmware is not required, at least for the mainline 
kernel. The system boots just fine without it. It might be needed for the 
Marvell provided kernel. I didn't check that.

baruch
Sergey Matyukevich Nov. 13, 2017, 7:51 p.m. UTC | #5
> > +BR2_TARGET_ARMADA_FIRMWARE=y
> > +BR2_TARGET_ARMADA_FIRMWARE_IMAGE="mrvl_scp_bl2_8040.img"
> > +BR2_TARGET_ARMADA_FIRMWARE_VERSION="binaries-marvell-armada-17.10"
> 
> It turns out that this firmware is not required, at least for the mainline 
> kernel. The system boots just fine without it. It might be needed for the 
> Marvell provided kernel. I didn't check that.

Thanks for checking! I followed BSP HOWTO at http://wiki.macchiatobin.net.
But it looks slightly outdated since it refers to 17.06 versions for all
the repositories. I will check both mainline and vendor BSPs to clarify
whether it is needed at all.

Regards,
Sergey
Sergey Matyukevich Nov. 13, 2017, 8:06 p.m. UTC | #6
> > Add MacchiatoBin board by SolidRun. This board is based on Marvell
> > Armada 8040 SoC. Board support package includes the following
> > two options: mainline and vendor BSPs.
> > 
> > Mainline BSP:
> > - Marvell ATF v1.3-armada-17.10 and its dependencies
> > - mainline U-Boot v2017.09
> > - mainline Linux kernel v4.13.11
> 
> Thanks. For the mainline kernel BSP:
> 
> Tested-by: Baruch Siach <baruch@tkos.co.il>
> 
> I'll note though that 'df' crashes here consistently:
> 
> [  962.179129] df[1346]: unhandled level 2 translation fault (11) at 0x00000a74, esr 0x92000046, in busybox[400000+a4000]
> [  962.190801] CPU: 0 PID: 1346 Comm: df Not tainted 4.13.11 #1
> [  962.197869] Hardware name: Marvell 8040 MACHIATOBin (DT)
> ...
> 
> I have not investigated it any further.

This issue is not specific to MacchiatoBin board. I observed it last week
testing images for another arm64 board - Orange Pi Zero Plus2 board.
I haven't investigated it yet.

Meanwhile this is not the only problem with mainline BSP. It turned out that
network interfaces do not work properly neither on v4.13.11 nor in fresh v4.14.
Kernel v4.13.11 doesn't enable them in DTS. Kernel v4.14 does enable them,
but I couldn't make them work: Tx looks ok, but no Rx. Meanwhile on kernel from
devel-4.14/all branch from https://github.com/MISL-EBU-System-SW/mainline-public
management 1Gb interface appears to be working fine.

I plan to bump kernel version to 4.14 and find minimal set of patches needed to
enable networking.

> > +This default configuration will allow you to start experimenting with the
> > +buildroot environment for the MacchiatoBin board based on Marvell Armada
> > +8040 SoC. Documentation for the board hardware and software
> > +is available on wiki: http://wiki.macchiatobin.net
> > +
> > +This default configuration will bring-up the board and allow
> > +access through the serial console.
> 
> Would be nice to note that the serial console is accessible at the micro-USB 
> connector marked CON9.

Ok, will do.

> > +How to write the SD card
> > +========================
> > +
> > +Once the build process is finished you will have an image
> > +called "sdcard.img" in the output/images/ directory.
> > +
> > +Copy the bootable "sdcard.img" onto an SD card with "dd":
> > +
> > +  $ sudo dd if=output/images/sdcard.img of=/dev/sdX
> > +  $ sudo sync
> 
> A somewhat faster one liner:
> 
>   sudo dd if=output/images/sdcard.img of=/dev/sdX bs=1M conv=fsync

Ok, thanks! Will do.


> > +Insert the micro SDcard in MacchiatoBin board and power it up.
> > +The console is on the serial line, 115200 8N1.
> > +
> > +Note that MacchiatoBin board can be setup to load bootloader
> > +from different sources including eMMC, SPI flash, and SD card.
> > +Make sure to properly configure DIP switches SW1 and SW2
> > +according to information available on wiki.
> 
> Would be nice to write here the DIP switches configuration for SD card boot:
> 
> SW2: 01110
> SW1: 1xxxx

Good point. Will do.


> > +=> setenv fdt_addr 0x1000000
> > +=> setenv fdt_high 0xffffffffffffffff
> > +=> setenv fdt_name boot/armada-8040-mcbin.dtb
> > +=> setenv kernel_addr 0x2000000
> > +=> setenv image_name boot/Image
> > +=> setenv bootcmd 'mmc dev 1; ext4load mmc 1:1 $kernel_addr $image_name; ext4load mmc 1:1 $fdt_addr $fdt_name; booti $kernel_addr - $fdt_addr'
> > +=> boot
> 
> Having to type all that on the console is not nice. Unfortunately, current 
> mainline U-Boot does not make it easy to override the SPI flash stored 
> environment. But we can ease the pain somewhat. Create a uEnv.txt file, and 
> store it in /boot. The sequence above can now be shortened to:
> 
> => ext4load mmc 1:1 0x01700000 /boot/uEnv.txt
> => env import -t 0x01700000 $filesize
> => boot

Indeed, that will be easier for quick start.

Regards,
Sergey
Thomas Petazzoni Nov. 13, 2017, 10:36 p.m. UTC | #7
Hello,

On Mon, 13 Nov 2017 23:06:10 +0300, Sergey Matyukevich wrote:

> This issue is not specific to MacchiatoBin board. I observed it last week
> testing images for another arm64 board - Orange Pi Zero Plus2 board.
> I haven't investigated it yet.
> 
> Meanwhile this is not the only problem with mainline BSP. It turned out that
> network interfaces do not work properly neither on v4.13.11 nor in fresh v4.14.
> Kernel v4.13.11 doesn't enable them in DTS. Kernel v4.14 does enable them,
> but I couldn't make them work: Tx looks ok, but no Rx. Meanwhile on kernel from
> devel-4.14/all branch from https://github.com/MISL-EBU-System-SW/mainline-public
> management 1Gb interface appears to be working fine.

The fact that network interfaces don't work on mcbin with the stock
4.14 is not expected. I've added in Cc: my colleague Antoine Ténart who
worked on this topic.

Antoine, do you know which patches are missing in 4.14 ?

Thanks!

Thomas
Antoine Tenart Nov. 14, 2017, 7:41 a.m. UTC | #8
Hello Thomas, Sergey,

On Mon, Nov 13, 2017 at 11:36:28PM +0100, Thomas Petazzoni wrote:
> On Mon, 13 Nov 2017 23:06:10 +0300, Sergey Matyukevich wrote:
> 
> > Meanwhile this is not the only problem with mainline BSP. It turned out that
> > network interfaces do not work properly neither on v4.13.11 nor in fresh v4.14.
> > Kernel v4.13.11 doesn't enable them in DTS. Kernel v4.14 does enable them,
> > but I couldn't make them work: Tx looks ok, but no Rx. Meanwhile on kernel from
> > devel-4.14/all branch from https://github.com/MISL-EBU-System-SW/mainline-public
> > management 1Gb interface appears to be working fine.
> 
> The fact that network interfaces don't work on mcbin with the stock
> 4.14 is not expected. I've added in Cc: my colleague Antoine Ténart who
> worked on this topic.
> 
> Antoine, do you know which patches are missing in 4.14 ?

The 4.14 network support for the mcbin is partial but you should be able
to use 2 out of the 4 interfaces in the mode U-Boot configured them.
tl;dr; eth0 in 10G (sfp) and eth2 in 1G.

See https://elinux.org/Marvell_EBU:MacchiatoBin for the network
interfaces description.

- eth0 should work on 10G (the sfp cage).
- eth1 is not working because of a bug which is not cleanly fixed yet.
  The devel-4.14/all branch contains a workaround (which is not suitable
  for the upstream kernel), see 0968cd30a0d4 ("DO NOT UPSTREAM: phy: marvell10g:
  Do not reset PHY autoneg for 10G KR mode"). With this patch it should
  work on 10G (sfp) with the 4.14 kernel.
- eth2 should be working just fine on 1G.
- eth3 is not supported yet, in both the upstream kernel and the
  devel-4.14/all branch.

One feature not supported in the upstream 4.14 kernel is the dynamic
reconfiguration of the interfaces, i.e. the ability to switch from/to
10G to/from 1G on eth0 and eth1 given what's connected. To do this you
would need a few device tree patches from devel-4.14/all (which will be
in 4.15):
- 0f0dfbec373e ("arm64: dts: marvell: extend the cp110 syscon register area length")
- c90dab5d2bf4 ("arm64: dts: marvell: add comphy nodes on cp110 master and slave")
- 26c08c06b827 ("arm64: dts: marvell: mcbin: add comphy references to Ethernet ports")

Also, please note the network PHY drivers are not selected to be
built-in in the arm64 upstream defconfig, so you should probably
select both CONFIG_MARVELL_PHY and CONFIG_MARVELL_10G_PHY. This is done
in the devel-4.14/all arm64 defconfig.

Antoine
Sergey Matyukevich Nov. 14, 2017, 9:20 a.m. UTC | #9
Hello Antoine,

> > > Meanwhile this is not the only problem with mainline BSP. It turned out that
> > > network interfaces do not work properly neither on v4.13.11 nor in fresh v4.14.
> > > Kernel v4.13.11 doesn't enable them in DTS. Kernel v4.14 does enable them,
> > > but I couldn't make them work: Tx looks ok, but no Rx. Meanwhile on kernel from
> > > devel-4.14/all branch from https://github.com/MISL-EBU-System-SW/mainline-public
> > > management 1Gb interface appears to be working fine.
> > 
> > The fact that network interfaces don't work on mcbin with the stock
> > 4.14 is not expected. I've added in Cc: my colleague Antoine Ténart who
> > worked on this topic.
> > 
> > Antoine, do you know which patches are missing in 4.14 ?
> 
> The 4.14 network support for the mcbin is partial but you should be able
> to use 2 out of the 4 interfaces in the mode U-Boot configured them.
> tl;dr; eth0 in 10G (sfp) and eth2 in 1G.
> 
> See https://elinux.org/Marvell_EBU:MacchiatoBin for the network
> interfaces description.
> 
> - eth0 should work on 10G (the sfp cage).
> - eth1 is not working because of a bug which is not cleanly fixed yet.
>   The devel-4.14/all branch contains a workaround (which is not suitable
>   for the upstream kernel), see 0968cd30a0d4 ("DO NOT UPSTREAM: phy: marvell10g:
>   Do not reset PHY autoneg for 10G KR mode"). With this patch it should
>   work on 10G (sfp) with the 4.14 kernel.
> - eth2 should be working just fine on 1G.
> - eth3 is not supported yet, in both the upstream kernel and the
>   devel-4.14/all branch.
> 
> One feature not supported in the upstream 4.14 kernel is the dynamic
> reconfiguration of the interfaces, i.e. the ability to switch from/to
> 10G to/from 1G on eth0 and eth1 given what's connected. To do this you
> would need a few device tree patches from devel-4.14/all (which will be
> in 4.15):
> - 0f0dfbec373e ("arm64: dts: marvell: extend the cp110 syscon register area length")
> - c90dab5d2bf4 ("arm64: dts: marvell: add comphy nodes on cp110 master and slave")
> - 26c08c06b827 ("arm64: dts: marvell: mcbin: add comphy references to Ethernet ports")
> 
> Also, please note the network PHY drivers are not selected to be
> built-in in the arm64 upstream defconfig, so you should probably
> select both CONFIG_MARVELL_PHY and CONFIG_MARVELL_10G_PHY. This is done
> in the devel-4.14/all arm64 defconfig.

Thanks for detailed summary of mcbin networking support. However it sill looks
like there is a missing piece here. I have checked behavior of both mainline 4.14
(516fb7f2e73dcc) and marvell-mainline devel-4.14/all (a3d9036af3c6033). I did no
changes to kernel/dts/defconfig at all other than enabling Marvell PHYs for mainline
kernel. But the result is still the same: 1Gb eth2 interface works with devel-4.14/all,
but doesn't work with mainline. Though PHY is recognized and attached, mii-diag also
provides sane report. Tx packet counter in ifconfig is increased, but no packets
on wire.

Probably I am missing something obvious. I will do more checks and comparisons
later this week. Setup is just the same: mainline U-Boot 2017.09 and images
built using this patchset.

Regards,
Sergey
Antoine Tenart Nov. 14, 2017, 9:42 a.m. UTC | #10
Hi Sergey,

On Tue, Nov 14, 2017 at 12:20:24PM +0300, Sergey Matyukevich wrote:
> 
> Thanks for detailed summary of mcbin networking support. However it sill looks
> like there is a missing piece here. I have checked behavior of both mainline 4.14
> (516fb7f2e73dcc) and marvell-mainline devel-4.14/all (a3d9036af3c6033). I did no
> changes to kernel/dts/defconfig at all other than enabling Marvell PHYs for mainline
> kernel. But the result is still the same: 1Gb eth2 interface works with devel-4.14/all,
> but doesn't work with mainline. Though PHY is recognized and attached, mii-diag also
> provides sane report. Tx packet counter in ifconfig is increased, but no packets
> on wire.
> 
> Probably I am missing something obvious. I will do more checks and comparisons
> later this week. Setup is just the same: mainline U-Boot 2017.09 and images
> built using this patchset.

Note that I never tested with the upstream U-Boot. Do the interfaces
work in U-Boot?

Antoine
Sergey Matyukevich Nov. 14, 2017, 7:11 p.m. UTC | #11
Hi Baruch,

> > > +BR2_TARGET_ARMADA_FIRMWARE=y
> > > +BR2_TARGET_ARMADA_FIRMWARE_IMAGE="mrvl_scp_bl2_8040.img"
> > > +BR2_TARGET_ARMADA_FIRMWARE_VERSION="binaries-marvell-armada-17.10"
> > 
> > It turns out that this firmware is not required, at least for the mainline 
> > kernel. The system boots just fine without it. It might be needed for the 
> > Marvell provided kernel. I didn't check that.
> 
> Thanks for checking! I followed BSP HOWTO at http://wiki.macchiatobin.net.
> But it looks slightly outdated since it refers to 17.06 versions for all
> the repositories. I will check both mainline and vendor BSPs to clarify
> whether it is needed at all.

I tried to build both vendor and mainline BSP w/o this firmware. Both appear
to be working fine without this firmware. According to ATF firmware design doc
https://github.com/ARM-software/arm-trusted-firmware, this SCP_BL2 image is
for platform-specific power/clock/reset/sysctl coprocessor available on
some systems.

As I mentioned, I didn't notice any issues during quick smoke test of images
built w/o SCP_BL2 firmware. However, according to MacchiatoBin wiki page
quite a few Linux power management features depend on this firmware:
http://wiki.macchiatobin.net/tiki-index.php?page=Enable+Power+Management+on+MACCHIATObin

So it makes a lot of sense to keep using it. To summarize, I would prefer
to keep this package, fixing all the issues.

Regards,
Sergey
Sergey Matyukevich Nov. 14, 2017, 8:27 p.m. UTC | #12
Hi Antoine,

> > Thanks for detailed summary of mcbin networking support. However it sill looks
> > like there is a missing piece here. I have checked behavior of both mainline 4.14
> > (516fb7f2e73dcc) and marvell-mainline devel-4.14/all (a3d9036af3c6033). I did no
> > changes to kernel/dts/defconfig at all other than enabling Marvell PHYs for mainline
> > kernel. But the result is still the same: 1Gb eth2 interface works with devel-4.14/all,
> > but doesn't work with mainline. Though PHY is recognized and attached, mii-diag also
> > provides sane report. Tx packet counter in ifconfig is increased, but no packets
> > on wire.
> > 
> > Probably I am missing something obvious. I will do more checks and comparisons
> > later this week. Setup is just the same: mainline U-Boot 2017.09 and images
> > built using this patchset.
> 
> Note that I never tested with the upstream U-Boot. Do the interfaces
> work in U-Boot?

No, interfaces do not work in U-Boot. Probably U-Boot matters,
but even with the same mainline U-Boot interface eth2 works
just fine on devel-4.14/all kernel.

By the way, could you please advise how to switch eth0
from SFP to RJ45 when using mainline kernel 4.14 ?

Regards,
Sergey
Antoine Tenart Nov. 14, 2017, 8:53 p.m. UTC | #13
Hi Sergey,

On Tue, Nov 14, 2017 at 11:27:00PM +0300, Sergey Matyukevich wrote:
> 
> No, interfaces do not work in U-Boot. Probably U-Boot matters,
> but even with the same mainline U-Boot interface eth2 works
> just fine on devel-4.14/all kernel.

This is expected. The mainline 4.14 kernel relies on the U-Boot
configuration for some parts while the devel-4.14/all contains all the
patches to configure the network interfaces (+ comphy) from scratch.

So, it seems to me the upstream U-Boot 2017.09 has an issue while
configuring the network interface. There are chances the issue is within
the comphy configuration / driver in this U-Boot version.

> By the way, could you please advise how to switch eth0
> from SFP to RJ45 when using mainline kernel 4.14 ?

You need to apply the dt patches I provided. You should then be able to
use eth0 and eth1 with either an SFP or an RJ45 cable, depending on
what's (dynamically) connected. To sum up, you just need to plugin
either the SFP or the RJ45 cable to start using the interface in the
right mode. You can switch from one to the other without rebooting the
board.

To get this board supported in Buildroot with an upstream kernel, I
would suggest to put the device tree patches I gave you, so that the
kernel can not rely on the bootloader configuration. And as soon as 4.15
is out the patches can be removed from Buildroot.

Antoine
Sergey Matyukevich Nov. 15, 2017, 9:20 p.m. UTC | #14
Hi Antoine,

Thanks for the update on upstream status of this board.

> > By the way, could you please advise how to switch eth0
> > from SFP to RJ45 when using mainline kernel 4.14 ?
> 
> You need to apply the dt patches I provided. You should then be able to
> use eth0 and eth1 with either an SFP or an RJ45 cable, depending on
> what's (dynamically) connected. To sum up, you just need to plugin
> either the SFP or the RJ45 cable to start using the interface in the
> right mode. You can switch from one to the other without rebooting the
> board.
> 
> To get this board supported in Buildroot with an upstream kernel, I
> would suggest to put the device tree patches I gave you, so that the
> kernel can not rely on the bootloader configuration. And as soon as 4.15
> is out the patches can be removed from Buildroot.

With those 3 dts patches J5 management interface is working fine
even with upstream U-Boot. So I will add those patches to board
files for the time being, just to enable network access to the board
right out of the box.

Regards,
Sergey
diff mbox series

Patch

diff --git a/board/solidrun/macchiatobin/genimage.cfg b/board/solidrun/macchiatobin/genimage.cfg
new file mode 100644
index 0000000000..fdcda368a2
--- /dev/null
+++ b/board/solidrun/macchiatobin/genimage.cfg
@@ -0,0 +1,16 @@ 
+image sdcard.img {
+	hdimage {
+	}
+
+	partition uboot {
+		in-partition-table = "no"
+		image = "flash-image.bin"
+		offset = 0x200000
+	}
+
+	partition rootfs {
+		partition-type = 0x83
+		offset = 0x2200000
+		image = "rootfs.ext4"
+	}
+}
diff --git a/board/solidrun/macchiatobin/readme.txt b/board/solidrun/macchiatobin/readme.txt
new file mode 100644
index 0000000000..7bab5aca3c
--- /dev/null
+++ b/board/solidrun/macchiatobin/readme.txt
@@ -0,0 +1,70 @@ 
+Intro
+=====
+
+This default configuration will allow you to start experimenting with the
+buildroot environment for the MacchiatoBin board based on Marvell Armada
+8040 SoC. Documentation for the board hardware and software
+is available on wiki: http://wiki.macchiatobin.net
+
+This default configuration will bring-up the board and allow
+access through the serial console.
+
+How to build
+============
+
+There are two build options. The first option is mainline BSP:
+ - Linux v4.13.11
+ - U-Boot v2017.09
+
+The second option is vendor BSP which enables more hardware.
+Marvell BSP is based on the following Linux and U-Boot versions:
+ - Linux v4.4.52
+ - U-Boot v2017.03
+Sources are available on Marvell GitHub page:
+   https://github.com/MarvellEmbeddedProcessors
+
+To use mainline BSP run the following commands:
+    $ make solidrun_macchiatobin_mainline_defconfig
+    $ make
+
+To use vendor BSP run the following commands:
+    $ make solidrun_macchiatobin_marvell_defconfig
+    $ make
+
+Note: you will need access to the internet to download
+all the required sources.
+
+How to write the SD card
+========================
+
+Once the build process is finished you will have an image
+called "sdcard.img" in the output/images/ directory.
+
+Copy the bootable "sdcard.img" onto an SD card with "dd":
+
+  $ sudo dd if=output/images/sdcard.img of=/dev/sdX
+  $ sudo sync
+
+Insert the micro SDcard in MacchiatoBin board and power it up.
+The console is on the serial line, 115200 8N1.
+
+Note that MacchiatoBin board can be setup to load bootloader
+from different sources including eMMC, SPI flash, and SD card.
+Make sure to properly configure DIP switches SW1 and SW2
+according to information available on wiki.
+
+By default U-Boot will use environment from SPI flash. If SPI flash
+is empty or it keeps legacy environment which is incompatible with
+up-to-date mainline U-Boot and kernel, then the following
+commands can be used to boot the board:
+
+=> env default -f -a
+=> setenv bootargs console=ttyS0,115200 root=/dev/mmcblk1p1 rw rootwait
+=> setenv bootdelay 2
+=> setenv fdt_addr 0x1000000
+=> setenv fdt_high 0xffffffffffffffff
+=> setenv fdt_name boot/armada-8040-mcbin.dtb
+=> setenv kernel_addr 0x2000000
+=> setenv image_name boot/Image
+=> setenv bootcmd 'mmc dev 1; ext4load mmc 1:1 $kernel_addr $image_name; ext4load mmc 1:1 $fdt_addr $fdt_name; booti $kernel_addr - $fdt_addr'
+=> boot
diff --git a/configs/solidrun_macchiatobin_mainline_defconfig b/configs/solidrun_macchiatobin_mainline_defconfig
new file mode 100644
index 0000000000..ab82865a0d
--- /dev/null
+++ b/configs/solidrun_macchiatobin_mainline_defconfig
@@ -0,0 +1,46 @@ 
+BR2_aarch64=y
+
+#
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_13=y
+BR2_TARGET_GENERIC_HOSTNAME="mcbin"
+BR2_TARGET_GENERIC_ISSUE="Welcome to Buildroot for Marvell MacchiatoBin"
+
+# Firmware
+BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_GIT=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_URL="https://github.com/MarvellEmbeddedProcessors/atf-marvell.git"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_VERSION="atf-v1.3-armada-17.10"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="a80x0_mcbin"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="USE_COHERENT_MEM=0"
+
+BR2_TARGET_ARMADA_FIRMWARE=y
+BR2_TARGET_ARMADA_FIRMWARE_IMAGE="mrvl_scp_bl2_8040.img"
+BR2_TARGET_ARMADA_FIRMWARE_VERSION="binaries-marvell-armada-17.10"
+
+BR2_TARGET_ARMADA_DDR=y
+BR2_TARGET_ARMADA_DDR_VERSION="mv_ddr-armada-17.10"
+
+# U-Boot
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_BOARDNAME="mvebu_mcbin-88f8040"
+BR2_TARGET_UBOOT_CUSTOM_VERSION=y
+BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2017.09"
+
+# Kernel
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.13.11"
+BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="marvell/armada-8040-mcbin"
+BR2_LINUX_KERNEL_INSTALL_TARGET=y
+
+# rootfs
+BR2_TARGET_ROOTFS_TAR=y
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/solidrun/macchiatobin/genimage.cfg"
diff --git a/configs/solidrun_macchiatobin_marvell_defconfig b/configs/solidrun_macchiatobin_marvell_defconfig
new file mode 100644
index 0000000000..f47df89fb3
--- /dev/null
+++ b/configs/solidrun_macchiatobin_marvell_defconfig
@@ -0,0 +1,48 @@ 
+BR2_aarch64=y
+
+#
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_4=y
+BR2_TARGET_GENERIC_HOSTNAME="mcbin"
+BR2_TARGET_GENERIC_ISSUE="Welcome to Buildroot for Marvell MacchiatoBin"
+
+# Firmware
+BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_GIT=y
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_URL="https://github.com/MarvellEmbeddedProcessors/atf-marvell.git"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_VERSION="atf-v1.3-armada-17.10"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="a80x0_mcbin"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="USE_COHERENT_MEM=0"
+
+BR2_TARGET_ARMADA_FIRMWARE=y
+BR2_TARGET_ARMADA_FIRMWARE_IMAGE="mrvl_scp_bl2_8040.img"
+BR2_TARGET_ARMADA_FIRMWARE_VERSION="binaries-marvell-armada-17.10"
+
+BR2_TARGET_ARMADA_DDR=y
+BR2_TARGET_ARMADA_DDR_VERSION="mv_ddr-armada-17.10"
+
+# U-Boot
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_CUSTOM_GIT=y
+BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/MarvellEmbeddedProcessors/u-boot-marvell"
+BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="u-boot-2017.03-armada-17.10"
+BR2_TARGET_UBOOT_BOARDNAME="mvebu_mcbin-88f8040"
+
+# Kernel
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/MarvellEmbeddedProcessors/linux-marvell"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="linux-4.4.52-armada-17.10"
+BR2_LINUX_KERNEL_DEFCONFIG="mvebu_v8_lsp"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="marvell/armada-8040-mcbin"
+BR2_LINUX_KERNEL_INSTALL_TARGET=y
+
+# rootfs
+BR2_TARGET_ROOTFS_TAR=y
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/solidrun/macchiatobin/genimage.cfg"