2011-08-29

[DM368][IPNC] Upgrade udev on IPNC-DM368

[Prolog]

the reason I would like to upgrade udev on IPNC-DM368 is that the latest Appro package (Ver_2.00.26, kernel 2.6.18) doesn't contain 'udevadmin', which is used to control the runtime behavior of udev, request kernel events, manage queue, and debug udev.

Appro's package includes some of udev helper functions such as udevtrigger and udevinfo. However, udevadmin is what I want to follow Embedded Linux Primer, 2nd edition, ch19.

[Main]

1. Get the udev package from kernel tree. The latest version which supports kernel 2.6.18 is udev-127.

2. Unpack the tarball

3. Configure the make envionment
CC=/opt/mv_pro_5.0.0/montavista/pro/devkit/arm/v5t_le/bin/arm_v5t_le-gcc ./configure --host=armv5tl-montavista-linux-gnueabi --prefix=/home/usr/work/udev-127/filesys


4. make & make install

5. udevd and udevadm were generated under directory ./udev


[Epilog]

Easy work! as long as the CC is set correctly, there will be no problem to finish the job.

[Extend readings]

CH19, Embedded Linux Primer, 2nd Edition






2011-08-17

[DM368][IPNC] Using GDB on IPNC

[Prolog]

To dig into Appro's application, I decided to enable gdb on IPNC platform. There are two useful page provided by TI's wiki and they let me enable gdb on IPNC in one hour.
==============================
==============================

[Main]
1. get the latest gdb from gdb download page

2. configure and make gdb and gdbserver

for gdb
==============================
host# ./configure --host=i686-pc-linux-gnu --target=armv5tl-montavista-linux-gnueabi --prefix=/opt/mv_pro_5.0.0/montavista/pro/devkit/arm/v5t_le
host# make
host# make install
==============================

for gdbserver
==============================
host# cd gdb/gdbserver
host# CC=/opt/mv_pro_5.0.0/montavista/pro/devkit/arm/v5t_le/bin/arm_v5t_le-gcc ./configure  --host=armv5tl-montavista-linux-gnueabi --prefix=/home/user/workdir/filesys
host# make && make install
==============================

there was an error during "make install". the screen showed
==============================
cannot stat 'libinproctrace.so': No such file or directory
==============================

after quick google search, it can be fixed by modifying "gdb/gdbserver/Makefile.in"
==============================
original:
if [ x$IPA_DEPFILES != x ]; then \
fixed:
if [ x${IPA_DEPFILES} != x ]; then \
==============================


3. Running gdbserver at target
==============================
target# gdbserver 192.168.100.1:1000 ./sample
==============================



4. Running gdb at host
==============================
host# /opt/mv_pro_5.0.0/montavista/pro/devkit/arm/v5t_le/bin/armv5tl-montavista-linux-gnueabi-gdb ./sample
==============================

at gdb prompt
==============================
(gdb) set solib-search-path /home/user/workdir/filesys/lib (gdb) target remote 192.168.100.2:1000
==============================


5. (optional) using ddd
==============================
host# ddd --debugger arm_v5t_le-gdb
==============================

6. (optional) error "Malformed packet(b) (missing colon)" 
    in Appro reference design, there is an existing gdbserver under /usr/bin. However, the installation of gdbserver is toward /bin, and the PATH setting will select the old gdbserver (GNU gdbserver 6.6.50.20070301 in my case). Easy to fix though.




[Epilog]
Easy works as far! multitread debugging could be challenge though
[Extend readings]

Debugging on DaVinci using kgdb



2011-08-12

[DM368][IPNC][U-Boot] Porting U-boot to DM368-IPNC (1) Ethernet

