[OpenWrt-Devel] [PATCH 2/2 v3] linux: add support of Synopsys ARC770-based boards

Alexey Brodkin Alexey.Brodkin at synopsys.com
Wed Nov 4 12:22:29 EST 2015


Hi Jonas,

On Wed, 2015-11-04 at 13:06 +0100, Jonas Gorski wrote:
> Hi,
> 
> On Tue, Nov 3, 2015 at 12:27 AM, Alexey Brodkin
> <Alexey.Brodkin at synopsys.com> wrote:

> > This patch introduces support of new boards with ARC cores.
> > 
> >  [1] Synopsys SDP board
> >      This is a new-generation development board from Synopsys that
> >      consists of base-board and CPU tile-board (which might have a real
> >      ASIC or FPGA with CPU image).
> >      It sports a lot of DesignWare peripherals like GMAC, USB, SPI, I2C
> >      etc and is intended to be used for early development of ARC-based
> >      products.
> > 
> >  [2] nSIM
> >      This is a virtual board implemented in Synopsys proprietary
> >      software simulator (even though available for free for open source
> >      community). This board has only serial port as a peripheral and so
> >      it is meant to be used for runtime testing which is especially
> >      useful during bring-up of new tools and platforms.
> >      What's also important ARC cores are very configurable so there're
> >      many variations of options like cache sizes, their line lengths,
> >      additional hardware blocks like multipliers, dividers etc. And this
> >      board could be used to make sure built software still runs on
> >      different HW configurations.
> > 
> > Cc: Felix Fietkau <nbd at openwrt.org>
> > Cc: Jo-Philipp Wich <jow at openwrt.org>
> > Signed-off-by: Alexey Brodkin <abrodkin at synopsys.com>
> > ---
> > diff --git a/target/linux/arc770/base-files/etc/uci-defaults/02_network b/target/linux/arc770/base-files/etc/uci
> > -defaults/02_network
> > new file mode 100644
> > index 0000000..7db8451
> > --- /dev/null
> > +++ b/target/linux/arc770/base-files/etc/uci-defaults/02_network
> > @@ -0,0 +1,23 @@
> > +#!/bin/sh
> > +#
> > +# Copyright (C) 2015 OpenWrt.org
> > +#
> > +
> > +[ -e /etc/config/network ] && exit 0
> > +
> > +touch /etc/config/network
> > +
> > +. /lib/arc.sh
> > +. /lib/functions/uci-defaults.sh
> > +
> > +ucidef_set_interface_loopback
> > +
> > +case "$( arc_board_name )" in
> > +"arc-sdp"*)
> > +       ucidef_set_interface_wan "eth0"
> 
> If you only have one interface at all, it is usually better to make it
> lan/dhcp, else default firewall rules will prevent you from logging in
> through http/ssh. You can either borrow kirkwoods set_lan_dhcp (and
> maybe move that with a better name to base-files), or use
> ucidef_set_interface_raw to configure it appropriately.

Corrrect. I used ucidef_set_interface_wan as a "hack" to get its
settings automatically via DHCP.

So thanks a lot for pointing to better options.
For me ucidef_set_interface_raw looks simpler and cleaner
so I'll go with:
---------------->8------------------
ucidef_set_interface_raw "lan" "eth0" "dhcp"
---------------->8------------------
as it is done in realview.

> > +       ;;
> > +esac
> > +
> > +uci commit network
> > +
> > +exit 0
> > diff --git a/target/linux/arc770/base-files/lib/arc.sh b/target/linux/arc770/base-files/lib/arc.sh
> > new file mode 100644
> > index 0000000..b15e94b
> > --- /dev/null
> > +++ b/target/linux/arc770/base-files/lib/arc.sh
> > @@ -0,0 +1,76 @@
> > +#!/bin/sh
> > +#
> > +# Copyright (C) 2015 OpenWrt.org
> > +#
> > +
> > +# defaults
> > +ARC_BOARD_NAME="generic"
> > +ARC_BOARD_MODEL="Generic arc board"
> > +
> > +arc_board_detect() {
> > +       local board
> > +       local model
> > +
> > +       [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
> > +
> > +       model="$( cat /proc/device-tree/compatible )"
> > +
> > +       # We cannot just use "model" as it is because in case of SDP board
> 
> ePAPR says your dts root nodes must have a "model" property that
> uniquely identifies the board. I see that is currently missing even in
> upstream, so please fix your dts files. Then you won't need to grep in
> the compatible. On a side node, ePAPR also says that the recommended
> format is the same as compatible but .. *looks at arm* .. apparently
> nobody does that.

Indeed "model" is a required property.
So thanks for that suggestion.

Then we'll have:
---------------->8------------------
compatible = "snps,arc-sdp";
model = "snps,axs101";
---------------->8------------------
which looks for sure much better!

Will do this for starters here in OpenWRT and will submit a patch upstream
in Linux kernel.

> 
> > +       # it will be wet with "snps,axs101snps,arc-sdp" which is
> > +       # concatenation of "snps,axs101" and "snps,arc-sdp".
> > +       if cat /proc/device-tree/compatible | grep -q "snps,arc-sdp"; then
> > +               board="arc-sdp";
> > +       fi
> > +
> > +       if cat /proc/device-tree/compatible | grep -q "snps,axs101"; then
> > +               model="axs101";
> > +       fi
> > +
> > +       if cat /proc/device-tree/compatible | grep -q "snps,nsim"; then
> > +               board="nsim";
> > +       fi
> > +
> > +       if [ "$board" != "" ]; then
> > +               ARC_BOARD_NAME="$board"
> > +       fi
> > +
> > +       if [ "$model" != "" ]; then
> > +               ARC_BOARD_MODEL="$model"
> > +       fi
> > +
> > +       echo "$ARC_BOARD_NAME" > /tmp/sysinfo/board_name
> > +       echo "$ARC_BOARD_MODEL" > /tmp/sysinfo/model
> > +       echo "Detected $ARC_BOARD_NAME // $ARC_BOARD_MODEL"
> > +}
> > +
> > +arc_board_name() {
> > +       local name
> > +
> > +       [ -f /tmp/sysinfo/board_name ] && name="$(cat /tmp/sysinfo/board_name)"
> > +       [ -z "$name" ] && name="unknown"
> > +
> > +       echo "$name"
> > +}
> > +
> > +arc_tty_setup() {
> > +       local name
> > +       local tty_device
> > +
> > +       [ -f /tmp/sysinfo/board_name ] && name="$(cat /tmp/sysinfo/board_name)"
> > +       [ -z "$name" ] && name="unknown"
> > +
> > +       case "$name" in
> > +               "nsim")
> > +                       tty_device="ttyARC0"
> > +                       ;;
> > +
> > +               "arc-sdp")
> > +                       tty_device="ttyS3"
> 
> Why not parse this out of the cmdline?

Well actually this is sort of overkill indeed.
Because usually we reuse console device from kernel command line.

For example that's how it's done in Buildroot:
---------------->8------------------
# Put a getty on the serial port
console::respawn:/sbin/getty -L console 0 vt100
---------------->8------------------

But in OpenWRT looks like following construction should do
the same trick:
---------------->8------------------
::askconsole:/bin/ash --login
---------------->8------------------

And it happens in default inittab here:
package/base-files/files/etc/inittab

So looks like I just need to get rid of my inittab -
that's always good if default implementation might be used.

-Alexey
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list