ECB-BF532/how to u-boot
Contents |
Cargar U-boot en la SPI Flash
- Nota 1: Para hacer este tutorial es necesario que utilice las últimas versiones estables del toolchain, el u-boot y de las herramientas que provee el sistema operativo
- Nota 2: Para lograr cargar u-boot, el BF532 debe ser inicializado en BMODE=00 (Bypass), de esta forma se garantiza que no se inicie otro u-boot cargado anteriormente o que se ejecute código en la Boot ROM en busca de otro dispositivo de inicio.
Descargar el archivo u-boot-20xx.xx-XXXXX.tar.bz2 buscando en los ficheros del Das-Uboot
Descomprimir en una carpeta; ahora que se tiene el U-boot es importante recordar los archivos importantes para la configuración del sistema:
- board/cm-bf533.c : Archivo que contiene la información para indentificar la board y el fabricante
- include/asm/config-pre.h : Contiene configuraciones y parámetros comunes a los procesadores Blackfin
- include/configs/cm-bf533.h :Configuraciones y parámetros exclusivos de la tarjeta cm-bf533
- configs/bfin_adi_common.h : Configuraciones comunes de las tarjetas de Analogs Devices
cm-bf533.c
Primero ir al archivo "board/cm-bf533.c" y reemplazarlo por el siguiente:
/** U-boot - main board file** Copyright (c) 2005-2008 Analog Devices Inc.** Licensed under the GPL-2 or later.*/#include <common.h>#include <netdev.h>DECLARE_GLOBAL_DATA_PTR;int checkboard(void)
{printf("Board: emQbit ECB-BF532 board\n");
printf(" Support: http://wiki.linuxencaja.net/wiki/ECB-BF532\n");
return 0;
}
cm-bf533.h
Luego, buscar el archivo de configuración "include/configs/cm-bf533" el cual debe ser reemplazado por el siguiente:
/** U-boot - Configuration file for ECB-BF532 board* 23-Feb-2011* State: Running**/#ifndef __CONFIG_CM_BF533_H__#define __CONFIG_CM_BF533_H__#include <asm/config-pre.h>/** Processor Settings*/#define CONFIG_BFIN_CPU bf533-0.3#define CONFIG_BFIN_BOOT_MODE BFIN_BOOT_SPI_MASTER/** Clock Settings* CCLK = (CLKIN * VCO_MULT) / CCLK_DIV* SCLK = (CLKIN * VCO_MULT) / SCLK_DIV*//* CONFIG_CLKIN_HZ is any value in Hz */#define CONFIG_CLKIN_HZ 11059200/* CLKIN_HALF controls the DF bit in PLL_CTL 0 = CLKIN *//* 1 = CLKIN / 2 */#define CONFIG_CLKIN_HALF 0/* PLL_BYPASS controls the BYPASS bit in PLL_CTL 0 = do not bypass *//* 1 = bypass PLL */#define CONFIG_PLL_BYPASS 0/* VCO_MULT controls the MSEL (multiplier) bits in PLL_CTL *//* Values can range from 0-63 (where 0 means 64) */#define CONFIG_VCO_MULT 40/* CCLK_DIV controls the core clock divider *//* Values can be 1, 2, 4, or 8 ONLY */#define CONFIG_CCLK_DIV 1/* SCLK_DIV controls the system clock divider *//* Values can range from 1-15 */#define CONFIG_SCLK_DIV 3/* Decrease core voltage */#define CONFIG_VR_CTL_VAL (VLEV_115 | GAIN_20 | FREQ_1000)/** Memory Settings*/#define CONFIG_MEM_ADD_WDTH 9#define CONFIG_MEM_SIZE 32#define CONFIG_EBIU_SDRRC_VAL ((((CONFIG_SCLK_HZ / 1000) * 64) / 8192) - (7 + 2))#define CONFIG_EBIU_SDGCTL_VAL (SCTLE | PSS | TWR_2 | TRCD_2 | TRP_2 | TRAS_7 | PASR_ALL | CL_3)#define CONFIG_EBIU_AMGCTL_VAL (AMBEN_ALL)#define CONFIG_EBIU_AMBCTL0_VAL (B1WAT_7 | B1RAT_11 | B1HT_2 | B1ST_3 | B0WAT_7 | B0RAT_11 | B0HT_2 | B0ST_3)#define CONFIG_EBIU_AMBCTL1_VAL (B3WAT_7 | B3RAT_11 | B3HT_2 | B3ST_3 | B2WAT_7 | B2RAT_11 | B2HT_2 | B2ST_3)#define CONFIG_SYS_MONITOR_LEN (256 * 1024)#define CONFIG_SYS_MALLOC_LEN (128 * 1024)/** Network Settings*/#undef ADI_CMDS_NETWORK#undef CONFIG_CMD_IMI#undef CONFIG_CMD_NFS#undef CONFIG_BFIN_MAC#undef CONFIG_CMD_PING#undef CONFIG_CMD_TFTPBOOT#undef CONFIG_CMD_NET#undef CONFIG_CMD_FLASH#undef CONFIG_CMD_IMLS/** Flash Settings*/#define CONFIG_FLASH_CFI_DRIVER#define CONFIG_SYS_FLASH_BASE 0x20000000#define CONFIG_SYS_FLASH_CFI#define CONFIG_SYS_MAX_FLASH_BANKS 1#define CONFIG_SYS_MAX_FLASH_SECT 16/** Serial Flash Infomation*/#define CONFIG_BFIN_SPI#define CONFIG_ENV_SPI_MAX_HZ 20000000#define CONFIG_SF_DEFAULT_SPEED 20000000#define CONFIG_SPI_FLASH#define CONFIG_SPI_FLASH_STMICRO#define CONFIG_CMD_SF/** Env Storage Settings*/#define CONFIG_ENV_IS_IN_SPI_FLASH#define CONFIG_ENV_OFFSET 0x10000#define CONFIG_ENV_SIZE 0x10000#define CONFIG_ENV_SECT_SIZE 0x10000#define CONFIG_ENV_IS_EMBEDDED_IN_LDR/** Misc Settings*/#define CONFIG_BAUDRATE 115200#define CONFIG_UART_CONSOLE 0#define CONFIG_BOOTCOMMAND "run flashboot"#define FLASHBOOT_ENV_SETTINGS "flashboot=bootm 0x20040000\0"/** Pull in common ADI header for remaining command/environment setup*/#include <configs/bfin_adi_common.h>#endif
Abrir una terminal dentro de la carpeta raíz del u-boot y ejecutar los siguientes comandos:
make clean
make cm-bf533_configmake cm-bf533
init.S
Ahora se procede a crear el archivo init.S, el cual no está incluido en esta versión de u-boot. Para esto, se copia y pega en un archivo de texto llamado init.S el siguiente código:
#include <asm/blackfin.h>.global __start__start:sp.l = LO(L1_SRAM_SCRATCH_END - 20);
sp.h = HI(L1_SRAM_SCRATCH_END - 20);
call _initcode;1:
emuexcpt;jump 1b;.size __start, .-__start
Luego de guardar y cerrar el documento (el cual debe quedar grabado dentro de la carpeta de u-boot), se ejecuta el siguiente comando:
$ bfin-elf-gcc -nostartfiles init.S arch/blackfin/cpu/initcode.o -o init.elf -Iinclude -D__ASSEMBLY__ -mcpu=bf532
Luego en la carpeta del u-boot se creará el init.elf. Para verificar la dirección de memoria física se utiliza el siguiente código:
$ bfin-uclinux-readelf -l init.elf
...
Encabezados de Programa:
Tipo Desplaz DirVirt DirFísica TamFich TamMem Opt Alin
LOAD 0x001000 0xffa08000 0xffa08000 0x00124 0x00124 R E 0x1000
...
Como se observa la dirección correcta de memoria física debe ser: 0xffa08000, debido al mapeo de memoria del bf-532 Hasta este momento se han generado los archivos necesarios, ahora se procede a ejecutarlos en la memoria interna del Blackfin.
gdbproxy
Ahora, lo primero es conectarse al gdbproxy como root, configurando el cable adecuadamente:
- Nota: Para solucionar el problema de permisos y el PATH hacer como root:
$ sudo su
export PATH=:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/uClinux/bfin-uclinux/bin:/opt/uClinux/bfin-linux-uclibc/bin:/opt/uClinux/bfin-elf/bin
# bfin-gdbproxyFound USB cable: ARM-USB-OCD
Connected to libftdi driver.
IR length: 5
Chain length: 1
Device Id: 01010010011110100101000011001011 (0x527A50CB)
Manufacturer: Analog Devices, Inc. (0x0CB)
Part(0): BF533 (0x27A5)
Stepping: 5
Filename: /opt/uClinux/bfin-uclinux/bin/../share/urjtag/analog/bf533/bf533
/usr/src/packages/BUILD/blackfin-toolchain-2010R1/urjtag/src/bfin/bfin-part-bfin.c:154 bfin_wait_ready()
Warning: untested cable or frequency, set wait_clocks to 21
warning: bfin: no board selected, BF533 is detected
notice: bfin: jc: waiting on TCP port 2001
notice: bfin: jc: (you must connect GDB before using jtag console)
notice: bfin-gdbproxy: waiting on TCP port 2000
A partir de ahora se ingresarán datos en la tarjeta, por lo que si ya contiene algún modo de boot, por ejemplo por SPI_MASTER, lo mejor es forzar por medio de un par de jumpers el booteo por Bypass (Bmode=00) (ver imagen --FIXME). Teniendo el boot ahora por bypass entonces, en otra terminal abierta y teniendo el prompt dentro de la carpeta del u-boot:
gdb
$ bfin-elf-gdb ./u-boot
(gdb) target remote :2000
Remote debugging using :2000
0xef000000 in ?? ()
(gdb) load init.elf
Loading section .text, size 0x124 lma 0xffa08000
Start address 0xffa08000, load size 292
Transfer rate: 58400 bits/sec, 292 bytes/write.
(gdb) c
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0xffa0800e in ?? ()
(gdb) load u-boot
Loading section .text, size 0x12174 lma 0x1fc0000
Loading section .rodata, size 0x56d0 lma 0x1fd2174
Loading section .data, size 0x30cc lma 0x1fd7844
Loading section .u_boot_cmd, size 0x578 lma 0x1fda910
Loading section .text_l1, size 0x2c lma 0x1fdae88
Start address 0x1fc0000, load size 110260
Transfer rate: 1338512 bits/sec, 11026 bytes/write.
(gdb) call memset(&_bss_vma, 0, &_bss_len)
warning: Unable to restore previously selected frame.$2 = 33414508
Current language: auto; currently asm
Nota: Para generar comunicación serial tenga en cuenta que el minicom debe comunicarse a 115200 de Baudrate, 8N1, sin ningún control de flujo. Abrir minicom configurado correctamente en otro terminal para obtener la respuesta del u-boot por puerto serie, luego, en la consola que contiene el gdb:
(gdb) c
Continuing.
minicom
La respuesta en minicom será del tipo:
U-Boot 2008.10 (ADI-2009R1-pre) (Mar 20 2009 - 21:32:36)
CPU: ADSP bf533-0.3 (Detected Rev: 0.5) (spi flash boot)
Board: emQbit ECB-BF532 board
Support: http://wiki.linuxencaja.net/wiki/ECB-BF532
Clock: VCO: 442.368 MHz, Core: 442.368 MHz, System: 147.456 MHz
RAM: 32 MB
NAND: NanD_Command (ReadID) got fd fd
Unknown flash chip found: FD FDNo NAND flash chips recognised.
0 MBSF: Got idcode 20 20 16
*** Warning - bad CRC, using default environment
In: serialOut: serialErr: serialHit any key to stop autoboot: 0
bfin>
Ahora para cargar el u-boot en la SDRAM se utiliza el siguiente comando:
bfin> loady 0x1000000
## Ready for binary (ymodem) download to 0x01000000 at 115200 bps...C
Ahora que se ha abierto un enlace por ymodem se debe abrir la ventana de configuraciones del minicom (ctrl+a z), luego, seleccionar la opción "s" para enviar archivos. Despues de esto se abrirá un menú para seleccionar "ymodem", tras esto, se abrirá un navegador de archivos en el cual se debe buscar el archivo que se desea cargar, en este caso es: /home/xxx/...../u-boot-20xx.xx-XXXXX/u-boot.ldr Si la transmisión fue exitosa el minicom responderá de la siguiente forma:
## Ready for binary (ymodem) download to 0x01000000 at 115200 bps...C## Total Size = 0x00015610 = 87568 Bytes
Ahora, es necesario grabar el programa en la dirección de la memoria SPI la cual será 0x1000000, pero antes se selecciona la memoria:
bfin> sf probe 2
bfin> sf erase 0 40000
bfin> sf write 0x1000000 0 0x40000
Ya que se ha escrito correctamente el u-boot en la SPI sólo falta agregar una variable de entorno, la cual le permitirá seleccionar la memoria spi, leer su contenido en la dirección de memoria asignada (hacer una copia en sdram) y finalmente iniciar (boot) por el archivo que se copio en la ram:
bfin> setenv flashboot 'sf probe 2; sf read 0x1000000 0x50000 0x200000; bootm 0x1000000'
bfin> setenv bootargs 'root=/dev/mtdblock0 rw console=tty0 console=ttyBF0,115200'
bfin> saveenv
Así, al cambiar el BMode=00 (Bypass) por BMode=11 (SPI-Master) y reiniciar la tarjeta debe cargar el u-boot y finalizar con el prompt:
bfin>