分类 Code 下的文章

今天使用 iar-stm8 编译 atomthread 出错,出错提示为: Error[Lc036]: no block or place matches the pattern "ro code section .text in atomport-asm-iar.o"

经过一番搜索,发现,解决办法很简单。

把 atomthread-asm-iar.s 打开,修改如下。

  SECTION .text:code
  改成:      
  SECTION `.near_func.text`:CODE

今天在用codeblock打开几年前的avr工程,编译的时候,出错了,错误是 undefined reference to `eewr_byte_m169p。 经过1个小时的努力,终于找到问题所在了。 解释: As you see the EEPROM support has changed in recent years so that now the header files identify the AVR you are using (mega644) and then concatenate this onto the eewrbyte* style routine names and these are then provided in the link from the device specific .o file. When this works the map file shows something like: e:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr5\libc.a(eewr_byte_atmega644.o) test.o (__eewr_byte_m644) That's built on Windows with WinAVR but the point is that it's ../avr/lib/avr5/libc.a that is providing the function. If you get undefined ref then that suggests that you environment is not linking with the right libc.a Maybe show your complete build output? Is the -mmcu=atmega644 being passed to the link as well as the compiles?

解决办法很简单,libc.a需要选择../avr/lib/avr5/libc.a这个才行。

学习 《QT快速入门》命令行这一小节,发现有点问题。 编译的时候会提示没有 QApplication。 解决办法是在 *.pro 中添加

QT += widgets

在win7的命令行中要进行编译,首先环境变量当中要加入 \Tools\mingw482_32\bin 和 \5.3\mingw482_32\bin

  1. qmake -project
  2. qmake
  3. mingw32-make.exe

今天被枚举给坑了一下,枚举不能用于预编译中间,不能就肯定不是想要的逻辑。 例如 enum{Name_0, Name_1, Name_2};

define NAME Name_2

int main(void) {

if (NAME == Name_1)

 printf("111\n");

else

printf("222\n");

endif

} 结果输出的肯定是 111

找到的解释如下

The `#if' command in its simplest form consists of

if expression controlled text #endif / expression /

The comment following the #endif' is not required, but it is a good practice because it helps people match the#endif' to the corresponding #if'. Such comments should always be used, except in short conditionals that are not nested. In fact, you can put anything at all after the#endif' and it will be ignored by the GNU C preprocessor, but only comments are acceptable in ANSI Standard C.

expression is a C expression of integer type, subject to stringent restrictions. It may contain

Integer constants, which are all regarded as long or unsigned long.

Character constants, which are interpreted according to the character set and conventions of the machine and operating system on which the preprocessor is running. The GNU C preprocessor uses the C data type `char' for these character constants; therefore, whether some character codes are negative is determined by the C compiler used to compile the preprocessor. If it treats `char' as signed, then character codes large enough to set the sign bit will be considered negative; otherwise, no character code is considered negative.

Arithmetic operators for addition, subtraction, multiplication, division, bitwise operations, shifts, comparisons, and `&&' and `||'.

Identifiers that are not macros, which are all treated as zero(!).

Macro calls. All macro calls in the expression are expanded before actual computation of the expression's value begins.

