【问题标题】:Running Gmp on Stm32f4 discovery board在 Stm32f4 发现板上运行 Gmp
【发布时间】:2017-05-18 20:22:38
【问题描述】:

我发现了 stm32f4 发现板。 目前,我可以使用 LED、按钮并通过串行端口进行通信。 我现在正在尝试使用此板上的 Gmp 库。 我按照以下说明构建了 arm-none-eabi 工具链:https://blog.tan-ce.com/gcc-bare-metal/

我使用以下选项配置 Gmp: ./configure CC=arm-none-eabi-gcc CFLAGS="-nostartfiles --specs=nosys.specs -g" --host=arm-none-eabi --disable-assembly

我的项目编译和链接没有任何问题,但是 当我尝试使用以下代码初始化板上的 mpz_t 时:

mpz_t a; 
mpz_init_set_str(a, "31", 10);

我陷入了HardFault_Handler(),我的arm-none-eabi-gdb给了我:

(gdb) bt
#0  HardFault_Handler () at ./src/stm32f4xx_it.c:34
#1  <signal handler called>
#2  0x08016ade in __gmpn_fft_best_k (n=134358201, sqr=134358201) at mul_fft.c:151
#3  0x0801816e in __gmpn_mul_fft (op=0x80006f5 <HardFault_Handler>, pl=134219497, n=0x8022471 <Reset_Handler>, nl=537001984, m=0x80224b9 <WWDG_IRQHandler>, ml=134358201, k=134358201) at mul_fft.c:870
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

如果有人已经在微控制器上运行了 Gmp,我对如何实现它非常感兴趣!

【问题讨论】:

    标签: microcontroller stm32 gmp stm32f4discovery


    【解决方案1】:

    我终于找到了解决办法,必须指定皮质类型。 对于stm32f4,在CFLAGS中加入-mcpu=cortex-m4即可解决问题。

    我使用这里提供的工具链:arm-none-eabi toolchain

    整个配置命令是: ./configure CC=arm-none-eabi-gcc CFLAGS="-nostartfiles --specs=nosys.specs -mcpu=cortex-m4" --host=arm-none-eabi --disable-assembly --prefix=your -bare-metal-gmp-location

    其中“your-bare-metal-gmp-location”是安装目录(不能在经典的 /usr/local 中安装裸机库)。

    【讨论】:

      猜你喜欢
      • 2017-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-21
      • 2015-08-18
      • 2018-03-20
      • 2018-10-06
      • 2014-01-14
      相关资源
      最近更新 更多