viernes, 9 de enero de 2015

TELDAT I-router 1104-W. U-boot (II)

     Ya sabemos como trabaja U-boot por encima, tenemos un backup de nuestros ficheros mtd y acceso por consola al router.

     El U-boot, al arranque, nos indica que introduzcamos un password, y nos da 3 segundos para ello, si no, arranca el router de forma normal.

     Hay que tener en cuenta, que trabajar con u-boot, es extremadamente peligroso si no sabes que estás haciendo, puedes dejar el router inservible, (a menos que entres bajo JTAG y restaures el U-boot), así que cuidado con lo que tocas.

     El password en cuestión es: FUZXPIBTDLT, extraido con un editor hexadecimal del fichero mtd0_boot_1.0.4.bin.

     Abres un hiperterminal, 115.200 baudios, copias el password en el portapapeles, y cuando solicite el password, lo pegas:
U-Boot 1.1.6 (Mar 4 2011 - 10:29:05) Teldat 1.0.3

DRAM: 256 MB
Comcerto Flash Subsystem Initialization
Flash: 4 MB
NAND: board_nand_init nand->IO_ADDR_R =30000000
256 MiB
In: serial
Out: serial
Err: serial
Reserve MSP memory
Net: comcerto_gemac0, comcerto_gemac1
ethaddr=00:A0:26:7D:59:D4
sernum1=745/0xxxxx
sernum2=745/0xxxxx
Enter password - autoboot in 3 sec...
Comcerto-100 >
     Ya estamos dentro de U-boot, el set de comandos, se muestra con help:
Comcerto-100 >help
? - alias for 'help'
base - print or set address offset
bootm - boot application image from memory
bootp - boot image via network using BootP/TFTP protocol
chkmac - forces nor boot if default ethernet address
chnvdata- change non-volatile data
chnvfsn - change non-volatile first serial number
chpart - change active partition
cmp - memory compare
cp - memory copy
crc32 - checksum calculation
erase - erase FLASH memory
flinfo - print FLASH memory information
fsinfo - print information about filesystems
fsload - load binary file from a filesystem image
go - start application at address 'addr'
help - print online help
icrc32 - checksum calculation
iloop - infinite loop on address range
imd - i2c memory display
imm - i2c memory modify (auto-incrementing)
imw - memory write (fill)
inm - memory modify (constant address)
iprobe - probe to discover valid I2C chip addresses
loadb - load binary file over serial line (kermit mode)
loady - load binary file over serial line (ymodem mode)
loop - infinite loop on address range
ls - list files in a directory (default /)
md - memory display
mii - MII utility commands
mm - memory modify (auto-incrementing)
mtdparts- define flash/nand partitions
mtest - simple RAM test
mw - memory write (fill)
nand - NAND sub-system
nboot - boot from NAND device
nfs - boot image via network using NFS protocol
nm - memory modify (constant address)
ping - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
reset - Perform RESET of the CPU
run - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv - set environment variables
tftpboot- boot image via network using TFTP protocol
uload - load kernel file from a filesystem image
version - print monitor version
      Y ampliamos la ayuda sobre un comando con:
Comcerto-100 >elcomando help
     Para ver las variables de entorno de arranque de U-boot:
Comcerto-100 > printenv
ethaddr=00:A0:26:7D:59:D4
sernum1=745/0xxxxx
sernum2=745/0xxxxx
tstamp=1310051641781
bootdelay=15
baudrate=115200
preboot=run preboot2
gatewayip=192.168.0.1
netmask=255.255.255.0
hostname=prg
netdev=eth0
ethact=comcerto_gemac0
nfsargs=setenv bootargs init= root /dev/nfs rw nfsroot :
init_process=/etc/preinit
addip=setenv bootargs ip=::192.168.0.1:255.255.255.0:prg:eth0:on
addeth=setenv bootargs hwaddress eth2,00:A0:26:7D:59:D4
addtty=setenv bootargs console=ttyS0,115200
addmtd=setenv bootargs
boot_nfs=nfs 80600000 /boot/
boot=run bootm 80600000
rootpath=/devel/fs-teldat
kernelfile=uImage
bootfile=u-boot.bin
mtdids=nor0=comcertoflash.0,nand0=comcertonand
mtdparts=mtdparts=comcertoflash.0:256k(boot)ro,128k(env),128k(tldt)ro,1280k(kr)r
o,-(fs)ro;comcertonand:2M(kr1),100M(fs1),2M(kr2),100M(fs2),-(cfg)
fsfile=roatefs tftp 81000000
updatefs=cp.b 81000000 201c0000
updateboot=cp.b 81000000 20000000
updatekernel=cp.b 81000000 20080000
biosfile=bios.bin
savemac=cp.b 20060000 81400000 20000
restoremac=cp.b 81400000 20060000 20000
erasenor=erase nor0,0
updatebios=run restoremac
irouterfile=irouter.bin
updateirouter=nand write.raw 81000000 0
bootnor=bootm
bootnand=bootm
bootnand1=run bootnand
bootnand2=run bootnand
trybootnand1=run bootnand1
trybootnand2=run bootnand2
modelname=iRouter
preboot2=chkmac
biosversion=1.0.3
prodclass=iRouter1104-W
hwversion=TS-745/4
versionnand1=1.0.3
datenand1=1299856314
bootcmd=run bootnand1
eanpersistent=1299856314
stdin=serial
stdout=serial
stderr=serial
partition=nor0,3
mtddevnum=3
mtddevname=kr
     Mostrándonos los parámetros y scripts de u-boot, un ejemplo de parámetro, esperar 3 segundos antes de arrancar.
bootdelay=3
     Ejemplo de script, añadir a bootarg una consola en ttyS0 a 115200 bauds.
addtty=setenv bootargs console=ttyS0,115200
     Otro ejemplo, crear un comando a partir de un script:
restoremac=cp.b 81400000 20060000 20000
     Si ejecutáramos restoremac, nos restauraría la mac del router, a partir de la posición en memoria donde reside. 

     Si quisiéramos por ejemplo, cambiar la variable bootdelay=3, que espere 3 segundo antes de cargar y cambiarla a 15 segundos de espera:
Comcerto-100 >setenv bootdelay=15
     Y con el comando saveenv lo grabamos en la memoria flash:
Comcerto-100 > saveenv
     En nuestro próximo arranque, esperará 15 segundos antes de arrancar.

     Hay otros comandos nada peligrosos, como:
Comcerto-100 > version
-----------------------------
U-Boot 1.1.6 (Mar 4 2011 - 10:29:05) Teldat 1.0.3
ARM Clock: 450000000 Hz
AHB Clock: 165000000 Hz
DDR Size : 256 MByte
-----------------------------
     Podemos cambiar tamaño de las particiones, renombrarlas, montarlas por ejemplo como rw, y jugar con ellas, NO LO HAGAS, es tan peligroso como suena, y no vamos a tocar el tema JTAG por el momento. 

     Vamos a darle un poco de utilidad al tema del U-boot en el próximos post.

No hay comentarios: