原因

IAR 中8051版8.20之前创建的项目,移植到8.30之后得到错误。
官方解释原文:
The error happens since the new cstartup file in version 8.30 has been changed to optimize the usage of the virtual register area.
机翻:
由于更改了版本8.30中的新cstartup文件以优化虚拟寄存器区域的使用,因此发生了错误。

解决方法

修改 Number of virtual 为8

在左侧Workspace下的GenericApp右键–>Options。
在这里插入图片描述

修改 chipcon_cstartup.s51 文件

用记事本打开 ZStack-CC2530-2.5.1a\Projects\zstack\ZMain\TI2530DB下的chipcon_cstartup.s51文件。
现成文件:chipcon_cstartup.s51

  1. 在原文件末尾删除 “END”
  2. 把以下代码复制到最后面
;----------------------------------------------------------------;
; Virtual registers						 ;
; =================						 ;
; Below is some segment needed for the IAR ICC C/EC++ compiler   ;
;								 ;
; BREG  : A segment for 8 bit registers for use by the compiler. ;
;         ?B0 is the first register.                             ;
; VREG  : Segment that holds up to 32 virtual registers for      ;
;         use by the compiler. ?V0 is the first register.        ;
; PSP   : Segment containing the PDATA stack pointer (?PSP)      ;
; XSP   : Segment containing the XDATA stack pointer (?XSP)      ;
; 								 ;
;----------------------------------------------------------------;
;----------------------------------------------------------------;

	PROGRAM VIRTUAL_REGISTERS
	PUBLIC  ?B0
	PUBLIC  ?V0
	PUBLIC  ?V1
	PUBLIC  ?V2
	PUBLIC  ?V3
	PUBLIC  ?V4
	PUBLIC  ?V5
	PUBLIC  ?V6
	PUBLIC  ?V7
	PUBLIC  ?V8
	PUBLIC  ?V9
	PUBLIC  ?V10
	PUBLIC  ?V11
	PUBLIC  ?V12
	PUBLIC  ?V13
	PUBLIC  ?V14
	PUBLIC  ?V15
	PUBLIC  ?V16
	PUBLIC  ?V17
	PUBLIC  ?V18
	PUBLIC  ?V19
	PUBLIC  ?V20
	PUBLIC  ?V21
	PUBLIC  ?V22
	PUBLIC  ?V23
	PUBLIC  ?V24
	PUBLIC  ?V25
	PUBLIC  ?V26
	PUBLIC  ?V27
	PUBLIC  ?V28
	PUBLIC  ?V29
	PUBLIC  ?V30
	PUBLIC  ?V31
	PUBLIC  ?PSP
	PUBLIC  ?XSP
	RSEG    BREG:BIT:NOROOT
?B0:
	DS      8

  	RSEG    VREG:DATA:NOROOT
?V0:
	DS      1
?V1:
	DS      1
?V2:
	DS      1
?V3:
	DS      1
?V4:
	DS      1
?V5:
	DS      1
?V6:
	DS      1
?V7:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V7
?V8:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V8
?V9:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V9
?V10:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V10
?V11:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V11
?V12:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V12
?V13:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V13
?V14:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V14
?V15:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V15
?V16:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V16
?V17:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V17
?V18:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V18
?V19:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V19
?V20:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V20
?V21:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V21
?V22:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V22
?V23:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V23
?V24:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V24
?V25:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V25
?V26:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V26
?V27:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V27
?V28:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V28
?V29:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V29
?V30:
	DS      1

  	RSEG    VREG:DATA:NOROOT
  	REQUIRE ?V30
?V31:
	DS      1

	RSEG    PSP:DATA:NOROOT
	EXTERN  ?RESET_PSP
	REQUIRE	?RESET_PSP
?PSP:
	DS      1

	RSEG    XSP:DATA:NOROOT
	EXTERN  ?RESET_XSP
	REQUIRE	?RESET_XSP
?XSP:
	DS      2

	ENDMOD ; VIRTUAL_REGISTERS

	END

参考:https://www.iar.com/support/tech-notes/linker/8051-v8.30-linker-errore46-undefined-external-v1-referred-in-abcd/

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