From 1d99c38a7262c03de2151599e9690d290f35b50a Mon Sep 17 00:00:00 2001 From: Kevin Redon Date: Sun, 2 Mar 2014 18:40:00 +0100 Subject: [PATCH] moved all to hardware subfolder --- hardware/.gitignore | 17 +++ hardware/CHANGES.txt | 0 hardware/LICENSE.txt | 189 +++++++++++++++++++++++++ hardware/PRODUCT.txt | 0 hardware/Rakefile | 218 +++++++++++++++++++++++++++++ hardware/gafrc | 4 + hardware/gschemrc | 3 + hardware/lib/footprints/.gitignore | 1 + hardware/lib/symbols/.gitignore | 1 + hardware/name | 0 hardware/version | 0 11 files changed, 433 insertions(+) create mode 100644 hardware/.gitignore create mode 100644 hardware/CHANGES.txt create mode 100644 hardware/LICENSE.txt create mode 100644 hardware/PRODUCT.txt create mode 100644 hardware/Rakefile create mode 100644 hardware/gafrc create mode 100644 hardware/gschemrc create mode 100644 hardware/lib/footprints/.gitignore create mode 100644 hardware/lib/symbols/.gitignore create mode 100644 hardware/name create mode 100644 hardware/version diff --git a/hardware/.gitignore b/hardware/.gitignore new file mode 100644 index 0000000..6b9ad63 --- /dev/null +++ b/hardware/.gitignore @@ -0,0 +1,17 @@ +TODO +*_v*.*.sch +*_v*.*.pcb +*.pdf +*.png +*~ +\#*.sch\# +attribs +notes.txt +*.net +*.cmd +*.new.pcb +*.pcb- +*.pcb.bak +*.gbr +*.cnc +hardware-release*.tar.* diff --git a/hardware/CHANGES.txt b/hardware/CHANGES.txt new file mode 100644 index 0000000..e69de29 diff --git a/hardware/LICENSE.txt b/hardware/LICENSE.txt new file mode 100644 index 0000000..6e2467a --- /dev/null +++ b/hardware/LICENSE.txt @@ -0,0 +1,189 @@ +CERN Open Hardware Licence v1.2 + +Preamble + +Through this CERN Open Hardware Licence ("CERN OHL") version 1.2, CERN +wishes to provide a tool to foster collaboration and sharing among +hardware designers. The CERN OHL is copyright CERN. Anyone is welcome +to use the CERN OHL, in unmodified form only, for the distribution of +their own Open Hardware designs. Any other right is reserved. Release +of hardware designs under the CERN OHL does not constitute an +endorsement of the licensor or its designs nor does it imply any +involvement by CERN in the development of such designs. + +1. Definitions + +In this Licence, the following terms have the following meanings: + +“Licence” means this CERN OHL. + +“Documentation” means schematic diagrams, designs, circuit or circuit +board layouts, mechanical drawings, flow charts and descriptive text, +and other explanatory material that is explicitly stated as being made +available under the conditions of this Licence. The Documentation may +be in any medium, including but not limited to computer files and +representations on paper, film, or any other media. + +“Documentation Location” means a location where the Licensor has +placed Documentation, and which he believes will be publicly +accessible for at least three years from the first communication to +the public or distribution of Documentation. + +“Product” means either an entire, or any part of a, device built using +the Documentation or the modified Documentation. + +“Licensee” means any natural or legal person exercising rights under +this Licence. + +“Licensor” means any natural or legal person that creates or modifies +Documentation and subsequently communicates to the public and/ or +distributes the resulting Documentation under the terms and conditions +of this Licence. + +A Licensee may at the same time be a Licensor, and vice versa. + +Use of the masculine gender includes the feminine and neuter genders +and is employed solely to facilitate reading. + +2. Applicability + +2.1. This Licence governs the use, copying, modification, +communication to the public and distribution of the Documentation, and +the manufacture and distribution of Products. By exercising any right +granted under this Licence, the Licensee irrevocably accepts these +terms and conditions. + +2.2. This Licence is granted by the Licensor directly to the Licensee, +and shall apply worldwide and without limitation in time. The Licensee +may assign his licence rights or grant sub-licences. + +2.3. This Licence does not extend to software, firmware, or code +loaded into programmable devices which may be used in conjunction with +the Documentation, the modified Documentation or with Products, unless +such software, firmware, or code is explicitly expressed to be subject +to this Licence. The use of such software, firmware, or code is +otherwise subject to the applicable licence terms and conditions. + +3. Copying, modification, communication to the public and distribution +of the Documentation + +3.1. The Licensee shall keep intact all copyright and trademarks +notices, all notices referring to Documentation Location, and all +notices that refer to this Licence and to the disclaimer of warranties +that are included in the Documentation. He shall include a copy +thereof in every copy of the Documentation or, as the case may be, +modified Documentation, that he communicates to the public or +distributes. + +3.2. The Licensee may copy, communicate to the public and distribute +verbatim copies of the Documentation, in any medium, subject to the +requirements specified in section 3.1. + +3.3. The Licensee may modify the Documentation or any portion thereof +provided that upon modification of the Documentation, the Licensee +shall make the modified Documentation available from a Documentation +Location such that it can be easily located by an original Licensor +once the Licensee communicates to the public or distributes the +modified Documentation under section 3.4, and, where required by +section 4.1, by a recipient of a Product. However, the Licensor shall +not assert his rights under the foregoing proviso unless or until a +Product is distributed. + +3.4. The Licensee may communicate to the public and distribute the +modified Documentation (thereby in addition to being a Licensee also +becoming a Licensor), always provided that he shall: + +a) comply with section 3.1; + +b) cause the modified Documentation to carry prominent notices stating +that the Licensee has modified the Documentation, with the date and +description of the modifications; + +c) cause the modified Documentation to carry a new Documentation +Location notice if the original Documentation provided for one; + +d) make available the modified Documentation at the same level of +abstraction as that of the Documentation, in the preferred format for +making modifications to it (e.g. the native format of the CAD tool as +applicable), and in the event that format is proprietary, in a format +viewable with a tool licensed under an OSI-approved license if the +proprietary tool can create it; and + +e) license the modified Documentation under the terms and conditions +of this Licence or, where applicable, a later version of this Licence +as may be issued by CERN. + +3.5. The Licence includes a non-exclusive licence to those patents or +registered designs that are held by, under the control of, or +sub-licensable by the Licensor, to the extent necessary to make use of +the rights granted under this Licence. The scope of this section 3.5 +shall be strictly limited to the parts of the Documentation or +modified Documentation created by the Licensor. + +4. Manufacture and distribution of Products + +4.1. The Licensee may manufacture or distribute Products always +provided that, where such manufacture or distribution requires a +licence under this Licence the Licensee provides to each recipient of +such Products an easy means of accessing a copy of the Documentation +or modified Documentation, as applicable, as set out in section 3. + +4.2. The Licensee is invited to inform any Licensor who has indicated +his wish to receive this information about the type, quantity and +dates of production of Products the Licensee has (had) manufactured + +5. Warranty and liability + +5.1. DISCLAIMER – The Documentation and any modified Documentation are +provided "as is" and any express or implied warranties, including, but +not limited to, implied warranties of merchantability, of satisfactory +quality, non-infringement of third party rights, and fitness for a +particular purpose or use are disclaimed in respect of the +Documentation, the modified Documentation or any Product. The Licensor +makes no representation that the Documentation, modified +Documentation, or any Product, does or will not infringe any patent, +copyright, trade secret or other proprietary right. The entire risk as +to the use, quality, and performance of a Product shall be with the +Licensee and not the Licensor. This disclaimer of warranty is an +essential part of this Licence and a condition for the grant of any +rights granted under this Licence. The Licensee warrants that it does +not act in a consumer capacity. + +5.2. LIMITATION OF LIABILITY – The Licensor shall have no liability +for direct, indirect, special, incidental, consequential, exemplary, +punitive or other damages of any character including, without +limitation, procurement of substitute goods or services, loss of use, +data or profits, or business interruption, however caused and on any +theory of contract, warranty, tort (including negligence), product +liability or otherwise, arising in any way in relation to the +Documentation, modified Documentation and/or the use, manufacture or +distribution of a Product, even if advised of the possibility of such +damages, and the Licensee shall hold the Licensor(s) free and harmless +from any liability, costs, damages, fees and expenses, including +claims by third parties, in relation to such use. + +6. General + +6.1. Except for the rights explicitly granted hereunder, this Licence +does not imply or represent any transfer or assignment of intellectual +property rights to the Licensee. + +6.2. The Licensee shall not use or make reference to any of the names +(including acronyms and abbreviations), images, or logos under which +the Licensor is known, save in so far as required to comply with +section 3. Any such permitted use or reference shall be factual and +shall in no event suggest any kind of endorsement by the Licensor or +its personnel of the modified Documentation or any Product, or any +kind of implication by the Licensor or its personnel in the +preparation of the modified Documentation or Product. + +6.3. CERN may publish updated versions of this Licence which retain +the same general provisions as this version, but differ in detail so +far this is required and reasonable. New versions will be published +with a unique version number. + +6.4. This Licence shall terminate with immediate effect, upon written +notice and without involvement of a court if the Licensee fails to +comply with any of its terms and conditions, or if the Licensee +initiates legal action against Licensor in relation to this +Licence. Section 5 shall continue to apply. diff --git a/hardware/PRODUCT.txt b/hardware/PRODUCT.txt new file mode 100644 index 0000000..e69de29 diff --git a/hardware/Rakefile b/hardware/Rakefile new file mode 100644 index 0000000..0219c71 --- /dev/null +++ b/hardware/Rakefile @@ -0,0 +1,218 @@ +require 'rake/clean' + +# ================= +# project variables +# ================= + +# main name used if filename +target = IO.read("name").split("\n")[0] +raise "define project name in 'name' file" unless target +# schema +sch = "#{target}.sch" +# pcb layout +pcb = "#{target}.pcb" +# project version, read from "version" file +version = IO.read("version").split("\n")[0] +raise "define project version in 'version' file" unless version +# current date for stamping output +date = Time.now.strftime("%Y-%m-%d") +# schematic revision, based on the number of schematic commits) +sch_rev = `git log --pretty=oneline "#{sch}" | wc -l`.chomp.to_i +# pcb layout revision, based on the number of pcb commits) +pcb_rev = `git log --pretty=oneline "#{pcb}" | wc -l`.chomp.to_i +# schema name with version and revition +vsch = "#{target}_v#{version}.#{sch_rev.to_s.rjust(3,'0')}.sch" +# pcb layout name with version and revition +vpcb = "#{target}_v#{version}.#{pcb_rev.to_s.rjust(3,'0')}.pcb" + +# ========== +# main tasks +# ========== + +desc "main building task" +task :default => [:version,:print,:notes,:photo,:gerber] + +desc "create release file" +task :release => "hardware-release_v#{version}.tar.gz" +CLOBBER.include("hardware-release_v#{version}.tar.gz") + +desc "set version in schematic and layout" +task :version => [vsch,vpcb] +CLEAN.include(vsch) +CLEAN.include(vpcb) +CLOBBER.include("#{target}_*.sch") +CLOBBER.include("#{target}_*.pcb") + +desc "print schematic and layout (as pdf)" +task :print => ["#{target}_schematic.pdf","#{target}_layout.pdf"] +CLEAN.include("#{target}_schematic.pdf") +CLEAN.include("#{target}_layout.pdf") + +desc "export notes from schematic" +task :notes => "notes.txt" +CLOBBER.include("notes.txt") + +desc "verify schematic attributes" +task :verify => vsch do |t| + ["value","footprint"].each do |attribute| + bom2(t.prerequisites[0],attribute).each do |data| + next unless data[attribute]=="unknown" + puts "#{attribute}s not defined for #{data[:refdes]*','}" + end + end + uniq = true + numbered = true + bom2(t.prerequisites[0],"refdes").each do |data| + uniq &= data[:refdes].size==1 + numbered &= !data["refdes"].include?("?") + end + puts "not all refdes uniq" unless uniq + puts "not all refdes numbered" unless numbered +end + +desc "convert schematic to pcb layout" +task :sch2pcb => vsch do |t| + sh "gsch2pcb #{t.prerequisites[0]} --elements-dir #{File.dirname(__FILE__)}/lib/footprints --skip-m4 --output-name #{target}" +end + +PHOTOS = ["#{target}_layout-top.png","#{target}_layout-bottom.png"] +desc "render layout" +task :photo => PHOTOS +CLOBBER.include(PHOTOS) + +GERBERS = [".top.gbr",".topmask.gbr",".toppaste.gbr",".topsilk.gbr",".bottom.gbr",".bottommask.gbr",".bottompaste.gbr",".bottomsilk.gbr",".outline.gbr",".fab.gbr",".plated-drill.cnc",".unplated-drill.cnc"].collect{|suffix| target+suffix} +desc "export gerber" +task :gerber => GERBERS +CLOBBER.include(GERBERS) + +desc "reformat gerber and drill output (some programs like LPKF CircuitPro have difficulties with gEDA pcb output)" +task :reformat => GERBERS do + GERBERS.each do |gerber| + if gerber.end_with? ".gbr" then + sh "gerbv --export=rs274x --output=#{gerber} #{gerber}" + elsif gerber.end_with? ".cnc" then + sh "gerbv --export=drill --output=#{gerber} #{gerber}" + end + end +end + +# ================ +# helper functions +# ================ + +# generate gnetlist bom2 and parse them +# arguments: schematic=schematic to usse, attributes=the attributs to use for generating bom2 +# return [{:refdes => [refdes of component], => text of attributes}] +def bom2(schematic, attributes) + to_return = [] + # force attributes to be an array + attributes = case attributes.class + when String + [attributes] + when Array + attributes + else + [attributes.to_s] + end + # create gnetlist backend + File.open("attribs","w") do |attribs| + attributes.each do |attribute| + attribs.puts attribute + end + end + # generate bom2 + list = `gnetlist -g bom2 -q -o - #{schematic}` + # parse bom2 + regex = /^(?(\w+,?)+):(?.*):(?\d+)$/ + list.each_line do |line| + next unless line =~ regex + data = line.match regex + hash = {refdes: data[:refdes].split(',')} + attributes.each_index do |i| + hash.merge!({attributes[i] => data[:attributes].split(':')[i]}) + end + to_return << hash + end + return to_return +end +CLEAN.include("attribs") + +# =============== +# file generation +# =============== + +desc "copy schematic to version it: include version, revision, and date" +file vsch => sch do |t| + sh "cp #{t.prerequisites.join(' ')} #{t.name}" + # on \ is to prevent ruby interpreting it, th other is for sed + # the version + sh "sed -i 's/\\(version=\\)\\$Version\\$/\\1#{version}/' #{t.name}" + # the date + sh "sed -i 's/\\(date=\\)\\$Date\\$/\\1#{date}/' #{t.name}" + # the revision + sh "sed -i 's/\\(revision=\\)\\$Revision\\$/\\1#{sch_rev}/' #{t.name}" +end + +desc "copy layout to version it: include version, date, and run teardrops when available" +file vpcb => pcb do |t| + sh "cp #{t.prerequisites.join(' ')} #{t.name}" + # on \ is to prevent ruby interpreting it, th other is for sed + # the version and revision + version_revision = "v#{version}.#{pcb_rev.to_s.rjust(3,'0')}" + sh "sed -i 's/\\$version\\$/#{version_revision}/' #{t.name}" + # the date + sh "sed -i 's/\\$date\\$/#{date}/' #{t.name}" + # run teardrop for vias and pins + if File.exist? "#{Dir.home}/.pcb/plugins/teardrops.so" then + sh "pcb --action-string \"djopt(splitlines) Teardrops() s() q()\" #{t.name}" + end +end + +desc "generate printable version (PDF) of schematic" +file "#{target}_schematic.pdf" => vsch do |t| + sh "gaf export -f pdf -c -o #{t.name} #{t.prerequisites.join(' ')} 2> /dev/null" +end + +desc "generate printable documentation (PDF) from layout" +file "#{target}_layout.pdf" => vpcb do |t| + sh "pcb -x ps --psfile #{t.name}.ps #{t.prerequisites.join(' ')} 2> /dev/null" + sh "ps2pdf #{t.name}.ps #{t.name} 2> /dev/null" + sh "rm #{t.name}.ps 2> /dev/null" +end + +desc "generate note file from schematic, listing the 'note' attributes from elements" +file "notes.txt" => vsch do |t| + notes_data = bom2(t.prerequisites[0],"note") + File.open(t.name,"w") do |notes_file| + notes_data.each do |note| + next if note["note"]=="unknown" + notes_file.puts "#{note[:refdes]*','}:\n#{note["note"]}\n\n" + end + end +end + +desc "generate photo realistic picture from layout (front side)" +file "#{target}_layout-top.png" => vpcb do |t| +# sh "pcb -x png --dpi 600 --format PNG --photo-mode --outfile #{target}_layout-top.png #{t.prerequisites.join(' ')}" + sh "pcb -x png --format PNG --photo-mode --outfile #{target}_layout-top.png #{t.prerequisites.join(' ')}" +end + +desc "generate photo realistic picture from layout (bottom side)" +file "#{target}_layout-bottom.png" => vpcb do |t| +# sh "pcb -x png --dpi 600 --format PNG --photo-mode --photo-flip-x --outfile #{target}_layout-bottom.png #{t.prerequisites.join(' ')}" + sh "pcb -x png --format PNG --photo-mode --photo-flip-x --outfile #{target}_layout-bottom.png #{t.prerequisites.join(' ')}" +end + +desc "export gerber (and drill) files from layout" +GERBERS.each do |gerber| + file gerber => vpcb do |t| + puts "make #{t.name}" + sh "pcb -x gerber --gerberfile #{target} --all-layers #{t.prerequisites.join(' ')}" + end +end + +ATTACHMENTS = ["cern_ohl_v_1_2_howto.pdf","CHANGES.txt","LICENSE.txt","PRODUCT.txt"] +desc "create archive with release files" +file "hardware-release_v#{version}.tar.gz" => ATTACHMENTS+["lib",vsch,vpcb,"notes.txt","#{target}_schematic.pdf","#{target}_layout.pdf","#{target}_layout-top.png","#{target}_layout-bottom.png"]+GERBERS do |t| + sh "tar -acf '#{t.name}' #{t.prerequisites.join(' ')}" +end diff --git a/hardware/gafrc b/hardware/gafrc new file mode 100644 index 0000000..d5ca56c --- /dev/null +++ b/hardware/gafrc @@ -0,0 +1,4 @@ +; .sch gEDA configuration file +(define library "lib") +(component-library (build-path library "symbols")) +(component-library (build-path library "footprints")) diff --git a/hardware/gschemrc b/hardware/gschemrc new file mode 100644 index 0000000..7de188d --- /dev/null +++ b/hardware/gschemrc @@ -0,0 +1,3 @@ +; gschem configuration file +(paper-size 11.69 8.27) ; A4 +;(output-color "enabled") ; for color postscript output (black background) diff --git a/hardware/lib/footprints/.gitignore b/hardware/lib/footprints/.gitignore new file mode 100644 index 0000000..6bad313 --- /dev/null +++ b/hardware/lib/footprints/.gitignore @@ -0,0 +1 @@ +*.fp- diff --git a/hardware/lib/symbols/.gitignore b/hardware/lib/symbols/.gitignore new file mode 100644 index 0000000..aa28541 --- /dev/null +++ b/hardware/lib/symbols/.gitignore @@ -0,0 +1 @@ +\#*.sym\# diff --git a/hardware/name b/hardware/name new file mode 100644 index 0000000..e69de29 diff --git a/hardware/version b/hardware/version new file mode 100644 index 0000000..e69de29