打印

stm32 redboot移植(去掉FSMC,仅用片内64KRAM)

[复制链接]
4374|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
walnutcy|  楼主 | 2011-7-12 10:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 walnutcy 于 2011-7-12 13:50 编辑

简单介绍下安装, 下载ecos-install.tcl,然后用SHELL执行安装,选ARM工具链及源码即可.

安装ecos3.0源码后,在目录ecos-3.0\packages\hal\cortexm\stm32\下能找到EVAL的开发板,
这块开发板有外扩的RAM及NORFlash,手边没有相应的板子,所以这里要修改.

板子是105RC的,所以复制stm3210e_eval目录为stm32f105_tcu,并修改其中的CDL及源码、LDI等文件,包括文件名及内容。
CDL根据板子修改如下:文件名,
修改串口号,

# implements CYGINT_HAL_STM32_UART0
# implements CYGINT_HAL_STM32_UART1
# walnutcy 2011.07.08

implements CYGINT_HAL_STM32_UART3
implements CYGINT_HAL_STM32_UART4
修改启动方式:
cdl_component CYG_HAL_STARTUP {
display "Startup type"
flavor data
default_value {"ROM"}
legal_values {"ROM"}
修改内存布局:

cdl_component CYGHWR_MEMORY_LAYOUT {
display "Memory layout"
flavor data
no_define
calculated { "cortexm_stm32f105_tcu_rom" }

include/pkgconf下只留两个文件:
mlt_cortexm_stm32f105_tcu_rom.ldi, mlt_cortexm_stm32f105_tcu_rom.h
H文件修改后如下:
#define CYGMEM_REGION_sram (0x20000000)
#define CYGMEM_REGION_sram_SIZE (0x00010000-CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE)
#define CYGMEM_REGION_sram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
#define CYGMEM_REGION_flash (0x08000000)
#define CYGMEM_REGION_flash_SIZE (0x00080000)
#define CYGMEM_REGION_flash_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
// walnutcy 2011.07.07
#define CYGMEM_REGION_ram  
CYGMEM_REGION_sram
#define CYGMEM_REGION_ram_SIZE  
CYGMEM_REGION_sram_SIZE
//#define CYGMEM_REGION_ram (0x68000000)
//#define CYGMEM_REGION_ram_SIZE (0x00100000)
//#define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
//#define CYGMEM_REGION_rom (0x64000000)
//#define CYGMEM_REGION_rom_SIZE (0x01000000)
//#define CYGMEM_REGION_rom_ATTR (CYGMEM_REGION_ATTR_R)
LDI文件修改后如下:
MEMORY
{
    sram: ORIGIN = 0x20000000, LENGTH = 0x00010000-CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE
    flash : ORIGIN = 0x08000000, LENGTH = 0x00080000
}

SECTIONS
{
SECTIONS_BEGIN
SECTION_rom_vectors (flash, 0x08000000, LMA_EQ_VMA)
SECTION_RELOCS (flash, ALIGN (0x8), LMA_EQ_VMA)
SECTION_text (flash, ALIGN (0x8), LMA_EQ_VMA)
SECTION_fini (flash, ALIGN (0x8), LMA_EQ_VMA)
SECTION_rodata (flash, ALIGN (0x8), LMA_EQ_VMA)
SECTION_rodata1 (flash, ALIGN (0x8), LMA_EQ_VMA)
SECTION_fixup (flash, ALIGN (0x8), LMA_EQ_VMA)
SECTION_gcc_except_table (flash, ALIGN (0x8), LMA_EQ_VMA)
SECTION_eh_frame (flash, ALIGN (0x8), LMA_EQ_VMA)
SECTION_got (flash, ALIGN (0x8), LMA_EQ_VMA)
SECTION_sram (sram, 0x20000400, FOLLOWING (.got))
SECTION_data (sram, ALIGN (0x8), FOLLOWING (.sram))
SECTION_bss (sram, ALIGN (0x8), LMA_EQ_VMA)
CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
SECTIONS_END
}
其他代码修改部分:
stm32f105_tcu_misc.c修改,
hal_system_init函数中注释掉部分,如下:

// Set up GPIO lines for external bus
//base = CYGHWR_HAL_STM32_GPIOD;
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_GPIO_CRL, 0x44bb44bb );
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_GPIO_CRH, 0xbbbbbbbb );
//base = CYGHWR_HAL_STM32_GPIOE;
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_GPIO_CRL, 0xbbbbb4bb );
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_GPIO_CRH, 0xbbbbbbbb );
//base = CYGHWR_HAL_STM32_GPIOF;
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_GPIO_CRL, 0x44bbbbbb );
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_GPIO_CRH, 0xbbbb4444 );
//base = CYGHWR_HAL_STM32_GPIOG;
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_GPIO_CRL, 0x44bbbbbb );
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_GPIO_CRH, 0x44444bb4 );

