• slider image 442
  • slider image 477
  • slider image 479
  • slider image 480
  • slider image 481
  • slider image 482
:::


Browsing this Thread:   1 Anonymous Users




(1) 2 »


ATSAME54P20A--定址
#1
新會員
新會員


查看用戶資訊
想請問為何使用絕對定址但出現錯誤?
#include <stddef.h>      // Defines NULL
#include <stdbool.h>     // Defines true
#include <stdlib.h>      // Defines EXIT_FAILURE
#include "definitions.h" // SYS function prototypes
//=========================================================================================================================================================
uint8_t Can0MessageRAM[CAN0_MESSAGE_RAM_CONFIG_SIZE__attribute__((aligned(32), address(0x20000000)));                                
uint8_t Can1MessageRAM[CAN1_MESSAGE_RAM_CONFIG_SIZE__attribute__((aligned(32), address(0x20000000 CAN0_MESSAGE_RAM_CONFIG_SIZE))); 
 
int main(void)
{
    
/* Initialize all modules */
    
SYS_Initialize(NULL);
    
SYSTICK_TimerStart();
    
LED0_Set();
    
SYSTICK_DelayMs(100);

    
/* Set Message RAM Configuration */
    
CAN0_MessageRAMConfigSet(Can0MessageRAM);
    
CAN1_MessageRAMConfigSet(Can1MessageRAM);
    
CAN1_RxCallbackRegister(APP_CAN_Callback, (uintptr_t)APP_STATE_CAN_RECEIVECAN_MSG_ATTR_RX_FIFO0);
    
CAN1_TxCallbackRegister(APP_CAN_Callback, (uintptr_t)APP_STATE_CAN_TRANSMIT);
    
display_menu();
    while (
true)
    {
     }
}

//不知為何0x20000000及 CAN0_MESSAGE_RAM_CONFIG_SIZE中間的加號無法顯示


以下為compiler的錯誤訊息
Link ErrorCould not allocate section '_0c4b18f05ec644c4' at 0x20000000  
Link Error
Could not allocate data memory 
collect2
.exeerrorld returned 255 exit status 
make
[2]: *** [nbproject/Makefile-sam_e54_xpro.mk:336dist/sam_e54_xpro/production/sam_e54_xpro.X.production.hexError 255 
make
[1]: *** [nbproject/Makefile-sam_e54_xpro.mk:94: .build-confError 2 
make
: *** [nbproject/Makefile-impl.mk:39: .build-implError 2  
BUILD FAILED 
(exit value 2total time3s)


有無方法可以排除,感謝。

發表於: 2020/5/21 17:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ATSAME54P20A--定址
#2
新會員
新會員


查看用戶資訊
假如我將定址改到其他位址。
uint8_t Can0MessageRAM[CAN0_MESSAGE_RAM_CONFIG_SIZE__attribute__((aligned(32), address(0x20010000)));                                 

uint8_t Can1MessageRAM[CAN1_MESSAGE_RAM_CONFIG_SIZE__attribute__((aligned(32), address(0x20010000 CAN0_MESSAGE_RAM_CONFIG_SIZE)));

確認map檔內容無誤。
_0c5519485ec73812%1                 
0x20010060       0x60  
_0c5519485ec73812                
 0x20010060       0x60 build
/sam_e54_xpro/production/_ext/1360937237/main_e54.o  
               
0x20010060                Can1MessageRAM  
_0c5518f05ec73812
%2                 
0x20010000       0x60 
 _0c5518f05ec73812 

0x20010000       0x60 build
/sam_e54_xpro/production/_ext/1360937237/main_e54.o                 
0x20010000                Can0MessageRAM


RAM Data
-Memory Usage
section                    address  length 
[bytes]      (dec)  Description
-------                 ----------  -------------------------  -----------
.
bss                    0x20000000           0x10          16  Uninitialized data 
.data.impure_data       0x20000010          0x418        1048   
.data.__malloc_av_      0x20000428          0x408        1032   
.data.__global_locale   0x20000830          0x16c         364   
.bss.message            0x2000099c           0x40          64   
.bss.rx_message         0x200009dc           0x40          64   
.bss.can1RxMsg          0x20000a1c           0x30          48   
.bss.can0RxMsg          0x20000a4c           0x30          48   
.bss.can1Obj            0x20000a7c           0x28          40   
.bss.can0Obj            0x20000aa4           0x28          40   
.bss.__malloc_current_m 0x20000acc           0x28          40   
.bss.can1CallbackObj    0x20000af4           0x20          32   
.bss.can0CallbackObj    0x20000b14           0x20          32   
.bss                    0x20000b34           0x1c          28  Uninitialized data 
.bss.messageID          0x20000b50            0x4           4   
.bss.rx_messageID       0x20000b54            0x4           4   
.bss.xferContext        0x20000b58            0x4           4   
.data._impure_ptr       0x20000b5c            0x4           4   
.bss.__malloc_max_sbrke 0x20000b60            0x4           4   
.bss.__malloc_max_total 0x20000b64            0x4           4   
.bss.__malloc_top_pad   0x20000b68            0x4           4   
.data.__malloc_sbrk_bas 0x20000b6c            0x4           4   
.data.__malloc_trim_thr 0x20000b70            0x4           4   
.bss                    0x20000b74            0x4           4  Uninitialized data 
.bss.timestamp          0x20000b78            0x2           2   
.bss.messageMarker.8529 0x20000b7a            0x1           1   
.bss.loop_count         0x20000b7b            0x1           1   
.bss.messageLength      0x20000b7c            0x1           1   
.bss.rx_messageLength   0x20000b7d            0x1           1   
.data.state             0x20000b7e            0x1           1   
_0c63b8f05ec7381b       0x20010000           0x60          96   
_0c63b9485ec7381b       0x20010060           0x60          96   
         Total RAM used  
:       0xc3f        3135  1.2of 0x40000
        
--------------------------------------------------------------------------
            
Total Data Memory used  :       0xc3f        3135  1.2of 0x40000
        
--------------------------------------------------------------------------

但是通訊會有問題,data傳送內容為0x00,ID也是為0x00,
當然不定址就不會有這樣的狀況。
因為有特殊規劃,所以需要定址。
有無方式可以排除此狀況。

發表於: 2020/5/22 10:51
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ATSAME54P20A--定址
#3
管理員
管理員


查看用戶資訊
你好, 這個部分有兩個問題
1. 原先的寫法
uint8_t Can0MessageRAM[CAN0_MESSAGE_RAM_CONFIG_SIZE] __attribute__((aligned(32), address(0x20000000)));
uint8_t Can1MessageRAM[CAN1_MESSAGE_RAM_CONFIG_SIZE] __attribute__((aligned(32), address(0x20000000 + CAN0_MESSAGE_RAM_CONFIG_SIZE)));

CAN0_MESSAGE_RAM_CONFIG_SIZE = 56
Can1MessageRAM 的 address 因為aligned(32)的關係, 會等於address(0x20000000 + 32), 導致 Can1MessageRAM 記憶體位址去疊到Can0MessageRAM
Can0MessageRAM @ 0x20000000, size 56 (0x20000000 ~ 0x20000038)
Can1MessageRAM @ 0x20000020, size 56
所以請拿掉aligned(32)或是將Can1MessageRAM的定址取為32的倍數
最後
uint8_t Can0MessageRAM[CAN0_MESSAGE_RAM_CONFIG_SIZE] __attribute__((aligned(32), address(0x20000020)));
uint8_t Can1MessageRAM[CAN1_MESSAGE_RAM_CONFIG_SIZE] __attribute__((aligned(32), address(0x20000020 + ((CAN0_MESSAGE_RAM_CONFIG_SIZE%32)+1)*32)));

2. 另外一個問題是上面你看到, 起始位置不是在0x20000000而是自0x20000020開始, 你看MAP file時會發現前面0x20000000開始有保留一小塊區塊, 這部分需要避開
.bss 0x20000000 0x10 16 Uninitialized data
這部分會因為你用到的Harmony Module而不同, 看起來是因為SYS_Tick Module拿去用了, 我建的專案佔了0x0C, 你的佔了0x10, 因為aligned(32)所以我將起始位置移到0x20000020

發表於: 2020/5/22 11:46
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ATSAME54P20A--定址
#4
管理員
管理員


查看用戶資訊
看起來是Compiler強佔民房了, 目前不知道實際的用途,
但確實是拿了0x20000000的位置, 放了一些東西....
0x20000000的位置, 看起來使用無望..

makefile
.bss (NOLOAD) :
    {
        . = 
ALIGN(4);
        
__bss_start__ = .;
        
_sbss = . ;
        
_szero = .;
        *(
COMMON)
        . = 
ALIGN(4);
        
__bss_end__ = .;
        
_ebss = . ;
        
_ezero = .;
    } > 
DATA_REGION


.map
.bss            0x20000000        0x0
                0x20000000                
. = ALIGN (0x4)
                
0x20000000                __bss_start__ = .
                
0x20000000                _sbss = .
                
0x20000000                _szero = .
 *(
COMMON)
                
0x20000000                . = ALIGN (0x4)
                
0x20000000                __bss_end__ = .
                
0x20000000                _ebss = .
                
0x20000000                _ezero = .
                
0x20000000                . = ALIGN (0x4)
                
0x20000000                _end = .
                
0x2003ffff                _ram_end_ = ((ORIGIN (ram) + LENGTH (ram)) - 0x1)

發表於: 2020/5/22 12:02
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ATSAME54P20A--定址
#5
新會員
新會員


查看用戶資訊
感謝 Libra及Adam 。
我另外多加的了一些Module,確實可以用的位址確實往後移了。
1.    RAM Data-Memory Usage
2.    section                    address  length 
[bytes]      (dec)  Description
3.    
-------                 ----------  -------------------------  -----------
4.    .bss                    0x20000000         0x5460       21600  Uninitialized data
5.    
.data.impure_data       0x20005460          0x418        1048
6.    
.data.__malloc_av_      0x20005878          0x408        1032
7.    
.data.InitBMSInParamSet 0x20005c80          0x170         368
8.    
.data.__global_locale   0x20005df0          0x16c         364
9.    
.bss.can1Obj            0x20005f5c           0x28          40
10.    
.bss.sercom7I2CObj      0x20005f84           0x28          40
11.    
.bss.can0Obj            0x20005fac           0x28          40
12.    
.bss.sercom4I2CObj      0x20005fd4           0x28          40
13.    
.bss.__malloc_current_m 0x20005ffc           0x28          40
14.    
.data.messageError      0x20006024           0x21          33
15.    
.bss.writeStatus        0x20006045            0x1           1
16.    
.bss.readStatus         0x20006046            0x1           1
17.    
.bss.writeStatus5       0x20006047            0x1           1
18.    
.bss.can1RxMsg          0x20006048           0x20          32
19.    
.bss.can1CallbackObj    0x20006068           0x20          32
20.    
.bss.can0RxMsg          0x20006088           0x20          32
21.    
.bss.can0CallbackObj    0x200060a8           0x20          32
22.    
.bss                    0x200060c8           0x1c          28  Uninitialized data
23.    
.bss.receiveBuffer      0x200060e4            0xa          10
24.    
.bss.messageMarker.8529 0x200060ee            0x1           1
25.    
.bss.errorStatus        0x200060ef            0x1           1
26.    
.bss.message1ID         0x200060f0            0x4           4
27.    
.bss.status0            0x200060f4            0x4           4
28.    
.bss.status1            0x200060f8            0x4           4
29.    
.bss.messageID          0x200060fc            0x4           4
30.    
.bss.rx_message0ID      0x20006100            0x4           4
31.    
.bss.rx_message1ID      0x20006104            0x4           4
32.    
.bss.xfer0Context       0x20006108            0x4           4
33.    
.bss.xfer1Context       0x2000610c            0x4           4
34.    
.data._impure_ptr       0x20006110            0x4           4
35.    
.bss.__malloc_max_sbrke 0x20006114            0x4           4
36.    
.bss.__malloc_max_total 0x20006118            0x4           4
37.    
.bss.__malloc_top_pad   0x2000611c            0x4           4
38.    
.data.__malloc_sbrk_bas 0x20006120            0x4           4
39.    
.data.__malloc_trim_thr 0x20006124            0x4           4
40.    
.bss                    0x20006128            0x4           4  Uninitialized data
41.    
.bss.retStatus          0x2000612c            0x1           1
42.    
.bss.message0Length     0x2000612d            0x1           1
43.    
.bss.message1Length     0x2000612e            0x1           1
44.    
.bss.rx_message0Length  0x2000612f            0x1           1
45.    
.bss.rx_message1Length  0x20006130            0x1           1
46.    
.data.state0            0x20006131            0x1           1
47.    
.data.state1            0x20006132            0x1           1
48.    
.bss.messageMarker.8529 0x20006133            0x1           1
49.    _0cfed8405ec77515       0x20010000           0x44          68
50.    
.data.messageStart      0x20010044           0x48          72
51.    
.bss.echoBuffer         0x2001008c            0xe          14
52.    
.bss.timestamp          0x2001009a            0x2           2
53.    
.bss.message0ID         0x2001009c            0x4           4
54.    _0cfed8985ec77515       0x200100a0           0x44          68
55.    Total RAM used  
:      0x6218       25112  9.6of 0x40000
56.    
--------------------------------------------------------------------------
57.    Total Data Memory used  :      0x6218       25112  9.6of 0x40000
58.    
--------------------------------------------------------------------------

_0cfed8405ec77515 Can0MessageRAM
_0cfed8985ec77515 Can1MessageRAM
也將定址位址往後移,但是通訊還是有問題,data傳送內容一樣為0x00,ID也是為0x00。

假如,修改linker script是否可以將.bss的位址調整,
空出SRAM一部分專用。
要如何修改linker script(我知道這很麻煩,拜託幫幫忙!)
修改後的linker檔案(*.ld)要如何加入編輯,
我按照文件的方式後,看起來還是使用原本的script。

發表於: 2020/5/22 15:01
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ATSAME54P20A--定址
#6
管理員
管理員


查看用戶資訊
所以如果使用自動變數就會正常?
uint8_t Can0MessageRAM[CAN0_MESSAGE_RAM_CONFIG_SIZE];
uint8_t Can1MessageRAM[CAN1_MESSAGE_RAM_CONFIG_SIZE];

.bss是在linker file中去指定的
SAME54的Global Linker file在(XC32 v2.40之後只有64bit)
C:\Program Files\Microchip\xc32\v2.40\pic32c\lib\proc\ATSAME54P20A\ATSAME54P20A.ld

這裡不可以改它, 如果你要修改時, 要把它Copy到你的專案下, 然後在你的專案下的\Linker Files中加進來
縮圖

ATSAME54P20A.ld中
RAM_ORIGIN 0x20000000
RAM_LENGTH 0x40000
決定了Compiler可以管理的SRAM起始位置及大小
當然也可以去改變它後, 得到這樣的結果
RAM Data-Memory Usage
section                    address  length 
[bytes]      (dec)  Description
-------                 ----------  -------------------------  -----------
.
bss                    0x20010000            0xc          12  Uninitialized data 
.bss.can1Obj            0x2001000c           0x28          40   
.bss.can0Obj            0x20010034           0x28          40


在程式中沒人管的區段, 就任憑自己去處置了
uint32_t *Can0MessageRAM = (uint32_t *)(0x20000000U);
uint32_t *Can1MessageRAM = (uint32_t *)(0x20000040U);
((uint8_t*)Can0MessageRAM)[0] = 0x12;
((uint8_t*)Can0MessageRAM)[1] = 0x34;
((uint8_t*)Can1MessageRAM)[0] = 0x56;
((uint8_t*)Can1MessageRAM)[1] = 0x78;

更動記憶體配置可能造成不可預期的結果, 請務必小心謹慎後果自負.

Attach file:



jpg  (0.00 KB)


發表於: 2020/5/22 15:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ATSAME54P20A--定址
#7
新會員
新會員


查看用戶資訊
參照:

Libra 寫道:
所以如果使用自動變數就會正常?
uint8_t Can0MessageRAM[CAN0_MESSAGE_RAM_CONFIG_SIZE];
uint8_t Can1MessageRAM[CAN1_MESSAGE_RAM_CONFIG_SIZE];


是的,CAN的傳送接收都正常。
但一定址就會出問題。


參照:

Libra 寫道:
.bss是在linker file中去指定的
SAME54的Global Linker file在(XC32 v2.40之後只有64bit)
C:\Program Files\Microchip\xc32\v2.40\pic32c\lib\proc\ATSAME54P20A\ATSAME54P20A.ld

這裡不可以改它, 如果你要修改時, 要把它Copy到你的專案下, 然後在你的專案下的\Linker Files中加進來


縮圖













以下為ld檔修改的內容:
#ifndef RAM_LENGTH
#  define RAM_LENGTH 0x40000
#elif (RAM_LENGTH > 0x40000)
#  error RAM_LENGTH is greater than the max size of 0x40000
#endif
//---------------------------------------
#ifndef RAM_LENGTH_01
#  define RAM_LENGTH_01 0x3FEC0
#elif (RAM_LENGTH_01 > 0x3FEC0)
#  error RAM_LENGTH_01 is greater than the max size of 0x3FEC0
#endif

MEMORY
{
  
rom (LRX) : ORIGIN ROM_ORIGINLENGTH ROM_LENGTH
  
//--------------------------------------------------------
  /*ram (WX!R) : ORIGIN = RAM_ORIGIN, LENGTH = RAM_LENGTH*/
  
ram (WX!R) : ORIGIN RAM_ORIGIN_01LENGTH RAM_LENGTH_01
  
//--------------------------------------------------------
  
tcm (WX) : ORIGIN TCM_ORIGINLENGTH __XC32_TCM_LENGTH
  config_00804000 
ORIGIN 0x00804000LENGTH 0x4
  config_00804004 
ORIGIN 0x00804004LENGTH 0x4
  config_00804008 
ORIGIN 0x00804008LENGTH 0x4

}


依照一樣的方式,並未造成任何變更。
1.    RAM Data-Memory Usage
2.    section                    address  length 
[bytes]      (dec)  Description
3.    
-------                 ----------  -------------------------  -----------
4.    .bss                    0x20000000          0x178         376  Uninitialized data
5.    
.data.impure_data       0x20000178          0x418        1048
6.    
.data.__malloc_av_      0x20000590          0x408        1032
7.    
.data.__global_locale   0x20000998          0x16c         364
8.    
.bss.message            0x20000b04           0x40          64
9.    
.bss.rx_message         0x20000b44           0x40          64
10.    
.bss.can1RxMsg          0x20000b84           0x30          48
11.    
.bss.can0RxMsg          0x20000bb4           0x30          48
12.    
.bss.can1Obj            0x20000be4           0x28          40
13.    
.bss.can0Obj            0x20000c0c           0x28          40
14.    
.bss.__malloc_current_m 0x20000c34           0x28          40
15.    
.bss.can1CallbackObj    0x20000c5c           0x20          32
16.    
.bss.can0CallbackObj    0x20000c7c           0x20          32
17.    
.bss                    0x20000c9c           0x1c          28  Uninitialized data
18.    
.bss.messageID          0x20000cb8            0x4           4
19.    
.bss.rx_messageID       0x20000cbc            0x4           4
20.    
.bss.xferContext        0x20000cc0            0x4           4
21.    
.data._impure_ptr       0x20000cc4            0x4           4
22.    
.bss.__malloc_max_sbrke 0x20000cc8            0x4           4
23.    
.bss.__malloc_max_total 0x20000ccc            0x4           4
24.    
.bss.__malloc_top_pad   0x20000cd0            0x4           4
25.    
.data.__malloc_sbrk_bas 0x20000cd4            0x4           4
26.    
.data.__malloc_trim_thr 0x20000cd8            0x4           4
27.    
.bss                    0x20000cdc            0x4           4  Uninitialized data
28.    
.bss.timestamp          0x20000ce0            0x2           2
29.    
.bss.messageMarker.8529 0x20000ce2            0x1           1
30.    
.bss.loop_count         0x20000ce3            0x1           1
31.    
.bss.messageLength      0x20000ce4            0x1           1
32.    
.bss.rx_messageLength   0x20000ce5            0x1           1
33.    
.data.state             0x20000ce6            0x1           1
34.    _0c5728f05ec78eed       0x20010000           0x60          96
35.    _0c5729485ec78eed       0x20010060           0x60          96
1.    Total RAM used  
:       0xda7        3495  1.3of 0x40000
ii
.    --------------------------------------------------------------------------
1.    Total Data Memory used  :       0xda7        3495  1.3of 0x40000
iii
.    --------------------------------------------------------------------------


這是使用定址的異常狀況:
縮圖


















這是不使用定址的傳送與接收:
ID=0x469

縮圖














ID=0x111

縮圖

Attach file:



jpg  (0.00 KB)


jpg  (0.00 KB)


jpg  (0.00 KB)


jpg  (0.00 KB)


發表於: 2020/5/22 16:52

Edited by Gordon0010 on 2020年05月22日 17:12:31
Edited by Gordon0010 on 2020年05月22日 17:17:34
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ATSAME54P20A--定址
#8
管理員
管理員


查看用戶資訊
你改過的.ld要在X IDE的專案中, 加到Linker File底下, Compiler才會引用到, 不是Copy過來而已
Linker Files\ 按右鍵 -> Add Existing Item

發表於: 2020/5/25 8:26
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ATSAME54P20A--定址
#9
新會員
新會員


查看用戶資訊
參照:

Libra 寫道:
你改過的.ld要在X IDE的專案中, 加到Linker File底下, Compiler才會引用到, 不是Copy過來而已
Linker Files\ 按右鍵 -> Add Existing Item


感謝!Libra.
這部分有我有做,就是因為這樣,但還是無法變更所以才很納悶!
如圖:

Attach file:



jpg  (0.00 KB)


發表於: 2020/5/25 10:12
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ATSAME54P20A--定址
#10
管理員
管理員


查看用戶資訊
真奇怪, 我的就可以, 把我的.ld 跟 .map寄給你看一下
這檔案用7z壓縮的, 要用7z解壓縮, 不能在Windows直接點用winzip解壓縮

Attach file:


Link only for registered users

發表於: 2020/5/25 11:07
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------