# File: hello.s -- Say Hello to MIPS Assembly Language Programmer
# Author: falcon <wuzhangjin@gmail.com>, 2009/01/17
# Ref:
# [*] http://www.tldp.org/HOWTO/Assembly-HOWTO/mips.html
# [*] MIPS Assembly Language Programmer's Guide
# [*] See MIPS Run Linux(second version)
# Compile:
# $ gcc -o hello hello.s
# or
# $ as -o hello.o hello.s
# $ ld -e main -o hello hello.o
.text
.globl main
main:
.set noreorder
.cpload $gp # setup the pointer to global data
.set reorder
# print sth. via sys_write
li $a0, 1 # print to standard ouput
la $a1, stradr # set the string address
lw $a2, strlen # set the string length
li $v0, 4004 # index of sys_write:
# __NR_write in /usr/include/asm/unistd.h
syscall # causes a system call trap.
# exit via sys_exit
move $a0, $0 # exit status as 0
li $v0, 4001 # index of sys_exit
# __NR_exit in /usr/include/asm/unistd.h
syscall
.rdata
stradr: .asciiz "hello, world!\n"
strlen: .word . - stradr # current address - the string address
# end
opkg update
opkg install tar
wget http://pkgs.fedoraproject.org/repo/pkgs/sshpass/sshpass-1.05.tar.gz/c52d65fdee0712af6f77eb2b60974ac7/sshpass-1.05.tar.gz
tar -zxvf sshpass-1.05.tar.gz
cd sshpass-1.05
./configure
make
make install
The second type is C-API which is needed compile, gcc will help.
Sample Install crcmod:
Install python_devel
cd /usr/include/python2.7
wget -O python_devel.tar.gz https://www.dropbox.com/s/z49hrigv3umaaj8/python_devel.tar.gz?dl=0 --no-check-certificate
tar -zxvf python_devel.tar.gz
rm python_devel.tar.gz
Download crcmod
cd /mnt/sda1
wget https://pypi.python.org/packages/source/c/crcmod/crcmod-1.7.tar.gz --no-check-certificate
tar -zxvf crcmod-1.7.tar.gz
cd crcmod-1.7
python setup.py build
one thing to note - try avoiding doing stuff in the main file system on the Yun; remember it is flash memory and has a limit of how many writes it can handle before going kaput. best to use a mounted SD card (i formatted mine with ext3 file system) and/or the /tmp directory which is mapped to a RAM drive i believe. so many cool things you can do with the Linux side of the Yun
The utility "nm" lists symbol table of object files.
root@Arduino:/mnt/sda1# nm hello
00400180 r _DYNAMIC
00410ca0 A _GLOBAL_OFFSET_TABLE_
00400a70 t _GLOBAL__sub_D_main
00400a38 t _GLOBAL__sub_I_main
...
I don't recall what stopped me to compile grep by Native GCC for Yun, but the link of package is cross compile. I guess every one find it working then for general use.
These are great examples, thank you! Between these and noblepepper's blog on the subject, I had no problems getting things going (once I got over my hesitation and actually tried!)
What's missing from these examples is accessing the Yun's bridge from C or C++. Is it possible to get/put bridge values or access the bridge mailbox mechanism from C or C++? (lots of Python and PHP examples, but I can't find any in C.)
sonnyyu:
Since UART's speed is only 0.5Mb/s and will be bottleneck, compiled programming languages assembly/c/c++ has no advantage than script languages php/python/lua.
UART is interface between Yun and Arduino.
ab -n 20 -c 1 http://192.168.0.186/arduino/analog/2/123
Concurrency Level: 1
Time taken for tests: 3.425 seconds
Complete requests: 20
Failed requests: 0
Write errors: 0
Non-2xx responses: 20
Total transferred: 2100 bytes
HTML transferred: 0 bytes
Requests per second: 5.84 [#/sec] (mean)
Time per request: 171.275 [ms] (mean)
Time per request: 171.275 [ms] (mean, across all concurrent requests)
Transfer rate: 0.60 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 164 171 7.9 169 192
Waiting: 153 159 6.2 156 171
Total: 164 171 7.9 169 192
171.275 [ms] (0.17 s) is average speed of bridge speed, and **should meet average application's requirement**.
0.17 samples/s and 0.5Mb/s make compiled programming languages assembly/c/c++ is not good candidates.