Hi all,

Further to the patch I have just submitted I thought it would be useful for
any reviewers to have the following example programs and output as a
reference when reviewing the patch.

Thanks in advance for your review and feedback.

Regards,
James Fitzsimons
U-Boot SPL 2019.04-00002-g07d5700e21 (Mar 06 2020 - 11:24:55 -0600)
Trying to boot from MMC2
Loading Environment from EXT4... 
** Unable to use mmc 0:1 for loading the env **


U-Boot 2019.04-00002-g07d5700e21 (Mar 06 2020 - 11:24:55 -0600), Build: 
jenkins-github_Bootloader-Builder-137

CPU  : AM335X-GP rev 2.1
I2C:   ready
DRAM:  512 MiB
No match for driver 'omap_hsmmc'
No match for driver 'omap_hsmmc'
Some drivers were not found
Reset Source: Power-on reset has occurred.
RTC 32KCLK Source: External.
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from EXT4... 
** Unable to use mmc 0:1 for loading the env **
Board: BeagleBone Black
<ethaddr> not set. Validating first E-fuse MAC
BeagleBone Black:
Model: BeagleBoard.org BeagleBone Black Wireless:
BeagleBone: cape eeprom: i2c_probe: 0x54:
BeagleBone: cape eeprom: i2c_probe: 0x55:
BeagleBone: cape eeprom: i2c_probe: 0x56:
BeagleBone: cape eeprom: i2c_probe: 0x57:
Net:   eth0: MII MODE
Could not get PHY for cpsw: addr 0
cpsw, usb_ether
Press SPACE to abort autoboot in 0 seconds
board_name=[BBBW] ...
switch to partitions #0, OK
mmc0 is current device
SD/MMC found on device 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
53130 bytes read in 6 ms (8.4 MiB/s)
gpio: pin 56 (gpio 56) value is 0
gpio: pin 55 (gpio 55) value is 0
gpio: pin 54 (gpio 54) value is 0
gpio: pin 53 (gpio 53) value is 1
switch to partitions #0, OK
mmc0 is current device
gpio: pin 54 (gpio 54) value is 1
Checking for: /uEnv.txt ...
282 bytes read in 2 ms (137.7 KiB/s)
gpio: pin 55 (gpio 55) value is 1
Loaded environment from /uEnv.txt
Importing environment from mmc ...
Checking if uenvcmd is set ...
gpio: pin 56 (gpio 56) value is 1
Running uenvcmd ...
86538 bytes read in 8 ms (10.3 MiB/s)
53130 bytes read in 6 ms (8.4 MiB/s)
373 bytes read in 2 ms (181.6 KiB/s)
## Booting kernel from Legacy Image at 80800000 ...
   Image Name:   RTEMS
   Created:      2020-08-21   9:28:55 UTC
   Image Type:   ARM Linux Kernel Image (gzip compressed)
   Data Size:    86474 Bytes = 84.4 KiB
   Load Address: 80000000
   Entry Point:  80000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Uncompressing Kernel Image ... OK
   Loading Device Tree to 8ffef000, end 8fffffff ... OK

Starting kernel ...


RTEMS Beagleboard: am335x-based
        ARM Debug: 0x4b141000
Initialising QEP
Setting Quadrature mode to relative
Setting unit timer to 1s
Completed initialising QEP
clock is running true
Enabling PWM  output....
Value of qep position is -4936
Value of qep position is -5382
Value of qep position is -5400
Value of qep position is -5403
Value of qep position is -5406
Value of qep position is -5413
Value of qep position is -5418
Value of qep position is -5421
Value of qep position is -5421
Value of qep position is -5422
Value of qep position is -5422
Value of qep position is -5431
Value of qep position is -5435
Value of qep position is -5434
Value of qep position is -5438
Value of qep position is -5437
Value of qep position is -5440
Value of qep position is -5444
Value of qep position is -5444
PWM disabled. Test finished.

