打印
[PIC®/AVR®/dsPIC®产品]

给PIC16F18446 curiosity nano板做个bootloader

[复制链接]
楼主: lcczg
手机看帖
扫描二维码
随时随地手机跟帖
21
本帖最后由 TsaiRH 于 2020-2-13 23:38 编辑
TsaiRH 发表于 2020-2-13 23:20
我现在把编译器换成XC 8 2.0版本,还是不行

编译器是免费版的,Optimization level只能选择0 和1

微信截图_20200213232712.png (43.63 KB )

微信截图_20200213232712.png

使用特权

评论回复
22
lcczg|  楼主 | 2020-2-14 11:12 | 只看该作者
TsaiRH 发表于 2020-2-13 23:36
编译器是免费版的,Optimization level只能选择0 和1

我的工程里bootloader占用的空间预设为0-2FF,优化等级为1的话是放不下的,你将它改为0-3FF。另外其他 所有相对应的地址要做响应的修改(包括 APP 和 HOST当中),如何修改看下1楼附件里的文档,里面的描述很清楚。

使用特权

评论回复
评论
lcczg 2020-3-27 15:17 回复TA
@渔夫的烟斗 :0-3FF是bootloader的存放空间。那么APP的空间就是从400开始。从HOST界面输入APP的地址是也要是400. 看下1楼附件里的文档吧。 
渔夫的烟斗 2020-3-24 10:59 回复TA
0-3ff这个有什么讲究吗?与其它地方是否有相对应的? 
23
TsaiRH| | 2020-2-14 18:25 | 只看该作者
lcczg 发表于 2020-2-14 11:12
我的工程里bootloader占用的空间预设为0-2FF,优化等级为1的话是放不下的,你将它改为0-3FF。另外其他 所有 ...

thks,空间设置改了,现在编译通过了

使用特权

评论回复
24
渔夫的烟斗| | 2020-3-24 10:50 | 只看该作者
lcczg 发表于 2019-6-18 11:54
(二)产生自举程序并下载应用程序
这部分的内容是依据前面提到的实验手册的“”实验2“”部分。
1.创建新 ...

你好,试了一下你给的代码,还是会报错。

