翻舊帳

2017年11月28日 星期二

µPD720201 init fail on Linux

開機過程中, 掛載driver時出現 stall on CPU 2 的訊息.
/proc/bus/pci/devices 裡面看得到µPD720201的編號, 卻沒有辦法正確init.

原因很簡單, µPD720201需要外部的ROM存放FW, 如果ROM沒有上或是裡面沒有燒FW, 就會出現這個狀況.

2017年11月24日 星期五

2017年10月13日 星期五

free(): invalid next size (fast)

我參考Linux man page的code:
#define _GNU_SOURCE
#include
#include

int
main(void)
{
FILE *fp;
char *line = NULL;
size_t len = 0;
ssize_t read;

fp = fopen("/etc/motd", "r");
if (fp == NULL)
exit(EXIT_FAILURE);

while ((read = getline(&line, &len, fp)) != -1) {
printf("Retrieved line of length %zu :\n", read);
printf("%s", line);
}

free(line);
exit(EXIT_SUCCESS);
}

針對getline()產生的line buffer, 在最後將它free, 卻得到free(): invalid next size (fast).

最後我改用另一種寫法, 先malloc一塊夠大的buffer給line pointer, 然後, 然後就沒有error了.
len = 512;
line = malloc(len);
while( (ret = getline(&line, (size_t *)&len, fp)) != -1 ) {
if(line[0] == '#') continue; //comment
}
if(line != NULL) free(line);

2017年9月1日 星期五

編譯 toolchain, 出現 texi 相關的文件 error

output/toolchain/gcc-4.3.5/gcc/doc/cppopts.texi:757: @itemx must follow @item
make[2]: *** [doc/cpp.info] Error 1

編譯 buildroot 時, 遇到的問題.
這個問題是因為 textinfo 版本太新所造成的.
解法在此: https://git.busybox.net/buildroot/commit/?id=62322acb2ce186d544ab21fe253ccc8561a68a48

2017年8月31日 星期四

編譯的時候, 出現 undefined reference 錯誤

1. 沒有指定 library (-l)
2. 沒有指向 library 的目錄 (-L)
3. 參考到的 library 版本有問題
4. 參考路徑的順序有錯

第四點比較玄奇, 沒想到的話會花一點時間.
有可能參考路徑中有不只一個同名的 library, 但是這幾個檔案也許不是同一個編譯器做出來的, 也許不是同一個版本產生出來的, 也許是make clean的時候忘記去清掉上一次編譯出來的檔案.
Related Posts Plugin for WordPress, Blogger...