*** FATAL ***
fatal source: 0 (INTERNAL_ERROR_CORE)
fatal code: 5 (INTERNAL_ERROR_THREAD_EXITTED)
/*
 * Copyright (c) 2020 <james.fitzsim...@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>

#include <rtems.h>
#include <bsp/pwmss.h>
#include <bsp/bbb-pwm.h>
#include <bsp/beagleboneblack.h>
#include <bsp/qep.h>
#include <bsp/bbb-gpio.h>
#include <bsp/gpio.h>


static void
Init(rtems_task_argument arg)
{
    rtems_status_code sc;
    bool success;
    int32_t position = 0;

    /*Initialize GPIO pins in BBB*/
    rtems_gpio_initialize();

    sc = rtems_gpio_request_pin(BBB_P9_15, DIGITAL_OUTPUT, false, false, NULL);
    assert(sc == RTEMS_SUCCESSFUL);

    // Enable line is active low so start with it pulled high
    rtems_gpio_set(BBB_P9_15);

    // Configure both channels of PWM instance 0 to run at 10 Hz, 50% duty cycle
    BBB_PWMSS pwmss_id = BBB_PWMSS1;
    float pwm_freq = 20000.0f; //Hz
    float duty_a = 50.0f;
    float duty_b = 50.0f;

    /* Set P9 Header , 21 Pin number , PWM B channel and 0 PWM instance to generate frequency*/
    beagle_pwm_pinmux_setup(BBB_P9_16_1B, pwmss_id);

    /* Set P8 Header, pins 33 and 35 as inputs eQEP1 A_IN & B_IN */
    beagle_qep_pinmux_setup(BBB_P8_33_1B_IN, pwmss_id, true);
    beagle_qep_pinmux_setup(BBB_P8_35_1A_IN, pwmss_id, true);

    // Initialise the pwm module
    success = beagle_pwm_init(pwmss_id);
    assert(success == true);

    // Initialise the pwm module
    printf("Initialising QEP\n");
    sc = beagle_qep_init(pwmss_id);
    assert(sc == RTEMS_SUCCESSFUL);
    printf("Completed initialising QEP\n");

    /* check clock is running */
    bool is_running = beagle_pwmss_is_running(pwmss_id);
    printf("clock is running %s\n", is_running ? "true" : "false");

    // Configure the PWM module for a 10Hz output at 50% duty cycle
    beagle_pwm_configure(pwmss_id, pwm_freq, duty_a, duty_b);

    printf("Enabling PWM  output....\n");
    // Enable the pwm output
    beagle_pwm_enable(pwmss_id);

    // enable the h-bridge
    rtems_gpio_clear(BBB_P9_15);

    int32_t count = 0;
    duty_b = 70.0f;
    beagle_pwm_configure(pwmss_id, pwm_freq, duty_a, duty_b);
    while(++count < 20) {
      position = beagle_qep_get_position(pwmss_id);
      printf("Value of qep position is %d\n", position);
      sleep(1);
    }

    // disable the h-bridge
    rtems_gpio_set(BBB_P9_15);

    /*freeze the counter and disable pwm module*/
    beagle_pwm_disable(pwmss_id);
    printf("PWM disabled. Test finished.\n");
}

#define CONFIGURE_MICROSECONDS_PER_TICK 1000

#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER

#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 10
#define CONFIGURE_UNLIMITED_OBJECTS
#define CONFIGURE_UNIFIED_WORK_AREAS

#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT

#include <rtems/confdefs.h>
/*
 * Copyright (c) 2020 <james.fitzsim...@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>

#include <rtems.h>
#include <bsp/pwmss.h>
#include <bsp/bbb-pwm.h>
#include <bsp/beagleboneblack.h>
#include <bsp/qep.h>
#include <bsp/bbb-gpio.h>
#include <bsp/gpio.h>


void timer_callback(BBB_PWMSS pwmss_id) {
  int32_t position = beagle_qep_get_position(pwmss_id);
  printf("Value of qep position is %d\n", position);
}

static void
Init(rtems_task_argument arg)
{
    rtems_status_code sc;
    bool success;

    /*Initialize GPIO pins in BBB*/
    rtems_gpio_initialize();

    sc = rtems_gpio_request_pin(BBB_P9_15, DIGITAL_OUTPUT, false, false, NULL);
    assert(sc == RTEMS_SUCCESSFUL);

    // Enable line is active low so start with it pulled high
    rtems_gpio_set(BBB_P9_15);

    // Configure both channels of PWM instance 0 to run at 10 Hz, 50% duty cycle
    BBB_PWMSS pwmss_id = BBB_PWMSS1;
    float pwm_freq = 20000.0f; //Hz
    float duty_a = 50.0f;
    float duty_b = 50.0f;

    /* Set P9 Header , 21 Pin number , PWM B channel and 0 PWM instance to generate frequency*/
    beagle_pwm_pinmux_setup(BBB_P9_16_1B, pwmss_id);

    /* Set P8 Header, pins 33 and 35 as inputs eQEP1 A_IN & B_IN */
    beagle_qep_pinmux_setup(BBB_P8_33_1B_IN, pwmss_id, true);
    beagle_qep_pinmux_setup(BBB_P8_35_1A_IN, pwmss_id, true);

    // Initialise the pwm module
    success = beagle_pwm_init(pwmss_id);
    assert(success == true);

    // Initialise the pwm module
    printf("Initialising QEP\n");
    bbb_eqep_timer_callback callback = timer_callback;
    sc = beagle_qep_init(pwmss_id);
    assert(sc == RTEMS_SUCCESSFUL);
    printf("Setting Quadrature mode to relative\n");
    sc = beagle_qep_set_quadrature_mode(pwmss_id, RELATIVE);
    assert(sc == RTEMS_SUCCESSFUL);
    printf("Setting unit timer to 1s\n");
    sc = beagle_eqep_set_timer_period(pwmss_id, 1000000000, callback);
    assert(sc == RTEMS_SUCCESSFUL);
    printf("Completed initialising QEP\n");

    /* check clock is running */
    bool is_running = beagle_pwmss_is_running(pwmss_id);
    printf("clock is running %s\n", is_running ? "true" : "false");

    // Configure the PWM module for a 10Hz output at 50% duty cycle
    beagle_pwm_configure(pwmss_id, pwm_freq, duty_a, duty_b);

    printf("Enabling PWM  output....\n");
    // Enable the pwm output
    beagle_pwm_enable(pwmss_id);

    // enable the h-bridge
    rtems_gpio_clear(BBB_P9_15);

    int32_t count = 0;
    duty_b = 70.0f;
    beagle_pwm_configure(pwmss_id, pwm_freq, duty_a, duty_b);
    while(++count < 20) {
      sleep(1);
    }

    // disable the h-bridge
    rtems_gpio_set(BBB_P9_15);

    /*freeze the counter and disable pwm module*/
    beagle_pwm_disable(pwmss_id);
    printf("PWM disabled. Test finished.\n");
}

