This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/BEAGLEBK: pin mode change after boot

Part Number: BEAGLEBK


Tool/software: Linux

Hi,

I have implemented a pwm on a pin. However the polarity is wrong on boot up. When setting up the pwm pin mode in the dts file selecting PIN_OUTPUT_PULLUP makes no difference. A possible solution is to program the pin as GPIO with pullup in the dts. Let the application change the mode to pwm and enable the pwm with 100% duty cycle. Can you direct me to any information to program the pin mode in runtime/ userspace

dts

AM33XX_IOPAD(0x950, PIN_OUTPUT_PULLUP | MUX_MODE3)     // pwm but boot up polarity wrong

or

AM33XX_IOPAD(0x950, PIN_OUTPUT_PULLUP | MUX_MODE7)     // programmed as gpio with polarity high, but how can I change the pin mode after boot?

best regards

other info

ti SDK 5.00.00.15

ti SDK 4.02.00.09

beaglebone black

  • Hi Naseer,

    In AM335x device we can not write pinmux registers (Control Module) from user space, as Cortex-A8 ARM should in supervisor/privileged mode. ARM is in supervisor/privileged mode only in u-boot/kernel stage, not in user space.

    Check AM335x TRM, section 9.1 Introduction

    Note: For writing to the control module registers, the MPU will need to be in privileged mode of operation and writes will not work from user mode.

    You might try with external pull up on that pin, as the internal pull up might be weak.

    Check also below pointers:

    e2e.ti.com/.../1053217
    e2e.ti.com/.../225767
    e2e.ti.com/.../1524521

    Regards,
    Pavel
  • Hi Pavel,

    Thanks for your response, that was useful, i've got more work to do.
    Can you point to some example u-boot/kernel programming and compiling how-to with the sdk. Never done this before.
    If fact which should it be in u-boot or kernel or both?
    Also would the pwm/gpio pinmux in the dts become reduntant and removed?

    much appreciated

    best regards

    Naseer
  • Naseer,

    If you are asking for example for "how to change the GPIO pinmux from user space", unfortunately I do not have such ready made example for you.

    Regards,
    Pavel
  • Hi Pavel,
    Not quite. A How-to for u-boot or kernel programming and compiling with the sdk in supervisor/privileged mode. There is a ti wiki on u-boot but it is for pre-built sources, software-dl.ti.com/.../Foundational_Components_U-Boot.html. It is not for creating a new file to add my pinmux code.

    best regards
  • Nazar,

    u-boot and kernel are in supervisor/privileged mode by default.

    Regarding GPIO module and pinmux programming in u-boot/kernel, I can provide you the below pointers:

    software-dl.ti.com/.../Foundational_Components_Kernel_Drivers.html

    http://software-dl.ti.com/processor-sdk-linux/esd/docs/latest/linux/Foundational_Components_U-Boot.html#u-boot-splash-screen


    Regards,
    Pavel

  • If you have no more questions related to the subject of the e2e thread, please close/verify/resolve this thread.

    Regards,
    Pavel
  • Hi Pavel,

    I can make the pwm pin high on boot. Briefly, I decided not to write a driver and work around it. However I have decided to change by app to support pwm-leds just for this pin.

    1. changed the kernel dts from pwm to pwm-leds for ehrpwm0a. Set brightness to default-on

    I also added u-boot changes, either of these seem to work. But where not now necessary

    1. changed the u-boot dts and include pwm-leds for ehrpwm0a. Set brightness to default-on

    2. add in uEnv.txt

    gpio set 2

    3. set ehrpwm gpio high in function board_init()  in u-boot-xxx/board/ti/am335x/board.c

    int board_init(void)

    { .....

    REQUEST_AND_SET_GPIO(GPIO_TO_PIN(0, 2));

    return 0;

    }

    best regards

    Naseer

  • Hi Pavel,
    I was a bit premature, problem not fixed. Revisited the boot up and current code. Programming board.c with the pin set is necessary as uEnv.txt and u-boot dts commands seem to be ignored. Programming dts to pwm-leds with default-on causes the pin to pulse low on Kernel startup. ie almost right, it should remain high all the time.

    I am guessing the pulse low is the time dts programs the ehrpwm0a to the time the driver pwm-leds programs the pin high.

    So at the moment the issue is still not resolved completely.

    best regards

    Naseer