2013/10/21

Learning u-boot Part 2

My goal
I need to some how implement a feature for loading firmwares via ethernet cable only (IE fading out no SERIAL CONSOLE RS232). A suggestion from my supervisor is starting from bootloader. Basically, that's why this thread coming out :D

1. Direction
According to the /doc/README.Netconsole, u-boot provides an access via netcat. So, this is my starting point.

2. Enable netconsole
Netconsole is disabled by default of my board setting due to minimize the files size of that executable file (I guess). So, the following recording how I enable netconsole.

According to
/common/device.c:240~242
240 #ifdef CONFIG_NETCONSOLE
241         drv_nc_init ();
242 #endif

It is clear that we need to define that constant in order to enable netconsole.

Add lines
#define CONFIG_NETCONSOLE /* enable nc */
into /includes/configs/<board>.h

Recompile the u-boot binary and loading into the device.
PS. How to load bootloader into the device will not be discussed here.

For now, bootloader should be able to use nc.

3.  Follow up
Keep following the README.Netconsole, execute following commands via serial console.
setenv nc setenv stdin nc\; setenv stdout nc
setenv ncip <YOUR_SERVER>
setenv netmask <YOUR_SERVER_NETMASK>
saveenv
run nc

In your server run the following script file,
#! /bin/bash

[ $# = 1 ] || { echo "Usage: $0 target_ip" >&2 ; exit 1 ; }
TARGET_IP=$1

stty -icanon -echo intr ^T
nc -u -l 6666 < /dev/null &
nc -u ${TARGET_IP} 6666
stty icanon echo intr ^C

# interupt by CTRL+T
# $1 is your device ip

For now, magic happen :D
You can interact with the device as if you are using serial console cable.

4. Summery
I can setup a network link between embedded device and my pc. The rest of the tasks are putting things together. For example, when and how to enable netconsole on the embedded device. I will cover these stuffs later on (I hope) since I have no progress till now.

沒有留言:

張貼留言