#define CONFIGURE_MICROSECONDS_PER_TICK 1000

#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER

#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 10
#define CONFIGURE_UNLIMITED_OBJECTS
#define CONFIGURE_UNIFIED_WORK_AREAS

#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT

#include <rtems/confdefs.h>
U-Boot SPL 2019.04-00002-g07d5700e21 (Mar 06 2020 - 11:24:55 -0600)
Trying to boot from MMC2
Loading Environment from EXT4... 
** Unable to use mmc 0:1 for loading the env **


U-Boot 2019.04-00002-g07d5700e21 (Mar 06 2020 - 11:24:55 -0600), Build: 
jenkins-github_Bootloader-Builder-137

CPU  : AM335X-GP rev 2.1
I2C:   ready
DRAM:  512 MiB
No match for driver 'omap_hsmmc'
No match for driver 'omap_hsmmc'
Some drivers were not found
Reset Source: Power-on reset has occurred.
RTC 32KCLK Source: External.
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from EXT4... 
** Unable to use mmc 0:1 for loading the env **
Board: BeagleBone Black
<ethaddr> not set. Validating first E-fuse MAC
BeagleBone Black:
Model: BeagleBoard.org BeagleBone Black Wireless:
BeagleBone: cape eeprom: i2c_probe: 0x54:
BeagleBone: cape eeprom: i2c_probe: 0x55:
BeagleBone: cape eeprom: i2c_probe: 0x56:
BeagleBone: cape eeprom: i2c_probe: 0x57:
Net:   eth0: MII MODE
Could not get PHY for cpsw: addr 0
cpsw, usb_ether
Press SPACE to abort autoboot in 0 seconds
board_name=[BBBW] ...
switch to partitions #0, OK
mmc0 is current device
SD/MMC found on device 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
53130 bytes read in 6 ms (8.4 MiB/s)
gpio: pin 56 (gpio 56) value is 0
gpio: pin 55 (gpio 55) value is 0
gpio: pin 54 (gpio 54) value is 0
gpio: pin 53 (gpio 53) value is 1
switch to partitions #0, OK
mmc0 is current device
gpio: pin 54 (gpio 54) value is 1
Checking for: /uEnv.txt ...
282 bytes read in 2 ms (137.7 KiB/s)
gpio: pin 55 (gpio 55) value is 1
Loaded environment from /uEnv.txt
Importing environment from mmc ...
Checking if uenvcmd is set ...
gpio: pin 56 (gpio 56) value is 1
Running uenvcmd ...
86422 bytes read in 8 ms (10.3 MiB/s)
53130 bytes read in 6 ms (8.4 MiB/s)
373 bytes read in 2 ms (181.6 KiB/s)
## Booting kernel from Legacy Image at 80800000 ...
   Image Name:   RTEMS
   Created:      2020-08-21   9:33:18 UTC
   Image Type:   ARM Linux Kernel Image (gzip compressed)
   Data Size:    86358 Bytes = 84.3 KiB
   Load Address: 80000000
   Entry Point:  80000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Uncompressing Kernel Image ... OK
   Loading Device Tree to 8ffef000, end 8fffffff ... OK

Starting kernel ...


RTEMS Beagleboard: am335x-based
        ARM Debug: 0x4b141000
Initialising QEP
Completed initialising QEP
clock is running true
Enabling PWM  output....
Value of qep position is 0
Value of qep position is -5093
Value of qep position is -10552
Value of qep position is -16016
Value of qep position is -21485
Value of qep position is -26950
Value of qep position is -32418
Value of qep position is -37890
Value of qep position is -43361
Value of qep position is -48830
Value of qep position is -54300
Value of qep position is -59765
Value of qep position is -65238
Value of qep position is -70711
Value of qep position is -76146
Value of qep position is -81597
Value of qep position is -87052
Value of qep position is -92517
Value of qep position is -97988
PWM disabled. Test finished.

*** FATAL ***
fatal source: 0 (INTERNAL_ERROR_CORE)
fatal code: 5 (INTERNAL_ERROR_THREAD_EXITTED)
RTEMS version: 5.0.0.5284e812e2c82466b3f3a21e494310d8cb69c7cd-modified
RTEMS tools: 7.5.0 20191114 (RTEMS 5, RSB 5 (f2f0fdf13587 modified), Newlib 
7947581)
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to