CLEAN SUCCESSFUL (total time: 44ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/H/Desktop/PIC_BLD/bootloder and app/bootloader pic16f18446/bootloader demo.X'
make  -f nbproject/Makefile-default.mk dist/default/production/bootloader_demo.X.production.hex
make[2]: Entering directory 'C:/Users/H/Desktop/PIC_BLD/bootloder and app/bootloader pic16f18446/bootloader demo.X'
"D:\XC8\bin\xc8-cc.exe"  -mcpu=16F18446 -c  -fno-short-double -fshort-float -mrom=0-2FF -Os -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mc90lib   -std=c99 -gdwarf-3 -mstack=compiled:auto:auto     -o build/default/production/mcc_generated_files/eusart1.p1 mcc_generated_files/eusart1.c
"D:\XC8\bin\xc8-cc.exe"  -mcpu=16F18446 -c  -fno-short-double -fshort-float -mrom=0-2FF -Os -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mc90lib   -std=c99 -gdwarf-3 -mstack=compiled:auto:auto     -o build/default/production/main.p1 main.c
"D:\XC8\bin\xc8-cc.exe"  -mcpu=16F18446 -c  -fno-short-double -fshort-float -mrom=0-2FF -Os -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mc90lib   -std=c99 -gdwarf-3 -mstack=compiled:auto:auto     -o build/default/production/mcc_generated_files/mcc.p1 mcc_generated_files/mcc.c
"D:\XC8\bin\xc8-cc.exe"  -mcpu=16F18446 -c  -fno-short-double -fshort-float -mrom=0-2FF -Os -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mc90lib   -std=c99 -gdwarf-3 -mstack=compiled:auto:auto     -o build/default/production/mcc_generated_files/device_config.p1 mcc_generated_files/device_config.c
"D:\XC8\bin\xc8-cc.exe"  -mcpu=16F18446 -c  -fno-short-double -fshort-float -mrom=0-2FF -Os -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mc90lib   -std=c99 -gdwarf-3 -mstack=compiled:auto:auto     -o build/default/production/mcc_generated_files/pic16f1_bootload.p1 mcc_generated_files/pic16f1_bootload.c
"D:\XC8\bin\xc8-cc.exe"  -mcpu=16F18446 -c  -fno-short-double -fshort-float -mrom=0-2FF -Os -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mc90lib   -std=c99 -gdwarf-3 -mstack=compiled:auto:auto     -o build/default/production/mcc_generated_files/memory.p1 mcc_generated_files/memory.c
"D:\XC8\bin\xc8-cc.exe"  -mcpu=16F18446 -c  -fno-short-double -fshort-float -mrom=0-2FF -Os -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mc90lib   -std=c99 -gdwarf-3 -mstack=compiled:auto:auto     -o build/default/production/mcc_generated_files/pic16f1_uart.p1 mcc_generated_files/pic16f1_uart.c
"D:\XC8\bin\xc8-cc.exe"  -mcpu=16F18446 -c  -fno-short-double -fshort-float -mrom=0-2FF -Os -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mc90lib   -std=c99 -gdwarf-3 -mstack=compiled:auto:auto     -o build/default/production/mcc_generated_files/pin_manager.p1 mcc_generated_files/pin_manager.c
::: advisory: (2051) The current license does not permit the selected optimization level, using optimization level 2
::: advisory: (2051) The current license does not permit the selected optimization level, using optimization level 2
::: advisory: (2051) The current license does not permit the selected optimization level, using optimization level 2
::: advisory: (2051) The current license does not permit the selected optimization level, using optimization level 2
::: advisory: (2051) The current license does not permit the selected optimization level, using optimization level 2
::: advisory: (2051) The current license does not permit the selected optimization level, using optimization level 2
::: advisory: (2051) The current license does not permit the selected optimization level, using optimization level 2
::: advisory: (2051) The current license does not permit the selected optimization level, using optimization level 2
"D:\XC8\bin\xc8-cc.exe"  -mcpu=16F18446 -Wl,-Map=dist/default/production/bootloader_demo.X.production.map  -DXPRJ_default=default  -Wl,--defsym=__MPLAB_BUILD=1  -fno-short-double -fshort-float -mrom=0-2FF -Os -maddrqual=ignore -xassembler-with-cpp -Wa,-a -msummary=-psect,-class,+mem,-hex,-file  -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mc90lib -std=c99 -gdwarf-3 -mstack=compiled:auto:auto      -Wl,--memorysummary,dist/default/production/memoryfile.xml -o dist/default/production/bootloader_demo.X.production.elf  build/default/production/mcc_generated_files/memory.p1 build/default/production/mcc_generated_files/pic16f1_bootload.p1 build/default/production/mcc_generated_files/eusart1.p1 build/default/production/mcc_generated_files/device_config.p1 build/default/production/mcc_generated_files/pic16f1_uart.p1 build/default/production/mcc_generated_files/mcc.p1 build/default/production/mcc_generated_files/pin_manager.p1 build/default/production/main.p1     
::: advisory: (2051) The current license does not permit the selected optimization level, using optimization level 2
mcc_generated_files/memory.c:58:: warning: (520) function "_FLASH_ReadWord" is never called
mcc_generated_files/memory.c:75:: warning: (520) function "_FLASH_WriteWord" is never called
mcc_generated_files/memory.c:94:: warning: (520) function "_FLASH_WriteBlock" is never called
mcc_generated_files/memory.c:149:: warning: (520) function "_FLASH_EraseBlock" is never called
mcc_generated_files/memory.c:180:: warning: (520) function "_DATAEE_WriteByte" is never called
mcc_generated_files/memory.c:202:: warning: (520) function "_DATAEE_ReadByte" is never called
mcc_generated_files/eusart1.c:93:: warning: (520) function "_EUSART1_is_tx_ready" is never called
mcc_generated_files/eusart1.c:98:: warning: (520) function "_EUSART1_is_rx_ready" is never called
mcc_generated_files/eusart1.c:103:: warning: (520) function "_EUSART1_is_tx_done" is never called
mcc_generated_files/eusart1.c:108:: warning: (520) function "_EUSART1_get_last_status" is never called
mcc_generated_files/pin_manager.c:110:: warning: (520) function "_PIN_MANAGER_IOC" is never called
:0:: error: (1347) can't find 0x24 words (0x24 withtotal) for psect "text3" in class "CODE" (largest unused contiguous range 0x1D)
Non line specific message::: advisory: (1493) updated 32-bit floating-point routines might trigger "can't find space" messages appearing after updating to this release; consider using the smaller 24-bit floating-point types
:0:: error: (1347) can't find 0x23 words (0x23 withtotal) for psect "text22" in class "CODE" (largest unused contiguous range 0x1D)
:0:: error: (1347) can't find 0x21 words (0x21 withtotal) for psect "text5" in class "CODE" (largest unused contiguous range 0x1D)
:0:: error: (1347) can't find 0x12 words (0x12 withtotal) for psect "text9" in class "CODE" (largest unused contiguous range 0x5)
:0:: error: (1347) can't find 0xF words (0xf withtotal) for psect "text1" in class "CODE" (largest unused contiguous range 0x5)
:0:: error: (1347) can't find 0xC words (0xc withtotal) for psect "text20" in class "CODE" (largest unused contiguous range 0x5)
:0:: error: (1347) can't find 0xA words (0xa withtotal) for psect "text2" in class "CODE" (largest unused contiguous range 0x5)
:0:: error: (1347) can't find 0x9 words (0x9 withtotal) for psect "text4" in class "CODE" (largest unused contiguous range 0x5)
:0:: error: (1347) can't find 0x9 words (0x9 withtotal) for psect "text17" in class "CODE" (largest unused contiguous range 0x5)
:0:: error: (1347) can't find 0x8 words (0x8 withtotal) for psect "text19" in class "CODE" (largest unused contiguous range 0x5)
:0:: error: (1347) can't find 0x6 words (0x6 withtotal) for psect "clrtext" in class "CODE" (largest unused contiguous range 0x5)
:0:: error: (1347) can't find 0x6 words (0x6 withtotal) for psect "text7" in class "CODE" (largest unused contiguous range 0x5)
:0:: error: (1347) can't find 0x5 words (0x5 withtotal) for psect "text8" in class "CODE" (largest unused contiguous range 0x0)
:0:: error: (1347) can't find 0x4 words (0x4 withtotal) for psect "maintext" in class "CODE" (largest unused contiguous range 0x0)
(908) exit status = 1
nbproject/Makefile-default.mk:249: recipe for target 'dist/default/production/bootloader_demo.X.production.hex' failed
make[2]: Leaving directory 'C:/Users/H/Desktop/PIC_BLD/bootloder and app/bootloader pic16f18446/bootloader demo.X'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/H/Desktop/PIC_BLD/bootloder and app/bootloader pic16f18446/bootloader demo.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [dist/default/production/bootloader_demo.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 4s)

使用特权

评论回复
25
lcczg|  楼主 | 2020-3-27 15:12 | 只看该作者
渔夫的烟斗 发表于 2020-3-24 10:50
你好,试了一下你给的代码,还是会报错。

你的MPLAB IDE的license不能使用-Os, 它实际用的是-O2. 这是你的输出提示:The current license does not permit the selected optimization level, using optimization level 2。 你和23楼的问题一样。可以往大更改空间设置,见我22楼的回答。

使用特权

评论回复
26
小卡| | 2020-3-30 12:54 | 只看该作者
好文支持~

使用特权

评论回复
27
luochangqing112| | 2020-4-5 21:25 | 只看该作者
好帖

使用特权

评论回复
28
小卡| | 2020-4-8 11:37 | 只看该作者
支持啊~

使用特权

评论回复
29
浪里陶壶| | 2020-4-30 11:01 | 只看该作者
必须赞一个,感谢楼主

使用特权

评论回复
30
Xanxurs| | 2021-7-5 09:36 | 只看该作者
附件点击下载没反应,是我电脑出问题了吗

使用特权

评论回复
31
lcczg|  楼主 | 2021-7-5 16:37 | 只看该作者
Xanxurs 发表于 2021-7-5 09:36
附件点击下载没反应,是我电脑出问题了吗

我试了可以的,你再试下。不行就留个邮箱。

使用特权

评论回复
32
Xanxurs| | 2021-7-7 15:14 | 只看该作者
lcczg 发表于 2021-7-5 16:37
我试了可以的,你再试下。不行就留个邮箱。

大佬,你有没有试试实验三呀,就是把boot与app整合到一个工程里,我整合以后直接编译失败,单个试都是好的

使用特权

评论回复
33
lcczg|  楼主 | 2021-7-7 16:19 | 只看该作者
Xanxurs 发表于 2021-7-7 15:14
大佬,你有没有试试实验三呀,就是把boot与app整合到一个工程里,我整合以后直接编译失败,单个试都是好 ...

编译结果的具体信息帖一下

使用特权

评论回复
34
Xanxurs| | 2021-7-7 20:41 | 只看该作者
lcczg 发表于 2021-7-7 16:19
编译结果的具体信息帖一下

https://bbs.21ic.com/forum.php?mod=viewthread&tid=3146134&page=1#pid12198892
我发了个帖子,大佬移步看下

使用特权

评论回复
35
cxque| | 2022-6-1 08:42 | 只看该作者
您好,

UnifiedHost-1.15.0配置串口时,一点Apply就闪退了,不知道楼主有没有遇到?

使用特权

评论回复
36
lcczg|  楼主 | 2022-6-2 15:02 | 只看该作者
cxque 发表于 2022-6-1 08:42
您好,

UnifiedHost-1.15.0配置串口时,一点Apply就闪退了,不知道楼主有没有遇到?

你安装MPLAB X IDE了吗?
要装的。看6.2 PREREQUISITES (https://ww1.microchip.com/downloads/en/DeviceDoc/40001779B.pdf

使用特权

评论回复
37
cxque| | 2022-6-5 23:10 | 只看该作者
lcczg 发表于 2022-6-2 15:02
你安装MPLAB X IDE了吗?
要装的。看6.2 PREREQUISITES (https://ww1.microchip.com/downloads/en/Devic ...

嗯,有装的。不知道怎么回事,我和同事共4台电脑,全部都是闪退,不知道是不是和公司的系统有关系

使用特权

评论回复
38
喵先森メ| | 2022-6-12 14:45 | 只看该作者
cxque 发表于 2022-6-5 23:10
嗯,有装的。不知道怎么回事,我和同事共4台电脑,全部都是闪退,不知道是不是和公司的系统有关系 ...

这个闪退的问题有解决吗,我这也是闪退

使用特权

评论回复
39
cxque| | 2022-6-14 15:56 | 只看该作者
本帖最后由 cxque 于 2022-6-15 10:12 编辑
lcczg 发表于 2022-6-2 15:02
你安装MPLAB X IDE了吗?
要装的。看6.2 PREREQUISITES (https://ww1.microchip.com/downloads/en/Devic ...

闪退问题可能和公司系统有关系,没有解决,后面自己写上位机了。但是还有其他问题,就是跳转到app后可以运行(串口有调试输出),但是中断用不了了,boot中有设置app的中断向量,不知道什么原因,楼主你知道这是什么问题吗?


boot中设置了中断向量:
// To be device independent, these are set by mcc in memory.h
#define LAST_WORD_MASK                     (WRITE_FLASH_BLOCKSIZE - 1)
#define NEW_RESET_VECTOR                   0x1000
#define NEW_INTERRUPT_VECTOR               0x1004


#define APPLICATION_SIZE_WORDS              (END_FLASH - NEW_RESET_VECTOR)
#define CRC_RESERVED_WORDS                  1U
#define CRC_RESERVED_BYTES                  2U
#define FLASH_CHECK_ADDR_CRC                (END_FLASH - CRC_RESERVED_WORDS)


#define _str(x)                             #x
#define str(x)                              _str(x)

// *****************************************************************************
// The bootloader code does not use any interrupts.
// However, the application code may use interrupts.
// The interrupt vector on a PIC16F is located at
// address 0x0004.
// The following function will be located
// at the interrupt vector and will contain a jump to
// the new application interrupt vector
asm("psect  intentry,global,class=CODE,delta=2");
asm("pagesel " str(NEW_INTERRUPT_VECTOR));
asm("GOTO " str(NEW_INTERRUPT_VECTOR));

application中一使能全局中断,就导致复位:
// Enable the Global Interrupts
INTERRUPT_GlobalInterruptEnable();
// Enable the Peripheral Interrupts
INTERRUPT_PeripheralInterruptEnable();

使用特权

评论回复
40
lcczg|  楼主 | 2022-6-15 17:09 | 只看该作者
cxque 发表于 2022-6-14 15:56
闪退问题可能和公司系统有关系,没有解决,后面自己写上位机了。但是还有其他问题,就是跳转到app后可以运 ...

你用的那颗芯片?有看复位状态寄存器吗?有中断发生吗,是否中断跳转飞掉了?

使用特权

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

本版积分规则