ATK rocks on!

I received a blast-from-the-past email yesterday wanting to know how to format  ATK code for submitting a patch. I was going to simply refer them to the ATK GitHub project I helped create, but then thought I’d better check and see what’s been happening in the project lately (regular readers will be know I’ve been developing with Yii for the past couple year).

I was pleasantly surprised to find the project has been forked, and there’s been a lot of new development supported by the Italian company Sintattica. ATK was originally developed in Belgium, which proves open-source knows no national boundaries!

The new project still has some community relations work to do as the links and developer information in README.md haven’t been updated since forking, and there doesn’t seem to be a public issue tracker, but it seems ATK could be off to a great new beginning. There’s even a new development branch featuring PSR-4 compatibility and a modern class system!

It’s great to see ATK continue as a presence in the rapid web app development space, and it’s rewarding to think my efforts migrating the source from iBuilding’s Subversion repo to GitHub may have helped in some small way. With the buzz that new fad frameworks attract from their fanboyz before fading away, it’s refreshing to see a truly innovative idea continue. Thanks iBuildings and Ivo for starting the project, and thanks Sintattica for your support.

 

TI CCS 6.1.1 and MSPWare MSP-EXP432P401R Example Projects

CCS 6.1.1 included updates to the default MSP432 linker and startup files (copied to a new project created in CCS), but unfortunately it seems the example projects in MSPWare didn’t get the same update.

The fix is simple. After importing an example project into CCS from MSPWare, edit msp432_startup_ccs.c and add “#pragma RETAIN(interruptVectors)” before building and debugging.

Now for the fun bit. If you tried building and debugging BEFORE editing the startup file, you likely loaded crap onto your MSP-EXP432P401R and now it’s bricked (except for “Error -1063” when you try connecting to it from CCS). If that’s the case, perform a factory reset of the MSP-EXP432P401R first to wipe it clean, then load a good build.

Summary of the problem, cause and workaround:  https://e2e.ti.com/support/microcontrollers/msp430/f/166/p/460430/1663082#1663082

How to perform a factory reset: https://e2e.ti.com/support/microcontrollers/msp430/f/166/p/465581/1671110#1671110

 

Open Source Software – Copyright, Trademark and License

I am an engineer, not a lawyer, and this post is not professional advice. Legal documents can be complicated and interpretation may depend on jurisdiction, context and domain. You should consult with a lawyer if the risks and consequences are important to you.

Open source software is a concept that enables software development and support to be shared by a typically non-competitive community. An open source project is more than just code, it is also a community motivated by common goals and bound together by the relationships formed by working collaboratively.

Open source projects use one or more forms of intellectual property (IP) rights protection to protect itself against being taken advantage of. These are copyright, trademark and license. Copyright protects ownership of the software source code, trademark protects the project name and image, and a license protects the project community from liability.

Copyright

Copyright is a legal concept that gives the author of an original work exclusive rights to their work. The copyright for a line of code is generally held by its author (developer), unless it is assigned to someone else. Assignment may be implicit, such as when an employee creates code for an employer (“works for hire”), or explicitly through a formal agreement, such as a Contributor License Agreement (CLA) or Copyright Assignment Agreement (CAA).

Open source projects generally follow one of two options:

  1. Contributors retain individual copyright to their contribution. Author of have an inherent copyright to the code they write, but to limit liability, some projects require contributors to submit a Contributor License Agreement (CLA), which states they have the legal right to provide their work to the project and any conditions they impose (e.g. the license).
  2. Contributors assign their copyright to a legal entity used by the project for that purpose, using either a Contributor License Agreement (CLA) or a Copyright Assignment Agreement (CAA).

Open source projects most commonly follow Option 1, in particular ad hoc projects. As a side-effect, it makes re-licensing almost impossible as it would require explicit consent from all copyright owners. Option 2 is most common when the project uses multiple licenses for different users (e.g. an open source license for some and a proprietary license and revenue opportunity for others), or if the project doesn’t want to preclude potential re-licensing in the future.

Trademark

Trademark law will provide practical protection of the project’s name, so long as the project uses the name in a way that can be trademarked, generally some type of logo. An individual (e.g. the project founder) or a legal organization owns the trademark (which preferably should be registered), and allows for its fair use by creating a Trademark and Logo Policy (e.g. the Drupal Trademark and Logo Policy).

A Trademark and Logo Policy clarifies rights over the use of the project’s identity. Your name and logo are important to your community, and may want to create T-shirts, booth displays at trade shows and conferences, support material for clients, etc., that incorporate the project name and logo. The Trademark and Logo Policy controls their use to the benefit of the project as a whole, and provides a background from which abusers can be legally instructed to stop.

License

Generally, the simpler the better but some projects use different licenses for different things, such as the GPL for code and a Creative Commons license for documentation.

Use a permissive license (e.g. the BSD, Apache or MIT license) if you want the software to be usable by as many people as possible. Use a copy-left license (e.g. GPL or AGPL) if you want to enforce users giving back. Commercial users may be wary of copy-left code in general, as it requires more thorough consideration to ensure the copy-left license won’t be applied to more code than intended once it is integrated.

Recommendations

1. Include a License and Copyright statement in the project source code (e.g. in a README file), and also state prominently on the project website. State the license for the code, and who owns the copyright. Describe any legal requirements for submissions, such as whether a CLA or CAA must be submitted first, and terms assumed to apply to submissions (such as the same license terms as the project). Explicitly say whether the license covers Plug-ins or other extensions.

The GPL is generally understood to apply to Plug-ins, but being explicit will avoid potential misunderstanding or disagreement, clarify the intent of the project and even encourage development (and save you from having to repeatedly answer the question).

2. Include a Trademark and Logo Policy statement in the project souce code (e.g. in a README file), and also state prominently on the project website. State who owns the trademark and/or logo, whether it is registered, and describe what is, and isn’t, considered fair use.

3. Publish a list of open source dependencies (the open source projects that your project depends on), including the license each uses. Make it easy for potential users to evaluate the implications. Ensure each included project identifies its own license in your repository. If needed, work with subordinate projects to help improve their legal clarity as it will benefit both of you.

Related Information

Bob Jacobsen had to regain control over the open source model railroad controller software he had written to clear his name professionally. See FLOSS Weekly Episode 117 and Java Model Railroad Interface (JMRI) in Wikipedia.

Roberto Rosario had to develop Mayan EDMS in a way that would permit GPL licensing when he was as an employee of the Porto Rico government, and also had to deal with an early fork that threatened the project’s future. See FLOSS Weekly Episode 253.

Build a FreeBSD-10 server with Apache, MariaDB, and php using binary packages

It has been traditional for a FreeBSD sysadmin to compile applications from source in the ports tree, but binary packages can now be used for basic needs which saves significant time.

This server is being built for Maestro development. It will be running on my Windows 10 laptop using VirtualBox, although it could just as easily run on bare metal.

Features will include:

  • FreeBSD 10.1-RELEASE Unix-like operating system.
  • Apache 2.4, MariaDB 5.5 and PHP 5.6 AMP stack (using mod_php).
  • Samba 3.6 and rsync (Samba to access Windows file shares as well as share the Maestro file vault to Windows clients, and rsync to synchronize the Maestro file vault to a Windows share).
  • A variety of handy utilities, including git and mdbtools (to import from a Parts&Vendors Jet4 mdb database file).

This post does not include a mail server or gateway, and also will be updated shortly to include infrastructure requirements for Maestro testing (using PHPUnit with Selenium). Maestro is being updated first to use Composer following current best practices, with Composer being used to install PHPUnit. 

Create Virtual Server

Create a new vm and specify BSD OS (FreeBSD) with 256 MB memory and a 20G system drive. Configure the network interface for NAT mode, and forward the IP ports being used from the vm (client) to Windows (host).

HTTPS (secure HTTP) will not be configured at this time. However, it will become the norm in the future.

ssh               host port 2222        client port 22
http              host port 8880        client port 80
mysql-tcp         host port 3336        client port 3306
mysql-udp         host port 3336        client port 3306

Download FreeBSD-10.2-RELEASE-i386.dvd1.iso from FreeBSD.org, boot the vm from the ISO, and perform a standard install (use 64-bit if you prefer, I still tend to create 32-bit virtual machines because I know it works and don’t need the extra address space). I will simply use root to admin the server, and will not create additional users during the install.

After installing the OS and rebooting into the new system, update the system to the latest release if you used an older install ISO, and also update the packages system (pkg, or pkgng in older references).

# freebsd-update upgrade -r 10.2-RELEASE
# freebsd-update install

# pkg update

Edit /etc/rc.conf to specify the hostname and DHCP network config.

hostname="whizzer.swiftconstructioncompany.net"
ifconfig_em0="DHCP"

sshd_enable="YES"
 
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"

Edit /etc/hosts so that necessary hostnames resolve (10.0.2.15 is the default IP address for a VirtualBox vm, substitute if necessary).

I am requiring that the vm never be exposed to the internet by using hostname swiftconstructioncompany.net. A different hostname must be used if the vm will be exposed to the internet.

::1         localhost localhost.local
127.0.0.1   localhost localhost.local
127.0.0.1   localhost localhost.swiftconstructioncompany.net
10.0.2.15   whizzer.swiftconstructioncompany.net whizzer
10.0.2.15   whizzer.swiftconstructioncompany.net.

Edit /etc/ssh/sshd_config to permit remote root login only, and only using an ssh key (a password can still be used at the console if necessary).

AllowUsers root
PermitRootLogin YES
 
PasswordAuthentication no
ChallengeResponseAuthentication no
 
UsePAM yes

Copy root‘s public ssh key to /root/.ssh/authorized_keys and restart sshd.

# service sshd restart

Install Apache and php

The venerated Apache with mod_php will be used, and installing mod_php will first install Apache 2.x as a dependency.

# pkg install mod_php5

Edit /usr/local/etc/apache24/httpd.conf to specify the server name and when to use php.

# ServerAdmin: Your address, where problems with the server should be
ServerAdmin admin@whizzer.swiftconstructioncompany.net

# ServerName gives the name and port that the server uses to identify itself.
ServerName www.swiftconstructioncompany.net:80

# as per message from pkg install mod_php56
<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

Edit /etc/rc.conf to start Apache at boot:

apache24_enable="YES"

Use the provided production PHP configuration file (or use the production file to suppress warnings and errors).

# cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini

Edit php.ini to specify the server timezone.

# add default date timezone
date.timezone = "America/Edmonton"

# uncomment session.save_path
session.save_path = "/tmp"

Confirm that the PHP comnmand line tools were installed correctly (no errors means things are good).

# php -r "phpinfo ( );"

Test the Apache configuration and start Apache.

# service apache24 configtest
# service apache24 start

Test that Apache will serve HTML by browsing http://localhost:8880 to see the default Apache install page.

Test that Apache will execute PHP by displaying the output from phpinfo() in a web page. I like to explicitly configure Apache for each site or page served to avoid the possibility of accidentally creating a security risk. First create /usr/local/www/phpinfo/index.php, the PHP code for the “phpinfo website”.

<?php
 phpinfo();
?>

Next, create an Apache configuration file /usr/local/etc/apache24/Includes/phpinfo.conf.

Alias /phpinfo "/usr/local/www/phpinfo"

<Directory "/usr/local/www/phpinfo">
 Require all granted
</Directory>

Finally restart Apache,

# service apache24 restart

and browse to http://localhost:8880/phpinfo to confirm all is ok.

This post will be updated shortly to include the infrastructure for Maestro testing using PHPUnit and Selenium.

Install MariaDB

Install the MariaDB database server (and the mysql command line client). I haven’t tested Maestro with MariaDB v10.x yet, so will use MariaDB v5.5, which retains full compatibility with MySQL 5.5.

# pkg install mariadb55-server

Use the my-medium.cnf config file:

# cp /usr/local/share/mysql/my-medium.cnf /var/db/mysql/my.cnf

and edit it to default to InnoDB tables:

# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /var/db/mysql
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/db/mysql
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

Install MariaDB’s management database and setup grant tables:

# cd /usr/local/
# mysql_install_db --user=mysql --basedir=/usr/local --basedir=/usr/local --datadir=/var/db/mysql

The –datadir option should not be necessary but must be specified if mysql_install_db cannot determine datadir (aka ldir) correctly.

Edit /etc/rc.conf to start MariaDB at boot.

mysql_enable="YES"

Start MariaDB.

# service mysql-server start

Configure the MariaDB root password:

> mysqladmin -u root password 'appleton'
> mysqladmin -u root -p -h localhost password 'appleton'
> mysqladmin -u root -p -h whizzer.swiftconstructioncompany.net password 'appleton'

If desired, grant root permission to connect remotely (e.g. to connect to MariaDB on the vm directly from the Windows host, or some other “remote” server).

> mysql -u root -p
mysql> grant all privileges on *.* to 'root'@'%' identified by 'appleton' with grant option;
mysql> exit;

Restart MariaDB to read the edited my.cnf file:

# service mysql-server restart

Run mysql_secure_installation as a double-check that all is ok.

# mysql_secure_installation

Install Samba and rsync

The venerable Samba v3 will be used for simple CIFS file sharing.

# pkg install samba3

Create the Maestro share directory.

# mkdir -p /usr/home/maestro
# chmod ugo+w /usr/home/maestro

Edit /usr/local/etc/smb.conf to configure Samba.

#======================= Global Settings =====================
[global]
workgroup = WORKGROUP
server string = Maestro Share
security = share
passdb backend = tdbsam
#======================= Share Definitions =====================
[maestro]
comment = Maestro Share
path = /usr/home/maestro
public = yes
read only = no

Edit /etc/rc.conf to start Samba at boot:

# samba3
samba_enable="YES"
winbindd_enable="YES"

Start Samba:

# service samba start

Install rsync.

# pkg install rsync

Install Utilities

Git

Git is used to clone the Maestro project repository.

Install Git.

# pkg install git

Configure git with your username and email. I prefer plain text without color-coding.

# git config --global user.name "Dale Scott"
# git config --global user.email "dale@dalescott.net"

# git config --global color.ui false
# git config --global color.diff false
# git config --global color.status false
# git config --global color.branch false
# git config --global color.interactive false

mdbtools

mdbtools is used by Maestro export data from Parts&Vendors, which uses a Microsoft Jet v4 database (colloquially called an Access database).

# pkg install mdbtools

flip

flip is useful for converting the occasional pesky Windows-format text file.

# pkg install flip