ECB-BF532/how to u-boot

From Wiki-linuxencaja
Jump to: navigation, search

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:

  1. board/cm-bf533.c : Archivo que contiene la información para indentificar la board y el fabricante
  2. include/asm/config-pre.h : Contiene configuraciones y parámetros comunes a los procesadores Blackfin
  3. include/configs/cm-bf533.h :Configuraciones y parámetros exclusivos de la tarjeta cm-bf533
  4. 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:

  1. /*
  2.  * U-boot - main board file
  3.  *
  4.  * Copyright (c) 2005-2008 Analog Devices Inc.
  5.  *
  6.  * Licensed under the GPL-2 or later.
  7.  */
  8.  
  9. #include <common.h>
  10. #include <netdev.h>
  11.  
  12. DECLARE_GLOBAL_DATA_PTR;
  13.  
  14. int checkboard(void)
  15. {
  16. 	printf("Board: emQbit ECB-BF532 board\n");
  17. 	printf("       Support: http://wiki.linuxencaja.net/wiki/ECB-BF532\n");
  18. 	return 0;
  19. }

cm-bf533.h

Luego, buscar el archivo de configuración "include/configs/cm-bf533" el cual debe ser reemplazado por el siguiente:

  1. /*
  2.  * U-boot - Configuration file for ECB-BF532 board
  3.  * 23-Feb-2011
  4.  * State: Running
  5.  *
  6.  */
  7.  
  8. #ifndef __CONFIG_CM_BF533_H__
  9. #define __CONFIG_CM_BF533_H__
  10.  
  11. #include <asm/config-pre.h>
  12.  
  13.  
  14. /*
  15.  * Processor Settings
  16.  */
  17. #define CONFIG_BFIN_CPU             bf533-0.3
  18. #define CONFIG_BFIN_BOOT_MODE       BFIN_BOOT_SPI_MASTER
  19.  
  20.  
  21. /*
  22.  * Clock Settings
  23.  *	CCLK = (CLKIN * VCO_MULT) / CCLK_DIV
  24.  *	SCLK = (CLKIN * VCO_MULT) / SCLK_DIV
  25.  */
  26. /* CONFIG_CLKIN_HZ is any value in Hz					*/
  27. #define CONFIG_CLKIN_HZ			11059200
  28. /* CLKIN_HALF controls the DF bit in PLL_CTL      0 = CLKIN		*/
  29. /*                                                1 = CLKIN / 2		*/
  30. #define CONFIG_CLKIN_HALF		0
  31. /* PLL_BYPASS controls the BYPASS bit in PLL_CTL  0 = do not bypass	*/
  32. /*                                                1 = bypass PLL	*/
  33. #define CONFIG_PLL_BYPASS		0
  34. /* VCO_MULT controls the MSEL (multiplier) bits in PLL_CTL		*/
  35. /* Values can range from 0-63 (where 0 means 64)			*/
  36. #define CONFIG_VCO_MULT			40
  37. /* CCLK_DIV controls the core clock divider				*/
  38. /* Values can be 1, 2, 4, or 8 ONLY					*/
  39. #define CONFIG_CCLK_DIV			1
  40. /* SCLK_DIV controls the system clock divider				*/
  41. /* Values can range from 1-15						*/
  42. #define CONFIG_SCLK_DIV			3
  43.  
  44. /* Decrease core voltage */
  45. #define CONFIG_VR_CTL_VAL (VLEV_115 | GAIN_20 | FREQ_1000)
  46.  
  47.  
  48. /*
  49.  * Memory Settings
  50.  */
  51. #define CONFIG_MEM_ADD_WDTH	9
  52. #define CONFIG_MEM_SIZE		32
  53.  
  54. #define CONFIG_EBIU_SDRRC_VAL	((((CONFIG_SCLK_HZ / 1000) * 64) / 8192) - (7 + 2))
  55. #define CONFIG_EBIU_SDGCTL_VAL	(SCTLE | PSS | TWR_2 | TRCD_2 | TRP_2 | TRAS_7 | PASR_ALL | CL_3)
  56.  
  57. #define CONFIG_EBIU_AMGCTL_VAL	(AMBEN_ALL)
  58. #define CONFIG_EBIU_AMBCTL0_VAL	(B1WAT_7 | B1RAT_11 | B1HT_2 | B1ST_3 | B0WAT_7 | B0RAT_11 | B0HT_2 | B0ST_3)
  59. #define CONFIG_EBIU_AMBCTL1_VAL	(B3WAT_7 | B3RAT_11 | B3HT_2 | B3ST_3 | B2WAT_7 | B2RAT_11 | B2HT_2 | B2ST_3)
  60.  
  61. #define CONFIG_SYS_MONITOR_LEN	(256 * 1024)
  62. #define CONFIG_SYS_MALLOC_LEN	(128 * 1024)
  63.  
  64.  
  65. /*
  66.  * Network Settings
  67.  */
  68. #undef ADI_CMDS_NETWORK
  69. #undef CONFIG_CMD_IMI
  70. #undef CONFIG_CMD_NFS
  71. #undef CONFIG_BFIN_MAC
  72. #undef CONFIG_CMD_PING
  73. #undef CONFIG_CMD_TFTPBOOT
  74. #undef CONFIG_CMD_NET
  75. #undef CONFIG_CMD_FLASH
  76. #undef CONFIG_CMD_IMLS
  77.  
  78.  
  79. /*
  80.  * Flash Settings
  81.  */
  82. #define CONFIG_FLASH_CFI_DRIVER
  83. #define CONFIG_SYS_FLASH_BASE		0x20000000
  84. #define CONFIG_SYS_FLASH_CFI
  85. #define CONFIG_SYS_MAX_FLASH_BANKS	1
  86. #define CONFIG_SYS_MAX_FLASH_SECT	16
  87.  
  88.  
  89. /*
  90.  * Serial Flash Infomation
  91.  */
  92. #define CONFIG_BFIN_SPI
  93. #define CONFIG_ENV_SPI_MAX_HZ	20000000
  94. #define CONFIG_SF_DEFAULT_SPEED	20000000
  95. #define CONFIG_SPI_FLASH
  96. #define CONFIG_SPI_FLASH_STMICRO
  97. #define CONFIG_CMD_SF
  98.  
  99. /*
  100.  * Env Storage Settings
  101.  */
  102. #define CONFIG_ENV_IS_IN_SPI_FLASH
  103. #define CONFIG_ENV_OFFSET	0x10000
  104. #define CONFIG_ENV_SIZE		0x10000
  105. #define CONFIG_ENV_SECT_SIZE	0x10000
  106. #define CONFIG_ENV_IS_EMBEDDED_IN_LDR
  107.  
  108.  
  109. /*
  110.  * Misc Settings
  111.  */
  112. #define CONFIG_BAUDRATE		115200
  113. #define CONFIG_UART_CONSOLE	0
  114. #define CONFIG_BOOTCOMMAND	"run flashboot"
  115. #define FLASHBOOT_ENV_SETTINGS	"flashboot=bootm 0x20040000\0"
  116.  
  117.  
  118. /*
  119.  * Pull in common ADI header for remaining command/environment setup
  120.  */
  121. #include <configs/bfin_adi_common.h>
  122.  
  123. #endif

