RTEMS on Beaglebone Black

Angelo Fraietta newsgroups at smartcontroller.com.au
Mon Jul 27 01:38:04 UTC 2015


Greetings Steve, I have modified your code so the standard task only
toggles one LED and the interrupt on GPIO12 should toggle the other 3.
However, IO cannot for the life of me find which pin is GPIO12 so I can
test on the hardware. I have posted the code with the mods I made at the
bottom of this email

http://beagleboard.org/support/bone101

What physical pin should I be toggling to make it work?

Thanks

/*
 *  COPYRIGHT (c) 1989-2007.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <bsp.h>

#include "./testmacros.h"

#define GPIO_IRQSTATUS_0 0x2C
#define GPIO_IRQSTATUS_1 0x30

#define GPIO_IRQSTATUS_SET_0 0x34
#define GPIO_IRQSTATUS_SET_1 0x38
#define OE_ADDR 0x134
#define GPIO_DATAOUT 0x13C
#define GPIO_DATAIN 0x138
#define GPIO_RISINGDETECT 0x148
#define GPIO_FALLINGDETECT 0x14C

#define GPIO0_ADDR 0x44E07000
#define GPIO1_ADDR 0x4804C000
#define GPIO2_ADDR 0x481AC000
#define GPIO3_ADDR 0x481AF000

#define GPIO1_IRQn 99 //GPIO INT1A



rtems_id   Task_id[ 4 ];         /* array of task ids */
rtems_name Task_name[ 4 ];       /* array of task names */

rtems_task Test_task(
  rtems_task_argument task_index
)
{
  rtems_time_of_day time;
  rtems_interval    ticks;

  ticks = task_index * 2 * rtems_clock_get_ticks_per_second();

  for ( ; ; ) {
    (void) rtems_clock_get_tod( &time );
    /*if ( time.second >= 35 ) {
      puts( "*** END OF CLOCK TICK TEST ***" );
      //exit( 0 );
      while(1);
      }*/
    put_name( Task_name[ task_index ], FALSE );
    print_time( " - rtems_clock_get_tod - ", &time, "\n" );

    //Toggle GPIO. ISR will wake up on rising edge of this,
    // if P8_11 and P8_12 are jumped together.
    *(unsigned long *)(GPIO1_ADDR+GPIO_DATAOUT) ^= (1<<13);

    // toggle first led only
    *(unsigned long *)(GPIO1_ADDR+GPIO_DATAOUT) ^= ((1<<21);

    (void) rtems_task_wake_after( ticks );
  }
}

//ISR:
rtems_isr GPIO1_IRQHandler (rtems_vector_number vector)
{
  //Toggle other three LEDs here:
  *(unsigned long *)(GPIO1_ADDR+GPIO_DATAOUT) ^= ((1<<22)| (1<<23)
|(1<<24));

  //Clear interrupt:
  //Per AM335x technical reference manual, we can read IRQSTATUS,
  // and then write corresponding bits on IRQSTATUS to clear whichever one
was serviced.
  // in this application it's hard coded to number 12 so I just write that
bit.
  // For some reason writing IRQSTATUS value back to itself doesn't clear
the interrupt.
  unsigned long irqstat = *(unsigned long*)(GPIO1_ADDR + GPIO_IRQSTATUS_1);
  *(unsigned long*)(GPIO1_ADDR + GPIO_IRQSTATUS_1) = (1<<12);
  //*(unsigned long*)(GPIO1_ADDR + GPIO_IRQSTATUS_1) = irqstat;

}

rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_time_of_day time;

  //Enable all four LEDs as outputs (GPIO1_21, 22, 23, 24), and one line to
feed into IRQ line (I choose number 13):
  *(unsigned long *)(GPIO1_ADDR+OE_ADDR) &= ~((1<<21) | (1<<22) | (1<<23) |
(1<<24) | (1<<13));
  //Set all outputs LOW to start:
  *(unsigned long *)(GPIO1_ADDR+GPIO_DATAOUT) &= ~((1<<21) | (1<<22)|
(1<<23) | (1<<24) | (1<<13));

  puts( "\n\n*** GPIO IRQ Test by Steve Battazzo modified by Angelo
Fraietta***" );

  time.year   = 1988;
  time.month  = 12;
  time.day    = 31;
  time.hour   = 9;
  time.minute = 0;
  time.second = 0;
  time.ticks  = 0;

  (void) rtems_clock_set( &time );

  *(unsigned long *)(GPIO1_ADDR+GPIO_IRQSTATUS_SET_1) = (1<<12); //Enable
IRQ on GPIO1_12
  *(unsigned long *)(GPIO1_ADDR+GPIO_RISINGDETECT) |= (1<<12);   //Rising
detect on GPIO1_12

  //Install ISR
  rtems_status_code status = rtems_interrupt_handler_install(GPIO1_IRQn,
"GPIO", RTEMS_INTERRUPT_UNIQUE, \
  (rtems_interrupt_handler) GPIO1_IRQHandler, NULL);
  if (status != RTEMS_SUCCESSFUL)
  {
    puts("\r\nCould not install interrupt handler.\r\n");
  }
  else
  {
    puts("\r\nInterrupt handler installed.\r\n");
  }

  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );

  (void) rtems_task_create(
    Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ]
  );

  (void) rtems_task_start( Task_id[ 1 ], Test_task, 1 );

  (void) rtems_task_delete( RTEMS_SELF );
}

/**************** START OF CONFIGURATION INFORMATION ****************/

#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER

#define CONFIGURE_MAXIMUM_TASKS             4

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT_TASK_STACK_SIZE    (2 * RTEMS_MINIMUM_STACK_SIZE)