//---walnutcy 2011.07.07  
// Set up FSMC NOR/SRAM bank 2 for NOR Flash

//base = CYGHWR_HAL_STM32_FSMC;
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_FSMC_BCR2, 0x00001059 );
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_FSMC_BTR2, 0x10000705 );

// Set up FSMC NOR/SRAM bank 3 for SRAM
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_FSMC_BCR3, 0x00001011 );
//HAL_WRITE_UINT32( base+CYGHWR_HAL_STM32_FSMC_BTR3, 0x00000200 );

stm32f105_tcu_flash.c中修改如下:
删除AMD NorFlash相关函数,修改后如下:
cyg_stm32_flash_dev hal_stm32_flash_priv;
CYG_FLASH_DRIVER(hal_stm32_flash,
&cyg_stm32_flash_funs,
0,
0x08000000,
0,
0,
0,
&hal_stm32_flash_priv
);

最后是修改ecos.db,在文件的最后添加:
package CYGPKG_HAL_CORTEXM_STM32_STM32F105_TCU {
alias { "ST STM32F105 TCU HAL" hal_cortexm_stm32f105_tcu }
directory hal/cortexm/stm32/stm32f105_tcu
script hal_cortexm_stm32_stm32f105_tcu.cdl
hardware  
description "
The stm32f105_tcu HAL package provides the support needed to run
eCos on the ST STM32F105 TCU board."
}

target stm32f105_tcu {
alias { "ST STM32F105 TCU board" stm32f105 }
packages { CYGPKG_HAL_CORTEXM
        CYGPKG_HAL_CORTEXM_STM32
        CYGPKG_HAL_CORTEXM_STM32_STM32F105_TCU
        CYGPKG_DEVS_FLASH_STM32
        CYGPKG_DEVS_FLASH_SPI_M25PXX
        CYGPKG_IO_SERIAL_CORTEXM_STM32
        CYGPKG_DEVS_WALLCLOCK_STM32
        CYGPKG_IO_SPI
        CYGPKG_DEVS_SPI_CORTEXM_STM32
    }

description "The stm32f105_tcu target provides the packages needed
to run eCos on the STM32F105 TCU board."
}

完成后,启动ecos configuration tool, 即可在Build/templates中找到STM32F105 TCU board,选择redboot编译即可,
在install目录会生成redboot.bin,不修改编译参数的情况下,大小约为40K。
redboot.elf 是用于调试的。可以在keil下仿真运行,从serial window查看redboot启动。
注serialwindow目前只能较好地支持STM32的uart1,uart2.
沙发
香水城| | 2011-7-12 11:23 | 只看该作者
送裤子。  字太小!

使用特权

评论回复
板凳
walnutcy|  楼主 | 2011-7-12 13:55 | 只看该作者
2# 香水城
拿word写的,没处理,
重新用coolformat格式化了一下,漂亮了一些。:lol

使用特权

评论回复
地板
hsbjb| | 2011-7-13 10:18 | 只看该作者
很有想法

使用特权

评论回复
5
bucker| | 2012-9-2 22:56 | 只看该作者
学习一下

使用特权

评论回复
6
john_lee| | 2012-9-3 02:00 | 只看该作者
楼主太有时间了。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

111

主题

1443

帖子

5

粉丝