http://embeddedcomputer.nl/lanotattachments/download/file/id/3/store/1/
Booting Ubuntu on BeagleBoard Black
http://circuitco.com/support/index.php?title=Booting_Ubuntu_on_BeagleBoard_Black
Linux on ARM / Home:
http://eewiki.net/display/linuxonarm/BeagleBone+Black
uEnv.txt based bootscript:
Beaglebone Black CircuitCo support page:
http://circuitco.com/support/index.php?title=BeagleBoneBlack
BeagleBone Boot Sequence.
http://elinux.org/EBC_Exercise_21a_Boot_Sequence#Booting_Up
Unbrick
http://hipstercircuits.com/unbrick-beaglebone-black-without-erasing-emmc/
Angstrom Cloud9 distribution download
http://downloads.angstrom-distribution.org/demo/beaglebone/
Burning an IMG File
http://doc.freenas.org/index.php/Burning_an_IMG_File
6+ hour:
Building Angstrom for Beaglebone from Source:
http://derekmolloy.ie/building-angstrom-for-beaglebone-from-source/
http://nomel.tumblr.com/post/30357133735/beaglebone-tutorial-how-to-compile-kernel-modules-and
Monday, September 30, 2013
Saturday, September 28, 2013
Create Partion and Filesystems
Divide and conquer your disk space
http://www.ibm.com/developerworks/library/l-lpic1-v3-104-1/
http://www.ibm.com/developerworks/library/l-lpic1-v3-104-1/
Friday, September 27, 2013
Beaglebone USB Ethernet Connection
http://robotic-controls.com/learn/beaglebone/beaglebone-internet-over-usb-only
http://shallowsky.com/blog/hardware/talking-to-beaglebone.html
On the beaglebone:
Once your network is running, you might want to run
Scripts for configuration after automatic connection
http://www.circuidipity.com/getting-started-with-beaglebone-black.html
http://shallowsky.com/blog/hardware/talking-to-beaglebone.html
On the beaglebone:
/sbin/route add default gw 192.168.7.1 echo "nameserver 8.8.8.8" >> /etc/resolv.confYou'll probably want to add these lines to the end of /usr/bin/g-ether-load.sh on the BBB, so they'll be run automatically every time you boot. Then, back on your Linux host, do this:
sudo iptables -A POSTROUTING -t nat -j MASQUERADE echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/nullNow you should be able to ping, ssh or otherwise use the BBB to get anywhere on the net.
Once your network is running, you might want to run
/usr/bin/ntpdate -b -s -u pool.ntp.org
to set the time, since the BBB doesn't have a real-time clock (RTC).Scripts for configuration after automatic connection
http://www.circuidipity.com/getting-started-with-beaglebone-black.html
Wednesday, September 25, 2013
RT-N16
http://www.dd-wrt.com/wiki/index.php/Asus_RT-N16
http://www.anandtech.com/show/6180/open-source-router-platforms
OpenWRT
http://wiki.openwrt.org/toh/asus/rt-n16#from.linux
http://www.anandtech.com/show/6180/open-source-router-platforms
OpenWRT
http://wiki.openwrt.org/toh/asus/rt-n16#from.linux
Tuesday, September 24, 2013
interrupt, Callback, Software Debounce, RPi
raspi.tv/2013/how-to-use-interrupts-with-python-on-the-raspberry-pi-and-rpi-gpio-part-2
Friday, September 20, 2013
Why should you use strncpy instead of strcpy?
www.blogger.com/blogger.g?blogID=3857439785589817539#editor/target=post;postID=1092521179290748231
Secondly, why you chose to only copy 5 characters on 7 character string is beyond me, but it's producing expected behavior. It's only copying over the first
The
strncpy
combats buffer overflow by requiring you to put a length in it. strcpy
depends on a trailing \0
, which may not always occur.Secondly, why you chose to only copy 5 characters on 7 character string is beyond me, but it's producing expected behavior. It's only copying over the first
n
characters, where n
is the third argument.The
n
functions are all used as defensive coding against buffer overflows. Please use them in lieu of older functions, such as strcpy
.
strncpy was initially introduced into the C library to deal with fixed-length name fields in structures such as directory entries
http://www.lysator.liu.se/c/rat/d11.html
memcpy
memmove
....
functions
chris & Sinan: It's getting upvotes
because the question was, "Why would you use strncpy instead of strcpy?"
Not, "What is strncpy for?" There's a distinct difference. This answer
addresses the former, not the latter.
http://stackoverflow.com/questions/2593814/why-do-i-get-a-segmentation-fault-when-using-strncpy
The problem is that tp->mnem is pointing to a string literal, which
is generally allocated in a read-only segment of memory. Therefore it's
illegal to overwrite it.
C dynamic memory allocation
statically, automatically dynamically
Static-duration variables are allocated in main memory, usually along with the executable code of the program, and persist for the lifetime of the program; automatic-duration variables are allocated on the stack and come and go as functions are called and return.
These limitations are avoided by using dynamic memory allocation in which memory is more explicitly (but more flexibly) managed. Typically, by allocating it from heap
Type safety:
Static-duration variables are allocated in main memory, usually along with the executable code of the program, and persist for the lifetime of the program; automatic-duration variables are allocated on the stack and come and go as functions are called and return.
These limitations are avoided by using dynamic memory allocation in which memory is more explicitly (but more flexibly) managed. Typically, by allocating it from heap
Type safety:
int *ptr; ptr = malloc(10 * sizeof (*ptr)); /* without a cast */ ptr = (int *)malloc(10 * sizeof (*ptr)); /* with a cast */ ptr = reinterpret_cast<int *>(malloc(10 * sizeof (*ptr))); /* with a cast, for C++ */
Wednesday, September 18, 2013
How kernel compiler c library work together
http://wiki.osdev.org/How_kernel,_compiler,_and_C_library_work_together
Tuesday, September 17, 2013
Difference between .o and .ko file
http://stackoverflow.com/questions/10476990/difference-between-o-and-ko-file
The short answer is that the .ko file is your
object file linked with some kernel automatically generated data
structures that are needed by the kernel.
The .o file is the object file of your modules - the result of compiling your c files. The kernel build system then automatically creates another C file with some data structures describing the kernel module (named your_module_kmod.c), compile this C file into another object file and links your object file and the object file it built together to create the .ko file.
The dynamic linker in the kernel that is in charge of loading kernel modules, expects to find the data structure the kernel put in the kmod object in the .ko file and will not be able to load your kernel module without them
The .o file is the object file of your modules - the result of compiling your c files. The kernel build system then automatically creates another C file with some data structures describing the kernel module (named your_module_kmod.c), compile this C file into another object file and links your object file and the object file it built together to create the .ko file.
The dynamic linker in the kernel that is in charge of loading kernel modules, expects to find the data structure the kernel put in the kmod object in the .ko file and will not be able to load your kernel module without them
Sunday, September 15, 2013
Disabling the beaglebone black HDMI Cape
mount /dev/mmcblk0p1 /mnt/card
Edit the uEnv.txt on the mounted partition:
nano /mnt/card/uEnv.txt
To disable the HDMI Cape, change the contents of uEnv.txt to:
optargs=quiet capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN
Save the file:
Ctrl-X, Y
Unmount the partition:
umount /mnt/card
Reboot the board:
shutdown -r now
Wait about 10 seconds and reconnect to the BeagleBone Black through SSH. To see what capes are enabled:
cat /sys/devices/bone_capemgr.*/slots
Every line shows something like “P-O-L” or “P-O–”. The letter “L” means
the Cape is enabled; no letter “L” means that it is disabled. You can
see here that the HDMI Cape has been disabled, so pin 27 to 46 on header
P8 are now available to use
http://www.logicsupply.com/blog/2013/07/18/disabling-the-beaglebone-black-hdmi-cape/
Sunday, September 8, 2013
Scope, lifetime and Visability in C
http://www.linuxforu.com/2011/10/joy-of-programming-scope-lifetime-and-visibility-in-c/
There are five scopes in C: program, file, function, block, and prototype.
All non-static functions have program scope, and they can be called from anywhere in the program.
Of course, to make such a call, the function needs to be first declared using extern, before being called, but the point is that it is available throughout the program.
There are three lifetimes in C: static, automatic and dynamic.
Visibility is about the ‘accessibility’ of the declared variables: it arises because of the possibility of variables in outer scope having the same name as the ones in inner scopes, resulting in ‘hiding’.
There are five scopes in C: program, file, function, block, and prototype.
void
foo() {}
// "foo" has program scope
static
void
bar() {
// "bar" has file scope
printf
(
"hello world"
);
int
i;
// "i" has block scope
}
void
baz(
int
j);
// "j" has prototype scope
print:
// "print" has function scope
All non-static functions have program scope, and they can be called from anywhere in the program.
Of course, to make such a call, the function needs to be first declared using extern, before being called, but the point is that it is available throughout the program.
There are three lifetimes in C: static, automatic and dynamic.
Summery of differences
As you can see, scope, lifetime and visibility are related to each other, but are distinct. Scope is about the ‘availability’ of the declared variable: within the same scope, it is not possible to declare/define two variables of the same type with the same name. Lifetime is about the duration in which the variable is ‘alive’: it determines how long the named or unnamed variable has memory allocated to it.Visibility is about the ‘accessibility’ of the declared variables: it arises because of the possibility of variables in outer scope having the same name as the ones in inner scopes, resulting in ‘hiding’.
Function Pointers and Callback in C
http://www.linuxforu.com/2012/02/function-pointers-and-callbacks-in-c-an-odyssey/
http://www.learncpp.com/cpp-tutorial/78-function-pointers/
typedef....
http://www.learncpp.com/cpp-tutorial/78-function-pointers/
typedef....
Using name space and scope
http://stackoverflow.com/questions/223021/whats-the-scope-of-the-using-declaration-in-c
The scope of the using statement depends on where it is located in the code:
http://stackoverflow.com/questions/1677778/why-enclose-blocks-of-c-code-in-curly-braces
http://stackoverflow.com/questions/2759371/in-c-do-braces-act-as-a-stack-frame
- Placed at the top of a file, it has scope throughout that file.
- If this is a header file, it will have scope in all files that include that header. In general, this is "not a good idea" as it can have unexpected side effects
- Otherwise the using statement has scope within the block that contains it from the point it occurs to the end of the block. If it is placed within a method, it will have scope within that method. If it is placed within a class definition it will have scope within that class.
http://stackoverflow.com/questions/1677778/why-enclose-blocks-of-c-code-in-curly-braces
http://stackoverflow.com/questions/2759371/in-c-do-braces-act-as-a-stack-frame
void foo(int[]);
void bar(void);
void foobar(int);
void foobar(int flag) {
if (flag) {
int big[100000000];
foo(big);
}
bar();
}
gives:_foobar:
pushl %ebp
movl %esp, %ebp
movl $400000008, %eax
call __alloca
cmpl $0, 8(%ebp)
je L2
leal -400000000(%ebp), %eax
movl %eax, (%esp)
call _foo
L2:
call _bar
leave
ret