https://wiki.archlinux.org/api.php?action=feedcontributions&user=PenguinFlavored&feedformat=atomArchWiki - User contributions [en]2024-03-28T15:16:01ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Arduino&diff=32478Arduino2007-11-16T03:54:46Z<p>PenguinFlavored: Added more instructions to the pkgbuild modifications, added arduino package</p>
<hr />
<div>[[Category:Development (English)]]<br />
{{stub}}<br />
===Notice===<br />
This article is in no way complete. I have successfully built the avr toolchain and written and uploaded some sample code to the Arduino. All this information are notes from my memory. I plan to go back, look at my changes, and rebuild the toolchain taking more detailed notes so I can make this page more accurate and complete.<br />
<br />
On that note, feel free to edit this page if you have something to contribute, it needs a lot of work. If you do edit it please let me know what changes you've made.<br />
<br />
-PenguinFlavored<br />
<br />
===Download AUR packages===<br />
* binutils-avr<br />
* gcc-avr<br />
* avr-libc<br />
* avrdude<br />
* arduino<br />
<br />
===Edit the PKGBUILDs===<br />
These packages were last updated about 10-12 months ago in the AUR, so you may have to do some tweaking. I will submit patches to the maintainers while in the process of completing this guide.<br />
<br />
====binutils-avr====<br />
* bump pkgver up to 2.18<br />
* bump pkgrel down to 1<br />
* turn licenses into an array<br />
* add arch=('yourarch')<br />
* change options=(NOSTRIP) to options=(!STRIP)<br />
* generate new md5sums<br />
<br />
====avr-libc====<br />
* bump pkgver up to 1.4.7<br />
* generate new md5sums<br />
* change the license line to license=('BSD')<br />
* add arch=('yourarch')<br />
<br />
====gcc-avr====<br />
* bump pkgver up to 4.2.2<br />
* add c++ to --enable-languages on the ./configure line<br />
../configure --target=avr --prefix=/opt/avr --disable-nls --enable-languages=c,c++ --disable-libssp<br />
* generate new md5sums<br />
<br />
====avrdude====<br />
* bump pkgver up to 5.5<br />
* generate new md5sums<br />
* turn licenses into an array<br />
* generate new md5sums<br />
<br />
====arduino====<br />
* bump pkgver up to 0010<br />
* remove uisp from the depends array and replace it with avrdude<br />
* generate new md5sums<br />
<br />
===Build the packages===<br />
Run makepkg and install the resulting package in this order:<br />
* binutils-avr<br />
* gcc-avr<br />
* avr-libc<br />
* avrdude<br />
* arduino<br />
<br />
===As a user===<br />
Congrats, you've built the toolchain for the AVR microcontroller. Now we need an environment to work in. The Arduino team wrote a nice IDE to write your programs in (aka sketches). I choose not to use this IDE. Instead I opt for my favorite text editor, and Arduino's makefile.<br />
<br />
Set up a directory to program your Arduino. Then download their Makefile[http://www.arduino.cc/en/uploads/Hacking/Makefile]<br />
<br />
You will have to modify this a little bit to reflect your settings. The makefile should be pretty self explainatory. Here are some lines you may have to edit.<br />
<br />
PORT = usually /dev/ttyUSBx, where x is the usb serial port your arduino is plugged into<br />
TARGET = your sketch's name<br />
ARDUINO = /usr/share/arduino/lib/targets/arduino<br />
<br />
Depending on which library functions you call in your sketch, you may need to compile parts of the library. To do that you need to edit your SRC and CXXSRC to include the required libraries.<br />
<br />
Now you should be able to make && make upload to your board to execute your sketch.<br />
<br />
===References===<br />
* http://www.arduino.cc/en/Hacking/CommandLine<br />
* http://bbs.archlinux.org/viewtopic.php?pid=295312<br />
* http://regomodoslinux.blogspot.com/2007/10/how-to-install-arduino-ide-in-archlinux.html</div>PenguinFlavoredhttps://wiki.archlinux.org/index.php?title=Arduino&diff=31874Arduino2007-11-06T17:13:24Z<p>PenguinFlavored: Fixed the category.</p>
<hr />
<div>[[Category:Development (English)]]<br />
{{stub}}<br />
===Notice===<br />
This article is in no way complete. I have successfully built the avr toolchain and written and uploaded some sample code to the Arduino. All this information are notes from my memory. I plan to go back, look at my changes, and rebuild the toolchain taking more detailed notes so I can make this page more accurate and complete.<br />
<br />
On that note, feel free to edit this page if you have something to contribute, it needs a lot of work. If you do edit it please let me know what changes you've made.<br />
<br />
-PenguinFlavored<br />
===Download AUR packages===<br />
* binutils-avr<br />
* gcc-avr<br />
* avr-libc<br />
* avrdude<br />
<br />
===Edit the PKGBUILDs===<br />
These packages were last updated about 10-12 months ago in the AUR, so you may have to do some tweaking. I will submit patches to the maintainers while in the process of completing this guide.<br />
<br />
====binutils-avr====<br />
* bump pkgver up to 2.18<br />
<br />
====avr-libc====<br />
* bump pkgver up to 1.4.7<br />
<br />
====gcc-avr====<br />
* bump pkgver up to 4.2.2<br />
* add c++ to --enable-languages on the ./configure line<br />
../configure --target=avr --prefix=/opt/avr --disable-nls --enable-languages=c,c++ --disable-libssp<br />
<br />
====avrdude====<br />
* bump pkgver up to 5.5<br />
<br />
===Build the packages===<br />
Run makepkg and install the resulting package in this order:<br />
* binutils-avr<br />
* gcc-avr<br />
* avr-libc<br />
* avrdude<br />
<br />
===As a user===<br />
Congrats, you've built the toolchain for the AVR microcontroller. Now we need an environment to work in. The Arduino team wrote a nice IDE to write your programs in (aka sketches). I choose not to use this IDE. Instead I opt for my favorite text editor, and Arduino's makefile.<br />
<br />
Set up a directory to program your Arduino. Then download their Makefile[http://www.arduino.cc/en/uploads/Hacking/Makefile]<br />
<br />
You will have to modify this a little bit to reflect your settings. The makefile should be pretty self explainatory. Here are some lines you may have to edit.<br />
<br />
PORT = usually /dev/ttyUSBx, where x is the usb serial port your arduino is plugged into<br />
TARGET = your sketch's name<br />
ARDUINO = /usr/share/arduino/lib/targets/arduino<br />
<br />
Depending on which library functions you call in your sketch, you may need to compile parts of the library. To do that you need to edit your SRC and CXXSRC to include the required libraries.<br />
<br />
Now you should be able to make && make upload to your board to execute your sketch.<br />
<br />
===References===<br />
* http://www.arduino.cc/en/Hacking/CommandLine<br />
* http://bbs.archlinux.org/viewtopic.php?pid=295312<br />
* http://regomodoslinux.blogspot.com/2007/10/how-to-install-arduino-ide-in-archlinux.html</div>PenguinFlavoredhttps://wiki.archlinux.org/index.php?title=Arduino&diff=31872Arduino2007-11-06T17:10:10Z<p>PenguinFlavored: Initial commit, based on notes in my memory.</p>
<hr />
<div>[[Category: Development]]<br />
{{stub}}<br />
===Notice===<br />
This article is in no way complete. I have successfully built the avr toolchain and written and uploaded some sample code to the Arduino. All this information are notes from my memory. I plan to go back, look at my changes, and rebuild the toolchain taking more detailed notes so I can make this page more accurate and complete.<br />
<br />
On that note, feel free to edit this page if you have something to contribute, it needs a lot of work. If you do edit it please let me know what changes you've made.<br />
<br />
-PenguinFlavored<br />
===Download AUR packages===<br />
* binutils-avr<br />
* gcc-avr<br />
* avr-libc<br />
* avrdude<br />
<br />
===Edit the PKGBUILDs===<br />
These packages were last updated about 10-12 months ago in the AUR, so you may have to do some tweaking. I will submit patches to the maintainers while in the process of completing this guide.<br />
<br />
====binutils-avr====<br />
* bump pkgver up to 2.18<br />
<br />
====avr-libc====<br />
* bump pkgver up to 1.4.7<br />
<br />
====gcc-avr====<br />
* bump pkgver up to 4.2.2<br />
* add c++ to --enable-languages on the ./configure line<br />
../configure --target=avr --prefix=/opt/avr --disable-nls --enable-languages=c,c++ --disable-libssp<br />
<br />
====avrdude====<br />
* bump pkgver up to 5.5<br />
<br />
===Build the packages===<br />
Run makepkg and install the resulting package in this order:<br />
* binutils-avr<br />
* gcc-avr<br />
* avr-libc<br />
* avrdude<br />
<br />
===As a user===<br />
Congrats, you've built the toolchain for the AVR microcontroller. Now we need an environment to work in. The Arduino team wrote a nice IDE to write your programs in (aka sketches). I choose not to use this IDE. Instead I opt for my favorite text editor, and Arduino's makefile.<br />
<br />
Set up a directory to program your Arduino. Then download their Makefile[http://www.arduino.cc/en/uploads/Hacking/Makefile]<br />
<br />
You will have to modify this a little bit to reflect your settings. The makefile should be pretty self explainatory. Here are some lines you may have to edit.<br />
<br />
PORT = usually /dev/ttyUSBx, where x is the usb serial port your arduino is plugged into<br />
TARGET = your sketch's name<br />
ARDUINO = /usr/share/arduino/lib/targets/arduino<br />
<br />
Depending on which library functions you call in your sketch, you may need to compile parts of the library. To do that you need to edit your SRC and CXXSRC to include the required libraries.<br />
<br />
Now you should be able to make && make upload to your board to execute your sketch.<br />
<br />
===References===<br />
* http://www.arduino.cc/en/Hacking/CommandLine<br />
* http://bbs.archlinux.org/viewtopic.php?pid=295312<br />
* http://regomodoslinux.blogspot.com/2007/10/how-to-install-arduino-ide-in-archlinux.html</div>PenguinFlavoredhttps://wiki.archlinux.org/index.php?title=Local_mirror&diff=21705Local mirror2007-03-07T16:35:05Z<p>PenguinFlavored: modified the hosts.allow and vsftpd.conf for correct syntax</p>
<hr />
<div>[[Category:Package management (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
:''This document describes how to create a mirror on your local machine of all the files on the Arch mirrors of the "current" and "extra" directories, how to make it update using cron, how to serve the mirror with vsftpd, and how to set up pacman to use the local mirror.''<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Local Mirror}}<br />
{{i18n_entry|中文(简体)|本地镜像}}<br />
{{i18n_links_end}}<br />
<br />
== Initial Setup ==<br />
<br />
First, let's update and install the necessary tools:<br />
<br />
pacman -Sy rsync vsftpd<br />
<br />
Now, we are going to create a new user (with no login privileges) that will be used for sync operations, and as the user to serve the files with FTP. The name of our user is "mirror" in this example, but you can use any name you want. Do '''not''' use root, or any account that has login access. In order to make this secure, we want to use a user with as few priviliges as possible.<br />
<br />
useradd -m -s /bin/false mirror<br />
<br />
Now, let's get on with setting up the mirror.<br />
<br />
== Creating the local mirror directory ==<br />
We will be using <tt>/home/mirror</tt>, the home directory of our unprivileged user, for storage of the scripts, logs, and packages.<br />
<br />
This guide will sync current, extra, and community. You may also choose to sync testing, unstable, and release.<br />
<br />
The first thing we need to do is create several directories in /home/mirror:<br />
<br />
cd /home/mirror<br />
sudo -u mirror mkdir {scripts,packages,logs}<br />
<br />
== The synchornization script ==<br />
<br />
Now lets create the actual rsync script, <tt>scripts/sync.sh</tt>, using your favorite editor.<br />
<br />
#!/bin/bash<br />
# <br />
# This script is used to sync a local mirror of the Arch Linux repositories.<br />
#<br />
# Copyright (c)2007 Woody Gilk <woody@archlinux.org><br />
# Licensed under the GNU GPL (version 2)<br />
<br />
# Filesystem locations for the sync operations<br />
SYNC_HOME="/home/mirror"<br />
SYNC_LOGS="$SYNC_HOME/logs"<br />
SYNC_PKGS="$SYNC_HOME/packages"<br />
<br />
# This allows you to set which repositories you would like to sync<br />
# Valid options are: current, extra, community, unstable, testing, release<br />
SYNC_REPO=(current extra community)<br />
<br />
# The following line is the format of the log file name, this example will<br />
# output something like this: pkgsync_20070201-8.log<br />
LOG_FILE="pkgsync_$(date +%Y%m%d-%H).log"<br />
<br />
# Do not edit the following lines, they protect the sync from running more than<br />
# one instance at a time.<br />
if [ ! -d $SYNC_HOME ]; then<br />
echo "$SYNC_HOME does not exist, please create it, then run this script again."<br />
exit 1<br />
fi<br />
<br />
SYNC_LOCK="$SYNC_HOME/sync_running.lock"<br />
<br />
[ -f $SYNC_LOCK ] && exit 1<br />
touch "$SYNC_LOCK"<br />
# End of non-editable lines <br />
<br />
# Create the log file and insert a timestamp <br />
touch "$SYNC_LOGS/$LOG_FILE"<br />
echo "==========================================" >> "$SYNC_LOGS/$LOG_FILE"<br />
echo ">> Starting sync on $(date)" >> "$SYNC_LOGS/$LOG_FILE"<br />
echo ">> ---" >> "$SYNC_LOGS/$LOG_FILE"<br />
<br />
# Rsync each of the repos set in $SYNC_REPO<br />
for repo in ${SYNC_REPO[@]}; do<br />
repo=$(echo $repo |tr [:upper:] [:lower:])<br />
echo ">> Syncing $repo to $SYNC_PKGS/$repo" >> "$SYNC_LOGS/$LOG_FILE" <br />
<br />
repourl=$repo<br />
# Only current and extra do not have "ftp/" on the front<br />
[ "$repo" != "extra" -a "$repo" != "current" ] && repourl="ftp/$repourl" && repo=""<br />
<br />
#<br />
# If you only want to mirror 32bit packages, you can add<br />
# " --exclude=os/x86_64" after "--delete"<br />
# <br />
# If you only want to mirror 64bit packages, use "--exclude=os/i686"<br />
# If you want both 32bit and 64bit, leave the following line as it is<br />
#<br />
rsync -rptv --delete rsync.archlinux.org::$repourl "$SYNC_PKGS/$repo" >> "$SYNC_LOGS/$LOG_FILE"<br />
<br />
# If you know of a rsync mirror that is geographically closer to you than archlinux.org<br />
# simply replace ".archlinux.org" with the domain of that mirror in the above line<br />
done<br />
<br />
# Insert another timestamp and close the log file<br />
echo ">> ---" >> "$SYNC_LOGS/$LOG_FILE"<br />
echo ">> Finished sync on $(date)" >> "$SYNC_LOGS/$LOG_FILE"<br />
echo "==========================================" >> "$SYNC_LOGS/$LOG_FILE"<br />
echo " " >> "$SYNC_LOGS/$LOG_FILE"<br />
<br />
# Remove the lock file and exit<br />
rm -f "$SYNC_LOCK"<br />
exit 0<br />
<br />
Nothing terribly fancy here, just a slightly advanced bash script to do what we need. Let's make it executable.<br />
<br />
chmod +x scripts/sync.sh<br />
<br />
That's it, you now have an easily modifiable script. You probably don't want to have to run this manually though, so let's set up a cron job to run this for us.<br />
<br />
One note before we move on to the next step: your logs directory is going to keep growing in size. Make sure that you check it regularly so that it doesn't start overtaking the server with garbage. It is highly recommened that you set up [[LogRotate]] to manage this, or write some kind of cleanup script.<br />
<br />
== Running a cron job ==<br />
<br />
Let's make sure we have the necessary cron tools (most Arch installations will):<br />
<br />
pacman -S dcron<br />
<br />
We will be running our cron job with <tt>crontab</tt>. For more infomation, see <tt>man crontab</tt>. The benefit of running the sync with a crontab is a higher level of security, and not cluttering up <tt>/etc/cron.*</tt> with files. It also allows for a higher level of control for when the script is run.<br />
<br />
Create <tt>scripts/mirror.cron</tt> with the following contents:<br />
<br />
* 3 * * * /home/mirror/scripts/sync.sh<br />
<br />
Now we need to activate our crontab:<br />
<br />
sudo -u mirror crontab scripts/mirror.cron<br />
<br />
Let's make sure that crontab picked up our job:<br />
<br />
sudo -u mirror crontab -l<br />
<br />
You should see the contents of <tt>scripts/mirror.cron</tt> printed out. If not, rerun the previous command and check again.<br />
<br />
This cron setup will run our sync.sh script every night at 3AM. You can adjust this however you want, see http://www.adminschoice.com/docs/crontab.htm for more information on crontab syntax.<br />
<br />
=== Editing the cron job ===<br />
If you ever need to edit <tt>mirror.cron</tt>, use the following command:<br />
<br />
sudo -u mirror crontab -e<br />
<br />
If you you edit the file by hand, use the following command to update crontab:<br />
<br />
sudo -u mirror crontab scripts/mirror.cron<br />
<br />
Now let's set up pacman to use our local mirror.<br />
<br />
== Setting up pacman to use the local mirror ==<br />
<br />
If you only want to access your mirror on one computer, you can use the following steps.<br />
<br />
=== Single machine ===<br />
<br />
You will not need vsftpd for this type of setup, because we are accessing the files via a file:// url, as opposed to a ftp:// url.<br />
<br />
Add the following line to the top of <tt>/etc/pacman.d/current</tt>, at the top of the Servers list:<br />
<br />
Server = file:///home/mirror/packages/current/os/i686<br />
<br />
You should also add this line, substituting <tt>/current/</tt> for the name of the repository you are mirroring (eg: for community, the line should look like this):<br />
<br />
Server = file:///home/mirror/packages/community/os/i686<br />
<br />
Also be sure to change <tt>i686</tt> to <tt>x86_64</tt> if you are using a 64bit version of Arch.<br />
<br />
=== Multiple machines ===<br />
<br />
Syncing this way will allow you to use FTP to access your local mirror from other machines. You can also use this method to sync to your local machine (more details on this later).<br />
<br />
==== FTP server configuration ====<br />
<br />
The first thing we need to do is configure vsftpd. Edit <tt>/etc/vsftpd.conf</tt> to look like this:<br />
<br />
# vsftpd config file /etc/vsftpd.conf<br />
#<br />
# Setup for a secure anonymous FTP server<br />
#<br />
# Listen (non-xinetd) mode<br />
listen=YES<br />
# Use tcp_wrappers to control connections<br />
tcp_wrappers=YES<br />
# Use localtimes instead of GMT for files<br />
use_localtime=YES<br />
# Hide the true user/group ID of files<br />
hide_ids=YES<br />
# <br />
# Enable anonymous access (pacman requires this)<br />
anonymous_enable=YES<br />
# Use this user for anonymous logins<br />
ftp_username=mirror<br />
# Chroot directory for anonymous user<br />
anon_root=/home/mirror/packages<br />
# Don't require a password for anonymous access (pacman requires this)<br />
no_anon_password=YES<br />
#<br />
# User to run vsftpd as (same as ftp_username)<br />
nopriv_user=mirror<br />
# Enable recursive "ls" listing<br />
ls_recurse_enable=YES<br />
#<br />
# Forcefully destroy sessions after X seconds of inactivity <br />
# (It is highly recommended to not set this above 300)<br />
idle_session_timeout=120<br />
# Forcefully stop sending data after X seconds of inactivity during a transfer<br />
# (It is highly recommended to not set this higher than idle_session_timeout)<br />
data_connection_timeout=30<br />
<br />
This setup will offer a very secure FTP server, tailored specifically for our needs. Note that this setup does '''not''' require a password, and should not be used in a publically accessible network (unless that's what you want). ''Password protecting the FTP and still allowing it to work with pacman is beyond the scope of this document.''<br />
<br />
If you are going to connecting to this machine from the outside, you will need to add the following line to <tt>/etc/hosts.allow</tt>:<br />
<br />
vsftpd : ALL : ALL<br />
<br />
Note that this will allow '''anyone''' to download from the mirror. If you want to control downloads more tightly, and don't know how to do so, see [http://linux.about.com/od/commands/l/blcmdl5_hostsal.htm see linux.about.com] on the subject.<br />
<br />
Let's make sure vsftpd starts:<br />
<br />
sudo /etc/rc.d/vsftpd start<br />
<br />
If vsftpd does not start, check that the options are set correctly in your <tt>/etc/vsftpd.conf</tt> file.<br />
<br />
==== Enabling the mirror for pacman ====<br />
<br />
Now let's edit <tt>/etc/pacman.d/*</tt> files to use our shiny new mirror. Add the following line to the top of <tt>/etc/pacman.d/current</tt>, at the top of the Servers list:<br />
<br />
Server = ftp://192.168.1.21/current/os/i686<br />
<br />
Note that <tt>192.168.1.21</tt> is the IP address of my test machine. Your address will most likely be different. (Remember that you can get the current IP of an Arch box with <tt>ifconfig -a</tt> or <tt>ifconfig eth0</tt>.)<br />
<br />
If you want to use this same mirror on the local machine, use the following Server line:<br />
<br />
Server = ftp://localhost/current/os/i686<br />
<br />
Repeat this same process for the other repositories you are mirroring. Non-local machines will need to use an IP address to access the repository. Also make sure that the machine serving the mirror has a static IP address.<br />
<br />
== Synchronizing for the first time ==<br />
<br />
Here comes the pain! Run the following command to start the sync:<br />
<br />
sudo -u mirror ./scripts/sync.sh<br />
<br />
This won't give you any kind of output, but you probably want some. You can use something like this (correct for the name of log file) to monitor sync:<br />
<br />
tail -f logs/pkgsync_20070203-9.log<br />
<br />
This process will usually take a few hours, depending on the speed of your internet connection and how many repositories you are mirroring. After the first sync, only new packages will be sync'ed, so it will be much faster.<br />
<br />
Wait for the first sync to finish, then run <tt>pacman -Sy</tt> to make sure that your new mirrors are syncing properly.<br />
<br />
That's it! You now a local mirror which will offer you massively improved speeds when updating your packages.<br />
<br />
== Notes ==<br />
<br />
First version of this guide was written by busfahrer. He can be reached at [ArchChannel|#archlinux]] on irc.freenode.net.<br />
<br />
Second version of this guide was written by Shadowhand. He can be reached at [ArchChannel|#archlinux]] on irc.freenode.net.<br />
<br />
Comments and suggestions are always appreciated.<br />
<br />
=== License ===<br />
<br />
This document is released under the [http://www.gnu.org/licenses/fdl.txt GFDL].<br />
<br />
=== Related topics ===<br />
<br />
To go further, try [[Howto_Upgrade_via_Home_Network | this]].</div>PenguinFlavoredhttps://wiki.archlinux.org/index.php?title=User:PenguinFlavored&diff=19303User:PenguinFlavored2006-12-30T01:04:57Z<p>PenguinFlavored: First edit</p>
<hr />
<div>== Jesse Young ==<br />
I've been an Arch User for a couple years now, and I want to help out the community. I think I've found my home distro in Arch, and I'm really happy with it.<br />
<br />
Visit [http://www.iit.edu/~jyoung13 my site]</div>PenguinFlavored