Abrir una terminal dentro de la carpeta raíz del u-boot y ejecutar los siguientes comandos:

  1.   make clean
  2.   make cm-bf533_config
  3.   make 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:

  1. #include <asm/blackfin.h>
  2. .global __start
  3. __start:
  4. 	sp.l = LO(L1_SRAM_SCRATCH_END - 20);
  5. 	sp.h = HI(L1_SRAM_SCRATCH_END - 20);
  6. 	call _initcode;
  7. 1:
  8. 	emuexcpt;
  9. 	jump 1b;
  10. .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:

  1. $ 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:

  1. $ bfin-uclinux-readelf -l init.elf
  2. ...
  3. Encabezados de Programa:
  4.   Tipo           Desplaz  DirVirt    DirFísica  TamFich TamMem  Opt Alin
  5.   LOAD           0x001000 0xffa08000 0xffa08000 0x00124 0x00124 R E 0x1000
  6. ...

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:
  1. $ sudo su
  2. 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
  3.  
  4. # bfin-gdbproxy
  5. Found USB cable: ARM-USB-OCD
  6. Connected to libftdi driver.
  7. IR length: 5
  8. Chain length: 1
  9. Device Id: 01010010011110100101000011001011 (0x527A50CB)
  10.   Manufacturer: Analog Devices, Inc. (0x0CB)
  11.   Part(0):      BF533 (0x27A5)
  12.   Stepping:     5
  13.   Filename:     /opt/uClinux/bfin-uclinux/bin/../share/urjtag/analog/bf533/bf533
  14. /usr/src/packages/BUILD/blackfin-toolchain-2010R1/urjtag/src/bfin/bfin-part-bfin.c:154 bfin_wait_ready() 
  15. Warning: untested cable or frequency, set wait_clocks to 21
  16. warning:   bfin: no board selected, BF533 is detected
  17. notice:    bfin: jc: waiting on TCP port 2001
  18. notice:    bfin: jc:  (you must connect GDB before using jtag console)
  19. 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

  1. $ bfin-elf-gdb ./u-boot
  2.  
  3. (gdb) target remote :2000
  4. Remote debugging using :2000
  5. 0xef000000 in ?? ()
  6.  
  7. (gdb) load init.elf
  8. Loading section .text, size 0x124 lma 0xffa08000
  9. Start address 0xffa08000, load size 292
  10. Transfer rate: 58400 bits/sec, 292 bytes/write.
  11.  
  12. (gdb) c
  13. Continuing.
  14. Program received signal SIGTRAP, Trace/breakpoint trap.
  15. 0xffa0800e in ?? ()
  16.  
  17. (gdb) load u-boot
  18. Loading section .text, size 0x12174 lma 0x1fc0000
  19. Loading section .rodata, size 0x56d0 lma 0x1fd2174
  20. Loading section .data, size 0x30cc lma 0x1fd7844
  21. Loading section .u_boot_cmd, size 0x578 lma 0x1fda910
  22. Loading section .text_l1, size 0x2c lma 0x1fdae88
  23. Start address 0x1fc0000, load size 110260
  24. Transfer rate: 1338512 bits/sec, 11026 bytes/write.
  25.  
  26. (gdb) call memset(&_bss_vma, 0, &_bss_len)
  27. warning: Unable to restore previously selected frame.
  28. $2 = 33414508
  29. 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:

  1. (gdb) c
  2. Continuing.

