Commit 543e61c651c91e2fc32ddcb78dc64fd889358bd3
1 parent
213c241355
Exists in
master
and in
2 other branches
= JIG Test 관련 스크립트 추가 =
Showing
7 changed files
with
679 additions
and
1 deletions
Show diff stats
buildroot/buildroot-2016.08.1/board/falinux/prime_oven/rootfs_overlay/etc/init.d/S83fusing
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | |
3 | 3 | CMDLINE=$(cat /proc/cmdline) |
4 | 4 | TOOL_PATH="/root/.falinux" |
5 | +JIG_PATH="/root/.falinux/prime_jig/prime_jig.sh" | |
5 | 6 | |
6 | 7 | start() { |
7 | 8 | echo "## Start Boot Img eMMC Fusing ##" |
... | ... | @@ -15,7 +16,9 @@ start() { |
15 | 16 | # Check First Boot |
16 | 17 | if [ ! -f "${TOOL_PATH}/.complete" ]; then |
17 | 18 | echo "Run JIG Script" |
18 | - | |
19 | + ${JIG_PATH} | |
20 | + touch ${TOOL_PATH}/.complete | |
21 | + sync | |
19 | 22 | fi |
20 | 23 | fi |
21 | 24 | } | ... | ... |
buildroot/buildroot-2016.08.1/board/falinux/prime_oven/rootfs_overlay/root/.falinux/prime_jig/fram_test
No preview for this file type
buildroot/buildroot-2016.08.1/board/falinux/prime_oven/rootfs_overlay/root/.falinux/prime_jig/opening.wav
No preview for this file type
buildroot/buildroot-2016.08.1/board/falinux/prime_oven/rootfs_overlay/root/.falinux/prime_jig/prime_jig.sh
... | ... | @@ -0,0 +1,466 @@ |
1 | +#!/bin/bash | |
2 | + | |
3 | +C_LRED='\033[1;31m' | |
4 | +C_LGREEN='\033[1;32m' | |
5 | +C_LCYAN='\033[1;36m' | |
6 | +C_NC='\033[0m' | |
7 | +C_BLINK='\033[5m' | |
8 | +C_BOLD='\033[1m' | |
9 | + | |
10 | + | |
11 | +PING_ADDR="192.168.10.1" | |
12 | +MAC_ADDR="" | |
13 | +ETH_NAME="eth0" | |
14 | +SUMMARY_PATH="/tmp/list" | |
15 | +JIG_PATH="/root/.falinux/prime_jig/" | |
16 | +RESULT_LOG="${JIG_PATH}result_log" | |
17 | +THREAD_FUNC_SCRIPT="${JIG_PATH}thread_func.sh" | |
18 | +FRAM_TEST_APP="${JIG_PATH}fram_test" | |
19 | +COMPLETE_TEST_NAME="" | |
20 | + | |
21 | +function Init() | |
22 | +{ | |
23 | + | |
24 | + if [ -f "${SUMMARY_PATH}" ]; then | |
25 | + rm -rf ${SUMMARY_PATH} | |
26 | + fi | |
27 | +} | |
28 | + | |
29 | +function summary() | |
30 | +{ | |
31 | + clear | |
32 | + echo -e "" | |
33 | + echo -e "============================" | |
34 | + echo -e " Test Summary " | |
35 | + echo -e "============================" | |
36 | + cat $SUMMARY_PATH | |
37 | + echo -e "============================" | |
38 | + echo -e " MAC: ${MAC_ADDR}" | |
39 | + echo -e "============================" | |
40 | + echo -e "" | |
41 | + echo -e "" | |
42 | +} | |
43 | + | |
44 | +function save_result() | |
45 | +{ | |
46 | + echo -e "" >> ${RESULT_LOG} | |
47 | + echo -e "============================" >> ${RESULT_LOG} | |
48 | + echo -e " Test Summary " >> ${RESULT_LOG} | |
49 | + echo -e "============================" >> ${RESULT_LOG} | |
50 | + cat $SUMMARY_PATH >> ${RESULT_LOG} | |
51 | + echo -e "============================" >> ${RESULT_LOG} | |
52 | + echo -e " MAC: ${MAC_ADDR}" >> ${RESULT_LOG} | |
53 | + echo -e "============================" >> ${RESULT_LOG} | |
54 | + echo -e "" >> ${RESULT_LOG} | |
55 | + echo -e "" >> ${RESULT_LOG} | |
56 | + sync | |
57 | +} | |
58 | + | |
59 | +function error_check() | |
60 | +{ | |
61 | + if [ "$1" != "0" ]; then | |
62 | + echo -e "[${C_LRED}ERR${C_NC}]: $2" >> $SUMMARY_PATH | |
63 | + else | |
64 | + echo -e "[${C_LGREEN} OK${C_NC}]: $2" >> $SUMMARY_PATH | |
65 | + fi | |
66 | +} | |
67 | + | |
68 | + | |
69 | +function test_mac() | |
70 | +{ | |
71 | + echo "" | |
72 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
73 | + echo "" | |
74 | + | |
75 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
76 | + | |
77 | + | |
78 | + for i in 0xfa 0xfb 0xfc 0xfd 0xfe 0xff | |
79 | + do | |
80 | + if [ "$i" == "0xfa" ]; then | |
81 | + EEPROM_MAC=$(i2cget -f -y 1 0x50 $i b | sed 's/0x//') | |
82 | + else | |
83 | + EEPROM_MAC+=$(i2cget -f -y 1 0x50 $i b | sed 's/0x/:/') | |
84 | + fi | |
85 | + done | |
86 | + | |
87 | + MAC_ADDR="${EEPROM_MAC^^}" | |
88 | + | |
89 | + ETH_MAC=$(ifconfig | grep eth0 | awk {'print $5'}) | |
90 | + | |
91 | + if [ "${EEPROM_MAC^^}" = "${ETH_MAC^^}" ]; then | |
92 | + return $? | |
93 | + else | |
94 | + return -1 | |
95 | + fi | |
96 | +} | |
97 | + | |
98 | +function check_ping() | |
99 | +{ | |
100 | + for i in 1 2 3 4 | |
101 | + do | |
102 | + sleep 1 | |
103 | + ping -c 1 -w 1 $PING_ADDR > /dev/null | |
104 | + if [ "$?" = "0" ]; then | |
105 | + return $? | |
106 | + fi | |
107 | + done | |
108 | + | |
109 | + return -1 | |
110 | +} | |
111 | + | |
112 | +function check_ethernet() | |
113 | +{ | |
114 | + echo "Check Ethernet Link Up/Down" | |
115 | + if [ $(cat /sys/class/net/$1/operstate) = "up" ]; then | |
116 | + return 0 | |
117 | + else | |
118 | + ifconfig eth0 up | |
119 | + return -1 | |
120 | + fi | |
121 | +} | |
122 | + | |
123 | +function test_ethernet() | |
124 | +{ | |
125 | + echo "" | |
126 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
127 | + echo "" | |
128 | + | |
129 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
130 | + | |
131 | + # TODO Test | |
132 | + | |
133 | + IFACE="$1" | |
134 | + | |
135 | + for i in {1..10} | |
136 | + do | |
137 | + check_ethernet $IFACE | |
138 | + if [ "$?" = "0" ]; then | |
139 | + break | |
140 | + else | |
141 | + echo "$IFACE Link is down" | |
142 | + fi | |
143 | + sleep 1 | |
144 | + done | |
145 | + | |
146 | + udhcpc -i eth0 -n -q | |
147 | + if [ "$?" != 0 ]; then | |
148 | + return -1 | |
149 | + fi | |
150 | + | |
151 | + check_ping | |
152 | + if [ "$?" != 0 ]; then | |
153 | + return -1 | |
154 | + fi | |
155 | + | |
156 | + return $? | |
157 | +} | |
158 | + | |
159 | +function test_rtc() | |
160 | +{ | |
161 | + echo "" | |
162 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
163 | + echo "" | |
164 | + | |
165 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
166 | + | |
167 | + # TODO Test | |
168 | + | |
169 | + ls /dev/rtc0 | |
170 | + if [ "$?" != 0 ]; then | |
171 | + return -1 | |
172 | + fi | |
173 | + | |
174 | + return $? | |
175 | +} | |
176 | + | |
177 | +TOUCH_IC_NAME="TSC2007" | |
178 | +function test_touch() | |
179 | +{ | |
180 | + echo "" | |
181 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
182 | + echo "" | |
183 | + | |
184 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
185 | + | |
186 | + # TODO Test | |
187 | + | |
188 | + cat /proc/bus/input/devices | grep $TOUCH_IC_NAME | |
189 | + if [ "$?" != "0" ]; then | |
190 | + return -1 | |
191 | + fi | |
192 | + | |
193 | + hexdump /dev/input/event0 & | |
194 | + if [ "$?" != "0" ]; then | |
195 | + return -1 | |
196 | + fi | |
197 | + | |
198 | + echo -e "" | |
199 | + echo -e "${C_BLINK}${C_BOLD}Press any key to ${FUNCNAME} exit...${C_NC}" | |
200 | + echo -e "" | |
201 | + read -rs | |
202 | + | |
203 | + killall hexdump | |
204 | + | |
205 | + return 0 | |
206 | +} | |
207 | + | |
208 | +BACK_LIGHT="/sys/class/backlight/backlight_lvds.19/brightness" | |
209 | +function test_lcd() | |
210 | +{ | |
211 | + echo "" | |
212 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
213 | + echo "" | |
214 | + | |
215 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
216 | + | |
217 | + # TODO Test | |
218 | + | |
219 | + fb-test | |
220 | + if [ "$?" != 0 ]; then | |
221 | + return -1 | |
222 | + fi | |
223 | + | |
224 | + sleep 1 | |
225 | + echo 0 > $BACK_LIGHT | |
226 | + | |
227 | + sleep 1 | |
228 | + echo 10 > $BACK_LIGHT | |
229 | + | |
230 | + sleep 1 | |
231 | + echo 0 > $BACK_LIGHT | |
232 | + | |
233 | + sleep 1 | |
234 | + echo 10 > $BACK_LIGHT | |
235 | + | |
236 | + sleep 1 | |
237 | + echo 0 > $BACK_LIGHT | |
238 | + | |
239 | + sleep 1 | |
240 | + echo 5 > $BACK_LIGHT | |
241 | + | |
242 | + return $? | |
243 | +} | |
244 | + | |
245 | +function test_encoder() | |
246 | +{ | |
247 | + echo "" | |
248 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
249 | + echo "" | |
250 | + | |
251 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
252 | + | |
253 | + # TODO Test | |
254 | + | |
255 | + ${THREAD_FUNC_SCRIPT} evtest & | |
256 | + if [ "$?" != 0 ]; then | |
257 | + return -1 | |
258 | + fi | |
259 | + | |
260 | + echo -e "" | |
261 | + echo -e "${C_BLINK}${C_BOLD}Press any key to ${FUNCNAME} exit...${C_NC}" | |
262 | + echo -e "" | |
263 | + read -rs | |
264 | + | |
265 | + killall evtest | |
266 | + | |
267 | + return $? | |
268 | +} | |
269 | + | |
270 | +WAV_FILE="${JIG_PATH}opening.wav" | |
271 | +function test_audio() | |
272 | +{ | |
273 | + echo "" | |
274 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
275 | + echo "" | |
276 | + | |
277 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
278 | + | |
279 | + # TODO Test | |
280 | + | |
281 | + aplay $WAV_FILE | |
282 | + if [ "$?" != "0" ]; then | |
283 | + return -1 | |
284 | + fi | |
285 | + | |
286 | + return $? | |
287 | +} | |
288 | + | |
289 | +function test_usb_storage() | |
290 | +{ | |
291 | + echo "" | |
292 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
293 | + echo "" | |
294 | + | |
295 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
296 | + | |
297 | + # TODO Test | |
298 | + | |
299 | + ls /dev/sda | |
300 | + if [ "$?" != "0" ]; then | |
301 | + return -1 | |
302 | + fi | |
303 | + | |
304 | + ls /dev/sdb | |
305 | + return $? | |
306 | +} | |
307 | + | |
308 | +function test_fram() | |
309 | +{ | |
310 | + echo "" | |
311 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
312 | + echo "" | |
313 | + | |
314 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
315 | + | |
316 | + # TODO Test | |
317 | + | |
318 | + ${FRAM_TEST_APP} | |
319 | + if [ "$?" != "0" ]; then | |
320 | + return -1 | |
321 | + fi | |
322 | + | |
323 | + return $? | |
324 | +} | |
325 | + | |
326 | +function test_tty() | |
327 | +{ | |
328 | + echo "" | |
329 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
330 | + echo "" | |
331 | + | |
332 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
333 | + WRITE_MSG="FALINUX_TTY" | |
334 | + | |
335 | + # TODO Test | |
336 | + | |
337 | + DEV_TTY_PATH="/dev/ttymxc1" | |
338 | + | |
339 | + ${THREAD_FUNC_SCRIPT} tty ${DEV_TTY_PATH} ${WRITE_MSG} & | |
340 | + read -s -t 5 READ_MSG < ${DEV_TTY_PATH} | |
341 | + if [ "$?" != 0 ]; then | |
342 | + return -1 | |
343 | + fi | |
344 | + echo "Read: [${READ_MSG}]" | |
345 | + | |
346 | + if [ "${WRITE_MSG}" != "${READ_MSG}" ]; then | |
347 | + return -1 | |
348 | + fi | |
349 | + | |
350 | + return $? | |
351 | +} | |
352 | + | |
353 | +function test_rs485() | |
354 | +{ | |
355 | + echo "" | |
356 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
357 | + echo "" | |
358 | + | |
359 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
360 | + | |
361 | + # TODO Test | |
362 | + | |
363 | + DEV_RS485_PATH1="/dev/ttymxc2" | |
364 | + DEV_RS485_PATH2="/dev/ttymxc3" | |
365 | + | |
366 | + # Read : RS485_1, Write : RS485_2 | |
367 | + RS485_WRITE_MSG="FALINUX_TEST:"${DEV_RS485_PATH2} | |
368 | + ${THREAD_FUNC_SCRIPT} rs485 ${DEV_RS485_PATH2} ${RS485_WRITE_MSG} & | |
369 | + read -s -t 5 RS485_READ_MSG < ${DEV_RS485_PATH1} | |
370 | + if [ "$?" != 0 ]; then | |
371 | + return -1 | |
372 | + fi | |
373 | + echo "Read: [${RS485_READ_MSG}]" | |
374 | + | |
375 | + if [ "${RS485_WRITE_MSG}" != "${RS485_READ_MSG}" ]; then | |
376 | + return -1 | |
377 | + fi | |
378 | + | |
379 | + # Read : RS485_2, Write : RS485_1 | |
380 | + RS485_WRITE_MSG="FALINUX_TEST:"${DEV_RS485_PATH1} | |
381 | + ${THREAD_FUNC_SCRIPT} rs485 ${DEV_RS485_PATH1} ${RS485_WRITE_MSG} & | |
382 | + read -s -t 5 RS485_READ_MSG < ${DEV_RS485_PATH2} | |
383 | + if [ "$?" != 0 ]; then | |
384 | + return -1 | |
385 | + fi | |
386 | + echo "Read: [${RS485_READ_MSG}]" | |
387 | + | |
388 | + if [ "${RS485_WRITE_MSG}" != "${RS485_READ_MSG}" ]; then | |
389 | + return -1 | |
390 | + fi | |
391 | + | |
392 | + return $? | |
393 | +} | |
394 | + | |
395 | + | |
396 | +function test_default() | |
397 | +{ | |
398 | + echo "" | |
399 | + echo -e "${C_LCYAN}### [${FUNCNAME}] ###${C_NC}" | |
400 | + echo "" | |
401 | + | |
402 | + COMPLETE_TEST_NAME=${FUNCNAME} | |
403 | + | |
404 | + # TODO Test | |
405 | + | |
406 | + | |
407 | + return $? | |
408 | +} | |
409 | + | |
410 | +function main() | |
411 | +{ | |
412 | + echo "" | |
413 | + echo -e " ### Start DEV Test - [${FUNCNAME}] ###" | |
414 | + echo "" | |
415 | + | |
416 | + Init | |
417 | + | |
418 | + test_mac | |
419 | + error_check $? ${COMPLETE_TEST_NAME} | |
420 | + | |
421 | + test_ethernet ${ETH_NAME} | |
422 | + error_check $? ${COMPLETE_TEST_NAME} | |
423 | + | |
424 | + test_rtc | |
425 | + error_check $? ${COMPLETE_TEST_NAME} | |
426 | + | |
427 | + test_touch | |
428 | + error_check $? ${COMPLETE_TEST_NAME} | |
429 | + | |
430 | + test_lcd | |
431 | + error_check $? ${COMPLETE_TEST_NAME} | |
432 | + | |
433 | + test_encoder | |
434 | + error_check $? ${COMPLETE_TEST_NAME} | |
435 | + | |
436 | + test_audio | |
437 | + error_check $? ${COMPLETE_TEST_NAME} | |
438 | + | |
439 | + test_usb_storage | |
440 | + error_check $? ${COMPLETE_TEST_NAME} | |
441 | + | |
442 | + test_fram | |
443 | + error_check $? ${COMPLETE_TEST_NAME} | |
444 | + | |
445 | + test_tty | |
446 | + error_check $? ${COMPLETE_TEST_NAME} | |
447 | + | |
448 | + test_rs485 | |
449 | + error_check $? ${COMPLETE_TEST_NAME} | |
450 | + | |
451 | + summary | |
452 | + save_result | |
453 | +} | |
454 | + | |
455 | +function test_func() | |
456 | +{ | |
457 | + echo "" | |
458 | + echo -e " ### TEST Func - [${FUNCNAME}] ###" | |
459 | + echo "" | |
460 | + | |
461 | + test_encoder | |
462 | + error_check $? ${COMPLETE_TEST_NAME} | |
463 | +} | |
464 | + | |
465 | + | |
466 | +main | ... | ... |
buildroot/buildroot-2016.08.1/board/falinux/prime_oven/rootfs_overlay/root/.falinux/prime_jig/thread_func.sh
... | ... | @@ -0,0 +1,97 @@ |
1 | +#!/bin/bash | |
2 | + | |
3 | +C_LRED='\033[1;31m' | |
4 | +C_LGREEN='\033[1;32m' | |
5 | +C_LCYAN='\033[1;36m' | |
6 | +C_NC='\033[0m' | |
7 | +C_BLINK='\033[5m' | |
8 | +C_BOLD='\033[1m' | |
9 | + | |
10 | +SUMMARY_PATH="/tmp/list" | |
11 | +THREAD_FUNC_NAME="" | |
12 | + | |
13 | +function error_check() | |
14 | +{ | |
15 | + if [ "$1" != "0" ]; then | |
16 | + echo -e "[${C_LRED}ERR${C_NC}]: $2" >> $SUMMARY_PATH | |
17 | + fi | |
18 | +} | |
19 | + | |
20 | + | |
21 | +function thread_evtest() | |
22 | +{ | |
23 | + echo "" | |
24 | + echo " @@@ [${FUNCNAME}] @@@" | |
25 | + echo "" | |
26 | + | |
27 | + THREAD_FUNC_NAME=${FUNCNAME} | |
28 | + | |
29 | + evtest << EOF | |
30 | + 1 | |
31 | +EOF | |
32 | + | |
33 | + return $? | |
34 | +} | |
35 | + | |
36 | +function thread_tty() | |
37 | +{ | |
38 | + echo "" | |
39 | + echo " @@@ [${FUNCNAME}] @@@" | |
40 | + echo "" | |
41 | + | |
42 | + DEV_TTY_PATH="$2" | |
43 | + SEND_MESSAGE="$3" | |
44 | + | |
45 | + THREAD_FUNC_NAME=${FUNCNAME} | |
46 | + | |
47 | + sleep 1 | |
48 | + echo $2 $3 | |
49 | + echo "Send: [${SEND_MESSAGE}]" | |
50 | + echo "${SEND_MESSAGE}" > ${DEV_TTY_PATH} | |
51 | + | |
52 | + return $? | |
53 | +} | |
54 | + | |
55 | +function thread_rs485() | |
56 | +{ | |
57 | + echo "" | |
58 | + echo " @@@ [${FUNCNAME}] @@@" | |
59 | + echo "" | |
60 | + | |
61 | + DEV_RS485_PATH=$2 | |
62 | + SEND_MESSAGE=$3 | |
63 | + | |
64 | + THREAD_FUNC_NAME=${FUNCNAME} | |
65 | + | |
66 | + echo $SEND_MESSAGE $DEV_RS485_PATH | |
67 | + echo ${SEND_MESSAGE} ${DEV_RS485_PATH} | |
68 | + | |
69 | + sleep 1 | |
70 | + echo "Send: [${SEND_MESSAGE}]" | |
71 | + echo "${SEND_MESSAGE}" > ${DEV_RS485_PATH} | |
72 | + | |
73 | + return $? | |
74 | +} | |
75 | + | |
76 | + | |
77 | +function main() | |
78 | +{ | |
79 | + case $1 in | |
80 | + evtest) | |
81 | + thread_evtest | |
82 | + error_check $? ${COMPLETE_TEST_NAME} | |
83 | + ;; | |
84 | + tty) | |
85 | + echo $2 $3 | |
86 | + thread_tty $@ | |
87 | + error_check $? ${COMPLETE_TEST_NAME} | |
88 | + ;; | |
89 | + rs485) | |
90 | + thread_rs485 $@ | |
91 | + error_check $? ${COMPLETE_TEST_NAME} | |
92 | + ;; | |
93 | + esac | |
94 | +} | |
95 | + | |
96 | + | |
97 | +main $@ | ... | ... |
samplecode/fram/fram_test.c
... | ... | @@ -0,0 +1,110 @@ |
1 | +#include <stdio.h> | |
2 | +#include <stdlib.h> | |
3 | +#include <unistd.h> | |
4 | +#include <errno.h> | |
5 | +#include <signal.h> | |
6 | +#include <fcntl.h> | |
7 | +#include <ftw.h> | |
8 | +#include <string.h> | |
9 | + | |
10 | +#define RW_SIZE 32 | |
11 | + | |
12 | +#define DEV_NAME "/sys/bus/spi/devices/spi0.0/fram" | |
13 | + | |
14 | +unsigned char *cWriteBuffer = NULL; | |
15 | +unsigned char *cReadBuffer = NULL; | |
16 | + | |
17 | + | |
18 | +int RWDateCompare(void) | |
19 | +{ | |
20 | + int i; | |
21 | + | |
22 | + for(i=0; i<RW_SIZE; i++) | |
23 | + { | |
24 | + if( cWriteBuffer[i] != cReadBuffer[i] ) | |
25 | + return -1; | |
26 | + } | |
27 | + | |
28 | + return 0; | |
29 | +} | |
30 | + | |
31 | +int Fram_Write(int fd) | |
32 | +{ | |
33 | + int ret; | |
34 | + | |
35 | + lseek(fd, 0, SEEK_SET); | |
36 | + ret = write(fd, cWriteBuffer, RW_SIZE); | |
37 | + | |
38 | + if(ret != RW_SIZE) | |
39 | + { | |
40 | + fputs("Error Write()\n",stderr); | |
41 | + free(cWriteBuffer); | |
42 | + free(cReadBuffer); | |
43 | + exit(-EIO); | |
44 | + } | |
45 | + | |
46 | + return 0; | |
47 | +} | |
48 | + | |
49 | +int Fram_Read(int fd) | |
50 | +{ | |
51 | + int ret; | |
52 | + | |
53 | + lseek(fd, 0, SEEK_SET); | |
54 | + ret = read(fd, cReadBuffer, RW_SIZE); | |
55 | + | |
56 | + if(ret != RW_SIZE) | |
57 | + { | |
58 | + fputs("Error Read()\n",stderr); | |
59 | + free(cWriteBuffer); | |
60 | + free(cReadBuffer); | |
61 | + exit(-EIO); | |
62 | + } | |
63 | + | |
64 | + return 0; | |
65 | +} | |
66 | + | |
67 | + | |
68 | +int main(int argc, char **argv) | |
69 | +{ | |
70 | + | |
71 | + int ret, i; | |
72 | + unsigned int fd; | |
73 | + | |
74 | + printf("### Fram Read/Write Test App Start!! ###\n"); | |
75 | + cWriteBuffer = (unsigned char *)malloc( sizeof(unsigned char)*RW_SIZE); | |
76 | + if( cWriteBuffer == NULL) | |
77 | + return -ENOMEM; | |
78 | + | |
79 | + cReadBuffer = (unsigned char *)malloc( sizeof(unsigned char)*RW_SIZE); | |
80 | + if( cReadBuffer == NULL) | |
81 | + return -ENOMEM; | |
82 | + | |
83 | + memset(cWriteBuffer, 0, RW_SIZE); | |
84 | + memset(cReadBuffer, 0, RW_SIZE); | |
85 | + | |
86 | + fd = open (DEV_NAME, O_RDWR); | |
87 | + if(fd < 0) { | |
88 | + fputs("Error open()\n",stderr); | |
89 | + free(cWriteBuffer); | |
90 | + free(cReadBuffer); | |
91 | + return -ENODEV; | |
92 | + } | |
93 | + | |
94 | + // Init 0 (32Byte) | |
95 | + Fram_Write(fd); | |
96 | + | |
97 | + // Set Value | |
98 | + for(i=0; i<RW_SIZE; i++) | |
99 | + cWriteBuffer[i] = i; | |
100 | + | |
101 | + | |
102 | + Fram_Write(fd); | |
103 | + | |
104 | + Fram_Read(fd); | |
105 | + | |
106 | + ret = RWDateCompare(); | |
107 | + | |
108 | + printf("### Fram Read/Write Test App End!! ###\n"); | |
109 | + return ret; | |
110 | +} | ... | ... |
samplecode/fram/make.sh