#define CONFIGURE_EXTRA_TASK_STACKS       (4 * RTEMS_MINIMUM_STACK_SIZE)

#define CONFIGURE_INIT
#include <rtems/confdefs.h>

/****************  END OF CONFIGURATION INFORMATION  ****************/



On Sat, Feb 21, 2015 at 4:26 AM, Steve B <sbattazzo at gmail.com> wrote:

> I think Xenomai (alongside Linux) works quite well on Beaglebone Black in
> my experience, so you might consider that. There's a pretty easy to follow
> guide on getting that up and running, also.
>
> I was considering RTEMS for a particular project but device drivers were
> not available and I wasn't sure about developing those from the ground up.
> I ended up having to port drivers for Xenomai eventually but I think the
> actual work of driver porting took less time than it would have with RTEMS.
> For an example of how to get an interrupt off of a GPIO, this white paper
> may be useful, it looks like they did something close to what you want to
> do: https://www.osadl.org/fileadmin/dam/rtlws/12/Brown.pdf
>
>
> On Mon, Feb 16, 2015 at 12:59 PM, angelo fraietta <
> newsgroups at smartcontroller.com.au> wrote:
>
>>
>> On 16/02/2015 5:34 PM, Mathew Benson wrote:
>>
>>> You're doing that in the CPU?  If all your doing is toggling a GPIO at a
>>> steady rate, why don't you just use the PRU and a PWM pin?  Or do you have
>>> RTEMS running in the PRU?
>>>
>>
>> That is all I did in the test to see what sort of performance I could get
>> just toggling a pin.  What I actually need to do is interrupt every 640ns,
>> and during that time, read 14 pins and store values in memory. Then, after
>> 16 of these, toggle a pint.  After 10ms of this, I need to raise an event
>> to read the 10ms worth of data, encode it, and send it via UDP.
>>
>>
>>
>>  Sent from my iPad
>>>
>>>  On Feb 16, 2015, at 12:15 AM, angelo fraietta <
>>>> newsgroups at smartcontroller.com.au> wrote:
>>>>
>>>> Greetings
>>>>
>>>> Have you got interrupts working on the GPIOs. Also, do you have any
>>>> sample of reading and writing to GPIO. I need to see whether it is going to
>>>> be fast enough,
>>>>
>>>> I ran a program (on linux) on beagle that used registers basically
>>>> toggling an output. EG
>>>> http://vabi-robotics.blogspot.com.au/2013/10/register-
>>>> access-to-gpios-of-beaglebone.html
>>>>
>>>> It toggled at rate of just under 1Mhz, and what was just doing a while
>>>> 1 loop. I did not look even look at interrupts there and did nothing else -
>>>> I didn't even do any reads of GPIO.
>>>>
>>>> I want to get interrupts happening at 1.56Mhz (preferable) and read 14
>>>> GPOI, sbut I could go to half the rate by reducing my sample rate.  The
>>>> beagle runs at 1Ghz, so I think it should be able to handle it.
>>>>
>>>>
>>>> Thanks
>>>>
>>>>
>>>>
>>>>  On 23/01/2015 4:19 PM, Ben Gras wrote:
>>>>> All,
>>>>>
>>>>> A while ago I finished the basics needed to use the beaglebones and
>>>>> beagleboards with RTEMS. The hardware support isn't very complete yet.
>>>>> The code is merged with RTEMS mainline though. My fork of rtems-tools
>>>>> and RSB is needed for help with building.
>>>>>
>>>>> Full details on how to build it are here:
>>>>> http://www.shrike-systems.com/beagleboard-xm-beaglebone-
>>>>> black-and-everything-else-rtems-on-the-beagles.html
>>>>>
>>>>> I hope you like it :-). Let me know if you'd like any followup.
>>>>>
>>>>> Cheers,
>>>>> Ben
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Jan 22, 2015 at 4:46 AM, angelo fraietta
>>>>> <newsgroups at smartcontroller.com.au> wrote:
>>>>>
>>>>>> Greetings
>>>>>> Does anyone know the status of the beaglebone port?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> ---
>>>>>> This email has been checked for viruses by Avast antivirus software.
>>>>>> http://www.avast.com
>>>>>>
>>>>>> _______________________________________________
>>>>>> users mailing list
>>>>>> users at rtems.org
>>>>>> http://lists.rtems.org/mailman/listinfo/users
>>>>>>
>>>>> --
>>>> Dr Angelo Fraietta
>>>> A.Eng, A.Mus.A, BA(Hons), Ph.D.
>>>>
>>>> PO Box 859
>>>> Hamilton NSW 2303
>>>>
>>>> Home Page
>>>>
>>>>
>>>> http://www.smartcontroller.com.au/
>>>>
>>>> There are those who seek knowledge for the sake of knowledge - that is
>>>> CURIOSITY
>>>> There are those who seek knowledge to be known by others - that is
>>>> VANITY
>>>> There are those who seek knowledge in order to serve - that is LOVE
>>>>     Bernard of Clairvaux (1090 - 1153)
>>>>
>>>>
>>>> ---
>>>> This email has been checked for viruses by Avast antivirus software.
>>>> http://www.avast.com
>>>>
>>>> _______________________________________________
>>>> users mailing list
>>>> users at rtems.org
>>>> http://lists.rtems.org/mailman/listinfo/users
>>>>
>>>
>> ---
>> This email has been checked for viruses by Avast antivirus software.
>> http://www.avast.com
>>
>> _______________________________________________
>> users mailing list
>> users at rtems.org
>> http://lists.rtems.org/mailman/listinfo/users
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20150727/463d492f/attachment.html>


More information about the users mailing list