Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

#3903 closed defect (fixed)

raspberrypi2 libbsd 5-freebsd-12 does not build

Reported by: Chris Johns Owned by: Christian Mauderer <christian.mauderer@…>
Priority: high Milestone: 5.1
Component: network/libbsd Version: 5
Severity: blocker Keywords:
Cc: Blocked By:
Blocking:

Description (last modified by Chris Johns)

The build is failing with ...

/opt/work/rtems/5/lib/gcc/arm-rtems5/7.5.0/../../../../arm-rtems5/bin/ld: ./libbsd.a(rtems-kernel-nexus.c.18.o): in function `nexus_ofw_map_intr':
/opt/work/chris/rtems/rsb/rtems-source-builder.git/rtems/build/rtems-libbsd-v2b9172c9d42d056b6fb16d667091e2ee3ac64009-arm-rtems5-1/rtems-libbsd-2b9172c9d42d056b6fb16d667091e2ee3ac64009/build/arm-rtems5-raspberrypi2-default/../../rtemsbsd/rtems/rtems-kernel-nexus.c:359: undefined reference to `bsp_fdt_map_intr'
collect2: error: ld returned 1 exit status

Is something on master that needs to be back ported to the 5-freebsd-12 branch?

Attachments (1)

0001-bsp-raspberry-Add-a-bsp_fdt_map_intr.patch (1.8 KB) - added by Christian Mauderer on 03/10/20 at 07:52:10.
Untested patch for the problem.

Download all attachments as: .zip

Change History (9)

comment:1 Changed on 03/08/20 at 00:39:59 by Chris Johns

Description: modified (diff)

comment:2 Changed on 03/08/20 at 09:34:03 by Sebastian Huber

The bsp_fdt_map_intr() must be provided by the BSP, e.g. bsps/arm/beagle/start/bspstart.c.

comment:3 Changed on 03/08/20 at 21:16:06 by Christian Mauderer

The same bug happens for libbsd master. Niteesh recently enabled FDT support for this BSP (following my suggestion) to be able to support the console for Pi2 and Pi3. It seems that I missed that libbsd doesn't build anymore when reviewing the patches. So the bug is not in libbsd but in RTEMS.

comment:4 Changed on 03/08/20 at 21:50:56 by Christian Mauderer

And of course - like everything else on this chip family - the interrupts can't be simple on RPi. There are at least two groups. Interrupts from the GPU and ones from the normal system.

See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt?id=791d3ef2e11100449837dc0b6fe884e60ca3a484
and https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2836-l1-intc.txt?id=36464580e658019ac7be26a08c4679bee0454d2c

The interrupts in the device tree look like this:

    // GPIO - 49 to 52 in RTEMS
    interrupts = <2 17>, <2 18>, <2 19>, <2 20>;
    // USB - 9 in RTEMS
    interrupts = <1 9>;
    // Mailbox - most likely 65 in RTEMS
    interrupts = <0 1>;

So I assume it should be a mapping like follows (in pseudo code):

#define MAGIC_OFFSET_FOR_SECOND_LEVEL 32

    switch(first_number) {
    case 0:
        return second_number + BCM2835_IRQ_ID_BASIC_BASE_ID;
        break;
    case 1:
        return second_number;
        break;
    case 2:
        return second_number + MAGIC_OFFSET_FOR_SECOND_LEVEL;
        break;
    default:
        /* Handle invalid interrupt */
        break;
    }

comment:5 Changed on 03/09/20 at 06:27:45 by Sebastian Huber

At least it looks like the API can handle this.

comment:6 Changed on 03/10/20 at 07:51:33 by Christian Mauderer

I created a patch that should work. But I didn't have the time to test it yet. I'll test it in the next few days.

Changed on 03/10/20 at 07:52:10 by Christian Mauderer

Untested patch for the problem.

comment:7 Changed on 04/04/20 at 10:55:45 by Christian Mauderer

Sorry for the long delay: The patch works and delivers the correct results (tested for the three cases GPIO0, USB and MBOX mentioned above). I'll send it to the mailing list.

comment:8 Changed on 04/04/20 at 17:49:17 by Christian Mauderer <christian.mauderer@…>

Owner: set to Christian Mauderer <christian.mauderer@…>
Resolution: fixed
Status: newclosed

In [changeset:"bb8ae78d36d5a32f11404d194d47d8befdbe0664/rtems" bb8ae78/rtems]:

bsp/raspberry: Add a bsp_fdt_map_intr().

Fixes #3903

Note: See TracTickets for help on using tickets.