我用的是TI-SDK-am335x-evm-06.00.00.00 PSP是linux3.2.0-psp04.06.00.11,为了在BBB上用上CAN总线,对mux33xx.c做了如下修改
修改前
_AM33XX_MUXENTRY(UART1_CTSN, 0,
"uart1_ctsn", NULL, " NULL", "i2c2_sda",
"spi1_cs0", NULL, NULL, "gpio0_12"),
_AM33XX_MUXENTRY(UART1_RTSN, 0,
"uart1_rtsn", NULL, " NULL", "i2c2_scl",
"spi1_cs1", NULL, NULL, "gpio0_13"),
_AM33XX_MUXENTRY(UART1_RXD, 0,
"uart1_rxd", "mmc1_sdwp", " NULL", "i2c1_sda",
NULL, "pr1_uart0_rxd_mux1", NULL, "gpio0_14"),
_AM33XX_MUXENTRY(UART1_TXD, 0,
"uart1_txd", "mmc2_sdwp", " NULL", "i2c1_scl",
NULL, "pr1_uart0_txd_mux1", NULL, "gpio0_15"),
修改后
_AM33XX_MUXENTRY(UART1_CTSN, 0,
"uart1_ctsn", NULL, "d_can0_tx", "i2c2_sda",
"spi1_cs0", NULL, NULL, "gpio0_12"),
_AM33XX_MUXENTRY(UART1_RTSN, 0,
"uart1_rtsn", NULL, "d_can0_rx", "i2c2_scl",
"spi1_cs1", NULL, NULL, "gpio0_13"),
_AM33XX_MUXENTRY(UART1_RXD, 0,
"uart1_rxd", "mmc1_sdwp", "d_can1_tx", "i2c1_sda",
NULL, "pr1_uart0_rxd_mux1", NULL, "gpio0_14"),
_AM33XX_MUXENTRY(UART1_TXD, 0,
"uart1_txd", "mmc2_sdwp", "d_can1_rx", "i2c1_scl",
NULL, "pr1_uart0_txd_mux1", NULL, "gpio0_15"),
对board-am335xevm.c文件进行如下修改:
加入
static struct pinmux_config d_can_bbb0_pin_mux[] = {
{"uart1_ctsn.d_can0_tx", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL},
{"uart1_rtsn.d_can0_rx", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLUP},
{NULL, 0},
};
static struct pinmux_config d_can_bbb1_pin_mux[] = {
{"uart1_rxd.d_can1_tx", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL},
{"uart1_txd.d_can1_rx", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLUP},
{NULL, 0},
};
在函数static void d_can_init(int evm_id, int profile)中加入
case BEAGLE_BONE_BLACK:
/* Instance Zero */
setup_pin_mux(d_can_bbb0_pin_mux);
am33xx_d_can_init(0);
/* Instance one */
setup_pin_mux(d_can_bbb1_pin_mux);
am33xx_d_can_init(1);
break;
最后/* Beaglebone Black */
static struct evm_dev_cfg beagleboneblack_dev_cfg[] = {
{am335x_rtc_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{clkout2_enable, DEV_ON_BASEBOARD, PROFILE_NONE},
{tps65217_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{mii1_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{usb0_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{usb1_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{mmc1_emmc_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{mmc0_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{d_can_init, DEV_ON_BASEBOARD, PROFILE_NONE},// 加入d_can_init函数
/* {i2c2_init, DEV_ON_BASEBOARD, PROFILE_NONE},*/ //删除i2c2的初始化函数
{sgx_init, DEV_ON_BASEBOARD, PROFILE_NONE},
{NULL, 0, 0},
};
按照AM335X DCAN driver guide.pdf 对linux driver的CAN进行了配置,然后编译内核,将内核拷到SD卡中(我用的是SD启动),uboot和filesystem没有变,能正常启动,
问题:但是在/dev目录下找不到can0,can1的驱动,运行canconfig can0 start 提示Cannot find device "can0".查看串口显示记录,在启动过程中出现了boardname:A335BNLT board version : 000B,The board is a AM335x Beaglebone Black……….等等,关于CAN的显示CAN device driver interface, CAN bus driver for Bosch D_CAN controller 1.0,can:controller area network core (rev 20090105 abi 8),can:raw protocol(rev 20090105),can:broadcast manager prorocol (20090105 t)。
PS:目前我只用了BBB,没有CAN扩展板,没有接CAN收发器,如果只看/dev目录下有没有驱动的话 CAN收发器应该可以不接,请教TI的大神帮我
Jian Zhou:
刚在EVM板上调试了CAN口,是可以用can utility操作的。
你有没有用menuconfig更改过内核呢?
fa lin:
回复 Jian Zhou:
谢谢你的及时回复,配置过了 按照TI DCAN driver文档上配置过了,是不是D15,16,17,18这几个管脚不能同时用作CAN0,CAN1,你看看我对那两个文件的修改对不对?
fa lin:
回复 Jian Zhou:
好了
Jian Zhou:
回复 fa lin:
修改了哪里就好了呢?
fa lin:
回复 Jian Zhou:
_AM33XX_MUXENTRY(UART1_CTSN, 0, "uart1_ctsn", NULL, "d_can0_tx", NULL, "spi1_cs0", NULL, NULL, "gpio0_12"), _AM33XX_MUXENTRY(UART1_RTSN, 0, "uart1_rtsn", NULL, "d_can0_rx", NULL, "spi1_cs1", NULL, NULL, "gpio0_13"), _AM33XX_MUXENTRY(UART1_RXD, 0, "uart1_rxd", "mmc1_sdwp", "d_can1_tx", NULL, NULL, "pr1_uart0_rxd_mux1", NULL, "gpio0_14"), _AM33XX_MUXENTRY(UART1_TXD, 0, "uart1_txd", "mmc2_sdwp", "d_can1_rx", NULL, NULL, "pr1_uart0_txd_mux1", NULL, "gpio0_15"),
即将i2c2_scl,i2c1_scl等改为NULL就可以了,貌似和I2C有冲突,再问下有没有关于UART的文档,我在外扩展了串口收发器,但是不知道怎么配置内核??
Jian Zhou:
回复 fa lin:
6个UART内核已经配置好了,主要是要配置好pinmux。
UART被认为是比较通用的外设,因此在wiki上没有特别的文档。