minicom

La respuesta en minicom será del tipo:

  1. U-Boot 2008.10 (ADI-2009R1-pre) (Mar 20 2009 - 21:32:36)
  2.  
  3. CPU:   ADSP bf533-0.3 (Detected Rev: 0.5) (spi flash boot)
  4. Board: emQbit ECB-BF532 board
  5.        Support: http://wiki.linuxencaja.net/wiki/ECB-BF532
  6. Clock: VCO: 442.368 MHz, Core: 442.368 MHz, System: 147.456 MHz
  7. RAM:   32 MB
  8. NAND:  NanD_Command (ReadID) got fd fd
  9. Unknown flash chip found: FD FD
  10. No NAND flash chips recognised.
  11.    0 MB
  12. SF: Got idcode 20 20 16
  13. *** Warning - bad CRC, using default environment
  14.  
  15. In:    serial
  16. Out:   serial
  17. Err:   serial
  18. Hit any key to stop autoboot:  0 
  19. bfin>

Ahora para cargar el u-boot en la SDRAM se utiliza el siguiente comando:

  1. bfin> loady 0x1000000
  2. ## Ready for binary (ymodem) download to 0x01000000 at 115200 bps...                    
  3. 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:

  1. ## Ready for binary (ymodem) download to 0x01000000 at 115200 bps...                    
  2. 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:

  1. bfin> sf probe 2
  2. bfin> sf erase 0 40000
  3. 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:

  1. bfin> setenv flashboot 'sf probe 2; sf read 0x1000000 0x50000 0x200000; bootm 0x1000000'
  2. bfin> setenv bootargs 'root=/dev/mtdblock0 rw console=tty0 console=ttyBF0,115200'
  3. 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:

  1. bfin>

Fuentes

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox