How to make bootloader on another UART than UART0? (K64f)

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

How to make bootloader on another UART than UART0? (K64f)

Jump to solution
1,084 Views
grochal7
Contributor III

Hello!

I'm using the frdm k64f and i'm testing the bootloader with examples. I'm using the freedom_bootloader example from bootloader_examples (SDK 2.5.0) and the KinetisFlashTool for updating programs.

For me both examples - led_demo_freedom_0000 (without bootloader) and led_demo_freedom_a000 (with BL) works!

Now I try to use another UART for updating my program, e.g UART2 (RX - PTD2 TX - PTD3).

I found this note inside ""pinmux_utility_common.c":

//! this is to store the function pointer for calling back to the function that wants
//! the UART RX instance pin that triggered the interrupt. This only supports 1 pin
//! for UART0 because UART1 is on PORTC which does not support interrupts Smiley Sad

Soo, is it possible to run my bootloader by using UART2 on PTD2/3?

Where can I check which uart is usable?

I found sth like this for MKV31F51212:

Hi,

Sorry for reply you so late.

I tested UART2, it can work. There are some key point you should pay attention to.

1. In peripherals_pinmux.c,

#define BL_ENABLE_PINMUX_UART2 (BL_CONFIG_SCUART)

 //! UART pinmux configurations
#define UART2_RX_PORT_BASE PORTE
#define UART2_RX_GPIO_BASE PTE
#define UART2_RX_GPIO_PIN_NUM 17 // PIN 16 in the PTB group
#define UART2_RX_FUNC_ALT_MODE kPORT_MuxAlt3 // ALT mode for UART0 RX
#define UART2_RX_GPIO_ALT_MODE kPORT_MuxAsGpio // ALT mdoe for GPIO functionality
#define UART2_RX_GPIO_IRQn PORTE_IRQn
#define UART2_RX_GPIO_IRQHandler PORTE_IRQHandler
#define UART2_TX_PORT_BASE PORTE
#define UART2_TX_GPIO_PIN_NUM 16 // PIN 17 in the PTB group
#define UART2_TX_FUNC_ALT_MODE kPORT_MuxAlt3 // ALT mode for UART0 TX



 2. In peripherals_KV31F512.c

#if BL_CONFIG_SCUART
 // UART0
 {.typeMask = kPeripheralType_UART,
 .instance = 2, //must set to 2
 .pinmuxConfig = uart_pinmux_config,
 .controlInterface = &g_scuartControlInterface,
 .byteInterface = &g_scuartByteInterface,
 .packetInterface = &g_framingPacketInterface },
#endif // BL_CONFIG_SCUART



 3. DSPI pin is conflict with UART2, please take care.



 4. In the function get_uart_clock(), you should add

 case 2:
 return get_bus_clock();



 Regards,

Jing

Quotation from: https://community.nxp.com/thread/474392 

I did all what Jing suggested and I still cant connect with KinetisFlashTool.

jingpan‌ maybe u have any other suggestions?

Regards!

1 Solution
867 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi

In the K64F device, MCUBOOT uses PTD2 and PTD3 with the DSPI communication, so there is a conflict when you try to communicate with UART but this pin is rooted with the SPI functionality.

I disable the SPI peripheral in the bootloader_config.h file as below:

#if !defined(BL_CONFIG_SCUART)
#define BL_CONFIG_SCUART (1)
#endif
#if !defined(BL_CONFIG_I2C)
#define BL_CONFIG_I2C (1)
#endif
#if !defined(BL_CONFIG_DSPI)
#define BL_CONFIG_DSPI (0)
#endif
#if !defined(BL_CONFIG_USB_HID)
#define BL_CONFIG_USB_HID (1)
#endif
#if !defined(BL_CONFIG_USB_MSC)
#define BL_CONFIG_USB_MSC (1)
#endif

then I change the code to enable UART2 as you do and I was able to communicate with the Kinetisflashtool.

Hope this helps

Best regards

View solution in original post

2 Replies
868 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi

In the K64F device, MCUBOOT uses PTD2 and PTD3 with the DSPI communication, so there is a conflict when you try to communicate with UART but this pin is rooted with the SPI functionality.

I disable the SPI peripheral in the bootloader_config.h file as below:

#if !defined(BL_CONFIG_SCUART)
#define BL_CONFIG_SCUART (1)
#endif
#if !defined(BL_CONFIG_I2C)
#define BL_CONFIG_I2C (1)
#endif
#if !defined(BL_CONFIG_DSPI)
#define BL_CONFIG_DSPI (0)
#endif
#if !defined(BL_CONFIG_USB_HID)
#define BL_CONFIG_USB_HID (1)
#endif
#if !defined(BL_CONFIG_USB_MSC)
#define BL_CONFIG_USB_MSC (1)
#endif

then I change the code to enable UART2 as you do and I was able to communicate with the Kinetisflashtool.

Hope this helps

Best regards

867 Views
grochal7
Contributor III

Yes! Great! It was the problem!

Thank You very much!

0 Kudos