Note that `sizeof' operators and enum-type values are not allowed. enum-type values, like all other identifiers that are not taken as macro calls and expanded, are treated as zero.

The controlled text inside of a conditional can include preprocessor commands. Then the commands inside the conditional are obeyed only if that branch of the conditional succeeds. The text can also contain other conditional groups. However, the #if' and#endif' commands must balance.

From:

今天使用GCC编译的时候发现了一个错误,invalid application of 'sizeof' to incomplete type 。 这个错误的原因是sizeof是在编译阶段进行计算的,而extern是在链接阶段工作的,所以在多文件的时候会出现这个错误。 解决办法也很简单,就是在头文件里面extern的地方显式的表现出数组的大小。

本次网卡移植参考国嵌实验

在include/configs/tq2440.h中

58行左右 / modified by ptz , for tq2440, dm9000 /

define CONFIG_DRIVER_CS8900 1 / we have a CS8900 on-board /

//#define NETWORK_DRIVER_CS8900 1

define NETWORK_DRIVER_DM9000 1

if defined (NETWORK_DRIVER_CS8900)

define CS8900_BASE 0x19000300

define CS8900_BUS16 1 / the Linux driver does accesses as shorts /

elif defined (NETWORK_DRIVER_DM9000)

define CONFIG_DRIVER_DM9000 1

define CONFIG_DM9000_USE_16BIT 1

define CONFIG_DM9000_BASE 0x20000300

define DM9000_IO 0x20000300

define DM9000_DATA 0x20000304

endif

112行左右 / add by ptz, for tq2440, PING CMD/

define CONFIG_CMD_PING

119行左右 / modified by ptz , for tq2440, dm9000 /

define CONFIG_IPADDR 192.168.1.105

define CONFIG_SERVERIP 192.168.1.103

define CONFIG_ETHADDR 00.01.02.03.04.05

在打开 driver/net/dm9000x.c 吧MII接口的注释掉 388行左右 / delete by ptz, for tq2440, for dm9000 /

if 0

i = 0; while (!(phy_read(1) & 0x20)) { / autonegation complete bit / udelay(1000); i++; if (i == 10000) { printf("could not establish link\n"); return 0; } } / see what we've got / lnk = phy_read(17) >> 12; printf("operating at "); switch (lnk) { case 1: printf("10M half duplex "); break; case 2: printf("10M full duplex "); break; case 4: printf("100M half duplex "); break; case 8: printf("100M full duplex "); break; default: printf("unknown: %d ", lnk); break; } printf("mode\n");

endif

这样就修改好了

打开 u-boot 主上目录下的 Makefile , 找到 smdk2410_config, 在其下 , 加入 smdk2410_config : unconfig @(MKCONFIG)(@:_config=) arm arm920t smdk2410 NULL s3c24x0 tq2440_config : unconfig @(MKCONFIG)(@:_config=) arm arm920t tq2440 ptz s3c24x0

根据需要配置CROSS_COMPILE

在 board 子目录下建立自己的开发板 ptz/tq2440 目录,然后,将 smdk2410 目录下的文件拷入此目录中,然后,将 tq2440 目录下的 smdk2410.c 改 为tq2440.c ,同时还得修改 board/ptz/tq2440/Makefile 文件。 COBJS :=tq2440.o flash.o

在 include/configs/ 下建立 tq2440.h 配置头文件,把smdk2410 的相应头文件复制一份在相同目录下,并改名为 tq2440.h

编译测试一下是否能够通过 [...]# make distclean [...]# make tq2440_config Configuring for tq2440 board... [...]# make CROSS_COMPILE=arm-linux-

如果没有错误出现,就可以进行下一步的修改了。

fork 作用是建立一个子进程,父子进程之间在fork()之后分道扬镳,子进程会获得一个父进程数据的副本。

在fork语句之前,printf有没有增加"\n"是非常重要的。如果没有"\n"那么printf的内容会写入显示缓冲,那么fork之后,子进程也会获得这个缓冲,所以如果在fork之前有printf,并且没有增加 "\n" 那么最后同样的内容,子进程和父进程会都打印一遍。

但是如果增加了 "\n" 就是立即显示了,那么子进程就不会有相应的显示缓冲,所以只会打印一遍.

最近做用430结果被BT定时器折腾了。BT定时器和以前接触过的AVR的普通定时器不太一样。以前的定时器都是计数到FF然后产生溢出中断。而BT定时器不一样。 MSP430 basic timer 基本定时器中断时间的计算 - ptz19861212 - ptz19861212的博客 BT定时器是在相应的选择位产生进位的情况下产生中断的。比如说,如果我们选中BTIPx为001的话,那么BTCNT2中的数据为 0x00,0x01,0x02,0x03然后在0X04的时候,也就是在Q1向Q2进位的时候产生中断。而且不管高位的数据,这个例子中Q3-Q7中的数据没有任何影响。