Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
4.0.2的HWCRYPTO例子编译错误
发布于 2019-12-24 00:11:46 浏览:2144
订阅该版
menuconfig已使能 ![截图_2019-12-24_00-06-10.png](/uploads/201912/24/000807g4cy0y06w4x4fjx6.png) hwcrypto的子选项全部选了,板子stm32f411 .config ```CONFIG_RT_USING_HWCRYPTO=y CONFIG_RT_HWCRYPTO_DEFAULT_NAME="hwcryto" CONFIG_RT_HWCRYPTO_IV_MAX_SIZE=16 CONFIG_RT_HWCRYPTO_KEYBIT_MAX_SIZE=256 CONFIG_RT_HWCRYPTO_USING_GCM=y CONFIG_RT_HWCRYPTO_USING_AES=y CONFIG_RT_HWCRYPTO_USING_AES_ECB=y CONFIG_RT_HWCRYPTO_USING_AES_CBC=y CONFIG_RT_HWCRYPTO_USING_AES_CFB=y CONFIG_RT_HWCRYPTO_USING_AES_CTR=y CONFIG_RT_HWCRYPTO_USING_AES_OFB=y CONFIG_RT_HWCRYPTO_USING_DES=y CONFIG_RT_HWCRYPTO_USING_DES_ECB=y CONFIG_RT_HWCRYPTO_USING_DES_CBC=y CONFIG_RT_HWCRYPTO_USING_3DES=y CONFIG_RT_HWCRYPTO_USING_3DES_ECB=y CONFIG_RT_HWCRYPTO_USING_3DES_CBC=y CONFIG_RT_HWCRYPTO_USING_RC4=y CONFIG_RT_HWCRYPTO_USING_MD5=y CONFIG_RT_HWCRYPTO_USING_SHA1=y CONFIG_RT_HWCRYPTO_USING_SHA2=y CONFIG_RT_HWCRYPTO_USING_SHA2_224=y CONFIG_RT_HWCRYPTO_USING_SHA2_256=y CONFIG_RT_HWCRYPTO_USING_SHA2_384=y CONFIG_RT_HWCRYPTO_USING_SHA2_512=y CONFIG_RT_HWCRYPTO_USING_RNG=y CONFIG_RT_HWCRYPTO_USING_CRC=y CONFIG_RT_HWCRYPTO_USING_CRC_07=y CONFIG_RT_HWCRYPTO_USING_CRC_8005=y CONFIG_RT_HWCRYPTO_USING_CRC_1021=y CONFIG_RT_HWCRYPTO_USING_CRC_3D65=y CONFIG_RT_HWCRYPTO_USING_CRC_04C11DB7=y CONFIG_RT_HWCRYPTO_USING_BIGNUM=y CONFIG_RT_HWCRYPTO_USING_BIGNUM_EXPTMOD=y CONFIG_RT_HWCRYPTO_USING_BIGNUM_MULMOD=y CONFIG_RT_HWCRYPTO_USING_BIGNUM_MUL=y CONFIG_RT_HWCRYPTO_USING_BIGNUM_ADD=y CONFIG_RT_HWCRYPTO_USING_BIGNUM_SUB=y``` 提示错误 ```build/applications/main.o: In function `hw_aes_cbc': ~/downloads/stm32f411ceu6/applications/main.c:10: undefined reference to `rt_hwcrypto_dev_dufault' build/applications/main.o: In function `hw_hash': ~/downloads/stm32f411ceu6/applications/main.c:29: undefined reference to `rt_hwcrypto_dev_dufault'``` 代码抄的 ```https://www.rt-thread.org/document/site/programming-manual/device/crypto/crypto/#_50``` rt_hwcrypto_dev_dufault()方法在下面文件里面有 ```${workspaceFolder}/rt-thread/components/drivers/hwcrypto/hwcrypto.c```
查看更多
9
个回答
默认排序
按发布时间排序
RTT_User1
2019-12-24
这家伙很懒,什么也没写!
[i=s] 本帖最后由 RTT_User1 于 2019-12-24 15:57 编辑 [/i] rt_hwcrypto_dev_**dufault** 这个应该是文档上面写错了 调用这个函数就可以 **rt_hwcrypto_dev_default()** ``` /** * @brief Get the default hardware crypto device * * @return Hardware crypto device * */ struct rt_hwcrypto_device *rt_hwcrypto_dev_default(void) { static struct rt_hwcrypto_device *hwcrypto_dev; /* If there is a default device, return the device */ if (hwcrypto_dev) { return hwcrypto_dev; } /* Find by default device name */ hwcrypto_dev = (struct rt_hwcrypto_device *)rt_device_find(RT_HWCRYPTO_DEFAULT_NAME); return hwcrypto_dev; } ```
921742079
2019-12-24
这家伙很懒,什么也没写!
>rt_hwcrypto_dev_dufault > >这个应该是文档上面写错了 --- 感谢,我看了半天也没发现
921742079
2019-12-24
这家伙很懒,什么也没写!
现在创建ctx始终为null ``` ctx = rt_hwcrypto_symmetric_create(rt_hwcrypto_dev_default(), HWCRYPTO_TYPE_AES_CBC); if (ctx == RT_NULL) { rt_kprintf("create AES-CBC context err!"); return; } ``` cubeMX需要设置哪方面的东西么?
921742079
2019-12-24
这家伙很懒,什么也没写!
[i=s] 本帖最后由 921742079 于 2019-12-24 23:22 编辑 [/i] 单步调试 ``` static rt_err_t _crypto_create(struct rt_hwcrypto_ctx *ctx) { rt_err_t res = RT_EOK; switch (ctx->type & HWCRYPTO_MAIN_TYPE_MASK) {
#if defined(BSP_USING_RNG)
case HWCRYPTO_TYPE_RNG: { RNG_HandleTypeDef *hrng = rt_calloc(1, sizeof(RNG_HandleTypeDef)); hrng->Instance = RNG; HAL_RNG_Init(hrng); ctx->contex = hrng; ((struct hwcrypto_rng *)ctx)->ops = &rng_ops; break; } #endif /* BSP_USING_RNG */
#if defined(BSP_USING_CRC)
case HWCRYPTO_TYPE_CRC: { CRC_HandleTypeDef *hcrc = rt_calloc(1, sizeof(CRC_HandleTypeDef)); if (RT_NULL == hcrc) { res = -RT_ERROR; break; } hcrc->Instance = CRC; #if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32F7) hcrc->Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE; hcrc->Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_DISABLE; hcrc->Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_BYTE; hcrc->Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_ENABLE; hcrc->InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES; #else if (HAL_CRC_Init(hcrc) != HAL_OK) { res = -RT_ERROR; } #endif /* defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32F7) */ ctx->contex = hcrc; ((struct hwcrypto_crc *)ctx)->ops = &crc_ops; break; } #endif /* BSP_USING_CRC */ default: res = -RT_ERROR; break; } return res; } ``` 发现是需要定义 BSP_USING_RNG 或者 BSP_USING_CRC menuconfig里面搜索,在On-chip Peripheral Drivers里面看到相应配置, 打开 board/Kconfig,发现关键点 source "libraries/HAL_Drivers/Kconfig" 于是打开 libraries/HAL_Drivers/Kconfig ``` config BSP_USING_CRC bool "Enable CRC (CRC-32 0x04C11DB7 Polynomial)" select RT_USING_HWCRYPTO select RT_HWCRYPTO_USING_CRC # "Crypto device frame dose not support above 8-bits granularity" # "Reserve progress, running well, about 32-bits granularity, such as stm32f1, stm32f4" depends on (SOC_SERIES_STM32L4 || SOC_SERIES_STM32F0 || SOC_SERIES_STM32F7 || SOC_SERIES_STM32H7) default n config BSP_USING_RNG bool "Enable RNG (Random Number Generator)" select RT_USING_HWCRYPTO select RT_HWCRYPTO_USING_RNG depends on (SOC_SERIES_STM32L4 || SOC_SERIES_STM32F4 || SOC_SERIES_STM32F7 || \ SOC_SERIES_STM32H7) default n ``` 我的F4, BSP_USING_CRC 不支持,难怪在menuconfig里面虽然能搜到,但是看不到,勾选了 BSP_USING_RNG,编译,报错,错误信息如下: ``` libraries/HAL_Drivers/drv_crypto.c: In function '_rng_rand': libraries/HAL_Drivers/drv_crypto.c:145:5: error: unknown type name 'RNG_HandleTypeDef' RNG_HandleTypeDef *HW_TypeDef = (RNG_HandleTypeDef *)(ctx->parent.contex); ^~~~~~~~~~~~~~~~~ libraries/HAL_Drivers/drv_crypto.c:145:38: error: 'RNG_HandleTypeDef' undeclared (first use in this function) RNG_HandleTypeDef *HW_TypeDef = (RNG_HandleTypeDef *)(ctx->parent.contex); ^~~~~~~~~~~~~~~~~ libraries/HAL_Drivers/drv_crypto.c:145:38: note: each undeclared identifier is reported only once for each function it appears in libraries/HAL_Drivers/drv_crypto.c:145:57: error: expected expression before ')' token RNG_HandleTypeDef *HW_TypeDef = (RNG_HandleTypeDef *)(ctx->parent.contex); ^ libraries/HAL_Drivers/drv_crypto.c:147:20: warning: implicit declaration of function 'HAL_RNG_GenerateRandomNumber' [-Wimplicit-function-declaration] if (HAL_OK == HAL_RNG_GenerateRandomNumber(HW_TypeDef, &gen_random)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ libraries/HAL_Drivers/drv_crypto.c: In function '_crypto_create': libraries/HAL_Drivers/drv_crypto.c:170:9: error: unknown type name 'RNG_HandleTypeDef' RNG_HandleTypeDef *hrng = rt_calloc(1, sizeof(RNG_HandleTypeDef)); ^~~~~~~~~~~~~~~~~ libraries/HAL_Drivers/drv_crypto.c:170:55: error: 'RNG_HandleTypeDef' undeclared (first use in this function) RNG_HandleTypeDef *hrng = rt_calloc(1, sizeof(RNG_HandleTypeDef)); ^~~~~~~~~~~~~~~~~ libraries/HAL_Drivers/drv_crypto.c:172:13: error: request for member 'Instance' in something not a structure or union hrng->Instance = RNG; ^~ libraries/HAL_Drivers/drv_crypto.c:172:26: error: 'RNG' undeclared (first use in this function) hrng->Instance = RNG; ^~~ libraries/HAL_Drivers/drv_crypto.c:173:9: warning: implicit declaration of function 'HAL_RNG_Init' [-Wimplicit-function-declaration] HAL_RNG_Init(hrng); ^~~~~~~~~~~~ libraries/HAL_Drivers/drv_crypto.c: In function '_crypto_clone': libraries/HAL_Drivers/drv_crypto.c:248:56: error: invalid application of 'sizeof' to incomplete type 'struct hash_ctx_des' rt_memcpy(des->contex, src->contex, sizeof(struct hash_ctx_des)); ^~~~~~ scons: *** [libraries/HAL_Drivers/drv_crypto.o] Error 1 scons: building terminated because of errors. 终端进程已终止,退出代码: 2 ``` 应该怎么弄?
RTT_User1
2019-12-25
这家伙很懒,什么也没写!
>单步调试发现是需要定义 >BSP_USING_RNG >或者 --- F411 系列好像没有RNG
921742079
2019-12-25
这家伙很懒,什么也没写!
>F411 系列好像没有RNG --- 好吧,感谢
RTT_User1
2019-12-25
这家伙很懒,什么也没写!
>好吧,感谢 --- 你开启CRC试一下
921742079
2019-12-25
这家伙很懒,什么也没写!
>你开启CRC试一下 --- 好
921742079
2019-12-25
这家伙很懒,什么也没写!
测试了下,cubeMX里面开启这个没用,KConfig里面修改下面这段 ``` config SOC_STM32F411CE bool select SOC_SERIES_STM32F4 select RT_USING_COMPONENTS_INIT select RT_USING_USER_MAIN default y ``` F4改成L4, menuconfig就能看到 [attach]12869[/attach] F4看不到的 [attach]12870[/attach] 还是很感谢,就这样吧,以后换板子的时候再研究吧
撰写答案
登录
注册新账号
关注者
0
被浏览
2.1k
关于作者
921742079
这家伙很懒,什么也没写!
提问
42
回答
145
被采纳
3
关注TA
发私信
相关问题
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
如何在master上的BSP中添加配置yml文件
2
使用百度AI助手辅助编写一个rt-thread下的ONVIF设备发现功能的功能代码
3
RT-Thread 发布 EtherKit开源以太网硬件!
4
rt-thread使用cherryusb实现虚拟串口
5
《C++20 图形界面程序:速度与渲染效率的双重优化秘籍》
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
I2C_IIC
WIZnet_W5500
UART
ota在线升级
PWM
cubemx
freemodbus
flash
packages_软件包
BSP
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
socket
中断
Debug
编译报错
msh
SFUD
keil_MDK
rt_mq_消息队列_msg_queue
ulog
C++_cpp
at_device
本月问答贡献
踩姑娘的小蘑菇
7
个答案
3
次被采纳
a1012112796
13
个答案
2
次被采纳
张世争
9
个答案
2
次被采纳
rv666
5
个答案
2
次被采纳
用户名由3_15位
11
个答案
1
次被采纳
本月文章贡献
程序员阿伟
9
篇文章
2
次点赞
hhart
3
篇文章
4
次点赞
大龄码农
1
篇文章
5
次点赞
RTT_逍遥
1
篇文章
2
次点赞
ThinkCode
1
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部