Vybrid UART's from Linux

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vybrid UART's from Linux

Jump to solution
4,872 Views
kubiznak_petr
Contributor V

Hi, does anybody have a clue how to use other then the default (UART1) UART from the Timesys' Linux? They seem to be disabled in kernel but maybe I'm wrong.

I'm discussing the topic with Timesys support but they also don't seem to be sure about the solution.

Labels (1)
Tags (3)
0 Kudos
1 Solution
2,249 Views
timesyssupport
Senior Contributor II

Hello Johannes,

Enabling a different UART is not a supported configuration in the current Linux kernel for Vybrid. As this would involve changes to bootloader and kernel source, this falls outside the scope of general support and would need to be covered under a services agreement with Timesys. Please contact Timesys if you would be interested in escalating.

Regards,

Timesys Support

View solution in original post

0 Kudos
22 Replies
2,096 Views
rodrigomendes
Contributor I

Hello everybody,

Maybe dummy questions.

In which software component (u-boot / kernel / application) or in which moments may the IOMUX settings be changed ?

And how this can be done?

Is there a specific header or sample code to do it? 

Thanks and regards,

Rodrigo

0 Kudos
2,094 Views
kubiznak_petr
Contributor V

Hi Rodrigo,

are you speaking about UART configuration or about IOMUX generally? I think that the UART question is practically answered here (just don't look at the "Correct Answer", read the whole text).

Regards,

Petr

0 Kudos
2,094 Views
rodrigomendes
Contributor I

Hi Petr,

I am speaking about IOMUX generally.

Regards,

Rodrigo

0 Kudos
2,094 Views
kubiznak_petr
Contributor V

That is very general question. IOMUX should be usually configured in u-boot or during Linux kernel boot. That depends on the purpose. You should probably open a separate thread with more specific question.

0 Kudos
2,096 Views
tombudd
Contributor I

I'm using EmCraft's VF6 SOM and this is what I did to get a functional UART2 on PTB6 and PTB7.  Please note that I am not using Timesys Linux but hopefully these changes can work for you or point you in the direction you need to get UART2 running.

Added the following definitions to linux/arch/arm/plat-mxc/include/mach/iomux-mvf.h just below the UART0 and UART1 definitions (search for UART1 in the file to find the spot).

/*UART2*/

#define MVF600_PAD28_PTB6_UART2_TX \

IOMUX_PAD(0x0070, 0x0070, 7, 0x038c, 0, \

MVF600_UART_PAD_CTRL | PAD_CTL_OBE_ENABLE)

#define MVF600_PAD29_PTB7_UART2_RX \

IOMUX_PAD(0x0074, 0x0074, 7, 0x0388, 0, \

MVF600_UART_PAD_CTRL | PAD_CTL_IBE_ENABLE)

Modify the linux/arch/arm/mach-mvf/board-emcraft-vybrid-som.c file:

     ... If you have the VF6 Freescale Tower board you can probably make similar/identical changes to

     ... the linux/arch/arm/mach-mvf/board-twr-vf700.c file to get the same results.

Add these lines after the UART1 definitions, search for UART1

/*UART2*/

MVF600_PAD28_PTB6_UART2_TX,

MVF600_PAD29_PTB7_UART2_RX,

Add this struct after the corresponding struct for uart1

/* UART2 */

static struct imxuart_platform_data mvf_uart2_pdata = {

.flags = IMXUART_FIFO | IMXUART_EDMA,

.dma_req_rx = DMA_MUX03_UART2_RX,

.dma_req_tx = DMA_MUX03_UART2_TX,

};

Add this line to the mvf_vf700_init_uart(void) function to initialize your new port


mvf_add_imx_uart(2, &mvf_uart2_pdata);



Add the following line to your initramfs file to create /dev/ttymxc2


nod /dev/ttymxc2 0666 0 0 c 207 18



* Corrected daisy chain settings on the pad definitions from my original post, thanks to EmCraft for catching my mistake

0 Kudos
2,096 Views
johannestraxler
Contributor III

Dear Tom,

thanks for sharing your information - actually this is the same what I did, but it didn't work!

You are not using timesys linux - what are you using instead?

Have you modified any other source file (e.g. clock.c)?

Thanks,

Johannes

0 Kudos
2,096 Views
tombudd
Contributor I

Hello Johannes,

I am using a distribution from EmCraft that is based on the Freescale version.  I have not modified clock.c, only the files I mentioned.  Could you elaborate more on how it doesn't work?  Does the boot sequence show the new UART?  Does the device show in /dev ?  Something to check is to make sure that no other device is using the GPIO pins associated with your UART and make sure you edited the correct board file for your hardware.  It looks like the UARTs all share the same clock so if one of them works the others should work as well.

Serial: MVF driver

imx-uart.0: ttymxc0 at MMIO 0x40027000 (irq = 93) is a IMX

console [ttymxc0] enabled

imx-uart.2: ttymxc2 at MMIO 0x40029000 (irq = 95) is a IMX

imx-uart.3: ttymxc3 at MMIO 0x4002a000 (irq = 96) is a IMX

/dev # ls -l ttymxc*

crw-rw-rw-    1 root     root      207,  16 Jan  1 00:04 ttymxc0

crw-rw-rw-    1 root     root      207,  18 May 13  2014 ttymxc2

crw-rw-rw-    1 root     root      207,  19 May 13  2014 ttymxc3

I hope this helps narrow it down.

Tom

0 Kudos
2,096 Views
mnw
Contributor II

I'm not sure if this helps, but we had to modify setup_iomux_uart to get UART2 working in uBoot. 

The pads should be setup for ALT7.

__raw_writel(0x007011a2, IOMUXC_PAD_028);
__raw_writel(0x007011a1, IOMUXC_PAD_029);
0 Kudos
2,096 Views
kubiznak_petr
Contributor V

Hi Martin,

thank you for your reply. I tried to modify IOMUXC as you suggested but it did not change anything. Since I don't know the role of u-boot deeply, can you please provide more information?

  • Is this the only change you made to set UART2 working?
  • Is u-boot responsible for all requested configuration? I thought the hardware should be initialized during the Linux boot.
  • Is there a way how to test functionality of a particular UART from u-boot?
0 Kudos
2,096 Views
ioseph_martinez
NXP Employee
NXP Employee

Hello Petr

I have been digging a bit into this question. First, I booted using timesys linux and checked what are the supported uart drivers on the kernel. It seems it only loads uart 1 as you mention.

fb3:  fb device registered successfully.

Serial: MVF driver

imx-uart.1: ttymxc1 at MMIO 0x40028000 (irq = 94) is a IMX

console [ttymxc1] enabled

So adding code in the Kernel source to support other ports is a must I think.

Enabling a different uart on uboot won't make it work on linux since linux takes over and does all over again anything needed for the system.

This is what I would try, without knowing for sure is enough (we need to include timesys into this thread so they can provide their thoughts)

  1. ~/timesys/twr_vf600/kernel-source/linux-3.0/arch/arm/mach-mvf has specific initalization for the tower board.
  2. board-twr-vf700.c
    1. add pin initialization, only uart 1 pins are initialized.
    2. add another struct for imxuart_platform_data for the uart you want to support. That will use a different dma hardware request.
    3. on mvf_vf700_init_uart add another call to init the additional instance of the uart

I think after this the upper layers will take care of having the proper instances of the driver ports. I would expect that the additional ports will be mentioned during the linux boot messages.

2,096 Views
kubiznak_petr
Contributor V

Hello Ioseph,

thank you for your reply. I've already done what you suggest but it obviously is not enough. Firstly what I did with Linux kernel:

  • In board-twr-vf700.c I added all what you suggest for UART0 and UART2.
  • For UART2 I had to define MVF600_PAD79_PTD0_UART2_TX, the same for PTD1 and PTD2 in iomux-mvf.h.

That is enough to have created devices ttymxc0, ttymxc1 and ttymxc2 in /dev . Further I did with u-boot source:

  • Modified setup_iomux_uart in board/freescale/vybrid/vybrid.c as Martin suggested. No change noticed.
  • In include/configs/vybrid.h I redefined CONFIG_SYS_UART_PORT to (0).

Currently I'm getting the following boot sequence:

Serial: MVF driver
imx-uart.0: ttymxc0 at MMIO 0x40027000 (irq = 93) is a IMX
console [ttymxc0] enabled
imx-uart.1: ttymxc1 at MMIO 0x40028000 (irq = 94) is a IMX
imx-uart.2: ttymxc2 at MMIO 0x40029000 (irq = 95) is a IMX
brd: module loaded

Enabling a different uart on uboot won't make it work on linux since linux takes over and does all over again anything needed for the system.

This is very important but questionable thing. I'm experiencing dependencies between settings of u-boot and Linux. Not only that u-boot's console bootarg changes the behaviour (which is of course expected), but also the value of CONFIG_SYS_UART_PORT affects it.

In my case, Linux console works correctly only in case CONFIG_SYS_UART_PORT is set to the same value X as console=ttymxcX. This way I can switch the console between UART0 and UART1 successfully (did not test for UART2 as it is RS485). But while one UART selected this way works fine, the remaining do not work.

Say I selected UART0. Console works correctly on this uart. I can echo to /dev/ttymxc0 or communicate with it using microcom (from the device, via telnet). If I echo to /dev/ttymxc1 or /dev/ttymxc2, nothing happens. If I cat it, it somehow crashes as I usually have to reboot. It also does not communicate with microcom, which even does not quit after specified time (-t option) - I have to kill it from different telnet session.

The same situation happens if I switch to UART1, with the difference the only working uart is then UART1, the others crash the same way as explained above. Thus it must unluckily be somehow connected to the u-boot configuration. But how?


0 Kudos
2,096 Views
ioseph_martinez
NXP Employee
NXP Employee

I tried to look for some code in the linux kernel but I got lost... could not find anything.

Is memtool available on timesys linux? maybe you can dump the register configuration of the different UART channels and you can compare vs the values they have during uboot time.

That will tell quickly if Linux tried to configure the registers or not.

By the way, have you heard anything back from timesys?

0 Kudos
2,096 Views
kubiznak_petr
Contributor V

Dumping register configuration sounds promising but I did not find such a tool. Maybe I just overlooked it - is "memtool" the real name which I should look for? Should that be accessible from menuconfig? (I tried to look for "memtool" in menuconfig with no success.)

Nothing helpful came from timesys, regrettably.

0 Kudos
2,096 Views
ioseph_martinez
NXP Employee
NXP Employee

Seems memtool is exclusive on i.mx bsp. I just tried to connect with JTAG debugger and I have access to the peripheral registers.

If you send me your kernel binary I can give a try dumping this info manually with the debugger.

0 Kudos
2,096 Views
CurtisWald
NXP Employee
NXP Employee

The memtool is found in the imx-test package found in i.MX BSP's.  The command ./ltib -m prep -p imx-test will provide the sources in <ltib>/rpm/BUILD directory.

As Iospeh stated TimeSys does not today provide memtool in their offerrings.

Another user space application that is available in TimeSys Vybrid desktop factory is devmem which is found in the Busybox utilities. By default devmem is not enabled. Here are the steps to enable, build, and location in the root file system.

The BusyBox documentation has this description:

devmem

devmem ADDRESS [WIDTH [VALUE]]

Read/write from physical address

        ADDRESS Address to act upon

        WIDTH   Width (8/16/...)

        VALUE   Data to be written

This assumes you have downloaded, installed and built desktop factory once. (Not available from Web factory).

  1. make busybox-menuconfig

busybox-menuconfig1.png

At the desktop factory top level directory issue the “make busybox-menuconfig” command which then shows the configuration menu. Using the keyboard arrow keys, down arrow and select “Miscellaneous Utilities then hit the enter key. This selects the Miscellaneous Utilities menu.

busybox-menuconfig2.png

Using the down arrow key go down until devmem entry. Using the space bar select to enable and you will see [*] the item is selected.

busybox-menuconfig4.png

Right arrow to exit and hit enter and then select yes to save.

2. make busybox-build

3. make busybox-rfs-install

This installs in the root file system. To see, change to the directory on your installation where the desktop factory is installed, for me I had :

cd /home/user/vybrid/factory/build_armv7l-timesys-linux-gnueabi/rfs/

$ find . -name devmem -print

./sbin/devmem

The root file system (rfs) now has the devmem utility.

0 Kudos
2,096 Views
kubiznak_petr
Contributor V

Hi Curtis, thank you for a very helpful reply. Using devmem I found out IOMUXC is configured properly while UART1xxx and UART2xxx registers differ from UART0xxx registers. I've been playing with these registers a bit, it did something, but did not solve it yet. Also don't know yet which SW (uboot/kernel/...) is responsible for the differences. I will write more when I have some news. Thank you so far.

0 Kudos
2,096 Views
johannestraxler
Contributor III

Dear Petr,

as I'm currently in the same situation like you, I was wondering if you have found a working solution to enable two additional UARTs in Linux? I'll be very pleased if you give me a reply! Thanks!

0 Kudos
2,096 Views
kubiznak_petr
Contributor V

Dear Johannes,

you are maybe in a worse situation as I currently needed only to switch the UART, not to use more channels in parallel. If this is the case, I worry I cannot help you because I did not manage to do it, although I tried. Please push on Timesys to get the solution (and share it here then :smileywink:).

Should you need only to switch the used channel, the following stuff needs to be set up properly:

  1. Modify board-twr-vf700.c in the kernel source as described above (modify mvf600_pads array, add new imxuart_platform_data structure, add calls to mvf_add_imx_uart inmvf_vf700_init_uart) and add respective definitions to iomux-mvf.h. As a result, you will see new ttymxcX devices in /dev/.
  2. In the u-boot source, add proper calls to __raw_writel in setup_iomux_uart in vybrid.c (this will initialize new channel in u-boot) and redefine CONFIG_SYS_UART_PORT in vybrid.h (u-boot will output to the channel specified here).
  3. In timesys factory, modify target/configs/device_table/twr_vf600/device_table, line /dev/ttyDefault to point to required channel. This will make linux to direct standard output to the channel.

Hope that helped you.

0 Kudos
2,096 Views
karina_valencia
NXP Apps Support
NXP Apps Support

timesyssupport can you   help on this case?

0 Kudos
2,250 Views
timesyssupport
Senior Contributor II

Hello Johannes,

Enabling a different UART is not a supported configuration in the current Linux kernel for Vybrid. As this would involve changes to bootloader and kernel source, this falls outside the scope of general support and would need to be covered under a services agreement with Timesys. Please contact Timesys if you would be interested in escalating.

Regards,

Timesys Support

0 Kudos