RTEMS 4.11已经支持STM32F4系列的BSP了,因此移植还是相当的简单。移植过程如下:
(1)开发环境的建立:使用官方的工具链直接生成RTEMS 4.11的工具链(gcc 4.9.3)。
(2)下载RTEMS 4.11的内核源码(分支:4.11)。
(3)修改内核源码与stm32f429相关的配置文件。(默认为:stm32f407 168MHz 我使用stm32f429 180MHz)。
修改: rtems-4.11/c/src/lib/libbsp/arm/stm32f4/configure.ac
-
AC_PREREQ([2.69])
-
AC_INIT([rtems-c-src-lib-libbsp-arm-stm32f4],[_RTEMS_VERSION],[https:
-
AC_CONFIG_SRCDIR([bsp_specs])
-
RTEMS_TOP(../../../../../..)
-
-
RTEMS_CANONICAL_TARGET_CPU
-
AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.12.2])
-
RTEMS_BSP_CONFIGURE
-
-
RTEMS_PROG_CC_FOR_TARGET
-
RTEMS_CANONICALIZE_TOOLS
-
RTEMS_PROG_CCAS
-
-
RTEMS_CHECK_NETWORKING
-
AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
-
-
-
RTEMS_BSPOPTS_SET([STM32F4_FAMILY_F4XXXX],[stm32f4*],[1])
-
RTEMS_BSPOPTS_HELP([STM32F4_FAMILY_F4XXXX],[Chip belongs to the STM32F4XXXX family.])
-
-
RTEMS_BSPOPTS_SET([STM32F4_HSE_OSCILLATOR],[*],[8000000])
-
RTEMS_BSPOPTS_HELP([STM32F4_HSE_OSCILLATOR],[HSE oscillator frequency in Hz])
-
-
RTEMS_BSPOPTS_SET([STM32F4_SYSCLK],[*],[180000000])
-
RTEMS_BSPOPTS_HELP([STM32F4_SYSCLK],[SYSCLK frequency in Hz])
-
-
RTEMS_BSPOPTS_SET([STM32F4_HCLK],[*],[180000000])
-
RTEMS_BSPOPTS_HELP([STM32F4_HCLK],[HCLK frequency in Hz])
-
-
RTEMS_BSPOPTS_SET([STM32F4_PCLK1],[*],[45000000])
-
RTEMS_BSPOPTS_HELP([STM32F4_PCLK1],[PCLK1 frequency in Hz])
-
-
RTEMS_BSPOPTS_SET([STM32F4_PCLK2],[*],[90000000])
-
RTEMS_BSPOPTS_HELP([STM32F4_PCLK2],[PCLK2 frequency in Hz])
-
-
RTEMS_BSPOPTS_SET([STM32F4_USART_BAUD],[*],[115200])
-
RTEMS_BSPOPTS_HELP([STM32F4_USART_BAUD],[baud for USARTs])
-
-
RTEMS_BSPOPTS_SET([STM32F4_ENABLE_USART_1],[*],[])
-
RTEMS_BSPOPTS_HELP([STM32F4_ENABLE_USART_1],[enable USART 1])
-
-
RTEMS_BSPOPTS_SET([STM32F4_ENABLE_USART_2],[*],[])
-
RTEMS_BSPOPTS_HELP([STM32F4_ENABLE_USART_2],[enable USART 2])
-
-
RTEMS_BSPOPTS_SET([STM32F4_ENABLE_USART_3],[*],[1])
-
RTEMS_BSPOPTS_HELP([STM32F4_ENABLE_USART_3],[enable USART 3])
-
-
RTEMS_BSPOPTS_SET([STM32F4_ENABLE_UART_4],[*],[])
-
RTEMS_BSPOPTS_HELP([STM32F4_ENABLE_UART_4],[enable UART 4])
-
-
RTEMS_BSPOPTS_SET([STM32F4_ENABLE_UART_5],[*],[])
-
RTEMS_BSPOPTS_HELP([STM32F4_ENABLE_UART_5],[enable UART 5])
-
-
RTEMS_BSPOPTS_SET([STM32F4_ENABLE_USART_6],[*],[])
-
RTEMS_BSPOPTS_HELP([STM32F4_ENABLE_USART_6],[enable USART 6])
-
-
RTEMS_BSPOPTS_SET([STM32F4_ENABLE_I2C1],[*],[])
-
RTEMS_BSPOPTS_HELP([STM32F4_ENABLE_I2C1],[enable I2C 1])
-
-
RTEMS_BSPOPTS_SET([STM32F4_ENABLE_I2C2],[*],[])
-
RTEMS_BSPOPTS_HELP([STM32F4_ENABLE_I2C2],[enable I2C 2])
-
-
RTEMS_BSP_CLEANUP_OPTIONS(0, 0)
-
RTEMS_BSP_LINKCMDS
-
-
AC_CONFIG_FILES([Makefile])
-
AC_OUTPUT
(4)修改启动部分的初始化函数:
/rtems-4.11/c/src/lib/libbsp/arm/stm32f4/startup/bspstart.c
-
-
apbpre1 = ( sys_clk * 100 ) / 45;
-
-
if ( apbpre1 <= 100 ) {
-
apbpre1 = RCC_CFGR_PPRE1_BY_1;
-
} else if ( apbpre1 <= 200 ) {
-
apbpre1 = RCC_CFGR_PPRE1_BY_2;
-
} else if ( apbpre1 <= 400 ) {
-
apbpre1 = RCC_CFGR_PPRE1_BY_4;
-
} else if ( apbpre1 <= 800 ) {
-
apbpre1 = RCC_CFGR_PPRE1_BY_8;
-
} else if ( apbpre1 ) {
-
apbpre1 = RCC_CFGR_PPRE1_BY_16;
-
}
-
-
-
apbpre2 = ( sys_clk * 100 ) / 90;
-
-
if ( apbpre2 <= 100 ) {
-
apbpre2 = RCC_CFGR_PPRE2_BY_1;
-
} else if ( apbpre2 <= 200 ) {
-
apbpre2 = RCC_CFGR_PPRE2_BY_2;
-
} else if ( apbpre2 <= 400 ) {
-
apbpre2 = RCC_CFGR_PPRE2_BY_4;
-
} else if ( apbpre2 <= 800 ) {
-
apbpre2 = RCC_CFGR_PPRE2_BY_8;
-
} else {
-
apbpre2 = RCC_CFGR_PPRE2_BY_16;
-
}
-
-
rcc->cr |= RCC_CR_HSION;
-
-
while ( ( !( rcc->cr & RCC_CR_HSIRDY ) ) ) ;
(5) 目前修改这么多,就可以了,后期还需要继续修改。
然后在rtmes-4.11主目录,执行编译相关的命令。
# ./bootstrap -c
#./boostrap -p
#./bootstrap
#cd ..
#mkdir stm32f4
#cd stm32f4
# ../rtems-4.11/configure --target=arm-rtems4.11 --disable-posix --disable-itron --disable-cxx --disable-networking --enable-rtemsbsp="stm32f4" --prefix=/home/RTEMS/stm32f4
#make
#make install
(6)这样,在 stm32f4/arm-rtems4.12/c/stm32f4/testsuites/samples/hello目录下,就能生成测试文件
(7)编译stlink 的工具,生成st-flash等工具
(8)arm-rtems-objcopy -O binary hello.exe hello.bin可以生成bin文件,
st-flash write hello.bin 0x8000000即可下载到开发板。
(9)连接串口为:串口3 TTL电平,需要USB转TTL(3.3V TTL)等工具看一下输出效果。
如果成功打印,说明STM32F429 RTEMS BSP基本上正常了,可以再试一下ticker fileio等测试程序,基本上可以验证RTEMS是否成功运行。
我移植的下载地址:
阅读(2188) | 评论(0) | 转发(0) |