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

Jonas Gorski jogo at openwrt.org
Wed Nov 11 06:19:21 EST 2015


Hi Alexey,

On Tue, Nov 10, 2015 at 5:40 PM, Alexey Brodkin
<Alexey.Brodkin at synopsys.com> wrote:
> Hi Jonas,
>
> On Tue, 2015-11-10 at 12:02 +0100, Jonas Gorski wrote:
>> Hi Alexey,
>>
>> On Sat, Nov 7, 2015 at 2:25 PM, Alexey Brodkin
>> <Alexey.Brodkin at synopsys.com> wrote:
>> > This patch introduces support of new boards with ARC cores.
>> (snip)
>>
>> > 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..17ce657
>> > --- /dev/null
>> > +++ b/target/linux/arc770/base-files/lib/arc.sh
>> > @@ -0,0 +1,49 @@
>> > +#!/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/model )"
>> > +
>> > +       # Extract just one "compatible" value out of "snps,axs101snps,arc-sdp"
>> > +       # which is a 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,nsim"; then
>> > +               board="nsim";
>> > +       fi
>>
>> I guess I wasn't clear enough, the idea of using the model property is
>> so that you can then just do
>>
>> case "$model" in
>> "Synopsys AXS101 Development Board";)
>>         board="arc-sdp";
>>         ;;
>> "Synopsys ARC770 nSIM simulator")
>>         board="nsim";
>>         ;;
>> esac
>
> Well my implementation was intentional.
> See we have 2 flavors of ARC SDP board: AXS101 and AXS103.
> They have the same base-board (where all peripherals really reside)
> and different CPU-cards: AXS101 sports CPU-card with ARC770-based ASIC;
> AXS103 sports CPU-card with ARC HS38 in FPGA.
>
> So I wanted to detect existence of ARC SDP base-board and then set
> say network interfaces according to available devices.
>
> And difference in CPU type is not important here because it has
> no impact on the board behavior.
>
> Makes any sense?

I see what you want, but the way you are doing it is quite error prone
and inefficient. If you insist on using the compatible, i suggest:

1. Extract the first one instead of grepping through the full
compatible set, so you don't need to invoke grep for each comparison
(also dropping the misuse of cat ;p).
2. Do a full string comparison instead of grep, else you will have a
hard time telling apart "foo,bar" and "foo,bar-variant".

So then it would be

compatible = /* magic */;

case "$compatible" in
"snps,arc-sdp")
        board="arc-sdp";
        ;;
"snps,nsim")
        board="arc-nsim";
        ;;
esac


Jonas
_______________________________________________
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