[Prologue]
Appro's DM368 IPNC reference code uses u-boot version 1.3.4, which is kind of old version without USB and MMC boot support. Appro doesn't seems to upgrade it in the near future (actually it doesn't care except you are big customer). 


Couple days ago I found TI released a new dvsdk for DM365/DM368 (DVSDK_4.02 4_02_00_06), which contains U-Boot 2010.12-rc2. Even though it's not the latest version, it includes all required feature I want. I decided to port this version to DM368-IPNC.




[Main]
After scanning related config files, I decided to use include/configs/davinci_dm365evm.h as template to start the work. This article focuses on enabling Ethernet of U-Boot on IPNC. Others issues will be discussed later.

Steps:
1. create a new config file include/configs/davinci_dm368_ipnc.h with the same content of davinci_dm365evm.h

2. add board information to boards.cfg
==============================
(davinci_dm368_ipnc           arm         arm926ejs   dm365evm            davinci        davinci)
==============================

3. make u-boot!
I didn't use CodeSourcery so had to assign cross compiler.
the commands are
==============================
make CROSS_COMPILE=arm_v5t_le- distclean
make CROSS_COMPILE=arm_v5t_le- clean
make CROSS_COMPILE=arm_v5t_le- davinci_dm368_ipnc_config
make CROSS_COMPILE=arm_v5t_le-
==============================

4. found Ethernet doesn't work. after issuing "ping 192.168.1.1", which is my tftp/nfs server, IPNC hung forever without any message shown. I cannot break it by Ctrl-C either.

5.turn on Ethernet debug to get more messages
at drivers/net/davinci_emac.c, enable emac_dbg
==============================
unsigned int emac_dbg = 1;
==============================

6. reboot IPNC, and issue ping again, I got

==============================
+ emac_close
+ emac_ch_teardown
- emac_ch_teardown
+ emac_ch_teardown
- emac_ch_teardown
- emac_close
+ emac_open
==============================
and IPNC hung. "+ emac_open" was printed by davinci_eth_open()@drivers/net/davinci_emac.c. after get_link_speed statement, it broke by "return 0".
==============================
(!phy.get_link_speed(active_phy_addr))
return(0);

==============================

6. the suspicious point was the variable "active_phy_addr" above. so I added two debug print to ensure it's the root cause.
==============================

debug_emac("+ emac get_link_speed, active_phy_addr = %x\n", active_phy_addr);
if (!phy.get_link_speed(active_phy_addr))
return(0);
debug_emac("- emac get_link_speed\n");
==============================
it confirmed the problem point and active_phy_addr = 0xFF, which is strange.

7. trace code to locate where we got the active_phy_addr and found davinci_eth_phy_detect() @ drivers/net/davinci_emac.c
==============================

phy_act_state = readl(&adap_mdio->ALIVE) & EMAC_MDIO_PHY_MASK;
if (phy_act_state == 0)
return(0); /* No active PHYs */
==============================
there is no error handling code if return 0 (No active PHYs). EMAC_MDIO_PHY_MASK is a macro from EMAC_MDIO_PHY_NUM(@emac_defs.h), which is defined in config file with the value 2.
==============================
/* PHY mask - set only those phy number bits where phy is/can be connected */
#define EMAC_MDIO_PHY_NUM           CONFIG_EMAC_MDIO_PHY_NUM
#define EMAC_MDIO_PHY_MASK          (1 << EMAC_MDIO_PHY_NUM)
==============================

8. Check with schematic file of IPNC and the datasheet of PHY (DM9161), the strapping config is 1 (PHYAD0 pull high), which means the PHY address is 1. Tried to dump the register of MDIO-ALIVE(0x01d0b00c) and the value is 0x00000002. it showed the PHY address should be 1.

9. Change the config value of PHY number at davinci_dm368_ipnc
==============================
 #define CONFIG_EMAC_MDIO_PHY_NUM 1
==============================
and make u-boot again

10. Bingo!
==============================
Ethernet PHY: GENERIC @ 0x01
DaVinci-EMAC
Hit any key to stop autoboot:  0
==============================

[Epilogue]


Some of the issues are not discussed, some are not fixed yet.
To Be Post -
UART
NAND - ECC

To Be Fixed -
USB
MMC
MTD